mirror of
https://github.com/zadam/trilium.git
synced 2025-11-05 04:45:47 +01:00
split out library loader
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import treeService from '../services/tree.js';
|
||||
import cloningService from '../services/cloning.js';
|
||||
import linkService from '../services/link.js';
|
||||
import noteDetailService from '../services/note_detail.js';
|
||||
|
||||
@@ -30,14 +30,18 @@ async function showDialog() {
|
||||
$noteTitle.html(noteTitle);
|
||||
}
|
||||
|
||||
$form.submit(() => {
|
||||
async function savePrefix() {
|
||||
const prefix = $treePrefixInput.val();
|
||||
|
||||
server.put('tree/' + branchId + '/set-prefix', {
|
||||
prefix: prefix
|
||||
}).then(() => treeService.setPrefix(branchId, prefix));
|
||||
await server.put('tree/' + branchId + '/set-prefix', { prefix: prefix });
|
||||
|
||||
await treeService.setPrefix(branchId, prefix);
|
||||
|
||||
$dialog.dialog("close");
|
||||
}
|
||||
|
||||
$form.submit(() => {
|
||||
savePrefix();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@ function formatNode(node, level) {
|
||||
const indentAfter = new Array(level - 1).join(' ');
|
||||
let textNode;
|
||||
|
||||
for (let i = 0; i < node.children.length; i++) {
|
||||
for (const i = 0; i < node.children.length; i++) {
|
||||
textNode = document.createTextNode('\n' + indentBefore);
|
||||
node.insertBefore(textNode, node.children[i]);
|
||||
|
||||
|
||||
@@ -27,6 +27,21 @@ function addRecentNote(branchId, notePath) {
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
async function getNoteTitle(notePath) {
|
||||
let noteTitle;
|
||||
|
||||
try {
|
||||
noteTitle = await treeUtils.getNotePathTitle(notePath);
|
||||
}
|
||||
catch (e) {
|
||||
noteTitle = "[error - can't find note title]";
|
||||
|
||||
messagingService.logError("Could not find title for notePath=" + notePath + ", stack=" + e.stack);
|
||||
}
|
||||
|
||||
return noteTitle;
|
||||
}
|
||||
|
||||
async function showDialog() {
|
||||
glob.activeDialog = $dialog;
|
||||
|
||||
@@ -44,19 +59,8 @@ async function showDialog() {
|
||||
const items = [];
|
||||
|
||||
for (const notePath of recNotes) {
|
||||
let noteTitle;
|
||||
|
||||
try {
|
||||
noteTitle = await treeUtils.getNotePathTitle(notePath);
|
||||
}
|
||||
catch (e) {
|
||||
noteTitle = "[error - can't find note title]";
|
||||
|
||||
messagingService.logError("Could not find title for notePath=" + notePath + ", stack=" + e.stack);
|
||||
}
|
||||
|
||||
items.push({
|
||||
label: noteTitle,
|
||||
label: await getNoteTitle(notePath),
|
||||
value: notePath
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ import infoService from "../services/info.js";
|
||||
const $dialog = $("#settings-dialog");
|
||||
const $tabs = $("#settings-tabs");
|
||||
|
||||
const settingModules = [];
|
||||
const tabHandlers = [];
|
||||
|
||||
function addModule(module) {
|
||||
settingModules.push(module);
|
||||
function addTabHandler(handler) {
|
||||
tabHandlers.push(handler);
|
||||
}
|
||||
|
||||
async function showDialog() {
|
||||
@@ -26,9 +26,9 @@ async function showDialog() {
|
||||
|
||||
$tabs.tabs();
|
||||
|
||||
for (const module of settingModules) {
|
||||
if (module.settingsLoaded) {
|
||||
module.settingsLoaded(settings);
|
||||
for (const handler of tabHandlers) {
|
||||
if (handler.settingsLoaded) {
|
||||
handler.settingsLoaded(settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ export default {
|
||||
saveSettings
|
||||
};
|
||||
|
||||
addModule((function() {
|
||||
addTabHandler((function() {
|
||||
const $form = $("#change-password-form");
|
||||
const $oldPassword = $("#old-password");
|
||||
const $newPassword1 = $("#new-password1");
|
||||
@@ -93,7 +93,7 @@ addModule((function() {
|
||||
};
|
||||
})());
|
||||
|
||||
addModule((function() {
|
||||
addTabHandler((function() {
|
||||
const $form = $("#protected-session-timeout-form");
|
||||
const $protectedSessionTimeout = $("#protected-session-timeout-in-seconds");
|
||||
const settingName = 'protected_session_timeout';
|
||||
@@ -117,7 +117,7 @@ addModule((function() {
|
||||
};
|
||||
})());
|
||||
|
||||
addModule((function () {
|
||||
addTabHandler((function () {
|
||||
const $form = $("#note-revision-snapshot-time-interval-form");
|
||||
const $timeInterval = $("#note-revision-snapshot-time-interval-in-seconds");
|
||||
const settingName = 'note_revision_snapshot_time_interval';
|
||||
@@ -137,7 +137,7 @@ addModule((function () {
|
||||
};
|
||||
})());
|
||||
|
||||
addModule((async function () {
|
||||
addTabHandler((async function () {
|
||||
const $appVersion = $("#app-version");
|
||||
const $dbVersion = $("#db-version");
|
||||
const $buildDate = $("#build-date");
|
||||
@@ -154,7 +154,7 @@ addModule((async function () {
|
||||
return {};
|
||||
})());
|
||||
|
||||
addModule((async function () {
|
||||
addTabHandler((async function () {
|
||||
const $forceFullSyncButton = $("#force-full-sync-button");
|
||||
const $fillSyncRowsButton = $("#fill-sync-rows-button");
|
||||
const $anonymizeButton = $("#anonymize-button");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import utils from '../services/utils.js';
|
||||
import libraryLoader from '../services/library_loader.js';
|
||||
import server from '../services/server.js';
|
||||
import infoService from "../services/info.js";
|
||||
|
||||
@@ -25,7 +26,7 @@ function showDialog() {
|
||||
|
||||
async function initEditor() {
|
||||
if (!codeEditor) {
|
||||
await utils.requireLibrary(utils.CODE_MIRROR);
|
||||
await libraryLoader.requireLibrary(libraryLoader.CODE_MIRROR);
|
||||
|
||||
CodeMirror.keyMap.default["Shift-Tab"] = "indentLess";
|
||||
CodeMirror.keyMap.default["Tab"] = "indentMore";
|
||||
|
||||
Reference in New Issue
Block a user