kempo-ui 0.4.5 → 0.4.7
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/Chat.js +201 -0
- package/dist/components/CodeEditor.js +21 -2
- package/dist/components/Dropdown.js +1 -1
- package/dist/components/HtmlEditor.js +42 -3
- package/dist/components/Markdown.js +1 -0
- package/dist/components/MarkdownEditor.js +173 -0
- package/dist/components/Resize.js +12 -2
- package/dist/components/markdownEditorControls/Bold.js +11 -0
- package/dist/components/markdownEditorControls/BulletList.js +11 -0
- package/dist/components/markdownEditorControls/Code.js +11 -0
- package/dist/components/markdownEditorControls/FormatBlock.js +30 -0
- package/dist/components/markdownEditorControls/Heading.js +11 -0
- package/dist/components/markdownEditorControls/Image.js +93 -0
- package/dist/components/markdownEditorControls/Italic.js +11 -0
- package/dist/components/markdownEditorControls/Link.js +11 -0
- package/dist/components/markdownEditorControls/MarkdownEditorControl.js +39 -0
- package/dist/components/markdownEditorControls/Menu.js +30 -0
- package/dist/components/markdownEditorControls/NumberedList.js +11 -0
- package/dist/components/markdownEditorControls/Quote.js +11 -0
- package/dist/components/markdownEditorControls/SpeechToText.js +16 -0
- package/dist/components/markdownEditorControls/Strikethrough.js +11 -0
- package/dist/components/markdownEditorControls/Table.js +80 -0
- package/dist/utils/marked.esm.js +1 -0
- package/dist/utils/renderMarkdown.js +1 -0
- package/dist/utils/sanitizeHtml.js +1 -0
- package/docs/components/accordion.html +16 -0
- package/docs/components/aside.html +16 -0
- package/docs/components/calendar.html +16 -0
- package/docs/components/card.html +16 -0
- package/docs/components/chat.html +719 -0
- package/docs/components/code-editor.html +52 -0
- package/docs/components/color-picker.html +16 -0
- package/docs/components/combobox.html +16 -0
- package/docs/components/content-slider.html +16 -0
- package/docs/components/context.html +16 -0
- package/docs/components/dialog.html +16 -0
- package/docs/components/dropdown.html +16 -0
- package/docs/components/filter-list.html +16 -0
- package/docs/components/focus-capture.html +16 -0
- package/docs/components/html-editor.html +57 -0
- package/docs/components/hybrid-component.html +16 -0
- package/docs/components/icon.html +16 -0
- package/docs/components/import.html +16 -0
- package/docs/components/light-component.html +16 -0
- package/docs/components/markdown-editor.html +928 -0
- package/docs/components/markdown.html +650 -0
- package/docs/components/nav-spacer.html +16 -0
- package/docs/components/nav.html +16 -0
- package/docs/components/photo-viewer.html +16 -0
- package/docs/components/progress.html +16 -0
- package/docs/components/resize.html +19 -0
- package/docs/components/rich-textarea.html +650 -0
- package/docs/components/shadow-component.html +16 -0
- package/docs/components/show-more.html +16 -0
- package/docs/components/slider.html +16 -0
- package/docs/components/sortable.html +16 -0
- package/docs/components/speech-to-text.html +16 -0
- package/docs/components/spinner.html +16 -0
- package/docs/components/split.html +16 -0
- package/docs/components/table.html +16 -0
- package/docs/components/tableControls.html +16 -0
- package/docs/components/tableCustomFields.html +16 -0
- package/docs/components/tableFetchRecords.html +16 -0
- package/docs/components/tableFieldSortHide.html +16 -0
- package/docs/components/tablePagination.html +16 -0
- package/docs/components/tablePlaceholder.html +16 -0
- package/docs/components/tableRecordEditing.html +16 -0
- package/docs/components/tableRecordFiltering.html +16 -0
- package/docs/components/tableRecordHiding.html +16 -0
- package/docs/components/tableRecordSearching.html +16 -0
- package/docs/components/tableRecordSelection.html +16 -0
- package/docs/components/tableRowControls.html +16 -0
- package/docs/components/tableServerSync.html +16 -0
- package/docs/components/tableSorting.html +16 -0
- package/docs/components/tabs.html +16 -0
- package/docs/components/tags.html +16 -0
- package/docs/components/text-to-speech.html +16 -0
- package/docs/components/theme-select.html +16 -0
- package/docs/components/theme-switcher.html +16 -0
- package/docs/components/time.html +16 -0
- package/docs/components/timestamp.html +16 -0
- package/docs/components/toast.html +16 -0
- package/docs/components/toggle.html +16 -0
- package/docs/components/tree.html +16 -0
- package/docs/components/voice-selector.html +16 -0
- package/docs/icons/done_all.svg +1 -0
- package/docs/icons/format_quote.svg +1 -0
- package/docs/icons/format_strikethrough.svg +1 -0
- package/docs/icons/send.svg +1 -0
- package/docs/icons/text_fields.svg +1 -0
- package/docs/index.html +40 -0
- package/docs/src/components/Chat.js +201 -0
- package/docs/src/components/CodeEditor.js +21 -2
- package/docs/src/components/Dropdown.js +1 -1
- package/docs/src/components/HtmlEditor.js +42 -3
- package/docs/src/components/Markdown.js +1 -0
- package/docs/src/components/MarkdownEditor.js +173 -0
- package/docs/src/components/Resize.js +12 -2
- package/docs/src/components/markdownEditorControls/Bold.js +11 -0
- package/docs/src/components/markdownEditorControls/BulletList.js +11 -0
- package/docs/src/components/markdownEditorControls/Code.js +11 -0
- package/docs/src/components/markdownEditorControls/FormatBlock.js +30 -0
- package/docs/src/components/markdownEditorControls/Heading.js +11 -0
- package/docs/src/components/markdownEditorControls/Image.js +93 -0
- package/docs/src/components/markdownEditorControls/Italic.js +11 -0
- package/docs/src/components/markdownEditorControls/Link.js +11 -0
- package/docs/src/components/markdownEditorControls/MarkdownEditorControl.js +39 -0
- package/docs/src/components/markdownEditorControls/Menu.js +30 -0
- package/docs/src/components/markdownEditorControls/NumberedList.js +11 -0
- package/docs/src/components/markdownEditorControls/Quote.js +11 -0
- package/docs/src/components/markdownEditorControls/SpeechToText.js +16 -0
- package/docs/src/components/markdownEditorControls/Strikethrough.js +11 -0
- package/docs/src/components/markdownEditorControls/Table.js +80 -0
- package/docs/src/utils/marked.esm.js +1 -0
- package/docs/src/utils/renderMarkdown.js +1 -0
- package/docs/src/utils/sanitizeHtml.js +1 -0
- package/docs/utils/context.html +16 -0
- package/docs/utils/cookie.html +16 -0
- package/docs/utils/debounce.html +16 -0
- package/docs/utils/drag.html +16 -0
- package/docs/utils/elevation.html +20 -10
- package/docs/utils/formatTimestamp.html +16 -0
- package/docs/utils/object.html +16 -0
- package/docs/utils/propConverters.html +16 -0
- package/docs/utils/sanitizeHtml.html +559 -0
- package/docs/utils/string.html +16 -0
- package/docs/utils/theme.html +16 -0
- package/docs/utils/toTitleCase.html +16 -0
- package/docs/utils/type.html +16 -0
- package/docs/utils/voice.html +16 -0
- package/docs/utils/wait.html +16 -0
- package/docs-src/components/chat.page.html +230 -0
- package/docs-src/components/code-editor.page.html +36 -0
- package/docs-src/components/html-editor.page.html +41 -0
- package/docs-src/components/markdown-editor.page.html +439 -0
- package/docs-src/components/markdown.page.html +161 -0
- package/docs-src/components/resize.page.html +3 -0
- package/docs-src/index.page.html +24 -0
- package/docs-src/nav.fragment.html +16 -0
- package/docs-src/utils/elevation.page.html +4 -10
- package/docs-src/utils/sanitizeHtml.page.html +73 -0
- package/icons/done_all.svg +1 -0
- package/icons/format_quote.svg +1 -0
- package/icons/format_strikethrough.svg +1 -0
- package/icons/send.svg +1 -0
- package/icons/text_fields.svg +1 -0
- package/llms.txt +6 -2
- package/package.json +3 -2
- package/src/components/Chat.js +435 -0
- package/src/components/CodeEditor.js +58 -2
- package/src/components/Dropdown.js +1 -1
- package/src/components/HtmlEditor.js +84 -4
- package/src/components/Markdown.js +125 -0
- package/src/components/MarkdownEditor.js +654 -0
- package/src/components/Resize.js +17 -1
- package/src/components/markdownEditorControls/Bold.js +30 -0
- package/src/components/markdownEditorControls/BulletList.js +30 -0
- package/src/components/markdownEditorControls/Code.js +39 -0
- package/src/components/markdownEditorControls/FormatBlock.js +102 -0
- package/src/components/markdownEditorControls/Heading.js +45 -0
- package/src/components/markdownEditorControls/Image.js +250 -0
- package/src/components/markdownEditorControls/Italic.js +30 -0
- package/src/components/markdownEditorControls/Link.js +74 -0
- package/src/components/markdownEditorControls/MarkdownEditorControl.js +158 -0
- package/src/components/markdownEditorControls/Menu.js +86 -0
- package/src/components/markdownEditorControls/NumberedList.js +69 -0
- package/src/components/markdownEditorControls/Quote.js +30 -0
- package/src/components/markdownEditorControls/SpeechToText.js +65 -0
- package/src/components/markdownEditorControls/Strikethrough.js +35 -0
- package/src/components/markdownEditorControls/Table.js +164 -0
- package/src/utils/marked.esm.js +77 -0
- package/src/utils/renderMarkdown.js +29 -0
- package/src/utils/sanitizeHtml.js +137 -0
- package/tests/components/Chat.browser-test.js +540 -0
- package/tests/components/Markdown.browser-test.js +292 -0
- package/tests/utils/sanitizeHtml.browser-test.js +179 -0
package/docs/utils/theme.html
CHANGED
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
>Calendar<br><small>Component</small></a></k-filter-item>
|
|
68
68
|
<k-filter-item filter-keywords="card components"><a
|
|
69
69
|
href="../components/card.html">Card<br><small>Component</small></a></k-filter-item>
|
|
70
|
+
<k-filter-item filter-keywords="chat message conversation messaging components"><a
|
|
71
|
+
href="../components/chat.html"
|
|
72
|
+
>Chat<br><small>Component</small></a></k-filter-item>
|
|
70
73
|
<k-filter-item filter-keywords="code editor codeeditor monaco components"><a
|
|
71
74
|
href="../components/code-editor.html"
|
|
72
75
|
>Code Editor<br><small>Component</small></a></k-filter-item>
|
|
@@ -95,6 +98,12 @@
|
|
|
95
98
|
<k-filter-item filter-keywords="html editor components"><a
|
|
96
99
|
href="../components/html-editor.html">HTML
|
|
97
100
|
Editor<br><small>Component</small></a></k-filter-item>
|
|
101
|
+
<k-filter-item filter-keywords="markdown render parser marked gfm components"><a
|
|
102
|
+
href="../components/markdown.html"
|
|
103
|
+
>Markdown<br><small>Component</small></a></k-filter-item>
|
|
104
|
+
<k-filter-item filter-keywords="markdown editor markdowneditor write preview marked gfm tables components"><a
|
|
105
|
+
href="../components/markdown-editor.html"
|
|
106
|
+
>Markdown Editor<br><small>Component</small></a></k-filter-item>
|
|
98
107
|
<k-filter-item filter-keywords="icon components"><a
|
|
99
108
|
href="../components/icon.html">Icon<br><small>Component</small></a></k-filter-item>
|
|
100
109
|
<k-filter-item filter-keywords="import components"><a
|
|
@@ -228,6 +237,9 @@
|
|
|
228
237
|
<k-filter-item filter-keywords="propconverters prop converters utils utility"><a
|
|
229
238
|
href="../utils/propConverters.html"
|
|
230
239
|
>propConverters<br><small>Utility</small></a></k-filter-item>
|
|
240
|
+
<k-filter-item filter-keywords="sanitizehtml sanitize html xss security utils utility"><a
|
|
241
|
+
href="../utils/sanitizeHtml.html"
|
|
242
|
+
>sanitizeHtml<br><small>Utility</small></a></k-filter-item>
|
|
231
243
|
<k-filter-item filter-keywords="string utils utility"><a
|
|
232
244
|
href="../utils/string.html">string<br><small>Utility</small></a></k-filter-item>
|
|
233
245
|
<k-filter-item filter-keywords="theme utils utility"><a
|
|
@@ -288,6 +300,7 @@
|
|
|
288
300
|
<a href="../components/aside.html">Aside</a>
|
|
289
301
|
<a href="../components/calendar.html">Calendar</a>
|
|
290
302
|
<a href="../components/card.html">Card</a>
|
|
303
|
+
<a href="../components/chat.html">Chat</a>
|
|
291
304
|
<a href="../components/code-editor.html">Code Editor</a>
|
|
292
305
|
<a href="../components/combobox.html">Combobox</a>
|
|
293
306
|
<a href="../components/color-picker.html">ColorPicker</a>
|
|
@@ -298,6 +311,8 @@
|
|
|
298
311
|
<a href="../components/filter-list.html">Filter List</a>
|
|
299
312
|
<a href="../components/focus-capture.html">FocusCapture</a>
|
|
300
313
|
<a href="../components/html-editor.html">HTML Editor</a>
|
|
314
|
+
<a href="../components/markdown.html">Markdown</a>
|
|
315
|
+
<a href="../components/markdown-editor.html">Markdown Editor</a>
|
|
301
316
|
<a href="../components/icon.html">Icon</a>
|
|
302
317
|
<a href="../components/import.html">Import</a>
|
|
303
318
|
<a href="../components/nav.html">Nav</a>
|
|
@@ -342,6 +357,7 @@
|
|
|
342
357
|
<a href="../utils/formatTimestamp.html">formatTimestamp</a>
|
|
343
358
|
<a href="../utils/object.html">object</a>
|
|
344
359
|
<a href="../utils/propConverters.html">propConverters</a>
|
|
360
|
+
<a href="../utils/sanitizeHtml.html">sanitizeHtml</a>
|
|
345
361
|
<a href="../utils/string.html">string</a>
|
|
346
362
|
<a href="../utils/theme.html">theme</a>
|
|
347
363
|
<a href="../utils/type.html">type</a>
|
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
>Calendar<br><small>Component</small></a></k-filter-item>
|
|
68
68
|
<k-filter-item filter-keywords="card components"><a
|
|
69
69
|
href="../components/card.html">Card<br><small>Component</small></a></k-filter-item>
|
|
70
|
+
<k-filter-item filter-keywords="chat message conversation messaging components"><a
|
|
71
|
+
href="../components/chat.html"
|
|
72
|
+
>Chat<br><small>Component</small></a></k-filter-item>
|
|
70
73
|
<k-filter-item filter-keywords="code editor codeeditor monaco components"><a
|
|
71
74
|
href="../components/code-editor.html"
|
|
72
75
|
>Code Editor<br><small>Component</small></a></k-filter-item>
|
|
@@ -95,6 +98,12 @@
|
|
|
95
98
|
<k-filter-item filter-keywords="html editor components"><a
|
|
96
99
|
href="../components/html-editor.html">HTML
|
|
97
100
|
Editor<br><small>Component</small></a></k-filter-item>
|
|
101
|
+
<k-filter-item filter-keywords="markdown render parser marked gfm components"><a
|
|
102
|
+
href="../components/markdown.html"
|
|
103
|
+
>Markdown<br><small>Component</small></a></k-filter-item>
|
|
104
|
+
<k-filter-item filter-keywords="markdown editor markdowneditor write preview marked gfm tables components"><a
|
|
105
|
+
href="../components/markdown-editor.html"
|
|
106
|
+
>Markdown Editor<br><small>Component</small></a></k-filter-item>
|
|
98
107
|
<k-filter-item filter-keywords="icon components"><a
|
|
99
108
|
href="../components/icon.html">Icon<br><small>Component</small></a></k-filter-item>
|
|
100
109
|
<k-filter-item filter-keywords="import components"><a
|
|
@@ -228,6 +237,9 @@
|
|
|
228
237
|
<k-filter-item filter-keywords="propconverters prop converters utils utility"><a
|
|
229
238
|
href="../utils/propConverters.html"
|
|
230
239
|
>propConverters<br><small>Utility</small></a></k-filter-item>
|
|
240
|
+
<k-filter-item filter-keywords="sanitizehtml sanitize html xss security utils utility"><a
|
|
241
|
+
href="../utils/sanitizeHtml.html"
|
|
242
|
+
>sanitizeHtml<br><small>Utility</small></a></k-filter-item>
|
|
231
243
|
<k-filter-item filter-keywords="string utils utility"><a
|
|
232
244
|
href="../utils/string.html">string<br><small>Utility</small></a></k-filter-item>
|
|
233
245
|
<k-filter-item filter-keywords="theme utils utility"><a
|
|
@@ -288,6 +300,7 @@
|
|
|
288
300
|
<a href="../components/aside.html">Aside</a>
|
|
289
301
|
<a href="../components/calendar.html">Calendar</a>
|
|
290
302
|
<a href="../components/card.html">Card</a>
|
|
303
|
+
<a href="../components/chat.html">Chat</a>
|
|
291
304
|
<a href="../components/code-editor.html">Code Editor</a>
|
|
292
305
|
<a href="../components/combobox.html">Combobox</a>
|
|
293
306
|
<a href="../components/color-picker.html">ColorPicker</a>
|
|
@@ -298,6 +311,8 @@
|
|
|
298
311
|
<a href="../components/filter-list.html">Filter List</a>
|
|
299
312
|
<a href="../components/focus-capture.html">FocusCapture</a>
|
|
300
313
|
<a href="../components/html-editor.html">HTML Editor</a>
|
|
314
|
+
<a href="../components/markdown.html">Markdown</a>
|
|
315
|
+
<a href="../components/markdown-editor.html">Markdown Editor</a>
|
|
301
316
|
<a href="../components/icon.html">Icon</a>
|
|
302
317
|
<a href="../components/import.html">Import</a>
|
|
303
318
|
<a href="../components/nav.html">Nav</a>
|
|
@@ -342,6 +357,7 @@
|
|
|
342
357
|
<a href="../utils/formatTimestamp.html">formatTimestamp</a>
|
|
343
358
|
<a href="../utils/object.html">object</a>
|
|
344
359
|
<a href="../utils/propConverters.html">propConverters</a>
|
|
360
|
+
<a href="../utils/sanitizeHtml.html">sanitizeHtml</a>
|
|
345
361
|
<a href="../utils/string.html">string</a>
|
|
346
362
|
<a href="../utils/theme.html">theme</a>
|
|
347
363
|
<a href="../utils/type.html">type</a>
|
package/docs/utils/type.html
CHANGED
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
>Calendar<br><small>Component</small></a></k-filter-item>
|
|
68
68
|
<k-filter-item filter-keywords="card components"><a
|
|
69
69
|
href="../components/card.html">Card<br><small>Component</small></a></k-filter-item>
|
|
70
|
+
<k-filter-item filter-keywords="chat message conversation messaging components"><a
|
|
71
|
+
href="../components/chat.html"
|
|
72
|
+
>Chat<br><small>Component</small></a></k-filter-item>
|
|
70
73
|
<k-filter-item filter-keywords="code editor codeeditor monaco components"><a
|
|
71
74
|
href="../components/code-editor.html"
|
|
72
75
|
>Code Editor<br><small>Component</small></a></k-filter-item>
|
|
@@ -95,6 +98,12 @@
|
|
|
95
98
|
<k-filter-item filter-keywords="html editor components"><a
|
|
96
99
|
href="../components/html-editor.html">HTML
|
|
97
100
|
Editor<br><small>Component</small></a></k-filter-item>
|
|
101
|
+
<k-filter-item filter-keywords="markdown render parser marked gfm components"><a
|
|
102
|
+
href="../components/markdown.html"
|
|
103
|
+
>Markdown<br><small>Component</small></a></k-filter-item>
|
|
104
|
+
<k-filter-item filter-keywords="markdown editor markdowneditor write preview marked gfm tables components"><a
|
|
105
|
+
href="../components/markdown-editor.html"
|
|
106
|
+
>Markdown Editor<br><small>Component</small></a></k-filter-item>
|
|
98
107
|
<k-filter-item filter-keywords="icon components"><a
|
|
99
108
|
href="../components/icon.html">Icon<br><small>Component</small></a></k-filter-item>
|
|
100
109
|
<k-filter-item filter-keywords="import components"><a
|
|
@@ -228,6 +237,9 @@
|
|
|
228
237
|
<k-filter-item filter-keywords="propconverters prop converters utils utility"><a
|
|
229
238
|
href="../utils/propConverters.html"
|
|
230
239
|
>propConverters<br><small>Utility</small></a></k-filter-item>
|
|
240
|
+
<k-filter-item filter-keywords="sanitizehtml sanitize html xss security utils utility"><a
|
|
241
|
+
href="../utils/sanitizeHtml.html"
|
|
242
|
+
>sanitizeHtml<br><small>Utility</small></a></k-filter-item>
|
|
231
243
|
<k-filter-item filter-keywords="string utils utility"><a
|
|
232
244
|
href="../utils/string.html">string<br><small>Utility</small></a></k-filter-item>
|
|
233
245
|
<k-filter-item filter-keywords="theme utils utility"><a
|
|
@@ -288,6 +300,7 @@
|
|
|
288
300
|
<a href="../components/aside.html">Aside</a>
|
|
289
301
|
<a href="../components/calendar.html">Calendar</a>
|
|
290
302
|
<a href="../components/card.html">Card</a>
|
|
303
|
+
<a href="../components/chat.html">Chat</a>
|
|
291
304
|
<a href="../components/code-editor.html">Code Editor</a>
|
|
292
305
|
<a href="../components/combobox.html">Combobox</a>
|
|
293
306
|
<a href="../components/color-picker.html">ColorPicker</a>
|
|
@@ -298,6 +311,8 @@
|
|
|
298
311
|
<a href="../components/filter-list.html">Filter List</a>
|
|
299
312
|
<a href="../components/focus-capture.html">FocusCapture</a>
|
|
300
313
|
<a href="../components/html-editor.html">HTML Editor</a>
|
|
314
|
+
<a href="../components/markdown.html">Markdown</a>
|
|
315
|
+
<a href="../components/markdown-editor.html">Markdown Editor</a>
|
|
301
316
|
<a href="../components/icon.html">Icon</a>
|
|
302
317
|
<a href="../components/import.html">Import</a>
|
|
303
318
|
<a href="../components/nav.html">Nav</a>
|
|
@@ -342,6 +357,7 @@
|
|
|
342
357
|
<a href="../utils/formatTimestamp.html">formatTimestamp</a>
|
|
343
358
|
<a href="../utils/object.html">object</a>
|
|
344
359
|
<a href="../utils/propConverters.html">propConverters</a>
|
|
360
|
+
<a href="../utils/sanitizeHtml.html">sanitizeHtml</a>
|
|
345
361
|
<a href="../utils/string.html">string</a>
|
|
346
362
|
<a href="../utils/theme.html">theme</a>
|
|
347
363
|
<a href="../utils/type.html">type</a>
|
package/docs/utils/voice.html
CHANGED
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
>Calendar<br><small>Component</small></a></k-filter-item>
|
|
68
68
|
<k-filter-item filter-keywords="card components"><a
|
|
69
69
|
href="../components/card.html">Card<br><small>Component</small></a></k-filter-item>
|
|
70
|
+
<k-filter-item filter-keywords="chat message conversation messaging components"><a
|
|
71
|
+
href="../components/chat.html"
|
|
72
|
+
>Chat<br><small>Component</small></a></k-filter-item>
|
|
70
73
|
<k-filter-item filter-keywords="code editor codeeditor monaco components"><a
|
|
71
74
|
href="../components/code-editor.html"
|
|
72
75
|
>Code Editor<br><small>Component</small></a></k-filter-item>
|
|
@@ -95,6 +98,12 @@
|
|
|
95
98
|
<k-filter-item filter-keywords="html editor components"><a
|
|
96
99
|
href="../components/html-editor.html">HTML
|
|
97
100
|
Editor<br><small>Component</small></a></k-filter-item>
|
|
101
|
+
<k-filter-item filter-keywords="markdown render parser marked gfm components"><a
|
|
102
|
+
href="../components/markdown.html"
|
|
103
|
+
>Markdown<br><small>Component</small></a></k-filter-item>
|
|
104
|
+
<k-filter-item filter-keywords="markdown editor markdowneditor write preview marked gfm tables components"><a
|
|
105
|
+
href="../components/markdown-editor.html"
|
|
106
|
+
>Markdown Editor<br><small>Component</small></a></k-filter-item>
|
|
98
107
|
<k-filter-item filter-keywords="icon components"><a
|
|
99
108
|
href="../components/icon.html">Icon<br><small>Component</small></a></k-filter-item>
|
|
100
109
|
<k-filter-item filter-keywords="import components"><a
|
|
@@ -228,6 +237,9 @@
|
|
|
228
237
|
<k-filter-item filter-keywords="propconverters prop converters utils utility"><a
|
|
229
238
|
href="../utils/propConverters.html"
|
|
230
239
|
>propConverters<br><small>Utility</small></a></k-filter-item>
|
|
240
|
+
<k-filter-item filter-keywords="sanitizehtml sanitize html xss security utils utility"><a
|
|
241
|
+
href="../utils/sanitizeHtml.html"
|
|
242
|
+
>sanitizeHtml<br><small>Utility</small></a></k-filter-item>
|
|
231
243
|
<k-filter-item filter-keywords="string utils utility"><a
|
|
232
244
|
href="../utils/string.html">string<br><small>Utility</small></a></k-filter-item>
|
|
233
245
|
<k-filter-item filter-keywords="theme utils utility"><a
|
|
@@ -288,6 +300,7 @@
|
|
|
288
300
|
<a href="../components/aside.html">Aside</a>
|
|
289
301
|
<a href="../components/calendar.html">Calendar</a>
|
|
290
302
|
<a href="../components/card.html">Card</a>
|
|
303
|
+
<a href="../components/chat.html">Chat</a>
|
|
291
304
|
<a href="../components/code-editor.html">Code Editor</a>
|
|
292
305
|
<a href="../components/combobox.html">Combobox</a>
|
|
293
306
|
<a href="../components/color-picker.html">ColorPicker</a>
|
|
@@ -298,6 +311,8 @@
|
|
|
298
311
|
<a href="../components/filter-list.html">Filter List</a>
|
|
299
312
|
<a href="../components/focus-capture.html">FocusCapture</a>
|
|
300
313
|
<a href="../components/html-editor.html">HTML Editor</a>
|
|
314
|
+
<a href="../components/markdown.html">Markdown</a>
|
|
315
|
+
<a href="../components/markdown-editor.html">Markdown Editor</a>
|
|
301
316
|
<a href="../components/icon.html">Icon</a>
|
|
302
317
|
<a href="../components/import.html">Import</a>
|
|
303
318
|
<a href="../components/nav.html">Nav</a>
|
|
@@ -342,6 +357,7 @@
|
|
|
342
357
|
<a href="../utils/formatTimestamp.html">formatTimestamp</a>
|
|
343
358
|
<a href="../utils/object.html">object</a>
|
|
344
359
|
<a href="../utils/propConverters.html">propConverters</a>
|
|
360
|
+
<a href="../utils/sanitizeHtml.html">sanitizeHtml</a>
|
|
345
361
|
<a href="../utils/string.html">string</a>
|
|
346
362
|
<a href="../utils/theme.html">theme</a>
|
|
347
363
|
<a href="../utils/type.html">type</a>
|
package/docs/utils/wait.html
CHANGED
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
>Calendar<br><small>Component</small></a></k-filter-item>
|
|
68
68
|
<k-filter-item filter-keywords="card components"><a
|
|
69
69
|
href="../components/card.html">Card<br><small>Component</small></a></k-filter-item>
|
|
70
|
+
<k-filter-item filter-keywords="chat message conversation messaging components"><a
|
|
71
|
+
href="../components/chat.html"
|
|
72
|
+
>Chat<br><small>Component</small></a></k-filter-item>
|
|
70
73
|
<k-filter-item filter-keywords="code editor codeeditor monaco components"><a
|
|
71
74
|
href="../components/code-editor.html"
|
|
72
75
|
>Code Editor<br><small>Component</small></a></k-filter-item>
|
|
@@ -95,6 +98,12 @@
|
|
|
95
98
|
<k-filter-item filter-keywords="html editor components"><a
|
|
96
99
|
href="../components/html-editor.html">HTML
|
|
97
100
|
Editor<br><small>Component</small></a></k-filter-item>
|
|
101
|
+
<k-filter-item filter-keywords="markdown render parser marked gfm components"><a
|
|
102
|
+
href="../components/markdown.html"
|
|
103
|
+
>Markdown<br><small>Component</small></a></k-filter-item>
|
|
104
|
+
<k-filter-item filter-keywords="markdown editor markdowneditor write preview marked gfm tables components"><a
|
|
105
|
+
href="../components/markdown-editor.html"
|
|
106
|
+
>Markdown Editor<br><small>Component</small></a></k-filter-item>
|
|
98
107
|
<k-filter-item filter-keywords="icon components"><a
|
|
99
108
|
href="../components/icon.html">Icon<br><small>Component</small></a></k-filter-item>
|
|
100
109
|
<k-filter-item filter-keywords="import components"><a
|
|
@@ -228,6 +237,9 @@
|
|
|
228
237
|
<k-filter-item filter-keywords="propconverters prop converters utils utility"><a
|
|
229
238
|
href="../utils/propConverters.html"
|
|
230
239
|
>propConverters<br><small>Utility</small></a></k-filter-item>
|
|
240
|
+
<k-filter-item filter-keywords="sanitizehtml sanitize html xss security utils utility"><a
|
|
241
|
+
href="../utils/sanitizeHtml.html"
|
|
242
|
+
>sanitizeHtml<br><small>Utility</small></a></k-filter-item>
|
|
231
243
|
<k-filter-item filter-keywords="string utils utility"><a
|
|
232
244
|
href="../utils/string.html">string<br><small>Utility</small></a></k-filter-item>
|
|
233
245
|
<k-filter-item filter-keywords="theme utils utility"><a
|
|
@@ -288,6 +300,7 @@
|
|
|
288
300
|
<a href="../components/aside.html">Aside</a>
|
|
289
301
|
<a href="../components/calendar.html">Calendar</a>
|
|
290
302
|
<a href="../components/card.html">Card</a>
|
|
303
|
+
<a href="../components/chat.html">Chat</a>
|
|
291
304
|
<a href="../components/code-editor.html">Code Editor</a>
|
|
292
305
|
<a href="../components/combobox.html">Combobox</a>
|
|
293
306
|
<a href="../components/color-picker.html">ColorPicker</a>
|
|
@@ -298,6 +311,8 @@
|
|
|
298
311
|
<a href="../components/filter-list.html">Filter List</a>
|
|
299
312
|
<a href="../components/focus-capture.html">FocusCapture</a>
|
|
300
313
|
<a href="../components/html-editor.html">HTML Editor</a>
|
|
314
|
+
<a href="../components/markdown.html">Markdown</a>
|
|
315
|
+
<a href="../components/markdown-editor.html">Markdown Editor</a>
|
|
301
316
|
<a href="../components/icon.html">Icon</a>
|
|
302
317
|
<a href="../components/import.html">Import</a>
|
|
303
318
|
<a href="../components/nav.html">Nav</a>
|
|
@@ -342,6 +357,7 @@
|
|
|
342
357
|
<a href="../utils/formatTimestamp.html">formatTimestamp</a>
|
|
343
358
|
<a href="../utils/object.html">object</a>
|
|
344
359
|
<a href="../utils/propConverters.html">propConverters</a>
|
|
360
|
+
<a href="../utils/sanitizeHtml.html">sanitizeHtml</a>
|
|
345
361
|
<a href="../utils/string.html">string</a>
|
|
346
362
|
<a href="../utils/theme.html">theme</a>
|
|
347
363
|
<a href="../utils/type.html">type</a>
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
<page pageName="Chat" title="Chat - Components - Kempo Docs - A Web Components Solution">
|
|
2
|
+
<content>
|
|
3
|
+
<k-accordion persistent-id="toc" class="b r mb">
|
|
4
|
+
<k-accordion-header for-panel="toc-panel">Table of Contents</k-accordion-header>
|
|
5
|
+
<k-accordion-panel name="toc-panel">
|
|
6
|
+
<div class="m pl">
|
|
7
|
+
<h6>Examples</h6>
|
|
8
|
+
<a href="#basicUsage">Basic Usage</a><br />
|
|
9
|
+
<a href="#enterBehavior">Enter Behavior</a><br />
|
|
10
|
+
<a href="#showStatus">Message Status</a><br />
|
|
11
|
+
<a href="#disabled">Disabled</a><br />
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<h6 class="mt"><a href="#jsRef" class="no-link">JavaScript Reference</a></h6>
|
|
15
|
+
<a href="#constructor">Constructor</a><br />
|
|
16
|
+
<a href="#requirements">Requirements</a><br />
|
|
17
|
+
<a href="#properties">Properties</a><br />
|
|
18
|
+
<a href="#methods">Methods</a><br />
|
|
19
|
+
<a href="#cssVariables">CSS Variables</a><br />
|
|
20
|
+
<a href="#events">Events</a><br />
|
|
21
|
+
<a href="#security">Security Notes</a><br />
|
|
22
|
+
</div>
|
|
23
|
+
</k-accordion-panel>
|
|
24
|
+
</k-accordion>
|
|
25
|
+
|
|
26
|
+
<p>A chat-room widget: scrollable history of messages above, a markdown input + Send button below. The input is a <a href="./markdown-editor.html"><code><k-markdown-editor></code></a> — users type markdown (with a Preview tab to see the rendered output before sending), and the message is rendered to HTML via the vendored <a href="https://marked.js.org" target="_blank">marked</a> parser (CommonMark + GFM, including tables and task lists). The rendered HTML runs through <a href="../utils/sanitizeHtml.html"><code>sanitizeHtml</code></a> on its way into the message bubble so any inline HTML the user types is filtered against the allow-list — <code><script></code>, <code><iframe></code>, etc. are always stripped.</p>
|
|
27
|
+
|
|
28
|
+
<h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage</a></h3>
|
|
29
|
+
<p>The component fires a <code>send</code> event when the user submits. Listen for it and call <code>chat.addMessage(...)</code> for incoming replies. Outgoing messages are added automatically.</p>
|
|
30
|
+
<div class="row -mx">
|
|
31
|
+
<div class="col m-span-12 px">
|
|
32
|
+
<k-card label="HTML">
|
|
33
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-chat</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"basicChat"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-chat</span>></span><br><span class="hljs-tag"><<span class="hljs-name">script</span>></span><span class="language-javascript"><br> <span class="hljs-keyword">const</span> chat = <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">getElementById</span>(<span class="hljs-string">'basicChat'</span>);<br> chat.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">'send'</span>, <span class="hljs-function">(<span class="hljs-params">e</span>) =></span> {<br> <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">'Sent:'</span>, e.<span class="hljs-property">detail</span>.<span class="hljs-property">markdown</span>);<br> <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =></span> {<br> chat.<span class="hljs-title function_">addMessage</span>({<br> <span class="hljs-attr">type</span>: <span class="hljs-string">'incoming'</span>,<br> <span class="hljs-attr">html</span>: <span class="hljs-string">'Got it!'</span>,<br> <span class="hljs-attr">sender</span>: <span class="hljs-string">'Bot'</span><br> });<br> }, <span class="hljs-number">500</span>);<br> });<br></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
34
|
+
</k-card>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="col m-span-12 px">
|
|
37
|
+
<k-card label="Output">
|
|
38
|
+
<k-chat id="basicChat"></k-chat>
|
|
39
|
+
<script type="module">
|
|
40
|
+
await customElements.whenDefined('k-chat');
|
|
41
|
+
const chat = document.getElementById('basicChat');
|
|
42
|
+
chat.addMessage({ type: 'incoming', html: 'Welcome — say hi!', sender: 'Bot' });
|
|
43
|
+
chat.addEventListener('send', (e) => {
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
chat.addMessage({
|
|
46
|
+
type: 'incoming',
|
|
47
|
+
html: '<i>Echo:</i> ' + e.detail.html,
|
|
48
|
+
sender: 'Bot'
|
|
49
|
+
});
|
|
50
|
+
}, 500);
|
|
51
|
+
});
|
|
52
|
+
</script>
|
|
53
|
+
</k-card>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<h3 id="enterBehavior"><a href="#enterBehavior" class="no-link">Enter Behavior</a></h3>
|
|
58
|
+
<p>By default the chat matches Slack/Discord/Messages: <strong>Enter sends</strong>, Shift+Enter inserts a newline. Add the <code>enter-newline</code> attribute to flip it — Enter inserts a newline, Shift+Enter sends.</p>
|
|
59
|
+
<div class="row -mx">
|
|
60
|
+
<div class="col m-span-12 px">
|
|
61
|
+
<k-card label="HTML">
|
|
62
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-chat</span> <span class="hljs-attr">enter-newline</span>></span><span class="hljs-tag"></<span class="hljs-name">k-chat</span>></span></code></pre>
|
|
63
|
+
</k-card>
|
|
64
|
+
</div>
|
|
65
|
+
<div class="col m-span-12 px">
|
|
66
|
+
<k-card label="Output">
|
|
67
|
+
<k-chat id="newlineChat" enter-newline></k-chat>
|
|
68
|
+
<script type="module">
|
|
69
|
+
await customElements.whenDefined('k-chat');
|
|
70
|
+
const chat = document.getElementById('newlineChat');
|
|
71
|
+
chat.addMessage({ type: 'incoming', html: 'Enter inserts a newline. Shift+Enter sends.', sender: 'Bot' });
|
|
72
|
+
chat.addEventListener('send', () => {
|
|
73
|
+
setTimeout(() => chat.addMessage({ type: 'incoming', html: '👍', sender: 'Bot' }), 400);
|
|
74
|
+
});
|
|
75
|
+
</script>
|
|
76
|
+
</k-card>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<h3 id="showStatus"><a href="#showStatus" class="no-link">Message Status</a></h3>
|
|
81
|
+
<p>Add <code>show-status</code> and outgoing messages get an iMessage-style status indicator below the bubble. The four statuses are <code>sending</code>, <code>delivered</code>, <code>read</code>, and <code>failed</code>. When the user submits, the message is added with <code>status: 'sending'</code>; advance it via <code>chat.updateMessage(id, { status })</code> as the backend confirms.</p>
|
|
82
|
+
<p>The attribute takes one of two display modes:</p>
|
|
83
|
+
<ul>
|
|
84
|
+
<li><code>show-status</code> or <code>show-status="text"</code> — small grey text labels (<em>Sending…</em>, <em>Delivered</em>, <em>Read</em>, <em>Not Delivered</em>). Default mode.</li>
|
|
85
|
+
<li><code>show-status="icons"</code> — spinner / check / double-check / error icons only.</li>
|
|
86
|
+
</ul>
|
|
87
|
+
<p>Following iMessage convention, the indicator only renders on the <strong>most recent outgoing message</strong> — older delivered/read messages stay clean. <code>sending</code> and <code>failed</code> always show regardless of position so the user knows about in-flight or stuck messages immediately.</p>
|
|
88
|
+
<div class="row -mx">
|
|
89
|
+
<div class="col m-span-12 px">
|
|
90
|
+
<k-card label="HTML">
|
|
91
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-chat</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"ackChat"</span> <span class="hljs-attr">show-status</span>></span><span class="hljs-tag"></<span class="hljs-name">k-chat</span>></span><br><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="language-javascript"><br> <span class="hljs-keyword">await</span> customElements.<span class="hljs-title function_">whenDefined</span>(<span class="hljs-string">'k-chat'</span>);<br> <span class="hljs-keyword">const</span> chat = <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">getElementById</span>(<span class="hljs-string">'ackChat'</span>);<br> chat.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">'send'</span>, <span class="hljs-title function_">async</span> (e) => {<br> <span class="hljs-comment">// Simulate a server round-trip</span><br> <span class="hljs-keyword">await</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Promise</span>(<span class="hljs-function"><span class="hljs-params">r</span> =></span> <span class="hljs-built_in">setTimeout</span>(r, <span class="hljs-number">800</span>));<br> chat.<span class="hljs-title function_">updateMessage</span>(e.<span class="hljs-property">detail</span>.<span class="hljs-property">id</span>, {<br> <span class="hljs-attr">status</span>: <span class="hljs-string">'delivered'</span><br> });<br> <span class="hljs-keyword">await</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Promise</span>(<span class="hljs-function"><span class="hljs-params">r</span> =></span> <span class="hljs-built_in">setTimeout</span>(r, <span class="hljs-number">1200</span>));<br> chat.<span class="hljs-title function_">updateMessage</span>(e.<span class="hljs-property">detail</span>.<span class="hljs-property">id</span>, {<br> <span class="hljs-attr">status</span>: <span class="hljs-string">'read'</span><br> });<br> });<br></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
92
|
+
</k-card>
|
|
93
|
+
</div>
|
|
94
|
+
<div class="col m-span-12 px">
|
|
95
|
+
<k-card label="Output">
|
|
96
|
+
<k-chat id="ackChat" show-status></k-chat>
|
|
97
|
+
<script type="module">
|
|
98
|
+
await customElements.whenDefined('k-chat');
|
|
99
|
+
const chat = document.getElementById('ackChat');
|
|
100
|
+
chat.addEventListener('send', async (e) => {
|
|
101
|
+
await new Promise(r => setTimeout(r, 800));
|
|
102
|
+
chat.updateMessage(e.detail.id, { status: 'delivered' });
|
|
103
|
+
await new Promise(r => setTimeout(r, 1200));
|
|
104
|
+
chat.updateMessage(e.detail.id, { status: 'read' });
|
|
105
|
+
});
|
|
106
|
+
</script>
|
|
107
|
+
</k-card>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<h4>Icon Mode</h4>
|
|
112
|
+
<p>Pass <code>show-status="icons"</code> for compact icon-only badges (spinner / single check / double check / red error) instead of text labels — closer to WhatsApp / Telegram styling.</p>
|
|
113
|
+
<div class="row -mx">
|
|
114
|
+
<div class="col m-span-12 px">
|
|
115
|
+
<k-card label="HTML">
|
|
116
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-chat</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"iconChat"</span> <span class="hljs-attr">show-status</span>=<span class="hljs-string">"icons"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-chat</span>></span><br><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="language-javascript"><br> <span class="hljs-keyword">await</span> customElements.<span class="hljs-title function_">whenDefined</span>(<span class="hljs-string">'k-chat'</span>);<br> <span class="hljs-keyword">const</span> chat = <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">getElementById</span>(<span class="hljs-string">'iconChat'</span>);<br> chat.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">'send'</span>, <span class="hljs-title function_">async</span> (e) => {<br> <span class="hljs-keyword">await</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Promise</span>(<span class="hljs-function"><span class="hljs-params">r</span> =></span> <span class="hljs-built_in">setTimeout</span>(r, <span class="hljs-number">800</span>));<br> chat.<span class="hljs-title function_">updateMessage</span>(e.<span class="hljs-property">detail</span>.<span class="hljs-property">id</span>, {<br> <span class="hljs-attr">status</span>: <span class="hljs-string">'delivered'</span><br> });<br> <span class="hljs-keyword">await</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">Promise</span>(<span class="hljs-function"><span class="hljs-params">r</span> =></span> <span class="hljs-built_in">setTimeout</span>(r, <span class="hljs-number">1200</span>));<br> chat.<span class="hljs-title function_">updateMessage</span>(e.<span class="hljs-property">detail</span>.<span class="hljs-property">id</span>, {<br> <span class="hljs-attr">status</span>: <span class="hljs-string">'read'</span><br> });<br> });<br></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
117
|
+
</k-card>
|
|
118
|
+
</div>
|
|
119
|
+
<div class="col m-span-12 px">
|
|
120
|
+
<k-card label="Output">
|
|
121
|
+
<k-chat id="iconChat" show-status="icons"></k-chat>
|
|
122
|
+
<script type="module">
|
|
123
|
+
await customElements.whenDefined('k-chat');
|
|
124
|
+
const chat = document.getElementById('iconChat');
|
|
125
|
+
chat.addEventListener('send', async (e) => {
|
|
126
|
+
await new Promise(r => setTimeout(r, 800));
|
|
127
|
+
chat.updateMessage(e.detail.id, { status: 'delivered' });
|
|
128
|
+
await new Promise(r => setTimeout(r, 1200));
|
|
129
|
+
chat.updateMessage(e.detail.id, { status: 'read' });
|
|
130
|
+
});
|
|
131
|
+
</script>
|
|
132
|
+
</k-card>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<h3 id="disabled"><a href="#disabled" class="no-link">Disabled</a></h3>
|
|
137
|
+
<p>The <code>disabled</code> attribute prevents user interaction. Useful while waiting for connection or rate-limiting.</p>
|
|
138
|
+
<div class="row -mx">
|
|
139
|
+
<div class="col m-span-12 px">
|
|
140
|
+
<k-card label="HTML">
|
|
141
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-chat</span> <span class="hljs-attr">disabled</span>></span><span class="hljs-tag"></<span class="hljs-name">k-chat</span>></span></code></pre>
|
|
142
|
+
</k-card>
|
|
143
|
+
</div>
|
|
144
|
+
<div class="col m-span-12 px">
|
|
145
|
+
<k-card label="Output">
|
|
146
|
+
<k-chat disabled></k-chat>
|
|
147
|
+
</k-card>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<h2 id="jsRef"><a href="#jsRef" class="no-link">JavaScript Reference</a></h2>
|
|
152
|
+
|
|
153
|
+
<h3 id="constructor"><a href="#constructor" class="no-link">Constructor</a></h3>
|
|
154
|
+
<h6>Extends <a href="./shadow-component.html">ShadowComponent</a></h6>
|
|
155
|
+
<h5><code>new Chat()</code></h5>
|
|
156
|
+
|
|
157
|
+
<h3 id="requirements"><a href="#requirements" class="no-link">Requirements</a></h3>
|
|
158
|
+
<ul>
|
|
159
|
+
<li><a href="./shadow-component.html">ShadowComponent</a></li>
|
|
160
|
+
<li><a href="./markdown-editor.html">MarkdownEditor</a> (used internally for the input)</li>
|
|
161
|
+
<li><a href="../utils/sanitizeHtml.html">sanitizeHtml</a> utility</li>
|
|
162
|
+
</ul>
|
|
163
|
+
|
|
164
|
+
<h3 id="properties"><a href="#properties" class="no-link">Properties</a></h3>
|
|
165
|
+
<h5><code>enterNewline<i>: Boolean</i></code></h5>
|
|
166
|
+
<p>Inverts the default Enter-key behavior. Default is <code>false</code> (Slack-style: Enter sends, Shift+Enter inserts a newline). When <code>true</code>: Enter inserts a newline and Shift+Enter sends. Syncs to <code>enter-newline</code> attribute.</p>
|
|
167
|
+
|
|
168
|
+
<h5><code>showStatus<i>: String</i></code></h5>
|
|
169
|
+
<p>Enables and configures the per-message status indicator. Possible values: <code>null</code>/empty (off, default), <code>"text"</code> (small grey labels — the default mode when the attribute is set without a value), or <code>"icons"</code> (spinner/check/double-check/error glyphs). The indicator only appears on the most recent outgoing message, except for <code>sending</code> and <code>failed</code> which always show. Outgoing messages submitted via the input start as <code>sending</code> — advance them via <code>updateMessage(id, { status })</code> as the backend confirms. Syncs to <code>show-status</code> attribute.</p>
|
|
170
|
+
|
|
171
|
+
<h5><code>placeholder<i>: String</i></code></h5>
|
|
172
|
+
<p>Placeholder text for the input. Default <code>"Type a message..."</code>. Syncs to <code>placeholder</code> attribute.</p>
|
|
173
|
+
|
|
174
|
+
<h5><code>disabled<i>: Boolean</i></code></h5>
|
|
175
|
+
<p>When <code>true</code>, the input and Send button are disabled. Syncs to <code>disabled</code> attribute.</p>
|
|
176
|
+
|
|
177
|
+
<h5><code>messages<i>: Array</i></code> (read-only state)</h5>
|
|
178
|
+
<p>The current array of messages. Each entry is <code>{ id, type, html, status, sender, timestamp }</code>. Don't mutate directly — use the public methods.</p>
|
|
179
|
+
|
|
180
|
+
<h3 id="methods"><a href="#methods" class="no-link">Methods</a></h3>
|
|
181
|
+
<h5><code>addMessage(msg)<i>: string</i></code></h5>
|
|
182
|
+
<p>Append a message and return its <code>id</code>. <code>msg</code> object accepts <code>{ id, type, html, status, sender, timestamp }</code>; missing fields are filled in (auto-generated id, type defaults to <code>"incoming"</code>, etc.). HTML is sanitized.</p>
|
|
183
|
+
|
|
184
|
+
<h5><code>updateMessage(id, updates)<i>: boolean</i></code></h5>
|
|
185
|
+
<p>Update an existing message's <code>html</code>, <code>status</code>, <code>sender</code>, or <code>timestamp</code>. Returns <code>true</code> if a message with that id was found.</p>
|
|
186
|
+
|
|
187
|
+
<h5><code>removeMessage(id)<i>: boolean</i></code></h5>
|
|
188
|
+
<p>Remove a message. Returns <code>true</code> if found.</p>
|
|
189
|
+
|
|
190
|
+
<h5><code>clear()<i>: void</i></code></h5>
|
|
191
|
+
<p>Remove every message.</p>
|
|
192
|
+
|
|
193
|
+
<h5><code>send()<i>: string | null</i></code></h5>
|
|
194
|
+
<p>Programmatically submit whatever is currently in the input. Returns the new outgoing message's <code>id</code>, or <code>null</code> if the input was empty.</p>
|
|
195
|
+
|
|
196
|
+
<h3 id="cssVariables"><a href="#cssVariables" class="no-link">CSS Variables</a></h3>
|
|
197
|
+
<table class="b">
|
|
198
|
+
<thead><tr><th>Variable</th><th>Default</th><th>Description</th></tr></thead>
|
|
199
|
+
<tbody>
|
|
200
|
+
<tr><td><code>--window_min_height</code></td><td><code>16rem</code></td><td>Minimum height of the message window (the chat won't collapse below this even when empty)</td></tr>
|
|
201
|
+
<tr><td><code>--window_max_height</code></td><td><code>32rem</code></td><td>Maximum height of the message window before it scrolls internally</td></tr>
|
|
202
|
+
<tr><td><code>--chat_padding</code></td><td><code>0.5rem</code></td><td>Padding inside both the message window and the input row</td></tr>
|
|
203
|
+
<tr><td><code>--chat_gap</code></td><td><code>0.5rem</code></td><td>Gap between messages and gap between the editor and the Send button</td></tr>
|
|
204
|
+
<tr><td><code>--height</code></td><td><code>13rem</code></td><td>Initial height of the embedded markdown editor; the user can drag the resize handle below it to grow or shrink past this</td></tr>
|
|
205
|
+
<tr><td><code>--message_max_width</code></td><td><code>75%</code></td><td>Max width of a single message bubble</td></tr>
|
|
206
|
+
<tr><td><code>--message_radius</code></td><td><code>1rem</code></td><td>Border radius of message bubbles</td></tr>
|
|
207
|
+
<tr><td><code>--bubble_padding</code></td><td><code>0.5rem 0.75rem</code></td><td>Padding inside bubbles</td></tr>
|
|
208
|
+
<tr><td><code>--bubble_bg__incoming</code></td><td><code>var(--c_bg__alt)</code></td><td>Background color of incoming bubbles</td></tr>
|
|
209
|
+
<tr><td><code>--bubble_bg__outgoing</code></td><td><code>var(--c_primary)</code></td><td>Background color of outgoing bubbles</td></tr>
|
|
210
|
+
<tr><td><code>--bubble_tc__outgoing</code></td><td><code>white</code></td><td>Text color of outgoing bubbles</td></tr>
|
|
211
|
+
</tbody>
|
|
212
|
+
</table>
|
|
213
|
+
|
|
214
|
+
<h3 id="events"><a href="#events" class="no-link">Events</a></h3>
|
|
215
|
+
<h5><code>send</code></h5>
|
|
216
|
+
<p>Fires when the user submits. <code>detail</code> contains <code>{ id, html, markdown }</code> — <code>html</code> is the rendered+sanitized output (the same string used in the bubble) and <code>markdown</code> is the raw source the user typed. The outgoing message is already in the conversation by the time the event fires — if you need to roll it back (e.g. on a network failure), call <code>updateMessage(id, { status: 'failed' })</code> or <code>removeMessage(id)</code>.</p>
|
|
217
|
+
|
|
218
|
+
<h3 id="security"><a href="#security" class="no-link">Security Notes</a></h3>
|
|
219
|
+
<div class="callout warning b r p mb">
|
|
220
|
+
<strong>The frontend sanitization in this component is not a substitute for server-side sanitization.</strong>
|
|
221
|
+
</div>
|
|
222
|
+
<p>Every message that enters the chat (whether from the user's editor, from <code>addMessage()</code>, or from <code>updateMessage()</code>) runs through <a href="../utils/sanitizeHtml.html"><code>sanitizeHtml</code></a> before it is added to the DOM. That strips <code><script></code>, <code><style></code>, <code><iframe></code>, event-handler attributes, and unsafe URL schemes — but it only protects content that flows through this component.</p>
|
|
223
|
+
<p>If you persist messages on a server and rebroadcast them to other users, the server <strong>must</strong> independently sanitize before storing and again before sending. A determined attacker can submit raw HTTP without ever loading your client code.</p>
|
|
224
|
+
</content>
|
|
225
|
+
<content location="scripts">
|
|
226
|
+
<script type="module" src="{{pathToRoot}}src/components/Chat.js"></script>
|
|
227
|
+
<script type="module" src="{{pathToRoot}}src/components/Accordion.js"></script>
|
|
228
|
+
<script type="module" src="{{pathToRoot}}src/components/Card.js"></script>
|
|
229
|
+
</content>
|
|
230
|
+
</page>
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
<a href="#controlsExample">Built-in Controls</a><br />
|
|
10
10
|
<a href="#customControls">Custom Controls</a><br />
|
|
11
11
|
<a href="#height">Setting Height</a><br />
|
|
12
|
+
<a href="#disabled">Disabled / Read-only</a><br />
|
|
12
13
|
<a href="#jsApi">JavaScript API</a><br />
|
|
13
14
|
|
|
14
15
|
<h6 class="mt"><a href="#jsRef" class="no-link">JavaScript Reference</a></h6>
|
|
@@ -100,6 +101,38 @@ console.log(x);"></k-code-editor>
|
|
|
100
101
|
</div>
|
|
101
102
|
</div>
|
|
102
103
|
|
|
104
|
+
<h3 id="disabled"><a href="#disabled" class="no-link">Disabled / Read-only</a></h3>
|
|
105
|
+
<p>The <code>disabled</code> attribute makes the editor non-interactive (Monaco is set to <code>readOnly</code>), mutes the toolbar, fades the host, and excludes the field from form submission. The <code>readonly</code> attribute lets the user select and copy text but not edit; the value is still submitted with the form.</p>
|
|
106
|
+
<div class="row -mx">
|
|
107
|
+
<div class="col m-span-12 px">
|
|
108
|
+
<k-card label="HTML">
|
|
109
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-code-editor</span> <span class="hljs-attr">disabled</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"..."</span>></span><span class="hljs-tag"></<span class="hljs-name">k-code-editor</span>></span><br><span class="hljs-tag"><<span class="hljs-name">k-code-editor</span> <span class="hljs-attr">readonly</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"..."</span>></span><span class="hljs-tag"></<span class="hljs-name">k-code-editor</span>></span></code></pre>
|
|
110
|
+
</k-card>
|
|
111
|
+
</div>
|
|
112
|
+
<div class="col m-span-12 px">
|
|
113
|
+
<k-card label="Output">
|
|
114
|
+
<k-code-editor
|
|
115
|
+
disabled
|
|
116
|
+
language="javascript"
|
|
117
|
+
class="b r mb"
|
|
118
|
+
style="height: 160px"
|
|
119
|
+
value="// This editor is disabled — toolbar is muted, content is locked.
|
|
120
|
+
const x = 42;
|
|
121
|
+
console.log(x);"
|
|
122
|
+
></k-code-editor>
|
|
123
|
+
<k-code-editor
|
|
124
|
+
readonly
|
|
125
|
+
language="javascript"
|
|
126
|
+
class="b r"
|
|
127
|
+
style="height: 160px"
|
|
128
|
+
value="// This editor is read-only — select and copy, just not edit.
|
|
129
|
+
const x = 42;
|
|
130
|
+
console.log(x);"
|
|
131
|
+
></k-code-editor>
|
|
132
|
+
</k-card>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
103
136
|
<h3 id="jsApi"><a href="#jsApi" class="no-link">JavaScript API</a></h3>
|
|
104
137
|
<p>Interact with the editor programmatically:</p>
|
|
105
138
|
<div class="row -mx">
|
|
@@ -127,6 +160,9 @@ console.log(x);"></k-code-editor>
|
|
|
127
160
|
<tr><td><code>controls</code></td><td><code>controls</code></td><td>String</td><td><code>''</code></td><td>Set to <code>'full'</code> for built-in toolbar; <code>'none'</code> or empty for no built-in controls</td></tr>
|
|
128
161
|
<tr><td><code>monacoSrc</code></td><td><code>monaco-src</code></td><td>String</td><td><code>''</code></td><td>Custom Monaco CDN base URL</td></tr>
|
|
129
162
|
<tr><td><code>editorTheme</code></td><td><code>editor-theme</code></td><td>String</td><td><code>'auto'</code></td><td>Theme override: <code>'auto'</code> (matches site theme), <code>'light'</code>, or <code>'dark'</code></td></tr>
|
|
163
|
+
<tr><td><code>disabled</code></td><td><code>disabled</code></td><td>Boolean</td><td><code>false</code></td><td>Editor is non-interactive (Monaco set to <code>readOnly</code>), toolbar is muted, host fades, and the field is excluded from form submission</td></tr>
|
|
164
|
+
<tr><td><code>readonly</code></td><td><code>readonly</code></td><td>Boolean</td><td><code>false</code></td><td>User can select and copy text but not edit (Monaco set to <code>readOnly</code>); value still submitted with the form</td></tr>
|
|
165
|
+
<tr><td><code>required</code></td><td><code>required</code></td><td>Boolean</td><td><code>false</code></td><td>When <code>true</code> and the editor is empty, the element reports a <code>valueMissing</code> validity error</td></tr>
|
|
130
166
|
</tbody>
|
|
131
167
|
</table>
|
|
132
168
|
|