From dc0482166ac7c3cfa8b8177f33f6dc6cd85a085f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=A1=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=BE=D0=B2?= Date: Mon, 13 Feb 2023 19:07:19 +0300 Subject: [PATCH] 0.9.31 fix bug with localstorage restore state --- package.json | 2 +- src/wc-wysiwyg.ts | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index f7a11d0..e6cbb69 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@webislife/wc-wysiwyg", - "version": "0.9.2", + "version": "0.9.31", "description": "WYWSIWYG HTML5 Editor written in ts and designed by web-componennt, support all JS frameworks and browsers", "main": "dist/wc-wysiwyg.js", "type": "module", diff --git a/src/wc-wysiwyg.ts b/src/wc-wysiwyg.ts index ce43684..65ab9ac 100644 --- a/src/wc-wysiwyg.ts +++ b/src/wc-wysiwyg.ts @@ -133,17 +133,11 @@ class WCWYSIWYG extends HTMLElement { this.#EditProps = this.getAttribute('data-edit-props') !== null ? JSON.parse(this.getAttribute('data-edit-props') || '') : false; this.#Autocomplete = this.getAttribute('data-autocomplete') === '1'; this.#HideBottomActions = this.getAttribute('data-hide-bottom-actions') === '1'; + //allow inline without ['video','audio','img'] this.EditorInlineActions = this.EditorTags.filter(action => ['video','audio','img'].includes(action.tag) === false); - //Check local storage key - this.#SotrageKey = this.getAttribute('data-storage'); - if(this.#SotrageKey) { - let storeValue = window.localStorage.getItem(this.#SotrageKey); - if(storeValue) { - this.value = storeValue; - } - } + this.EditorActionsSection = el('section', { classList: ['wc-wysiwyg_ec'] }); //Clear format button this.EditorClearFormatBtn = el('button', { @@ -362,6 +356,16 @@ class WCWYSIWYG extends HTMLElement { this.append(this.EditorBottomForm); } this.EditorNode.innerHTML = this.EditorPreviewText.value; + //Check local storage key + this.#SotrageKey = this.getAttribute('data-storage'); + console.log('storage key is ', this.#SotrageKey); + if(this.#SotrageKey) { + let storeValue = window.localStorage.getItem(this.#SotrageKey); + console.log('restore from storage', storeValue); + if(storeValue) { + this.EditorNode.innerHTML = storeValue; + } + } this.updateContent(); this.#Connected = true;