Skip to content

Build your personal knowledge base with Trilium Notes

fixed CSS lazy loading (same file could be loaded multiple times)

zadamd4e27c1b765a
diff --git a/db/demo.tar b/db/demo.tar
index cfb5477c80..fde6a83ef6 100644
Binary files a/db/demo.tar and b/db/demo.tar differ
diff --git a/src/public/javascripts/services/css_loader.js b/src/public/javascripts/services/css_loader.js
index b8ed72abe5..8f9bba3f49 100644
--- a/src/public/javascripts/services/css_loader.js
+++ b/src/public/javascripts/services/css_loader.js
@@ -1,9 +1,9 @@
async function requireCss(url) {
- const css = Array
+ const cssLinks = Array
.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));
}
}
diff --git a/src/public/javascripts/services/entrypoints.js b/src/public/javascripts/services/entrypoints.js
index 3cf60bd590..628e8772b5 100644
--- a/src/public/javascripts/services/entrypoints.js
+++ b/src/public/javascripts/services/entrypoints.js
@@ -56,11 +56,7 @@ function registerEntrypoints() {
return;
}
- import(NOTE_SOURCE).then(d => {
- console.log(d);
-
- d.showDialog()
- });
+ import(NOTE_SOURCE).then(d => d.showDialog());
});
$noteTabContainer.on("click", ".show-link-map-button", function() {
diff --git a/src/services/import/tar.js b/src/services/import/tar.js
index f81d528fc3..6ca3cd2f73 100644
--- a/src/services/import/tar.js
+++ b/src/services/import/tar.js
@@ -237,13 +237,15 @@ async function importTar(importContext, fileBuffer, importRootNote) {
content = content.toString("UTF-8");
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
// links pointing outside the export will be broken and changed (ctx.getNewNoteId() will still assign new noteId)
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
- content = content.replace(new RegExp(link.targetNoteId, "g"), getNewNoteId(link.targetNoteId));
+ content = content.replace(new RegExp(link.value, "g"), getNewNoteId(link.value));
}
}
}