diff --git a/addon/chrome/content/export.xul b/addon/chrome/content/export.xul
index d4fd5a4..9210770 100644
--- a/addon/chrome/content/export.xul
+++ b/addon/chrome/content/export.xul
@@ -36,6 +36,9 @@
+
+ &zotero.__addonRef__.export.help.label;
+
\ No newline at end of file
diff --git a/addon/chrome/locale/en-US/overlay.dtd b/addon/chrome/locale/en-US/overlay.dtd
index 90cdafc..2b4f005 100644
--- a/addon/chrome/locale/en-US/overlay.dtd
+++ b/addon/chrome/locale/en-US/overlay.dtd
@@ -24,6 +24,7 @@
+
diff --git a/addon/chrome/locale/zh-CN/overlay.dtd b/addon/chrome/locale/zh-CN/overlay.dtd
index d80c215..244fb24 100644
--- a/addon/chrome/locale/zh-CN/overlay.dtd
+++ b/addon/chrome/locale/zh-CN/overlay.dtd
@@ -24,6 +24,7 @@
+
diff --git a/src/events.ts b/src/events.ts
index 42e4ee3..01fa127 100644
--- a/src/events.ts
+++ b/src/events.ts
@@ -902,7 +902,7 @@ class AddonEvents extends AddonBase {
(window as unknown as XULWindow).openDialog(
"chrome://Knowledge4Zotero/content/export.xul",
"",
- "chrome,centerscreen,width=300,height=200",
+ "chrome,centerscreen,width=300,height=300",
io
);
await io.deferred.promise;
diff --git a/src/knowledge.ts b/src/knowledge.ts
index 5167fad..a2685a7 100644
--- a/src/knowledge.ts
+++ b/src/knowledge.ts
@@ -609,25 +609,32 @@ class Knowledge extends AddonBase {
}
note = note || this.getWorkspaceNote();
const noteID = await ZoteroPane_Local.newNote();
- const item = Zotero.Items.get(noteID);
+ const newNote = Zotero.Items.get(noteID);
const rootNoteIds = [note.id];
- const newLines = await this.convertNoteLines(
+ const convertResult = await this.convertNoteLines(
note,
rootNoteIds,
convertNoteLinks,
convertNoteImages
);
- this.setLinesToNote(item, newLines);
+ this.setLinesToNote(newNote, convertResult.lines);
+ Zotero.debug(convertResult.subNotes);
+
+ await Zotero.DB.executeTransaction(async () => {
+ for (const subNote of convertResult.subNotes) {
+ await Zotero.Notes.copyEmbeddedImages(subNote, newNote);
+ }
+ });
if (saveFile) {
const exporter = new Zotero_File_Exporter();
- exporter.items = [item];
+ exporter.items = [newNote];
await exporter.save();
}
if (saveCopy) {
Zotero_File_Interface.exportItemsToClipboard(
- [item],
+ [newNote],
Zotero.Translators.TRANSLATOR_ID_MARKDOWN_AND_RICH_TEXT
);
this._Addon.views.showProgressWindow("Better Notes", "Note Copied");
@@ -637,7 +644,9 @@ class Knowledge extends AddonBase {
// Wait copy finish
await Zotero.Promise.delay(500);
}
- await Zotero.Items.erase(item.id);
+ await Zotero.Items.erase(newNote.id);
+ } else {
+ ZoteroPane.openNoteWindow(newNote.id);
}
}
@@ -687,9 +696,10 @@ class Knowledge extends AddonBase {
rootNoteIds: number[],
convertNoteLinks: boolean = true,
convertNoteImages: boolean = true
- ) {
+ ): Promise<{ lines: string[]; subNotes: ZoteroItem[] }> {
Zotero.debug(`convert note ${currentNote.id}`);
+ let subNotes = [];
const [..._rootNoteIds] = rootNoteIds;
_rootNoteIds.push(currentNote.id);
let newLines = [];
@@ -718,15 +728,16 @@ class Knowledge extends AddonBase {
Zotero.debug(`Knowledge4Zotero: Exporting sub-note ${link}`);
newLines.push("
");
newLines.push(`Linked Note:
`);
- newLines = newLines.concat(
- await this.convertNoteLines(
- subNote,
- _rootNoteIds,
- convertNoteLinks,
- convertNoteImages
- )
+ const convertResult = await this.convertNoteLines(
+ subNote,
+ _rootNoteIds,
+ convertNoteLinks,
+ convertNoteImages
);
+ newLines = newLines.concat(convertResult.lines);
newLines.push("
");
+ subNotes.push(subNote);
+ subNotes = subNotes.concat(convertResult.subNotes);
}
noteLines[i] = noteLines[i].substring(
noteLines[i].search(/zotero:\/\/note\//g)
@@ -738,7 +749,8 @@ class Knowledge extends AddonBase {
}
}
}
- return newLines;
+ Zotero.debug(subNotes);
+ return { lines: newLines, subNotes: subNotes };
}
getLinkFromText(text: string) {
diff --git a/src/views.ts b/src/views.ts
index aad1dc7..f8a049a 100644
--- a/src/views.ts
+++ b/src/views.ts
@@ -302,9 +302,13 @@ class AddonViews extends AddonBase {
let newLines = [];
newLines.push("");
newLines.push(`Linked Note:
`);
- newLines = newLines.concat(
- await this._Addon.knowledge.convertNoteLines(note, [], true, false)
+ const convertResult = await this._Addon.knowledge.convertNoteLines(
+ note,
+ [],
+ true,
+ false
);
+ newLines = newLines.concat(convertResult.lines);
newLines.push("
");
Zotero.debug(newLines);
await this._Addon.knowledge.addLinesToNote(