mirror of
https://github.com/webislife/wc-wysiwyg.git
synced 2025-07-30 12:55:58 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
ac5f987346 | |||
10b3d32a8e | |||
fa78a053bc | |||
b0abbd9df8 | |||
805f0421a5 | |||
e34226efb8 | |||
0283a5ae02 | |||
26d1bc72ea | |||
a59904adfe | |||
1bbcdf97f0 |
2
.github/workflows/release-package.yml
vendored
2
.github/workflows/release-package.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: wc-wysiwyg-editor package
|
name: wc-wysiwyg package
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
|
85
README.md
85
README.md
@ -1,7 +1,45 @@
|
|||||||
# wc-time
|
# wc-wysiwyg custom element
|
||||||
WYWSIWYG HTML5 Editor written in TypeScript and designed by web-componennt, support all JS frameworks and browsers.
|
|
||||||
|
WC-WSIWYG HTML5 Editor written in TypeScript and designed by web-componennt, support all JS frameworks and browsers.
|
||||||
See full demo - [wc-wysiwyg demo](https://webislife.ru/demo/wc-wysiwyg/) list and demo of all editor features
|
See full demo - [wc-wysiwyg demo](https://webislife.ru/demo/wc-wysiwyg/) list and demo of all editor features
|
||||||
|
|
||||||
|
## Features
|
||||||
|
✅ Multilingual support via [HTMLElement.lang](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/lang) attribute 🇷🇺/🇺🇸 supported by default
|
||||||
|
|
||||||
|
✅ 🌐 Support all major browsers
|
||||||
|
|
||||||
|
✅ 🚀 Reusable between all major JS frameworks
|
||||||
|
|
||||||
|
✅ CSS styles for all popular HTML5 tags
|
||||||
|
|
||||||
|
✅ CSS support for 🔥 in bulleted lists
|
||||||
|
|
||||||
|
✅ Support for style inheritance via CSS class in the `data-content-class` attribute of emoji in bulleted lists
|
||||||
|
|
||||||
|
✅ Inline actions on selected text
|
||||||
|
|
||||||
|
✅ Storing value in `window.localStorage` and restoring after reload, check in comment form below
|
||||||
|
|
||||||
|
✅ Eetting editable properties of any tags, the number of tags and attributes are configurable
|
||||||
|
|
||||||
|
✅ Autocomplete as you type `/` for supported tags in new paragraph
|
||||||
|
|
||||||
|
✅ `Text\HTML5` view switcher
|
||||||
|
|
||||||
|
✅ Clear format tag button `Ⱦ`
|
||||||
|
|
||||||
|
✅ Live preview
|
||||||
|
|
||||||
|
- ✅ Keyboard Shortcuts
|
||||||
|
- `ALT`+`SPACE` toggle the current caret pointer outside the tag
|
||||||
|
- `ESCAPE` close bottom editor dialog box
|
||||||
|
|
||||||
|
✅ Validation `required`, `minlength`, `maxlength`, `filtertags`
|
||||||
|
|
||||||
|
✅ Inserting `<audio>` element
|
||||||
|
|
||||||
|
✅ Inserting `<video>` element
|
||||||
|
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
@ -11,26 +49,42 @@ npm i wc-wysiwyg-editor --save
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
Available package commands
|
- Available package commands
|
||||||
|
|
||||||
|
Build scss styles
|
||||||
|
```
|
||||||
|
npm run sass
|
||||||
|
```
|
||||||
|
- Compile TypeScript
|
||||||
|
```
|
||||||
|
npm run tsc
|
||||||
|
```
|
||||||
|
- Minify code with babel-minify after TypeScript compile
|
||||||
|
```
|
||||||
|
npm run babel-minify
|
||||||
|
```
|
||||||
|
build all stpes 1.sass 2.tsc 3.babel-minif
|
||||||
|
|
||||||
```
|
```
|
||||||
`npm run sass' - build scss styles
|
npm run build
|
||||||
`npm run tsc' - run typescript
|
|
||||||
`npm run babel-minify' - minify code after typescript
|
|
||||||
`npm run build' - build all stpes 1.sass 2.tsc 3.babel-minify
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Custom element demo
|
## Integration WC-WYSIWYG element demo
|
||||||
<!--
|
<!--
|
||||||
```
|
```
|
||||||
<custom-element-demo>
|
<wc-wysiwyg value="foo">
|
||||||
<template>
|
<textarea></textarea>
|
||||||
<link rel="import" href="index.html">
|
</wc-wysiwyg>
|
||||||
<next-code-block></next-code-block>
|
|
||||||
</template>
|
|
||||||
</custom-element-demo>
|
|
||||||
```
|
```
|
||||||
-->
|
-->
|
||||||
|
First, include JS and define custom element
|
||||||
|
```javascript
|
||||||
|
import('/src/components/wc-wysiwyg.js').then(esm => {
|
||||||
|
esm.define();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
And use in HTML
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<wc-wysiwyg id="wc-demo-comment"
|
<wc-wysiwyg id="wc-demo-comment"
|
||||||
data-allow-tags="strong,u,i,b,q,blockquote,a,img,pre"
|
data-allow-tags="strong,u,i,b,q,blockquote,a,img,pre"
|
||||||
@ -44,8 +98,9 @@ Available package commands
|
|||||||
</wc-wysiwyg>
|
</wc-wysiwyg>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
See full demo - [wc-wysiwyg demo](https://webislife.ru/demo/wc-wysiwyg/) list and demo of all editor features
|
See full demo - [wc-wysiwyg demo](https://webislife.ru/demo/wc-wysiwyg/) list and demo of all editor features
|
||||||
|
|
||||||
Dont forgot star on git! Thank you! Enojoy!
|
Dont forgot star on git! Thank you! Enojoy!
|
||||||
|
|
||||||
Dev by strokoff.ru - make web, not war)
|
Dev by strokoff - make web, not war)
|
10
package.json
10
package.json
@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "wc-wysiwyg-editor",
|
"name": "@webislife/wc-wysiwyg",
|
||||||
"version": "0.9.1",
|
"version": "0.9.2",
|
||||||
"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": "src/wc-wysiwyg.ts",
|
"main": "dist/wc-wysiwyg.js",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"sass": "./node_modules/node-sass/bin/node-sass ./src -o ./dist",
|
"sass": "./node_modules/node-sass/bin/node-sass ./src -o ./dist",
|
||||||
"tsc": "./node_modules/.bin/tsc",
|
"tsc": "./node_modules/.bin/tsc",
|
||||||
@ -16,7 +17,8 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"web-component",
|
"web-component",
|
||||||
"custom-element",
|
"custom-element",
|
||||||
"time",
|
"html5 editor",
|
||||||
|
"wysiwyg",
|
||||||
"html5",
|
"html5",
|
||||||
"esnext",
|
"esnext",
|
||||||
"typescript"
|
"typescript"
|
||||||
|
@ -99,7 +99,9 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
//if check exist selection string
|
//if check exist selection string
|
||||||
if(selection !== null && selection.toString().length > 0) {
|
if(selection !== null && selection.toString().length > 0) {
|
||||||
this.EditorInlineActionsForm.style.display = '';
|
this.EditorInlineActionsForm.style.display = '';
|
||||||
|
if(this.EditorPropertyForm){
|
||||||
this.EditorPropertyForm.style.display = 'none';
|
this.EditorPropertyForm.style.display = 'none';
|
||||||
|
}
|
||||||
this.showEditorInlineDialog();
|
this.showEditorInlineDialog();
|
||||||
} else {
|
} else {
|
||||||
this.hideEditorInlineDialog();
|
this.hideEditorInlineDialog();
|
||||||
@ -128,7 +130,7 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
this.EditorAllowTags = allowTags.split(',');
|
this.EditorAllowTags = allowTags.split(',');
|
||||||
this.EditorTags = allTags.filter(tag => allowTags.includes(tag.tag));
|
this.EditorTags = allTags.filter(tag => allowTags.includes(tag.tag));
|
||||||
|
|
||||||
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']
|
||||||
@ -210,6 +212,93 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
classList: ['wc-wysiwyg_bt'],
|
classList: ['wc-wysiwyg_bt'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Check custom tags
|
||||||
|
this.EditorCustomTags = JSON.parse( String(this.getAttribute('data-custom-tags')) );
|
||||||
|
if(this.EditorCustomTags !== null) {
|
||||||
|
//Custom panel tags
|
||||||
|
this.EditorCustomTagsForm = el('fieldset', {
|
||||||
|
classList: ['wc-wysiwyg_ce'],
|
||||||
|
});
|
||||||
|
//Make custom actions buttons panel
|
||||||
|
this.#makeActionButtons(this.EditorCustomTagsForm as HTMLElement, this.EditorCustomTags);
|
||||||
|
|
||||||
|
this.appendChild(this.EditorCustomTagsForm as HTMLElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Node editable
|
||||||
|
this.EditorNode = el('article', {
|
||||||
|
classList: ['wc-wysiwyg_content', this.getAttribute('data-content-class') || ''],
|
||||||
|
props: {
|
||||||
|
contentEditable: true,
|
||||||
|
onpointerup: event => {
|
||||||
|
this.checkCanClearElement(event);
|
||||||
|
if(this.#EditProps) {
|
||||||
|
this.checkEditProps(event);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
oninput: event => {
|
||||||
|
this.updateContent();
|
||||||
|
if(this.#Autocomplete) {
|
||||||
|
this.checkAutoComplete();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//Handle key bindings
|
||||||
|
onkeydown: event => {
|
||||||
|
//check hold alt
|
||||||
|
if(event.altKey) {
|
||||||
|
//alt+space - move caret to parent node next sibling
|
||||||
|
if(event.code === 'Space') {
|
||||||
|
const Selection = window.getSelection();
|
||||||
|
if(Selection?.type === 'Caret') {
|
||||||
|
//insertAdjacentElement dont support textNodes, first insert span
|
||||||
|
const span = el('span');
|
||||||
|
Selection?.anchorNode?.parentElement?.insertAdjacentElement('afterend', span)
|
||||||
|
//after replace span with textnode and select it
|
||||||
|
const textN = document.createTextNode(' ');
|
||||||
|
span.replaceWith(textN);
|
||||||
|
const range = document.createRange();
|
||||||
|
range.selectNodeContents(textN);
|
||||||
|
Selection.removeAllRanges();
|
||||||
|
Selection.addRange(range);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//tag - hide editor dialog
|
||||||
|
if(event.code === 'Escape') {
|
||||||
|
this.hideEditorInlineDialog();
|
||||||
|
}
|
||||||
|
//enter - set p as default tag in newline
|
||||||
|
if(event.code === 'Enter' && event.shiftKey === false) {
|
||||||
|
const Selection = window.getSelection();
|
||||||
|
let tagName = 'p';
|
||||||
|
//tags with return default browser behavior
|
||||||
|
if(['LI', 'ARTICLE', 'P'].includes(Selection.anchorNode.parentElement.tagName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const p = el(tagName, { props: { innerHTML: ` ` } });
|
||||||
|
Selection?.anchorNode?.parentElement?.insertAdjacentElement('afterend', p);
|
||||||
|
const range = document.createRange();
|
||||||
|
range.selectNodeContents(p);
|
||||||
|
Selection?.removeAllRanges();
|
||||||
|
Selection?.addRange(range);
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
//Make action buttons
|
||||||
|
this.#makeActionButtons(this.EditorActionsSection, this.EditorTags);
|
||||||
|
this.#makeActionButtons(this.EditorInlineActionsForm, this.EditorInlineActions);
|
||||||
|
|
||||||
|
//Inser wc-editor after textarea node
|
||||||
|
this.append(
|
||||||
|
this.EditorActionsSection,
|
||||||
|
this.EditorInlineDialog,
|
||||||
|
this.EditorNode,
|
||||||
|
);
|
||||||
|
|
||||||
if(this.#HideBottomActions === false) {
|
if(this.#HideBottomActions === false) {
|
||||||
//Toggler btn text/html
|
//Toggler btn text/html
|
||||||
this.EditorBottomFormViewToggle = el('button', {
|
this.EditorBottomFormViewToggle = el('button', {
|
||||||
@ -222,9 +311,9 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
type:'button',
|
type:'button',
|
||||||
innerText: 'текст/html5',
|
innerText: 'текст/html5',
|
||||||
onpointerup: event => {
|
onpointerup: event => {
|
||||||
let mode = this.EditorBottomFormViewToggle.getAttribute('data-mode');
|
let mode = this.EditorBottomFormViewToggle?.getAttribute('data-mode');
|
||||||
let newMode = mode === 'html5' ? 'text' : 'html5';
|
let newMode = mode === 'html5' ? 'text' : 'html5';
|
||||||
this.EditorBottomFormViewToggle.setAttribute('data-mode', newMode);
|
this.EditorBottomFormViewToggle?.setAttribute('data-mode', newMode);
|
||||||
this.EditorNode.style.display = newMode === 'html5' ? '' : 'none';
|
this.EditorNode.style.display = newMode === 'html5' ? '' : 'none';
|
||||||
this.EditorPreviewText.classList.toggle('-display-none', newMode === 'html5' ? true : false)
|
this.EditorPreviewText.classList.toggle('-display-none', newMode === 'html5' ? true : false)
|
||||||
if(newMode === 'text') {
|
if(newMode === 'text') {
|
||||||
@ -265,101 +354,13 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.EditorBottomForm.append(
|
this.EditorBottomForm?.append(
|
||||||
this.EditorBottomFormNewP,
|
this.EditorBottomFormNewP,
|
||||||
this.EditorBottomFormViewToggle,
|
this.EditorBottomFormViewToggle,
|
||||||
this.EditorFullScreenButton,
|
this.EditorFullScreenButton,
|
||||||
);
|
);
|
||||||
|
this.append(this.EditorBottomForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check custom tags
|
|
||||||
this.EditorCustomTags = JSON.parse( String(this.getAttribute('data-custom-tags')) );
|
|
||||||
if(this.EditorCustomTags !== null) {
|
|
||||||
//Custom panel tags
|
|
||||||
this.EditorCustomTagsForm = el('fieldset', {
|
|
||||||
classList: ['wc-wysiwyg_ce'],
|
|
||||||
});
|
|
||||||
//Make custom actions buttons panel
|
|
||||||
this.#makeActionButtons(this.EditorCustomTagsForm, this.EditorCustomTags);
|
|
||||||
|
|
||||||
this.appendChild(this.EditorCustomTagsForm);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Node editable
|
|
||||||
this.EditorNode = el('article', {
|
|
||||||
classList: ['wc-wysiwyg_content', this.getAttribute('data-content-class')],
|
|
||||||
props: {
|
|
||||||
contentEditable: true,
|
|
||||||
onpointerup: event => {
|
|
||||||
this.checkCanClearElement(event);
|
|
||||||
if(this.#EditProps) {
|
|
||||||
this.checkEditProps(event);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
oninput: event => {
|
|
||||||
this.updateContent();
|
|
||||||
if(this.#Autocomplete) {
|
|
||||||
this.checkAutoComplete();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//Handle key bindings
|
|
||||||
onkeydown: event => {
|
|
||||||
//check hold alt
|
|
||||||
if(event.altKey) {
|
|
||||||
//alt+space - move caret to parent node next sibling
|
|
||||||
if(event.code === 'Space') {
|
|
||||||
const Selection = window.getSelection();
|
|
||||||
if(Selection.type === 'Caret') {
|
|
||||||
//insertAdjacentElement dont support textNodes, first insert span
|
|
||||||
const span = el('span');
|
|
||||||
Selection.anchorNode.parentElement.insertAdjacentElement('afterend', span)
|
|
||||||
//after replace span with textnode and select it
|
|
||||||
const textN = document.createTextNode(' ');
|
|
||||||
span.replaceWith(textN);
|
|
||||||
const range = document.createRange();
|
|
||||||
range.selectNodeContents(textN);
|
|
||||||
Selection.removeAllRanges();
|
|
||||||
Selection.addRange(range);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//tag - hide editor dialog
|
|
||||||
if(event.code === 'Escape') {
|
|
||||||
this.hideEditorInlineDialog();
|
|
||||||
}
|
|
||||||
//enter - set p as default tag in newline
|
|
||||||
if(event.code === 'Enter' && event.shiftKey === false) {
|
|
||||||
const Selection = window.getSelection();
|
|
||||||
let tagName = 'p';
|
|
||||||
//tags with return default browser behavior
|
|
||||||
if(['LI', 'ARTICLE', 'P'].includes(Selection.anchorNode.parentElement.tagName)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
const p = el(tagName, { props: { innerHTML: ` ` } });
|
|
||||||
Selection.anchorNode.parentElement.insertAdjacentElement('afterend', p);
|
|
||||||
const range = document.createRange();
|
|
||||||
range.selectNodeContents(p);
|
|
||||||
Selection.removeAllRanges();
|
|
||||||
Selection.addRange(range);
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
//Make action buttons
|
|
||||||
this.#makeActionButtons(this.EditorActionsSection, this.EditorTags);
|
|
||||||
this.#makeActionButtons(this.EditorInlineActionsForm, this.EditorInlineActions);
|
|
||||||
|
|
||||||
//Inser wc-editor after textarea node
|
|
||||||
this.append(
|
|
||||||
this.EditorActionsSection,
|
|
||||||
this.EditorInlineDialog,
|
|
||||||
this.EditorNode,
|
|
||||||
this.EditorPreviewText,
|
|
||||||
this.EditorBottomForm,
|
|
||||||
);
|
|
||||||
this.EditorNode.innerHTML = this.EditorPreviewText.value;
|
this.EditorNode.innerHTML = this.EditorPreviewText.value;
|
||||||
this.updateContent();
|
this.updateContent();
|
||||||
|
|
||||||
@ -372,6 +373,7 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
*/
|
*/
|
||||||
updateContent() {
|
updateContent() {
|
||||||
this.value = this.EditorNode.innerHTML;
|
this.value = this.EditorNode.innerHTML;
|
||||||
|
this.EditorPreviewText.value = this.value;
|
||||||
this.checkValidity();
|
this.checkValidity();
|
||||||
if(this.#SotrageKey) {
|
if(this.#SotrageKey) {
|
||||||
window.localStorage.setItem(this.#SotrageKey, this.value);
|
window.localStorage.setItem(this.#SotrageKey, this.value);
|
||||||
@ -399,7 +401,7 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
*/
|
*/
|
||||||
checkValidity() {
|
checkValidity() {
|
||||||
let hasErros = false,
|
let hasErros = false,
|
||||||
errors= [];
|
errors:string[] = [];
|
||||||
|
|
||||||
//Check attrs
|
//Check attrs
|
||||||
if(this.getAttribute('required') !== null) {
|
if(this.getAttribute('required') !== null) {
|
||||||
@ -420,8 +422,9 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
errors.push(`${this.#t('maxlength')} ${this.getAttribute('maxlength')}`);
|
errors.push(`${this.#t('maxlength')} ${this.getAttribute('maxlength')}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.getAttribute('filtertags')) {
|
const filterTags = this.getAttribute('filtertags');
|
||||||
const disallowTags = this.getAttribute('filtertags').split(',');
|
if(filterTags !== null) {
|
||||||
|
const disallowTags = filterTags.split(',') || [];
|
||||||
for (let i = 0; i < disallowTags.length; i++) {
|
for (let i = 0; i < disallowTags.length; i++) {
|
||||||
const checkTag = disallowTags[i];
|
const checkTag = disallowTags[i];
|
||||||
if(this.EditorNode.querySelector(checkTag)) {
|
if(this.EditorNode.querySelector(checkTag)) {
|
||||||
@ -434,7 +437,7 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
this.EditorNode.classList.toggle('-invalid', hasErros);
|
this.EditorNode.classList.toggle('-invalid', hasErros);
|
||||||
let oldErrors = this.querySelector('.-errors');
|
let oldErrors = this.querySelector('.-errors');
|
||||||
if(oldErrors) {
|
if(oldErrors) {
|
||||||
oldErrors.parentElement.removeChild(oldErrors);
|
oldErrors.parentElement?.removeChild(oldErrors);
|
||||||
}
|
}
|
||||||
if(hasErros) {
|
if(hasErros) {
|
||||||
const errosEl = el('p', {
|
const errosEl = el('p', {
|
||||||
@ -457,7 +460,7 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
const Selecton = window.getSelection();
|
const Selecton = window.getSelection();
|
||||||
if(Selecton !== null && Selecton.anchorNode !== null) {
|
if(Selecton !== null && Selecton.anchorNode !== null) {
|
||||||
const SelectionParentEl = Selecton.anchorNode.parentElement as HTMLParagraphElement;
|
const SelectionParentEl = Selecton.anchorNode.parentElement as HTMLParagraphElement;
|
||||||
|
const AutoCompleteForm = this.EditorAutoCompleteForm as HTMLElement;
|
||||||
if(SelectionParentEl !== null &&
|
if(SelectionParentEl !== null &&
|
||||||
//if empty selection
|
//if empty selection
|
||||||
Selecton.toString() === '' &&
|
Selecton.toString() === '' &&
|
||||||
@ -470,9 +473,9 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
const parsedTagName = SelectionParentEl.innerText.replace('/', '');
|
const parsedTagName = SelectionParentEl.innerText.replace('/', '');
|
||||||
const filteredActions = this.EditorTags.filter(action => action.tag.toLocaleLowerCase().startsWith(parsedTagName.toLocaleLowerCase()));
|
const filteredActions = this.EditorTags.filter(action => action.tag.toLocaleLowerCase().startsWith(parsedTagName.toLocaleLowerCase()));
|
||||||
if(filteredActions.length > 0) {
|
if(filteredActions.length > 0) {
|
||||||
this.EditorAutoCompleteForm.innerHTML = '';
|
AutoCompleteForm.innerHTML = '';
|
||||||
filteredActions.forEach(action => {
|
filteredActions.forEach(action => {
|
||||||
this.EditorAutoCompleteForm.appendChild(el('button', {
|
AutoCompleteForm?.appendChild(el('button', {
|
||||||
classList: ['wc-wysiwyg_btn', `-${action.tag}`],
|
classList: ['wc-wysiwyg_btn', `-${action.tag}`],
|
||||||
attrs: {
|
attrs: {
|
||||||
'data-hint': this.#t(action.tag) || null,
|
'data-hint': this.#t(action.tag) || null,
|
||||||
@ -484,13 +487,13 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
SelectionParentEl.appendChild(this.EditorAutoCompleteForm);
|
SelectionParentEl.appendChild(AutoCompleteForm);
|
||||||
} else {
|
} else {
|
||||||
//clear form
|
//clear form
|
||||||
this.EditorAutoCompleteForm.innerHTML = '';
|
AutoCompleteForm.innerHTML = '';
|
||||||
//if exist in DOM detach
|
//if exist in DOM detach
|
||||||
if(this.EditorAutoCompleteForm.parentElement) {
|
if(AutoCompleteForm.parentElement) {
|
||||||
this.EditorAutoCompleteForm.parentElement.removeChild(this.EditorAutoCompleteForm);
|
AutoCompleteForm.parentElement.removeChild(AutoCompleteForm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -532,7 +535,7 @@ class WCWYSIWYG extends HTMLElement {
|
|||||||
this.showEditorInlineDialog();
|
this.showEditorInlineDialog();
|
||||||
} else {
|
} else {
|
||||||
this.EditorClearFormatBtn.style.display = 'none';
|
this.EditorClearFormatBtn.style.display = 'none';
|
||||||
this.EditorClearFormatBtn.onpointerup = undefined;
|
this.EditorClearFormatBtn.onpointerup = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user