mirror of
https://github.com/webislife/wc-wysiwyg.git
synced 2025-07-22 06:59:36 +00:00
Merge pull request #7 from webislife/v1
0.9.31 fix bug with localstorage restore state
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@webislife/wc-wysiwyg",
|
"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",
|
"description": "WYWSIWYG HTML5 Editor written in ts and designed by web-componennt, support all JS frameworks and browsers",
|
||||||
"main": "dist/wc-wysiwyg.js",
|
"main": "dist/wc-wysiwyg.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
@ -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.#EditProps = this.getAttribute('data-edit-props') !== null ? JSON.parse(this.getAttribute('data-edit-props') || '') : false;
|
||||||
this.#Autocomplete = this.getAttribute('data-autocomplete') === '1';
|
this.#Autocomplete = this.getAttribute('data-autocomplete') === '1';
|
||||||
this.#HideBottomActions = this.getAttribute('data-hide-bottom-actions') === '1';
|
this.#HideBottomActions = this.getAttribute('data-hide-bottom-actions') === '1';
|
||||||
|
|
||||||
//allow inline without ['video','audio','img']
|
//allow inline without ['video','audio','img']
|
||||||
this.EditorInlineActions = this.EditorTags.filter(action => ['video','audio','img'].includes(action.tag) === false);
|
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'] });
|
this.EditorActionsSection = el('section', { classList: ['wc-wysiwyg_ec'] });
|
||||||
//Clear format button
|
//Clear format button
|
||||||
this.EditorClearFormatBtn = el('button', {
|
this.EditorClearFormatBtn = el('button', {
|
||||||
@ -362,6 +356,16 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
this.append(this.EditorBottomForm);
|
this.append(this.EditorBottomForm);
|
||||||
}
|
}
|
||||||
this.EditorNode.innerHTML = this.EditorPreviewText.value;
|
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.updateContent();
|
||||||
|
|
||||||
this.#Connected = true;
|
this.#Connected = true;
|
||||||
|
Reference in New Issue
Block a user