fix: export note blank image bug
This commit is contained in:
parent
551c3db02c
commit
4491cbec04
|
|
@ -36,6 +36,9 @@
|
|||
<checkbox id="__addonRef__-export-enablecopy" checked="false" />
|
||||
<label value="&zotero.__addonRef__.export.copy.enable.label;" />
|
||||
</row>
|
||||
<row>
|
||||
<html:div style="position: fixed">&zotero.__addonRef__.export.help.label;</html:div>
|
||||
</row>
|
||||
</rows>
|
||||
</box>
|
||||
</dialog>
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
<!ENTITY zotero.__addonRef__.export.image.enable.label "Embed Images(MarkDown file only)">
|
||||
<!ENTITY zotero.__addonRef__.export.note.enable.label "Export to new note">
|
||||
<!ENTITY zotero.__addonRef__.export.copy.enable.label "Export to clipboard">
|
||||
<!ENTITY zotero.__addonRef__.export.help.label "To export to MS Word/OneNote with sub-note images, use[Embed Linked Notes + Export to new note]. Select all and copy-paste the new note context. After that, you may delete the new note.">
|
||||
|
||||
<!ENTITY zotero.__addonRef__.wizard.title "Welcomed to Zotero Better Notes">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page1.header "Zotero Better Notes User Guide">
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
<!ENTITY zotero.__addonRef__.export.image.enable.label "嵌入图片(只在MarkDown文件导出时勾选)">
|
||||
<!ENTITY zotero.__addonRef__.export.note.enable.label "导出到新笔记">
|
||||
<!ENTITY zotero.__addonRef__.export.copy.enable.label "导出到剪贴板">
|
||||
<!ENTITY zotero.__addonRef__.export.help.label "要导出到MS Word/OneNote并带有子笔记图片, 使用[嵌入链接的子笔记 + 导出到新笔记]。在新笔记中全选(ctrl/cmd+A)并复制内容,粘贴完毕后可删除该新笔记。">
|
||||
|
||||
<!ENTITY zotero.__addonRef__.wizard.title "欢迎使用 Zotero Better Notes">
|
||||
<!ENTITY zotero.__addonRef__.wizard.page1.header "Zotero Better Notes 用户指引">
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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("<blockquote>");
|
||||
newLines.push(`<p><strong>Linked Note:</strong></p>`);
|
||||
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("</blockquote>");
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -302,9 +302,13 @@ class AddonViews extends AddonBase {
|
|||
let newLines = [];
|
||||
newLines.push("<blockquote>");
|
||||
newLines.push(`<p><strong>Linked Note:</strong></p>`);
|
||||
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("</blockquote>");
|
||||
Zotero.debug(newLines);
|
||||
await this._Addon.knowledge.addLinesToNote(
|
||||
|
|
|
|||
Loading…
Reference in New Issue