Merge pull request #7 from webislife/v1

0.9.31 fix bug with localstorage restore state
This commit is contained in:
Denis
2023-02-13 19:09:19 +03:00
committed by GitHub
2 changed files with 13 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@webislife/wc-wysiwyg",
"version": "0.9.3",
"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",

View File

@ -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;