mirror of
https://github.com/zadam/trilium.git
synced 2025-06-05 17:38:47 +02:00
added "explodeArchives" option to the import dialog
This commit is contained in:
parent
7e2a2baa5d
commit
8b3e721028
@ -16,6 +16,7 @@ const $safeImportCheckbox = $("#safe-import-checkbox");
|
||||
const $shrinkImagesCheckbox = $("#shrink-images-checkbox");
|
||||
const $textImportedAsTextCheckbox = $("#text-imported-as-text-checkbox");
|
||||
const $codeImportedAsCodeCheckbox = $("#code-imported-as-code-checkbox");
|
||||
const $explodeArchivesCheckbox = $("#explode-archives-checkbox");
|
||||
|
||||
let importId;
|
||||
|
||||
@ -30,6 +31,7 @@ async function showDialog() {
|
||||
$shrinkImagesCheckbox.prop("checked", true);
|
||||
$textImportedAsTextCheckbox.prop("checked", true);
|
||||
$codeImportedAsCodeCheckbox.prop("checked", true);
|
||||
$explodeArchivesCheckbox.prop("checked", true);
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
|
||||
@ -61,7 +63,8 @@ async function importIntoNote(importNoteId) {
|
||||
safeImport: boolToString($safeImportCheckbox),
|
||||
shrinkImages: boolToString($shrinkImagesCheckbox),
|
||||
textImportedAsText: boolToString($textImportedAsTextCheckbox),
|
||||
codeImportedAsCode: boolToString($codeImportedAsCodeCheckbox)
|
||||
codeImportedAsCode: boolToString($codeImportedAsCodeCheckbox),
|
||||
explodeArchives: boolToString($explodeArchivesCheckbox)
|
||||
};
|
||||
|
||||
await uploadFiles(importNoteId, files, options);
|
||||
@ -76,10 +79,10 @@ async function uploadFiles(importNoteId, files, options) {
|
||||
const formData = new FormData();
|
||||
formData.append('upload', file);
|
||||
formData.append('importId', importId);
|
||||
formData.append('safeImport', options.safeImport);
|
||||
formData.append('shrinkImages', options.shrinkImages);
|
||||
formData.append('textImportedAsText', options.textImportedAsText);
|
||||
formData.append('codeImportedAsCode', options.codeImportedAsCode);
|
||||
|
||||
for (const key in options) {
|
||||
formData.append(key, options[key]);
|
||||
}
|
||||
|
||||
({noteId} = await $.ajax({
|
||||
url: baseApiUrl + 'notes/' + importNoteId + '/import',
|
||||
|
@ -42,7 +42,8 @@ const dragAndDropSetup = {
|
||||
safeImport: true,
|
||||
shrinkImages: true,
|
||||
textImportedAsText: true,
|
||||
codeImportedAsCode: true
|
||||
codeImportedAsCode: true,
|
||||
explodeArchives: true
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
@ -19,7 +19,8 @@ async function importToBranch(req) {
|
||||
safeImport: req.body.safeImport !== 'false',
|
||||
shrinkImages: req.body.shrinkImages !== 'false',
|
||||
textImportedAsText: req.body.textImportedAsText !== 'false',
|
||||
codeImportedAsCode: req.body.codeImportedAsCode !== 'false'
|
||||
codeImportedAsCode: req.body.codeImportedAsCode !== 'false',
|
||||
explodeArchives: req.body.explodeArchives !== 'false'
|
||||
};
|
||||
|
||||
const file = req.file;
|
||||
@ -45,11 +46,11 @@ async function importToBranch(req) {
|
||||
const importContext = ImportContext.getInstance(importId, options);
|
||||
|
||||
try {
|
||||
if (extension === '.tar') {
|
||||
if (extension === '.tar' && options.explodeArchives) {
|
||||
note = await tarImportService.importTar(importContext, file.buffer, parentNote);
|
||||
} else if (extension === '.opml') {
|
||||
} else if (extension === '.opml' && options.explodeArchives) {
|
||||
note = await opmlImportService.importOpml(importContext, file.buffer, parentNote);
|
||||
} else if (extension === '.enex') {
|
||||
} else if (extension === '.enex' && options.explodeArchives) {
|
||||
note = await enexImportService.importEnex(importContext, file, parentNote);
|
||||
} else {
|
||||
note = await singleImportService.importSingleFile(importContext, file, parentNote);
|
||||
|
@ -31,6 +31,13 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox">
|
||||
<label data-toggle="tooltip" title="If this is checked then Trilium will read <code>.tar</code>, <code>.enex</code> and <code>.opml</code> files and create notes from files insides those archives. If unchecked, then Trilium will attach the archives themselves to the note.">
|
||||
<input id="explode-archives-checkbox" value="1" type="checkbox" checked>
|
||||
Read contents of <code>.tar</code>, <code>.enex</code> and <code>.opml</code> archives.
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox">
|
||||
<label data-toggle="tooltip" title="<p>If you check this option, Trilium will attempt to shrink the imported images by scaling and optimization which may affect the perceived image quality. If unchecked, images will be imported without changes.</p><p>This doesn't apply to <code>.tar</code> imports with metadata since it is assumed these files are already optimized.</p>">
|
||||
<input id="shrink-images-checkbox" value="1" type="checkbox" checked> Shrink images
|
||||
|
Loading…
x
Reference in New Issue
Block a user