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
package/docs-src/index.page.html
CHANGED
|
@@ -53,6 +53,12 @@
|
|
|
53
53
|
<p class="tc-muted">Container component with optional labels and border styling.</p>
|
|
54
54
|
</a>
|
|
55
55
|
</div>
|
|
56
|
+
<div class="span-12 t-span-6 d-span-4 px">
|
|
57
|
+
<a href="{{pathToRoot}}components/code-editor.html" class="card mb no-link d-b">
|
|
58
|
+
<h3 class="tc-primary">Code Editor</h3>
|
|
59
|
+
<p class="tc-muted">Monaco-powered code editor with language support and theme integration.</p>
|
|
60
|
+
</a>
|
|
61
|
+
</div>
|
|
56
62
|
<div class="span-12 t-span-6 d-span-4 px">
|
|
57
63
|
<a href="{{pathToRoot}}components/color-picker.html" class="card mb no-link d-b">
|
|
58
64
|
<h3 class="tc-primary">ColorPicker</h3>
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
<k-filter-item filter-keywords="accordion components"><a href="{{pathToRoot}}components/accordion.html">Accordion<br><small>Component</small></a></k-filter-item>
|
|
15
15
|
<k-filter-item filter-keywords="aside sidebar components"><a href="{{pathToRoot}}components/aside.html">Aside<br><small>Component</small></a></k-filter-item>
|
|
16
16
|
<k-filter-item filter-keywords="card components"><a href="{{pathToRoot}}components/card.html">Card<br><small>Component</small></a></k-filter-item>
|
|
17
|
+
<k-filter-item filter-keywords="code editor codeeditor monaco components"><a href="{{pathToRoot}}components/code-editor.html">Code Editor<br><small>Component</small></a></k-filter-item>
|
|
17
18
|
<k-filter-item filter-keywords="color picker colorpicker components"><a href="{{pathToRoot}}components/color-picker.html">Color Picker<br><small>Component</small></a></k-filter-item>
|
|
18
19
|
<k-filter-item filter-keywords="content slider components"><a href="{{pathToRoot}}components/content-slider.html">Content Slider<br><small>Component</small></a></k-filter-item>
|
|
19
20
|
<k-filter-item filter-keywords="context state global components"><a href="{{pathToRoot}}components/context.html">Context<br><small>Component</small></a></k-filter-item>
|
|
@@ -92,6 +93,7 @@
|
|
|
92
93
|
<a href="{{pathToRoot}}components/accordion.html">Accordion</a>
|
|
93
94
|
<a href="{{pathToRoot}}components/aside.html">Aside</a>
|
|
94
95
|
<a href="{{pathToRoot}}components/card.html">Card</a>
|
|
96
|
+
<a href="{{pathToRoot}}components/code-editor.html">Code Editor</a>
|
|
95
97
|
<a href="{{pathToRoot}}components/color-picker.html">ColorPicker</a>
|
|
96
98
|
<a href="{{pathToRoot}}components/content-slider.html">Content Slider</a>
|
|
97
99
|
<a href="{{pathToRoot}}components/context.html">Context</a>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="m800-680-38-82-82-38 82-38 38-82 38 82 82 38-82 38-38 82Zm-460 0-38-82-82-38 82-38 38-82 38 82 82 38-82 38-38 82Zm460 460-38-82-82-38 82-38 38-82 38 82 82 38-82 38-38 82ZM204-92 92-204q-12-12-12-29t12-29l446-446q12-12 29-12t29 12l112 112q12 12 12 29t-12 29L262-92q-12 12-29 12t-29-12Zm30-84 286-288-56-56-288 286 58 58Z"/></svg>
|
|
@@ -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>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M324-111.5Q251-143 197-197t-85.5-127Q80-397 80-480t31.5-156Q143-709 197-763t127-85.5Q397-880 480-880t156 31.5Q709-817 763-763t85.5 127Q880-563 880-480t-31.5 156Q817-251 763-197t-127 85.5Q563-80 480-80t-156-31.5ZM520-163q119-15 199.5-104.5T800-480q0-123-80.5-212.5T520-797v634Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M344-336 200-480l144-144 56 57-87 87 87 87-56 57Zm272 0-56-57 87-87-87-87 56-57 144 144-144 144ZM200-120q-33 0-56.5-23.5T120-200v-160h80v160h160v80H200Zm400 0v-80h160v-160h80v160q0 33-23.5 56.5T760-120H600ZM120-600v-160q0-33 23.5-56.5T200-840h160v80H200v160h-80Zm640 0v-160H600v-80h160q33 0 56.5 23.5T840-760v160h-80Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M120-120v-200h80v120h120v80H120Zm520 0v-80h120v-120h80v200H640ZM120-640v-200h200v80H200v120h-80Zm640 0v-120H640v-80h200v200h-80Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M240-120v-120H120v-80h200v200h-80Zm400 0v-200h200v80H720v120h-80ZM120-640v-80h120v-120h80v200H120Zm520 0v-200h80v120h120v80H640Z"/></svg>
|
package/icons/map.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="m600-120-240-84-186 72q-20 8-37-4.5T120-170v-560q0-13 7.5-23t20.5-15l212-72 240 84 186-72q20-8 37 4.5t17 33.5v560q0 13-7.5 23T812-192l-212 72Zm-40-98v-468l-160-56v468l160 56Zm80 0 120-40v-474l-120 46v468Zm-440-10 120-46v-468l-120 40v474Zm440-458v468-468Zm-320-56v468-468Z"/></svg>
|
package/icons/redo.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm384-16v-80h320v80H600Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="m40-200 210-560h100l210 560h-96l-51-143H187l-51 143H40Zm176-224h168l-82-232h-4l-82 232Zm504 104v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z"/></svg>
|
package/icons/undo.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="m356-160-56-56 180-180 180 180-56 56-124-124-124 124Zm124-404L300-744l56-56 124 124 124-124 56 56-180 180Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M480-120 300-300l58-58 122 122 122-122 58 58-180 180ZM358-598l-58-58 180-180 180 180-58 58-122-122-122 122Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M588-132 440-280l148-148 56 58-50 50h96q29 0 49.5-20.5T760-390q0-29-20.5-49.5T690-460H160v-80h530q63 0 106.5 43.5T840-390q0 63-43.5 106.5T690-240h-96l50 50-56 58ZM160-240v-80h200v80H160Zm0-440v-80h640v80H160Z"/></svg>
|
package/llm.txt
CHANGED
|
@@ -55,6 +55,7 @@ import { html, css, LitElement } from 'kempo-ui/src/lit-all.min.js';
|
|
|
55
55
|
| `<k-accordion>` `<k-accordion-header>` `<k-accordion-panel>` | `Accordion.js` | Collapsible panel groups; `for-panel` attribute links headers to panels | [accordion.html](https://dustinpoissant.github.io/kempo-ui/components/accordion.html) |
|
|
56
56
|
| `<k-aside>` `<k-aside-item>` `<k-aside-label>` `<k-aside-menu>` `<k-aside-spacer>` `<k-aside-toggle>` | `Aside.js` | Sidebar/drawer; `main="push"` or `main="overlay"`, `side="left|right"` | [aside.html](https://dustinpoissant.github.io/kempo-ui/components/aside.html) |
|
|
57
57
|
| `<k-card>` | `Card.js` | Bordered container; optional `label` attribute | [card.html](https://dustinpoissant.github.io/kempo-ui/components/card.html) |
|
|
58
|
+
| `<k-code-editor>` | `CodeEditor.js` | Monaco-powered code editor; `value`, `language`, `controls` attributes; form-associated; theme-aware | [code-editor.html](https://dustinpoissant.github.io/kempo-ui/components/code-editor.html) |
|
|
58
59
|
| `<k-color-picker>` | `ColorPicker.js` | Full color picker (hex, rgb, hsl, hsv, alpha); `value` property | [color-picker.html](https://dustinpoissant.github.io/kempo-ui/components/color-picker.html) |
|
|
59
60
|
| `<k-content-slider>` | `ContentSlider.js` | Swipeable carousel | [content-slider.html](https://dustinpoissant.github.io/kempo-ui/components/content-slider.html) |
|
|
60
61
|
| `<k-context>` | `Context.js` | Non-rendering state container; `set(key,value)`, `get(key)`, `delete(key)`, `clear()`, `getData()`; fires `context:create`, `context:set`, `context:delete` | [context.html](https://dustinpoissant.github.io/kempo-ui/components/context.html) |
|
|
@@ -62,7 +63,7 @@ import { html, css, LitElement } from 'kempo-ui/src/lit-all.min.js';
|
|
|
62
63
|
| `<k-dropdown>` | `Dropdown.js` | Action menu with keyboard navigation | [dropdown.html](https://dustinpoissant.github.io/kempo-ui/components/dropdown.html) |
|
|
63
64
|
| `<k-filter-list>` `<k-filter-item>` | `FilterList.js` `FilterItem.js` | Filter/search list; items have `filter` attribute with keywords | [filter-list.html](https://dustinpoissant.github.io/kempo-ui/components/filter-list.html) |
|
|
64
65
|
| `<k-focus-capture>` | `FocusCapture.js` | Traps keyboard focus within children | [focus-capture.html](https://dustinpoissant.github.io/kempo-ui/components/focus-capture.html) |
|
|
65
|
-
| `<k-html-editor>` | `HtmlEditor.js` | WYSIWYG rich text editor; `value` property | [html-editor.html](https://dustinpoissant.github.io/kempo-ui/components/html-editor.html) |
|
|
66
|
+
| `<k-html-editor>` | `HtmlEditor.js` | WYSIWYG rich text editor; `value` property; `controls` attribute (`full`/`normal`/`minimal`/`none`) for built-in toolbars | [html-editor.html](https://dustinpoissant.github.io/kempo-ui/components/html-editor.html) |
|
|
66
67
|
| `<k-icon>` | `Icon.js` | SVG icon; `name` (looked up in `pathsToIcons`) or `src` (direct URL); `rotation`, `direction`, `animation` attributes | [icon.html](https://dustinpoissant.github.io/kempo-ui/components/icon.html) |
|
|
67
68
|
| `<k-import>` | `Import.js` | Includes external HTML fragments; `src` attribute | [import.html](https://dustinpoissant.github.io/kempo-ui/components/import.html) |
|
|
68
69
|
| `<k-main>` | `Main.js` | Layout main; automatically adjusts margins when a `k-aside[main="push"]` opens | — |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kempo-ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Lit based web-component library",
|
|
6
6
|
"main": "index.js",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"highlight.js": "^11.11.1",
|
|
38
38
|
"js-beautify": "^1.15.4",
|
|
39
39
|
"kempo-server": "^3.0.3",
|
|
40
|
-
"kempo-testing-framework": "^1.4.
|
|
40
|
+
"kempo-testing-framework": "^1.4.6",
|
|
41
41
|
"terser": "^5.43.1"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@inquirer/prompts": "^8.3.0",
|
|
45
|
-
"kempo-css": "^2.1.
|
|
45
|
+
"kempo-css": "^2.1.9"
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
import { html, css } from '../lit-all.min.js';
|
|
2
|
+
import ShadowComponent from './ShadowComponent.js';
|
|
3
|
+
import formatCode from '../utils/formatCode.js';
|
|
4
|
+
import { getCalculatedTheme, subscribeToTheme } from '../utils/theme.js';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
Default CDN URL
|
|
8
|
+
*/
|
|
9
|
+
const MONACO_VERSION = '0.52.2';
|
|
10
|
+
const DEFAULT_MONACO_SRC = `https://cdn.jsdelivr.net/npm/monaco-editor@${MONACO_VERSION}/min`;
|
|
11
|
+
|
|
12
|
+
export default class CodeEditor extends ShadowComponent {
|
|
13
|
+
static formAssociated = true;
|
|
14
|
+
|
|
15
|
+
static properties = {
|
|
16
|
+
name: { type: String, reflect: true },
|
|
17
|
+
value: { type: String, reflect: true },
|
|
18
|
+
language: { type: String, reflect: true },
|
|
19
|
+
monacoSrc: { type: String, attribute: 'monaco-src' },
|
|
20
|
+
controls: { type: String, reflect: true },
|
|
21
|
+
editorTheme: { type: String, attribute: 'editor-theme', reflect: true },
|
|
22
|
+
hasTopToolbar: { type: Boolean, state: true },
|
|
23
|
+
hasBottomToolbar: { type: Boolean, state: true },
|
|
24
|
+
fullscreen: { type: Boolean, reflect: true },
|
|
25
|
+
wordWrap: { type: Boolean },
|
|
26
|
+
minimapEnabled: { type: Boolean }
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
this.internals = this.attachInternals();
|
|
32
|
+
this.name = '';
|
|
33
|
+
this.value = '';
|
|
34
|
+
this.language = 'javascript';
|
|
35
|
+
this.monacoSrc = '';
|
|
36
|
+
this.controls = '';
|
|
37
|
+
this.controlsLoaded = false;
|
|
38
|
+
this.hasTopToolbar = false;
|
|
39
|
+
this.hasBottomToolbar = false;
|
|
40
|
+
this.monacoEditor = null;
|
|
41
|
+
this.skipValueSync = false;
|
|
42
|
+
this.editorTheme = 'auto';
|
|
43
|
+
this.wordWrap = true;
|
|
44
|
+
this.minimapEnabled = false;
|
|
45
|
+
this.fontSize = 14;
|
|
46
|
+
this.fullscreen = false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
Lifecycle Callbacks
|
|
51
|
+
*/
|
|
52
|
+
connectedCallback() {
|
|
53
|
+
super.connectedCallback();
|
|
54
|
+
if(this.hasAttribute('value')){
|
|
55
|
+
this.value = this.getAttribute('value');
|
|
56
|
+
}
|
|
57
|
+
this.slotObserver = new MutationObserver(() => this.updateToolbarVisibility());
|
|
58
|
+
this.slotObserver.observe(this, { childList: true, subtree: true });
|
|
59
|
+
this.updateToolbarVisibility();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
disconnectedCallback() {
|
|
63
|
+
super.disconnectedCallback();
|
|
64
|
+
this.slotObserver?.disconnect();
|
|
65
|
+
this.monacoEditor?.dispose();
|
|
66
|
+
this.unsubscribeTheme?.();
|
|
67
|
+
if(this.fullscreen) this.exitFullscreen();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
updateToolbarVisibility() {
|
|
71
|
+
const slots = new Set(Array.from(this.children).map(c => c.getAttribute('slot')));
|
|
72
|
+
const set = this.constructor.controlSets[this.controls] ?? null;
|
|
73
|
+
this.hasTopToolbar =
|
|
74
|
+
!!(set?.topLeft || set?.topRight) ||
|
|
75
|
+
['toolbar-top', 'toolbar-top-left', 'toolbar-top-right'].some(s => slots.has(s));
|
|
76
|
+
this.hasBottomToolbar =
|
|
77
|
+
!!(set?.bottomLeft || set?.bottomRight) ||
|
|
78
|
+
['toolbar-bottom', 'toolbar-bottom-left', 'toolbar-bottom-right'].some(s => slots.has(s));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
updated(changedProperties) {
|
|
82
|
+
super.updated(changedProperties);
|
|
83
|
+
if(changedProperties.has('controls')){
|
|
84
|
+
this.updateToolbarVisibility();
|
|
85
|
+
if(this.controls && this.controls !== 'none') this.loadControls();
|
|
86
|
+
}
|
|
87
|
+
if(changedProperties.has('value') && !this.skipValueSync){
|
|
88
|
+
if(this.monacoEditor && this.monacoEditor.getValue() !== this.value){
|
|
89
|
+
this.monacoEditor.setValue(this.value);
|
|
90
|
+
}
|
|
91
|
+
this.updateFormValue();
|
|
92
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
93
|
+
detail: { value: this.value },
|
|
94
|
+
bubbles: true
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
if(changedProperties.has('language') && this.monacoEditor){
|
|
98
|
+
const model = this.monacoEditor.getModel();
|
|
99
|
+
if(model) window.monaco.editor.setModelLanguage(model, this.language);
|
|
100
|
+
this.dispatchEvent(new CustomEvent('language-changed', { detail: { language: this.language }, bubbles: true }));
|
|
101
|
+
}
|
|
102
|
+
if(changedProperties.has('editorTheme') && this.monacoEditor){
|
|
103
|
+
window.monaco.editor.setTheme(this.resolveMonacoTheme());
|
|
104
|
+
this.dispatchEvent(new CustomEvent('editor-theme-changed', { detail: { editorTheme: this.editorTheme }, bubbles: true }));
|
|
105
|
+
}
|
|
106
|
+
if(changedProperties.has('wordWrap')){
|
|
107
|
+
this.monacoEditor?.updateOptions({ wordWrap: this.wordWrap ? 'on' : 'off' });
|
|
108
|
+
this.dispatchEvent(new CustomEvent('word-wrap-changed', { detail: { wordWrap: this.wordWrap }, bubbles: true }));
|
|
109
|
+
}
|
|
110
|
+
if(changedProperties.has('minimapEnabled')){
|
|
111
|
+
this.monacoEditor?.updateOptions({ minimap: { enabled: this.minimapEnabled } });
|
|
112
|
+
this.dispatchEvent(new CustomEvent('minimap-changed', { detail: { minimapEnabled: this.minimapEnabled }, bubbles: true }));
|
|
113
|
+
}
|
|
114
|
+
if(changedProperties.has('fullscreen')){
|
|
115
|
+
if(!this.fullscreen) this.monacoEditor?.layout({ width: 0, height: 0 });
|
|
116
|
+
requestAnimationFrame(() => this.monacoEditor?.layout());
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async firstUpdated() {
|
|
121
|
+
this.monacoContainer = this.shadowRoot.querySelector('.monaco-editor-container');
|
|
122
|
+
await this.initMonaco();
|
|
123
|
+
this.dispatchEvent(new CustomEvent('ready', {
|
|
124
|
+
detail: { value: this.value },
|
|
125
|
+
bubbles: true
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/*
|
|
130
|
+
Module Loading
|
|
131
|
+
*/
|
|
132
|
+
async loadControls() {
|
|
133
|
+
if(this.controlsLoaded) return;
|
|
134
|
+
this.controlsLoaded = true;
|
|
135
|
+
const base = new URL('./codeEditorControls/', import.meta.url).href;
|
|
136
|
+
await Promise.all([
|
|
137
|
+
import(/* @vite-ignore */ `${base}FormatCode.js`),
|
|
138
|
+
import(/* @vite-ignore */ `${base}CopyCode.js`),
|
|
139
|
+
import(/* @vite-ignore */ `${base}EditorTheme.js`),
|
|
140
|
+
import(/* @vite-ignore */ `${base}Undo.js`),
|
|
141
|
+
import(/* @vite-ignore */ `${base}Redo.js`),
|
|
142
|
+
import(/* @vite-ignore */ `${base}WordWrap.js`),
|
|
143
|
+
import(/* @vite-ignore */ `${base}Minimap.js`),
|
|
144
|
+
import(/* @vite-ignore */ `${base}FindReplace.js`),
|
|
145
|
+
import(/* @vite-ignore */ `${base}FontSize.js`),
|
|
146
|
+
import(/* @vite-ignore */ `${base}FoldAll.js`),
|
|
147
|
+
import(/* @vite-ignore */ `${base}LanguageSelect.js`),
|
|
148
|
+
import(/* @vite-ignore */ `${base}Fullscreen.js`),
|
|
149
|
+
import(/* @vite-ignore */ `${base}ControlGroup.js`),
|
|
150
|
+
import(/* @vite-ignore */ `${base}ControlSpacer.js`)
|
|
151
|
+
]);
|
|
152
|
+
this.requestUpdate();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async initMonaco() {
|
|
156
|
+
if(this.monacoEditor) return;
|
|
157
|
+
if(this.monacoInitPromise) return this.monacoInitPromise;
|
|
158
|
+
this.monacoInitPromise = this._initMonaco();
|
|
159
|
+
await this.monacoInitPromise;
|
|
160
|
+
this.monacoInitPromise = null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async _initMonaco() {
|
|
164
|
+
const src = this.monacoSrc || window.kempo?.monacoUrl || DEFAULT_MONACO_SRC;
|
|
165
|
+
await new Promise((resolve, reject) => {
|
|
166
|
+
if(window.monaco){ resolve(); return; }
|
|
167
|
+
if(window.require?.defined?.('vs/editor/editor.main')){ resolve(); return; }
|
|
168
|
+
const existing = document.querySelector(`script[src="${src}/vs/loader.js"]`);
|
|
169
|
+
if(existing){
|
|
170
|
+
existing.addEventListener('load', () => {
|
|
171
|
+
window.require.config({ paths: { vs: `${src}/vs` } });
|
|
172
|
+
window.require(['vs/editor/editor.main'], () => resolve(), reject);
|
|
173
|
+
});
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const script = document.createElement('script');
|
|
177
|
+
script.src = `${src}/vs/loader.js`;
|
|
178
|
+
script.onload = () => {
|
|
179
|
+
window.require.config({ paths: { vs: `${src}/vs` } });
|
|
180
|
+
window.require(['vs/editor/editor.main'], () => resolve(), reject);
|
|
181
|
+
};
|
|
182
|
+
script.onerror = reject;
|
|
183
|
+
document.head.appendChild(script);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
this.monacoEditor = window.monaco.editor.create(this.monacoContainer, {
|
|
187
|
+
value: this.value,
|
|
188
|
+
language: this.language,
|
|
189
|
+
theme: this.resolveMonacoTheme(),
|
|
190
|
+
minimap: { enabled: false },
|
|
191
|
+
wordWrap: 'on',
|
|
192
|
+
fontSize: 14,
|
|
193
|
+
scrollBeyondLastLine: false,
|
|
194
|
+
automaticLayout: true,
|
|
195
|
+
tabSize: 2,
|
|
196
|
+
padding: { top: 8 }
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const monacoCSS = document.querySelector('link[href*="monaco"][href*="editor.main.css"]');
|
|
200
|
+
if(monacoCSS){
|
|
201
|
+
const link = document.createElement('link');
|
|
202
|
+
link.rel = 'stylesheet';
|
|
203
|
+
link.href = monacoCSS.href;
|
|
204
|
+
this.shadowRoot.appendChild(link);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
this.unsubscribeTheme = subscribeToTheme(() => {
|
|
208
|
+
if(this.monacoEditor && this.editorTheme === 'auto'){
|
|
209
|
+
window.monaco.editor.setTheme(this.resolveMonacoTheme());
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
this.monacoEditor.onDidChangeModelContent(() => {
|
|
214
|
+
this.skipValueSync = true;
|
|
215
|
+
this.value = this.monacoEditor.getValue();
|
|
216
|
+
this.skipValueSync = false;
|
|
217
|
+
this.updateFormValue();
|
|
218
|
+
this.dispatchEvent(new CustomEvent('change', { detail: { value: this.value }, bubbles: true }));
|
|
219
|
+
this.dispatchEvent(new CustomEvent('input', { detail: { value: this.value }, bubbles: true }));
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/*
|
|
224
|
+
Form Integration
|
|
225
|
+
*/
|
|
226
|
+
updateFormValue() {
|
|
227
|
+
this.internals.setFormValue(this.getValue());
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
formResetCallback() {
|
|
231
|
+
this.value = '';
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
formStateRestoreCallback(state) {
|
|
235
|
+
this.value = state;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/*
|
|
239
|
+
Public Methods
|
|
240
|
+
*/
|
|
241
|
+
getValue() {
|
|
242
|
+
if(this.monacoEditor) return this.monacoEditor.getValue();
|
|
243
|
+
return this.value;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
setValue(str) {
|
|
247
|
+
this.skipValueSync = true;
|
|
248
|
+
this.value = str;
|
|
249
|
+
if(this.monacoEditor) this.monacoEditor.setValue(str);
|
|
250
|
+
this.updateFormValue();
|
|
251
|
+
this.skipValueSync = false;
|
|
252
|
+
return this;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
clear() {
|
|
256
|
+
return this.setValue('');
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
formatCode() {
|
|
260
|
+
this.monacoEditor?.getAction('editor.action.formatDocument')?.run();
|
|
261
|
+
return this;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
selectAll() {
|
|
265
|
+
if(!this.monacoEditor) return this;
|
|
266
|
+
const model = this.monacoEditor.getModel();
|
|
267
|
+
if(model) this.monacoEditor.setSelection(model.getFullModelRange());
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
getSelectedText() {
|
|
272
|
+
if(!this.monacoEditor) return '';
|
|
273
|
+
return this.monacoEditor.getModel()?.getValueInRange(this.monacoEditor.getSelection()) || '';
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
focus() {
|
|
277
|
+
this.monacoEditor?.focus();
|
|
278
|
+
return this;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
setLanguage(lang) {
|
|
282
|
+
this.language = lang;
|
|
283
|
+
return this;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
setEditorTheme(theme) {
|
|
287
|
+
if(['auto', 'light', 'dark'].includes(theme)) this.editorTheme = theme;
|
|
288
|
+
return this;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
copyToClipboard() {
|
|
292
|
+
navigator.clipboard.writeText(this.getValue());
|
|
293
|
+
return this;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
undo() {
|
|
297
|
+
this.monacoEditor?.trigger('toolbar', 'undo');
|
|
298
|
+
return this;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
redo() {
|
|
302
|
+
this.monacoEditor?.trigger('toolbar', 'redo');
|
|
303
|
+
return this;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
setWordWrap(enabled) {
|
|
307
|
+
this.wordWrap = enabled;
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
setMinimap(enabled) {
|
|
312
|
+
this.minimapEnabled = enabled;
|
|
313
|
+
return this;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
toggleWordWrap() {
|
|
317
|
+
return this.setWordWrap(!this.wordWrap);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
toggleMinimap() {
|
|
321
|
+
return this.setMinimap(!this.minimapEnabled);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
openFind() {
|
|
325
|
+
this.monacoEditor?.getAction('actions.find')?.run();
|
|
326
|
+
return this;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
increaseFontSize() {
|
|
330
|
+
this.fontSize = Math.min(this.fontSize + 2, 40);
|
|
331
|
+
this.monacoEditor?.updateOptions({ fontSize: this.fontSize });
|
|
332
|
+
return this;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
decreaseFontSize() {
|
|
336
|
+
this.fontSize = Math.max(this.fontSize - 2, 8);
|
|
337
|
+
this.monacoEditor?.updateOptions({ fontSize: this.fontSize });
|
|
338
|
+
return this;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
foldAll() {
|
|
342
|
+
this.monacoEditor?.getAction('editor.foldAll')?.run();
|
|
343
|
+
return this;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
unfoldAll() {
|
|
347
|
+
this.monacoEditor?.getAction('editor.unfoldAll')?.run();
|
|
348
|
+
return this;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
enterFullscreen() {
|
|
352
|
+
this.fullscreen = true;
|
|
353
|
+
document.body.classList.add('no-scroll');
|
|
354
|
+
this.dispatchEvent(new CustomEvent('fullscreen-changed', { detail: { fullscreen: true }, bubbles: true }));
|
|
355
|
+
return this;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
exitFullscreen() {
|
|
359
|
+
this.fullscreen = false;
|
|
360
|
+
document.body.classList.remove('no-scroll');
|
|
361
|
+
this.dispatchEvent(new CustomEvent('fullscreen-changed', { detail: { fullscreen: false }, bubbles: true }));
|
|
362
|
+
return this;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
toggleFullscreen() {
|
|
366
|
+
return this.fullscreen ? this.exitFullscreen() : this.enterFullscreen();
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/*
|
|
370
|
+
Utility Methods
|
|
371
|
+
*/
|
|
372
|
+
resolveMonacoTheme() {
|
|
373
|
+
if(this.editorTheme === 'dark') return 'vs-dark';
|
|
374
|
+
if(this.editorTheme === 'light') return 'vs';
|
|
375
|
+
return getCalculatedTheme() === 'dark' ? 'vs-dark' : 'vs';
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
/*
|
|
381
|
+
Rendering
|
|
382
|
+
*/
|
|
383
|
+
static controlSets = {
|
|
384
|
+
full: {
|
|
385
|
+
topLeft: html`
|
|
386
|
+
<k-cec-group>
|
|
387
|
+
<k-cec-undo></k-cec-undo>
|
|
388
|
+
<k-cec-redo></k-cec-redo>
|
|
389
|
+
</k-cec-group>
|
|
390
|
+
<k-cec-group>
|
|
391
|
+
<k-cec-format-code></k-cec-format-code>
|
|
392
|
+
<k-cec-copy-code></k-cec-copy-code>
|
|
393
|
+
<k-cec-find-replace></k-cec-find-replace>
|
|
394
|
+
</k-cec-group>
|
|
395
|
+
<k-cec-group>
|
|
396
|
+
<k-cec-word-wrap></k-cec-word-wrap>
|
|
397
|
+
<k-cec-minimap></k-cec-minimap>
|
|
398
|
+
<k-cec-fold-all></k-cec-fold-all>
|
|
399
|
+
</k-cec-group>
|
|
400
|
+
<k-cec-font-size></k-cec-font-size>
|
|
401
|
+
`,
|
|
402
|
+
topRight: html`
|
|
403
|
+
<k-cec-language></k-cec-language>
|
|
404
|
+
<k-cec-editor-theme></k-cec-editor-theme>
|
|
405
|
+
<k-cec-fullscreen></k-cec-fullscreen>
|
|
406
|
+
`,
|
|
407
|
+
bottomLeft: null,
|
|
408
|
+
bottomRight: null,
|
|
409
|
+
},
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
static styles = css`
|
|
413
|
+
:host {
|
|
414
|
+
display: flex;
|
|
415
|
+
flex-direction: column;
|
|
416
|
+
gap: 0;
|
|
417
|
+
height: 400px;
|
|
418
|
+
background: var(--c_bg);
|
|
419
|
+
}
|
|
420
|
+
:host([fullscreen]) {
|
|
421
|
+
position: fixed;
|
|
422
|
+
top: 0;
|
|
423
|
+
left: 0;
|
|
424
|
+
width: 100vw;
|
|
425
|
+
height: 100vh;
|
|
426
|
+
z-index: 10000;
|
|
427
|
+
}
|
|
428
|
+
.toolbar-top,
|
|
429
|
+
.toolbar-bottom {
|
|
430
|
+
display: flex;
|
|
431
|
+
align-items: center;
|
|
432
|
+
background: var(--bg-secondary);
|
|
433
|
+
min-height: 40px;
|
|
434
|
+
}
|
|
435
|
+
.toolbar-start {
|
|
436
|
+
display: flex;
|
|
437
|
+
flex-wrap: wrap;
|
|
438
|
+
align-items: center;
|
|
439
|
+
}
|
|
440
|
+
.toolbar-end {
|
|
441
|
+
display: flex;
|
|
442
|
+
flex-wrap: wrap-reverse;
|
|
443
|
+
align-items: center;
|
|
444
|
+
justify-content: flex-end;
|
|
445
|
+
margin-left: auto;
|
|
446
|
+
}
|
|
447
|
+
.editor-container {
|
|
448
|
+
position: relative;
|
|
449
|
+
flex: 1;
|
|
450
|
+
min-height: 0;
|
|
451
|
+
overflow: hidden;
|
|
452
|
+
}
|
|
453
|
+
.monaco-editor-container {
|
|
454
|
+
width: 100%;
|
|
455
|
+
height: 100%;
|
|
456
|
+
box-sizing: border-box;
|
|
457
|
+
overflow: auto;
|
|
458
|
+
border: 1px solid var(--border-color);
|
|
459
|
+
}
|
|
460
|
+
[hidden] {
|
|
461
|
+
display: none !important;
|
|
462
|
+
}
|
|
463
|
+
`;
|
|
464
|
+
|
|
465
|
+
render() {
|
|
466
|
+
const set = this.constructor.controlSets[this.controls] ?? {};
|
|
467
|
+
return html`
|
|
468
|
+
${this.hasTopToolbar ? html`
|
|
469
|
+
<div class="toolbar-top bb">
|
|
470
|
+
<div class="toolbar-start">
|
|
471
|
+
<slot name="toolbar-top-left">${set.topLeft ?? ''}</slot>
|
|
472
|
+
</div>
|
|
473
|
+
<div class="toolbar-end">
|
|
474
|
+
<slot name="toolbar-top-right">${set.topRight ?? ''}</slot>
|
|
475
|
+
</div>
|
|
476
|
+
</div>
|
|
477
|
+
` : ''}
|
|
478
|
+
<div class="editor-container">
|
|
479
|
+
<div class="monaco-editor-container"></div>
|
|
480
|
+
</div>
|
|
481
|
+
${this.hasBottomToolbar ? html`
|
|
482
|
+
<div class="toolbar-bottom bt">
|
|
483
|
+
<div class="toolbar-start">
|
|
484
|
+
<slot name="toolbar-bottom-left">${set.bottomLeft ?? ''}</slot>
|
|
485
|
+
</div>
|
|
486
|
+
<div class="toolbar-end">
|
|
487
|
+
<slot name="toolbar-bottom-right">${set.bottomRight ?? ''}</slot>
|
|
488
|
+
</div>
|
|
489
|
+
</div>
|
|
490
|
+
` : ''}
|
|
491
|
+
`;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
customElements.define('k-code-editor', CodeEditor);
|