mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
add option to disable auto-download of images for offline storage, #2859
This commit is contained in:
parent
2085dc5ed4
commit
819cf0907d
@ -33,7 +33,13 @@ const TPL = `
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h4>Image compression</h4>
|
<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>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input id="image-compresion-enabled" type="checkbox" name="image-compression-enabled">
|
<input id="image-compresion-enabled" type="checkbox" name="image-compression-enabled">
|
||||||
@ -216,6 +222,15 @@ export default class ProtectedSessionOptions {
|
|||||||
return false;
|
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.$enableImageCompression = $("#image-compresion-enabled");
|
||||||
this.$imageCompressionWrapper = $("#image-compression-enabled-wraper");
|
this.$imageCompressionWrapper = $("#image-compression-enabled-wraper");
|
||||||
|
|
||||||
@ -225,7 +240,7 @@ export default class ProtectedSessionOptions {
|
|||||||
} else {
|
} else {
|
||||||
this.$imageCompressionWrapper.addClass("disabled-field");
|
this.$imageCompressionWrapper.addClass("disabled-field");
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
this.$enableImageCompression.on("change", () => {
|
this.$enableImageCompression.on("change", () => {
|
||||||
const isChecked = this.$enableImageCompression.prop("checked");
|
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."));
|
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
|
||||||
|
|
||||||
this.setImageCompression(isChecked);
|
this.setImageCompression(isChecked);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
optionsLoaded(options) {
|
optionsLoaded(options) {
|
||||||
@ -251,6 +266,9 @@ export default class ProtectedSessionOptions {
|
|||||||
this.$autoReadonlySizeText.val(options['autoReadonlySizeText']);
|
this.$autoReadonlySizeText.val(options['autoReadonlySizeText']);
|
||||||
this.$autoReadonlySizeCode.val(options['autoReadonlySizeCode']);
|
this.$autoReadonlySizeCode.val(options['autoReadonlySizeCode']);
|
||||||
|
|
||||||
|
const downloadImagesAutomatically = options['downloadImagesAutomatically'] === 'true';
|
||||||
|
this.$downloadImagesAutomatically.prop('checked', downloadImagesAutomatically);
|
||||||
|
|
||||||
const compressImages = options['compressImages'] === 'true';
|
const compressImages = options['compressImages'] === 'true';
|
||||||
this.$enableImageCompression.prop('checked', compressImages);
|
this.$enableImageCompression.prop('checked', compressImages);
|
||||||
this.setImageCompression(compressImages);
|
this.setImageCompression(compressImages);
|
||||||
|
@ -55,7 +55,8 @@ const ALLOWED_OPTIONS = new Set([
|
|||||||
'weeklyBackupEnabled',
|
'weeklyBackupEnabled',
|
||||||
'monthlyBackupEnabled',
|
'monthlyBackupEnabled',
|
||||||
'maxContentWidth',
|
'maxContentWidth',
|
||||||
'compressImages'
|
'compressImages',
|
||||||
|
'downloadImagesAutomatically'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function getOptions() {
|
function getOptions() {
|
||||||
|
@ -323,6 +323,10 @@ function replaceUrl(content, url, imageNote) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function downloadImages(noteId, content) {
|
function downloadImages(noteId, content) {
|
||||||
|
if (!optionService.getOptionBool("downloadImagesAutomatically")) {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
const imageRe = /<img[^>]*?\ssrc=['"]([^'">]+)['"]/ig;
|
const imageRe = /<img[^>]*?\ssrc=['"]([^'">]+)['"]/ig;
|
||||||
let imageMatch;
|
let imageMatch;
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@ function initNotSyncedOptions(initialized, opts = {}) {
|
|||||||
optionService.createOption('lastSyncedPush', '0', false);
|
optionService.createOption('lastSyncedPush', '0', false);
|
||||||
|
|
||||||
let theme = 'dark'; // default based on the poll in https://github.com/zadam/trilium/issues/2516
|
let theme = 'dark'; // default based on the poll in https://github.com/zadam/trilium/issues/2516
|
||||||
|
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
const {nativeTheme} = require('electron');
|
const {nativeTheme} = require('electron');
|
||||||
|
|
||||||
theme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
theme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
||||||
}
|
}
|
||||||
|
|
||||||
optionService.createOption('theme', theme, false);
|
optionService.createOption('theme', theme, false);
|
||||||
|
|
||||||
optionService.createOption('syncServerHost', opts.syncServerHost || '', false);
|
optionService.createOption('syncServerHost', opts.syncServerHost || '', false);
|
||||||
@ -83,7 +83,8 @@ const defaultOptions = [
|
|||||||
{ name: 'weeklyBackupEnabled', value: 'true', isSynced: false },
|
{ name: 'weeklyBackupEnabled', value: 'true', isSynced: false },
|
||||||
{ name: 'monthlyBackupEnabled', value: 'true', isSynced: false },
|
{ name: 'monthlyBackupEnabled', value: 'true', isSynced: false },
|
||||||
{ name: 'maxContentWidth', value: '1200', 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() {
|
function initStartupOptions() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user