mirror of
https://github.com/codex-team/editor.js
synced 2026-03-16 15:45:47 +01:00
Update data get/set
This commit is contained in:
parent
5e462d4f7f
commit
392074cdc6
1 changed files with 15 additions and 7 deletions
|
|
@ -13,10 +13,16 @@ class Paragraph {
|
|||
|
||||
constructor(data={}) {
|
||||
|
||||
this.CLASS = 'ce-paragraph';
|
||||
this.CSS = {
|
||||
wrapper: 'ce-paragraph'
|
||||
};
|
||||
|
||||
this._data = {};
|
||||
|
||||
this.data = data;
|
||||
|
||||
this.element = this.render();
|
||||
this.data = data;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -24,7 +30,7 @@ class Paragraph {
|
|||
|
||||
let div = document.createElement('DIV');
|
||||
|
||||
div.classList.add(this.CLASS);
|
||||
div.classList.add(this.CSS.wrapper);
|
||||
div.contentEditable = true;
|
||||
|
||||
return div;
|
||||
|
|
@ -53,15 +59,17 @@ class Paragraph {
|
|||
|
||||
let text = this.element.innerHTML;
|
||||
|
||||
return {
|
||||
'text': text,
|
||||
};
|
||||
this._data.text = text;
|
||||
|
||||
return this._data;
|
||||
|
||||
}
|
||||
|
||||
set data(data) {
|
||||
|
||||
this.element.innerHTML = data.text || '';
|
||||
Object.assign(this._data, data);
|
||||
|
||||
this.element.innerHTML = this._data.text || '';
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue