4 Commits

Author SHA1 Message Date
5c29bb3bb9 Merge pull request #7 from webislife/v1
0.9.31 fix bug with localstorage restore state
2023-02-13 19:09:19 +03:00
e095392d54 Merge branch 'main' into v1 2023-02-13 19:09:06 +03:00
dc0482166a 0.9.31 fix bug with localstorage restore state 2023-02-13 19:07:19 +03:00
92d68cefc8 Update package.json 2023-02-13 02:09:08 +03:00
2 changed files with 14 additions and 10 deletions

View File

@ -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",
@ -38,4 +38,4 @@
"@webislife:registry": "https://npm.pkg.github.com"
}
}

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;