@aleph-alpha/chat-kit 6.4.0 → 6.4.2
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/{CkHistory.vue_vue_type_script_setup_true_lang-B0WUzTHa.js → CkHistory.vue_vue_type_script_setup_true_lang-wu1Zrvgc.js} +76 -14
- package/dist/adapters/responses-api.js +1 -1
- package/dist/chat-kit.css +101 -18
- package/dist/{code-palette-DH_G7mZ5.js → code-palette-BWrZDi47.js} +71 -35
- package/dist/components/base/CkCodeEditor/CkCodeEditor.stories.d.ts +2 -1
- package/dist/components/base/CkCodeEditor/CkCodeEditor.stories.d.ts.map +1 -1
- package/dist/components/base/CkCodeEditor/CkCodeEditor.vue.d.ts +3 -0
- package/dist/components/base/CkCodeEditor/CkCodeEditor.vue.d.ts.map +1 -1
- package/dist/components/base/CkCodeEditor/badgeDecoration.d.ts +2 -2
- package/dist/components/base/CkCodeEditor/createCodeMirror.d.ts +15 -1
- package/dist/components/base/CkCodeEditor/createCodeMirror.d.ts.map +1 -1
- package/dist/components/base/CkCodeEditor/types.d.ts +37 -6
- package/dist/components/base/CkCodeEditor/types.d.ts.map +1 -1
- package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.stories.d.ts +7 -0
- package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.stories.d.ts.map +1 -1
- package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue.d.ts +9 -0
- package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue.d.ts.map +1 -1
- package/dist/components/base/CkMarkdownRenderer/types.d.ts +13 -0
- package/dist/components/base/CkMarkdownRenderer/types.d.ts.map +1 -1
- package/dist/components/base/index.d.ts +1 -1
- package/dist/components/base/index.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/composables/index.js +1 -1
- package/dist/{createCodeMirror-5iswYetS.js → createCodeMirror-BO-TWTzn.js} +27 -9
- package/dist/{createCrepeEditor-C-AQ1w_e.js → createCrepeEditor-BGSlwmKn.js} +4 -4
- package/dist/handlers/index.js +2 -2
- package/dist/helpers/codemirror/theme.d.ts.map +1 -1
- package/dist/helpers/unified/remarkBreaks.d.ts +15 -0
- package/dist/helpers/unified/remarkBreaks.d.ts.map +1 -0
- package/dist/{index-DLjsqQHx.js → index--Yonjzfi.js} +3 -3
- package/dist/{index-Mh3WUU-6.js → index-2YPxXIaf.js} +1 -1
- package/dist/{index-CWp_t8Wl.js → index-B4uqe-fL.js} +2 -2
- package/dist/{index-hEJ_Bavx.js → index-Bfo4U-Al.js} +2 -2
- package/dist/{index-g2X42srv.js → index-Bw39pbRL.js} +3 -3
- package/dist/{index-CIF4qQzR.js → index-CGEgwupi.js} +4 -4
- package/dist/{index-Dbi75pKH.js → index-CZmdzLaU.js} +3 -3
- package/dist/{index-CR2kGrpY.js → index-CeaT_FBl.js} +3 -3
- package/dist/{index-DfLCrnVq.js → index-CefLTKmi.js} +2 -2
- package/dist/{index-CLdXUpL8.js → index-CfVHzirA.js} +5 -5
- package/dist/{index-D0IZW-Up.js → index-CrBanggA.js} +2 -2
- package/dist/{index-BlIc9r0r.js → index-Cx5ThXzs.js} +3 -3
- package/dist/{index-CZFx44C7.js → index-D0DQjdsq.js} +2 -2
- package/dist/{index-DPgw0Cf_.js → index-DH9e_hqJ.js} +2 -2
- package/dist/{index-hbS5PDHj.js → index-DTomeh-p.js} +3 -3
- package/dist/{index-GpSpJ3ti.js → index-DZGfsazg.js} +3 -3
- package/dist/{index-QAs789O5.js → index-DlLnTKv3.js} +2 -2
- package/dist/{index-ABUMl7H3.js → index-DqUiBDRo.js} +3 -3
- package/dist/{index-CFGO7LRz.js → index-GDUM7K5V.js} +2 -2
- package/dist/{index-Db5-PJG-.js → index-Hro6EPZS.js} +2 -2
- package/dist/{index-CG8e3146.js → index-KgumaL1c.js} +1 -1
- package/dist/{index-XZeturb3.js → index-TemHfU1M.js} +3 -3
- package/dist/{index-DKwEe_Tu.js → index-g_Bs6dNr.js} +4 -4
- package/dist/{index-S4ylc8JK.js → index-oO_X5wU0.js} +3 -3
- package/dist/{index-BqWO6mvz.js → index-ptbBQ53d.js} +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/{markdownToPlainText-BOtlQ_BY.js → markdownToPlainText-DN_G-I6g.js} +1 -1
- package/dist/{useChatKitLabels-CatQSpfL.js → useChatKitLabels-DxW0N5U-.js} +1 -1
- package/dist/{useMessageHandler-nnsort0-.js → useMessageHandler-Bkzrdgfj.js} +1 -1
- package/package.json +1 -1
- package/src/components/base/CkCodeEditor/CkCodeEditor.spec.ts +128 -1
- package/src/components/base/CkCodeEditor/CkCodeEditor.stories.ts +13 -1
- package/src/components/base/CkCodeEditor/CkCodeEditor.vue +156 -19
- package/src/components/base/CkCodeEditor/badgeDecoration.ts +2 -2
- package/src/components/base/CkCodeEditor/createCodeMirror.ts +45 -8
- package/src/components/base/CkCodeEditor/types.ts +42 -6
- package/src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.spec.ts +40 -0
- package/src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.stories.ts +31 -0
- package/src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue +3 -0
- package/src/components/base/CkMarkdownRenderer/types.ts +13 -0
- package/src/components/base/CkMilkdownEditor/milkdown-theme.css +6 -3
- package/src/components/base/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/helpers/codemirror/code-palette.css +23 -3
- package/src/helpers/codemirror/theme.ts +44 -8
- package/src/helpers/unified/remarkBreaks.ts +32 -0
- package/src/index.ts +1 -0
|
@@ -31,11 +31,21 @@ export const ckHighlightStyle = HighlightStyle.define([
|
|
|
31
31
|
t.moduleKeyword,
|
|
32
32
|
t.operatorKeyword,
|
|
33
33
|
t.operator,
|
|
34
|
+
// CSS units (`px`, `rem`) are `keyword.other.unit` to a TextMate grammar.
|
|
35
|
+
t.unit,
|
|
34
36
|
],
|
|
35
37
|
color: cssVar('keyword'),
|
|
36
38
|
},
|
|
37
39
|
{
|
|
38
|
-
tag: [
|
|
40
|
+
tag: [
|
|
41
|
+
t.string,
|
|
42
|
+
t.special(t.string),
|
|
43
|
+
t.regexp,
|
|
44
|
+
t.escape,
|
|
45
|
+
t.character,
|
|
46
|
+
// `class="card"` — the quoted value is a string, not a constant.
|
|
47
|
+
t.attributeValue,
|
|
48
|
+
],
|
|
39
49
|
color: cssVar('string'),
|
|
40
50
|
},
|
|
41
51
|
{
|
|
@@ -51,7 +61,8 @@ export const ckHighlightStyle = HighlightStyle.define([
|
|
|
51
61
|
t.definition(t.typeName),
|
|
52
62
|
t.className,
|
|
53
63
|
t.namespace,
|
|
54
|
-
|
|
64
|
+
// `entity.other.attribute-name`, which GitHub colours like any entity.
|
|
65
|
+
t.attributeName,
|
|
55
66
|
],
|
|
56
67
|
color: cssVar('function'),
|
|
57
68
|
},
|
|
@@ -68,19 +79,35 @@ export const ckHighlightStyle = HighlightStyle.define([
|
|
|
68
79
|
t.typeName,
|
|
69
80
|
t.standard(t.typeName),
|
|
70
81
|
t.propertyName,
|
|
71
|
-
|
|
72
|
-
t.
|
|
82
|
+
// `this` / `self` are `variable.language`, which GitHub paints blue.
|
|
83
|
+
t.self,
|
|
84
|
+
// CSS colour literals (`#ff0066`), `constant.other.color-*`.
|
|
85
|
+
t.color,
|
|
86
|
+
// Bare identifiers a grammar cannot classify further — SQL column and
|
|
87
|
+
// table names, for one. Every more specific name tag has its own rule
|
|
88
|
+
// above, so this only catches what would otherwise be unstyled.
|
|
89
|
+
t.name,
|
|
73
90
|
],
|
|
74
91
|
color: cssVar('constant'),
|
|
75
92
|
},
|
|
76
93
|
// A declared property name, which UiCodeBlock renders in the text token.
|
|
77
94
|
{ tag: t.definition(t.propertyName), color: cssVar('property') },
|
|
78
|
-
{ tag:
|
|
95
|
+
{ tag: t.tagName, color: cssVar('tag') },
|
|
96
|
+
// Markdown blockquotes are `markup.quote`, the same green as a tag name.
|
|
97
|
+
{ tag: t.quote, color: cssVar('tag') },
|
|
79
98
|
{
|
|
80
|
-
tag: [
|
|
99
|
+
tag: [
|
|
100
|
+
t.variableName,
|
|
101
|
+
t.punctuation,
|
|
102
|
+
t.bracket,
|
|
103
|
+
t.separator,
|
|
104
|
+
// `<`, `>` and `</` are plain text in the GitHub themes; only the tag
|
|
105
|
+
// name inside them is green.
|
|
106
|
+
t.angleBracket,
|
|
107
|
+
],
|
|
81
108
|
color: cssVar('foreground'),
|
|
82
109
|
},
|
|
83
|
-
{ tag: t.heading, fontWeight: 'bold' },
|
|
110
|
+
{ tag: t.heading, color: cssVar('constant'), fontWeight: 'bold' },
|
|
84
111
|
{ tag: t.strong, fontWeight: 'bold' },
|
|
85
112
|
{ tag: t.emphasis, fontStyle: 'italic' },
|
|
86
113
|
{ tag: t.link, textDecoration: 'underline' },
|
|
@@ -116,7 +143,16 @@ export const ckCodeMirrorTheme: Extension = [
|
|
|
116
143
|
'.cm-gutters': {
|
|
117
144
|
backgroundColor: 'transparent',
|
|
118
145
|
borderRight: 'none',
|
|
119
|
-
color: cssVar('
|
|
146
|
+
color: cssVar('line-number'),
|
|
147
|
+
},
|
|
148
|
+
// `UiCodeBlock` draws its numbers as a 2rem right-aligned column inside the
|
|
149
|
+
// block's 1rem padding, with a 1rem gap before the code. CodeMirror puts
|
|
150
|
+
// the gutter outside `.cm-content`, so the same geometry is expressed as
|
|
151
|
+
// padding on the number cell.
|
|
152
|
+
'.cm-lineNumbers .cm-gutterElement': {
|
|
153
|
+
minWidth: '4rem',
|
|
154
|
+
padding: '0 1rem',
|
|
155
|
+
textAlign: 'right',
|
|
120
156
|
},
|
|
121
157
|
'.cm-activeLineGutter': {
|
|
122
158
|
backgroundColor: 'transparent',
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Plugin } from 'unified';
|
|
2
|
+
import { findAndReplace } from 'mdast-util-find-and-replace';
|
|
3
|
+
|
|
4
|
+
// A newline that a writer typed inside a paragraph. In CommonMark this is a
|
|
5
|
+
// "soft break", which renders as nothing more than whitespace, so two lines
|
|
6
|
+
// typed in an editor arrive as one flowing line. Block structure (paragraphs,
|
|
7
|
+
// list items, code fences) is already separate nodes by the time this runs, so
|
|
8
|
+
// the only newlines left inside `text` nodes are these soft breaks.
|
|
9
|
+
const SOFT_BREAK_RE = /\r?\n/g;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Turns every soft line break into a hard one, so a single press of Enter shows
|
|
13
|
+
* up as a line break rather than being collapsed into the previous line.
|
|
14
|
+
*
|
|
15
|
+
* This is what chat interfaces usually want: people type a message the way they
|
|
16
|
+
* would in any other text box and expect the lines they made to survive. Strict
|
|
17
|
+
* CommonMark instead requires two trailing spaces, a backslash, or a blank line
|
|
18
|
+
* to force a break.
|
|
19
|
+
*
|
|
20
|
+
* `findAndReplace` only visits `text` nodes, so newlines inside code spans and
|
|
21
|
+
* fenced code blocks are untouched and keep their literal meaning.
|
|
22
|
+
*/
|
|
23
|
+
// The tree type is left as unified's default (a unist `Node`) so the published
|
|
24
|
+
// `.d.ts` does not depend on `mdast` types; the cast keeps the call typed.
|
|
25
|
+
export const remarkBreaks: Plugin<[]> = () => {
|
|
26
|
+
return (tree) => {
|
|
27
|
+
findAndReplace(tree as Parameters<typeof findAndReplace>[0], [
|
|
28
|
+
SOFT_BREAK_RE,
|
|
29
|
+
() => ({ type: 'break' }),
|
|
30
|
+
]);
|
|
31
|
+
};
|
|
32
|
+
};
|