mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	chore(prettier): fix all files
This commit is contained in:
		| @@ -5,11 +5,11 @@ import { randomSecureToken, isWindows } from "./utils.js"; | ||||
| import log from "./log.js"; | ||||
| import dateUtils from "./date_utils.js"; | ||||
| import keyboardActions from "./keyboard_actions.js"; | ||||
| import { KeyboardShortcutWithRequiredActionName } from './keyboard_actions_interface.js'; | ||||
| import { KeyboardShortcutWithRequiredActionName } from "./keyboard_actions_interface.js"; | ||||
|  | ||||
| function initDocumentOptions() { | ||||
|     optionService.createOption('documentId', randomSecureToken(16), false); | ||||
|     optionService.createOption('documentSecret', randomSecureToken(16), false); | ||||
|     optionService.createOption("documentId", randomSecureToken(16), false); | ||||
|     optionService.createOption("documentSecret", randomSecureToken(16), false); | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -26,10 +26,10 @@ interface NotSyncedOpts { | ||||
| interface DefaultOption { | ||||
|     name: OptionNames; | ||||
|     /** | ||||
|     * The value to initialize the option with, if the option is not already present in the database. | ||||
|     * | ||||
|     * If a function is passed Gin instead, the function is called if the option does not exist (with access to the current options) and the return value is used instead. Useful to migrate a new option with a value depending on some other option that might be initialized. | ||||
|     */ | ||||
|      * The value to initialize the option with, if the option is not already present in the database. | ||||
|      * | ||||
|      * If a function is passed Gin instead, the function is called if the option does not exist (with access to the current options) and the return value is used instead. Useful to migrate a new option with a value depending on some other option that might be initialized. | ||||
|      */ | ||||
|     value: string | ((options: OptionMap) => string); | ||||
|     isSynced: boolean; | ||||
| } | ||||
| @@ -41,95 +41,107 @@ interface DefaultOption { | ||||
|  * @param opts additional options to be initialized, for example the sync configuration. | ||||
|  */ | ||||
| async function initNotSyncedOptions(initialized: boolean, opts: NotSyncedOpts = {}) { | ||||
|     optionService.createOption('openNoteContexts', JSON.stringify([ | ||||
|         { | ||||
|             notePath: 'root', | ||||
|             active: true | ||||
|         } | ||||
|     ]), false); | ||||
|     optionService.createOption( | ||||
|         "openNoteContexts", | ||||
|         JSON.stringify([ | ||||
|             { | ||||
|                 notePath: "root", | ||||
|                 active: true | ||||
|             } | ||||
|         ]), | ||||
|         false | ||||
|     ); | ||||
|  | ||||
|     optionService.createOption('lastDailyBackupDate', dateUtils.utcNowDateTime(), false); | ||||
|     optionService.createOption('lastWeeklyBackupDate', dateUtils.utcNowDateTime(), false); | ||||
|     optionService.createOption('lastMonthlyBackupDate', dateUtils.utcNowDateTime(), false); | ||||
|     optionService.createOption('dbVersion', appInfo.dbVersion.toString(), false); | ||||
|     optionService.createOption("lastDailyBackupDate", dateUtils.utcNowDateTime(), false); | ||||
|     optionService.createOption("lastWeeklyBackupDate", dateUtils.utcNowDateTime(), false); | ||||
|     optionService.createOption("lastMonthlyBackupDate", dateUtils.utcNowDateTime(), false); | ||||
|     optionService.createOption("dbVersion", appInfo.dbVersion.toString(), false); | ||||
|  | ||||
|     optionService.createOption('initialized', initialized ? 'true' : 'false', false); | ||||
|     optionService.createOption("initialized", initialized ? "true" : "false", false); | ||||
|  | ||||
|     optionService.createOption('lastSyncedPull', '0', false); | ||||
|     optionService.createOption('lastSyncedPush', '0', false); | ||||
|     optionService.createOption("lastSyncedPull", "0", false); | ||||
|     optionService.createOption("lastSyncedPush", "0", false); | ||||
|  | ||||
|     optionService.createOption('theme', 'next', false); | ||||
|     optionService.createOption("theme", "next", false); | ||||
|  | ||||
|     optionService.createOption('syncServerHost', opts.syncServerHost || '', false); | ||||
|     optionService.createOption('syncServerTimeout', '120000', false); | ||||
|     optionService.createOption('syncProxy', opts.syncProxy || '', false); | ||||
|     optionService.createOption("syncServerHost", opts.syncServerHost || "", false); | ||||
|     optionService.createOption("syncServerTimeout", "120000", false); | ||||
|     optionService.createOption("syncProxy", opts.syncProxy || "", false); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Contains all the default options that must be initialized on new and existing databases (at startup). The value can also be determined based on other options, provided they have already been initialized. | ||||
|  */ | ||||
| const defaultOptions: DefaultOption[] = [ | ||||
|     { name: 'revisionSnapshotTimeInterval', value: '600', isSynced: true }, | ||||
|     { name: 'revisionSnapshotNumberLimit', value: '-1', isSynced: true }, | ||||
|     { name: 'protectedSessionTimeout', value: '600', isSynced: true }, | ||||
|     { name: 'zoomFactor', value: isWindows() ? '0.9' : '1.0', isSynced: false }, | ||||
|     { name: 'overrideThemeFonts', value: 'false', isSynced: false }, | ||||
|     { name: 'mainFontFamily', value: 'theme', isSynced: false }, | ||||
|     { name: 'mainFontSize', value: '100', isSynced: false }, | ||||
|     { name: 'treeFontFamily', value: 'theme', isSynced: false }, | ||||
|     { name: 'treeFontSize', value: '100', isSynced: false }, | ||||
|     { name: 'detailFontFamily', value: 'theme', isSynced: false }, | ||||
|     { name: 'detailFontSize', value: '110', isSynced: false }, | ||||
|     { name: 'monospaceFontFamily', value: 'theme', isSynced: false }, | ||||
|     { name: 'monospaceFontSize', value: '110', isSynced: false }, | ||||
|     { name: 'spellCheckEnabled', value: 'true', isSynced: false }, | ||||
|     { name: 'spellCheckLanguageCode', value: 'en-US', isSynced: false }, | ||||
|     { name: 'imageMaxWidthHeight', value: '2000', isSynced: true }, | ||||
|     { name: 'imageJpegQuality', value: '75', isSynced: true }, | ||||
|     { name: 'autoFixConsistencyIssues', value: 'true', isSynced: false }, | ||||
|     { name: 'vimKeymapEnabled', value: 'false', isSynced: false }, | ||||
|     { name: 'codeLineWrapEnabled', value: 'true', isSynced: false }, | ||||
|     { name: 'codeNotesMimeTypes', value: '["text/x-csrc","text/x-c++src","text/x-csharp","text/css","text/x-go","text/x-groovy","text/x-haskell","text/html","message/http","text/x-java","application/javascript;env=frontend","application/javascript;env=backend","application/json","text/x-kotlin","text/x-markdown","text/x-perl","text/x-php","text/x-python","text/x-ruby",null,"text/x-sql","text/x-sqlite;schema=trilium","text/x-swift","text/xml","text/x-yaml","text/x-sh"]', isSynced: true }, | ||||
|     { name: 'leftPaneWidth', value: '25', isSynced: false }, | ||||
|     { name: 'leftPaneVisible', value: 'true', isSynced: false }, | ||||
|     { name: 'rightPaneWidth', value: '25', isSynced: false }, | ||||
|     { name: 'rightPaneVisible', value: 'true', isSynced: false }, | ||||
|     { name: 'nativeTitleBarVisible', value: 'false', isSynced: false }, | ||||
|     { name: 'eraseEntitiesAfterTimeInSeconds', value: '604800', isSynced: true }, // default is 7 days | ||||
|     { name: 'hideArchivedNotes_main', value: 'false', isSynced: false }, | ||||
|     { name: 'debugModeEnabled', value: 'false', isSynced: false }, | ||||
|     { name: 'headingStyle', value: 'underline', isSynced: true }, | ||||
|     { name: 'autoCollapseNoteTree', value: 'true', isSynced: true }, | ||||
|     { name: 'autoReadonlySizeText', value: '10000', isSynced: false }, | ||||
|     { name: 'autoReadonlySizeCode', value: '30000', isSynced: false }, | ||||
|     { name: 'dailyBackupEnabled', value: 'true', isSynced: false }, | ||||
|     { name: 'weeklyBackupEnabled', value: 'true', isSynced: false }, | ||||
|     { name: 'monthlyBackupEnabled', value: 'true', isSynced: false }, | ||||
|     { name: 'maxContentWidth', value: '1200', isSynced: false }, | ||||
|     { name: 'compressImages', value: 'true', isSynced: true }, | ||||
|     { name: 'downloadImagesAutomatically', value: 'true', isSynced: true }, | ||||
|     { name: 'minTocHeadings', value: '5', isSynced: true }, | ||||
|     { name: 'highlightsList', value: '["bold","italic","underline","color","bgColor"]', isSynced: true }, | ||||
|     { name: 'checkForUpdates', value: 'true', isSynced: true }, | ||||
|     { name: 'disableTray', value: 'false', isSynced: false }, | ||||
|     { name: 'eraseUnusedAttachmentsAfterSeconds', value: '2592000', isSynced: true }, | ||||
|     { name: 'customSearchEngineName', value: 'DuckDuckGo', isSynced: true }, | ||||
|     { name: 'customSearchEngineUrl', value: 'https://duckduckgo.com/?q={keyword}', isSynced: true }, | ||||
|     { name: 'promotedAttributesOpenInRibbon', value: 'true', isSynced: true }, | ||||
|     { name: 'editedNotesOpenInRibbon', value: 'true', isSynced: true }, | ||||
|     { name: "revisionSnapshotTimeInterval", value: "600", isSynced: true }, | ||||
|     { name: "revisionSnapshotNumberLimit", value: "-1", isSynced: true }, | ||||
|     { name: "protectedSessionTimeout", value: "600", isSynced: true }, | ||||
|     { name: "zoomFactor", value: isWindows() ? "0.9" : "1.0", isSynced: false }, | ||||
|     { name: "overrideThemeFonts", value: "false", isSynced: false }, | ||||
|     { name: "mainFontFamily", value: "theme", isSynced: false }, | ||||
|     { name: "mainFontSize", value: "100", isSynced: false }, | ||||
|     { name: "treeFontFamily", value: "theme", isSynced: false }, | ||||
|     { name: "treeFontSize", value: "100", isSynced: false }, | ||||
|     { name: "detailFontFamily", value: "theme", isSynced: false }, | ||||
|     { name: "detailFontSize", value: "110", isSynced: false }, | ||||
|     { name: "monospaceFontFamily", value: "theme", isSynced: false }, | ||||
|     { name: "monospaceFontSize", value: "110", isSynced: false }, | ||||
|     { name: "spellCheckEnabled", value: "true", isSynced: false }, | ||||
|     { name: "spellCheckLanguageCode", value: "en-US", isSynced: false }, | ||||
|     { name: "imageMaxWidthHeight", value: "2000", isSynced: true }, | ||||
|     { name: "imageJpegQuality", value: "75", isSynced: true }, | ||||
|     { name: "autoFixConsistencyIssues", value: "true", isSynced: false }, | ||||
|     { name: "vimKeymapEnabled", value: "false", isSynced: false }, | ||||
|     { name: "codeLineWrapEnabled", value: "true", isSynced: false }, | ||||
|     { | ||||
|         name: "codeNotesMimeTypes", | ||||
|         value: '["text/x-csrc","text/x-c++src","text/x-csharp","text/css","text/x-go","text/x-groovy","text/x-haskell","text/html","message/http","text/x-java","application/javascript;env=frontend","application/javascript;env=backend","application/json","text/x-kotlin","text/x-markdown","text/x-perl","text/x-php","text/x-python","text/x-ruby",null,"text/x-sql","text/x-sqlite;schema=trilium","text/x-swift","text/xml","text/x-yaml","text/x-sh"]', | ||||
|         isSynced: true | ||||
|     }, | ||||
|     { name: "leftPaneWidth", value: "25", isSynced: false }, | ||||
|     { name: "leftPaneVisible", value: "true", isSynced: false }, | ||||
|     { name: "rightPaneWidth", value: "25", isSynced: false }, | ||||
|     { name: "rightPaneVisible", value: "true", isSynced: false }, | ||||
|     { name: "nativeTitleBarVisible", value: "false", isSynced: false }, | ||||
|     { name: "eraseEntitiesAfterTimeInSeconds", value: "604800", isSynced: true }, // default is 7 days | ||||
|     { name: "hideArchivedNotes_main", value: "false", isSynced: false }, | ||||
|     { name: "debugModeEnabled", value: "false", isSynced: false }, | ||||
|     { name: "headingStyle", value: "underline", isSynced: true }, | ||||
|     { name: "autoCollapseNoteTree", value: "true", isSynced: true }, | ||||
|     { name: "autoReadonlySizeText", value: "10000", isSynced: false }, | ||||
|     { name: "autoReadonlySizeCode", value: "30000", isSynced: false }, | ||||
|     { name: "dailyBackupEnabled", value: "true", isSynced: false }, | ||||
|     { name: "weeklyBackupEnabled", value: "true", isSynced: false }, | ||||
|     { name: "monthlyBackupEnabled", value: "true", isSynced: false }, | ||||
|     { name: "maxContentWidth", value: "1200", isSynced: false }, | ||||
|     { name: "compressImages", value: "true", isSynced: true }, | ||||
|     { name: "downloadImagesAutomatically", value: "true", isSynced: true }, | ||||
|     { name: "minTocHeadings", value: "5", isSynced: true }, | ||||
|     { name: "highlightsList", value: '["bold","italic","underline","color","bgColor"]', isSynced: true }, | ||||
|     { name: "checkForUpdates", value: "true", isSynced: true }, | ||||
|     { name: "disableTray", value: "false", isSynced: false }, | ||||
|     { name: "eraseUnusedAttachmentsAfterSeconds", value: "2592000", isSynced: true }, | ||||
|     { name: "customSearchEngineName", value: "DuckDuckGo", isSynced: true }, | ||||
|     { name: "customSearchEngineUrl", value: "https://duckduckgo.com/?q={keyword}", isSynced: true }, | ||||
|     { name: "promotedAttributesOpenInRibbon", value: "true", isSynced: true }, | ||||
|     { name: "editedNotesOpenInRibbon", value: "true", isSynced: true }, | ||||
|  | ||||
|     // Internationalization | ||||
|     { name: 'locale', value: 'en', isSynced: true }, | ||||
|     { name: 'firstDayOfWeek', value: '1', isSynced: true }, | ||||
|     { name: "locale", value: "en", isSynced: true }, | ||||
|     { name: "firstDayOfWeek", value: "1", isSynced: true }, | ||||
|  | ||||
|     // Code block configuration | ||||
|     { name: "codeBlockTheme", value: (optionsMap) => { | ||||
|         if (optionsMap.theme === "light") { | ||||
|             return "default:stackoverflow-light"; | ||||
|         } else { | ||||
|             return "default:stackoverflow-dark"; | ||||
|         } | ||||
|     }, isSynced: false }, | ||||
|     { | ||||
|         name: "codeBlockTheme", | ||||
|         value: (optionsMap) => { | ||||
|             if (optionsMap.theme === "light") { | ||||
|                 return "default:stackoverflow-light"; | ||||
|             } else { | ||||
|                 return "default:stackoverflow-dark"; | ||||
|             } | ||||
|         }, | ||||
|         isSynced: false | ||||
|     }, | ||||
|     { name: "codeBlockWordWrap", value: "false", isSynced: true }, | ||||
|  | ||||
|     // Text note configuration | ||||
| @@ -139,18 +151,106 @@ const defaultOptions: DefaultOption[] = [ | ||||
|     // HTML import configuration | ||||
|     { name: "layoutOrientation", value: "vertical", isSynced: false }, | ||||
|     { name: "backgroundEffects", value: "false", isSynced: false }, | ||||
|     { name: "allowedHtmlTags", value: JSON.stringify([ | ||||
|         'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol', | ||||
|         'li', 'b', 'i', 'strong', 'em', 'strike', 's', 'del', 'abbr', 'code', 'hr', 'br', 'div', | ||||
|         'table', 'thead', 'caption', 'tbody', 'tfoot', 'tr', 'th', 'td', 'pre', 'section', 'img', | ||||
|         'figure', 'figcaption', 'span', 'label', 'input', 'details', 'summary', 'address', 'aside', 'footer', | ||||
|         'header', 'hgroup', 'main', 'nav', 'dl', 'dt', 'menu', 'bdi', 'bdo', 'dfn', 'kbd', 'mark', 'q', 'time', | ||||
|         'var', 'wbr', 'area', 'map', 'track', 'video', 'audio', 'picture', 'del', 'ins', | ||||
|         'en-media', | ||||
|         'acronym', 'article', 'big', 'button', 'cite', 'col', 'colgroup', 'data', 'dd', | ||||
|         'fieldset', 'form', 'legend', 'meter', 'noscript', 'option', 'progress', 'rp', | ||||
|         'samp', 'small', 'sub', 'sup', 'template', 'textarea', 'tt' | ||||
|     ]), isSynced: true }, | ||||
|     { | ||||
|         name: "allowedHtmlTags", | ||||
|         value: JSON.stringify([ | ||||
|             "h1", | ||||
|             "h2", | ||||
|             "h3", | ||||
|             "h4", | ||||
|             "h5", | ||||
|             "h6", | ||||
|             "blockquote", | ||||
|             "p", | ||||
|             "a", | ||||
|             "ul", | ||||
|             "ol", | ||||
|             "li", | ||||
|             "b", | ||||
|             "i", | ||||
|             "strong", | ||||
|             "em", | ||||
|             "strike", | ||||
|             "s", | ||||
|             "del", | ||||
|             "abbr", | ||||
|             "code", | ||||
|             "hr", | ||||
|             "br", | ||||
|             "div", | ||||
|             "table", | ||||
|             "thead", | ||||
|             "caption", | ||||
|             "tbody", | ||||
|             "tfoot", | ||||
|             "tr", | ||||
|             "th", | ||||
|             "td", | ||||
|             "pre", | ||||
|             "section", | ||||
|             "img", | ||||
|             "figure", | ||||
|             "figcaption", | ||||
|             "span", | ||||
|             "label", | ||||
|             "input", | ||||
|             "details", | ||||
|             "summary", | ||||
|             "address", | ||||
|             "aside", | ||||
|             "footer", | ||||
|             "header", | ||||
|             "hgroup", | ||||
|             "main", | ||||
|             "nav", | ||||
|             "dl", | ||||
|             "dt", | ||||
|             "menu", | ||||
|             "bdi", | ||||
|             "bdo", | ||||
|             "dfn", | ||||
|             "kbd", | ||||
|             "mark", | ||||
|             "q", | ||||
|             "time", | ||||
|             "var", | ||||
|             "wbr", | ||||
|             "area", | ||||
|             "map", | ||||
|             "track", | ||||
|             "video", | ||||
|             "audio", | ||||
|             "picture", | ||||
|             "del", | ||||
|             "ins", | ||||
|             "en-media", | ||||
|             "acronym", | ||||
|             "article", | ||||
|             "big", | ||||
|             "button", | ||||
|             "cite", | ||||
|             "col", | ||||
|             "colgroup", | ||||
|             "data", | ||||
|             "dd", | ||||
|             "fieldset", | ||||
|             "form", | ||||
|             "legend", | ||||
|             "meter", | ||||
|             "noscript", | ||||
|             "option", | ||||
|             "progress", | ||||
|             "rp", | ||||
|             "samp", | ||||
|             "small", | ||||
|             "sub", | ||||
|             "sup", | ||||
|             "template", | ||||
|             "textarea", | ||||
|             "tt" | ||||
|         ]), | ||||
|         isSynced: true | ||||
|     } | ||||
| ]; | ||||
|  | ||||
| /** | ||||
| @@ -163,7 +263,7 @@ function initStartupOptions() { | ||||
|  | ||||
|     const allDefaultOptions = defaultOptions.concat(getKeyboardDefaultOptions()); | ||||
|  | ||||
|     for (const {name, value, isSynced} of allDefaultOptions) { | ||||
|     for (const { name, value, isSynced } of allDefaultOptions) { | ||||
|         if (!(name in optionsMap)) { | ||||
|             let resolvedValue; | ||||
|             if (typeof value === "function") { | ||||
| @@ -178,23 +278,24 @@ function initStartupOptions() { | ||||
|     } | ||||
|  | ||||
|     if (process.env.TRILIUM_START_NOTE_ID || process.env.TRILIUM_SAFE_MODE) { | ||||
|         optionService.setOption('openNoteContexts', JSON.stringify([ | ||||
|             { | ||||
|                 notePath: process.env.TRILIUM_START_NOTE_ID || 'root', | ||||
|                 active: true | ||||
|             } | ||||
|         ])); | ||||
|         optionService.setOption( | ||||
|             "openNoteContexts", | ||||
|             JSON.stringify([ | ||||
|                 { | ||||
|                     notePath: process.env.TRILIUM_START_NOTE_ID || "root", | ||||
|                     active: true | ||||
|                 } | ||||
|             ]) | ||||
|         ); | ||||
|     } | ||||
| } | ||||
|  | ||||
| function getKeyboardDefaultOptions() { | ||||
|     return (keyboardActions.getDefaultKeyboardActions() | ||||
|         .filter(ka => !!ka.actionName) as KeyboardShortcutWithRequiredActionName[]) | ||||
|         .map(ka => ({ | ||||
|             name: `keyboardShortcuts${ka.actionName.charAt(0).toUpperCase()}${ka.actionName.slice(1)}`, | ||||
|             value: JSON.stringify(ka.defaultShortcuts), | ||||
|             isSynced: false | ||||
|         })) as DefaultOption[]; | ||||
|     return (keyboardActions.getDefaultKeyboardActions().filter((ka) => !!ka.actionName) as KeyboardShortcutWithRequiredActionName[]).map((ka) => ({ | ||||
|         name: `keyboardShortcuts${ka.actionName.charAt(0).toUpperCase()}${ka.actionName.slice(1)}`, | ||||
|         value: JSON.stringify(ka.defaultShortcuts), | ||||
|         isSynced: false | ||||
|     })) as DefaultOption[]; | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user