2022-06-16 22:53:11 +02:00
|
|
|
import utils from "../../../services/utils.js";
|
|
|
|
import server from "../../../services/server.js";
|
|
|
|
import toastService from "../../../services/toast.js";
|
2019-10-06 21:35:26 +02:00
|
|
|
|
2019-11-03 19:06:22 +01:00
|
|
|
const TPL = `
|
2021-11-21 15:27:13 +00:00
|
|
|
<style>
|
|
|
|
.disabled-field {
|
|
|
|
opacity: 0.5;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2019-11-03 19:06:22 +01:00
|
|
|
<div>
|
|
|
|
<h4>Spell check</h4>
|
|
|
|
|
2020-01-10 19:56:27 +01:00
|
|
|
<p>These options apply only for desktop builds, browsers will use their own native spell check. App restart is required after change.</p>
|
2019-11-03 19:06:22 +01:00
|
|
|
|
|
|
|
<div class="custom-control custom-checkbox">
|
|
|
|
<input type="checkbox" class="custom-control-input" id="spell-check-enabled">
|
|
|
|
<label class="custom-control-label" for="spell-check-enabled">Enable spellcheck</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2020-02-28 22:07:08 +01:00
|
|
|
<label for="spell-check-language-code">Language code(s)</label>
|
2019-11-24 10:44:09 +01:00
|
|
|
<input type="text" class="form-control" id="spell-check-language-code" placeholder="for example "en-US", "de-AT"">
|
2019-11-03 19:06:22 +01:00
|
|
|
</div>
|
|
|
|
|
2020-04-20 22:26:31 +02:00
|
|
|
<p>Multiple languages can be separated by comma, e.g. <code>en-US, de-DE, cs</code>. Changes to the spell check options will take effect after application restart.</p>
|
|
|
|
|
|
|
|
<p><strong>Available language codes: </strong> <span id="available-language-codes"></span></p>
|
2019-11-03 19:06:22 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
2022-05-21 14:00:53 +02:00
|
|
|
<h4>Images</h4>
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<input id="download-images-automatically" type="checkbox" name="download-images-automatically">
|
|
|
|
<label for="download-images-automatically">Download images automatically for offline use.</label>
|
|
|
|
<p>(pasted HTML can contain references to online images, Trilium will find those references and download the images so that they are available offline)</p>
|
|
|
|
</div>
|
2021-11-21 15:27:13 +00:00
|
|
|
|
2019-11-03 19:06:22 +01:00
|
|
|
<div class="form-group">
|
2021-11-21 15:27:13 +00:00
|
|
|
<input id="image-compresion-enabled" type="checkbox" name="image-compression-enabled">
|
|
|
|
<label for="image-compresion-enabled">Enable image compression</label>
|
2019-11-03 19:06:22 +01:00
|
|
|
</div>
|
|
|
|
|
2021-11-21 15:27:13 +00:00
|
|
|
<div id="image-compression-enabled-wraper">
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="image-max-width-height">Max width / height of an image in pixels (image will be resized if it exceeds this setting).</label>
|
2021-12-14 21:54:38 +01:00
|
|
|
<input class="form-control" id="image-max-width-height" type="number" min="1">
|
2021-11-21 15:27:13 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2021-12-19 10:54:30 +01:00
|
|
|
<label for="image-jpeg-quality">JPEG quality (10 - worst quality, 100 best quality, 50 - 85 is recommended)</label>
|
|
|
|
<input class="form-control" id="image-jpeg-quality" min="10" max="100" type="number">
|
2021-11-21 15:27:13 +00:00
|
|
|
</div>
|
2019-11-03 19:06:22 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-01-03 22:32:49 +01:00
|
|
|
<div>
|
|
|
|
<h4>Note erasure timeout</h4>
|
|
|
|
|
2020-12-14 13:47:33 +01:00
|
|
|
<p>Deleted notes (and attributes, revisions...) are at first only marked as deleted and it is possible to recover them
|
2020-07-24 16:03:39 -04:00
|
|
|
from Recent Notes dialog. After a period of time, deleted notes are "erased" which means
|
2020-01-03 22:32:49 +01:00
|
|
|
their content is not recoverable anymore. This setting allows you to configure the length
|
|
|
|
of the period between deleting and erasing the note.</p>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2020-12-14 13:47:33 +01:00
|
|
|
<label for="erase-entities-after-time-in-seconds">Erase notes after X seconds</label>
|
|
|
|
<input class="form-control" id="erase-entities-after-time-in-seconds" type="number" min="0">
|
2020-01-03 22:32:49 +01:00
|
|
|
</div>
|
2020-12-06 22:11:49 +01:00
|
|
|
|
|
|
|
<p>You can also trigger erasing manually:</p>
|
|
|
|
|
|
|
|
<button id="erase-deleted-notes-now-button" class="btn">Erase deleted notes now</button>
|
|
|
|
|
|
|
|
<br/><br/>
|
2020-01-03 22:32:49 +01:00
|
|
|
</div>
|
|
|
|
|
2019-11-03 19:06:22 +01:00
|
|
|
<div>
|
|
|
|
<h4>Protected session timeout</h4>
|
|
|
|
|
2020-07-24 16:03:39 -04:00
|
|
|
<p>Protected session timeout is a time period after which the protected session is wiped from
|
|
|
|
the browser's memory. This is measured from the last interaction with protected notes. See <a href="https://github.com/zadam/trilium/wiki/Protected-notes" class="external">wiki</a> for more info.</p>
|
2019-11-03 19:06:22 +01:00
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="protected-session-timeout-in-seconds">Protected session timeout (in seconds)</label>
|
2021-12-08 21:04:22 +01:00
|
|
|
<input class="form-control" id="protected-session-timeout-in-seconds" type="number" min="60">
|
2019-11-03 19:06:22 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<h4>Note revisions snapshot interval</h4>
|
|
|
|
|
2020-07-24 16:03:39 -04:00
|
|
|
<p>Note revision snapshot time interval is time in seconds after which a new note revision will be created for the note. See <a href="https://github.com/zadam/trilium/wiki/Note-revisions" class="external">wiki</a> for more info.</p>
|
2019-11-03 19:06:22 +01:00
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="note-revision-snapshot-time-interval-in-seconds">Note revision snapshot time interval (in seconds)</label>
|
2021-12-08 21:04:22 +01:00
|
|
|
<input class="form-control" id="note-revision-snapshot-time-interval-in-seconds" type="number" min="10">
|
2019-11-03 19:06:22 +01:00
|
|
|
</div>
|
2021-09-20 21:08:41 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<h4>Automatic readonly size</h4>
|
|
|
|
|
2021-09-20 21:12:35 +02:00
|
|
|
<p>Automatic readonly note size is the size after which notes will be displayed in a readonly mode (for performance reasons).</p>
|
2021-09-20 21:08:41 +02:00
|
|
|
|
|
|
|
<div class="form-group">
|
2021-09-20 21:12:35 +02:00
|
|
|
<label for="auto-readonly-size-text">Automatic readonly size (text notes)</label>
|
2021-12-08 21:04:22 +01:00
|
|
|
<input class="form-control" id="auto-readonly-size-text" type="number" min="0">
|
2021-09-20 21:08:41 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2021-09-20 21:12:35 +02:00
|
|
|
<label for="auto-readonly-size-code">Automatic readonly size (code notes)</label>
|
2021-12-08 21:04:22 +01:00
|
|
|
<input class="form-control" id="auto-readonly-size-code" type="number" min="0">
|
2021-09-20 21:08:41 +02:00
|
|
|
</div>
|
2022-07-19 16:01:27 -04:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<h4>Network connections</h4>
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<input id="check-for-updates" type="checkbox" name="check-for-updates">
|
|
|
|
<label for="check-for-updates">Check for updates automatically</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
`;
|
2019-11-03 19:06:22 +01:00
|
|
|
|
2019-10-06 21:35:26 +02:00
|
|
|
export default class ProtectedSessionOptions {
|
|
|
|
constructor() {
|
2019-11-03 19:06:22 +01:00
|
|
|
$("#options-other").html(TPL);
|
|
|
|
|
2019-10-06 21:35:26 +02:00
|
|
|
this.$spellCheckEnabled = $("#spell-check-enabled");
|
|
|
|
this.$spellCheckLanguageCode = $("#spell-check-language-code");
|
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
this.$spellCheckEnabled.on('change', () => {
|
2019-10-06 21:35:26 +02:00
|
|
|
const opts = { 'spellCheckEnabled': this.$spellCheckEnabled.is(":checked") ? "true" : "false" };
|
2021-12-12 15:08:54 -05:00
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
|
2019-10-06 21:35:26 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
this.$spellCheckLanguageCode.on('change', () => {
|
2019-10-06 21:35:26 +02:00
|
|
|
const opts = { 'spellCheckLanguageCode': this.$spellCheckLanguageCode.val() };
|
2021-12-12 15:08:54 -05:00
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
|
2019-10-06 21:35:26 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2020-04-20 22:26:31 +02:00
|
|
|
this.$availableLanguageCodes = $("#available-language-codes");
|
|
|
|
|
|
|
|
if (utils.isElectron()) {
|
2022-07-19 16:01:27 -04:00
|
|
|
const { webContents } = utils.dynamicRequire('@electron/remote').getCurrentWindow();
|
2020-04-20 22:26:31 +02:00
|
|
|
|
|
|
|
this.$availableLanguageCodes.text(webContents.session.availableSpellCheckerLanguages.join(', '));
|
|
|
|
}
|
|
|
|
|
2020-12-14 13:47:33 +01:00
|
|
|
this.$eraseEntitiesAfterTimeInSeconds = $("#erase-entities-after-time-in-seconds");
|
2020-01-03 22:32:49 +01:00
|
|
|
|
2020-12-14 13:47:33 +01:00
|
|
|
this.$eraseEntitiesAfterTimeInSeconds.on('change', () => {
|
|
|
|
const eraseEntitiesAfterTimeInSeconds = this.$eraseEntitiesAfterTimeInSeconds.val();
|
2020-01-03 22:32:49 +01:00
|
|
|
|
2020-12-14 13:47:33 +01:00
|
|
|
server.put('options', { 'eraseEntitiesAfterTimeInSeconds': eraseEntitiesAfterTimeInSeconds }).then(() => {
|
2021-12-12 15:08:54 -05:00
|
|
|
toastService.showMessage("Options changed have been saved.");
|
2020-01-03 22:32:49 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2020-12-06 22:11:49 +01:00
|
|
|
this.$eraseDeletedNotesButton = $("#erase-deleted-notes-now-button");
|
|
|
|
this.$eraseDeletedNotesButton.on('click', () => {
|
|
|
|
server.post('notes/erase-deleted-notes-now').then(() => {
|
|
|
|
toastService.showMessage("Deleted notes have been erased.");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-11-03 17:59:11 +01:00
|
|
|
this.$protectedSessionTimeout = $("#protected-session-timeout-in-seconds");
|
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
this.$protectedSessionTimeout.on('change', () => {
|
2019-10-06 21:35:26 +02:00
|
|
|
const protectedSessionTimeout = this.$protectedSessionTimeout.val();
|
|
|
|
|
|
|
|
server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
|
2021-12-12 15:08:54 -05:00
|
|
|
toastService.showMessage("Options changed have been saved.");
|
2019-10-06 21:35:26 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2019-11-03 17:59:11 +01:00
|
|
|
this.$noteRevisionsTimeInterval = $("#note-revision-snapshot-time-interval-in-seconds");
|
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
this.$noteRevisionsTimeInterval.on('change', () => {
|
2019-10-06 21:35:26 +02:00
|
|
|
const opts = { 'noteRevisionSnapshotTimeInterval': this.$noteRevisionsTimeInterval.val() };
|
2021-12-12 15:08:54 -05:00
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
|
2019-10-06 21:35:26 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
2019-11-03 17:59:11 +01:00
|
|
|
|
|
|
|
this.$imageMaxWidthHeight = $("#image-max-width-height");
|
|
|
|
this.$imageJpegQuality = $("#image-jpeg-quality");
|
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
this.$imageMaxWidthHeight.on('change', () => {
|
2019-11-03 17:59:11 +01:00
|
|
|
const opts = { 'imageMaxWidthHeight': this.$imageMaxWidthHeight.val() };
|
2021-12-12 15:08:54 -05:00
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
|
2019-11-03 17:59:11 +01:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
this.$imageJpegQuality.on('change', () => {
|
2019-11-03 17:59:11 +01:00
|
|
|
const opts = { 'imageJpegQuality': this.$imageJpegQuality.val() };
|
2021-12-12 15:08:54 -05:00
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
|
2019-11-03 17:59:11 +01:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
2021-09-20 21:08:41 +02:00
|
|
|
|
2021-09-20 21:12:35 +02:00
|
|
|
this.$autoReadonlySizeText = $("#auto-readonly-size-text");
|
2021-09-20 21:08:41 +02:00
|
|
|
|
2021-09-20 21:12:35 +02:00
|
|
|
this.$autoReadonlySizeText.on('change', () => {
|
|
|
|
const opts = { 'autoReadonlySizeText': this.$autoReadonlySizeText.val() };
|
2021-12-12 15:08:54 -05:00
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
|
2021-09-20 21:08:41 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2021-09-20 21:12:35 +02:00
|
|
|
this.$autoReadonlySizeCode = $("#auto-readonly-size-code");
|
2021-09-20 21:08:41 +02:00
|
|
|
|
2021-09-20 21:12:35 +02:00
|
|
|
this.$autoReadonlySizeCode.on('change', () => {
|
|
|
|
const opts = { 'autoReadonlySizeCode': this.$autoReadonlySizeText.val() };
|
2021-12-12 15:08:54 -05:00
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
|
2021-09-20 21:08:41 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
2021-11-21 15:27:13 +00:00
|
|
|
|
2022-05-21 14:00:53 +02:00
|
|
|
this.$downloadImagesAutomatically = $("#download-images-automatically");
|
|
|
|
|
|
|
|
this.$downloadImagesAutomatically.on("change", () => {
|
|
|
|
const isChecked = this.$downloadImagesAutomatically.prop("checked");
|
|
|
|
const opts = { 'downloadImagesAutomatically': isChecked ? 'true' : 'false' };
|
|
|
|
|
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
|
|
|
|
});
|
|
|
|
|
2021-11-21 15:27:13 +00:00
|
|
|
this.$enableImageCompression = $("#image-compresion-enabled");
|
|
|
|
this.$imageCompressionWrapper = $("#image-compression-enabled-wraper");
|
|
|
|
|
|
|
|
this.setImageCompression = (isChecked) => {
|
|
|
|
if (isChecked) {
|
|
|
|
this.$imageCompressionWrapper.removeClass("disabled-field");
|
|
|
|
} else {
|
|
|
|
this.$imageCompressionWrapper.addClass("disabled-field");
|
|
|
|
}
|
2022-05-21 14:00:53 +02:00
|
|
|
};
|
2021-11-21 15:27:13 +00:00
|
|
|
|
|
|
|
this.$enableImageCompression.on("change", () => {
|
|
|
|
const isChecked = this.$enableImageCompression.prop("checked");
|
|
|
|
const opts = { 'compressImages': isChecked ? 'true' : 'false' };
|
|
|
|
|
2021-12-12 15:08:54 -05:00
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
|
2021-11-21 15:27:13 +00:00
|
|
|
|
|
|
|
this.setImageCompression(isChecked);
|
2022-05-21 14:00:53 +02:00
|
|
|
});
|
2022-07-19 16:01:27 -04:00
|
|
|
|
|
|
|
this.$checkForUpdates = $("#check-for-updates");
|
|
|
|
this.$checkForUpdates.on("change", () => {
|
|
|
|
const isChecked = this.$checkForUpdates.prop("checked");
|
|
|
|
const opts = { 'checkForUpdates': isChecked ? 'true' : 'false' };
|
|
|
|
|
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
|
|
|
|
});
|
2019-10-06 21:35:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
optionsLoaded(options) {
|
|
|
|
this.$spellCheckEnabled.prop("checked", options['spellCheckEnabled'] === 'true');
|
|
|
|
this.$spellCheckLanguageCode.val(options['spellCheckLanguageCode']);
|
|
|
|
|
2020-12-14 13:47:33 +01:00
|
|
|
this.$eraseEntitiesAfterTimeInSeconds.val(options['eraseEntitiesAfterTimeInSeconds']);
|
2019-10-06 21:35:26 +02:00
|
|
|
this.$protectedSessionTimeout.val(options['protectedSessionTimeout']);
|
|
|
|
this.$noteRevisionsTimeInterval.val(options['noteRevisionSnapshotTimeInterval']);
|
2019-11-03 17:59:11 +01:00
|
|
|
|
|
|
|
this.$imageMaxWidthHeight.val(options['imageMaxWidthHeight']);
|
|
|
|
this.$imageJpegQuality.val(options['imageJpegQuality']);
|
2021-09-20 21:08:41 +02:00
|
|
|
|
2021-09-20 21:12:35 +02:00
|
|
|
this.$autoReadonlySizeText.val(options['autoReadonlySizeText']);
|
|
|
|
this.$autoReadonlySizeCode.val(options['autoReadonlySizeCode']);
|
2021-11-21 15:27:13 +00:00
|
|
|
|
2022-05-21 14:00:53 +02:00
|
|
|
const downloadImagesAutomatically = options['downloadImagesAutomatically'] === 'true';
|
|
|
|
this.$downloadImagesAutomatically.prop('checked', downloadImagesAutomatically);
|
|
|
|
|
2021-11-21 15:27:13 +00:00
|
|
|
const compressImages = options['compressImages'] === 'true';
|
|
|
|
this.$enableImageCompression.prop('checked', compressImages);
|
|
|
|
this.setImageCompression(compressImages);
|
2022-07-19 16:01:27 -04:00
|
|
|
|
|
|
|
|
|
|
|
const checkForUpdates = options['checkForUpdates'] === 'true';
|
|
|
|
this.$checkForUpdates.prop('checked', checkForUpdates);
|
|
|
|
|
2019-10-06 21:35:26 +02:00
|
|
|
}
|
2019-11-24 10:44:09 +01:00
|
|
|
}
|