Skip to content

Commit

Permalink
feat: note templates
Browse files Browse the repository at this point in the history
fix: #22 mac export image bug
  • Loading branch information
xiangyu committed May 19, 2022
1 parent addab7b commit 677d0f6
Show file tree
Hide file tree
Showing 13 changed files with 525 additions and 13 deletions.
2 changes: 1 addition & 1 deletion addon/chrome/content/export.xul
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
%knowledgeDTD;
]>

<dialog id="zotero-select-items-dialog" windowtype="knowledge-export" title="&zotero.__addonRef__.export.title;" orient="vertical" width="300" height="300" buttons="cancel,accept" ondialogaccept="Zotero.Knowledge4Zotero.export.doAccept();" onload="Zotero.Knowledge4Zotero.export.doLoad(window);" onunload="Zotero.Knowledge4Zotero.export.doUnload();" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" style="padding:2em" persist="screenX screenY width height">
<dialog id="betternotes-export-dialog" windowtype="betternotes-export" title="&zotero.__addonRef__.export.title;" orient="vertical" width="300" height="300" buttons="cancel,accept" ondialogaccept="Zotero.Knowledge4Zotero.export.doAccept();" onload="Zotero.Knowledge4Zotero.export.doLoad(window);" onunload="Zotero.Knowledge4Zotero.export.doUnload();" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" style="padding:2em" persist="screenX screenY width height">
<script src="chrome://zotero/content/include.js" />
<box flex="1">
<rows flex="1">
Expand Down
59 changes: 59 additions & 0 deletions addon/chrome/content/template.xul
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/standalone.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero-platform/content/overlay.css"?>

<!DOCTYPE window [
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
%globalDTD;
<!ENTITY % standaloneDTD SYSTEM "chrome://zotero/locale/standalone.dtd">
%standaloneDTD;
<!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd">
%zoteroDTD;
<!ENTITY % knowledgeDTD SYSTEM "chrome://__addonRef__/locale/overlay.dtd">
%knowledgeDTD;
]>

<window id="zotero-knowledge-template-editor" onload="Zotero.Knowledge4Zotero.template.initTemplates(window);" orient="vertical" width="600" height="350" title="&zotero.__addonRef__.template.title;" persist="screenX screenY width height" windowtype="zotero:knowledgeTemplateEditor" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
<script src="chrome://zotero/content/include.js" />

<keyset>
<key id="key_save" key="S" modifiers="accel" command="cmd_save" />
<key id="key_close" key="W" modifiers="accel" command="cmd_close" />
</keyset>
<command id="cmd_save" oncommand="Zotero.Knowledge4Zotero.template.saveSelectedTemplate();" />
<command id="cmd_close" oncommand="window.close();" />

<hbox flex="1">
<vbox id="template-container" flex="1" minwidth="200px">
<listbox id="template-list" flex="1" seltype="single" onselect="Zotero.Knowledge4Zotero.template.updateEditorView();">
<listhead>
<listheader id="name" label="&zotero.__addonRef__.template.list.label;" flex="1" />
</listhead>
<listcols>
<listcol flex="1" />
</listcols>
</listbox>
</vbox>
<splitter></splitter>
<rows>
<row style="margin: 10px 0 10px 0;">
<label value="&zotero.__addonRef__.template.header.label;"></label>
<textbox id="editor-name" disabled="true"></textbox>
</row>
<row flex="1">
<textbox id="editor-textbox" flex="1" multiline="true" disabled="true"></textbox>
</row>
<row style="margin: 10px 0 10px 0;">
<button id="create-template" label="&zotero.__addonRef__.template.create.label;" oncommand="Zotero.Knowledge4Zotero.template.createTemplate();"></button>
<button id="import-template" label="&zotero.__addonRef__.template.import.label;" oncommand="Zotero.Knowledge4Zotero.template.importNoteTemplate();"></button>
<button id="save-template" label="&zotero.__addonRef__.template.save.label;" oncommand="Zotero.Knowledge4Zotero.template.saveSelectedTemplate();"></button>
<button id="delete-template" label="&zotero.__addonRef__.template.delete.label;" oncommand="Zotero.Knowledge4Zotero.template.deleteSelectedTemplate();"></button>
<!-- <button id="help" label="&helpMenu.label;"></button> -->
</row>
</rows>
</hbox>

</window>
21 changes: 16 additions & 5 deletions addon/chrome/content/workspace.xul
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<?xml-stylesheet href="chrome://zotero/skin/standalone.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero-platform/content/overlay.css"?>
<?xml-stylesheet href="chrome://__addonRef__/skin/workspace.css" type="text/css"?>
<?xml-stylesheet href="chrome://__addonRef__/content/lib/css/dx.light.css" type="text/css"?>
<?xul-overlay href="chrome://zotero/content/standalone/editMenuOverlay.xul"?>

<!DOCTYPE window [
Expand All @@ -21,25 +20,26 @@
%knowledgeDTD;
]>

