diff --git a/Architype.js b/Architype.js index fc24fc2..8bba8ef 100644 --- a/Architype.js +++ b/Architype.js @@ -31,23 +31,15 @@ class Architype { this.unserialize(JSON.parse(localStorage.getItem('currentState'))); - this.observeStructure_ = new MutationObserver(e => { this.onStructureChange(e); }); - this.observeStructure_.observe(editorElem, { + this.observer_ = new MutationObserver(e => { this.onChange(e); }); + this.observer_.observe(editorElem, { attributes: true, - attributeFilter: ['data-struct-change'], + attributeFilter: ['data-arch-value'], childList: true, subtree: true, }); - // TODO: handle case when value change alters link graph - this.observeContent_ = new MutationObserver(e => { this.onContentChange(e); }); - this.observeContent_.observe(editorElem, { - attributes: true, - attributeFilter: ['data-arch-value'], - subtree: true, - }); - - this.onStructureChange(); + this.onChange(); } serialize() { @@ -73,12 +65,8 @@ class Architype { } } - onStructureChange(e) { + onChange(e) { this.graph_ = this.buildGraph(); - this.onContentChange(e); - } - - onContentChange(e) { localStorage.setItem('currentState', JSON.stringify(this.serialize())); this.buildGrid(this.graph_); this.updateTargets(this.graph_); diff --git a/EditorNode.js b/EditorNode.js index 12dde0d..caf37c5 100644 --- a/EditorNode.js +++ b/EditorNode.js @@ -121,10 +121,6 @@ class EditorNode extends EditorEntryBase { } onInput() { - if (!this.input_.getAttribute('data-arch-value') || - this.input_.value == '') { - this.input_.setAttribute('data-struct-change', 'x'); - } this.input_.setAttribute('data-arch-value', this.input_.value); }