@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.
Files changed (80) hide show
  1. package/dist/{CkHistory.vue_vue_type_script_setup_true_lang-B0WUzTHa.js → CkHistory.vue_vue_type_script_setup_true_lang-wu1Zrvgc.js} +76 -14
  2. package/dist/adapters/responses-api.js +1 -1
  3. package/dist/chat-kit.css +101 -18
  4. package/dist/{code-palette-DH_G7mZ5.js → code-palette-BWrZDi47.js} +71 -35
  5. package/dist/components/base/CkCodeEditor/CkCodeEditor.stories.d.ts +2 -1
  6. package/dist/components/base/CkCodeEditor/CkCodeEditor.stories.d.ts.map +1 -1
  7. package/dist/components/base/CkCodeEditor/CkCodeEditor.vue.d.ts +3 -0
  8. package/dist/components/base/CkCodeEditor/CkCodeEditor.vue.d.ts.map +1 -1
  9. package/dist/components/base/CkCodeEditor/badgeDecoration.d.ts +2 -2
  10. package/dist/components/base/CkCodeEditor/createCodeMirror.d.ts +15 -1
  11. package/dist/components/base/CkCodeEditor/createCodeMirror.d.ts.map +1 -1
  12. package/dist/components/base/CkCodeEditor/types.d.ts +37 -6
  13. package/dist/components/base/CkCodeEditor/types.d.ts.map +1 -1
  14. package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.stories.d.ts +7 -0
  15. package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.stories.d.ts.map +1 -1
  16. package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue.d.ts +9 -0
  17. package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue.d.ts.map +1 -1
  18. package/dist/components/base/CkMarkdownRenderer/types.d.ts +13 -0
  19. package/dist/components/base/CkMarkdownRenderer/types.d.ts.map +1 -1
  20. package/dist/components/base/index.d.ts +1 -1
  21. package/dist/components/base/index.d.ts.map +1 -1
  22. package/dist/components/index.d.ts +1 -1
  23. package/dist/components/index.d.ts.map +1 -1
  24. package/dist/components/index.js +1 -1
  25. package/dist/composables/index.js +1 -1
  26. package/dist/{createCodeMirror-5iswYetS.js → createCodeMirror-BO-TWTzn.js} +27 -9
  27. package/dist/{createCrepeEditor-C-AQ1w_e.js → createCrepeEditor-BGSlwmKn.js} +4 -4
  28. package/dist/handlers/index.js +2 -2
  29. package/dist/helpers/codemirror/theme.d.ts.map +1 -1
  30. package/dist/helpers/unified/remarkBreaks.d.ts +15 -0
  31. package/dist/helpers/unified/remarkBreaks.d.ts.map +1 -0
  32. package/dist/{index-DLjsqQHx.js → index--Yonjzfi.js} +3 -3
  33. package/dist/{index-Mh3WUU-6.js → index-2YPxXIaf.js} +1 -1
  34. package/dist/{index-CWp_t8Wl.js → index-B4uqe-fL.js} +2 -2
  35. package/dist/{index-hEJ_Bavx.js → index-Bfo4U-Al.js} +2 -2
  36. package/dist/{index-g2X42srv.js → index-Bw39pbRL.js} +3 -3
  37. package/dist/{index-CIF4qQzR.js → index-CGEgwupi.js} +4 -4
  38. package/dist/{index-Dbi75pKH.js → index-CZmdzLaU.js} +3 -3
  39. package/dist/{index-CR2kGrpY.js → index-CeaT_FBl.js} +3 -3
  40. package/dist/{index-DfLCrnVq.js → index-CefLTKmi.js} +2 -2
  41. package/dist/{index-CLdXUpL8.js → index-CfVHzirA.js} +5 -5
  42. package/dist/{index-D0IZW-Up.js → index-CrBanggA.js} +2 -2
  43. package/dist/{index-BlIc9r0r.js → index-Cx5ThXzs.js} +3 -3
  44. package/dist/{index-CZFx44C7.js → index-D0DQjdsq.js} +2 -2
  45. package/dist/{index-DPgw0Cf_.js → index-DH9e_hqJ.js} +2 -2
  46. package/dist/{index-hbS5PDHj.js → index-DTomeh-p.js} +3 -3
  47. package/dist/{index-GpSpJ3ti.js → index-DZGfsazg.js} +3 -3
  48. package/dist/{index-QAs789O5.js → index-DlLnTKv3.js} +2 -2
  49. package/dist/{index-ABUMl7H3.js → index-DqUiBDRo.js} +3 -3
  50. package/dist/{index-CFGO7LRz.js → index-GDUM7K5V.js} +2 -2
  51. package/dist/{index-Db5-PJG-.js → index-Hro6EPZS.js} +2 -2
  52. package/dist/{index-CG8e3146.js → index-KgumaL1c.js} +1 -1
  53. package/dist/{index-XZeturb3.js → index-TemHfU1M.js} +3 -3
  54. package/dist/{index-DKwEe_Tu.js → index-g_Bs6dNr.js} +4 -4
  55. package/dist/{index-S4ylc8JK.js → index-oO_X5wU0.js} +3 -3
  56. package/dist/{index-BqWO6mvz.js → index-ptbBQ53d.js} +4 -4
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +5 -5
  60. package/dist/{markdownToPlainText-BOtlQ_BY.js → markdownToPlainText-DN_G-I6g.js} +1 -1
  61. package/dist/{useChatKitLabels-CatQSpfL.js → useChatKitLabels-DxW0N5U-.js} +1 -1
  62. package/dist/{useMessageHandler-nnsort0-.js → useMessageHandler-Bkzrdgfj.js} +1 -1
  63. package/package.json +1 -1
  64. package/src/components/base/CkCodeEditor/CkCodeEditor.spec.ts +128 -1
  65. package/src/components/base/CkCodeEditor/CkCodeEditor.stories.ts +13 -1
  66. package/src/components/base/CkCodeEditor/CkCodeEditor.vue +156 -19
  67. package/src/components/base/CkCodeEditor/badgeDecoration.ts +2 -2
  68. package/src/components/base/CkCodeEditor/createCodeMirror.ts +45 -8
  69. package/src/components/base/CkCodeEditor/types.ts +42 -6
  70. package/src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.spec.ts +40 -0
  71. package/src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.stories.ts +31 -0
  72. package/src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue +3 -0
  73. package/src/components/base/CkMarkdownRenderer/types.ts +13 -0
  74. package/src/components/base/CkMilkdownEditor/milkdown-theme.css +6 -3
  75. package/src/components/base/index.ts +1 -0
  76. package/src/components/index.ts +1 -0
  77. package/src/helpers/codemirror/code-palette.css +23 -3
  78. package/src/helpers/codemirror/theme.ts +44 -8
  79. package/src/helpers/unified/remarkBreaks.ts +32 -0
  80. 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: [t.string, t.special(t.string), t.regexp, t.escape, t.character],
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
- t.self,
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
- t.attributeName,
72
- t.attributeValue,
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: [t.tagName, t.angleBracket], color: cssVar('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: [t.variableName, t.punctuation, t.bracket, t.separator],
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('comment'),
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
+ };
package/src/index.ts CHANGED
@@ -148,6 +148,7 @@ export type {
148
148
  CkMilkdownEditorProps,
149
149
  CkCodeEditorEmits,
150
150
  CkCodeEditorExposed,
151
+ CkCodeEditorFadeSurface,
151
152
  CkCodeEditorProps,
152
153
  } from './components';
153
154