@@ -216,6 +222,15 @@ export default class ProtectedSessionOptions {
return false;
});
+ 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."));
+ });
+
this.$enableImageCompression = $("#image-compresion-enabled");
this.$imageCompressionWrapper = $("#image-compression-enabled-wraper");
@@ -225,7 +240,7 @@ export default class ProtectedSessionOptions {
} else {
this.$imageCompressionWrapper.addClass("disabled-field");
}
- }
+ };
this.$enableImageCompression.on("change", () => {
const isChecked = this.$enableImageCompression.prop("checked");
@@ -234,7 +249,7 @@ export default class ProtectedSessionOptions {
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
this.setImageCompression(isChecked);
- })
+ });
}
optionsLoaded(options) {
@@ -251,6 +266,9 @@ export default class ProtectedSessionOptions {
this.$autoReadonlySizeText.val(options['autoReadonlySizeText']);
this.$autoReadonlySizeCode.val(options['autoReadonlySizeCode']);
+ const downloadImagesAutomatically = options['downloadImagesAutomatically'] === 'true';
+ this.$downloadImagesAutomatically.prop('checked', downloadImagesAutomatically);
+
const compressImages = options['compressImages'] === 'true';
this.$enableImageCompression.prop('checked', compressImages);
this.setImageCompression(compressImages);
diff --git a/src/routes/api/options.js b/src/routes/api/options.js
index 3df70f68d3..5c38ff4c81 100644
--- a/src/routes/api/options.js
+++ b/src/routes/api/options.js
@@ -55,7 +55,8 @@ const ALLOWED_OPTIONS = new Set([
'weeklyBackupEnabled',
'monthlyBackupEnabled',
'maxContentWidth',
- 'compressImages'
+ 'compressImages',
+ 'downloadImagesAutomatically'
]);
function getOptions() {
diff --git a/src/services/notes.js b/src/services/notes.js
index 067bf45960..5e36707277 100644
--- a/src/services/notes.js
+++ b/src/services/notes.js
@@ -323,6 +323,10 @@ function replaceUrl(content, url, imageNote) {
}
function downloadImages(noteId, content) {
+ if (!optionService.getOptionBool("downloadImagesAutomatically")) {
+ return content;
+ }
+
const imageRe = /
]*?\ssrc=['"]([^'">]+)['"]/ig;
let imageMatch;
diff --git a/src/services/options_init.js b/src/services/options_init.js
index 5744148c3d..20e9dabb93 100644
--- a/src/services/options_init.js
+++ b/src/services/options_init.js
@@ -29,13 +29,13 @@ function initNotSyncedOptions(initialized, opts = {}) {
optionService.createOption('lastSyncedPush', '0', false);
let theme = 'dark'; // default based on the poll in https://github.com/zadam/trilium/issues/2516
-
+
if (utils.isElectron()) {
const {nativeTheme} = require('electron');
-
+
theme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
}
-
+
optionService.createOption('theme', theme, false);
optionService.createOption('syncServerHost', opts.syncServerHost || '', false);
@@ -83,7 +83,8 @@ const defaultOptions = [
{ 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: 'compressImages', value: 'true', isSynced: true },
+ { name: 'downloadImagesAutomatically', value: 'true', isSynced: true }
];
function initStartupOptions() {