2024-11-02 01:42:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import optionService from "./options.js";
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-04 11:52:40 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import type { OptionMap, OptionNames } from "./options_interface.js";
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-18 21:35:17 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import appInfo from "./app_info.js";
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-02 18:47:41 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import { randomSecureToken, isWindows } from "./utils.js";
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-18 21:35:17 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import log from "./log.js";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import dateUtils from "./date_utils.js";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import keyboardActions from "./keyboard_actions.js";
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-24 20:33:35 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import { KeyboardShortcutWithRequiredActionName } from './keyboard_actions_interface.js';
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-21 08:55:24 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-20 12:31:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								function initDocumentOptions() {
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-02 13:47:44 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('documentId', randomSecureToken(16), false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('documentSecret', randomSecureToken(16), false);
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-23 21:15:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-21 08:55:24 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:20:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Contains additional options to be initialized for a new database, containing the information entered by the user.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-18 13:32:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								interface NotSyncedOpts {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    syncServerHost?: string;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    syncProxy?: string;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:39:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Represents a correspondence between an option and its default value, to be initialized when the database is missing that particular option (after a migration from an older version, or when creating a new database).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-11 07:36:00 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								interface DefaultOption {
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-03 17:54:05 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    name: OptionNames;
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:39:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    /**
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-22 15:42:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    * The value to initialize the option with, if the option is not already present in the database.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    *
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-03 17:54:05 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    * 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.
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-22 15:42:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    */
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:39:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    value: string | ((options: OptionMap) => string);
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-11 07:36:00 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isSynced: boolean;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:20:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Initializes the default options for new databases only.
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-22 15:42:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:20:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param initialized `true` if the database has been fully initialized (i.e. a new database was created), or `false` if the database is created for sync.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param opts additional options to be initialized, for example the sync configuration.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-22 20:15:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								async function initNotSyncedOptions(initialized: boolean, opts: NotSyncedOpts = {}) {
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-11 22:00:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('openNoteContexts', JSON.stringify([
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-10 21:43:40 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        {
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-30 22:03:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            notePath: 'root',
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-11 22:29:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            active: true
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-10 21:43:40 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]), false);
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 10:43:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-20 12:31:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('lastDailyBackupDate', dateUtils.utcNowDateTime(), false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('lastWeeklyBackupDate', dateUtils.utcNowDateTime(), false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('lastMonthlyBackupDate', dateUtils.utcNowDateTime(), false);
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-18 13:32:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('dbVersion', appInfo.dbVersion.toString(), false);
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-23 21:15:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-20 12:31:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('initialized', initialized ? 'true' : 'false', false);
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 10:43:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-20 12:31:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('lastSyncedPull', '0', false);
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-22 15:42:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('lastSyncedPush', '0', false);
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-21 14:00:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-22 20:15:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('theme', 'next', false);
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-22 15:42:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-20 12:31:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('syncServerHost', opts.syncServerHost || '', false);
							 | 
						
					
						
							
								
									
										
										
										
											2021-02-10 22:56:23 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('syncServerTimeout', '120000', false);
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-20 12:31:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    optionService.createOption('syncProxy', opts.syncProxy || '', false);
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 10:43:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-24 08:12:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:55:45 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * 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.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-11 07:36:00 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const defaultOptions: DefaultOption[] = [
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-04 23:01:40 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'revisionSnapshotTimeInterval', value: '600', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2024-09-04 08:41:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'revisionSnapshotNumberLimit', value: '-1', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-16 17:03:18 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'protectedSessionTimeout', value: '600', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-02 18:47:41 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'zoomFactor', value: isWindows() ? '0.9' : '1.0', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-28 10:02:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'overrideThemeFonts', value: 'false', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-04 21:23:16 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'mainFontFamily', value: 'theme', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 10:43:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'mainFontSize', value: '100', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-04 21:23:16 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'treeFontFamily', value: 'theme', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 10:43:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'treeFontSize', value: '100', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-04 21:23:16 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'detailFontFamily', value: 'theme', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 10:43:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'detailFontSize', value: '110', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-04 21:23:16 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'monospaceFontFamily', value: 'theme', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-27 21:01:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'monospaceFontSize', value: '110', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 10:43:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'spellCheckEnabled', value: 'true', isSynced: false },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    { name: 'spellCheckLanguageCode', value: 'en-US', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-28 10:58:34 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'imageMaxWidthHeight', value: '2000', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-10 11:25:41 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'imageJpegQuality', value: '75', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-08 09:12:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'autoFixConsistencyIssues', value: 'true', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-26 12:24:18 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'vimKeymapEnabled', value: 'false', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-08 22:55:11 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'codeLineWrapEnabled', value: 'true', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2023-10-24 23:00:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { 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 },
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-23 20:34:29 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'leftPaneWidth', value: '25', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-04 20:42:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'leftPaneVisible', value: 'true', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-23 20:34:29 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'rightPaneWidth', value: '25', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-24 12:10:32 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'rightPaneVisible', value: 'true', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2020-01-03 22:32:49 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'nativeTitleBarVisible', value: 'false', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2020-12-14 13:47:33 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'eraseEntitiesAfterTimeInSeconds', value: '604800', isSynced: true }, // default is 7 days
							 | 
						
					
						
							
								
									
										
										
										
											2020-05-03 21:27:24 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'hideArchivedNotes_main', value: 'false', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-09 22:06:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'debugModeEnabled', value: 'false', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-23 16:04:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'headingStyle', value: 'underline', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-18 20:11:58 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'autoCollapseNoteTree', value: 'true', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-20 21:12:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'autoReadonlySizeText', value: '10000', isSynced: false },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    { name: 'autoReadonlySizeCode', value: '30000', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-11 22:30:23 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'dailyBackupEnabled', value: 'true', isSynced: false },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    { name: 'weeklyBackupEnabled', value: 'true', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-31 21:55:11 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'monthlyBackupEnabled', value: 'true', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-21 15:27:13 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'maxContentWidth', value: '1200', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-21 14:00:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'compressImages', value: 'true', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2022-07-16 00:15:45 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'downloadImagesAutomatically', value: 'true', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2022-07-19 16:23:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'minTocHeadings', value: '5', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-22 15:38:36 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'highlightsList', value: '["bold","italic","underline","color","bgColor"]', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2022-07-19 16:23:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'checkForUpdates', value: 'true', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-18 21:08:32 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'disableTray', value: 'false', isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2023-05-29 13:02:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'eraseUnusedAttachmentsAfterSeconds', value: '2592000', isSynced: true },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    { name: 'customSearchEngineName', value: 'DuckDuckGo', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-09 22:50:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'customSearchEngineUrl', value: 'https://duckduckgo.com/?q={keyword}', isSynced: true },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    { name: 'promotedAttributesOpenInRibbon', value: 'true', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-11 07:36:00 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'editedNotesOpenInRibbon', value: 'true', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-31 16:24:09 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Internationalization
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    { name: 'locale', value: 'en', isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2024-10-27 21:51:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: 'firstDayOfWeek', value: '1', isSynced: true },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:55:45 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // Code block configuration
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:39:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: "codeBlockTheme", value: (optionsMap) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (optionsMap.theme === "light") {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            return "default:stackoverflow-light";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            return "default:stackoverflow-dark";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }, isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-09 14:33:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: "codeBlockWordWrap", value: "false", isSynced: true },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Text note configuration
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-23 09:06:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: "textNoteEditorType", value: "ckeditor-balloon", isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-14 01:24:29 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: "textNoteEditorMultilineToolbar", value: "false", isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-23 09:06:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-17 20:16:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // HTML import configuration
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-28 21:56:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: "layoutOrientation", value: "vertical", isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-09 21:57:54 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { name: "backgroundEffects", value: "false", isSynced: false },
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-17 16:08:44 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    { 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'
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-17 20:16:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ]), isSynced: true },
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 10:43:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:55:45 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Initializes the options, by checking which options from {@link #allDefaultOptions()} are missing and registering them. It will also check some environment variables such as safe mode, to make any necessary adjustments.
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-22 15:42:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:55:45 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * This method is called regardless of whether a new database is created, or an existing database is used.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-20 12:31:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								function initStartupOptions() {
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-29 22:10:13 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const optionsMap = optionService.getOptionMap();
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 10:43:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-18 23:01:31 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const allDefaultOptions = defaultOptions.concat(getKeyboardDefaultOptions());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for (const {name, value, isSynced} of allDefaultOptions) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 10:43:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if (!(name in optionsMap)) {
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:39:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            let resolvedValue;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if (typeof value === "function") {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                resolvedValue = value(optionsMap);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                resolvedValue = value;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            }
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 11:43:04 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-02 00:39:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            optionService.createOption(name, resolvedValue, isSynced);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            log.info(`Created option "${name}" with default value "${resolvedValue}"`);
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 10:43:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-11 22:29:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-15 20:12:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if (process.env.TRILIUM_START_NOTE_ID || process.env.TRILIUM_SAFE_MODE) {
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-11 22:00:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        optionService.setOption('openNoteContexts', JSON.stringify([
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-11 22:29:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            {
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-15 20:12:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                notePath: process.env.TRILIUM_START_NOTE_ID || 'root',
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-11 22:29:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                active: true
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ]));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-21 08:55:24 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-18 23:01:31 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								function getKeyboardDefaultOptions() {
							 | 
						
					
						
							
								
									
										
										
										
											2024-10-12 10:29:50 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return (keyboardActions.getDefaultKeyboardActions()
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-18 13:32:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        .filter(ka => !!ka.actionName) as KeyboardShortcutWithRequiredActionName[])
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-28 22:07:08 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        .map(ka => ({
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-21 15:19:05 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            name: `keyboardShortcuts${ka.actionName.charAt(0).toUpperCase()}${ka.actionName.slice(1)}`,
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-28 22:07:08 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            value: JSON.stringify(ka.defaultShortcuts),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            isSynced: false
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-03 17:54:05 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        })) as DefaultOption[];
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-18 23:01:31 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-18 21:47:30 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export default {
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-23 21:15:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    initDocumentOptions,
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-03 10:43:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    initNotSyncedOptions,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    initStartupOptions
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-20 12:31:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								};
							 |