From 18ffcf7880ea625a29629c64aaf6275e8978b6b6 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 3 Oct 2021 23:01:22 +0200 Subject: [PATCH] small fixes --- src/becca/entities/branch.js | 13 ++++++++++--- src/public/app/services/tab_manager.js | 4 ++-- src/services/html_sanitizer.js | 16 ++++++---------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/becca/entities/branch.js b/src/becca/entities/branch.js index 003c22df5..a7ae115ae 100644 --- a/src/becca/entities/branch.js +++ b/src/becca/entities/branch.js @@ -61,10 +61,17 @@ class Branch extends AbstractEntity { const childNote = this.childNote; const parentNote = this.parentNote; - childNote.parents.push(parentNote); - childNote.parentBranches.push(this); + if (!childNote.parents.includes(parentNote)) { + childNote.parents.push(parentNote); + } - parentNote.children.push(childNote); + if (!childNote.parentBranches.includes(this)) { + childNote.parentBranches.push(this); + } + + if (!parentNote.children.includes(childNote)) { + parentNote.children.push(childNote); + } this.becca.branches[this.branchId] = this; this.becca.childParentToBranch[`${this.noteId}-${this.parentNoteId}`] = this; diff --git a/src/public/app/services/tab_manager.js b/src/public/app/services/tab_manager.js index 0e51864ec..4ae14dc04 100644 --- a/src/public/app/services/tab_manager.js +++ b/src/public/app/services/tab_manager.js @@ -389,13 +389,13 @@ export default class TabManager extends Component { } async removeAllTabsCommand() { - for (const ntxIdToRemove of this.noteContexts.map(nc => nc.ntxId)) { + for (const ntxIdToRemove of this.mainNoteContexts.map(nc => nc.ntxId)) { await this.removeNoteContext(ntxIdToRemove); } } async removeAllTabsExceptForThisCommand({ntxId}) { - for (const ntxIdToRemove of this.noteContexts.map(nc => nc.ntxId)) { + for (const ntxIdToRemove of this.mainNoteContexts.map(nc => nc.ntxId)) { if (ntxIdToRemove !== ntxId) { await this.removeNoteContext(ntxIdToRemove); } diff --git a/src/services/html_sanitizer.js b/src/services/html_sanitizer.js index 81e88224c..5af84fbbb 100644 --- a/src/services/html_sanitizer.js +++ b/src/services/html_sanitizer.js @@ -3,19 +3,15 @@ const sanitizeHtml = require('sanitize-html'); // intended mainly as protection against XSS via import // secondarily it (partly) protects against "CSS takeover" function sanitize(dirtyHtml) { - // avoid H1 per https://github.com/zadam/trilium/issues/1552 // demote H1, and if that conflicts with existing H2, demote that, etc - let transformTags = {}; - const loweraseHtml = dirtyHtml.toLowerCase(); - for (let i = 1; i < 6; ++i) - { - if (loweraseHtml.includes(`