kempo-ui 0.0.43 → 0.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/copilot-instructions.md +11 -0
- package/.github/workflows/publish.yml +66 -0
- package/CONTRIBUTING.md +70 -0
- package/dist/components/Dialog.js +9 -8
- package/dist/components/HtmlEditor.js +91 -0
- package/dist/components/Icon.js +2 -2
- package/dist/components/Main.js +5 -9
- package/dist/components/ShadowComponent.js +1 -1
- package/dist/components/SideMenu.js +1 -1
- package/dist/components/SidePanel.js +46 -35
- package/dist/components/htmlEditorControls/AlignCenter.js +12 -0
- package/dist/components/htmlEditorControls/AlignJustify.js +12 -0
- package/dist/components/htmlEditorControls/AlignLeft.js +12 -0
- package/dist/components/htmlEditorControls/AlignRight.js +12 -0
- package/dist/components/htmlEditorControls/Bold.js +12 -0
- package/dist/components/htmlEditorControls/BulletList.js +12 -0
- package/dist/components/htmlEditorControls/CharacterCount.js +18 -0
- package/dist/components/htmlEditorControls/ClearFormatting.js +12 -0
- package/dist/components/htmlEditorControls/CodeBlock.js +12 -0
- package/dist/components/htmlEditorControls/ControlGroup.js +14 -0
- package/dist/components/htmlEditorControls/ControlSpacer.js +6 -0
- package/dist/components/htmlEditorControls/CreateLink.js +15 -0
- package/dist/components/htmlEditorControls/DropdownControl.js +57 -0
- package/dist/components/htmlEditorControls/FormatBlock.js +12 -0
- package/dist/components/htmlEditorControls/HtmlEditorControl.js +44 -0
- package/dist/components/htmlEditorControls/InlineCode.js +12 -0
- package/dist/components/htmlEditorControls/InsertTable.js +15 -0
- package/dist/components/htmlEditorControls/Italic.js +12 -0
- package/dist/components/htmlEditorControls/Mode.js +9 -0
- package/dist/components/htmlEditorControls/NumberList.js +12 -0
- package/dist/components/htmlEditorControls/Strikethrough.js +12 -0
- package/dist/components/htmlEditorControls/TextBackgroundColor.js +97 -0
- package/dist/components/htmlEditorControls/TextColor.js +97 -0
- package/dist/components/htmlEditorControls/Underline.js +12 -0
- package/dist/components/htmlEditorControls/WordCount.js +18 -0
- package/dist/utils/formatCode.js +1 -0
- package/docs/components/dropdown.html +2 -2
- package/docs/components/html-editor.html +442 -0
- package/docs/components/icon.html +2 -7
- package/docs/components/photo-viewer.html +14 -14
- package/docs/components/side-menu.html +32 -0
- package/docs/components/side-panel-dual.html +70 -0
- package/docs/components/side-panel-scroll.html +176 -0
- package/docs/components/side-panel.html +41 -1
- package/docs/icons/arrow_drop_down.svg +1 -0
- package/docs/icons/circle.svg +1 -0
- package/docs/icons/code.svg +1 -0
- package/docs/icons/code_blocks.svg +1 -0
- package/docs/icons/copy.svg +1 -0
- package/docs/icons/dot.svg +1 -0
- package/docs/icons/format_align_center.svg +1 -0
- package/docs/icons/format_align_justify.svg +1 -0
- package/docs/icons/format_align_left.svg +1 -0
- package/docs/icons/format_align_right.svg +1 -0
- package/docs/icons/format_bold.svg +1 -0
- package/docs/icons/format_clear.svg +1 -0
- package/docs/icons/format_color_fill.svg +1 -0
- package/docs/icons/format_color_text.svg +1 -0
- package/docs/icons/format_h1.svg +1 -0
- package/docs/icons/format_h2.svg +1 -0
- package/docs/icons/format_h3.svg +1 -0
- package/docs/icons/format_h4.svg +1 -0
- package/docs/icons/format_h5.svg +1 -0
- package/docs/icons/format_h6.svg +1 -0
- package/docs/icons/format_italic.svg +1 -0
- package/docs/icons/format_list_bulleted.svg +1 -0
- package/docs/icons/format_list_numbered.svg +1 -0
- package/docs/icons/format_paragraph.svg +1 -0
- package/docs/icons/format_underlined.svg +1 -0
- package/docs/icons/help.svg +1 -0
- package/docs/icons/link.svg +1 -0
- package/docs/icons/more_vert.svg +1 -0
- package/docs/icons/strikethrough_s.svg +1 -0
- package/docs/icons/table.svg +1 -0
- package/docs/icons/wysiwyg.svg +1 -0
- package/docs/index.html +6 -0
- package/docs/nav-1.inc.html +1 -0
- package/docs/nav.inc.html +1 -0
- package/docs/src/components/Dialog.js +9 -8
- package/docs/src/components/HtmlEditor.js +91 -0
- package/docs/src/components/Icon.js +2 -2
- package/docs/src/components/Main.js +5 -9
- package/docs/src/components/ShadowComponent.js +1 -1
- package/docs/src/components/SideMenu.js +1 -1
- package/docs/src/components/SidePanel.js +46 -35
- package/docs/src/components/htmlEditorControls/AlignCenter.js +12 -0
- package/docs/src/components/htmlEditorControls/AlignJustify.js +12 -0
- package/docs/src/components/htmlEditorControls/AlignLeft.js +12 -0
- package/docs/src/components/htmlEditorControls/AlignRight.js +12 -0
- package/docs/src/components/htmlEditorControls/Bold.js +12 -0
- package/docs/src/components/htmlEditorControls/BulletList.js +12 -0
- package/docs/src/components/htmlEditorControls/CharacterCount.js +18 -0
- package/docs/src/components/htmlEditorControls/ClearFormatting.js +12 -0
- package/docs/src/components/htmlEditorControls/CodeBlock.js +12 -0
- package/docs/src/components/htmlEditorControls/ControlGroup.js +14 -0
- package/docs/src/components/htmlEditorControls/ControlSpacer.js +6 -0
- package/docs/src/components/htmlEditorControls/CreateLink.js +15 -0
- package/docs/src/components/htmlEditorControls/DropdownControl.js +57 -0
- package/docs/src/components/htmlEditorControls/FormatBlock.js +12 -0
- package/docs/src/components/htmlEditorControls/HtmlEditorControl.js +44 -0
- package/docs/src/components/htmlEditorControls/InlineCode.js +12 -0
- package/docs/src/components/htmlEditorControls/InsertTable.js +15 -0
- package/docs/src/components/htmlEditorControls/Italic.js +12 -0
- package/docs/src/components/htmlEditorControls/Mode.js +9 -0
- package/docs/src/components/htmlEditorControls/NumberList.js +12 -0
- package/docs/src/components/htmlEditorControls/Strikethrough.js +12 -0
- package/docs/src/components/htmlEditorControls/TextBackgroundColor.js +97 -0
- package/docs/src/components/htmlEditorControls/TextColor.js +97 -0
- package/docs/src/components/htmlEditorControls/Underline.js +12 -0
- package/docs/src/components/htmlEditorControls/WordCount.js +18 -0
- package/docs/src/utils/formatCode.js +1 -0
- package/icons/arrow_drop_down.svg +1 -0
- package/icons/circle.svg +1 -0
- package/icons/code.svg +1 -0
- package/icons/code_blocks.svg +1 -0
- package/icons/copy.svg +1 -0
- package/icons/dot.svg +1 -0
- package/icons/format_align_center.svg +1 -0
- package/icons/format_align_justify.svg +1 -0
- package/icons/format_align_left.svg +1 -0
- package/icons/format_align_right.svg +1 -0
- package/icons/format_bold.svg +1 -0
- package/icons/format_clear.svg +1 -0
- package/icons/format_color_fill.svg +1 -0
- package/icons/format_color_text.svg +1 -0
- package/icons/format_h1.svg +1 -0
- package/icons/format_h2.svg +1 -0
- package/icons/format_h3.svg +1 -0
- package/icons/format_h4.svg +1 -0
- package/icons/format_h5.svg +1 -0
- package/icons/format_h6.svg +1 -0
- package/icons/format_italic.svg +1 -0
- package/icons/format_list_bulleted.svg +1 -0
- package/icons/format_list_numbered.svg +1 -0
- package/icons/format_paragraph.svg +1 -0
- package/icons/format_underlined.svg +1 -0
- package/icons/help.svg +1 -0
- package/icons/link.svg +1 -0
- package/icons/more_vert.svg +1 -0
- package/icons/strikethrough_s.svg +1 -0
- package/icons/table.svg +1 -0
- package/icons/wysiwyg.svg +1 -0
- package/package.json +6 -5
- package/scripts/getIcon.js +52 -0
- package/src/components/Dialog.js +25 -10
- package/src/components/HtmlEditor.js +1548 -0
- package/src/components/Icon.js +6 -3
- package/src/components/Main.js +22 -23
- package/src/components/ShadowComponent.js +0 -1
- package/src/components/SideMenu.js +10 -0
- package/src/components/SidePanel.js +78 -37
- package/src/components/htmlEditorControls/AlignCenter.js +65 -0
- package/src/components/htmlEditorControls/AlignJustify.js +65 -0
- package/src/components/htmlEditorControls/AlignLeft.js +65 -0
- package/src/components/htmlEditorControls/AlignRight.js +65 -0
- package/src/components/htmlEditorControls/Bold.js +65 -0
- package/src/components/htmlEditorControls/BulletList.js +65 -0
- package/src/components/htmlEditorControls/CharacterCount.js +75 -0
- package/src/components/htmlEditorControls/ClearFormatting.js +65 -0
- package/src/components/htmlEditorControls/CodeBlock.js +72 -0
- package/src/components/htmlEditorControls/ControlGroup.js +95 -0
- package/src/components/htmlEditorControls/ControlSpacer.js +23 -0
- package/src/components/htmlEditorControls/CreateLink.js +121 -0
- package/src/components/htmlEditorControls/DropdownControl.js +149 -0
- package/src/components/htmlEditorControls/FormatBlock.js +108 -0
- package/src/components/htmlEditorControls/HtmlEditorControl.js +126 -0
- package/src/components/htmlEditorControls/InlineCode.js +77 -0
- package/src/components/htmlEditorControls/InsertTable.js +171 -0
- package/src/components/htmlEditorControls/Italic.js +65 -0
- package/src/components/htmlEditorControls/Mode.js +66 -0
- package/src/components/htmlEditorControls/NumberList.js +65 -0
- package/src/components/htmlEditorControls/Strikethrough.js +65 -0
- package/src/components/htmlEditorControls/TextBackgroundColor.js +195 -0
- package/src/components/htmlEditorControls/TextColor.js +195 -0
- package/src/components/htmlEditorControls/Underline.js +65 -0
- package/src/components/htmlEditorControls/WordCount.js +76 -0
- package/src/utils/formatCode.js +87 -0
- package/tests/components/Main.browser-test.js +166 -105
- package/tests/components/SidePanel.browser-test.js +62 -8
- package/.github/workflows/publish-major.yml +0 -39
- package/.github/workflows/publish-minor.yml +0 -39
- package/.github/workflows/publish-patch.yml +0 -45
- package/docs/icons/arrow-back.svg +0 -1
- package/docs/icons/arrow-down-double.svg +0 -1
- package/docs/icons/arrow-down.svg +0 -1
- package/docs/icons/arrow-forward.svg +0 -1
- package/docs/icons/arrow-menu-close.svg +0 -1
- package/docs/icons/arrow-menu-open.svg +0 -1
- package/docs/icons/arrow-right.svg +0 -1
- package/docs/icons/arrow-up-double.svg +0 -1
- package/docs/icons/arrow-up.svg +0 -1
- package/docs/icons/chevron-left.svg +0 -1
- package/docs/icons/chevron-right.svg +0 -1
- package/docs/icons/chevron-up.svg +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class AlignLeft extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.alignLeft()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_align_left"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-align-left",AlignLeft);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class AlignRight extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.alignRight()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_align_right"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-align-right",AlignRight);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class Bold extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.bold()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_bold"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-bold",Bold);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class BulletList extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.unorderedList()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_list_bulleted"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-bullet-list",BulletList);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";export default class CharacterCount extends HtmlEditorControl{static properties={count:{type:Number,state:!0}};constructor(){super(),this.count=0}connectedCallback(){super.connectedCallback(),this.editor&&(this.editor.addEventListener("ready",()=>{this.updateCount()}),this.editor.addEventListener("change",()=>{this.updateCount()}),setTimeout(()=>this.updateCount(),0))}updateCount=()=>{if(!this.editor)return;const t=(new DOMParser).parseFromString(this.editor.getValue(),"text/html").body.innerText||"";this.count=t.length};render(){return html`
|
|
2
|
+
<span class="character-count">
|
|
3
|
+
<slot name="label">Characters:</slot> ${this.count}
|
|
4
|
+
</span>
|
|
5
|
+
`}static styles=[HtmlEditorControl.styles,css`
|
|
6
|
+
:host {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
padding: 0 0.5rem;
|
|
10
|
+
font-size: 0.875rem;
|
|
11
|
+
color: var(--text-color-secondary, #666);
|
|
12
|
+
}
|
|
13
|
+
.character-count {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 0.25rem;
|
|
17
|
+
}
|
|
18
|
+
`]}customElements.define("k-hec-character-count",CharacterCount);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class ClearFormatting extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.removeFormat()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_clear"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-clear-formatting",ClearFormatting);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class CodeBlock extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleMouseDown=t=>{const o=window.getSelection()?.toString();t.preventDefault(),t.stopPropagation(),this.editor&&(o?this.editor.wrapSelection("<pre>","</pre>",o):this.editor.formatBlock("pre"))};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @mousedown="${this.handleMouseDown}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="code_blocks"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-code-block",CodeBlock);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import ShadowComponent from"../ShadowComponent.js";import{html,css}from"../../lit-all.min.js";export default class ControlGroup extends ShadowComponent{static properties={editorMode:{type:String,state:!0},hidden:{type:Boolean,reflect:!0}};constructor(){super()}connectedCallback(){super.connectedCallback(),this.hasAttribute("class")||this.setAttribute("class","b r mq"),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}get editor(){return this.closest("k-html-editor")}updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode,this.requestUpdate())}hasVisibleChildren(){return Array.from(this.children).filter(t=>t.tagName.startsWith("K-HEC-")&&"K-HEC-SPACER"!==t.tagName).some(t=>{if(!1===t.hidden||void 0===t.hidden){return"none"!==window.getComputedStyle(t).display}return!1})}static styles=css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:host([hidden]) {
|
|
7
|
+
display: none !important;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
::slotted(*) {
|
|
11
|
+
margin-top: -1px;
|
|
12
|
+
margin-bottom: -1px;
|
|
13
|
+
}
|
|
14
|
+
`;render(){return html`<slot></slot>`}updated(){super.updated(),requestAnimationFrame(()=>{this.hidden=!this.hasVisibleChildren()})}}customElements.define("k-hec-group",ControlGroup);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ShadowComponent from"../ShadowComponent.js";import{html,css}from"../../lit-all.min.js";export default class ControlSpacer extends ShadowComponent{static styles=css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
flex: 1;
|
|
5
|
+
}
|
|
6
|
+
`;render(){return html``}}customElements.define("k-hec-spacer",ControlSpacer);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";import Dialog from"../Dialog.js";export default class CreateLink extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};constructor(){super()}connectedCallback(){super.connectedCallback(),this.editor&&(this.editorMode=this.editor.mode,this.editor?.addEventListener("mode-changed",()=>{this.editor&&(this.editorMode=this.editor.mode)}))}handleMouseDown=t=>{if(!this.editor)return;t.preventDefault(),t.stopPropagation();const e=this.editor.selection?.text||"",o=document.createElement("input");o.type="text",o.placeholder="https://example.com",o.style.cssText="padding: 0.5rem; border: 1px solid var(--border-color, #ccc); border-radius: 4px; font-size: 1rem;";const i=document.createElement("input");i.type="text",i.placeholder="Enter link text",i.value=e,i.style.cssText="padding: 0.5rem; border: 1px solid var(--border-color, #ccc); border-radius: 4px; font-size: 1rem;";const n=document.createElement("div");n.className="p",n.style.cssText="display: flex; flex-direction: column; gap: 1rem;",n.innerHTML='\n\t\t\t<div style="display: flex; flex-direction: column; gap: 0.5rem;">\n\t\t\t\t<label style="font-weight: bold;">URL</label>\n\t\t\t</div>\n\t\t\t<div style="display: flex; flex-direction: column; gap: 0.5rem;">\n\t\t\t\t<label style="font-weight: bold;">Link Text</label>\n\t\t\t</div>\n\t\t',n.children[0].appendChild(o),n.children[1].appendChild(i),Dialog.create(n,{title:"Create Link",cancelText:"Cancel",confirmText:"Insert Link",confirmClasses:"success ml",confirmAction:t=>{const e=o.value.trim(),n=i.value.trim();if(!e)return void(t.keepDialogOpen=!0);const l=document.createElement("a");l.href=e,l.textContent=n||e,this.editor.selection?this.editor.replaceSelectionWithElement(l,!0):this.editor.insertElementAtCursor(l,!0)}})};render(){return this.hidden="code"===this.editorMode,html`
|
|
2
|
+
<button
|
|
3
|
+
class="${this.buttonClasses}"
|
|
4
|
+
@mousedown="${this.handleMouseDown}"
|
|
5
|
+
>
|
|
6
|
+
<slot name="icon">
|
|
7
|
+
<k-icon name="link"></k-icon>
|
|
8
|
+
</slot>
|
|
9
|
+
<slot></slot>
|
|
10
|
+
</button>
|
|
11
|
+
`}static styles=[HtmlEditorControl.styles,css`
|
|
12
|
+
:host {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
}
|
|
15
|
+
`]}customElements.define("k-hec-create-link",CreateLink);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Dropdown.js";import"../Icon.js";export default class DropdownControl extends HtmlEditorControl{static properties={opened:{type:Boolean,reflect:!0},editorMode:{type:String,state:!0}};constructor(){super(),this.opened=!1}connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}updated(t){super.updated(t),t.has("editorMode")&&requestAnimationFrame(()=>{this.hidden="code"===this.editorMode&&!this.hasVisibleChildren()})}updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}hasVisibleChildren(){return Array.from(this.children).filter(t=>!t.hasAttribute("slot")).some(t=>{if(!1===t.hidden||void 0===t.hidden){return"none"!==window.getComputedStyle(t).display}return!1})}static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
k-dropdown {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* Override fixed sizing for dropdown trigger */
|
|
11
|
+
button[slot="trigger"] {
|
|
12
|
+
width: auto !important;
|
|
13
|
+
height: auto !important;
|
|
14
|
+
min-width: 40px;
|
|
15
|
+
min-height: 40px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Style slotted items (not icon or label) */
|
|
19
|
+
::slotted(:not([slot="icon"]):not([slot="label"])) {
|
|
20
|
+
display: block !important;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
::slotted(:not([slot="icon"]):not([slot="label"])) .icon-btn,
|
|
24
|
+
::slotted(:not([slot="icon"]):not([slot="label"])) button {
|
|
25
|
+
display: flex !important;
|
|
26
|
+
width: 100% !important;
|
|
27
|
+
height: auto !important;
|
|
28
|
+
justify-content: flex-start !important;
|
|
29
|
+
padding: 0.5rem 0.75rem !important;
|
|
30
|
+
margin: 0 !important;
|
|
31
|
+
border: none !important;
|
|
32
|
+
border-radius: 0 !important;
|
|
33
|
+
border-bottom: 1px solid var(--c_border) !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
::slotted(:not([slot="icon"]):not([slot="label"]):last-of-type) .icon-btn,
|
|
37
|
+
::slotted(:not([slot="icon"]):not([slot="label"]):last-of-type) button {
|
|
38
|
+
border-bottom: none !important;
|
|
39
|
+
}
|
|
40
|
+
`];handleToggle=()=>{this.opened=!this.opened};handleOpened=()=>{this.opened=!0};handleClosed=()=>{this.opened=!1};render(){return html`
|
|
41
|
+
<k-dropdown
|
|
42
|
+
?opened=${this.opened}
|
|
43
|
+
@opened=${this.handleOpened}
|
|
44
|
+
@closed=${this.handleClosed}
|
|
45
|
+
>
|
|
46
|
+
<button
|
|
47
|
+
slot="trigger"
|
|
48
|
+
class="${this.buttonClasses}"
|
|
49
|
+
>
|
|
50
|
+
<slot name="icon">
|
|
51
|
+
<k-icon name="arrow_drop_down"></k-icon>
|
|
52
|
+
</slot>
|
|
53
|
+
<slot name="label"></slot>
|
|
54
|
+
</button>
|
|
55
|
+
<slot></slot>
|
|
56
|
+
</k-dropdown>
|
|
57
|
+
`}}customElements.define("k-hec-dropdown",DropdownControl);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class FormatBlock extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0},tag:{type:String},label:{type:String}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];constructor(){super(),this.tag="p",this.label=""}connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.formatBlock(this.tag)};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){this.hidden="code"===this.editorMode;this.label||this.getDefaultLabel();const t=this.getDefaultIcon();return html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="${t}"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}getDefaultLabel(){return{h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",p:"Paragraph"}[this.tag]||this.tag.toUpperCase()}getDefaultIcon(){return{h1:"format_h1",h2:"format_h2",h3:"format_h3",h4:"format_h4",h5:"format_h5",h6:"format_h6",p:"format_paragraph"}[this.tag]||"format_paragraph"}}customElements.define("k-hec-format-block",FormatBlock);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import ShadowComponent from"../ShadowComponent.js";import{html,css}from"../../lit-all.min.js";export default class HtmlEditorControl extends ShadowComponent{static properties={btnClass:{type:String,attribute:"btn-class"},groupBtnClass:{type:String,attribute:"group-btn-class"},groupLastBtnClass:{type:String,attribute:"group-last-btn-class"},hidden:{type:Boolean,reflect:!0}};constructor(){super(),this.btnClass="b r mq ph",this.groupBtnClass="br ph",this.groupLastBtnClass="ph"}get editor(){let t=this.getRootNode();for(;t instanceof ShadowRoot;){const o=t.host,n=o.closest("k-html-editor");if(n)return n;t=o.getRootNode()}return this.closest("k-html-editor")}get isInGroup(){const t=this.parentElement;return t&&"K-HEC-GROUP"===t.tagName}get isInDropdown(){const t=this.parentElement;return t&&"K-HEC-DROPDOWN"===t.tagName}get isLastInGroup(){if(!this.isInGroup)return!1;const t=this.parentElement,o=Array.from(t.children).filter(t=>t.tagName.startsWith("K-HEC-")&&"K-HEC-SPACER"!==t.tagName);return o[o.length-1]===this}get buttonClasses(){let t;return t=this.isInDropdown?"dropdown-item":this.isInGroup?this.isLastInGroup?this.groupLastBtnClass:this.groupBtnClass:this.btnClass,`no-btn icon-btn ${t}`.trim()}static styles=css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:host([hidden]) {
|
|
7
|
+
display: none !important;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.icon-btn {
|
|
11
|
+
display: inline-flex !important;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
width: 40px;
|
|
15
|
+
height: 40px;
|
|
16
|
+
gap: 0.5rem;
|
|
17
|
+
}
|
|
18
|
+
.icon-btn:disabled {
|
|
19
|
+
opacity: 0.6;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.icon-btn:has(slot:not([name])) {
|
|
23
|
+
width: auto;
|
|
24
|
+
padding-left: 0.75rem;
|
|
25
|
+
padding-right: 0.75rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Styles for controls in dropdown */
|
|
29
|
+
.icon-btn.dropdown-item {
|
|
30
|
+
display: flex !important;
|
|
31
|
+
width: 100% !important;
|
|
32
|
+
height: auto !important;
|
|
33
|
+
justify-content: flex-start !important;
|
|
34
|
+
padding: 0.5rem 0.75rem !important;
|
|
35
|
+
margin: 0 !important;
|
|
36
|
+
border: none !important;
|
|
37
|
+
border-radius: 0 !important;
|
|
38
|
+
border-bottom: 1px solid var(--c_border) !important;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:host(:last-child) .icon-btn.dropdown-item {
|
|
42
|
+
border-bottom: none !important;
|
|
43
|
+
}
|
|
44
|
+
`}customElements.define("k-html-editor-control",HtmlEditorControl);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class InlineCode extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleMouseDown=t=>{if(!this.editor)return;t.preventDefault(),t.stopPropagation();const e=document.createElement("code"),o=this.editor.getValueWithSelectionMarkers();o.hasSelection?(e.textContent=o.selectedText,this.editor.replaceSelectionWithElement(e,!0)):(e.textContent="",this.editor.insertElementAtCursor(e,!0))};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @mousedown="${this.handleMouseDown}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="code_blocks"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-inline-code",InlineCode);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";import Dialog from"../Dialog.js";export default class InsertTable extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};constructor(){super()}connectedCallback(){super.connectedCallback(),this.editor&&(this.editorMode=this.editor.mode,this.editor?.addEventListener("mode-changed",()=>{this.editor&&(this.editorMode=this.editor.mode)}))}handleMouseDown=e=>{if(!this.editor)return;e.preventDefault(),e.stopPropagation();const t=this.editor.shadowRoot.getSelection()||window.getSelection();let o=null,l=null;if(t.rangeCount){let e=t.getRangeAt(0).startContainer;e.nodeType===Node.TEXT_NODE&&(e=e.parentElement),o=e.closest("table")}const n=!!o;let r=3,s=3,i=!0;if(n){const e=o.querySelector("thead"),t=o.querySelector("tbody"),n=!!e;if(l=[],n){const t=e.querySelector("tr"),o=Array.from(t.cells).map(e=>e.innerHTML);l.push(o),s=o.length}const d=t.querySelectorAll("tr");d.forEach(e=>{const t=Array.from(e.cells).map(e=>e.innerHTML);l.push(t),t.length>s&&(s=t.length)}),r=d.length,i=n,o.remove()}const d=document.createElement("input");d.type="number",d.min="1",d.max="20",d.value=r.toString(),d.style.cssText="padding: 0.5rem; border: 1px solid var(--border-color, #ccc); border-radius: 4px; font-size: 1rem;";const c=document.createElement("input");c.type="number",c.min="1",c.max="10",c.value=s.toString(),c.style.cssText="padding: 0.5rem; border: 1px solid var(--border-color, #ccc); border-radius: 4px; font-size: 1rem;";const a=document.createElement("input");a.type="checkbox",a.checked=i,a.id="table-headers-checkbox";const m=document.createElement("div");m.className="p",m.style.cssText="display: flex; flex-direction: column; gap: 1rem;",m.innerHTML='\n\t\t\t<div style="display: flex; flex-direction: column; gap: 0.5rem;">\n\t\t\t\t<label style="font-weight: bold;">Rows</label>\n\t\t\t</div>\n\t\t\t<div style="display: flex; flex-direction: column; gap: 0.5rem;">\n\t\t\t\t<label style="font-weight: bold;">Columns</label>\n\t\t\t</div>\n\t\t\t<div style="display: flex; align-items: center; gap: 0.5rem;">\n\t\t\t\t<label for="table-headers-checkbox" style="font-weight: bold;">Include Headers</label>\n\t\t\t</div>\n\t\t',m.children[0].appendChild(d),m.children[1].appendChild(c),m.children[2].insertBefore(a,m.children[2].firstChild),Dialog.create(m,{title:n?"Edit Table":"Insert Table",cancelText:"Cancel",confirmText:n?"Update Table":"Insert Table",confirmClasses:"success",confirmAction:()=>{const e=parseInt(d.value)||3,t=parseInt(c.value)||3,o=a.checked;this.editor.insertTable(e,t,o,l)}})};render(){return this.hidden="code"===this.editorMode,html`
|
|
2
|
+
<button
|
|
3
|
+
class="${this.buttonClasses}"
|
|
4
|
+
@mousedown="${this.handleMouseDown}"
|
|
5
|
+
>
|
|
6
|
+
<slot name="icon">
|
|
7
|
+
<k-icon name="table"></k-icon>
|
|
8
|
+
</slot>
|
|
9
|
+
<slot></slot>
|
|
10
|
+
</button>
|
|
11
|
+
`}static styles=[HtmlEditorControl.styles,css`
|
|
12
|
+
:host {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
}
|
|
15
|
+
`]}customElements.define("k-hec-insert-table",InsertTable);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class Italic extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.italic()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_italic"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-italic",Italic);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class Mode extends HtmlEditorControl{static properties={mode:{type:String,reflect:!0}};connectedCallback(){super.connectedCallback(),this.updateMode(),this.editor?.addEventListener("mode-changed",()=>this.updateMode())}handleClick=()=>{this.editor&&(this.editor.mode="visual"===this.editor.mode?"code":"visual")};updateMode(){this.editor&&(this.mode=this.editor.mode)}static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];render(){const t="code"===this.mode?`${this.buttonClasses} bg-primary`:this.buttonClasses;return html`
|
|
6
|
+
<button class="${t}" @click="${this.handleClick}">
|
|
7
|
+
<k-icon name="code"></k-icon>
|
|
8
|
+
</button>
|
|
9
|
+
`}}customElements.define("k-hec-mode",Mode);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class NumberList extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.orderedList()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_list_numbered"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-number-list",NumberList);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class Strikethrough extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.strikethrough()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="strikethrough_s"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-strikethrough",Strikethrough);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import DropdownControl from"./DropdownControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class TextBackgroundColor extends DropdownControl{static properties={editorMode:{type:String,state:!0},colors:{type:String},disableRemove:{type:Boolean,attribute:"disable-remove"},disablePicker:{type:Boolean,attribute:"disable-picker"}};static styles=[DropdownControl.styles,css`
|
|
2
|
+
.dropdown-content {
|
|
3
|
+
padding: 8px;
|
|
4
|
+
min-width: 200px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.remove-btn {
|
|
8
|
+
width: 100%;
|
|
9
|
+
padding: 8px;
|
|
10
|
+
margin-bottom: 8px;
|
|
11
|
+
border: 1px solid var(--border-color, #ccc);
|
|
12
|
+
background: var(--background-color, white);
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
border-radius: 4px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.remove-btn:hover {
|
|
18
|
+
background: var(--hover-background-color, #f5f5f5);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.color-swatches {
|
|
22
|
+
display: grid;
|
|
23
|
+
grid-template-columns: repeat(6, 1fr);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.color-swatch {
|
|
27
|
+
width: 32px;
|
|
28
|
+
height: 32px;
|
|
29
|
+
border: 1px solid var(--border-color, #ccc);
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
border-radius: 4px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.color-swatch:hover {
|
|
35
|
+
border-color: var(--primary-color, #007acc);
|
|
36
|
+
box-shadow: 0 0 4px rgba(0, 122, 204, 0.3);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.picker-row {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
gap: 8px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.picker-row label {
|
|
46
|
+
flex-shrink: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.picker-row input[type="color"] {
|
|
50
|
+
flex: 1;
|
|
51
|
+
height: 32px;
|
|
52
|
+
border: 1px solid var(--border-color, #ccc);
|
|
53
|
+
border-radius: 4px;
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
}
|
|
56
|
+
`];constructor(){super(),this.colors="#ffff00,#00ffff,#ff66ff,#99ff99,#ffcc99,#ff9999,#cccccc,#ffffff,#ffffcc,#ccffff,#ffccff,#ccffcc",this.disableRemove=!1,this.disablePicker=!1,this.icon="format_color_fill"}connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleRemove=o=>{o.preventDefault(),o.stopPropagation(),this.editor&&this.editor.removeTextBackgroundColor(),this.opened=!1};handleSwatchClick=o=>{o.preventDefault(),o.stopPropagation();const e=o.target.style.backgroundColor;if(this.editor&&e){const o=e.match(/\d+/g),t=o?"#"+o.map(o=>parseInt(o).toString(16).padStart(2,"0")).join(""):e;this.editor.setTextBackgroundColor(t)}this.opened=!1};handlePickerChange=o=>{o.preventDefault(),o.stopPropagation();const e=o.target.value;this.editor&&e&&this.editor.setTextBackgroundColor(e),this.opened=!1};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}getColorArray(){return this.colors.split(",").map(o=>o.trim()).filter(o=>o)}render(){this.hidden="code"===this.editorMode;const o=this.getColorArray();return html`
|
|
57
|
+
<k-dropdown
|
|
58
|
+
?opened=${this.opened}
|
|
59
|
+
@opened=${this.handleOpened}
|
|
60
|
+
@closed=${this.handleClosed}
|
|
61
|
+
>
|
|
62
|
+
<button
|
|
63
|
+
slot="trigger"
|
|
64
|
+
class="${this.buttonClasses}"
|
|
65
|
+
>
|
|
66
|
+
<k-icon name="format_color_fill"></k-icon>
|
|
67
|
+
</button>
|
|
68
|
+
|
|
69
|
+
<div class="dropdown-content">
|
|
70
|
+
${this.disableRemove?"":html`
|
|
71
|
+
<button class="remove-btn" @click=${this.handleRemove}>
|
|
72
|
+
Remove Color
|
|
73
|
+
</button>
|
|
74
|
+
`}
|
|
75
|
+
|
|
76
|
+
<div class="color-swatches">
|
|
77
|
+
${o.map(o=>html`
|
|
78
|
+
<button
|
|
79
|
+
class="color-swatch"
|
|
80
|
+
style="background-color: ${o}"
|
|
81
|
+
@click=${this.handleSwatchClick}
|
|
82
|
+
></button>
|
|
83
|
+
`)}
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
${this.disablePicker?"":html`
|
|
87
|
+
<div class="picker-row">
|
|
88
|
+
<label>Custom:</label>
|
|
89
|
+
<input
|
|
90
|
+
type="color"
|
|
91
|
+
@input=${this.handlePickerChange}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
`}
|
|
95
|
+
</div>
|
|
96
|
+
</k-dropdown>
|
|
97
|
+
`}}customElements.define("k-hec-text-background-color",TextBackgroundColor);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import DropdownControl from"./DropdownControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class TextColor extends DropdownControl{static properties={editorMode:{type:String,state:!0},colors:{type:String},disableRemove:{type:Boolean,attribute:"disable-remove"},disablePicker:{type:Boolean,attribute:"disable-picker"}};static styles=[DropdownControl.styles,css`
|
|
2
|
+
.dropdown-content {
|
|
3
|
+
padding: 8px;
|
|
4
|
+
min-width: 200px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.remove-btn {
|
|
8
|
+
width: 100%;
|
|
9
|
+
padding: 8px;
|
|
10
|
+
margin-bottom: 8px;
|
|
11
|
+
border: 1px solid var(--border-color, #ccc);
|
|
12
|
+
background: var(--background-color, white);
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
border-radius: 4px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.remove-btn:hover {
|
|
18
|
+
background: var(--hover-background-color, #f5f5f5);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.color-swatches {
|
|
22
|
+
display: grid;
|
|
23
|
+
grid-template-columns: repeat(6, 1fr);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.color-swatch {
|
|
27
|
+
width: 32px;
|
|
28
|
+
height: 32px;
|
|
29
|
+
border: 1px solid var(--border-color, #ccc);
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
border-radius: 4px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.color-swatch:hover {
|
|
35
|
+
border-color: var(--primary-color, #007acc);
|
|
36
|
+
box-shadow: 0 0 4px rgba(0, 122, 204, 0.3);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.picker-row {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
gap: 8px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.picker-row label {
|
|
46
|
+
flex-shrink: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.picker-row input[type="color"] {
|
|
50
|
+
flex: 1;
|
|
51
|
+
height: 32px;
|
|
52
|
+
border: 1px solid var(--border-color, #ccc);
|
|
53
|
+
border-radius: 4px;
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
}
|
|
56
|
+
`];constructor(){super(),this.colors="#000000,#e60000,#ff9900,#ffff00,#008a00,#0066cc,#9933ff,#ffffff,#facccc,#ffebcc,#ffffcc,#cce8cc,#cce0f5,#ebd6ff",this.disableRemove=!1,this.disablePicker=!1,this.icon="format_color_text"}connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleRemove=o=>{o.preventDefault(),o.stopPropagation(),this.editor&&this.editor.removeTextColor(),this.opened=!1};handleSwatchClick=o=>{o.preventDefault(),o.stopPropagation();const e=o.target.style.backgroundColor;if(this.editor&&e){const o=e.match(/\d+/g),t=o?"#"+o.map(o=>parseInt(o).toString(16).padStart(2,"0")).join(""):e;this.editor.setTextColor(t)}this.opened=!1};handlePickerChange=o=>{o.preventDefault(),o.stopPropagation();const e=o.target.value;this.editor&&e&&this.editor.setTextColor(e),this.opened=!1};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}getColorArray(){return this.colors.split(",").map(o=>o.trim()).filter(o=>o)}render(){this.hidden="code"===this.editorMode;const o=this.getColorArray();return html`
|
|
57
|
+
<k-dropdown
|
|
58
|
+
?opened=${this.opened}
|
|
59
|
+
@opened=${this.handleOpened}
|
|
60
|
+
@closed=${this.handleClosed}
|
|
61
|
+
>
|
|
62
|
+
<button
|
|
63
|
+
slot="trigger"
|
|
64
|
+
class="${this.buttonClasses}"
|
|
65
|
+
>
|
|
66
|
+
<k-icon name="format_color_text"></k-icon>
|
|
67
|
+
</button>
|
|
68
|
+
|
|
69
|
+
<div class="dropdown-content">
|
|
70
|
+
${this.disableRemove?"":html`
|
|
71
|
+
<button class="remove-btn" @click=${this.handleRemove}>
|
|
72
|
+
Remove Color
|
|
73
|
+
</button>
|
|
74
|
+
`}
|
|
75
|
+
|
|
76
|
+
<div class="color-swatches">
|
|
77
|
+
${o.map(o=>html`
|
|
78
|
+
<button
|
|
79
|
+
class="color-swatch"
|
|
80
|
+
style="background-color: ${o}"
|
|
81
|
+
@click=${this.handleSwatchClick}
|
|
82
|
+
></button>
|
|
83
|
+
`)}
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
${this.disablePicker?"":html`
|
|
87
|
+
<div class="picker-row">
|
|
88
|
+
<label>Custom:</label>
|
|
89
|
+
<input
|
|
90
|
+
type="color"
|
|
91
|
+
@input=${this.handlePickerChange}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
`}
|
|
95
|
+
</div>
|
|
96
|
+
</k-dropdown>
|
|
97
|
+
`}}customElements.define("k-hec-text-color",TextColor);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class Underline extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.underline()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_underlined"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-underline",Underline);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";export default class WordCount extends HtmlEditorControl{static properties={count:{type:Number,state:!0}};constructor(){super(),this.count=0}connectedCallback(){super.connectedCallback(),this.editor&&(this.editor.addEventListener("ready",()=>{this.updateCount()}),this.editor.addEventListener("change",()=>{this.updateCount()}),setTimeout(()=>this.updateCount(),0))}updateCount=()=>{if(!this.editor)return;const t=((new DOMParser).parseFromString(this.editor.getValue(),"text/html").body.innerText||"").trim().split(/\s+/).filter(t=>t.length>0);this.count=t.length};render(){return html`
|
|
2
|
+
<span class="word-count">
|
|
3
|
+
<slot name="label">Words:</slot> ${this.count}
|
|
4
|
+
</span>
|
|
5
|
+
`}static styles=[HtmlEditorControl.styles,css`
|
|
6
|
+
:host {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
padding: 0 0.5rem;
|
|
10
|
+
font-size: 0.875rem;
|
|
11
|
+
color: var(--text-color-secondary, #666);
|
|
12
|
+
}
|
|
13
|
+
.word-count {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 0.25rem;
|
|
17
|
+
}
|
|
18
|
+
`]}customElements.define("k-hec-word-count",WordCount);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default(t,e={})=>{if(!t)return"";const{indent:n=" ",blockTags:r=["div","p","pre","h1","h2","h3","h4","h5","h6","ul","ol","li","table","thead","tbody","tr","td","th","form","fieldset","section","article","header","footer","nav","main","aside"],selfClosingTags:s=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]}=e;let o="",a=0;const i=[];let c=0;const l=/<[^>]+>/g;let h;for(;null!==(h=l.exec(t));){if(h.index>c){const e=t.substring(c,h.index).trim();e&&i.push({type:"text",content:e})}i.push({type:"tag",content:h[0]}),c=h.index+h[0].length}if(c<t.length){const e=t.substring(c).trim();e&&i.push({type:"text",content:e})}let d=!1;return i.forEach((t,e)=>{if("text"===t.type)o+=t.content,d=!1;else{const e=t.content,i=e.startsWith("</"),c=(t=>{const e=t.match(/<\/?(\w+)/)?.[1]?.toLowerCase();return e&&r.includes(e)})(e),l=(t=>{const e=t.match(/<(\w+)/)?.[1]?.toLowerCase();return e&&s.includes(e)||t.endsWith("/>")})(e);i&&c?(a=Math.max(0,a-1),o+=d?"\n"+n.repeat(a)+e:e,d=!0):c&&!l?(d&&o.length>0||o.length>0?o+="\n"+n.repeat(a)+e:o+=n.repeat(a)+e,a++,d=!0):(o+=e,d=!1)}}),o.trim()};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M480-360 280-560h400L480-360Z"/></svg>
|
package/icons/circle.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>
|
package/icons/code.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M320-240 80-480l240-240 57 57-184 184 183 183-56 56Zm320 0-57-57 184-184-183-183 56-56 240 240-240 240Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="m384-336 56-57-87-87 87-87-56-57-144 144 144 144Zm192 0 144-144-144-144-56 57 87 87-87 87 56 57ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"/></svg>
|
package/icons/copy.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"/></svg>
|
package/icons/dot.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle fill="currentColor" cx="50" cy="50" r="20"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"/></svg>
|