mirror of
https://github.com/zadam/trilium.git
synced 2025-11-21 08:04:24 +01:00
feat(print/list): rewrite links
This commit is contained in:
parent
eee496a050
commit
f4d6e98d61
@ -467,20 +467,21 @@ function getReferenceLinkTitleSync(href: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check why the event is not supported.
|
if (glob.device !== "print") {
|
||||||
//@ts-ignore
|
// TODO: Check why the event is not supported.
|
||||||
$(document).on("click", "a", goToLink);
|
//@ts-ignore
|
||||||
// TODO: Check why the event is not supported.
|
$(document).on("click", "a", goToLink);
|
||||||
//@ts-ignore
|
// TODO: Check why the event is not supported.
|
||||||
$(document).on("auxclick", "a", goToLink); // to handle the middle button
|
//@ts-ignore
|
||||||
// TODO: Check why the event is not supported.
|
$(document).on("auxclick", "a", goToLink); // to handle the middle button
|
||||||
//@ts-ignore
|
// TODO: Check why the event is not supported.
|
||||||
$(document).on("contextmenu", "a", linkContextMenu);
|
//@ts-ignore
|
||||||
// TODO: Check why the event is not supported.
|
$(document).on("contextmenu", "a", linkContextMenu);
|
||||||
//@ts-ignore
|
// TODO: Check why the event is not supported.
|
||||||
$(document).on("dblclick", "a", goToLink);
|
//@ts-ignore
|
||||||
|
$(document).on("dblclick", "a", goToLink);
|
||||||
|
|
||||||
$(document).on("mousedown", "a", (e) => {
|
$(document).on("mousedown", "a", (e) => {
|
||||||
if (e.which === 2) {
|
if (e.which === 2) {
|
||||||
// prevent paste on middle click
|
// prevent paste on middle click
|
||||||
// https://github.com/zadam/trilium/issues/2995
|
// https://github.com/zadam/trilium/issues/2995
|
||||||
@ -488,7 +489,8 @@ $(document).on("mousedown", "a", (e) => {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getNotePathFromUrl,
|
getNotePathFromUrl,
|
||||||
|
|||||||
@ -29,6 +29,7 @@ export function ListPrintView({ note, noteIds: unfilteredNoteIds, onReady }: Vie
|
|||||||
|
|
||||||
insertPageTitle(contentEl, note.title);
|
insertPageTitle(contentEl, note.title);
|
||||||
rewriteHeadings(contentEl, depth);
|
rewriteHeadings(contentEl, depth);
|
||||||
|
rewriteLinks(contentEl);
|
||||||
|
|
||||||
notesWithContent.push({ note, content: { __html: contentEl.innerHTML } });
|
notesWithContent.push({ note, content: { __html: contentEl.innerHTML } });
|
||||||
|
|
||||||
@ -84,3 +85,14 @@ function rewriteHeadings(contentEl: HTMLElement, depth: number) {
|
|||||||
headingEl.replaceWith(newHeadingEl);
|
headingEl.replaceWith(newHeadingEl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rewriteLinks(contentEl: HTMLElement) {
|
||||||
|
const linkEls = contentEl.querySelectorAll("a");
|
||||||
|
for (const linkEl of linkEls) {
|
||||||
|
const href = linkEl.getAttribute("href");
|
||||||
|
if (href && href.startsWith("#root/")) {
|
||||||
|
const noteId = href.split("/").at(-1);
|
||||||
|
linkEl.setAttribute("href", `#note-${noteId}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user