editor data
This commit is contained in:
@@ -53,8 +53,14 @@ angular.module('app.frontend')
|
|||||||
} else {
|
} else {
|
||||||
var id = event.data.id;
|
var id = event.data.id;
|
||||||
var text = event.data.text;
|
var text = event.data.text;
|
||||||
if(this.note.uuid == id) {
|
var data = event.data.data;
|
||||||
|
|
||||||
|
if(this.note.uuid === id) {
|
||||||
this.note.text = text;
|
this.note.text = text;
|
||||||
|
var changesMade = this.customEditor.setData(id, data);
|
||||||
|
if(changesMade) {
|
||||||
|
this.customEditor.setDirty(true);
|
||||||
|
}
|
||||||
this.changesMade();
|
this.changesMade();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,7 +109,7 @@ angular.module('app.frontend')
|
|||||||
this.postNoteToExternalEditor = function() {
|
this.postNoteToExternalEditor = function() {
|
||||||
var externalEditorElement = document.getElementById("editor-iframe");
|
var externalEditorElement = document.getElementById("editor-iframe");
|
||||||
if(externalEditorElement) {
|
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)
|
super.mapContentToLocalProperties(contentObject)
|
||||||
this.url = contentObject.url;
|
this.url = contentObject.url;
|
||||||
this.name = contentObject.name;
|
this.name = contentObject.name;
|
||||||
|
this.data = contentObject.data || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
structureParams() {
|
structureParams() {
|
||||||
var params = {
|
var params = {
|
||||||
url: this.url,
|
url: this.url,
|
||||||
name: this.name
|
name: this.name,
|
||||||
|
data: this.data
|
||||||
};
|
};
|
||||||
|
|
||||||
_.merge(params, super.structureParams());
|
_.merge(params, super.structureParams());
|
||||||
@@ -27,4 +29,17 @@ class Editor extends Item {
|
|||||||
get content_type() {
|
get content_type() {
|
||||||
return "SN|Editor";
|
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