parent
e859fe8cd9
commit
5e42e3db3d
|
|
@ -23,6 +23,10 @@
|
|||
var parser = new DOMParser();
|
||||
var serializer = new XMLSerializer();
|
||||
var htmlString = e.data.html;
|
||||
const styleString = e.data.style;
|
||||
const style = document.createElement("style");
|
||||
style.innerHTML = styleString;
|
||||
document.head.appendChild(style);
|
||||
var htmlDoc = parser.parseFromString(htmlString, "text/html");
|
||||
var xhtmlString = serializer.serializeToString(htmlDoc);
|
||||
document.querySelector(".markdown-body").innerHTML = xhtmlString;
|
||||
|
|
|
|||
|
|
@ -221,7 +221,9 @@ async function embedLinkedNotes(noteItem: Zotero.Item): Promise<string> {
|
|||
for (const i in noteLines) {
|
||||
newLines.push(noteLines[i]);
|
||||
const doc = parser.parseFromString(noteLines[i], "text/html");
|
||||
const linkParams = (Array.from(doc.querySelectorAll("a")) as HTMLAnchorElement[])
|
||||
const linkParams = (
|
||||
Array.from(doc.querySelectorAll("a")) as HTMLAnchorElement[]
|
||||
)
|
||||
.filter((a) => a?.href.startsWith("zotero://note/"))
|
||||
.map((a) => getNoteLinkParams(a?.href))
|
||||
.filter((p) => p.noteItem && !p.ignore);
|
||||
|
|
@ -248,10 +250,11 @@ async function embedLinkedNotes(noteItem: Zotero.Item): Promise<string> {
|
|||
seenCitationItemIDs.push(currentID);
|
||||
}
|
||||
}
|
||||
return `<div data-schema-version="${globalCitationData.schemaVersion
|
||||
}" data-citation-items="${encodeURIComponent(
|
||||
JSON.stringify(finalCitationItems),
|
||||
)}">${newLines.join("\n")}</div>`;
|
||||
return `<div data-schema-version="${
|
||||
globalCitationData.schemaVersion
|
||||
}" data-citation-items="${encodeURIComponent(
|
||||
JSON.stringify(finalCitationItems),
|
||||
)}">${newLines.join("\n")}</div>`;
|
||||
}
|
||||
|
||||
function getNoteCitationData(noteItem: Zotero.Item) {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,9 @@ async function parseDocxFields(html: string, worker: HTMLIFrameElement) {
|
|||
|
||||
const mathCache = {} as MathCache;
|
||||
|
||||
for (const elem of (Array.from(doc.querySelectorAll("math")) as MathMLElement[])) {
|
||||
for (const elem of Array.from(
|
||||
doc.querySelectorAll("math"),
|
||||
) as MathMLElement[]) {
|
||||
let str = (await sendWorkerTask(
|
||||
worker,
|
||||
"parseMML",
|
||||
|
|
@ -122,8 +124,9 @@ async function parseDocxFields(html: string, worker: HTMLIFrameElement) {
|
|||
citationItems.push(item);
|
||||
}
|
||||
const properties = citation.properties;
|
||||
const formattedCitation = `${elem.textContent || "Zotero Citation"
|
||||
} - Please click Zotero - Refresh in Word/LibreOffice to update all fields.`;
|
||||
const formattedCitation = `${
|
||||
elem.textContent || "Zotero Citation"
|
||||
} - Please click Zotero - Refresh in Word/LibreOffice to update all fields.`;
|
||||
properties.formattedCitation = formattedCitation;
|
||||
properties.plainCitation = formattedCitation + " ";
|
||||
properties.noteIndex = 0;
|
||||
|
|
|
|||
|
|
@ -177,11 +177,11 @@ function makeCheckboxLine(dataKey: string, callback?: (ev: Event) => void) {
|
|||
},
|
||||
listeners: callback
|
||||
? [
|
||||
{
|
||||
type: "change",
|
||||
listener: callback,
|
||||
},
|
||||
]
|
||||
{
|
||||
type: "change",
|
||||
listener: callback,
|
||||
},
|
||||
]
|
||||
: [],
|
||||
},
|
||||
],
|
||||
|
|
@ -223,11 +223,11 @@ function makeRadioLine(
|
|||
},
|
||||
listeners: callback
|
||||
? [
|
||||
{
|
||||
type: "change",
|
||||
listener: callback,
|
||||
},
|
||||
]
|
||||
{
|
||||
type: "change",
|
||||
listener: callback,
|
||||
},
|
||||
]
|
||||
: [],
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -17,7 +17,10 @@ export async function savePDF(noteId: number) {
|
|||
args,
|
||||
)!;
|
||||
await args._initPromise.promise;
|
||||
args.browser?.contentWindow.postMessage({ type: "print", html }, "*");
|
||||
args.browser?.contentWindow.postMessage(
|
||||
{ type: "print", html, style: Zotero.Prefs.get("note.css") || "" },
|
||||
"*",
|
||||
);
|
||||
win.print();
|
||||
showHint("Note Saved as PDF");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -283,10 +283,18 @@ function updateEditor() {
|
|||
"#editor-name",
|
||||
) as HTMLInputElement;
|
||||
const editor = win?.document.getElementById("editor") as HTMLIFrameElement;
|
||||
const saveTemplate = win?.document.getElementById("save") as XULButtonElement | null;
|
||||
const deleteTemplate = win?.document.getElementById("delete") as XULButtonElement | null;
|
||||
const resetTemplate = win?.document.getElementById("reset") as XULButtonElement | null;
|
||||
const shareTemplate = win?.document.getElementById("share") as XULButtonElement | null;
|
||||
const saveTemplate = win?.document.getElementById(
|
||||
"save",
|
||||
) as XULButtonElement | null;
|
||||
const deleteTemplate = win?.document.getElementById(
|
||||
"delete",
|
||||
) as XULButtonElement | null;
|
||||
const resetTemplate = win?.document.getElementById(
|
||||
"reset",
|
||||
) as XULButtonElement | null;
|
||||
const shareTemplate = win?.document.getElementById(
|
||||
"share",
|
||||
) as XULButtonElement | null;
|
||||
const formats = win?.document.getElementById(
|
||||
"formats-container",
|
||||
) as HTMLDivElement;
|
||||
|
|
@ -608,7 +616,7 @@ function resetSelectedTemplate() {
|
|||
if (addon.api.template.SYSTEM_TEMPLATE_NAMES.includes(name)) {
|
||||
addon.data.template.editor.editor.setValue(
|
||||
addon.api.template.DEFAULT_TEMPLATES.find((t) => t.name === name)?.text ||
|
||||
"",
|
||||
"",
|
||||
);
|
||||
showHint(`Template ${name} is reset. Please save before leaving.`);
|
||||
}
|
||||
|
|
@ -631,9 +639,9 @@ pluginVersion: "${version}"
|
|||
savedAt: "${new Date().toISOString()}"
|
||||
content: |-
|
||||
${content
|
||||
.split("\n")
|
||||
.map((line) => ` ${line}`)
|
||||
.join("\n")}
|
||||
.split("\n")
|
||||
.map((line) => ` ${line}`)
|
||||
.join("\n")}
|
||||
`;
|
||||
new ztoolkit.Clipboard().addText(yaml, "text/plain").copy();
|
||||
showHint(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
import { Workspace } from "../../elements/workspace/workspace";
|
||||
import { waitUtilAsync } from "../../utils/wait";
|
||||
|
||||
export async function initWorkspace(container: XULBoxElement, item: Zotero.Item) {
|
||||
export async function initWorkspace(
|
||||
container: XULBoxElement,
|
||||
item: Zotero.Item,
|
||||
) {
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@ async function setLinesToNote(note: Zotero.Item, lines: string[]) {
|
|||
} else {
|
||||
const noteHead = noteText.substring(0, containerIndex);
|
||||
note.setNote(
|
||||
`${noteHead}data-schema-version="${config.dataSchemaVersion
|
||||
`${noteHead}data-schema-version="${
|
||||
config.dataSchemaVersion
|
||||
}">${lines.join("\n")}</div>`,
|
||||
);
|
||||
}
|
||||
|
|
@ -368,8 +369,10 @@ async function copyEmbeddedImagesInHTML(
|
|||
note: targetNote,
|
||||
});
|
||||
});
|
||||
nodes.forEach((node) =>
|
||||
node?.setAttribute("data-attachment-key", copiedAttachment.key), Node
|
||||
nodes.forEach(
|
||||
(node) =>
|
||||
node?.setAttribute("data-attachment-key", copiedAttachment.key),
|
||||
Node,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue