editor note references

This commit is contained in:
Mo Bitar
2017-02-27 13:59:11 -06:00
parent e08c284a30
commit 1f90bf0286
6 changed files with 74 additions and 13 deletions

View File

@@ -52,8 +52,10 @@ angular.module('app.frontend')
this.showMenu = false;
this.loadTagsString();
if(note.editorUrl) {
this.customEditor = this.editorForUrl(note.editorUrl);
var editor = this.editorForNote(note);
if(editor) {
this.customEditor = editor;
this.postNoteToExternalEditor();
} else {
this.customEditor = null;
@@ -75,16 +77,27 @@ angular.module('app.frontend')
this.selectedEditor = function(editor) {
this.showEditorMenu = false;
if(editor.default) {
if(this.customEditor) {
this.customEditor.removeItemAsRelationship(this.note);
this.customEditor.setDirty(true);
}
this.customEditor = null;
} else {
this.customEditor = editor;
this.customEditor.addItemAsRelationship(this.note);
this.customEditor.setDirty(true);
}
this.note.editorUrl = editor.url;
}.bind(this)
this.editorForUrl = function(url) {
this.editorForNote = function(note) {
var editors = modelManager.itemsForContentType("SN|Editor");
return editors.filter(function(editor){return editor.url == url})[0];
for(var editor of editors) {
// console.log(editor.notes, editor.references);
if(_.includes(editor.notes, note)) {
return editor;
}
}
return null;
}
this.postNoteToExternalEditor = function() {