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,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()};
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
<div class="row -mx">
|
|
65
65
|
<div class="col m-span-12 px">
|
|
66
66
|
<k-card label="HTML">
|
|
67
|
-
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-dropdown</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">slot</span>=<span class="hljs-string">"trigger"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-icon</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"more_vert"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-icon</span>></span><br /> <span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">data-value</span>=<span class="hljs-string">"edit"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-icon</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"edit"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-icon</span>></span> Edit<br /> <span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">data-value</span>=<span class="hljs-string">"copy"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-icon</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"
|
|
67
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-dropdown</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">slot</span>=<span class="hljs-string">"trigger"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-icon</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"more_vert"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-icon</span>></span><br /> <span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">data-value</span>=<span class="hljs-string">"edit"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-icon</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"edit"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-icon</span>></span> Edit<br /> <span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">data-value</span>=<span class="hljs-string">"copy"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-icon</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"copy"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-icon</span>></span> Copy<br /> <span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">data-value</span>=<span class="hljs-string">"delete"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"tc-danger"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-icon</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"delete"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-icon</span>></span> Delete<br /> <span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">k-dropdown</span>></span></code></pre>
|
|
68
68
|
</k-card>
|
|
69
69
|
</div>
|
|
70
70
|
<div class="col m-span-12 px">
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
<k-icon name="edit"></k-icon> Edit
|
|
78
78
|
</button>
|
|
79
79
|
<button data-value="copy">
|
|
80
|
-
<k-icon name="
|
|
80
|
+
<k-icon name="copy"></k-icon> Copy
|
|
81
81
|
</button>
|
|
82
82
|
<button data-value="delete" class="tc-danger">
|
|
83
83
|
<k-icon name="delete"></k-icon> Delete
|