editor data
This commit is contained in:
@@ -53,8 +53,14 @@ angular.module('app.frontend')
|
||||
} else {
|
||||
var id = event.data.id;
|
||||
var text = event.data.text;
|
||||
if(this.note.uuid == id) {
|
||||
var data = event.data.data;
|
||||
|
||||
if(this.note.uuid === id) {
|
||||
this.note.text = text;
|
||||
var changesMade = this.customEditor.setData(id, data);
|
||||
if(changesMade) {
|
||||
this.customEditor.setDirty(true);
|
||||
}
|
||||
this.changesMade();
|
||||
}
|
||||
}
|
||||
@@ -103,7 +109,7 @@ angular.module('app.frontend')
|
||||
this.postNoteToExternalEditor = function() {
|
||||
var externalEditorElement = document.getElementById("editor-iframe");
|
||||
if(externalEditorElement) {
|
||||
externalEditorElement.contentWindow.postMessage({text: this.note.text, id: this.note.uuid}, '*');
|
||||
externalEditorElement.contentWindow.postMessage({text: this.note.text, data: this.customEditor.dataForKey(this.note.uuid), id: this.note.uuid}, '*');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,14 @@ class Editor extends Item {
|
||||
super.mapContentToLocalProperties(contentObject)
|
||||
this.url = contentObject.url;
|
||||
this.name = contentObject.name;
|
||||
this.data = contentObject.data || {};
|
||||
}
|
||||
|
||||
structureParams() {
|
||||
var params = {
|
||||
url: this.url,
|
||||
name: this.name
|
||||
name: this.name,
|
||||
data: this.data
|
||||
};
|
||||
|
||||
_.merge(params, super.structureParams());
|
||||
@@ -27,4 +29,17 @@ class Editor extends Item {
|
||||
get content_type() {
|
||||
return "SN|Editor";
|
||||
}
|
||||
|
||||
setData(key, value) {
|
||||
var dataHasChanged = JSON.stringify(this.data[key]) !== JSON.stringify(value);
|
||||
if(dataHasChanged) {
|
||||
this.data[key] = value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
dataForKey(key) {
|
||||
return this.data[key] || {};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user