kempo-ui 0.3.8 → 0.3.10
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/dist/components/CodeEditor.js +96 -0
- package/dist/components/HtmlEditor.js +155 -30
- package/dist/components/codeEditorControls/CodeEditorControl.js +17 -0
- package/dist/components/codeEditorControls/ControlGroup.js +12 -0
- package/dist/components/codeEditorControls/ControlSpacer.js +6 -0
- package/dist/components/codeEditorControls/CopyCode.js +9 -0
- package/dist/components/codeEditorControls/EditorTheme.js +26 -0
- package/dist/components/codeEditorControls/FindReplace.js +7 -0
- package/dist/components/codeEditorControls/FoldAll.js +7 -0
- package/dist/components/codeEditorControls/FontSize.js +13 -0
- package/dist/components/codeEditorControls/FormatCode.js +9 -0
- package/dist/components/codeEditorControls/Fullscreen.js +12 -0
- package/dist/components/codeEditorControls/LanguageSelect.js +15 -0
- package/dist/components/codeEditorControls/Minimap.js +8 -0
- package/dist/components/codeEditorControls/Redo.js +7 -0
- package/dist/components/codeEditorControls/Undo.js +7 -0
- package/dist/components/codeEditorControls/WordWrap.js +8 -0
- package/dist/components/htmlEditorControls/AlignCenter.js +4 -4
- package/dist/components/htmlEditorControls/AlignJustify.js +4 -4
- package/dist/components/htmlEditorControls/AlignLeft.js +4 -4
- package/dist/components/htmlEditorControls/AlignRight.js +4 -4
- package/dist/components/htmlEditorControls/Bold.js +4 -4
- package/dist/components/htmlEditorControls/BulletList.js +4 -4
- package/dist/components/htmlEditorControls/ClearFormatting.js +4 -4
- package/dist/components/htmlEditorControls/CodeBlock.js +2 -2
- package/dist/components/htmlEditorControls/ControlGroup.js +2 -4
- package/dist/components/htmlEditorControls/CreateLink.js +3 -3
- package/dist/components/htmlEditorControls/FormatBlock.js +4 -4
- package/dist/components/htmlEditorControls/FormatCode.js +1 -0
- package/dist/components/htmlEditorControls/HtmlEditorControl.js +2 -2
- package/dist/components/htmlEditorControls/InlineCode.js +2 -2
- package/dist/components/htmlEditorControls/InsertTable.js +3 -3
- package/dist/components/htmlEditorControls/Italic.js +4 -4
- package/dist/components/htmlEditorControls/Mode.js +3 -3
- package/dist/components/htmlEditorControls/NumberList.js +4 -4
- package/dist/components/htmlEditorControls/Strikethrough.js +4 -4
- package/dist/components/htmlEditorControls/TextBackgroundColor.js +1 -1
- package/dist/components/htmlEditorControls/TextColor.js +1 -1
- package/dist/components/htmlEditorControls/Underline.js +4 -4
- package/docs/components/accordion.html +2 -0
- package/docs/components/aside.html +2 -0
- package/docs/components/card.html +2 -0
- package/docs/components/code-editor.html +491 -0
- package/docs/components/color-picker.html +2 -0
- package/docs/components/content-slider.html +2 -0
- package/docs/components/context.html +2 -0
- package/docs/components/dialog.html +2 -0
- package/docs/components/dropdown.html +2 -0
- package/docs/components/filter-list.html +2 -0
- package/docs/components/focus-capture.html +2 -0
- package/docs/components/html-editor.html +525 -212
- package/docs/components/hybrid-component.html +2 -0
- package/docs/components/icon.html +2 -0
- package/docs/components/import.html +2 -0
- package/docs/components/light-component.html +2 -0
- package/docs/components/nav-spacer.html +2 -0
- package/docs/components/nav.html +2 -0
- package/docs/components/photo-viewer.html +2 -0
- package/docs/components/resize.html +2 -0
- package/docs/components/shadow-component.html +2 -0
- package/docs/components/show-more.html +2 -0
- package/docs/components/sortable.html +2 -0
- package/docs/components/spinner.html +2 -0
- package/docs/components/split.html +2 -0
- package/docs/components/table.html +2 -0
- package/docs/components/tableControls.html +2 -0
- package/docs/components/tableCustomFields.html +2 -0
- package/docs/components/tableFetchRecords.html +2 -0
- package/docs/components/tableFieldSortHide.html +2 -0
- package/docs/components/tablePagination.html +2 -0
- package/docs/components/tablePlaceholder.html +2 -0
- package/docs/components/tableRecordEditing.html +2 -0
- package/docs/components/tableRecordFiltering.html +2 -0
- package/docs/components/tableRecordHiding.html +2 -0
- package/docs/components/tableRecordSearching.html +2 -0
- package/docs/components/tableRecordSelection.html +2 -0
- package/docs/components/tableRowControls.html +2 -0
- package/docs/components/tableServerSync.html +2 -0
- package/docs/components/tableSorting.html +2 -0
- package/docs/components/tabs.html +2 -0
- package/docs/components/tags.html +2 -0
- package/docs/components/theme-select.html +2 -0
- package/docs/components/theme-switcher.html +2 -0
- package/docs/components/timestamp.html +2 -0
- package/docs/components/toast.html +2 -0
- package/docs/components/toggle.html +2 -0
- package/docs/components/tree.html +2 -0
- package/docs/icons/auto_fix_high.svg +1 -0
- package/docs/icons/content_copy.svg +1 -0
- package/docs/icons/contrast.svg +1 -0
- package/docs/icons/frame_source.svg +1 -0
- package/docs/icons/fullscreen.svg +1 -0
- package/docs/icons/fullscreen_exit.svg +1 -0
- package/docs/icons/map.svg +1 -0
- package/docs/icons/redo.svg +1 -0
- package/docs/icons/text_decrease.svg +1 -0
- package/docs/icons/text_increase.svg +1 -0
- package/docs/icons/undo.svg +1 -0
- package/docs/icons/unfold_less.svg +1 -0
- package/docs/icons/unfold_more.svg +1 -0
- package/docs/icons/wrap_text.svg +1 -0
- package/docs/index.html +8 -0
- package/docs/src/components/CodeEditor.js +96 -0
- package/docs/src/components/HtmlEditor.js +155 -30
- package/docs/src/components/codeEditorControls/CodeEditorControl.js +17 -0
- package/docs/src/components/codeEditorControls/ControlGroup.js +12 -0
- package/docs/src/components/codeEditorControls/ControlSpacer.js +6 -0
- package/docs/src/components/codeEditorControls/CopyCode.js +9 -0
- package/docs/src/components/codeEditorControls/EditorTheme.js +26 -0
- package/docs/src/components/codeEditorControls/FindReplace.js +7 -0
- package/docs/src/components/codeEditorControls/FoldAll.js +7 -0
- package/docs/src/components/codeEditorControls/FontSize.js +13 -0
- package/docs/src/components/codeEditorControls/FormatCode.js +9 -0
- package/docs/src/components/codeEditorControls/Fullscreen.js +12 -0
- package/docs/src/components/codeEditorControls/LanguageSelect.js +15 -0
- package/docs/src/components/codeEditorControls/Minimap.js +8 -0
- package/docs/src/components/codeEditorControls/Redo.js +7 -0
- package/docs/src/components/codeEditorControls/Undo.js +7 -0
- package/docs/src/components/codeEditorControls/WordWrap.js +8 -0
- package/docs/src/components/htmlEditorControls/AlignCenter.js +4 -4
- package/docs/src/components/htmlEditorControls/AlignJustify.js +4 -4
- package/docs/src/components/htmlEditorControls/AlignLeft.js +4 -4
- package/docs/src/components/htmlEditorControls/AlignRight.js +4 -4
- package/docs/src/components/htmlEditorControls/Bold.js +4 -4
- package/docs/src/components/htmlEditorControls/BulletList.js +4 -4
- package/docs/src/components/htmlEditorControls/ClearFormatting.js +4 -4
- package/docs/src/components/htmlEditorControls/CodeBlock.js +2 -2
- package/docs/src/components/htmlEditorControls/ControlGroup.js +2 -4
- package/docs/src/components/htmlEditorControls/CreateLink.js +3 -3
- package/docs/src/components/htmlEditorControls/FormatBlock.js +4 -4
- package/docs/src/components/htmlEditorControls/FormatCode.js +1 -0
- package/docs/src/components/htmlEditorControls/HtmlEditorControl.js +2 -2
- package/docs/src/components/htmlEditorControls/InlineCode.js +2 -2
- package/docs/src/components/htmlEditorControls/InsertTable.js +3 -3
- package/docs/src/components/htmlEditorControls/Italic.js +4 -4
- package/docs/src/components/htmlEditorControls/Mode.js +3 -3
- package/docs/src/components/htmlEditorControls/NumberList.js +4 -4
- package/docs/src/components/htmlEditorControls/Strikethrough.js +4 -4
- package/docs/src/components/htmlEditorControls/TextBackgroundColor.js +1 -1
- package/docs/src/components/htmlEditorControls/TextColor.js +1 -1
- package/docs/src/components/htmlEditorControls/Underline.js +4 -4
- package/docs/utils/context.html +2 -0
- package/docs/utils/cookie.html +2 -0
- package/docs/utils/debounce.html +2 -0
- package/docs/utils/drag.html +2 -0
- package/docs/utils/elevation.html +2 -0
- package/docs/utils/formatTimestamp.html +2 -0
- package/docs/utils/object.html +2 -0
- package/docs/utils/propConverters.html +2 -0
- package/docs/utils/string.html +2 -0
- package/docs/utils/theme.html +2 -0
- package/docs/utils/toTitleCase.html +2 -0
- package/docs/utils/type.html +2 -0
- package/docs/utils/wait.html +2 -0
- package/docs-src/components/code-editor.page.html +235 -0
- package/docs-src/components/html-editor.page.html +528 -214
- package/docs-src/index.page.html +6 -0
- package/docs-src/nav.fragment.html +2 -0
- package/icons/auto_fix_high.svg +1 -0
- package/icons/content_copy.svg +1 -0
- package/icons/contrast.svg +1 -0
- package/icons/frame_source.svg +1 -0
- package/icons/fullscreen.svg +1 -0
- package/icons/fullscreen_exit.svg +1 -0
- package/icons/map.svg +1 -0
- package/icons/redo.svg +1 -0
- package/icons/text_decrease.svg +1 -0
- package/icons/text_increase.svg +1 -0
- package/icons/undo.svg +1 -0
- package/icons/unfold_less.svg +1 -0
- package/icons/unfold_more.svg +1 -0
- package/icons/wrap_text.svg +1 -0
- package/llm.txt +2 -1
- package/package.json +3 -3
- package/src/components/CodeEditor.js +495 -0
- package/src/components/HtmlEditor.js +527 -152
- package/src/components/codeEditorControls/CodeEditorControl.js +134 -0
- package/src/components/codeEditorControls/ControlGroup.js +70 -0
- package/src/components/codeEditorControls/ControlSpacer.js +23 -0
- package/src/components/codeEditorControls/CopyCode.js +37 -0
- package/src/components/codeEditorControls/EditorTheme.js +81 -0
- package/src/components/codeEditorControls/FindReplace.js +35 -0
- package/src/components/codeEditorControls/FoldAll.js +49 -0
- package/src/components/codeEditorControls/FontSize.js +45 -0
- package/src/components/codeEditorControls/FormatCode.js +37 -0
- package/src/components/codeEditorControls/Fullscreen.js +72 -0
- package/src/components/codeEditorControls/LanguageSelect.js +74 -0
- package/src/components/codeEditorControls/Minimap.js +60 -0
- package/src/components/codeEditorControls/Redo.js +35 -0
- package/src/components/codeEditorControls/Undo.js +35 -0
- package/src/components/codeEditorControls/WordWrap.js +60 -0
- package/src/components/htmlEditorControls/AlignCenter.js +2 -4
- package/src/components/htmlEditorControls/AlignJustify.js +2 -4
- package/src/components/htmlEditorControls/AlignLeft.js +2 -4
- package/src/components/htmlEditorControls/AlignRight.js +2 -4
- package/src/components/htmlEditorControls/Bold.js +2 -4
- package/src/components/htmlEditorControls/BulletList.js +2 -4
- package/src/components/htmlEditorControls/ClearFormatting.js +2 -4
- package/src/components/htmlEditorControls/CodeBlock.js +3 -19
- package/src/components/htmlEditorControls/ControlGroup.js +16 -41
- package/src/components/htmlEditorControls/CreateLink.js +3 -5
- package/src/components/htmlEditorControls/FormatBlock.js +2 -4
- package/src/components/htmlEditorControls/FormatCode.js +7 -0
- package/src/components/htmlEditorControls/HtmlEditorControl.js +43 -5
- package/src/components/htmlEditorControls/InlineCode.js +3 -5
- package/src/components/htmlEditorControls/InsertTable.js +9 -53
- package/src/components/htmlEditorControls/Italic.js +2 -4
- package/src/components/htmlEditorControls/Mode.js +2 -0
- package/src/components/htmlEditorControls/NumberList.js +2 -4
- package/src/components/htmlEditorControls/Strikethrough.js +2 -4
- package/src/components/htmlEditorControls/TextBackgroundColor.js +0 -6
- package/src/components/htmlEditorControls/TextColor.js +0 -6
- package/src/components/htmlEditorControls/Underline.js +2 -4
- package/tests/components/CodeEditor.browser-test.js +297 -0
- package/tests/components/HtmlEditor.browser-test.js +207 -0
- package/tests/components/codeEditorControls/CopyCode.browser-test.js +57 -0
- package/tests/components/codeEditorControls/EditorTheme.browser-test.js +70 -0
- package/tests/components/codeEditorControls/FindReplace.browser-test.js +57 -0
- package/tests/components/codeEditorControls/FoldAll.browser-test.js +92 -0
- package/tests/components/codeEditorControls/FontSize.browser-test.js +74 -0
- package/tests/components/codeEditorControls/Fullscreen.browser-test.js +152 -0
- package/tests/components/codeEditorControls/LanguageSelect.browser-test.js +82 -0
- package/tests/components/codeEditorControls/Minimap.browser-test.js +84 -0
- package/tests/components/codeEditorControls/ModeVisibility.browser-test.js +82 -0
- package/tests/components/codeEditorControls/UndoRedo.browser-test.js +85 -0
- package/tests/components/codeEditorControls/WordWrap.browser-test.js +95 -0
- package/tests/components/htmlEditorControls/Align.browser-test.js +203 -0
- package/tests/components/htmlEditorControls/Bold.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/BulletList.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/CharacterCount.browser-test.js +106 -0
- package/tests/components/htmlEditorControls/ClearFormatting.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/CodeBlock.browser-test.js +143 -0
- package/tests/components/htmlEditorControls/ControlGroup.browser-test.js +116 -0
- package/tests/components/htmlEditorControls/ControlSpacer.browser-test.js +69 -0
- package/tests/components/htmlEditorControls/CreateLink.browser-test.js +129 -0
- package/tests/components/htmlEditorControls/DropdownControl.browser-test.js +138 -0
- package/tests/components/htmlEditorControls/FormatBlock.browser-test.js +163 -0
- package/tests/components/htmlEditorControls/FormatCode.browser-test.js +155 -0
- package/tests/components/htmlEditorControls/InlineCode.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/InsertTable.browser-test.js +129 -0
- package/tests/components/htmlEditorControls/Italic.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/Mode.browser-test.js +138 -0
- package/tests/components/htmlEditorControls/NumberList.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/Strikethrough.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/TextBackgroundColor.browser-test.js +136 -0
- package/tests/components/htmlEditorControls/TextColor.browser-test.js +136 -0
- package/tests/components/htmlEditorControls/Underline.browser-test.js +127 -0
- package/tests/components/htmlEditorControls/WordCount.browser-test.js +106 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import ShadowComponent from '../ShadowComponent.js';
|
|
2
|
+
import { css } from '../../lit-all.min.js';
|
|
3
|
+
|
|
4
|
+
export default class CodeEditorControl extends ShadowComponent {
|
|
5
|
+
static properties = {
|
|
6
|
+
btnClass: { type: String, attribute: 'btn-class' },
|
|
7
|
+
groupBtnClass: { type: String, attribute: 'group-btn-class' },
|
|
8
|
+
groupLastBtnClass: { type: String, attribute: 'group-last-btn-class' },
|
|
9
|
+
hidden: { type: Boolean, reflect: true }
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
Constructor
|
|
14
|
+
*/
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this.btnClass = 'b r mq ph';
|
|
18
|
+
this.groupBtnClass = 'br ph';
|
|
19
|
+
this.groupLastBtnClass = 'ph';
|
|
20
|
+
this.hidden = false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
Lifecycle Callbacks
|
|
25
|
+
*/
|
|
26
|
+
connectedCallback() {
|
|
27
|
+
super.connectedCallback();
|
|
28
|
+
this.updateModeVisibility();
|
|
29
|
+
const editor = this.editor;
|
|
30
|
+
if(editor?.tagName === 'K-HTML-EDITOR'){
|
|
31
|
+
this.modeHandler = () => this.updateModeVisibility();
|
|
32
|
+
editor.addEventListener('mode-changed', this.modeHandler);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
disconnectedCallback() {
|
|
37
|
+
super.disconnectedCallback();
|
|
38
|
+
if(this.modeHandler){
|
|
39
|
+
this.editor?.removeEventListener('mode-changed', this.modeHandler);
|
|
40
|
+
this.modeHandler = null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
updated(changed) {
|
|
45
|
+
super.updated(changed);
|
|
46
|
+
if(changed.has('hidden')){
|
|
47
|
+
this.dispatchEvent(new CustomEvent('control_visibility_change', { bubbles: true }));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
Mode Visibility
|
|
53
|
+
*/
|
|
54
|
+
updateModeVisibility() {
|
|
55
|
+
const editor = this.editor;
|
|
56
|
+
if(editor?.tagName === 'K-HTML-EDITOR'){
|
|
57
|
+
const shouldHide = editor.mode !== 'code';
|
|
58
|
+
if(this.hidden !== shouldHide){
|
|
59
|
+
this.hidden = shouldHide;
|
|
60
|
+
this.dispatchEvent(new CustomEvent('control_visibility_change', { bubbles: true }));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
Getters for Editor Integration
|
|
67
|
+
*/
|
|
68
|
+
get editor() {
|
|
69
|
+
const isEditor = el => el?.tagName === 'K-CODE-EDITOR' || el?.tagName === 'K-HTML-EDITOR';
|
|
70
|
+
let current = this.getRootNode();
|
|
71
|
+
while(current instanceof ShadowRoot){
|
|
72
|
+
const host = current.host;
|
|
73
|
+
if(isEditor(host)) return host;
|
|
74
|
+
current = host.getRootNode();
|
|
75
|
+
}
|
|
76
|
+
let el = this.parentElement;
|
|
77
|
+
while(el){
|
|
78
|
+
if(isEditor(el)) return el;
|
|
79
|
+
el = el.parentElement;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/*
|
|
85
|
+
Getters for Group Detection
|
|
86
|
+
*/
|
|
87
|
+
get isInGroup() {
|
|
88
|
+
const parent = this.parentElement;
|
|
89
|
+
return parent && parent.tagName === 'K-CEC-GROUP';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get isLastInGroup() {
|
|
93
|
+
if(!this.isInGroup) return false;
|
|
94
|
+
const siblings = Array.from(this.parentElement.children).filter(
|
|
95
|
+
child => child.tagName.startsWith('K-CEC-') && child.tagName !== 'K-CEC-SPACER'
|
|
96
|
+
);
|
|
97
|
+
return siblings[siblings.length - 1] === this;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/*
|
|
101
|
+
Getters for Button Classes
|
|
102
|
+
*/
|
|
103
|
+
get buttonClasses() {
|
|
104
|
+
const baseClass = 'no-btn icon-btn';
|
|
105
|
+
let styleClass;
|
|
106
|
+
if(this.isInGroup){
|
|
107
|
+
styleClass = this.isLastInGroup ? this.groupLastBtnClass : this.groupBtnClass;
|
|
108
|
+
} else {
|
|
109
|
+
styleClass = this.btnClass;
|
|
110
|
+
}
|
|
111
|
+
return `${baseClass} ${styleClass}`.trim();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/*
|
|
115
|
+
Styles
|
|
116
|
+
*/
|
|
117
|
+
static styles = css`
|
|
118
|
+
:host {
|
|
119
|
+
display: inline-flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
}
|
|
122
|
+
:host([hidden]) {
|
|
123
|
+
display: none !important;
|
|
124
|
+
}
|
|
125
|
+
button {
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
display: inline-flex;
|
|
128
|
+
align-items: center;
|
|
129
|
+
justify-content: center;
|
|
130
|
+
min-width: 2rem;
|
|
131
|
+
min-height: 2rem;
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import ShadowComponent from '../ShadowComponent.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
|
|
4
|
+
export default class ControlGroup extends ShadowComponent {
|
|
5
|
+
static properties = {
|
|
6
|
+
hidden: { type: Boolean, reflect: true }
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
Constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.hidden = false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
Lifecycle Callbacks
|
|
19
|
+
*/
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
super.connectedCallback();
|
|
22
|
+
if(!this.hasAttribute('class')){
|
|
23
|
+
this.setAttribute('class', 'b r mq');
|
|
24
|
+
}
|
|
25
|
+
this.addEventListener('control_visibility_change', this.checkVisibility);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
disconnectedCallback() {
|
|
29
|
+
super.disconnectedCallback();
|
|
30
|
+
this.removeEventListener('control_visibility_change', this.checkVisibility);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
Event Handlers
|
|
35
|
+
*/
|
|
36
|
+
checkVisibility = (e) => {
|
|
37
|
+
if(e.target === this) return;
|
|
38
|
+
const wasHidden = this.hidden;
|
|
39
|
+
this.hidden = Array.from(this.children).every(child => child.hidden === true);
|
|
40
|
+
if(this.hidden !== wasHidden){
|
|
41
|
+
this.dispatchEvent(new CustomEvent('control_visibility_change', { bubbles: true }));
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
Styles
|
|
47
|
+
*/
|
|
48
|
+
static styles = css`
|
|
49
|
+
:host {
|
|
50
|
+
display: inline-flex;
|
|
51
|
+
}
|
|
52
|
+
:host([hidden]) {
|
|
53
|
+
display: none !important;
|
|
54
|
+
}
|
|
55
|
+
::slotted(*) {
|
|
56
|
+
margin-top: -1px;
|
|
57
|
+
margin-bottom: -1px;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
Rendering
|
|
63
|
+
*/
|
|
64
|
+
render() {
|
|
65
|
+
return html`<slot></slot>`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
customElements.define('k-cec-group', ControlGroup);
|
|
70
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import ShadowComponent from '../ShadowComponent.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
|
|
4
|
+
export default class ControlSpacer extends ShadowComponent {
|
|
5
|
+
/*
|
|
6
|
+
Styles
|
|
7
|
+
*/
|
|
8
|
+
static styles = css`
|
|
9
|
+
:host {
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
flex: 1;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
Rendering
|
|
17
|
+
*/
|
|
18
|
+
render() {
|
|
19
|
+
return html``;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
customElements.define('k-cec-spacer', ControlSpacer);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import CodeEditorControl from './CodeEditorControl.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class CopyCode extends CodeEditorControl {
|
|
6
|
+
/*
|
|
7
|
+
Styles
|
|
8
|
+
*/
|
|
9
|
+
static styles = [
|
|
10
|
+
CodeEditorControl.styles,
|
|
11
|
+
css`
|
|
12
|
+
:host {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
}
|
|
15
|
+
`
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
Event Handlers
|
|
20
|
+
*/
|
|
21
|
+
handleClick = () => {
|
|
22
|
+
this.editor?.copyToClipboard();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
Rendering
|
|
27
|
+
*/
|
|
28
|
+
render() {
|
|
29
|
+
return html`
|
|
30
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}" title="Copy Code">
|
|
31
|
+
<k-icon name="content_copy"></k-icon>
|
|
32
|
+
</button>
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
customElements.define('k-cec-copy-code', CopyCode);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import CodeEditorControl from './CodeEditorControl.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class EditorTheme extends CodeEditorControl {
|
|
6
|
+
static properties = {
|
|
7
|
+
value: { type: String, state: true }
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
Lifecycle Callbacks
|
|
12
|
+
*/
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.value = 'auto';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
super.connectedCallback();
|
|
20
|
+
const editor = this.editor;
|
|
21
|
+
if(!editor) return;
|
|
22
|
+
this.value = editor.editorTheme || 'auto';
|
|
23
|
+
this.themeHandler = e => { this.value = e.detail.editorTheme; };
|
|
24
|
+
editor.addEventListener('editor-theme-changed', this.themeHandler);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
disconnectedCallback() {
|
|
28
|
+
super.disconnectedCallback();
|
|
29
|
+
this.editor?.removeEventListener('editor-theme-changed', this.themeHandler);
|
|
30
|
+
this.themeHandler = null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
Event Handlers
|
|
35
|
+
*/
|
|
36
|
+
handleChange = e => {
|
|
37
|
+
this.editor?.setEditorTheme(e.target.value);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
Styles
|
|
42
|
+
*/
|
|
43
|
+
static styles = [
|
|
44
|
+
CodeEditorControl.styles,
|
|
45
|
+
css`
|
|
46
|
+
:host {
|
|
47
|
+
background-color: var(--input_bg);
|
|
48
|
+
color: var(--input_tc);
|
|
49
|
+
border: var(--input_border_width) solid var(--c_input_border);
|
|
50
|
+
border-radius: var(--radius);
|
|
51
|
+
transition: box-shadow var(--animation_ms);
|
|
52
|
+
position: relative;
|
|
53
|
+
}
|
|
54
|
+
k-icon {
|
|
55
|
+
pointer-events: none;
|
|
56
|
+
position: absolute;
|
|
57
|
+
left: 0.5rem;
|
|
58
|
+
}
|
|
59
|
+
select {
|
|
60
|
+
padding-left: 2rem;
|
|
61
|
+
border: 0;
|
|
62
|
+
}
|
|
63
|
+
`
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
Rendering
|
|
68
|
+
*/
|
|
69
|
+
render() {
|
|
70
|
+
return html`
|
|
71
|
+
<k-icon name="contrast" style="font-size: 1.125rem; opacity: 0.7;"></k-icon>
|
|
72
|
+
<select .value=${this.value} @change=${this.handleChange} title="Editor Theme">
|
|
73
|
+
<option value="auto">Auto</option>
|
|
74
|
+
<option value="light">Light</option>
|
|
75
|
+
<option value="dark">Dark</option>
|
|
76
|
+
</select>
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
customElements.define('k-cec-editor-theme', EditorTheme);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import CodeEditorControl from './CodeEditorControl.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class FindReplace extends CodeEditorControl {
|
|
6
|
+
/*
|
|
7
|
+
Styles
|
|
8
|
+
*/
|
|
9
|
+
static styles = [
|
|
10
|
+
CodeEditorControl.styles,
|
|
11
|
+
css`
|
|
12
|
+
:host { display: inline-flex; }
|
|
13
|
+
`
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
Event Handlers
|
|
18
|
+
*/
|
|
19
|
+
handleClick = () => {
|
|
20
|
+
this.editor?.openFind();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
Rendering
|
|
25
|
+
*/
|
|
26
|
+
render() {
|
|
27
|
+
return html`
|
|
28
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}" title="Find & Replace">
|
|
29
|
+
<k-icon name="search"></k-icon>
|
|
30
|
+
</button>
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
customElements.define('k-cec-find-replace', FindReplace);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import CodeEditorControl from './CodeEditorControl.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class FoldAll extends CodeEditorControl {
|
|
6
|
+
static properties = {
|
|
7
|
+
folded: { type: Boolean, state: true }
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.folded = false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
Event Handlers
|
|
17
|
+
*/
|
|
18
|
+
handleClick = () => {
|
|
19
|
+
this.folded = !this.folded;
|
|
20
|
+
if(this.folded){
|
|
21
|
+
this.editor?.foldAll();
|
|
22
|
+
} else {
|
|
23
|
+
this.editor?.unfoldAll();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
Styles
|
|
29
|
+
*/
|
|
30
|
+
static styles = [
|
|
31
|
+
CodeEditorControl.styles,
|
|
32
|
+
css`
|
|
33
|
+
:host { display: inline-flex; }
|
|
34
|
+
`
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
Rendering
|
|
39
|
+
*/
|
|
40
|
+
render() {
|
|
41
|
+
return html`
|
|
42
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}" title="${this.folded ? 'Unfold All' : 'Fold All'}">
|
|
43
|
+
<k-icon name="${this.folded ? 'unfold_more' : 'unfold_less'}"></k-icon>
|
|
44
|
+
</button>
|
|
45
|
+
`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
customElements.define('k-cec-fold-all', FoldAll);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import CodeEditorControl from './CodeEditorControl.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class FontSize extends CodeEditorControl {
|
|
6
|
+
/*
|
|
7
|
+
Styles
|
|
8
|
+
*/
|
|
9
|
+
static styles = [
|
|
10
|
+
CodeEditorControl.styles,
|
|
11
|
+
css`
|
|
12
|
+
:host {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
gap: 0;
|
|
15
|
+
}
|
|
16
|
+
`
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
Event Handlers
|
|
21
|
+
*/
|
|
22
|
+
handleIncrease = () => {
|
|
23
|
+
this.editor?.increaseFontSize();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
handleDecrease = () => {
|
|
27
|
+
this.editor?.decreaseFontSize();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
Rendering
|
|
32
|
+
*/
|
|
33
|
+
render() {
|
|
34
|
+
return html`
|
|
35
|
+
<button class="${this.buttonClasses}" @click="${this.handleDecrease}" title="Decrease Font Size">
|
|
36
|
+
<k-icon name="text_decrease"></k-icon>
|
|
37
|
+
</button>
|
|
38
|
+
<button class="${this.buttonClasses}" @click="${this.handleIncrease}" title="Increase Font Size">
|
|
39
|
+
<k-icon name="text_increase"></k-icon>
|
|
40
|
+
</button>
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
customElements.define('k-cec-font-size', FontSize);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import CodeEditorControl from './CodeEditorControl.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class FormatCode extends CodeEditorControl {
|
|
6
|
+
/*
|
|
7
|
+
Styles
|
|
8
|
+
*/
|
|
9
|
+
static styles = [
|
|
10
|
+
CodeEditorControl.styles,
|
|
11
|
+
css`
|
|
12
|
+
:host {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
}
|
|
15
|
+
`
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
Event Handlers
|
|
20
|
+
*/
|
|
21
|
+
handleClick = () => {
|
|
22
|
+
this.editor?.formatCode();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
Rendering
|
|
27
|
+
*/
|
|
28
|
+
render() {
|
|
29
|
+
return html`
|
|
30
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}" title="Format Code">
|
|
31
|
+
<k-icon name="frame_source"></k-icon>
|
|
32
|
+
</button>
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
customElements.define('k-cec-format-code', FormatCode);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import CodeEditorControl from './CodeEditorControl.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class Fullscreen extends CodeEditorControl {
|
|
6
|
+
static properties = {
|
|
7
|
+
fullscreen: { type: Boolean, state: true }
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.fullscreen = false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
Lifecycle Callbacks
|
|
17
|
+
*/
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
super.connectedCallback();
|
|
20
|
+
const editor = this.editor;
|
|
21
|
+
if(!editor) return;
|
|
22
|
+
this.fullscreen = editor.fullscreen;
|
|
23
|
+
this.fullscreenHandler = () => { this.fullscreen = editor.fullscreen; };
|
|
24
|
+
editor.addEventListener('fullscreen-changed', this.fullscreenHandler);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
disconnectedCallback() {
|
|
28
|
+
super.disconnectedCallback();
|
|
29
|
+
this.editor?.removeEventListener('fullscreen-changed', this.fullscreenHandler);
|
|
30
|
+
this.fullscreenHandler = null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
Mode Visibility — visible in both visual and code modes
|
|
35
|
+
*/
|
|
36
|
+
updateModeVisibility() {}
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
Event Handlers
|
|
40
|
+
*/
|
|
41
|
+
handleClick = () => {
|
|
42
|
+
this.editor?.toggleFullscreen();
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
Styles
|
|
47
|
+
*/
|
|
48
|
+
static styles = [
|
|
49
|
+
CodeEditorControl.styles,
|
|
50
|
+
css`
|
|
51
|
+
:host { display: inline-flex; }
|
|
52
|
+
button.active { background: var(--primary-bg, rgba(0,120,212,0.15)); }
|
|
53
|
+
`
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
Rendering
|
|
58
|
+
*/
|
|
59
|
+
render() {
|
|
60
|
+
return html`
|
|
61
|
+
<button
|
|
62
|
+
class="${this.buttonClasses} ${this.fullscreen ? 'active' : ''}"
|
|
63
|
+
@click="${this.handleClick}"
|
|
64
|
+
title="${this.fullscreen ? 'Exit Fullscreen' : 'Fullscreen'}"
|
|
65
|
+
>
|
|
66
|
+
<k-icon name="${this.fullscreen ? 'fullscreen_exit' : 'fullscreen'}"></k-icon>
|
|
67
|
+
</button>
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
customElements.define('k-cec-fullscreen', Fullscreen);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import CodeEditorControl from './CodeEditorControl.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
const COMMON_LANGUAGES = [
|
|
6
|
+
'javascript', 'typescript', 'html', 'css', 'json',
|
|
7
|
+
'markdown', 'python', 'java', 'csharp', 'cpp',
|
|
8
|
+
'go', 'rust', 'php', 'ruby', 'sql',
|
|
9
|
+
'xml', 'yaml', 'shell', 'plaintext'
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export default class LanguageSelect extends CodeEditorControl {
|
|
13
|
+
static properties = {
|
|
14
|
+
value: { type: String, state: true }
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.value = 'javascript';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
super.connectedCallback();
|
|
24
|
+
const editor = this.editor;
|
|
25
|
+
if(!editor) return;
|
|
26
|
+
this.value = editor.language || 'javascript';
|
|
27
|
+
this.languageHandler = e => { this.value = e.detail.language; };
|
|
28
|
+
editor.addEventListener('language-changed', this.languageHandler);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
super.disconnectedCallback();
|
|
33
|
+
this.editor?.removeEventListener('language-changed', this.languageHandler);
|
|
34
|
+
this.languageHandler = null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
Event Handlers
|
|
39
|
+
*/
|
|
40
|
+
handleChange = e => {
|
|
41
|
+
this.editor?.setLanguage(e.target.value);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
Styles
|
|
46
|
+
*/
|
|
47
|
+
static styles = [
|
|
48
|
+
CodeEditorControl.styles,
|
|
49
|
+
css`
|
|
50
|
+
:host {
|
|
51
|
+
display: inline-flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
padding: 0 0.25rem;
|
|
54
|
+
gap: 0.25rem;
|
|
55
|
+
background-color:
|
|
56
|
+
}
|
|
57
|
+
`
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
Rendering
|
|
62
|
+
*/
|
|
63
|
+
render() {
|
|
64
|
+
return html`
|
|
65
|
+
<select .value=${this.value} @change=${this.handleChange} title="Language">
|
|
66
|
+
${COMMON_LANGUAGES.map(lang => html`
|
|
67
|
+
<option value="${lang}" ?selected=${this.value === lang}>${lang}</option>
|
|
68
|
+
`)}
|
|
69
|
+
</select>
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
customElements.define('k-cec-language', LanguageSelect);
|