mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 18:25:51 +01:00
using dynamic import for dialogs and widgets to speed up initial load
This commit is contained in:
@@ -9,7 +9,7 @@ const $buildDate = $("#build-date");
|
||||
const $buildRevision = $("#build-revision");
|
||||
const $dataDirectory = $("#data-directory");
|
||||
|
||||
async function showDialog() {
|
||||
export async function showDialog() {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
const appInfo = await server.get('app-info');
|
||||
@@ -25,8 +25,4 @@ async function showDialog() {
|
||||
glob.activeDialog = $dialog;
|
||||
|
||||
$dialog.modal();
|
||||
}
|
||||
|
||||
export default {
|
||||
showDialog
|
||||
}
|
||||
@@ -24,11 +24,11 @@ function setLinkType(linkType) {
|
||||
linkTypeChanged();
|
||||
}
|
||||
|
||||
async function showDialogForClone() {
|
||||
export async function showDialogForClone() {
|
||||
showDialog('selected-to-active');
|
||||
}
|
||||
|
||||
async function showDialog(linkType) {
|
||||
export async function showDialog(linkType) {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
@@ -147,8 +147,3 @@ function linkTypeChanged() {
|
||||
}
|
||||
|
||||
$linkTypes.change(linkTypeChanged);
|
||||
|
||||
export default {
|
||||
showDialog,
|
||||
showDialogForClone
|
||||
};
|
||||
@@ -254,7 +254,7 @@ function AttributesModel() {
|
||||
}
|
||||
}
|
||||
|
||||
async function showDialog() {
|
||||
export async function showDialog() {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
// lazily apply bindings on first use
|
||||
@@ -285,8 +285,4 @@ $dialog.on('focus', '.label-value', function (e) {
|
||||
$el: $(this),
|
||||
open: true
|
||||
})
|
||||
});
|
||||
|
||||
export default {
|
||||
showDialog
|
||||
};
|
||||
});
|
||||
@@ -12,7 +12,7 @@ const $noteTitle = $('#branch-prefix-note-title');
|
||||
|
||||
let branchId;
|
||||
|
||||
async function showDialog(node) {
|
||||
export async function showDialog(node) {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
@@ -47,8 +47,4 @@ $form.submit(() => {
|
||||
return false;
|
||||
});
|
||||
|
||||
$dialog.on('shown.bs.modal', () => $treePrefixInput.focus());
|
||||
|
||||
export default {
|
||||
showDialog
|
||||
};
|
||||
$dialog.on('shown.bs.modal', () => $treePrefixInput.focus());
|
||||
@@ -9,7 +9,7 @@ const DELETE_NOTE_BUTTON_ID = "confirm-dialog-delete-note";
|
||||
let resolve;
|
||||
let $originallyFocused; // element focused before the dialog was opened so we can return to it afterwards
|
||||
|
||||
function confirm(message) {
|
||||
export function confirm(message) {
|
||||
$originallyFocused = $(':focus');
|
||||
|
||||
$custom.hide();
|
||||
@@ -27,7 +27,7 @@ function confirm(message) {
|
||||
return new Promise((res, rej) => { resolve = res; });
|
||||
}
|
||||
|
||||
function confirmDeleteNoteBoxWithNote(title) {
|
||||
export function confirmDeleteNoteBoxWithNote(title) {
|
||||
glob.activeDialog = $dialog;
|
||||
|
||||
$confirmContent.text(`Are you sure you want to remove the note "${title}" from relation map?`);
|
||||
@@ -52,7 +52,7 @@ function confirmDeleteNoteBoxWithNote(title) {
|
||||
return new Promise((res, rej) => { resolve = res; });
|
||||
}
|
||||
|
||||
function isDeleteNoteChecked() {
|
||||
export function isDeleteNoteChecked() {
|
||||
return $("#" + DELETE_NOTE_BUTTON_ID + ":checked").length > 0;
|
||||
}
|
||||
|
||||
@@ -77,10 +77,4 @@ function doResolve(ret) {
|
||||
}
|
||||
|
||||
$cancelButton.click(() => doResolve(false));
|
||||
$okButton.click(() => doResolve(true));
|
||||
|
||||
export default {
|
||||
confirm,
|
||||
confirmDeleteNoteBoxWithNote,
|
||||
isDeleteNoteChecked
|
||||
}
|
||||
$okButton.click(() => doResolve(true));
|
||||
@@ -5,7 +5,7 @@ import server from '../services/server.js';
|
||||
const $dialog = $("#event-log-dialog");
|
||||
const $list = $("#event-log-list");
|
||||
|
||||
async function showDialog() {
|
||||
export async function showDialog() {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
@@ -29,8 +29,4 @@ async function showDialog() {
|
||||
|
||||
$list.append(eventEl);
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
showDialog
|
||||
};
|
||||
}
|
||||
@@ -18,7 +18,7 @@ const $opmlVersions = $("#opml-versions");
|
||||
let exportId = '';
|
||||
let branchId = null;
|
||||
|
||||
async function showDialog(node, defaultType) {
|
||||
export async function showDialog(node, defaultType) {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
// each opening of the dialog resets the exportId so we don't associate it with previous exports anymore
|
||||
@@ -134,8 +134,4 @@ messagingService.subscribeToMessages(async message => {
|
||||
|
||||
infoService.showMessage("Export finished successfully.");
|
||||
}
|
||||
});
|
||||
|
||||
export default {
|
||||
showDialog
|
||||
};
|
||||
});
|
||||
@@ -2,14 +2,10 @@ import utils from "../services/utils.js";
|
||||
|
||||
const $dialog = $("#help-dialog");
|
||||
|
||||
async function showDialog() {
|
||||
export async function showDialog() {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
|
||||
$dialog.modal();
|
||||
}
|
||||
|
||||
export default {
|
||||
showDialog
|
||||
}
|
||||
@@ -21,7 +21,7 @@ const $explodeArchivesCheckbox = $("#explode-archives-checkbox");
|
||||
let importId;
|
||||
let importIntoNoteId = null;
|
||||
|
||||
async function showDialog(node) {
|
||||
export async function showDialog(node) {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
// each opening of the dialog resets the importId so we don't associate it with previous imports anymore
|
||||
@@ -74,7 +74,7 @@ async function importIntoNote(importNoteId) {
|
||||
$dialog.modal('hide');
|
||||
}
|
||||
|
||||
async function uploadFiles(importNoteId, files, options) {
|
||||
export async function uploadFiles(importNoteId, files, options) {
|
||||
if (files.length === 0) {
|
||||
return;
|
||||
}
|
||||
@@ -144,8 +144,3 @@ $fileUploadInput.change(() => {
|
||||
$importButton.attr("disabled", "disabled");
|
||||
}
|
||||
});
|
||||
|
||||
export default {
|
||||
showDialog,
|
||||
uploadFiles
|
||||
}
|
||||
@@ -7,7 +7,7 @@ const $okButton = $("#info-dialog-ok-button");
|
||||
let resolve;
|
||||
let $originallyFocused; // element focused before the dialog was opened so we can return to it afterwards
|
||||
|
||||
function info(message) {
|
||||
export function info(message) {
|
||||
$originallyFocused = $(':focus');
|
||||
|
||||
utils.closeActiveDialog();
|
||||
@@ -34,8 +34,4 @@ $dialog.on("hidden.bs.modal", () => {
|
||||
}
|
||||
});
|
||||
|
||||
$okButton.click(() => $dialog.modal("hide"));
|
||||
|
||||
export default {
|
||||
info
|
||||
}
|
||||
$okButton.click(() => $dialog.modal("hide"));
|
||||
@@ -7,7 +7,7 @@ const $dialog = $("#jump-to-note-dialog");
|
||||
const $autoComplete = $("#jump-to-note-autocomplete");
|
||||
const $showInFullTextButton = $("#show-in-full-text-button");
|
||||
|
||||
async function showDialog() {
|
||||
export async function showDialog() {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
@@ -46,7 +46,3 @@ function showInFullText(e) {
|
||||
$showInFullTextButton.click(showInFullText);
|
||||
|
||||
utils.bindElShortcut($dialog, 'ctrl+return', showInFullText);
|
||||
|
||||
export default {
|
||||
showDialog
|
||||
};
|
||||
@@ -26,7 +26,7 @@ let jsPlumbInstance = null;
|
||||
let pzInstance = null;
|
||||
let renderer = null;
|
||||
|
||||
async function showDialog() {
|
||||
export async function showDialog() {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
@@ -216,7 +216,3 @@ function noteIdToId(noteId) {
|
||||
$(".link-map-settings").change(loadNotesAndRelations);
|
||||
|
||||
$maxNotesInput.on("input", loadNotesAndRelations);
|
||||
|
||||
export default {
|
||||
showDialog
|
||||
};
|
||||
@@ -25,7 +25,7 @@ async function convertMarkdownToHtml(text) {
|
||||
infoService.showMessage("Markdown content has been imported into the document.");
|
||||
}
|
||||
|
||||
async function importMarkdownInline() {
|
||||
export async function importMarkdownInline() {
|
||||
if (utils.isElectron()) {
|
||||
const {clipboard} = require('electron');
|
||||
const text = clipboard.readText();
|
||||
@@ -56,8 +56,4 @@ $importButton.click(sendForm);
|
||||
utils.bindElShortcut($dialog, 'ctrl+return', sendForm);
|
||||
|
||||
// for CKEditor integration (button on block toolbar)
|
||||
window.glob.importMarkdownInline = importMarkdownInline;
|
||||
|
||||
export default {
|
||||
importMarkdownInline
|
||||
};
|
||||
window.glob.importMarkdownInline = importMarkdownInline;
|
||||
@@ -9,7 +9,7 @@ const $type = $("#note-info-type");
|
||||
const $mime = $("#note-info-mime");
|
||||
const $okButton = $("#note-info-ok-button");
|
||||
|
||||
function showDialog() {
|
||||
export function showDialog() {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
@@ -26,7 +26,3 @@ function showDialog() {
|
||||
}
|
||||
|
||||
$okButton.click(() => $dialog.modal('hide'));
|
||||
|
||||
export default {
|
||||
showDialog
|
||||
};
|
||||
@@ -14,7 +14,7 @@ async function showCurrentNoteRevisions() {
|
||||
await showNoteRevisionsDialog(noteDetailService.getActiveNoteId());
|
||||
}
|
||||
|
||||
async function showNoteRevisionsDialog(noteId, noteRevisionId) {
|
||||
export async function showNoteRevisionsDialog(noteId, noteRevisionId) {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
@@ -73,7 +73,3 @@ $(document).on('click', "a[data-action='note-revision']", event => {
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
export default {
|
||||
showCurrentNoteRevisions
|
||||
};
|
||||
@@ -4,7 +4,7 @@ import utils from "../services/utils.js";
|
||||
const $dialog = $("#note-source-dialog");
|
||||
const $noteSource = $("#note-source");
|
||||
|
||||
function showDialog() {
|
||||
export function showDialog() {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
@@ -41,8 +41,4 @@ function formatNode(node, level) {
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
export default {
|
||||
showDialog
|
||||
};
|
||||
}
|
||||
@@ -16,7 +16,7 @@ function addTabHandler(handler) {
|
||||
tabHandlers.push(handler);
|
||||
}
|
||||
|
||||
async function showDialog() {
|
||||
export async function showDialog() {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
@@ -38,11 +38,6 @@ async function saveOptions(options) {
|
||||
infoService.showMessage("Options change have been saved.");
|
||||
}
|
||||
|
||||
export default {
|
||||
showDialog,
|
||||
saveOptions
|
||||
};
|
||||
|
||||
addTabHandler((function() {
|
||||
const $themeSelect = $("#theme-select");
|
||||
const $zoomFactorSelect = $("#zoom-factor-select");
|
||||
|
||||
@@ -11,7 +11,7 @@ const $form = $("#prompt-dialog-form");
|
||||
let resolve;
|
||||
let shownCb;
|
||||
|
||||
function ask({ message, defaultValue, shown }) {
|
||||
export function ask({ message, defaultValue, shown }) {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
@@ -58,7 +58,3 @@ $form.submit(() => {
|
||||
|
||||
$dialog.modal('hide');
|
||||
});
|
||||
|
||||
export default {
|
||||
ask
|
||||
}
|
||||
@@ -4,13 +4,13 @@ const $dialog = $("#protected-session-password-dialog");
|
||||
const $passwordForm = $dialog.find(".protected-session-password-form");
|
||||
const $passwordInput = $dialog.find(".protected-session-password");
|
||||
|
||||
function show() {
|
||||
export function show() {
|
||||
$dialog.modal();
|
||||
|
||||
$passwordInput.focus();
|
||||
}
|
||||
|
||||
function close() {
|
||||
export function close() {
|
||||
// this may fal if the dialog has not been previously opened (not sure if still true with Bootstrap modal)
|
||||
try {
|
||||
$dialog.modal('hide');
|
||||
@@ -26,8 +26,3 @@ $passwordForm.submit(() => {
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
export default {
|
||||
show,
|
||||
close
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import server from '../services/server.js';
|
||||
const $dialog = $("#recent-changes-dialog");
|
||||
const $content = $("#recent-changes-content");
|
||||
|
||||
async function showDialog() {
|
||||
export async function showDialog() {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
@@ -76,7 +76,3 @@ function groupByDate(result) {
|
||||
}
|
||||
return groupedByDate;
|
||||
}
|
||||
|
||||
export default {
|
||||
showDialog
|
||||
};
|
||||
@@ -14,7 +14,7 @@ let codeEditor;
|
||||
|
||||
$dialog.on("shown.bs.modal", e => initEditor());
|
||||
|
||||
async function showDialog() {
|
||||
export async function showDialog() {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
@@ -130,7 +130,3 @@ async function showTables() {
|
||||
utils.bindElShortcut($query, 'ctrl+return', execute);
|
||||
|
||||
$executeButton.click(execute);
|
||||
|
||||
export default {
|
||||
showDialog
|
||||
};
|
||||
Reference in New Issue
Block a user