Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
saving of widget configuration
zadamb84542064cd4
diff --git a/src/public/javascripts/dialogs/options/sidebar.js b/src/public/javascripts/dialogs/options/sidebar.jsindex 5e1d6d16a5..96a1ca063e 100644--- a/src/public/javascripts/dialogs/options/sidebar.js+++ b/src/public/javascripts/dialogs/options/sidebar.js@@ -7,6 +7,7 @@ export default class SidebarOptions {this.$sidebarMinWidth = $("#sidebar-min-width");this.$sidebarWidthPercent = $("#sidebar-width-percent");this.$showSidebarInNewTab = $("#show-sidebar-in-new-tab");+ this.$widgetsConfiguration = $("#widgets-configuration");this.$widgetsEnabled = $("#widgets-enabled");this.$widgetsDisabled = $("#widgets-disabled");@@ -69,7 +70,8 @@ export default class SidebarOptions {const $expandedCheckbox = $('<div class="expansion-conf">').attr("title", "If checked, the widget will be by default expanded (opened)").append($(`<input type="checkbox"${option.expanded ? ' checked' : ''}>`)- .attr('id', 'widget-exp-' + name))+ .attr('id', 'widget-exp-' + name)+ .change(() => this.save())).append(" ").append($("<label>").attr("for", 'widget-exp-' + name)@@ -83,19 +85,37 @@ export default class SidebarOptions {(option.enabled ? this.$widgetsEnabled : this.$widgetsDisabled).append($el);}- libraryLoader.requireLibrary(libraryLoader.SORTABLE).then(() => {- new Sortable(this.$widgetsEnabled[0], {- group: 'widgets',- handle: '.handle',- animation: 150- });+ await libraryLoader.requireLibrary(libraryLoader.SORTABLE);++ new Sortable(this.$widgetsEnabled[0], {+ group: 'widgets',+ handle: '.handle',+ animation: 150,+ onSort: evt => this.save()+ });- new Sortable(this.$widgetsDisabled[0], {- group: 'widgets',- handle: '.handle',- animation: 150+ new Sortable(this.$widgetsDisabled[0], {+ group: 'widgets',+ handle: '.handle',+ animation: 150,+ onSort: evt => this.save()+ });+ }++ async save() {+ const opts = {};++ this.$widgetsConfiguration.find('.list-group-item').each((i, el) => {+ const widgetName = $(el).find('div[data-widget-name]').attr('data-widget-name');++ opts[widgetName + 'Widget'] = JSON.stringify({+ enabled: $.contains(this.$widgetsEnabled[0], el),+ expanded: $(el).find("input[type=checkbox]").is(":checked"),+ position: (i + 1) * 10});});++ await server.put('options', opts);}parseJsonSafely(str) {diff --git a/src/services/import/tar.js b/src/services/import/tar.jsindex be1a383164..f81d528fc3 100644--- a/src/services/import/tar.js+++ b/src/services/import/tar.js@@ -237,7 +237,7 @@ async function importTar(importContext, fileBuffer, importRootNote) {content = content.toString("UTF-8");if (noteMeta) {- const internalLinks = (noteMeta.attributes || []).find(attr => attr.type === 'relation' && attr.name === 'internal-link');+ const internalLinks = (noteMeta.attributes || []).filter(attr => attr.type === 'relation' && attr.name === 'internal-link');// 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)