split out note's content into separate entity, WIP

This commit is contained in:
zadam
2019-02-06 20:19:25 +01:00
parent 8b250ed523
commit 8884177d9f
18 changed files with 417 additions and 213 deletions

View File

@@ -8,15 +8,15 @@ class NoteFull extends NoteShort {
super(treeCache, row);
/** @param {string} */
this.content = row.content;
this.noteContent = row.noteContent;
if (this.content !== "" && this.isJson()) {
try {
/** @param {object} */
this.jsonContent = JSON.parse(this.content);
}
catch(e) {}
}
// if (this.content !== "" && this.isJson()) {
// try {
// /** @param {object} */
// this.jsonContent = JSON.parse(this.content);
// }
// catch(e) {}
// }
}
}

View File

@@ -357,6 +357,7 @@ export default {
updateNoteView,
loadNote,
getCurrentNote,
getCurrentNoteContent,
getCurrentNoteType,
getCurrentNoteId,
focusOnTitle,
@@ -364,7 +365,6 @@ export default {
saveNote,
saveNoteIfChanged,
noteChanged,
getCurrentNoteContent,
onNoteChange,
addDetailLoadedListener
};

View File

@@ -49,7 +49,7 @@ async function show() {
// this needs to happen after the element is shown, otherwise the editor won't be refreshed
// CodeMirror breaks pretty badly on null so even though it shouldn't happen (guarded by consistency check)
// we provide fallback
codeEditor.setValue(currentNote.content || "");
codeEditor.setValue(currentNote.noteContent.content || "");
const info = CodeMirror.findModeByMIME(currentNote.mime);

View File

@@ -27,8 +27,8 @@ async function show() {
$fileSize.text((attributeMap.fileSize || "?") + " bytes");
$fileType.text(currentNote.mime);
$previewRow.toggle(!!currentNote.content);
$previewContent.text(currentNote.content);
$previewRow.toggle(!!currentNote.noteContent.content);
$previewContent.text(currentNote.noteContent.content);
}
$downloadButton.click(() => utils.download(getFileUrl()));

View File

@@ -93,9 +93,9 @@ function loadMapData() {
}
};
if (currentNote.content) {
if (currentNote.noteContent.content) {
try {
mapData = JSON.parse(currentNote.content);
mapData = JSON.parse(currentNote.noteContent.content);
} catch (e) {
console.log("Could not parse content: ", e);
}

View File

@@ -16,7 +16,7 @@ function show() {
$component.show();
try {
const json = JSON.parse(noteDetailService.getCurrentNote().content);
const json = JSON.parse(noteDetailService.getCurrentNote().noteContent.content);
$searchString.val(json.searchString);
}

View File

@@ -22,7 +22,7 @@ async function show() {
textEditor.isReadOnly = await isReadOnly();
textEditor.setData(noteDetailService.getCurrentNote().content);
textEditor.setData(noteDetailService.getCurrentNote().noteContent.content);
$component.show();
}