mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	improvements in mobile layout for launchbar
This commit is contained in:
		
							
								
								
									
										1
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -5,7 +5,6 @@ | |||||||
|   "requires": true, |   "requires": true, | ||||||
|   "packages": { |   "packages": { | ||||||
|     "": { |     "": { | ||||||
|       "name": "trilium", |  | ||||||
|       "version": "0.57.3", |       "version": "0.57.3", | ||||||
|       "hasInstallScript": true, |       "hasInstallScript": true, | ||||||
|       "license": "AGPL-3.0-only", |       "license": "AGPL-3.0-only", | ||||||
|   | |||||||
| @@ -63,6 +63,8 @@ class Attribute extends AbstractEntity { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     init() { |     init() { | ||||||
|  |         this.validate(); | ||||||
|  |  | ||||||
|         if (this.attributeId) { |         if (this.attributeId) { | ||||||
|             this.becca.attributes[this.attributeId] = this; |             this.becca.attributes[this.attributeId] = this; | ||||||
|         } |         } | ||||||
| @@ -85,6 +87,16 @@ class Attribute extends AbstractEntity { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     validate() { | ||||||
|  |         if (!["label", "relation"].includes(this.type)) { | ||||||
|  |             throw new Error(`Invalid attribute type '${this.type}' in attribute '${this.attributeId}'`); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (!this.name?.trim()) { | ||||||
|  |             throw new Error(`Invalid empty name in attribute '${this.attributeId}'`); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     get isAffectingSubtree() { |     get isAffectingSubtree() { | ||||||
|         return this.isInheritable |         return this.isInheritable | ||||||
|             || (this.type === 'relation' && this.name === 'template'); |             || (this.type === 'relation' && this.name === 'template'); | ||||||
| @@ -162,6 +174,8 @@ class Attribute extends AbstractEntity { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     beforeSaving() { |     beforeSaving() { | ||||||
|  |         this.validate(); | ||||||
|  |  | ||||||
|         if (this.type === 'relation') { |         if (this.type === 'relation') { | ||||||
|             if (!(this.value in this.becca.notes)) { |             if (!(this.value in this.becca.notes)) { | ||||||
|                 throw new Error(`Cannot save relation '${this.name}' since it target not existing note '${this.value}'.`); |                 throw new Error(`Cannot save relation '${this.name}' since it target not existing note '${this.value}'.`); | ||||||
|   | |||||||
| @@ -5,11 +5,11 @@ export default class MobileScreenSwitcherExecutor extends Component { | |||||||
|         if (screen !== this.activeScreen) { |         if (screen !== this.activeScreen) { | ||||||
|             this.activeScreen = screen; |             this.activeScreen = screen; | ||||||
|  |  | ||||||
|  |             if (screen === 'tree') { | ||||||
|  |                 document.location.hash = ''; | ||||||
|  |             } | ||||||
|  |  | ||||||
|             this.triggerEvent('activeScreenChanged', {activeScreen: screen}); |             this.triggerEvent('activeScreenChanged', {activeScreen: screen}); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     initialRenderCompleteEvent() { |  | ||||||
|         this.setActiveScreenCommand({screen: 'tree'}); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -83,6 +83,8 @@ class NoteContext extends Component { | |||||||
|         if (utils.isDesktop()) { |         if (utils.isDesktop()) { | ||||||
|             // close dangling autocompletes after closing the tab |             // close dangling autocompletes after closing the tab | ||||||
|             $(".aa-input").autocomplete("close"); |             $(".aa-input").autocomplete("close"); | ||||||
|  |         } else if (utils.isMobile()) { | ||||||
|  |             this.triggerCommand('setActiveScreen', {screen: 'detail'}); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -117,7 +117,7 @@ export default class MobileLayout { | |||||||
|             .child(new FlexContainer("row") |             .child(new FlexContainer("row") | ||||||
|                 .filling() |                 .filling() | ||||||
|                 .child(new ScreenContainer("tree", 'column') |                 .child(new ScreenContainer("tree", 'column') | ||||||
|                     .class("d-sm-flex d-md-flex d-lg-flex d-xl-flex col-12 col-sm-5 col-md-4 col-lg-4 col-xl-4") |                     .class("d-sm-flex d-md-flex d-lg-flex d-xl-flex col-12 col-sm-5 col-md-4 col-lg-3 col-xl-3") | ||||||
|                     .css("max-height", "100%") |                     .css("max-height", "100%") | ||||||
|                     .css('padding-left', 0) |                     .css('padding-left', 0) | ||||||
|                     .css('contain', 'content') |                     .css('contain', 'content') | ||||||
| @@ -125,7 +125,7 @@ export default class MobileLayout { | |||||||
|                     .child(new NoteTreeWidget() |                     .child(new NoteTreeWidget() | ||||||
|                         .cssBlock(FANCYTREE_CSS))) |                         .cssBlock(FANCYTREE_CSS))) | ||||||
|                 .child(new ScreenContainer("detail", "column") |                 .child(new ScreenContainer("detail", "column") | ||||||
|                     .class("d-sm-flex d-md-flex d-lg-flex d-xl-flex col-12 col-sm-7 col-md-8 col-lg-8") |                     .class("d-sm-flex d-md-flex d-lg-flex d-xl-flex col-12 col-sm-7 col-md-8 col-lg-9") | ||||||
|                     .css('max-height', '100%') |                     .css('max-height', '100%') | ||||||
|                     .child(new FlexContainer('row').contentSized() |                     .child(new FlexContainer('row').contentSized() | ||||||
|                         .css('font-size', 'larger') |                         .css('font-size', 'larger') | ||||||
|   | |||||||
| @@ -95,10 +95,15 @@ const TPL = ` | |||||||
|         </li> |         </li> | ||||||
|  |  | ||||||
|         <li class="dropdown-item switch-to-mobile-version-button" data-trigger-command="switchToMobileVersion"> |         <li class="dropdown-item switch-to-mobile-version-button" data-trigger-command="switchToMobileVersion"> | ||||||
|             <span class="bx bx-empty"></span> |             <span class="bx bx-mobile"></span> | ||||||
|             Switch to mobile version |             Switch to mobile version | ||||||
|         </li> |         </li> | ||||||
|          |          | ||||||
|  |         <li class="dropdown-item switch-to-desktop-version-button" data-trigger-command="switchToDesktopVersion"> | ||||||
|  |             <span class="bx bx-desktop"></span> | ||||||
|  |             Switch to desktop version | ||||||
|  |         </li> | ||||||
|  |          | ||||||
|         <span class="zoom-container dropdown-item"> |         <span class="zoom-container dropdown-item"> | ||||||
|             <div> |             <div> | ||||||
|                 <span class="bx bx-empty"></span> |                 <span class="bx bx-empty"></span> | ||||||
| @@ -218,7 +223,8 @@ export default class GlobalMenuWidget extends BasicWidget { | |||||||
|  |  | ||||||
|         this.$widget.find(".logout-button").toggle(!isElectron); |         this.$widget.find(".logout-button").toggle(!isElectron); | ||||||
|         this.$widget.find(".open-dev-tools-button").toggle(isElectron); |         this.$widget.find(".open-dev-tools-button").toggle(isElectron); | ||||||
|         this.$widget.find(".switch-to-mobile-version-button").toggle(!isElectron); |         this.$widget.find(".switch-to-mobile-version-button").toggle(!isElectron && utils.isDesktop()); | ||||||
|  |         this.$widget.find(".switch-to-desktop-version-button").toggle(!isElectron && utils.isMobile()); | ||||||
|  |  | ||||||
|         this.$widget.on('click', '.dropdown-item', e => { |         this.$widget.on('click', '.dropdown-item', e => { | ||||||
|             if ($(e.target).parent(".zoom-buttons")) { |             if ($(e.target).parent(".zoom-buttons")) { | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ import BasicWidget from "../basic_widget.js"; | |||||||
| import NoteLauncher from "../buttons/launcher/note_launcher.js"; | import NoteLauncher from "../buttons/launcher/note_launcher.js"; | ||||||
| import ScriptLauncher from "../buttons/launcher/script_launcher.js"; | import ScriptLauncher from "../buttons/launcher/script_launcher.js"; | ||||||
| import CommandButtonWidget from "../buttons/command_button.js"; | import CommandButtonWidget from "../buttons/command_button.js"; | ||||||
|  | import utils from "../../services/utils.js"; | ||||||
|  |  | ||||||
| export default class LauncherWidget extends BasicWidget { | export default class LauncherWidget extends BasicWidget { | ||||||
|     constructor() { |     constructor() { | ||||||
| @@ -30,6 +31,10 @@ export default class LauncherWidget extends BasicWidget { | |||||||
|             throw new Error(`Note '${note.noteId}' '${note.title}' is not a launcher even though it's in the launcher subtree`); |             throw new Error(`Note '${note.noteId}' '${note.title}' is not a launcher even though it's in the launcher subtree`); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         if (!utils.isDesktop() && note.hasLabel('desktopOnly')) { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         const launcherType = note.getLabelValue("launcherType"); |         const launcherType = note.getLabelValue("launcherType"); | ||||||
|  |  | ||||||
|         if (launcherType === 'command') { |         if (launcherType === 'command') { | ||||||
| @@ -54,6 +59,8 @@ export default class LauncherWidget extends BasicWidget { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         this.child(this.innerWidget); |         this.child(this.innerWidget); | ||||||
|  |  | ||||||
|  |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     initCommandLauncherWidget(note) { |     initCommandLauncherWidget(note) { | ||||||
|   | |||||||
| @@ -32,8 +32,11 @@ export default class LauncherContainer extends FlexContainer { | |||||||
|                 .map(async launcherNote => { |                 .map(async launcherNote => { | ||||||
|                     try { |                     try { | ||||||
|                         const launcherWidget = new LauncherWidget(); |                         const launcherWidget = new LauncherWidget(); | ||||||
|                         await launcherWidget.initLauncher(launcherNote); |                         const success = await launcherWidget.initLauncher(launcherNote); | ||||||
|                         this.child(launcherWidget); |  | ||||||
|  |                         if (success) { | ||||||
|  |                             this.child(launcherWidget); | ||||||
|  |                         } | ||||||
|                     } |                     } | ||||||
|                     catch (e) { |                     catch (e) { | ||||||
|                         console.error(e); |                         console.error(e); | ||||||
|   | |||||||
| @@ -383,10 +383,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { | |||||||
|  |  | ||||||
|                 const activeNoteContext = appContext.tabManager.getActiveContext(); |                 const activeNoteContext = appContext.tabManager.getActiveContext(); | ||||||
|                 await activeNoteContext.setNote(notePath); |                 await activeNoteContext.setNote(notePath); | ||||||
|  |  | ||||||
|                 if (utils.isMobile()) { |  | ||||||
|                     this.triggerCommand('setActiveScreen', {screen: 'detail'}); |  | ||||||
|                 } |  | ||||||
|             }, |             }, | ||||||
|             expand: (event, data) => this.setExpanded(data.node.data.branchId, true), |             expand: (event, data) => this.setExpanded(data.node.data.branchId, true), | ||||||
|             collapse: (event, data) => this.setExpanded(data.node.data.branchId, false), |             collapse: (event, data) => this.setExpanded(data.node.data.branchId, false), | ||||||
|   | |||||||
| @@ -171,11 +171,17 @@ const HIDDEN_SUBTREE_DEFINITION = { | |||||||
|                     attributes: [ { type: 'label', name: 'docName', value: 'launchbar_intro' } ], |                     attributes: [ { type: 'label', name: 'docName', value: 'launchbar_intro' } ], | ||||||
|                     children: [ |                     children: [ | ||||||
|                         { id: 'lbNewNote', title: 'New Note', type: 'launcher', command: 'createNoteIntoInbox', icon: 'bx bx-file-blank' }, |                         { id: 'lbNewNote', title: 'New Note', type: 'launcher', command: 'createNoteIntoInbox', icon: 'bx bx-file-blank' }, | ||||||
|                         { id: 'lbSearch', title: 'Search Notes', type: 'launcher', command: 'searchNotes', icon: 'bx bx-search' }, |                         { id: 'lbSearch', title: 'Search Notes', type: 'launcher', command: 'searchNotes', icon: 'bx bx-search', attributes: [ | ||||||
|                         { id: 'lbJumpTo', title: 'Jump to Note', type: 'launcher', command: 'jumpToNote', icon: 'bx bx-send' }, |                                 { type: 'label', name: 'desktopOnly' } | ||||||
|  |                             ] }, | ||||||
|  |                         { id: 'lbJumpTo', title: 'Jump to Note', type: 'launcher', command: 'jumpToNote', icon: 'bx bx-send', attributes: [ | ||||||
|  |                                 { type: 'label', name: 'desktopOnly' } | ||||||
|  |                             ] }, | ||||||
|                         { id: 'lbNoteMap', title: 'Note Map', type: 'launcher', targetNoteId: 'globalNoteMap', icon: 'bx bx-map-alt' }, |                         { id: 'lbNoteMap', title: 'Note Map', type: 'launcher', targetNoteId: 'globalNoteMap', icon: 'bx bx-map-alt' }, | ||||||
|                         { id: 'lbCalendar', title: 'Calendar', type: 'launcher', builtinWidget: 'calendar', icon: 'bx bx-calendar' }, |                         { id: 'lbCalendar', title: 'Calendar', type: 'launcher', builtinWidget: 'calendar', icon: 'bx bx-calendar' }, | ||||||
|                         { id: 'lbRecentChanges', title: 'Recent Changes', type: 'launcher', command: 'showRecentChanges', icon: 'bx bx-history' }, |                         { id: 'lbRecentChanges', title: 'Recent Changes', type: 'launcher', command: 'showRecentChanges', icon: 'bx bx-history', attributes: [ | ||||||
|  |                                 { type: 'label', name: 'desktopOnly' } | ||||||
|  |                             ] }, | ||||||
|                         { id: 'lbSpacer1', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "50", growthFactor: "0" }, |                         { id: 'lbSpacer1', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "50", growthFactor: "0" }, | ||||||
|                         { id: 'lbBookmarks', title: 'Bookmarks', type: 'launcher', builtinWidget: 'bookmarks', icon: 'bx bx-bookmark' }, |                         { id: 'lbBookmarks', title: 'Bookmarks', type: 'launcher', builtinWidget: 'bookmarks', icon: 'bx bx-bookmark' }, | ||||||
|                         { id: 'lbSpacer2', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "0", growthFactor: "1" }, |                         { id: 'lbSpacer2', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "0", growthFactor: "1" }, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user