parent
2db441128a
commit
c0e21f47e8
|
|
@ -66,7 +66,7 @@
|
|||
<menu id="menu_insertItemTemplate_betternotes" class="menu-type-betternotes" label="&zotero.__addonRef__.workspace.menu.insertItemTemplate;">
|
||||
<menupopup id="menu_insertItemTemplatePopup" onpopupshowing="Zotero.Knowledge4Zotero.views.updateTemplateMenu('Item');" />
|
||||
</menu>
|
||||
<menuitem id="menu_editTemplate_betternotes" class="menu-type-betternotes" label="&zotero.__addonRef__.workspace.menu.editTemplate;" command="cmd_editTemplate_betternotes" />
|
||||
<menuitem id="menu_editTemplate_betternotes" label="&zotero.__addonRef__.workspace.menu.editTemplate;" command="cmd_editTemplate_betternotes" />
|
||||
<menuseparator class="menu-type-betternotes" />
|
||||
<menuitem id="menu_addheading_betternotes" class="menu-type-betternotes" label="&zotero.__addonRef__.workspace.menu.addheading;" command="cmd_addheading_betternotes" />
|
||||
<menuitem id="menu_indent_betternotes" class="menu-type-betternotes" label="&zotero.__addonRef__.workspace.menu.indent;" command="cmd_indent_betternotes" key="key_indent_betternotes" />
|
||||
|
|
|
|||
|
|
@ -57,25 +57,28 @@ class AddonExport extends AddonBase {
|
|||
) as XUL.Checkbox
|
||||
).checked = exportCopy;
|
||||
}
|
||||
this.doUpdate();
|
||||
}
|
||||
doUpdate(event: XULEvent) {
|
||||
if (
|
||||
event.target.getAttribute("id") === "Knowledge4Zotero-export-enablesingle"
|
||||
) {
|
||||
(
|
||||
this._window.document.getElementById(
|
||||
"Knowledge4Zotero-export-embedLink"
|
||||
) as XUL.Checkbox
|
||||
).disabled = (event.target as XUL.Checkbox).checked;
|
||||
} else if (
|
||||
event.target.getAttribute("id") === "Knowledge4Zotero-export-enablefile"
|
||||
) {
|
||||
(
|
||||
this._window.document.getElementById(
|
||||
"Knowledge4Zotero-export-enablesingle"
|
||||
) as XUL.Checkbox
|
||||
).disabled = !(event.target as XUL.Checkbox).checked;
|
||||
}
|
||||
(
|
||||
this._window.document.getElementById(
|
||||
"Knowledge4Zotero-export-embedLink"
|
||||
) as XUL.Checkbox
|
||||
).disabled = (
|
||||
this._window.document.getElementById(
|
||||
"Knowledge4Zotero-export-enablesingle"
|
||||
) as XUL.Checkbox
|
||||
).checked;
|
||||
|
||||
(
|
||||
this._window.document.getElementById(
|
||||
"Knowledge4Zotero-export-enablesingle"
|
||||
) as XUL.Checkbox
|
||||
).disabled = !(
|
||||
this._window.document.getElementById(
|
||||
"Knowledge4Zotero-export-enablefile"
|
||||
) as XUL.Checkbox
|
||||
).checked;
|
||||
}
|
||||
doUnload() {
|
||||
this.io.deferred && this.io.deferred.resolve();
|
||||
|
|
|
|||
|
|
@ -854,11 +854,9 @@ class Knowledge extends AddonBase {
|
|||
|
||||
this._exportNote = newNote;
|
||||
|
||||
let filename = `${Zotero.File.pathToFile(filepath).path}/${
|
||||
newNote.getNoteTitle
|
||||
? newNote.getNoteTitle().replace(/[/\\?%*:|"<>]/g, "-") + "-"
|
||||
: ""
|
||||
}${note.key}.md`;
|
||||
let filename = `${
|
||||
Zotero.File.pathToFile(filepath).path
|
||||
}/${this._getFileName(note)}`;
|
||||
filename = filename.replace(/\\/g, "/");
|
||||
|
||||
this._export(newNote, filename, newNote.id !== note.id);
|
||||
|
|
@ -888,12 +886,7 @@ class Knowledge extends AddonBase {
|
|||
link: this.getNoteLink(_note),
|
||||
id: _note.id,
|
||||
note: _note,
|
||||
filename:
|
||||
(_note.getNoteTitle
|
||||
? _note.getNoteTitle().replace(/[/\\?%*:|"<> ]/g, "-") + "-"
|
||||
: "") +
|
||||
_note.key +
|
||||
".md",
|
||||
filename: this._getFileName(_note),
|
||||
};
|
||||
});
|
||||
this._exportFileDict = noteLinkDict;
|
||||
|
|
@ -909,7 +902,7 @@ class Knowledge extends AddonBase {
|
|||
}
|
||||
}
|
||||
|
||||
async _export(
|
||||
private async _export(
|
||||
note: ZoteroItem,
|
||||
filename: string,
|
||||
deleteAfterExport: boolean
|
||||
|
|
@ -942,6 +935,27 @@ class Knowledge extends AddonBase {
|
|||
}
|
||||
}
|
||||
|
||||
private _getFileName(noteItem: ZoteroItem) {
|
||||
let _newLine: string = "";
|
||||
const templateText =
|
||||
this._Addon.template.getTemplateText("[ExportMDFileName]");
|
||||
try {
|
||||
_newLine = new Function("noteItem", "return `" + templateText + "`")(
|
||||
noteItem
|
||||
);
|
||||
} catch (e) {
|
||||
alert(e);
|
||||
return (
|
||||
(noteItem.getNoteTitle
|
||||
? noteItem.getNoteTitle().replace(/[/\\?%*:|"<> ]/g, "-") + "-"
|
||||
: "") +
|
||||
noteItem.key +
|
||||
".md"
|
||||
);
|
||||
}
|
||||
return _newLine;
|
||||
}
|
||||
|
||||
async convertNoteLines(
|
||||
currentNote: ZoteroItem,
|
||||
rootNoteIds: number[],
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@ class AddonTemplate extends AddonBase {
|
|||
text: '<p>${annotationItem.annotationComment ? annotationItem.annotationComment : `<span style="background-color: ${annotationItem.annotationColor ? annotationItem.annotationColor : "#ffd400"}">Annotation</span>`}</p>',
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
name: "[ExportMDFileName]",
|
||||
text: '${(noteItem.getNoteTitle ? noteItem.getNoteTitle().replace(/[/\\?%*:|"<> ]/g, "-") + "-" : "")}${noteItem.key}.md',
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
name: "[Item] item-notes with metadata",
|
||||
text: '<h1>${topItem.getField("title")}</h1>\n<h2 style="color:red; background-color: #efe3da;">💡 Meta Data</h2>\n<table>\n <tr>\n <th style="background-color:#dbeedd;">\n <p style="text-align: right">Title </p>\n </th>\n <td style="background-color:#dbeedd;">\n ${topItem.getField(\'title\')}\n </td>\n </tr>\n <tr>\n <th style="background-color:#f3faf4;">\n <p style="text-align: right">Journal </p>\n </th>\n <td style="background-color:#f3faf4;">\n ${topItem.getField(\'publicationTitle\')}\n </td>\n </tr>\n <tr>\n <th style="background-color:#dbeedd;">\n <p style="text-align: right">1<sup>st</sup> Author </p>\n </th>\n <td style="background-color:#dbeedd;">\n ${topItem.getField(\'firstCreator\')}\n </td>\n </tr>\n <tr>\n <th style="background-color:#f3faf4;">\n <p style="text-align: right">Authors </p>\n </th>\n <td style="background-color:#f3faf4;">\n ${topItem.getCreators().map((v)=>v.firstName+" "+v.lastName).join("; ")}\n </td>\n </tr>\n <tr>\n <th style="background-color:#dbeedd;">\n <p style="text-align: right">Pub. date </p>\n </th>\n <td style="background-color:#dbeedd;">\n ${topItem.getField(\'date\')}\n </td>\n </tr>\n <tr>\n <th style="background-color:#f3faf4;">\n <p style="text-align: right">DOI </p>\n </th>\n <td style="background-color:#f3faf4;">\n <a href="https://doi.org/${topItem.getField(\'DOI\')}">${topItem.getField(\'DOI\')}</a>\n </td>\n </tr>\n <tr>\n <th style="background-color:#dbeedd;">\n <p style="text-align: right">Archive </p>\n </th>\n <td style="background-color:#dbeedd;">\n ${topItem.getField(\'archive\')}\n </td>\n </tr>\n <tr>\n <th style="background-color:#f3faf4;">\n <p style="text-align: right">Archive Location </p>\n </th>\n <td style="background-color:#f3faf4;">\n ${topItem.getField(\'archiveLocation\')}\n </td>\n </tr>\n <tr>\n <th style="background-color:#dbeedd;">\n <p style="text-align: right">Call No. </p>\n </th>\n <td style="background-color:#dbeedd;">\n ${topItem.getField(\'callNumber\')}\n </td>\n </tr>\n</table>\n${itemNotes.map((noteItem)=>{\nconst noteLine = `<h2 style="color:red; background-color: #efe3da;">📜 Note: <a href="${Zotero.Knowledge4Zotero.knowledge.getNoteLink(noteItem)}" rel="noopener noreferrer nofollow">${noteItem.key}</a></h2>\n<blockquote>\n ${noteItem.getNote()}\n <p style="background-color: pink;"><strong>Merge Date: </strong> ${new Date().toISOString().substr(0,10)+" "+ new Date().toTimeString()}</p>\n</blockquote>\n<p style="color:red; background-color: #efe3da;"><strong>📝 Comments</strong></p>\n<blockquote>\n <p>Make your comments</p>\n <p></p>\n</blockquote>`;\ncopyNoteImage(noteItem);\nreturn noteLine;\n}).join("\\n")}\n',
|
||||
|
|
|
|||
Loading…
Reference in New Issue