mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 21:19:01 +01:00 
			
		
		
		
	saving of widget configuration
This commit is contained in:
		
							parent
							
								
									8ab2c924c4
								
							
						
					
					
						commit
						b84542064c
					
				@ -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.$widgetsDisabled[0], {
 | 
			
		||||
                group: 'widgets',
 | 
			
		||||
                handle: '.handle',
 | 
			
		||||
                animation: 150
 | 
			
		||||
        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,
 | 
			
		||||
            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) {
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user