<window id="zotero-knowledge-workspace" orient="vertical" width="1000" height="350" title="&zotero.__addonRef__.workspace.title;" persist="screenX screenY width height" windowtype="zotero:knowledgeWorkspace" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
<window id="zotero-knowledge-workspace" orient="vertical" width="1000" height="350" title="&zotero.__addonRef__.workspace.title;" persist="screenX screenY width height sizemode" windowtype="zotero:knowledgeWorkspace" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">

<script src="chrome://zotero/content/include.js" />
<script src="chrome://zotero/content/note.js" />

<keyset>
<key id="key_new" key="N" modifiers="accel" command="cmd_new" />
<key id="key_open" key="O" modifiers="accel" command="cmd_open" />
<key id="key_import" key="I" modifiers="accel" command="cmd_import" />
<key id="key_export" key="E" modifiers="accel" command="cmd_export" />
<key id="key_close" key="W" modifiers="accel" command="cmd_close" />
<key id="key_insertNotes" key="I" modifiers="accel" command="cmd_insertNotes" />
<key id="key_indent" keycode="VK_TAB" command="cmd_indent" />
<key id="key_unindent" keycode="VK_TAB" modifiers="shift" command="cmd_unindent" />
</keyset>
<command id="cmd_new" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'createWorkspace'});" />
<command id="cmd_open" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'selectMainKnowledge'});" />
<command id="cmd_import" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'import'});" />
<command id="cmd_export" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'export', content: {editorInstance: {_item: false}}});" />
<command id="cmd_close" oncommand="window.close();" />
<command id="cmd_insertNotes" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'insertNotes'});" />
<command id="cmd_editTemplate" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'editTemplate'});" />
<command id="cmd_addheading" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'addHeading'});" />
<command id="cmd_indent" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'indentHeading'});" />
<command id="cmd_unindent" oncommand="Zotero.Knowledge4Zotero.events.onEditorEvent({type: 'unindentHeading'});" />
Expand All @@ -57,14 +57,25 @@
<menupopup id="menu_FilePopup">
<menuitem id="menu_new" label="&zotero.__addonRef__.workspace.menu.new;" key="key_new" accesskey="N" command="cmd_new" />
<menuitem id="menu_open" label="&zotero.__addonRef__.workspace.menu.open;" key="key_open" accesskey="O" command="cmd_open" />
<menuitem id="menu_import" label="&zotero.__addonRef__.workspace.menu.import;" key="key_import" accesskey="I" command="cmd_import" />
<menuitem id="menu_export" label="&zotero.__addonRef__.workspace.menu.export;" key="key_export" accesskey="E" command="cmd_export" />
<menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close" />
</menupopup>
</menu>

<menu id="menu_edit" label="&editMenu.label;" accesskey="&editMenu.accesskey;">
<menupopup id="menu_EditPopup">
<menuitem id="menu_insertNotes" label="&zotero.__addonRef__.workspace.menu.insertNotes;" key="key_insertNotes" accesskey="I" command="cmd_insertNotes" />
<menu id="menu_insertTextTemplate" label="&zotero.__addonRef__.workspace.menu.insertTextTemplate;">
<menupopup id="menu_insertTextTemplatePopup" onpopupshowing="Zotero.Knowledge4Zotero.views.updateTemplateMenu('Text');" />
</menu>
<menu id="menu_insertNoteTemplate" label="&zotero.__addonRef__.workspace.menu.insertNoteTemplate;">
<menupopup id="menu_insertNoteTemplatePopup" onpopupshowing="Zotero.Knowledge4Zotero.views.updateTemplateMenu('Note');" />
</menu>
<menu id="menu_insertItemTemplate" label="&zotero.__addonRef__.workspace.menu.insertItemTemplate;">
<menupopup id="menu_insertItemTemplatePopup" onpopupshowing="Zotero.Knowledge4Zotero.views.updateTemplateMenu('Item');" />
</menu>
<menuitem id="menu_editTemplate" label="&zotero.__addonRef__.workspace.menu.editTemplate;" command="cmd_editTemplate" />
<menuseparator />
<menuitem id="menu_addheading" label="&zotero.__addonRef__.workspace.menu.addheading;" command="cmd_addheading" />
<menuitem id="menu_indent" label="&zotero.__addonRef__.workspace.menu.indent;" command="cmd_indent" key="key_indent" />
<menuitem id="menu_unindent" label="&zotero.__addonRef__.workspace.menu.unindent;" command="cmd_unindent" key="key_unindent" />
Expand Down
14 changes: 13 additions & 1 deletion addon/chrome/locale/en-US/overlay.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

