@uipath/apollo-wind 2.23.0 → 2.24.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.
- package/dist/components/ui/index.cjs +96 -86
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/components/ui/prompt-editor/components/EditorToolbar.cjs +156 -0
- package/dist/components/ui/prompt-editor/components/EditorToolbar.d.ts +9 -0
- package/dist/components/ui/prompt-editor/components/EditorToolbar.js +122 -0
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.cjs +205 -0
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.d.ts +14 -0
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.js +161 -0
- package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.cjs +194 -0
- package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.d.ts +28 -0
- package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.js +160 -0
- package/dist/components/ui/prompt-editor/components/TokenPill.cjs +119 -0
- package/dist/components/ui/prompt-editor/components/TokenPill.d.ts +15 -0
- package/dist/components/ui/prompt-editor/components/TokenPill.js +85 -0
- package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.cjs +138 -0
- package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.d.ts +13 -0
- package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.js +104 -0
- package/dist/components/ui/prompt-editor/components/token-icon-markup.cjs +138 -0
- package/dist/components/ui/prompt-editor/components/token-icon-markup.d.ts +16 -0
- package/dist/components/ui/prompt-editor/components/token-icon-markup.js +104 -0
- package/dist/components/ui/prompt-editor/index.cjs +40 -0
- package/dist/components/ui/prompt-editor/index.d.ts +4 -0
- package/dist/components/ui/prompt-editor/index.js +3 -0
- package/dist/components/ui/prompt-editor/nodes/InputTokenNode.cjs +145 -0
- package/dist/components/ui/prompt-editor/nodes/InputTokenNode.d.ts +30 -0
- package/dist/components/ui/prompt-editor/nodes/InputTokenNode.js +105 -0
- package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.cjs +145 -0
- package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.d.ts +30 -0
- package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.js +105 -0
- package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.cjs +145 -0
- package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.d.ts +30 -0
- package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.js +105 -0
- package/dist/components/ui/prompt-editor/nodes/StateTokenNode.cjs +145 -0
- package/dist/components/ui/prompt-editor/nodes/StateTokenNode.d.ts +30 -0
- package/dist/components/ui/prompt-editor/nodes/StateTokenNode.js +105 -0
- package/dist/components/ui/prompt-editor/nodes/index.cjs +72 -0
- package/dist/components/ui/prompt-editor/nodes/index.d.ts +8 -0
- package/dist/components/ui/prompt-editor/nodes/index.js +5 -0
- package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.cjs +242 -0
- package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.d.ts +15 -0
- package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.js +208 -0
- package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.cjs +164 -0
- package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.d.ts +1 -0
- package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.js +130 -0
- package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.cjs +50 -0
- package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.d.ts +4 -0
- package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.js +16 -0
- package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.cjs +108 -0
- package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.d.ts +3 -0
- package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.js +74 -0
- package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.cjs +313 -0
- package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.d.ts +7 -0
- package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.js +276 -0
- package/dist/components/ui/prompt-editor/plugins/RenameTokensPlugin.cjs +186 -0
- package/dist/components/ui/prompt-editor/plugins/RenameTokensPlugin.d.ts +7 -0
- package/dist/components/ui/prompt-editor/plugins/RenameTokensPlugin.js +152 -0
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.cjs +132 -0
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.d.ts +7 -0
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.js +98 -0
- package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.cjs +85 -0
- package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.d.ts +4 -0
- package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.js +51 -0
- package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.cjs +98 -0
- package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.d.ts +8 -0
- package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.js +64 -0
- package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.cjs +137 -0
- package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.d.ts +19 -0
- package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.js +100 -0
- package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.cjs +49 -0
- package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.d.ts +8 -0
- package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.js +12 -0
- package/dist/components/ui/prompt-editor/prompt-editor.cjs +402 -0
- package/dist/components/ui/prompt-editor/prompt-editor.d.ts +35 -0
- package/dist/components/ui/prompt-editor/prompt-editor.js +368 -0
- package/dist/components/ui/prompt-editor/types.cjs +74 -0
- package/dist/components/ui/prompt-editor/types.d.ts +58 -0
- package/dist/components/ui/prompt-editor/types.js +31 -0
- package/dist/components/ui/prompt-editor/utils/autocomplete-segments.cjs +60 -0
- package/dist/components/ui/prompt-editor/utils/autocomplete-segments.d.ts +29 -0
- package/dist/components/ui/prompt-editor/utils/autocomplete-segments.js +20 -0
- package/dist/components/ui/prompt-editor/utils/comparison.cjs +39 -0
- package/dist/components/ui/prompt-editor/utils/comparison.d.ts +3 -0
- package/dist/components/ui/prompt-editor/utils/comparison.js +5 -0
- package/dist/components/ui/prompt-editor/utils/index.cjs +68 -0
- package/dist/components/ui/prompt-editor/utils/index.d.ts +3 -0
- package/dist/components/ui/prompt-editor/utils/index.js +4 -0
- package/dist/components/ui/prompt-editor/utils/insert-token.cjs +103 -0
- package/dist/components/ui/prompt-editor/utils/insert-token.d.ts +12 -0
- package/dist/components/ui/prompt-editor/utils/insert-token.js +66 -0
- package/dist/components/ui/prompt-editor/utils/serialization.cjs +255 -0
- package/dist/components/ui/prompt-editor/utils/serialization.d.ts +16 -0
- package/dist/components/ui/prompt-editor/utils/serialization.js +200 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/styles.css +42 -0
- package/dist/tailwind.utilities.css +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
areTokensEqual: ()=>areTokensEqual
|
|
28
|
+
});
|
|
29
|
+
const areTokensEqual = (a, b)=>{
|
|
30
|
+
if (a.length !== b.length) return false;
|
|
31
|
+
return a.every((token, i)=>token.type === b[i].type && token.value === b[i].value);
|
|
32
|
+
};
|
|
33
|
+
exports.areTokensEqual = __webpack_exports__.areTokensEqual;
|
|
34
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
35
|
+
"areTokensEqual"
|
|
36
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
37
|
+
Object.defineProperty(exports, '__esModule', {
|
|
38
|
+
value: true
|
|
39
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
tokensToClipboardString: ()=>external_serialization_cjs_namespaceObject.tokensToClipboardString,
|
|
28
|
+
$setEditorTokensInternal: ()=>external_serialization_cjs_namespaceObject.$setEditorTokensInternal,
|
|
29
|
+
areTokensEqual: ()=>external_comparison_cjs_namespaceObject.areTokensEqual,
|
|
30
|
+
getEditorTokens: ()=>external_serialization_cjs_namespaceObject.getEditorTokens,
|
|
31
|
+
$getEditorTokensInternal: ()=>external_serialization_cjs_namespaceObject.$getEditorTokensInternal,
|
|
32
|
+
$insertTokenAtCursor: ()=>external_insert_token_cjs_namespaceObject.$insertTokenAtCursor,
|
|
33
|
+
clipboardStringToTokens: ()=>external_serialization_cjs_namespaceObject.clipboardStringToTokens,
|
|
34
|
+
getEditorTokensFromSelection: ()=>external_serialization_cjs_namespaceObject.getEditorTokensFromSelection,
|
|
35
|
+
createTokenNodeForOption: ()=>external_insert_token_cjs_namespaceObject.createTokenNodeForOption,
|
|
36
|
+
WORD_JOINER: ()=>external_serialization_cjs_namespaceObject.WORD_JOINER,
|
|
37
|
+
setEditorTokens: ()=>external_serialization_cjs_namespaceObject.setEditorTokens
|
|
38
|
+
});
|
|
39
|
+
const external_serialization_cjs_namespaceObject = require("./serialization.cjs");
|
|
40
|
+
const external_comparison_cjs_namespaceObject = require("./comparison.cjs");
|
|
41
|
+
const external_insert_token_cjs_namespaceObject = require("./insert-token.cjs");
|
|
42
|
+
exports.$getEditorTokensInternal = __webpack_exports__.$getEditorTokensInternal;
|
|
43
|
+
exports.$insertTokenAtCursor = __webpack_exports__.$insertTokenAtCursor;
|
|
44
|
+
exports.$setEditorTokensInternal = __webpack_exports__.$setEditorTokensInternal;
|
|
45
|
+
exports.WORD_JOINER = __webpack_exports__.WORD_JOINER;
|
|
46
|
+
exports.areTokensEqual = __webpack_exports__.areTokensEqual;
|
|
47
|
+
exports.clipboardStringToTokens = __webpack_exports__.clipboardStringToTokens;
|
|
48
|
+
exports.createTokenNodeForOption = __webpack_exports__.createTokenNodeForOption;
|
|
49
|
+
exports.getEditorTokens = __webpack_exports__.getEditorTokens;
|
|
50
|
+
exports.getEditorTokensFromSelection = __webpack_exports__.getEditorTokensFromSelection;
|
|
51
|
+
exports.setEditorTokens = __webpack_exports__.setEditorTokens;
|
|
52
|
+
exports.tokensToClipboardString = __webpack_exports__.tokensToClipboardString;
|
|
53
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
54
|
+
"$getEditorTokensInternal",
|
|
55
|
+
"$insertTokenAtCursor",
|
|
56
|
+
"$setEditorTokensInternal",
|
|
57
|
+
"WORD_JOINER",
|
|
58
|
+
"areTokensEqual",
|
|
59
|
+
"clipboardStringToTokens",
|
|
60
|
+
"createTokenNodeForOption",
|
|
61
|
+
"getEditorTokens",
|
|
62
|
+
"getEditorTokensFromSelection",
|
|
63
|
+
"setEditorTokens",
|
|
64
|
+
"tokensToClipboardString"
|
|
65
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
66
|
+
Object.defineProperty(exports, '__esModule', {
|
|
67
|
+
value: true
|
|
68
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { $getEditorTokensInternal, $setEditorTokensInternal, getEditorTokens, setEditorTokens, tokensToClipboardString, clipboardStringToTokens, getEditorTokensFromSelection, WORD_JOINER, } from './serialization';
|
|
2
|
+
export { areTokensEqual } from './comparison';
|
|
3
|
+
export { $insertTokenAtCursor, createTokenNodeForOption } from './insert-token';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { $getEditorTokensInternal, $setEditorTokensInternal, WORD_JOINER, clipboardStringToTokens, getEditorTokens, getEditorTokensFromSelection, setEditorTokens, tokensToClipboardString } from "./serialization.js";
|
|
2
|
+
import { areTokensEqual } from "./comparison.js";
|
|
3
|
+
import { $insertTokenAtCursor, createTokenNodeForOption } from "./insert-token.js";
|
|
4
|
+
export { $getEditorTokensInternal, $insertTokenAtCursor, $setEditorTokensInternal, WORD_JOINER, areTokensEqual, clipboardStringToTokens, createTokenNodeForOption, getEditorTokens, getEditorTokensFromSelection, setEditorTokens, tokensToClipboardString };
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
createTokenNodeForOption: ()=>createTokenNodeForOption,
|
|
28
|
+
$insertTokenAtCursor: ()=>$insertTokenAtCursor
|
|
29
|
+
});
|
|
30
|
+
const external_lexical_namespaceObject = require("lexical");
|
|
31
|
+
const index_cjs_namespaceObject = require("../nodes/index.cjs");
|
|
32
|
+
const createTokenNodeForOption = (option)=>{
|
|
33
|
+
switch(option.type){
|
|
34
|
+
case 'input':
|
|
35
|
+
return (0, index_cjs_namespaceObject.createInputTokenNode)(option.value);
|
|
36
|
+
case 'output':
|
|
37
|
+
return (0, index_cjs_namespaceObject.createOutputTokenNode)(option.value);
|
|
38
|
+
case 'state':
|
|
39
|
+
return (0, index_cjs_namespaceObject.createStateTokenNode)(option.value);
|
|
40
|
+
case 'resource':
|
|
41
|
+
return (0, index_cjs_namespaceObject.createResourceTokenNode)(option.value);
|
|
42
|
+
default:
|
|
43
|
+
return (0, index_cjs_namespaceObject.createInputTokenNode)(option.value);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const $insertTokenAtCursor = (option)=>{
|
|
47
|
+
const tokenNode = createTokenNodeForOption(option);
|
|
48
|
+
const selection = (0, external_lexical_namespaceObject.$getSelection)();
|
|
49
|
+
if (!(0, external_lexical_namespaceObject.$isRangeSelection)(selection)) {
|
|
50
|
+
const root = (0, external_lexical_namespaceObject.$getRoot)();
|
|
51
|
+
const lastChild = root.getLastChild();
|
|
52
|
+
if (lastChild && (0, external_lexical_namespaceObject.$isElementNode)(lastChild)) lastChild.append(tokenNode);
|
|
53
|
+
else {
|
|
54
|
+
const paragraph = (0, external_lexical_namespaceObject.$createParagraphNode)();
|
|
55
|
+
paragraph.append(tokenNode);
|
|
56
|
+
root.append(paragraph);
|
|
57
|
+
}
|
|
58
|
+
tokenNode.selectNext(0, 0);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (!selection.isCollapsed()) selection.removeText();
|
|
62
|
+
const anchorNode = selection.anchor.getNode();
|
|
63
|
+
const anchorOffset = selection.anchor.offset;
|
|
64
|
+
if ((0, external_lexical_namespaceObject.$isTextNode)(anchorNode)) {
|
|
65
|
+
const textContent = anchorNode.getTextContent();
|
|
66
|
+
const textBefore = textContent.slice(0, anchorOffset);
|
|
67
|
+
const textAfter = textContent.slice(anchorOffset);
|
|
68
|
+
if (textBefore && textAfter) {
|
|
69
|
+
anchorNode.setTextContent(textBefore);
|
|
70
|
+
anchorNode.insertAfter(tokenNode);
|
|
71
|
+
const textAfterNode = (0, external_lexical_namespaceObject.$createTextNode)(textAfter);
|
|
72
|
+
tokenNode.insertAfter(textAfterNode);
|
|
73
|
+
textAfterNode.select(0, 0);
|
|
74
|
+
} else if (textBefore) {
|
|
75
|
+
anchorNode.setTextContent(textBefore);
|
|
76
|
+
anchorNode.insertAfter(tokenNode);
|
|
77
|
+
tokenNode.selectNext(0, 0);
|
|
78
|
+
} else if (textAfter) {
|
|
79
|
+
anchorNode.insertBefore(tokenNode);
|
|
80
|
+
tokenNode.selectNext(0, 0);
|
|
81
|
+
} else {
|
|
82
|
+
anchorNode.replace(tokenNode);
|
|
83
|
+
tokenNode.selectNext(0, 0);
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if ((0, external_lexical_namespaceObject.$isElementNode)(anchorNode)) {
|
|
88
|
+
const children = anchorNode.getChildren();
|
|
89
|
+
const childAtOffset = children[anchorOffset];
|
|
90
|
+
if (childAtOffset) childAtOffset.insertBefore(tokenNode);
|
|
91
|
+
else anchorNode.append(tokenNode);
|
|
92
|
+
tokenNode.selectNext(0, 0);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
exports.$insertTokenAtCursor = __webpack_exports__.$insertTokenAtCursor;
|
|
96
|
+
exports.createTokenNodeForOption = __webpack_exports__.createTokenNodeForOption;
|
|
97
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
98
|
+
"$insertTokenAtCursor",
|
|
99
|
+
"createTokenNodeForOption"
|
|
100
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
101
|
+
Object.defineProperty(exports, '__esModule', {
|
|
102
|
+
value: true
|
|
103
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PromptEditorAutoCompleteOption } from '../types';
|
|
2
|
+
/** Create the correct Lexical token decorator node for an autocomplete option. */
|
|
3
|
+
export declare const createTokenNodeForOption: (option: PromptEditorAutoCompleteOption) => import("../nodes").InputTokenNode | import("../nodes").OutputTokenNode | import("../nodes").StateTokenNode | import("../nodes").ResourceTokenNode;
|
|
4
|
+
/**
|
|
5
|
+
* Insert a token pill at the current cursor position. Must be called inside an
|
|
6
|
+
* `editor.update(() => ...)` block.
|
|
7
|
+
*
|
|
8
|
+
* - Text anchor: splits the text and inserts between the halves (or appends/prepends at edges).
|
|
9
|
+
* - Element anchor: inserts as a child at the selection offset.
|
|
10
|
+
* - No selection: appends to the root so the action is not silently dropped.
|
|
11
|
+
*/
|
|
12
|
+
export declare const $insertTokenAtCursor: (option: PromptEditorAutoCompleteOption) => void;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { $createParagraphNode, $createTextNode, $getRoot, $getSelection, $isElementNode, $isRangeSelection, $isTextNode } from "lexical";
|
|
2
|
+
import { createInputTokenNode, createOutputTokenNode, createResourceTokenNode, createStateTokenNode } from "../nodes/index.js";
|
|
3
|
+
const createTokenNodeForOption = (option)=>{
|
|
4
|
+
switch(option.type){
|
|
5
|
+
case 'input':
|
|
6
|
+
return createInputTokenNode(option.value);
|
|
7
|
+
case 'output':
|
|
8
|
+
return createOutputTokenNode(option.value);
|
|
9
|
+
case 'state':
|
|
10
|
+
return createStateTokenNode(option.value);
|
|
11
|
+
case 'resource':
|
|
12
|
+
return createResourceTokenNode(option.value);
|
|
13
|
+
default:
|
|
14
|
+
return createInputTokenNode(option.value);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const $insertTokenAtCursor = (option)=>{
|
|
18
|
+
const tokenNode = createTokenNodeForOption(option);
|
|
19
|
+
const selection = $getSelection();
|
|
20
|
+
if (!$isRangeSelection(selection)) {
|
|
21
|
+
const root = $getRoot();
|
|
22
|
+
const lastChild = root.getLastChild();
|
|
23
|
+
if (lastChild && $isElementNode(lastChild)) lastChild.append(tokenNode);
|
|
24
|
+
else {
|
|
25
|
+
const paragraph = $createParagraphNode();
|
|
26
|
+
paragraph.append(tokenNode);
|
|
27
|
+
root.append(paragraph);
|
|
28
|
+
}
|
|
29
|
+
tokenNode.selectNext(0, 0);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!selection.isCollapsed()) selection.removeText();
|
|
33
|
+
const anchorNode = selection.anchor.getNode();
|
|
34
|
+
const anchorOffset = selection.anchor.offset;
|
|
35
|
+
if ($isTextNode(anchorNode)) {
|
|
36
|
+
const textContent = anchorNode.getTextContent();
|
|
37
|
+
const textBefore = textContent.slice(0, anchorOffset);
|
|
38
|
+
const textAfter = textContent.slice(anchorOffset);
|
|
39
|
+
if (textBefore && textAfter) {
|
|
40
|
+
anchorNode.setTextContent(textBefore);
|
|
41
|
+
anchorNode.insertAfter(tokenNode);
|
|
42
|
+
const textAfterNode = $createTextNode(textAfter);
|
|
43
|
+
tokenNode.insertAfter(textAfterNode);
|
|
44
|
+
textAfterNode.select(0, 0);
|
|
45
|
+
} else if (textBefore) {
|
|
46
|
+
anchorNode.setTextContent(textBefore);
|
|
47
|
+
anchorNode.insertAfter(tokenNode);
|
|
48
|
+
tokenNode.selectNext(0, 0);
|
|
49
|
+
} else if (textAfter) {
|
|
50
|
+
anchorNode.insertBefore(tokenNode);
|
|
51
|
+
tokenNode.selectNext(0, 0);
|
|
52
|
+
} else {
|
|
53
|
+
anchorNode.replace(tokenNode);
|
|
54
|
+
tokenNode.selectNext(0, 0);
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if ($isElementNode(anchorNode)) {
|
|
59
|
+
const children = anchorNode.getChildren();
|
|
60
|
+
const childAtOffset = children[anchorOffset];
|
|
61
|
+
if (childAtOffset) childAtOffset.insertBefore(tokenNode);
|
|
62
|
+
else anchorNode.append(tokenNode);
|
|
63
|
+
tokenNode.selectNext(0, 0);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
export { $insertTokenAtCursor, createTokenNodeForOption };
|
|
@@ -0,0 +1,255 @@
|
|
|
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
|
+
tokensToClipboardString: ()=>tokensToClipboardString,
|
|
28
|
+
getEditorTokensFromSelection: ()=>getEditorTokensFromSelection,
|
|
29
|
+
$setEditorTokensInternal: ()=>$setEditorTokensInternal,
|
|
30
|
+
getEditorTokens: ()=>getEditorTokens,
|
|
31
|
+
$getEditorTokensInternal: ()=>$getEditorTokensInternal,
|
|
32
|
+
setEditorTokens: ()=>setEditorTokens,
|
|
33
|
+
clipboardStringToTokens: ()=>clipboardStringToTokens,
|
|
34
|
+
WORD_JOINER: ()=>WORD_JOINER
|
|
35
|
+
});
|
|
36
|
+
const external_lexical_namespaceObject = require("lexical");
|
|
37
|
+
const index_cjs_namespaceObject = require("../nodes/index.cjs");
|
|
38
|
+
const WORD_JOINER = '\u2060';
|
|
39
|
+
const appendTextToken = (tokens, raw)=>{
|
|
40
|
+
const text = raw.split(WORD_JOINER).join('');
|
|
41
|
+
if (!text) return;
|
|
42
|
+
const lastToken = tokens[tokens.length - 1];
|
|
43
|
+
if (lastToken && 'text' === lastToken.type) lastToken.value += text;
|
|
44
|
+
else tokens.push({
|
|
45
|
+
type: 'text',
|
|
46
|
+
value: text
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const $getEditorTokensInternal = ()=>{
|
|
50
|
+
const root = (0, external_lexical_namespaceObject.$getRoot)();
|
|
51
|
+
const tokens = [];
|
|
52
|
+
const addText = (raw)=>appendTextToken(tokens, raw);
|
|
53
|
+
const traverseChildren = (children)=>{
|
|
54
|
+
for (const node of children)if ((0, external_lexical_namespaceObject.$isTextNode)(node)) addText(node.getTextContent());
|
|
55
|
+
else if ((0, external_lexical_namespaceObject.$isLineBreakNode)(node)) addText('\n');
|
|
56
|
+
else if ((0, index_cjs_namespaceObject.isInputTokenNode)(node)) tokens.push({
|
|
57
|
+
type: 'input',
|
|
58
|
+
value: node.getValue()
|
|
59
|
+
});
|
|
60
|
+
else if ((0, index_cjs_namespaceObject.isOutputTokenNode)(node)) tokens.push({
|
|
61
|
+
type: 'output',
|
|
62
|
+
value: node.getValue()
|
|
63
|
+
});
|
|
64
|
+
else if ((0, index_cjs_namespaceObject.isStateTokenNode)(node)) tokens.push({
|
|
65
|
+
type: 'state',
|
|
66
|
+
value: node.getValue()
|
|
67
|
+
});
|
|
68
|
+
else if ((0, index_cjs_namespaceObject.isResourceTokenNode)(node)) tokens.push({
|
|
69
|
+
type: 'resource',
|
|
70
|
+
value: node.getValue()
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const paragraphs = root.getChildren();
|
|
74
|
+
for(let i = 0; i < paragraphs.length; i++){
|
|
75
|
+
const paragraph = paragraphs[i];
|
|
76
|
+
if ((0, external_lexical_namespaceObject.$isParagraphNode)(paragraph)) {
|
|
77
|
+
traverseChildren(paragraph.getChildren());
|
|
78
|
+
if (i < paragraphs.length - 1) addText('\n');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return tokens;
|
|
82
|
+
};
|
|
83
|
+
const $setEditorTokensInternal = (tokens)=>{
|
|
84
|
+
if (!Array.isArray(tokens)) throw new TypeError('setEditorTokensInternal: tokens must be an array');
|
|
85
|
+
const root = (0, external_lexical_namespaceObject.$getRoot)();
|
|
86
|
+
root.clear();
|
|
87
|
+
const currentParagraph = (0, external_lexical_namespaceObject.$createParagraphNode)();
|
|
88
|
+
for (const token of tokens)if ('text' === token.type) {
|
|
89
|
+
const lines = token.value.split('\n');
|
|
90
|
+
for(let i = 0; i < lines.length; i++){
|
|
91
|
+
if (lines[i]) currentParagraph.append((0, external_lexical_namespaceObject.$createTextNode)(lines[i]));
|
|
92
|
+
if (i < lines.length - 1) currentParagraph.append((0, external_lexical_namespaceObject.$createLineBreakNode)());
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
let node;
|
|
96
|
+
switch(token.type){
|
|
97
|
+
case 'input':
|
|
98
|
+
node = (0, index_cjs_namespaceObject.createInputTokenNode)(token.value);
|
|
99
|
+
break;
|
|
100
|
+
case 'output':
|
|
101
|
+
node = (0, index_cjs_namespaceObject.createOutputTokenNode)(token.value);
|
|
102
|
+
break;
|
|
103
|
+
case 'state':
|
|
104
|
+
node = (0, index_cjs_namespaceObject.createStateTokenNode)(token.value);
|
|
105
|
+
break;
|
|
106
|
+
case 'resource':
|
|
107
|
+
node = (0, index_cjs_namespaceObject.createResourceTokenNode)(token.value);
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
throw new Error(`Unknown token type: ${token.type}`);
|
|
111
|
+
}
|
|
112
|
+
currentParagraph.append(node);
|
|
113
|
+
}
|
|
114
|
+
root.append(currentParagraph);
|
|
115
|
+
};
|
|
116
|
+
const getEditorTokens = (editor)=>{
|
|
117
|
+
let tokens = [];
|
|
118
|
+
editor.getEditorState().read(()=>{
|
|
119
|
+
tokens = $getEditorTokensInternal();
|
|
120
|
+
});
|
|
121
|
+
return tokens;
|
|
122
|
+
};
|
|
123
|
+
const setEditorTokens = (editor, tokens)=>{
|
|
124
|
+
editor.update(()=>$setEditorTokensInternal(tokens), {
|
|
125
|
+
discrete: true
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
const tokensToClipboardString = (tokens)=>{
|
|
129
|
+
let result = '';
|
|
130
|
+
for (const token of tokens)if ('text' === token.type) result += token.value;
|
|
131
|
+
else result += `{{ ${token.value} }}`;
|
|
132
|
+
return result;
|
|
133
|
+
};
|
|
134
|
+
const clipboardStringToTokens = (str)=>{
|
|
135
|
+
const tokens = [];
|
|
136
|
+
let currentText = '';
|
|
137
|
+
let i = 0;
|
|
138
|
+
const flushText = ()=>{
|
|
139
|
+
if (currentText.length > 0) {
|
|
140
|
+
tokens.push({
|
|
141
|
+
type: 'text',
|
|
142
|
+
value: currentText
|
|
143
|
+
});
|
|
144
|
+
currentText = '';
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
while(i < str.length){
|
|
148
|
+
if ('{' === str[i] && i + 1 < str.length && '{' === str[i + 1]) {
|
|
149
|
+
flushText();
|
|
150
|
+
i += 2;
|
|
151
|
+
let inner = '';
|
|
152
|
+
let foundClosing = false;
|
|
153
|
+
while(i < str.length){
|
|
154
|
+
if ('}' === str[i] && i + 1 < str.length && '}' === str[i + 1]) {
|
|
155
|
+
i += 2;
|
|
156
|
+
foundClosing = true;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
inner += str[i];
|
|
160
|
+
i++;
|
|
161
|
+
}
|
|
162
|
+
if (foundClosing && inner.trim()) tokens.push({
|
|
163
|
+
type: 'input',
|
|
164
|
+
value: inner.trim()
|
|
165
|
+
});
|
|
166
|
+
else if (foundClosing) currentText += '{{}}';
|
|
167
|
+
else currentText += `{{${inner}`;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
currentText += str[i];
|
|
171
|
+
i++;
|
|
172
|
+
}
|
|
173
|
+
flushText();
|
|
174
|
+
return tokens;
|
|
175
|
+
};
|
|
176
|
+
const getEditorTokensFromSelection = (selection)=>{
|
|
177
|
+
if (!(0, external_lexical_namespaceObject.$isRangeSelection)(selection)) return [];
|
|
178
|
+
if (selection.isCollapsed()) return [];
|
|
179
|
+
const tokens = [];
|
|
180
|
+
const addText = (raw)=>appendTextToken(tokens, raw);
|
|
181
|
+
const selectedNodes = selection.getNodes();
|
|
182
|
+
const anchorKey = selection.anchor.key;
|
|
183
|
+
const focusKey = selection.focus.key;
|
|
184
|
+
const anchorOffset = selection.anchor.offset;
|
|
185
|
+
const focusOffset = selection.focus.offset;
|
|
186
|
+
const anchorNode = selection.anchor.getNode();
|
|
187
|
+
const nodeKeys = new Set(selectedNodes.map((n)=>n.getKey()));
|
|
188
|
+
const nodesToProcess = [];
|
|
189
|
+
if ((0, external_lexical_namespaceObject.$isTextNode)(anchorNode) && !nodeKeys.has(anchorKey)) nodesToProcess.push(anchorNode);
|
|
190
|
+
nodesToProcess.push(...selectedNodes);
|
|
191
|
+
if (0 === nodesToProcess.length) return [];
|
|
192
|
+
const firstSelectedNode = nodesToProcess[0];
|
|
193
|
+
const isForward = 1 === nodesToProcess.length ? anchorOffset <= focusOffset : firstSelectedNode.getKey() === anchorKey || firstSelectedNode.getParent()?.getKey() === anchorKey;
|
|
194
|
+
let prevNodeParagraph = null;
|
|
195
|
+
for (const node of nodesToProcess){
|
|
196
|
+
const nodeKey = node.getKey();
|
|
197
|
+
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)) {
|
|
202
|
+
if ('input-token' === nodeType) tokens.push({
|
|
203
|
+
type: 'input',
|
|
204
|
+
value: node.getValue()
|
|
205
|
+
});
|
|
206
|
+
else if ('output-token' === nodeType) tokens.push({
|
|
207
|
+
type: 'output',
|
|
208
|
+
value: node.getValue()
|
|
209
|
+
});
|
|
210
|
+
else if ('state-token' === nodeType) tokens.push({
|
|
211
|
+
type: 'state',
|
|
212
|
+
value: node.getValue()
|
|
213
|
+
});
|
|
214
|
+
else if ('resource-token' === nodeType) tokens.push({
|
|
215
|
+
type: 'resource',
|
|
216
|
+
value: node.getValue()
|
|
217
|
+
});
|
|
218
|
+
else if ((0, external_lexical_namespaceObject.$isTextNode)(node)) {
|
|
219
|
+
const textContent = node.getTextContent();
|
|
220
|
+
let selectedText = textContent;
|
|
221
|
+
const isAnchorNode = nodeKey === anchorKey;
|
|
222
|
+
const isFocusNode = nodeKey === focusKey;
|
|
223
|
+
if (isAnchorNode && isFocusNode) {
|
|
224
|
+
const start = Math.min(anchorOffset, focusOffset);
|
|
225
|
+
const end = Math.max(anchorOffset, focusOffset);
|
|
226
|
+
selectedText = textContent.slice(start, end);
|
|
227
|
+
} else if (isAnchorNode) selectedText = isForward ? textContent.slice(anchorOffset) : textContent.slice(0, anchorOffset);
|
|
228
|
+
else if (isFocusNode) selectedText = isForward ? textContent.slice(0, focusOffset) : textContent.slice(focusOffset);
|
|
229
|
+
if (selectedText) addText(selectedText);
|
|
230
|
+
} else if ((0, external_lexical_namespaceObject.$isLineBreakNode)(node)) addText('\n');
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return tokens;
|
|
234
|
+
};
|
|
235
|
+
exports.$getEditorTokensInternal = __webpack_exports__.$getEditorTokensInternal;
|
|
236
|
+
exports.$setEditorTokensInternal = __webpack_exports__.$setEditorTokensInternal;
|
|
237
|
+
exports.WORD_JOINER = __webpack_exports__.WORD_JOINER;
|
|
238
|
+
exports.clipboardStringToTokens = __webpack_exports__.clipboardStringToTokens;
|
|
239
|
+
exports.getEditorTokens = __webpack_exports__.getEditorTokens;
|
|
240
|
+
exports.getEditorTokensFromSelection = __webpack_exports__.getEditorTokensFromSelection;
|
|
241
|
+
exports.setEditorTokens = __webpack_exports__.setEditorTokens;
|
|
242
|
+
exports.tokensToClipboardString = __webpack_exports__.tokensToClipboardString;
|
|
243
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
244
|
+
"$getEditorTokensInternal",
|
|
245
|
+
"$setEditorTokensInternal",
|
|
246
|
+
"WORD_JOINER",
|
|
247
|
+
"clipboardStringToTokens",
|
|
248
|
+
"getEditorTokens",
|
|
249
|
+
"getEditorTokensFromSelection",
|
|
250
|
+
"setEditorTokens",
|
|
251
|
+
"tokensToClipboardString"
|
|
252
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
253
|
+
Object.defineProperty(exports, '__esModule', {
|
|
254
|
+
value: true
|
|
255
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type BaseSelection, type LexicalEditor } from 'lexical';
|
|
2
|
+
import type { PromptEditorToken } from '../types';
|
|
3
|
+
/** U+2060 WORD JOINER — zero-width, used as a caret anchor next to inline token pills. Explicit
|
|
4
|
+
* escape (not the invisible literal) so it can't be silently dropped/altered by editors. */
|
|
5
|
+
export declare const WORD_JOINER = "\u2060";
|
|
6
|
+
export declare const $getEditorTokensInternal: () => PromptEditorToken[];
|
|
7
|
+
/** Convert PromptEditorToken[] to Lexical editor state */
|
|
8
|
+
export declare const $setEditorTokensInternal: (tokens: PromptEditorToken[]) => void;
|
|
9
|
+
export declare const getEditorTokens: (editor: LexicalEditor) => PromptEditorToken[];
|
|
10
|
+
export declare const setEditorTokens: (editor: LexicalEditor, tokens: PromptEditorToken[]) => void;
|
|
11
|
+
/** Serialize tokens to clipboard-friendly string (using {{ }} for variables) */
|
|
12
|
+
export declare const tokensToClipboardString: (tokens: PromptEditorToken[]) => string;
|
|
13
|
+
/** Parse a clipboard string back into tokens */
|
|
14
|
+
export declare const clipboardStringToTokens: (str: string) => PromptEditorToken[];
|
|
15
|
+
/** Get tokens from a selection (for copy/cut operations) */
|
|
16
|
+
export declare const getEditorTokensFromSelection: (selection: BaseSelection) => PromptEditorToken[];
|