imported internal links crash ckeditor, #1979

This commit is contained in:
zadam 2021-05-25 21:45:59 +02:00
parent 3c7232f427
commit b9639bffce
4 changed files with 11 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -11,7 +11,7 @@ function sanitize(dirtyHtml) {
'figure', 'span', 'label', 'input'
],
allowedAttributes: {
'a': [ 'href', 'class' ],
'a': [ 'href', 'class', 'data-note-path' ],
'img': [ 'src' ],
'section': [ 'class', 'data-note-id' ],
'figure': [ 'class' ],

View File

@ -307,6 +307,14 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
return `href="#root/${targetNoteId}"`;
});
content = content.replace(/data-note-path="([^"]*)"/g, (match, notePath) => {
const noteId = notePath.split("/").pop();
const targetNoteId = noteIdMap[noteId];
return `data-note-path="root/${targetNoteId}"`;
});
if (noteMeta) {
const includeNoteLinks = (noteMeta.attributes || [])
.filter(attr => attr.type === 'relation' && attr.name === 'includeNoteLink');