@uipath/apollo-wind 2.46.0 → 2.47.0

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 (93) hide show
  1. package/dist/components/ui/avatar.d.ts +1 -1
  2. package/dist/components/ui/badge.d.ts +1 -1
  3. package/dist/components/ui/button.d.ts +2 -2
  4. package/dist/components/ui/command.d.ts +13 -13
  5. package/dist/components/ui/index.cjs +30 -30
  6. package/dist/components/ui/prompt-editor/components/EditorToolbar.cjs +101 -68
  7. package/dist/components/ui/prompt-editor/components/EditorToolbar.d.ts +16 -2
  8. package/dist/components/ui/prompt-editor/components/EditorToolbar.js +101 -68
  9. package/dist/components/ui/prompt-editor/components/MarkdownPreview.cjs +13 -8
  10. package/dist/components/ui/prompt-editor/components/MarkdownPreview.d.ts +13 -1
  11. package/dist/components/ui/prompt-editor/components/MarkdownPreview.js +13 -8
  12. package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.cjs +22 -11
  13. package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.js +23 -12
  14. package/dist/components/ui/prompt-editor/components/TokenPill.cjs +4 -2
  15. package/dist/components/ui/prompt-editor/components/TokenPill.js +4 -2
  16. package/dist/components/ui/prompt-editor/components/TokenPillSlot.cjs +58 -0
  17. package/dist/components/ui/prompt-editor/components/TokenPillSlot.d.ts +7 -0
  18. package/dist/components/ui/prompt-editor/components/TokenPillSlot.js +24 -0
  19. package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.cjs +8 -9
  20. package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.js +8 -9
  21. package/dist/components/ui/prompt-editor/index.cjs +152 -9
  22. package/dist/components/ui/prompt-editor/index.d.ts +13 -1
  23. package/dist/components/ui/prompt-editor/index.js +11 -1
  24. package/dist/components/ui/prompt-editor/nodes/InputTokenNode.cjs +2 -2
  25. package/dist/components/ui/prompt-editor/nodes/InputTokenNode.d.ts +1 -1
  26. package/dist/components/ui/prompt-editor/nodes/InputTokenNode.js +2 -2
  27. package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.cjs +2 -2
  28. package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.d.ts +1 -1
  29. package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.js +2 -2
  30. package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.cjs +2 -2
  31. package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.d.ts +1 -1
  32. package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.js +2 -2
  33. package/dist/components/ui/prompt-editor/nodes/StateTokenNode.cjs +2 -2
  34. package/dist/components/ui/prompt-editor/nodes/StateTokenNode.d.ts +1 -1
  35. package/dist/components/ui/prompt-editor/nodes/StateTokenNode.js +2 -2
  36. package/dist/components/ui/prompt-editor/nodes/index.cjs +1 -1
  37. package/dist/components/ui/prompt-editor/nodes/index.d.ts +5 -5
  38. package/dist/components/ui/prompt-editor/nodes/index.js +1 -1
  39. package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.cjs +11 -5
  40. package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.d.ts +8 -1
  41. package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.js +12 -6
  42. package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.cjs +1 -1
  43. package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.js +1 -1
  44. package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.cjs +1 -1
  45. package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.js +1 -1
  46. package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.cjs +1 -1
  47. package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.js +1 -1
  48. package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.cjs +12 -6
  49. package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.js +13 -7
  50. package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.cjs +64 -3
  51. package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.d.ts +6 -2
  52. package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.js +65 -4
  53. package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.cjs +4 -9
  54. package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.js +4 -9
  55. package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.cjs +10 -5
  56. package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.d.ts +3 -1
  57. package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.js +10 -5
  58. package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.cjs +1 -1
  59. package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.js +2 -2
  60. package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.cjs +10 -1
  61. package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.d.ts +4 -1
  62. package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.js +8 -2
  63. package/dist/components/ui/prompt-editor/prompt-editor-config.cjs +69 -0
  64. package/dist/components/ui/prompt-editor/prompt-editor-config.d.ts +70 -0
  65. package/dist/components/ui/prompt-editor/prompt-editor-config.js +29 -0
  66. package/dist/components/ui/prompt-editor/prompt-editor.cjs +198 -88
  67. package/dist/components/ui/prompt-editor/prompt-editor.d.ts +46 -1
  68. package/dist/components/ui/prompt-editor/prompt-editor.js +199 -89
  69. package/dist/components/ui/prompt-editor/types.cjs +5 -5
  70. package/dist/components/ui/prompt-editor/types.d.ts +18 -2
  71. package/dist/components/ui/prompt-editor/types.js +5 -5
  72. package/dist/components/ui/prompt-editor/utils/autocomplete-segments.cjs +10 -5
  73. package/dist/components/ui/prompt-editor/utils/autocomplete-segments.d.ts +13 -0
  74. package/dist/components/ui/prompt-editor/utils/autocomplete-segments.js +8 -6
  75. package/dist/components/ui/prompt-editor/utils/index.cjs +1 -1
  76. package/dist/components/ui/prompt-editor/utils/index.d.ts +1 -1
  77. package/dist/components/ui/prompt-editor/utils/index.js +1 -1
  78. package/dist/components/ui/prompt-editor/utils/insert-token.d.ts +1 -1
  79. package/dist/components/ui/prompt-editor/utils/rich-serialization.cjs +186 -0
  80. package/dist/components/ui/prompt-editor/utils/rich-serialization.d.ts +38 -0
  81. package/dist/components/ui/prompt-editor/utils/rich-serialization.js +140 -0
  82. package/dist/components/ui/prompt-editor/utils/serialization.cjs +13 -5
  83. package/dist/components/ui/prompt-editor/utils/serialization.js +14 -6
  84. package/dist/components/ui/sheet.d.ts +1 -1
  85. package/dist/components/ui/spinner.d.ts +1 -1
  86. package/dist/components/ui/switch.d.ts +2 -2
  87. package/dist/components/ui/toggle-group.d.ts +2 -2
  88. package/dist/components/ui/toggle.d.ts +2 -2
  89. package/dist/index.cjs +136 -61
  90. package/dist/index.d.ts +89 -89
  91. package/dist/index.js +61 -61
  92. package/dist/styles.css +15 -0
  93. package/package.json +3 -1
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ RICH_EDITOR_EXTRA_NODES: ()=>RICH_EDITOR_EXTRA_NODES,
28
+ $getRichEditorTokensInternal: ()=>$getRichEditorTokensInternal,
29
+ PROMPT_EDITOR_RICH_TRANSFORMERS: ()=>PROMPT_EDITOR_RICH_TRANSFORMERS,
30
+ $setRichEditorTokensInternal: ()=>$setRichEditorTokensInternal,
31
+ normalizeRichTextTokens: ()=>normalizeRichTextTokens
32
+ });
33
+ const list_namespaceObject = require("@lexical/list");
34
+ const markdown_namespaceObject = require("@lexical/markdown");
35
+ const external_lexical_namespaceObject = require("lexical");
36
+ const index_cjs_namespaceObject = require("../nodes/index.cjs");
37
+ const token_nodes_cjs_namespaceObject = require("../plugins/shared/token-nodes.cjs");
38
+ const external_insert_token_cjs_namespaceObject = require("./insert-token.cjs");
39
+ const external_serialization_cjs_namespaceObject = require("./serialization.cjs");
40
+ const PROMPT_EDITOR_RICH_TRANSFORMERS = [
41
+ markdown_namespaceObject.ORDERED_LIST,
42
+ markdown_namespaceObject.UNORDERED_LIST,
43
+ markdown_namespaceObject.BOLD_ITALIC_STAR,
44
+ markdown_namespaceObject.BOLD_ITALIC_UNDERSCORE,
45
+ markdown_namespaceObject.BOLD_STAR,
46
+ markdown_namespaceObject.BOLD_UNDERSCORE,
47
+ markdown_namespaceObject.ITALIC_STAR,
48
+ markdown_namespaceObject.ITALIC_UNDERSCORE,
49
+ markdown_namespaceObject.STRIKETHROUGH
50
+ ];
51
+ const RICH_EDITOR_EXTRA_NODES = [
52
+ list_namespaceObject.ListNode,
53
+ list_namespaceObject.ListItemNode
54
+ ];
55
+ const PILL_SENTINEL_START = '\uE000';
56
+ const PILL_SENTINEL_END = '\uE001';
57
+ const PILL_SENTINEL_IMPORT = /\uE000(\d+)\uE001/;
58
+ const PILL_SENTINEL_SPLIT = /(\uE000\d+\uE001)/;
59
+ const PILL_SENTINEL_ANY = /[\uE000\uE001]/g;
60
+ function createPillImportTransformer(pills) {
61
+ return {
62
+ dependencies: [
63
+ index_cjs_namespaceObject.InputTokenNode,
64
+ index_cjs_namespaceObject.OutputTokenNode,
65
+ index_cjs_namespaceObject.StateTokenNode,
66
+ index_cjs_namespaceObject.ResourceTokenNode
67
+ ],
68
+ importRegExp: PILL_SENTINEL_IMPORT,
69
+ regExp: PILL_SENTINEL_IMPORT,
70
+ replace: (node, match)=>{
71
+ const pill = pills[Number(match[1])];
72
+ if (!pill) return void node.setTextContent('');
73
+ node.replace((0, external_insert_token_cjs_namespaceObject.createTokenNodeForOption)(pill));
74
+ },
75
+ type: 'text-match'
76
+ };
77
+ }
78
+ function createPillExportTransformer(pills) {
79
+ return {
80
+ dependencies: [
81
+ index_cjs_namespaceObject.InputTokenNode,
82
+ index_cjs_namespaceObject.OutputTokenNode,
83
+ index_cjs_namespaceObject.StateTokenNode,
84
+ index_cjs_namespaceObject.ResourceTokenNode
85
+ ],
86
+ regExp: PILL_SENTINEL_IMPORT,
87
+ export: (node)=>{
88
+ if (!(0, token_nodes_cjs_namespaceObject.isPromptTokenNode)(node)) return null;
89
+ const type = token_nodes_cjs_namespaceObject.NODE_TYPE_TO_TOKEN_TYPE[node.getType()];
90
+ if (!type) return null;
91
+ const index = pills.length;
92
+ pills.push({
93
+ type,
94
+ value: node.getValue()
95
+ });
96
+ return `${PILL_SENTINEL_START}${index}${PILL_SENTINEL_END}`;
97
+ },
98
+ type: 'text-match'
99
+ };
100
+ }
101
+ const unescapeMarkdownLiterals = (markdown)=>markdown.replace(/\\([*_`~\\])/g, '$1');
102
+ function $getRichEditorTokensInternal() {
103
+ const pills = [];
104
+ const markdown = (0, markdown_namespaceObject.$convertToMarkdownString)([
105
+ ...PROMPT_EDITOR_RICH_TRANSFORMERS,
106
+ createPillExportTransformer(pills)
107
+ ], void 0, true);
108
+ const tokens = [];
109
+ for (const part of unescapeMarkdownLiterals(markdown).split(PILL_SENTINEL_SPLIT)){
110
+ if ('' === part) continue;
111
+ const pillMatch = PILL_SENTINEL_IMPORT.exec(part);
112
+ if (pillMatch && pillMatch[0] === part) {
113
+ const pill = pills[Number(pillMatch[1])];
114
+ if (pill) tokens.push({
115
+ ...pill
116
+ });
117
+ continue;
118
+ }
119
+ const text = part.split(external_serialization_cjs_namespaceObject.WORD_JOINER).join('');
120
+ if ('' === text) continue;
121
+ const last = tokens[tokens.length - 1];
122
+ if (last && 'text' === last.type) last.value += text;
123
+ else tokens.push({
124
+ type: 'text',
125
+ value: text
126
+ });
127
+ }
128
+ return tokens;
129
+ }
130
+ function $setRichEditorTokensInternal(tokens) {
131
+ const pills = [];
132
+ let markdown = '';
133
+ for (const token of tokens)if ('text' === token.type) markdown += token.value.replace(PILL_SENTINEL_ANY, '');
134
+ else {
135
+ const index = pills.length;
136
+ pills.push({
137
+ type: token.type,
138
+ value: token.value
139
+ });
140
+ markdown += `${PILL_SENTINEL_START}${index}${PILL_SENTINEL_END}`;
141
+ }
142
+ const root = (0, external_lexical_namespaceObject.$getRoot)();
143
+ root.clear();
144
+ (0, markdown_namespaceObject.$convertFromMarkdownString)(markdown, [
145
+ ...PROMPT_EDITOR_RICH_TRANSFORMERS,
146
+ createPillImportTransformer(pills)
147
+ ], root, true);
148
+ }
149
+ function normalizeRichTextTokens(tokens) {
150
+ const editor = (0, external_lexical_namespaceObject.createEditor)({
151
+ namespace: 'PromptEditorRichNormalize',
152
+ nodes: [
153
+ index_cjs_namespaceObject.InputTokenNode,
154
+ index_cjs_namespaceObject.OutputTokenNode,
155
+ index_cjs_namespaceObject.StateTokenNode,
156
+ index_cjs_namespaceObject.ResourceTokenNode,
157
+ ...RICH_EDITOR_EXTRA_NODES
158
+ ],
159
+ onError: (error)=>{
160
+ throw error;
161
+ }
162
+ });
163
+ editor.update(()=>$setRichEditorTokensInternal(tokens), {
164
+ discrete: true
165
+ });
166
+ let result = [];
167
+ editor.read(()=>{
168
+ result = $getRichEditorTokensInternal();
169
+ });
170
+ return result;
171
+ }
172
+ exports.$getRichEditorTokensInternal = __webpack_exports__.$getRichEditorTokensInternal;
173
+ exports.$setRichEditorTokensInternal = __webpack_exports__.$setRichEditorTokensInternal;
174
+ exports.PROMPT_EDITOR_RICH_TRANSFORMERS = __webpack_exports__.PROMPT_EDITOR_RICH_TRANSFORMERS;
175
+ exports.RICH_EDITOR_EXTRA_NODES = __webpack_exports__.RICH_EDITOR_EXTRA_NODES;
176
+ exports.normalizeRichTextTokens = __webpack_exports__.normalizeRichTextTokens;
177
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
178
+ "$getRichEditorTokensInternal",
179
+ "$setRichEditorTokensInternal",
180
+ "PROMPT_EDITOR_RICH_TRANSFORMERS",
181
+ "RICH_EDITOR_EXTRA_NODES",
182
+ "normalizeRichTextTokens"
183
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
184
+ Object.defineProperty(exports, '__esModule', {
185
+ value: true
186
+ });
@@ -0,0 +1,38 @@
1
+ import { ListItemNode, ListNode } from '@lexical/list';
2
+ import { type Transformer } from '@lexical/markdown';
3
+ import type { PromptEditorToken } from '../types';
4
+ /**
5
+ * Rich (WYSIWYG) serialization for the prompt editor: the `PromptEditorToken[]` contract is
6
+ * unchanged — text tokens carry markdown — but in rich mode the editor state holds real formatted
7
+ * nodes, converted through `@lexical/markdown` on the way in and out.
8
+ *
9
+ * Two invariants drive everything here:
10
+ *
11
+ * 1. **`\n` is a visible line break** (the plain editor's convention; previews render with
12
+ * `breaks: true`). Both conversions run with `shouldPreserveNewLines: true` so `a\nb` and
13
+ * `a\n\nb` each round-trip byte-identically instead of being rewritten into paragraph spacing.
14
+ * 2. **Unknown markdown stays literal.** The transformer set is exactly the toolbar's feature set
15
+ * (bold/italic/strikethrough + ordered/bulleted lists). Headings, quotes, code, links, tables
16
+ * pass through as plain text, which is the round-trip-safe behavior.
17
+ */
18
+ /** The toolbar's feature set. Underscore emphasis variants import legacy content; export emits star forms. */
19
+ export declare const PROMPT_EDITOR_RICH_TRANSFORMERS: Transformer[];
20
+ /** Lexical node classes rich mode registers beyond the plain editor's token nodes. */
21
+ export declare const RICH_EDITOR_EXTRA_NODES: (typeof ListNode | typeof ListItemNode)[];
22
+ /**
23
+ * Editor state → tokens. Must be called inside `editor.read()`/`editor.update()`.
24
+ * Formatted content serializes to markdown text tokens; pills come out as typed tokens.
25
+ */
26
+ export declare function $getRichEditorTokensInternal(): PromptEditorToken[];
27
+ /**
28
+ * Tokens → editor state. Must be called inside `editor.update()`. Clears the root and parses the
29
+ * text tokens' markdown into formatted nodes, splicing pills back in as decorator nodes.
30
+ */
31
+ export declare function $setRichEditorTokensInternal(tokens: PromptEditorToken[]): void;
32
+ /**
33
+ * Pure "what will the rich editor re-emit for this seed" — an import→export round-trip through a
34
+ * headless editor. Consumers use it to tell a genuine edit apart from mere markdown normalization
35
+ * (`_em_` → `*em*`, `* item` → `- item`, …) so an untouched open/blur never rewrites a stored
36
+ * value. Deterministic and side-effect free.
37
+ */
38
+ export declare function normalizeRichTextTokens(tokens: PromptEditorToken[]): PromptEditorToken[];
@@ -0,0 +1,140 @@
1
+ import { ListItemNode, ListNode } from "@lexical/list";
2
+ import { $convertFromMarkdownString, $convertToMarkdownString, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, ITALIC_STAR, ITALIC_UNDERSCORE, ORDERED_LIST, STRIKETHROUGH, UNORDERED_LIST } from "@lexical/markdown";
3
+ import { $getRoot, createEditor } from "lexical";
4
+ import { InputTokenNode, OutputTokenNode, ResourceTokenNode, StateTokenNode } from "../nodes/index.js";
5
+ import { NODE_TYPE_TO_TOKEN_TYPE, isPromptTokenNode } from "../plugins/shared/token-nodes.js";
6
+ import { createTokenNodeForOption } from "./insert-token.js";
7
+ import { WORD_JOINER } from "./serialization.js";
8
+ const PROMPT_EDITOR_RICH_TRANSFORMERS = [
9
+ ORDERED_LIST,
10
+ UNORDERED_LIST,
11
+ BOLD_ITALIC_STAR,
12
+ BOLD_ITALIC_UNDERSCORE,
13
+ BOLD_STAR,
14
+ BOLD_UNDERSCORE,
15
+ ITALIC_STAR,
16
+ ITALIC_UNDERSCORE,
17
+ STRIKETHROUGH
18
+ ];
19
+ const RICH_EDITOR_EXTRA_NODES = [
20
+ ListNode,
21
+ ListItemNode
22
+ ];
23
+ const PILL_SENTINEL_START = '\uE000';
24
+ const PILL_SENTINEL_END = '\uE001';
25
+ const PILL_SENTINEL_IMPORT = /\uE000(\d+)\uE001/;
26
+ const PILL_SENTINEL_SPLIT = /(\uE000\d+\uE001)/;
27
+ const PILL_SENTINEL_ANY = /[\uE000\uE001]/g;
28
+ function createPillImportTransformer(pills) {
29
+ return {
30
+ dependencies: [
31
+ InputTokenNode,
32
+ OutputTokenNode,
33
+ StateTokenNode,
34
+ ResourceTokenNode
35
+ ],
36
+ importRegExp: PILL_SENTINEL_IMPORT,
37
+ regExp: PILL_SENTINEL_IMPORT,
38
+ replace: (node, match)=>{
39
+ const pill = pills[Number(match[1])];
40
+ if (!pill) return void node.setTextContent('');
41
+ node.replace(createTokenNodeForOption(pill));
42
+ },
43
+ type: 'text-match'
44
+ };
45
+ }
46
+ function createPillExportTransformer(pills) {
47
+ return {
48
+ dependencies: [
49
+ InputTokenNode,
50
+ OutputTokenNode,
51
+ StateTokenNode,
52
+ ResourceTokenNode
53
+ ],
54
+ regExp: PILL_SENTINEL_IMPORT,
55
+ export: (node)=>{
56
+ if (!isPromptTokenNode(node)) return null;
57
+ const type = NODE_TYPE_TO_TOKEN_TYPE[node.getType()];
58
+ if (!type) return null;
59
+ const index = pills.length;
60
+ pills.push({
61
+ type,
62
+ value: node.getValue()
63
+ });
64
+ return `${PILL_SENTINEL_START}${index}${PILL_SENTINEL_END}`;
65
+ },
66
+ type: 'text-match'
67
+ };
68
+ }
69
+ const unescapeMarkdownLiterals = (markdown)=>markdown.replace(/\\([*_`~\\])/g, '$1');
70
+ function $getRichEditorTokensInternal() {
71
+ const pills = [];
72
+ const markdown = $convertToMarkdownString([
73
+ ...PROMPT_EDITOR_RICH_TRANSFORMERS,
74
+ createPillExportTransformer(pills)
75
+ ], void 0, true);
76
+ const tokens = [];
77
+ for (const part of unescapeMarkdownLiterals(markdown).split(PILL_SENTINEL_SPLIT)){
78
+ if ('' === part) continue;
79
+ const pillMatch = PILL_SENTINEL_IMPORT.exec(part);
80
+ if (pillMatch && pillMatch[0] === part) {
81
+ const pill = pills[Number(pillMatch[1])];
82
+ if (pill) tokens.push({
83
+ ...pill
84
+ });
85
+ continue;
86
+ }
87
+ const text = part.split(WORD_JOINER).join('');
88
+ if ('' === text) continue;
89
+ const last = tokens[tokens.length - 1];
90
+ if (last && 'text' === last.type) last.value += text;
91
+ else tokens.push({
92
+ type: 'text',
93
+ value: text
94
+ });
95
+ }
96
+ return tokens;
97
+ }
98
+ function $setRichEditorTokensInternal(tokens) {
99
+ const pills = [];
100
+ let markdown = '';
101
+ for (const token of tokens)if ('text' === token.type) markdown += token.value.replace(PILL_SENTINEL_ANY, '');
102
+ else {
103
+ const index = pills.length;
104
+ pills.push({
105
+ type: token.type,
106
+ value: token.value
107
+ });
108
+ markdown += `${PILL_SENTINEL_START}${index}${PILL_SENTINEL_END}`;
109
+ }
110
+ const root = $getRoot();
111
+ root.clear();
112
+ $convertFromMarkdownString(markdown, [
113
+ ...PROMPT_EDITOR_RICH_TRANSFORMERS,
114
+ createPillImportTransformer(pills)
115
+ ], root, true);
116
+ }
117
+ function normalizeRichTextTokens(tokens) {
118
+ const editor = createEditor({
119
+ namespace: 'PromptEditorRichNormalize',
120
+ nodes: [
121
+ InputTokenNode,
122
+ OutputTokenNode,
123
+ StateTokenNode,
124
+ ResourceTokenNode,
125
+ ...RICH_EDITOR_EXTRA_NODES
126
+ ],
127
+ onError: (error)=>{
128
+ throw error;
129
+ }
130
+ });
131
+ editor.update(()=>$setRichEditorTokensInternal(tokens), {
132
+ discrete: true
133
+ });
134
+ let result = [];
135
+ editor.read(()=>{
136
+ result = $getRichEditorTokensInternal();
137
+ });
138
+ return result;
139
+ }
140
+ export { $getRichEditorTokensInternal, $setRichEditorTokensInternal, PROMPT_EDITOR_RICH_TRANSFORMERS, RICH_EDITOR_EXTRA_NODES, normalizeRichTextTokens };
@@ -191,14 +191,22 @@ const getEditorTokensFromSelection = (selection)=>{
191
191
  if (0 === nodesToProcess.length) return [];
192
192
  const firstSelectedNode = nodesToProcess[0];
193
193
  const isForward = 1 === nodesToProcess.length ? anchorOffset <= focusOffset : firstSelectedNode.getKey() === anchorKey || firstSelectedNode.getParent()?.getKey() === anchorKey;
194
- let prevNodeParagraph = null;
194
+ const blockOf = (node)=>{
195
+ let current = node;
196
+ while(current){
197
+ if ((0, external_lexical_namespaceObject.$isElementNode)(current) && !current.isInline()) return current;
198
+ current = current.getParent();
199
+ }
200
+ return null;
201
+ };
202
+ let prevNodeBlock = null;
195
203
  for (const node of nodesToProcess){
196
204
  const nodeKey = node.getKey();
197
205
  const nodeType = node.getType();
198
- const nodeParagraph = (0, external_lexical_namespaceObject.$isParagraphNode)(node) ? node : node.getParent();
199
- if (prevNodeParagraph && nodeParagraph && prevNodeParagraph !== nodeParagraph) addText('\n');
200
- prevNodeParagraph = nodeParagraph;
201
- if (!(0, external_lexical_namespaceObject.$isParagraphNode)(node)) {
206
+ const nodeBlock = blockOf(node);
207
+ if (prevNodeBlock && nodeBlock && prevNodeBlock !== nodeBlock) addText('\n');
208
+ prevNodeBlock = nodeBlock;
209
+ if (!(0, external_lexical_namespaceObject.$isElementNode)(node)) {
202
210
  if ('input-token' === nodeType) tokens.push({
203
211
  type: 'input',
204
212
  value: node.getValue()
@@ -1,4 +1,4 @@
1
- import { $createLineBreakNode, $createParagraphNode, $createTextNode, $getRoot, $isLineBreakNode, $isParagraphNode, $isRangeSelection, $isTextNode } from "lexical";
1
+ import { $createLineBreakNode, $createParagraphNode, $createTextNode, $getRoot, $isElementNode, $isLineBreakNode, $isParagraphNode, $isRangeSelection, $isTextNode } from "lexical";
2
2
  import { createInputTokenNode, createOutputTokenNode, createResourceTokenNode, createStateTokenNode, isInputTokenNode, isOutputTokenNode, isResourceTokenNode, isStateTokenNode } from "../nodes/index.js";
3
3
  const WORD_JOINER = '\u2060';
4
4
  const appendTextToken = (tokens, raw)=>{
@@ -156,14 +156,22 @@ const getEditorTokensFromSelection = (selection)=>{
156
156
  if (0 === nodesToProcess.length) return [];
157
157
  const firstSelectedNode = nodesToProcess[0];
158
158
  const isForward = 1 === nodesToProcess.length ? anchorOffset <= focusOffset : firstSelectedNode.getKey() === anchorKey || firstSelectedNode.getParent()?.getKey() === anchorKey;
159
- let prevNodeParagraph = null;
159
+ const blockOf = (node)=>{
160
+ let current = node;
161
+ while(current){
162
+ if ($isElementNode(current) && !current.isInline()) return current;
163
+ current = current.getParent();
164
+ }
165
+ return null;
166
+ };
167
+ let prevNodeBlock = null;
160
168
  for (const node of nodesToProcess){
161
169
  const nodeKey = node.getKey();
162
170
  const nodeType = node.getType();
163
- const nodeParagraph = $isParagraphNode(node) ? node : node.getParent();
164
- if (prevNodeParagraph && nodeParagraph && prevNodeParagraph !== nodeParagraph) addText('\n');
165
- prevNodeParagraph = nodeParagraph;
166
- if (!$isParagraphNode(node)) {
171
+ const nodeBlock = blockOf(node);
172
+ if (prevNodeBlock && nodeBlock && prevNodeBlock !== nodeBlock) addText('\n');
173
+ prevNodeBlock = nodeBlock;
174
+ if (!$isElementNode(node)) {
167
175
  if ('input-token' === nodeType) tokens.push({
168
176
  type: 'input',
169
177
  value: node.getValue()
@@ -14,7 +14,7 @@ declare const SheetPortal: {
14
14
  };
15
15
  declare const SheetOverlay: React.ForwardRefExoticComponent<Omit<SheetPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
16
16
  declare const sheetVariants: (props?: ({
17
- side?: "left" | "right" | "bottom" | "top" | null | undefined;
17
+ side?: "left" | "right" | "top" | "bottom" | null | undefined;
18
18
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
19
19
  interface SheetContentProps extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>, VariantProps<typeof sheetVariants> {
20
20
  container?: PortalContainerOverride;
@@ -1,7 +1,7 @@
1
1
  import { type VariantProps } from 'class-variance-authority';
2
2
  import * as React from 'react';
3
3
  declare const spinnerVariants: (props?: ({
4
- size?: "default" | "lg" | "sm" | "xl" | null | undefined;
4
+ size?: "sm" | "lg" | "xl" | "default" | null | undefined;
5
5
  variant?: "default" | "primary" | "foreground" | null | undefined;
6
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
7
  export interface SpinnerProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof spinnerVariants> {
@@ -2,9 +2,9 @@ import * as SwitchPrimitives from '@radix-ui/react-switch';
2
2
  import { type VariantProps } from 'class-variance-authority';
3
3
  import * as React from 'react';
4
4
  declare const switchVariants: (props?: ({
5
- size?: "default" | "sm" | null | undefined;
5
+ size?: "sm" | "default" | null | undefined;
6
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
7
  declare const Switch: React.ForwardRefExoticComponent<Omit<SwitchPrimitives.SwitchProps & React.RefAttributes<HTMLButtonElement>, "ref"> & VariantProps<(props?: ({
8
- size?: "default" | "sm" | null | undefined;
8
+ size?: "sm" | "default" | null | undefined;
9
9
  } & import("class-variance-authority/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLButtonElement>>;
10
10
  export { Switch, switchVariants };
@@ -3,12 +3,12 @@ import { type VariantProps } from 'class-variance-authority';
3
3
  import * as React from 'react';
4
4
  declare const ToggleGroup: React.ForwardRefExoticComponent<((Omit<ToggleGroupPrimitive.ToggleGroupSingleProps & React.RefAttributes<HTMLDivElement>, "ref"> | Omit<ToggleGroupPrimitive.ToggleGroupMultipleProps & React.RefAttributes<HTMLDivElement>, "ref">) & VariantProps<(props?: ({
5
5
  variant?: "default" | "outline" | null | undefined;
6
- size?: "default" | "lg" | "sm" | "xs" | null | undefined;
6
+ size?: "sm" | "lg" | "default" | "xs" | null | undefined;
7
7
  } & import("class-variance-authority/types").ClassProp) | undefined) => string> & {
8
8
  spacing?: number;
9
9
  }) & React.RefAttributes<HTMLDivElement>>;
10
10
  declare const ToggleGroupItem: React.ForwardRefExoticComponent<Omit<ToggleGroupPrimitive.ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & VariantProps<(props?: ({
11
11
  variant?: "default" | "outline" | null | undefined;
12
- size?: "default" | "lg" | "sm" | "xs" | null | undefined;
12
+ size?: "sm" | "lg" | "default" | "xs" | null | undefined;
13
13
  } & import("class-variance-authority/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLButtonElement>>;
14
14
  export { ToggleGroup, ToggleGroupItem };
@@ -3,10 +3,10 @@ import { type VariantProps } from 'class-variance-authority';
3
3
  import * as React from 'react';
4
4
  declare const toggleVariants: (props?: ({
5
5
  variant?: "default" | "outline" | null | undefined;
6
- size?: "default" | "lg" | "sm" | "xs" | null | undefined;
6
+ size?: "sm" | "lg" | "default" | "xs" | null | undefined;
7
7
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
8
  declare const Toggle: React.ForwardRefExoticComponent<Omit<TogglePrimitive.ToggleProps & React.RefAttributes<HTMLButtonElement>, "ref"> & VariantProps<(props?: ({
9
9
  variant?: "default" | "outline" | null | undefined;
10
- size?: "default" | "lg" | "sm" | "xs" | null | undefined;
10
+ size?: "sm" | "lg" | "default" | "xs" | null | undefined;
11
11
  } & import("class-variance-authority/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLButtonElement>>;
12
12
  export { Toggle, toggleVariants };