From 0daf666fee67e4969a2f3b1b1efa559bee130f19 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Wed, 3 Jul 2019 01:51:13 +0000 Subject: [PATCH] Redraw graph on all changes --- Architype.js | 22 +++++----------------- EditorNode.js | 4 ---- 2 files changed, 5 insertions(+), 21 deletions(-) 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); }