support for loading and saving type and mime

This commit is contained in:
azivner
2018-01-21 23:36:09 -05:00
parent f9631ff59f
commit e56fb6d2d4
8 changed files with 40 additions and 20 deletions

View File

@@ -70,6 +70,8 @@ const noteEditor = (function() {
}
else if (note.detail.type === 'code') {
note.detail.note_text = codeEditor.getValue();
codeEditor.setOption("mode", note.detail.mime);
}
else {
throwError("Unrecognized type: " + note.detail.type);
@@ -131,6 +133,9 @@ const noteEditor = (function() {
noteTitleEl.val(currentNote.detail.note_title);
noteType.setNoteType(currentNote.detail.type);
noteType.setNoteMime(currentNote.detail.mime);
if (currentNote.detail.type === 'text') {
// temporary workaround for https://github.com/ckeditor/ckeditor5-enter/issues/49
editor.setData(currentNote.detail.note_text ? currentNote.detail.note_text : "<p></p>");
@@ -189,7 +194,6 @@ const noteEditor = (function() {
codeEditor = CodeMirror($("#note-detail-code")[0], {
value: "",
mode: "javascript",
viewportMargin: Infinity
});
@@ -205,18 +209,6 @@ const noteEditor = (function() {
noteDetailEl.attr("tabindex", 2);
});
$(document).bind('keydown', 'alt+q', async e => {
const note = getCurrentNote();
const type = note.detail.type;
const newType = type === "text" ? "code" : "text";
await server.put('notes/' + note.detail.note_id + '/type/' + newType);
await reload();
e.preventDefault();
});
setInterval(saveNoteIfChanged, 5000);
return {