Merge remote-tracking branch 'origin/master'

This commit is contained in:
zadam 2020-08-27 12:47:29 +02:00
commit c8af250caa
11 changed files with 46 additions and 81 deletions

Binary file not shown.

View file

@ -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

View file

@ -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

View file

@ -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));

View file

@ -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();

View file

@ -1,5 +1,5 @@
function reloadApp() {
window.location.reload(true);
//window.location.reload(true);
}
function parseDate(str) {

View file

@ -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 = $('<span>&nbsp; (<a class="unhoist-button">unhoist</a>)</span>');
//
// $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>&nbsp; <span class="refresh-search-button bx bx-refresh" title="Refresh saved search results"></span></span>');
//
// $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 = $('<span>&nbsp; (<a class="unhoist-button">unhoist</a>)</span>');
$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>&nbsp; <span class="refresh-search-button bx bx-refresh" title="Refresh saved search results"></span></span>');
$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) {

View file

@ -70,7 +70,6 @@
<script src="libraries/fancytree/jquery.fancytree-all-deps.min.js"></script>
<script src="libraries/jquery.hotkeys.js"></script>
<script src="libraries/jquery.fancytree.hotkeys.js"></script>
<script src="libraries/autocomplete.jquery.min.js"></script>

View file

@ -97,10 +97,6 @@
<body class="mobile">
<noscript>Trilium requires JavaScript to be enabled.</noscript>
<div style="text-align: center" id="loading-indicator">
<div class="lds-roller"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
</div>
<div id="toast-container" class="d-flex flex-column justify-content-center align-items-center"></div>
<div class="dropdown-menu dropdown-menu-sm" id="context-menu-container"></div>