add: setup wizard
This commit is contained in:
parent
93317f0230
commit
76318d5378
|
|
@ -0,0 +1,67 @@
|
|||
<?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-platform/content/overlay.css"?>
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % ZoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd">
|
||||
%ZoteroDTD;
|
||||
<!ENTITY % knowledgeDTD SYSTEM "chrome://__addonRef__/locale/overlay.dtd">
|
||||
%knowledgeDTD;
|
||||
]>
|
||||
|
||||
<wizard xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="knowledge-wizard" title="&zotero.__addonRef__.wizard.title;" width="788" height="600" onwizardfinish="Zotero.Knowledge4Zotero.wizard.setup()">
|
||||
<script src="chrome://zotero/content/include.js" />
|
||||
|
||||
<wizardpage label="&zotero.__addonRef__.wizard.title;">
|
||||
<image src="chrome://__addonRef__/skin/knowledge-app.png" width="560" height="400"></image>
|
||||
<description style="white-space: pre-wrap; font-size: large; font-weight: bold;">&zotero.__addonRef__.wizard.page1.header;</description>
|
||||
<description style="white-space: pre-wrap;">&zotero.__addonRef__.wizard.page1.description;</description>
|
||||
</wizardpage>
|
||||
<wizardpage label="&zotero.__addonRef__.wizard.create;">
|
||||
<image src="chrome://__addonRef__/skin/add-knowledge.gif" width="560" height="400" style="padding-top: 50px;"></image>
|
||||
<description style="white-space: pre-wrap; font-size: large; font-weight: bold;">&zotero.__addonRef__.wizard.page2.header;</description>
|
||||
<description style="white-space: pre-wrap;">&zotero.__addonRef__.wizard.page2.description;</description>
|
||||
</wizardpage>
|
||||
<wizardpage label="&zotero.__addonRef__.wizard.open;">
|
||||
<image src="chrome://__addonRef__/skin/open-knowledge.png" width="560" height="400"></image>
|
||||
<description style="white-space: pre-wrap; font-size: large; font-weight: bold;">&zotero.__addonRef__.wizard.page3.header;</description>
|
||||
<description style="white-space: pre-wrap;">&zotero.__addonRef__.wizard.page3.description;</description>
|
||||
</wizardpage>
|
||||
<wizardpage label="&zotero.__addonRef__.wizard.layout;">
|
||||
<image src="chrome://__addonRef__/skin/intro-workspace.png" width="560" height="400"></image>
|
||||
<description style="white-space: pre-wrap; font-size: large; font-weight: bold;">&zotero.__addonRef__.wizard.page4.header;</description>
|
||||
<description style="white-space: pre-wrap;">&zotero.__addonRef__.wizard.page4.description1;</description>
|
||||
<description style="white-space: pre-wrap;">&zotero.__addonRef__.wizard.page4.description2;</description>
|
||||
<description style="white-space: pre-wrap;">&zotero.__addonRef__.wizard.page4.description3;</description>
|
||||
</wizardpage>
|
||||
<wizardpage label="&zotero.__addonRef__.wizard.layout;">
|
||||
<image src="chrome://__addonRef__/skin/add-link.gif" width="560" height="400" style="padding-top: 50px;"></image>
|
||||
<description style="white-space: pre-wrap; font-size: large; font-weight: bold;">&zotero.__addonRef__.wizard.page5.header;</description>
|
||||
<description style="white-space: pre-wrap;">&zotero.__addonRef__.wizard.page5.description1;</description>
|
||||
<description style="white-space: pre-wrap;">&zotero.__addonRef__.wizard.page5.description2;</description>
|
||||
</wizardpage>
|
||||
<wizardpage label="&zotero.__addonRef__.wizard.setup;">
|
||||
<description style="white-space: pre-wrap; font-size: large; font-weight: bold;">&zotero.__addonRef__.wizard.page6.header;</description>
|
||||
<description style="white-space: pre-wrap;">&zotero.__addonRef__.wizard.page6.description1;</description>
|
||||
<description style="white-space: pre-wrap; color: red;">&zotero.__addonRef__.wizard.page6.description2;</description>
|
||||
|
||||
<rows>
|
||||
<row>
|
||||
<checkbox id="__addonRef__-setup-enable" checked="true" oncommand="Zotero.Knowledge4Zotero.wizard.changeSetup()" />
|
||||
<label value="&zotero.__addonRef__.wizard.setup.enable.label;" />
|
||||
</row>
|
||||
<row>
|
||||
<checkbox id="__addonRef__-setup-collectionenable" checked="true" oncommand="Zotero.Knowledge4Zotero.wizard.updateCollectionSetup()" />
|
||||
<label value="&zotero.__addonRef__.wizard.setup.collectionenable.label;" />
|
||||
<textbox id="__addonRef__-setup-collectionname" value="My Knowledges" oninput="Zotero.Knowledge4Zotero.wizard.updateCollectionSetup()" />
|
||||
</row>
|
||||
<row>
|
||||
<checkbox id="__addonRef__-setup-noteenable" checked="true" oncommand="Zotero.Knowledge4Zotero.wizard.updateNoteSetup()" />
|
||||
<label value="&zotero.__addonRef__.wizard.setup.noteenable.label;" />
|
||||
</row>
|
||||
</rows>
|
||||
</wizardpage>
|
||||
<script>Zotero.Knowledge4Zotero.wizard.init(document)</script>
|
||||
</wizard>
|
||||
|
|
@ -58,6 +58,10 @@
|
|||
<div id="outline-untab"></div>
|
||||
<span class="tooltiptext">Decrease the selected Heading level</span>
|
||||
</div>
|
||||
<div class="tooltip">
|
||||
<div id="user-guide"></div>
|
||||
<span class="tooltiptext">Open User Guide</span>
|
||||
</div>
|
||||
</html:div>
|
||||
</vbox>
|
||||
<splitter id="outline-splitter" collapse="before">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,33 @@
|
|||
<!ENTITY zotero.__addonRef__.workspace.title "Knowledge Workspace">
|
||||
<!ENTITY zotero.__addonRef__.itemmenu.setMainKnowledge.label "Set Main Knowledge">
|
||||
|
||||
<!ENTITY zotero.__addonRef__.wizard.title "Welcomed to Knowledge for Zotero">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page1.header "Knowledge for Zotero User Guide">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page1.description "Click Next to Continue.">
|
||||
<!ENTITY zotero.__addonRef__.wizard.create "Create Knowledge Workspace">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page2.header "Create Knowledge Workspace">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page2.description "Knowledge uses a note as the main workspace. Create a new note or right-click to set an existing note in the main workspace.">
|
||||
<!ENTITY zotero.__addonRef__.wizard.open "Open Knowledge Workspace">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page3.header "Open Knowledge Workspace">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page3.description "Click the link above 'My Library' or the home button in the note editor to open or focus the workspace.">
|
||||
<!ENTITY zotero.__addonRef__.wizard.layout "Knowledge Workspace Layout">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page4.header "Outline/Main Knowledge/Linked Note Preview">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page4.description1 "Modify/jump to headings inside main Knowledge with the Outline;">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page4.description2 "Main Knowledge stores all linked notes. Export to MarkDown/HTML with full text supported;">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page4.description3 "Open and edit linked notes in the preview.">
|
||||
<!ENTITY zotero.__addonRef__.wizard.link "Add Note Link to Knowledge">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page5.header "Open note link in Knowledge, and everywhere.">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page5.description1 "Click to insert the current note's link after the current line in main Knowledge, or select a position to insert.">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page5.description2 "Jump to notes even from other Apps via a note link!">
|
||||
<!ENTITY zotero.__addonRef__.wizard.setup "Setup Workspace">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page6.header "Almost there. Setup your workspace before starting.">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page6.description1 "You can come back later from the knowledge workspace.">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page6.description2 "WARNING If main knowledge is not set, this addon will not work properly.">
|
||||
|
||||
<!ENTITY zotero.__addonRef__.wizard.setup.enable.label "Enable Setup">
|
||||
<!ENTITY zotero.__addonRef__.wizard.setup.collectionenable.label "Create a new collection with the name:">
|
||||
<!ENTITY zotero.__addonRef__.wizard.setup.noteenable.label "Create a new note and use it as the main Knowledge">
|
||||
|
||||
<!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__">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,33 @@
|
|||
<!ENTITY zotero.__addonRef__.workspace.title "Knowledge工作区">
|
||||
<!ENTITY zotero.__addonRef__.itemmenu.setMainKnowledge.label "设置为主Knowledge">
|
||||
|
||||
<!ENTITY zotero.__addonRef__.wizard.title "欢迎使用 Knowledge for Zotero">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page1.header "Knowledge for Zotero 用户指引">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page1.description "单击下一步以继续。">
|
||||
<!ENTITY zotero.__addonRef__.wizard.create "创建Knowledge工作区">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page2.header "创建Knowledge工作区">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page2.description "Knowledge使用笔记(note)作为工作区。创建新笔记或在项目目录右键单击现有笔记以设置工作区。">
|
||||
<!ENTITY zotero.__addonRef__.wizard.open "打开Knowledge工作区">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page3.header "打开Knowledge工作区">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page3.description "单击“我的文库”上方链接或笔记编辑器中的“主页”按钮,来打开或聚焦工作区。">
|
||||
<!ENTITY zotero.__addonRef__.wizard.layout "Knowledge 工作区布局">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page4.header "大纲/主Knowledge/链接笔记预览">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page4.description1 "用大纲修改/跳转主 Knowledge 的标题;">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page4.description2 "主Knowledge存储所有链接的笔记。支持导出包含链接全文的MarkDown/HTML;">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page4.description3 "在预览中打开并编辑链接的笔记。">
|
||||
<!ENTITY zotero.__addonRef__.wizard.link "添加笔记链接到 Knowledge">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page5.header "在Knowledge, 以及任何地方打开笔记链接。">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page5.description1 "单击按钮,在主Knowledge中当前行插入当前笔记的链接,或选择位置以插入链接。">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page5.description2 "通过笔记链接,甚至可以从其他应用程序跳转到笔记!">
|
||||
<!ENTITY zotero.__addonRef__.wizard.setup "配置工作区">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page6.header "即将完成。在开始之前,请设置工作区。">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page6.description1 "您可以稍后从Knowledge工作区返回配置指引。">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page6.description2 "警告:如果未设置主Knowledge,此插件将无法正常工作。">
|
||||
|
||||
<!ENTITY zotero.__addonRef__.wizard.setup.enable.label "启用工作区配置">
|
||||
<!ENTITY zotero.__addonRef__.wizard.setup.collectionenable.label "用这个名字创建新的工作区分类文件夹:">
|
||||
<!ENTITY zotero.__addonRef__.wizard.setup.noteenable.label "创建一个新的笔记,并将其设为主Knowledge">
|
||||
|
||||
<!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__">
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 680 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 293 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 128 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 140 KiB |
|
|
@ -1,18 +1,18 @@
|
|||
import AddonEvents from "./events";
|
||||
import AddonViews from "./views";
|
||||
import AddonPrefs from "./prefs";
|
||||
import AddonWizard from "./wizard";
|
||||
import { Knowledge } from "./knowledge";
|
||||
|
||||
class Knowledge4Zotero {
|
||||
public events: AddonEvents;
|
||||
public views: AddonViews;
|
||||
public prefs: AddonPrefs;
|
||||
public wizard: AddonWizard;
|
||||
public knowledge: Knowledge;
|
||||
|
||||
constructor() {
|
||||
this.events = new AddonEvents(this);
|
||||
this.views = new AddonViews(this);
|
||||
this.prefs = new AddonPrefs(this);
|
||||
this.wizard = new AddonWizard(this);
|
||||
this.knowledge = new Knowledge(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -62,6 +62,9 @@ class AddonEvents extends AddonBase {
|
|||
},
|
||||
false
|
||||
);
|
||||
if (!Zotero.Prefs.get("Knowledge4Zotero.mainKnowledgeID")) {
|
||||
this.onEditorEvent(new EditorMessage("openUserGuide", {}));
|
||||
}
|
||||
this.resetState();
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +113,17 @@ class AddonEvents extends AddonBase {
|
|||
|
||||
public async onEditorEvent(message: EditorMessage) {
|
||||
Zotero.debug(`Knowledge4Zotero: onEditorEvent\n${message.type}`);
|
||||
if (message.type === "openWorkspace") {
|
||||
if (message.type === "openUserGuide") {
|
||||
/*
|
||||
message.content = {}
|
||||
*/
|
||||
window.open(
|
||||
"chrome://Knowledge4Zotero/content/wizard.xul",
|
||||
"_blank",
|
||||
// margin=44+44/32+10+10+53, final space is 700*500
|
||||
"chrome,extrachrome,centerscreen,width=650,height=608"
|
||||
);
|
||||
} else if (message.type === "openWorkspace") {
|
||||
/*
|
||||
message.content = {}
|
||||
*/
|
||||
|
|
|
|||
14
src/prefs.ts
14
src/prefs.ts
|
|
@ -1,14 +0,0 @@
|
|||
import { AddonBase } from "./base";
|
||||
|
||||
class AddonPrefs extends AddonBase {
|
||||
private _document: Document;
|
||||
constructor(parent: Knowledge4Zotero) {
|
||||
super(parent);
|
||||
}
|
||||
initPreferences(_document: Document) {
|
||||
this._document = _document;
|
||||
Zotero.debug("Knowledge4Zotero: Initialize preferences.");
|
||||
}
|
||||
}
|
||||
|
||||
export default AddonPrefs;
|
||||
|
|
@ -443,6 +443,14 @@ class AddonViews extends AddonBase {
|
|||
);
|
||||
},
|
||||
});
|
||||
this.$("#user-guide").dxButton({
|
||||
icon: "tips",
|
||||
onClick: (e) => {
|
||||
this._Addon.events.onEditorEvent(
|
||||
new EditorMessage("openUserGuide", {})
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
bindTreeViewResize() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
import { AddonBase, EditorMessage } from "./base";
|
||||
|
||||
class AddonWizard extends AddonBase {
|
||||
enableSetup: boolean;
|
||||
enableCollection: boolean;
|
||||
collectionName: string;
|
||||
enableNote: boolean;
|
||||
private _document: Document;
|
||||
constructor(parent: Knowledge4Zotero) {
|
||||
super(parent);
|
||||
this.enableSetup = true;
|
||||
this.enableCollection = true;
|
||||
this.collectionName = "";
|
||||
this.enableNote = true;
|
||||
}
|
||||
init(_document: Document) {
|
||||
this._document = _document;
|
||||
Zotero.debug("Knowledge4Zotero: Initialize AddonWizard.");
|
||||
this.updateCollectionSetup();
|
||||
}
|
||||
changeSetup() {
|
||||
this.enableSetup = (
|
||||
this._document.getElementById(
|
||||
"Knowledge4Zotero-setup-enable"
|
||||
) as XUL.Checkbox
|
||||
).checked;
|
||||
(
|
||||
this._document.getElementById(
|
||||
"Knowledge4Zotero-setup-collectionenable"
|
||||
) as XUL.Checkbox
|
||||
).disabled = !this.enableSetup;
|
||||
(
|
||||
this._document.getElementById(
|
||||
"Knowledge4Zotero-setup-collectionname"
|
||||
) as XUL.Textbox
|
||||
).disabled = !(this.enableSetup && this.enableCollection);
|
||||
(
|
||||
this._document.getElementById(
|
||||
"Knowledge4Zotero-setup-noteenable"
|
||||
) as XUL.Checkbox
|
||||
).disabled = !this.enableSetup;
|
||||
}
|
||||
updateCollectionSetup() {
|
||||
this.enableCollection = (
|
||||
this._document.getElementById(
|
||||
"Knowledge4Zotero-setup-collectionenable"
|
||||
) as XUL.Checkbox
|
||||
).checked;
|
||||
this.collectionName = (
|
||||
this._document.getElementById(
|
||||
"Knowledge4Zotero-setup-collectionname"
|
||||
) as XUL.Textbox
|
||||
).value;
|
||||
(
|
||||
this._document.getElementById(
|
||||
"Knowledge4Zotero-setup-collectionname"
|
||||
) as XUL.Textbox
|
||||
).disabled = !(this.enableSetup && this.enableCollection);
|
||||
}
|
||||
updateNoteSetup() {
|
||||
this.enableNote = (
|
||||
this._document.getElementById(
|
||||
"Knowledge4Zotero-setup-noteenable"
|
||||
) as XUL.Checkbox
|
||||
).checked;
|
||||
}
|
||||
async setup() {
|
||||
if (this.enableSetup) {
|
||||
if (this.enableCollection && this.collectionName.trim().length > 0) {
|
||||
const collection = new Zotero.Collection();
|
||||
collection.name = this.collectionName;
|
||||
await collection.saveTx();
|
||||
}
|
||||
if (this.enableNote) {
|
||||
await this._Addon.events.onEditorEvent(
|
||||
new EditorMessage("createWorkspace", {})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default AddonWizard;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
declare interface Knowledge4Zotero {
|
||||
events: import("../src/events");
|
||||
views: import("../src/view");
|
||||
prefs: import("../src/prefs");
|
||||
wizard: import("../src/wizard");
|
||||
knowledge: import("../src/knowledge").Knowledge;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ declare namespace XUL {
|
|||
public value?: string;
|
||||
public width?: number;
|
||||
public height?: number;
|
||||
public disabled?: boolean;
|
||||
public getAttribute?(name: string): string;
|
||||
public setAttribute?(name: string, value: any): void;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue