From f21f7deb88046e76ed4396923e6927b0c80bb724 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Tue, 17 Nov 2020 13:47:57 +0530 Subject: [PATCH] #se-input webcomponent event change update to svgedit --- src/editor/components/seInput.js | 38 ++++++++++++++++------------- src/editor/index.html | 6 ++--- src/editor/svgedit.js | 42 +++++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 21 deletions(-) diff --git a/src/editor/components/seInput.js b/src/editor/components/seInput.js index 76040a18..96d58991 100644 --- a/src/editor/components/seInput.js +++ b/src/editor/components/seInput.js @@ -19,7 +19,8 @@ class SeInput extends Input { return Object.assign(super[defaultState], { label: '', src: '', - inputsize: '100%' + inputsize: '100%', + value: '' }); } @@ -29,12 +30,19 @@ class SeInput extends Input { */ get [internal.template] () { const result = super[internal.template]; - console.log(result.content); result.content.prepend(fragmentFrom.html` - `.cloneNode(true)); + `.cloneNode(true)); + // change the style so it fits in our toolbar + result.content.append( + templateFrom.html` + + `.content + ); return result; } /** @@ -82,18 +90,13 @@ class SeInput extends Input { this.$input = this.shadowRoot.getElementById('inner'); this.$img = this.shadowRoot.querySelector('img'); this.$span = this.shadowRoot.querySelector('span'); - console.log(this.shadowRoot); - console.log(this.shadowRoot.querySelector('label')); - console.log(this.shadowRoot.querySelector('span')); - console.log(this.shadowRoot.querySelector('img')); - /* this.$event = new CustomEvent('change'); - this.addEventListener('selectedindexchange', (e) => { + this.$event = new CustomEvent('change'); + this.addEventListener('change', (e) => { e.preventDefault(); - this.value = this.children[e.detail.selectedIndex].getAttribute('value'); - }); */ + this.value = e.target.value; + }); } if (changed.inputsize) { - console.log('changed.inputsize --> ', this[internal.state].inputsize); this.$input.style.width = this[internal.state].inputsize; } if (changed.src) { @@ -108,13 +111,15 @@ class SeInput extends Input { this.$img.style.display = 'none'; } } + if (changed.value) { + this.dispatchEvent(this.$event); + } } /** * @function inputsize * @returns {string} inputsize */ get inputsize () { - console.log('get inputsize --> ', this[internal.state].inputsize); return this[internal.state].inputsize; } /** @@ -122,7 +127,6 @@ class SeInput extends Input { * @returns {void} */ set inputsize (inputsize) { - console.log('set inputsize --> ', this[internal.state].inputsize); this[internal.setState]({inputsize}); } /** diff --git a/src/editor/index.html b/src/editor/index.html index e487c5ee..a5ee50f1 100644 --- a/src/editor/index.html +++ b/src/editor/index.html @@ -147,12 +147,12 @@
-