save enex images as attachment, fixes #4163

This commit is contained in:
zadam 2023-08-13 23:32:41 +02:00
parent 737ab4917a
commit 3349385920
3 changed files with 442 additions and 274 deletions

700
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -101,7 +101,7 @@
"electron-builder": "24.6.3", "electron-builder": "24.6.3",
"electron-packager": "17.1.1", "electron-packager": "17.1.1",
"electron-rebuild": "3.2.9", "electron-rebuild": "3.2.9",
"eslint": "8.46.0", "eslint": "8.47.0",
"eslint-config-airbnb-base": "15.0.0", "eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "9.0.0", "eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.28.0", "eslint-plugin-import": "2.28.0",
@ -112,7 +112,7 @@
"jasmine": "5.1.0", "jasmine": "5.1.0",
"jsdoc": "4.0.2", "jsdoc": "4.0.2",
"jsonc-eslint-parser": "2.3.0", "jsonc-eslint-parser": "2.3.0",
"lint-staged": "13.2.3", "lint-staged": "13.3.0",
"lorem-ipsum": "2.0.8", "lorem-ipsum": "2.0.8",
"nodemon": "3.0.1", "nodemon": "3.0.1",
"prettier": "3.0.1", "prettier": "3.0.1",

View File

@ -301,16 +301,10 @@ function importEnex(taskContext, file, parentNote) {
? resource.title ? resource.title
: `image.${resource.mime.substr(6)}`; // default if real name is not present : `image.${resource.mime.substr(6)}`; // default if real name is not present
const {url, note: imageNote} = imageService.saveImage(noteEntity.noteId, resource.content, originalName, taskContext.data.shrinkImages); const attachment = imageService.saveImageToAttachment(noteEntity.noteId, resource.content, originalName, taskContext.data.shrinkImages);
for (const attr of resource.attributes) {
if (attr.name !== 'originalFileName') { // this one is already saved in imageService
imageNote.addAttribute(attr.type, attr.name, attr.value);
}
}
updateDates(imageNote, utcDateCreated, utcDateModified);
const sanitizedTitle = attachment.title.replace(/[^a-z0-9-.]/gi, "");
const url = `api/attachments/${attachment.attachmentId}/image/${sanitizedTitle}`;
const imageLink = `<img src="${url}">`; const imageLink = `<img src="${url}">`;
content = content.replace(mediaRegex, imageLink); content = content.replace(mediaRegex, imageLink);