diff --git a/bin/better-sqlite3/linux-desktop-better_sqlite3.node b/bin/better-sqlite3/linux-desktop-better_sqlite3.node new file mode 100644 index 000000000..b28277744 Binary files /dev/null and b/bin/better-sqlite3/linux-desktop-better_sqlite3.node differ diff --git a/bin/better-sqlite3/linux-better_sqlite3.node b/bin/better-sqlite3/linux-server-better_sqlite3.node similarity index 100% rename from bin/better-sqlite3/linux-better_sqlite3.node rename to bin/better-sqlite3/linux-server-better_sqlite3.node diff --git a/bin/better-sqlite3/win-better-sqlite3.node b/bin/better-sqlite3/win-better_sqlite3.node similarity index 100% rename from bin/better-sqlite3/win-better-sqlite3.node rename to bin/better-sqlite3/win-better_sqlite3.node diff --git a/bin/build-linux-x64.sh b/bin/build-linux-x64.sh index 9e4b85601..97ef3044a 100755 --- a/bin/build-linux-x64.sh +++ b/bin/build-linux-x64.sh @@ -11,7 +11,7 @@ rm -r $SRC_DIR/src/public/app-dist/*.mobile.* echo "Copying required linux-x64 binaries" -cp -r bin/better-sqlite3/linux-better_sqlite3.node $SRC_DIR/node_modules/better-sqlite3/build/Release/better_sqlite3.node +cp -r bin/better-sqlite3/linux-desktop-better_sqlite3.node $SRC_DIR/node_modules/better-sqlite3/build/Release/better_sqlite3.node ./node_modules/.bin/electron-packager $SRC_DIR --asar --out=dist --executable-name=trilium --platform=linux --arch=x64 --overwrite diff --git a/bin/build-server.sh b/bin/build-server.sh index 76b42f667..5e0407e67 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -16,9 +16,11 @@ cd .. mv dist/node-v${NODE_VERSION}-linux-x64 $PKG_DIR/node +rm -r $PKG_DIR/node/lib/node_modules/npm + rm -r $PKG_DIR/node_modules/electron* -cp -r bin/better-sqlite3/linux-better_sqlite3.node $SRC_DIR/node_modules/better-sqlite3/build/Release/better_sqlite3.node +cp -r bin/better-sqlite3/linux-server-better_sqlite3.node $PKG_DIR/node_modules/better-sqlite3/build/Release/better_sqlite3.node printf "#!/bin/sh\n./node/bin/node src/www" > $PKG_DIR/trilium.sh chmod 755 $PKG_DIR/trilium.sh diff --git a/libraries/jquery.fancytree.hotkeys.js b/libraries/jquery.fancytree.hotkeys.js deleted file mode 100644 index e19e16d85..000000000 --- a/libraries/jquery.fancytree.hotkeys.js +++ /dev/null @@ -1,35 +0,0 @@ -/**! - * jquery.fancytree.hotkeys.js - * - * Integrate the 'jQuery.Hotkeys' plugin as Fancytree extension: - * https://github.com/jeresig/jquery.hotkeys/ - * - * Copyright (c) 2008-2017, Martin Wendt (http://wwWendt.de) - * Released under the MIT license - * https://github.com/mar10/fancytree/wiki/LicenseInfo - */ -(function($, document) { - "use strict"; - - var initHotkeys = function(tree, data) { - $.each(data, function(event, keys) { - $.each(keys, function(key, handler) { - $(tree.$container).on(event, null, key, function(evt) { - var node = tree.getActiveNode(); - return handler(node, evt); - // return false from the handler will stop default handling. - }); - }); - }); - }; - - $.ui.fancytree.registerExtension({ - name: "hotkeys", - version: "@VERSION", - hotkeys: { }, - treeInit: function(ctx) { - this._superApply(arguments); - initHotkeys(this, ctx.options.hotkeys); - } - }); -}(jQuery, document)); diff --git a/src/public/app/services/app_context.js b/src/public/app/services/app_context.js index 6a06ea9f8..f2190c537 100644 --- a/src/public/app/services/app_context.js +++ b/src/public/app/services/app_context.js @@ -28,8 +28,6 @@ class AppContext extends Component { async start() { await Promise.all([treeCache.initializedPromise, options.initializedPromise]); - $("#loading-indicator").hide(); - this.showWidgets(); this.tabManager.loadTabs(); diff --git a/src/public/app/services/utils.js b/src/public/app/services/utils.js index 136080305..f70acd63b 100644 --- a/src/public/app/services/utils.js +++ b/src/public/app/services/utils.js @@ -1,5 +1,5 @@ function reloadApp() { - window.location.reload(true); + //window.location.reload(true); } function parseDate(str) { diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 3626bc032..c1d42aa38 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -303,7 +303,7 @@ export default class NoteTreeWidget extends TabAwareWidget { this.$tree.fancytree({ titlesTabbable: true, keyboard: true, - extensions: utils.isMobile() ? ["dnd5", "clones"] : ["hotkeys", "dnd5", "clones"], + extensions: ["dnd5", "clones"], source: treeData, scrollOfs: { top: 100, @@ -354,7 +354,6 @@ export default class NoteTreeWidget extends TabAwareWidget { }, expand: (event, data) => this.setExpanded(data.node.data.branchId, true), collapse: (event, data) => this.setExpanded(data.node.data.branchId, false), - //hotkeys: utils.isMobile() ? undefined : { keydown: await this.getHotKeys() }, dnd5: { autoExpandMS: 600, dragStart: (node, data) => { @@ -457,27 +456,27 @@ export default class NoteTreeWidget extends TabAwareWidget { clones: { highlightActiveClones: true }, - // enhanceTitle: async function (event, data) { - // const node = data.node; - // const $span = $(node.span); - // - // if (node.data.noteId !== 'root' - // && node.data.noteId === hoistedNoteService.getHoistedNoteId() - // && $span.find('.unhoist-button').length === 0) { - // - // const unhoistButton = $('  (unhoist)'); - // - // $span.append(unhoistButton); - // } - // - // const note = await treeCache.getNote(node.data.noteId); - // - // if (note.type === 'search' && $span.find('.refresh-search-button').length === 0) { - // const refreshSearchButton = $('  '); - // - // $span.append(refreshSearchButton); - // } - // }, + enhanceTitle: async function (event, data) { + const node = data.node; + const $span = $(node.span); + + if (node.data.noteId !== 'root' + && node.data.noteId === hoistedNoteService.getHoistedNoteId() + && $span.find('.unhoist-button').length === 0) { + + const unhoistButton = $('  (unhoist)'); + + $span.append(unhoistButton); + } + + const note = await treeCache.getNote(node.data.noteId); + + if (note.type === 'search' && $span.find('.refresh-search-button').length === 0) { + const refreshSearchButton = $('  '); + + $span.append(refreshSearchButton); + } + }, // this is done to automatically lazy load all expanded notes after tree load loadChildren: (event, data) => { data.node.visit((subNode) => { @@ -490,6 +489,20 @@ export default class NoteTreeWidget extends TabAwareWidget { } }); + if (!utils.isMobile()) { + this.getHotKeys().then(hotKeys => { + for (const key in hotKeys) { + const handler = hotKeys[key]; + + $(this.tree.$container).on('keydown', null, key, evt => { + const node = this.tree.getActiveNode(); + return handler(node, evt); + // return false from the handler will stop default handling. + }); + } + }); + } + this.$tree.on('contextmenu', '.fancytree-node', e => { const node = $.ui.fancytree.getNode(e); @@ -611,9 +624,7 @@ export default class NoteTreeWidget extends TabAwareWidget { const note = branch.getNoteFromCache(); if (!note) { - console.log("branch", branch); - - throw new Error(`Branch has no note "${branch.noteId}": ${JSON.stringify(note)}`); + throw new Error(`Branch has no note "${branch.noteId}": ${JSON.stringify(branch)}`); } const title = (branch.prefix ? (branch.prefix + " - ") : "") + note.title; @@ -633,11 +644,11 @@ export default class NoteTreeWidget extends TabAwareWidget { refKey: note.noteId, lazy: true, folder: isFolder, - expanded: branch.isExpanded || hoistedNoteId === note.noteId, + expanded: (branch.isExpanded || hoistedNoteId === note.noteId) && note.type !== 'search', key: utils.randomString(12) // this should prevent some "duplicate key" errors }; - if (node.folder && node.expanded) { + if (isFolder && node.expanded) { node.children = this.prepareChildren(note); } @@ -645,14 +656,8 @@ export default class NoteTreeWidget extends TabAwareWidget { } isFolder(note) { - if (note.type === 'search') { - return true; - } - else { - const childBranches = this.getChildBranches(note); - - return childBranches.length > 0; - } + return note.type === 'search' + || this.getChildBranches(note).length > 0; } getChildBranches(parentNote) { diff --git a/src/views/desktop.ejs b/src/views/desktop.ejs index 4422e2670..ef399712f 100644 --- a/src/views/desktop.ejs +++ b/src/views/desktop.ejs @@ -70,7 +70,6 @@ - diff --git a/src/views/mobile.ejs b/src/views/mobile.ejs index 2d10baac3..dc8988871 100644 --- a/src/views/mobile.ejs +++ b/src/views/mobile.ejs @@ -97,10 +97,6 @@ -
-
-
-