<!ENTITY zotero.__addonRef__.workspace.menu.new "Create New Main Note">
<!ENTITY zotero.__addonRef__.workspace.menu.open "Open Main Note...">
<!ENTITY zotero.__addonRef__.workspace.menu.import "Import Notes...">
<!ENTITY zotero.__addonRef__.workspace.menu.export "Export Main Note...">
<!ENTITY zotero.__addonRef__.workspace.menu.insertNotes "Insert Notes...">
<!ENTITY zotero.__addonRef__.workspace.menu.insertTextTemplate "Insert Template">
<!ENTITY zotero.__addonRef__.workspace.menu.insertNoteTemplate "Insert Notes Using Template">
<!ENTITY zotero.__addonRef__.workspace.menu.insertItemTemplate "Insert Items Using Template">
<!ENTITY zotero.__addonRef__.workspace.menu.editTemplate "Edit Templates...">
<!ENTITY zotero.__addonRef__.workspace.menu.addheading "Insert Heading...">
<!ENTITY zotero.__addonRef__.workspace.menu.indent "Decrease Heading Level">
<!ENTITY zotero.__addonRef__.workspace.menu.unindent "Increase Heading Level">
Expand Down Expand Up @@ -45,6 +49,14 @@
<!ENTITY zotero.__addonRef__.wizard.setup.collectionenable.label "Create a new collection for main notes:">
<!ENTITY zotero.__addonRef__.wizard.setup.noteenable.label "Create a 'Zotero Better Notes User Guide: Workflow' note">

<!ENTITY zotero.__addonRef__.template.title "Template Editor">
<!ENTITY zotero.__addonRef__.template.header.label "Template Name">
<!ENTITY zotero.__addonRef__.template.list.label "Template List">
<!ENTITY zotero.__addonRef__.template.create.label "Create">
<!ENTITY zotero.__addonRef__.template.import.label "Create from Note">
<!ENTITY zotero.__addonRef__.template.save.label "Save">
<!ENTITY zotero.__addonRef__.template.delete.label "Delete">

<!ENTITY zotero.__addonRef__.help.feedback.caption.label "User Guide and Feedback">
<!ENTITY zotero.__addonRef__.help.feedback.label "GitHub">
<!ENTITY zotero.__addonRef__.help.version.label "__addonName__ VERSION __buildVersion__">
Expand Down
14 changes: 13 additions & 1 deletion addon/chrome/locale/zh-CN/overlay.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

<!ENTITY zotero.__addonRef__.workspace.menu.new "创建新主笔记">
<!ENTITY zotero.__addonRef__.workspace.menu.open "打开主笔记...">
<!ENTITY zotero.__addonRef__.workspace.menu.import "导入笔记...">
<!ENTITY zotero.__addonRef__.workspace.menu.export "导出主笔记...">
<!ENTITY zotero.__addonRef__.workspace.menu.insertNotes "插入多条笔记...">
<!ENTITY zotero.__addonRef__.workspace.menu.insertTextTemplate "插入模板">
<!ENTITY zotero.__addonRef__.workspace.menu.insertNoteTemplate "使用模板插入多条笔记">
<!ENTITY zotero.__addonRef__.workspace.menu.insertItemTemplate "使用模板插入多个条目">
<!ENTITY zotero.__addonRef__.workspace.menu.editTemplate "编辑笔记模板...">
<!ENTITY zotero.__addonRef__.workspace.menu.addheading "插入标题...">
<!ENTITY zotero.__addonRef__.workspace.menu.indent "降低标题层级">
<!ENTITY zotero.__addonRef__.workspace.menu.unindent "提升标题层级">
Expand Down Expand Up @@ -45,6 +49,14 @@
<!ENTITY zotero.__addonRef__.wizard.setup.collectionenable.label "创建新的分类用来存放主笔记:">
<!ENTITY zotero.__addonRef__.wizard.setup.noteenable.label "创建 'Zotero Better Notes 用户指引:工作流' 笔记">

<!ENTITY zotero.__addonRef__.template.title "模板编辑器">
<!ENTITY zotero.__addonRef__.template.header.label "模板名称">
<!ENTITY zotero.__addonRef__.template.list.label "模板列表">
<!ENTITY zotero.__addonRef__.template.create.label "新建">
<!ENTITY zotero.__addonRef__.template.import.label "从笔记新建...">
<!ENTITY zotero.__addonRef__.template.save.label "保存">
<!ENTITY zotero.__addonRef__.template.delete.label "删除">

<!ENTITY zotero.__addonRef__.help.feedback.caption.label "User Guide and Feedback">
<!ENTITY zotero.__addonRef__.help.feedback.label "GitHub">
<!ENTITY zotero.__addonRef__.help.version.label "__addonName__ VERSION __buildVersion__">
Expand Down
3 changes: 3 additions & 0 deletions src/addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ import AddonViews from "./views";
import AddonWizard from "./wizard";
import AddonExport from "./export";
import Knowledge from "./knowledge";
import AddonTemplate from "./template";

class Knowledge4Zotero {
public events: AddonEvents;
public views: AddonViews;
public wizard: AddonWizard;
public export: AddonExport;
public template: AddonTemplate;
public knowledge: Knowledge;

constructor() {
this.events = new AddonEvents(this);
this.views = new AddonViews(this);
this.wizard = new AddonWizard(this);
this.export = new AddonExport(this);
this.template = new AddonTemplate(this);
this.knowledge = new Knowledge(this);
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ enum OutlineType {
bubbleMap,
}

export { AddonBase, EditorMessage, OutlineType };
class NoteTemplate {
name: string;
text: string;
disabled: boolean;
}

export { AddonBase, EditorMessage, OutlineType, NoteTemplate };
Loading

0 comments on commit 677d0f6

Please sign in to comment.