resolve: #119 AsciiDoc support

This commit is contained in:
xiangyu 2022-08-24 10:53:57 +08:00
parent 87ca3ac23a
commit eedc6bb9b6
7 changed files with 33 additions and 1 deletions

View File

@ -41,6 +41,7 @@
<command id="cmd_updatelink_betternotes" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'updateLink'});" /> -->
<command id="cmd_autoannotation_betternotes" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'updateAutoAnnotation'});" />
<command id="cmd_convertmd_betternotes" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'convertMD'});" />
<command id="cmd_convertasciidoc_betternotes" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'convertAsciiDoc'});" />
<command id="cmd_treeview_betternotes" oncommand="Zotero.Knowledge4Zotero.views.switchView(1);" />
<command id="cmd_mindmap_betternotes" oncommand="Zotero.Knowledge4Zotero.views.switchView(2);" />
<command id="cmd_bubblemap_betternotes" oncommand="Zotero.Knowledge4Zotero.views.switchView(3);" />
@ -89,6 +90,7 @@
<menuitem id="menu_autoannotation_betternotes" class="menu-betternotes" type="checkbox" label="&zotero.__addonRef__.workspace.menu.autoannotation;" command="cmd_autoannotation_betternotes" />
<menuseparator class="menu-betternotes" />
<menuitem id="menu_convertmd_betternotes" class="menu-betternotes" label="&zotero.__addonRef__.workspace.menu.convertmd;" command="cmd_convertmd_betternotes" />
<menuitem id="menu_convertasciidoc_betternotes" class="menu-betternotes" label="&zotero.__addonRef__.workspace.menu.convertasciidoc;" command="cmd_convertasciidoc_betternotes" />
<menuseparator class="menu-betternotes" />
</menupopup>

View File

@ -50,6 +50,7 @@
<command id="cmd_updatelink_betternotes" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'updateLink'});" /> -->
<command id="cmd_autoannotation_betternotes" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'updateAutoAnnotation', content: {event: event}});" />
<command id="cmd_convertmd_betternotes" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'convertMD'});" />
<command id="cmd_convertasciidoc_betternotes" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'convertAsciiDoc'});" />
<command id="cmd_treeview" oncommand="Zotero.Knowledge4Zotero.views.switchView(1);" />
<command id="cmd_mindmap" oncommand="Zotero.Knowledge4Zotero.views.switchView(2);" />
<command id="cmd_bubblemap" oncommand="Zotero.Knowledge4Zotero.views.switchView(3);" />
@ -95,6 +96,7 @@
<menuitem id="menu_autoannotation_betternotes" type="checkbox" label="&zotero.__addonRef__.workspace.menu.autoannotation;" command="cmd_autoannotation_betternotes" />
<menuseparator />
<menuitem id="menu_convertmd_betternotes" label="&zotero.__addonRef__.workspace.menu.convertmd;" command="cmd_convertmd_betternotes" />
<menuitem id="menu_convertasciidoc_betternotes" class="menu-betternotes" label="&zotero.__addonRef__.workspace.menu.convertasciidoc;" command="cmd_convertasciidoc_betternotes" />
</menupopup>
</menu>

View File

@ -18,7 +18,8 @@
<!ENTITY zotero.__addonRef__.workspace.menu.importLink "Import Selected Note Link Content">
<!ENTITY zotero.__addonRef__.workspace.menu.updateLink "Update Selected Note Link Text">
<!ENTITY zotero.__addonRef__.workspace.menu.autoannotation "Auto Insert New Annotations to Note">
<!ENTITY zotero.__addonRef__.workspace.menu.convertmd "Convert MarkDown In Clipboard">
<!ENTITY zotero.__addonRef__.workspace.menu.convertmd "Convert MarkDown in Clipboard">
<!ENTITY zotero.__addonRef__.workspace.menu.convertasciidoc "Convert AsciiDoc in Clipboard">
<!ENTITY zotero.__addonRef__.workspace.menu.treeview "Outline: Tree View">
<!ENTITY zotero.__addonRef__.workspace.menu.mindmap "Outline: Mind Map">
<!ENTITY zotero.__addonRef__.workspace.menu.bubblemap "Outline: Bubble Map">

View File

@ -19,6 +19,7 @@
<!ENTITY zotero.__addonRef__.workspace.menu.updateLink "更新选中的笔记链接文本">
<!ENTITY zotero.__addonRef__.workspace.menu.autoannotation "自动插入新注释到笔记">
<!ENTITY zotero.__addonRef__.workspace.menu.convertmd "转换剪贴板中的MarkDown内容">
<!ENTITY zotero.__addonRef__.workspace.menu.convertasciidoc "转换剪贴板中的AsciiDoc内容">
<!ENTITY zotero.__addonRef__.workspace.menu.treeview "大纲: 树视图">
<!ENTITY zotero.__addonRef__.workspace.menu.mindmap "大纲: 思维导图">
<!ENTITY zotero.__addonRef__.workspace.menu.bubblemap "大纲: 气泡导图">

View File

@ -28,6 +28,7 @@
"dependencies": {
"@syncfusion/ej2-base": "^20.1.50",
"@syncfusion/ej2-navigations": "^20.1.51",
"asciidoctor": "^2.2.6",
"compressing": "^1.5.1",
"esbuild": "^0.14.34",
"replace-in-file": "^6.3.2",

View File

@ -1798,6 +1798,26 @@ class AddonEvents extends AddonBase {
"Better Notes",
"Converted MarkDown is updated to the clipboard. You can paste them in the note."
);
} else if (message.type == "convertAsciiDoc") {
/*
message.content = {}
*/
const source = Zotero.Utilities.Internal.getClipboard("text/unicode");
if (!source) {
this._Addon.views.showProgressWindow(
"Better Notes",
"No AsciiDoc found."
);
return;
}
const html = this._Addon.parse.parseAsciiDocToHTML(source);
console.log(source, html);
new CopyHelper().addText(html, "text/html").copy();
this._Addon.views.showProgressWindow(
"Better Notes",
"Converted AsciiDoc is updated to the clipboard. You can paste them in the note."
);
} else {
Zotero.debug(`Knowledge4Zotero: message not handled.`);
}

View File

@ -1,6 +1,7 @@
import { AddonBase } from "./base";
import { HTML2Markdown, Markdown2HTML } from "./convertMD";
const TreeModel = require("./treemodel");
const asciidoctor = require("asciidoctor")();
class AddonParse extends AddonBase {
public parseNoteTree(note: ZoteroItem): TreeModel.Node<object> {
@ -424,6 +425,10 @@ class AddonParse extends AddonBase {
parseHTMLToMD(str: string): string {
return HTML2Markdown(str);
}
parseAsciiDocToHTML(str: string): string {
return asciidoctor.convert(str);
}
}
export default AddonParse;