mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixed major rendering problem with mixed links and formattings
This commit is contained in:
parent
579f9eaa60
commit
4a5d29b83d
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>insert - create new note on current tree level</li>
|
<li>insert - create new note on current tree level</li>
|
||||||
<li>shift + insert - create new sub-note</li>
|
<li>ctrl + insert - create new sub-note</li>
|
||||||
<li>delete - delete current note (and it's sub-notes)</li>
|
<li>delete - delete current note (and it's sub-notes)</li>
|
||||||
<li>shift + up - move current note up in the current tree level</li>
|
<li>shift + up - move current note up in the current tree level</li>
|
||||||
<li>shift + down - move current note down in the current tree level</li>
|
<li>shift + down - move current note down in the current tree level</li>
|
||||||
|
@ -144,5 +144,7 @@ function html2notecase(contents, note) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//console.log(contents);
|
||||||
|
|
||||||
note.detail.note_text = contents;
|
note.detail.note_text = contents;
|
||||||
}
|
}
|
@ -1,9 +1,14 @@
|
|||||||
function notecase2html(note) {
|
function notecase2html(note) {
|
||||||
let noteText = note.detail.note_text;
|
let noteText = note.detail.note_text;
|
||||||
|
|
||||||
let formatting = note.formatting;
|
note.formatting.forEach(el => el.type = 'formatting');
|
||||||
let links = note.links;
|
note.links.forEach(el => el.type = 'link');
|
||||||
let images = note.images;
|
note.images.forEach(el => el.type = 'image');
|
||||||
|
|
||||||
|
let all = note.formatting.concat(note.links).concat(note.images);
|
||||||
|
all.sort(function compare(a, b) {
|
||||||
|
return a.note_offset - b.note_offset;
|
||||||
|
});
|
||||||
|
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
let lastTag = null;
|
let lastTag = null;
|
||||||
@ -14,32 +19,28 @@ function notecase2html(note) {
|
|||||||
return noteText.substr(0, position) + injected + noteText.substr(position);
|
return noteText.substr(0, position) + injected + noteText.substr(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let fmt of formatting) {
|
for (let el of all) {
|
||||||
if (tags[fmt.fmt_tag]) {
|
if (el.type === 'formatting') {
|
||||||
noteText = inject(noteText, tags[fmt.fmt_tag], fmt.note_offset + offset);
|
if (tags[el.fmt_tag]) {
|
||||||
|
noteText = inject(noteText, tags[el.fmt_tag], el.note_offset + offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (el.type === 'link') {
|
||||||
|
let linkHtml = '<a href="' + el.target_url + '">' + el.lnk_text + '</a>';
|
||||||
|
|
||||||
offset = 0;
|
noteText = noteText.substr(0, el.note_offset + offset) + noteText.substr(el.note_offset + offset + el.lnk_text.length);
|
||||||
|
|
||||||
for (let link of links) {
|
noteText = inject(noteText, linkHtml, el.note_offset + offset);
|
||||||
let linkHtml = '<a href="' + link.target_url + '">' + link.lnk_text + '</a>';
|
|
||||||
|
|
||||||
noteText = noteText.substr(0, link.note_offset + offset) + noteText.substr(link.note_offset + offset + link.lnk_text.length);
|
offset -= el.lnk_text.length;
|
||||||
|
|
||||||
noteText = inject(noteText, linkHtml, link.note_offset + offset);
|
|
||||||
|
|
||||||
offset -= link.lnk_text.length;
|
|
||||||
}
|
}
|
||||||
|
else if (el.type === 'image') {
|
||||||
|
let type = el.is_png ? "png" : "jpg";
|
||||||
|
|
||||||
offset = 0;
|
let imgHtml = '<img alt="Embedded Image" src="data:image/' + type + ';base64,' + el.image_data + '" />';
|
||||||
|
|
||||||
for (let image of images) {
|
noteText = inject(noteText, imgHtml, el.note_offset + offset);
|
||||||
let type = image.is_png ? "png" : "jpg";
|
}
|
||||||
|
|
||||||
let imgHtml = '<img alt="Embedded Image" src="data:image/' + type + ';base64,' + image.image_data + '" />';
|
|
||||||
|
|
||||||
noteText = inject(noteText, imgHtml, image.note_offset + offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
noteText = noteText.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
noteText = noteText.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user