mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fixed CSS lazy loading (same file could be loaded multiple times)
This commit is contained in:
parent
be477f178b
commit
d4e27c1b76
BIN
db/demo.tar
BIN
db/demo.tar
Binary file not shown.
@ -1,9 +1,9 @@
|
|||||||
async function requireCss(url) {
|
async function requireCss(url) {
|
||||||
const css = Array
|
const cssLinks = Array
|
||||||
.from(document.querySelectorAll('link'))
|
.from(document.querySelectorAll('link'))
|
||||||
.map(scr => scr.href);
|
.map(el => el.href);
|
||||||
|
|
||||||
if (!css.includes(url)) {
|
if (!cssLinks.some(l => l.endsWith(url))) {
|
||||||
$('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', url));
|
$('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', url));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,11 +56,7 @@ function registerEntrypoints() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
import(NOTE_SOURCE).then(d => {
|
import(NOTE_SOURCE).then(d => d.showDialog());
|
||||||
console.log(d);
|
|
||||||
|
|
||||||
d.showDialog()
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$noteTabContainer.on("click", ".show-link-map-button", function() {
|
$noteTabContainer.on("click", ".show-link-map-button", function() {
|
||||||
|
@ -237,13 +237,15 @@ async function importTar(importContext, fileBuffer, importRootNote) {
|
|||||||
content = content.toString("UTF-8");
|
content = content.toString("UTF-8");
|
||||||
|
|
||||||
if (noteMeta) {
|
if (noteMeta) {
|
||||||
const internalLinks = (noteMeta.attributes || []).filter(attr => attr.type === 'relation' && attr.name === 'internal-link');
|
const internalLinks = (noteMeta.attributes || [])
|
||||||
|
.filter(attr => attr.type === 'relation' &&
|
||||||
|
['internal-link', 'relation-map-link', 'image-link'].includes(attr.name));
|
||||||
|
|
||||||
// this will replace all internal links (<a> and <img>) inside the body
|
// this will replace all internal links (<a> and <img>) inside the body
|
||||||
// links pointing outside the export will be broken and changed (ctx.getNewNoteId() will still assign new noteId)
|
// links pointing outside the export will be broken and changed (ctx.getNewNoteId() will still assign new noteId)
|
||||||
for (const link of internalLinks) {
|
for (const link of internalLinks) {
|
||||||
// no need to escape the regexp find string since it's a noteId which doesn't contain any special characters
|
// no need to escape the regexp find string since it's a noteId which doesn't contain any special characters
|
||||||
content = content.replace(new RegExp(link.targetNoteId, "g"), getNewNoteId(link.targetNoteId));
|
content = content.replace(new RegExp(link.value, "g"), getNewNoteId(link.value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user