@uipath/apollo-wind 2.22.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/forms/metadata-form.cjs +2 -2
- package/dist/components/forms/metadata-form.js +2 -2
- package/dist/components/ui/index.cjs +92 -82
- 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/editor-themes/monaco.cjs +2 -2
- package/dist/editor-themes/monaco.js +2 -2
- package/dist/index.cjs +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/styles.css +44 -16
- package/dist/tailwind.utilities.css +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,242 @@
|
|
|
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
|
+
AutocompletePlugin: ()=>AutocompletePlugin
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const LexicalComposerContext_namespaceObject = require("@lexical/react/LexicalComposerContext");
|
|
31
|
+
const utils_namespaceObject = require("@lexical/utils");
|
|
32
|
+
const external_lexical_namespaceObject = require("lexical");
|
|
33
|
+
const external_react_namespaceObject = require("react");
|
|
34
|
+
const PromptEditorAutocompleteMenu_cjs_namespaceObject = require("../components/PromptEditorAutocompleteMenu.cjs");
|
|
35
|
+
const autocomplete_segments_cjs_namespaceObject = require("../utils/autocomplete-segments.cjs");
|
|
36
|
+
const insert_token_cjs_namespaceObject = require("../utils/insert-token.cjs");
|
|
37
|
+
const findTrigger = (text, cursorPos)=>{
|
|
38
|
+
let triggerIndex = -1;
|
|
39
|
+
for(let i = cursorPos - 1; i >= 0; i--){
|
|
40
|
+
const char = text[i];
|
|
41
|
+
if (/\s/.test(char)) break;
|
|
42
|
+
if ('$' === char) {
|
|
43
|
+
if (0 === i || /\s/.test(text[i - 1])) triggerIndex = i;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (-1 === triggerIndex) return null;
|
|
48
|
+
return {
|
|
49
|
+
triggerIndex,
|
|
50
|
+
query: text.slice(triggerIndex + 1, cursorPos)
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const getCaretRectForEditor = (editor)=>{
|
|
54
|
+
const rootElement = editor.getRootElement();
|
|
55
|
+
const fallbackRect = rootElement?.getBoundingClientRect() ?? new DOMRect();
|
|
56
|
+
const domSelection = (0, external_lexical_namespaceObject.getDOMSelectionFromTarget)(rootElement);
|
|
57
|
+
if (!domSelection || 0 === domSelection.rangeCount) return fallbackRect;
|
|
58
|
+
const range = domSelection.getRangeAt(0).cloneRange();
|
|
59
|
+
range.collapse(false);
|
|
60
|
+
const rects = 'function' == typeof range.getClientRects ? range.getClientRects() : null;
|
|
61
|
+
const rect = rects?.item(0) ?? range.getBoundingClientRect();
|
|
62
|
+
if (!Number.isFinite(rect.x) || !Number.isFinite(rect.y)) return fallbackRect;
|
|
63
|
+
if (0 === rect.width && 0 === rect.height) return fallbackRect;
|
|
64
|
+
return rect;
|
|
65
|
+
};
|
|
66
|
+
const AutocompletePlugin = ({ options })=>{
|
|
67
|
+
const [editor] = (0, LexicalComposerContext_namespaceObject.useLexicalComposerContext)();
|
|
68
|
+
const [open, setOpen] = (0, external_react_namespaceObject.useState)(false);
|
|
69
|
+
const [anchorEl, setAnchorEl] = (0, external_react_namespaceObject.useState)(null);
|
|
70
|
+
const [query, setQuery] = (0, external_react_namespaceObject.useState)('');
|
|
71
|
+
const triggerInfoRef = (0, external_react_namespaceObject.useRef)(null);
|
|
72
|
+
const dismissedTriggerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
73
|
+
const optionsRef = (0, external_react_namespaceObject.useRef)(options);
|
|
74
|
+
const openRef = (0, external_react_namespaceObject.useRef)(open);
|
|
75
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
76
|
+
optionsRef.current = options;
|
|
77
|
+
openRef.current = open;
|
|
78
|
+
});
|
|
79
|
+
const closeMenu = (0, external_react_namespaceObject.useCallback)((explicit = false)=>{
|
|
80
|
+
const wasOpen = openRef.current;
|
|
81
|
+
if (explicit && triggerInfoRef.current) dismissedTriggerRef.current = {
|
|
82
|
+
...triggerInfoRef.current
|
|
83
|
+
};
|
|
84
|
+
setOpen(false);
|
|
85
|
+
setAnchorEl(null);
|
|
86
|
+
if (!explicit) triggerInfoRef.current = null;
|
|
87
|
+
if (wasOpen) editor.focus();
|
|
88
|
+
}, [
|
|
89
|
+
editor
|
|
90
|
+
]);
|
|
91
|
+
const commitChip = (0, external_react_namespaceObject.useCallback)((option)=>{
|
|
92
|
+
const triggerInfo = triggerInfoRef.current;
|
|
93
|
+
if (!triggerInfo) return;
|
|
94
|
+
editor.update(()=>{
|
|
95
|
+
const selection = (0, external_lexical_namespaceObject.$getSelection)();
|
|
96
|
+
if (!selection || !(0, external_lexical_namespaceObject.$isRangeSelection)(selection)) return;
|
|
97
|
+
const anchorNode = selection.anchor.getNode();
|
|
98
|
+
if (!(0, external_lexical_namespaceObject.$isTextNode)(anchorNode)) return;
|
|
99
|
+
if (anchorNode.getKey() !== triggerInfo.nodeKey) return;
|
|
100
|
+
const textContent = anchorNode.getTextContent();
|
|
101
|
+
const cursorOffset = selection.anchor.offset;
|
|
102
|
+
const textBefore = textContent.slice(0, triggerInfo.triggerIndex);
|
|
103
|
+
const textAfter = textContent.slice(cursorOffset);
|
|
104
|
+
const tokenNode = (0, insert_token_cjs_namespaceObject.createTokenNodeForOption)(option);
|
|
105
|
+
if (textBefore) {
|
|
106
|
+
anchorNode.setTextContent(textBefore);
|
|
107
|
+
anchorNode.insertAfter(tokenNode);
|
|
108
|
+
} else anchorNode.replace(tokenNode);
|
|
109
|
+
if (textAfter) {
|
|
110
|
+
const textAfterNode = (0, external_lexical_namespaceObject.$createTextNode)(textAfter);
|
|
111
|
+
tokenNode.insertAfter(textAfterNode);
|
|
112
|
+
textAfterNode.select(0, 0);
|
|
113
|
+
} else tokenNode.selectNext(0, 0);
|
|
114
|
+
});
|
|
115
|
+
closeMenu();
|
|
116
|
+
}, [
|
|
117
|
+
closeMenu,
|
|
118
|
+
editor
|
|
119
|
+
]);
|
|
120
|
+
const commitTypedAsChip = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
121
|
+
const triggerInfo = triggerInfoRef.current;
|
|
122
|
+
if (!triggerInfo) return false;
|
|
123
|
+
let committed = false;
|
|
124
|
+
editor.read(()=>{
|
|
125
|
+
const selection = (0, external_lexical_namespaceObject.$getSelection)();
|
|
126
|
+
if (!selection || !(0, external_lexical_namespaceObject.$isRangeSelection)(selection)) return;
|
|
127
|
+
const anchorNode = selection.anchor.getNode();
|
|
128
|
+
if (!(0, external_lexical_namespaceObject.$isTextNode)(anchorNode)) return;
|
|
129
|
+
if (anchorNode.getKey() !== triggerInfo.nodeKey) return;
|
|
130
|
+
const textContent = anchorNode.getTextContent();
|
|
131
|
+
const cursorOffset = selection.anchor.offset;
|
|
132
|
+
const typedQuery = textContent.slice(triggerInfo.triggerIndex + 1, cursorOffset);
|
|
133
|
+
if (!autocomplete_segments_cjs_namespaceObject.VARIABLE_PATH_REGEX.test(typedQuery)) return;
|
|
134
|
+
const inferredType = (0, autocomplete_segments_cjs_namespaceObject.inferTokenTypeFromPath)(typedQuery, optionsRef.current);
|
|
135
|
+
committed = true;
|
|
136
|
+
queueMicrotask(()=>commitChip({
|
|
137
|
+
type: inferredType,
|
|
138
|
+
value: typedQuery
|
|
139
|
+
}));
|
|
140
|
+
});
|
|
141
|
+
return committed;
|
|
142
|
+
}, [
|
|
143
|
+
commitChip,
|
|
144
|
+
editor
|
|
145
|
+
]);
|
|
146
|
+
const openPickerForTrigger = (0, external_react_namespaceObject.useCallback)((trigger, anchorNodeKey)=>{
|
|
147
|
+
triggerInfoRef.current = {
|
|
148
|
+
triggerIndex: trigger.triggerIndex,
|
|
149
|
+
nodeKey: anchorNodeKey
|
|
150
|
+
};
|
|
151
|
+
setQuery(trigger.query);
|
|
152
|
+
try {
|
|
153
|
+
const domSelection = (0, external_lexical_namespaceObject.getDOMSelectionFromTarget)(editor.getRootElement());
|
|
154
|
+
if (domSelection && domSelection.rangeCount > 0) {
|
|
155
|
+
const editorRoot = editor.getRootElement();
|
|
156
|
+
const caretRect = getCaretRectForEditor(editor);
|
|
157
|
+
const editorRect = editorRoot?.getBoundingClientRect() ?? new DOMRect();
|
|
158
|
+
const offsetTop = caretRect.top - editorRect.top;
|
|
159
|
+
const offsetLeft = caretRect.left - editorRect.left;
|
|
160
|
+
const caretWidth = caretRect.width;
|
|
161
|
+
const caretHeight = caretRect.height;
|
|
162
|
+
setAnchorEl({
|
|
163
|
+
getBoundingClientRect: ()=>{
|
|
164
|
+
const live = editorRoot?.getBoundingClientRect() ?? new DOMRect();
|
|
165
|
+
return new DOMRect(live.left + offsetLeft, live.top + offsetTop, caretWidth, caretHeight);
|
|
166
|
+
},
|
|
167
|
+
contextElement: editorRoot ?? void 0
|
|
168
|
+
});
|
|
169
|
+
setOpen(true);
|
|
170
|
+
} else closeMenu();
|
|
171
|
+
} catch {
|
|
172
|
+
closeMenu();
|
|
173
|
+
}
|
|
174
|
+
}, [
|
|
175
|
+
closeMenu,
|
|
176
|
+
editor
|
|
177
|
+
]);
|
|
178
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
179
|
+
let lastText = editor.getEditorState().read(()=>(0, external_lexical_namespaceObject.$getRoot)().getTextContent());
|
|
180
|
+
return (0, utils_namespaceObject.mergeRegister)(editor.registerUpdateListener(({ editorState })=>{
|
|
181
|
+
const currText = editorState.read(()=>(0, external_lexical_namespaceObject.$getRoot)().getTextContent());
|
|
182
|
+
const textChanged = currText !== lastText;
|
|
183
|
+
lastText = currText;
|
|
184
|
+
if (textChanged) dismissedTriggerRef.current = null;
|
|
185
|
+
editorState.read(()=>{
|
|
186
|
+
const selection = (0, external_lexical_namespaceObject.$getSelection)();
|
|
187
|
+
if (!selection || !(0, external_lexical_namespaceObject.$isRangeSelection)(selection) || !selection.isCollapsed()) return void closeMenu();
|
|
188
|
+
const anchorNode = selection.anchor.getNode();
|
|
189
|
+
if (!(0, external_lexical_namespaceObject.$isTextNode)(anchorNode)) return void closeMenu();
|
|
190
|
+
const textContent = anchorNode.getTextContent();
|
|
191
|
+
const trigger = findTrigger(textContent, selection.anchor.offset);
|
|
192
|
+
if (!trigger) return void closeMenu();
|
|
193
|
+
if ((0, autocomplete_segments_cjs_namespaceObject.shouldSuppressOpenForDismissed)({
|
|
194
|
+
triggerIndex: trigger.triggerIndex,
|
|
195
|
+
nodeKey: anchorNode.getKey()
|
|
196
|
+
}, dismissedTriggerRef.current)) return;
|
|
197
|
+
openPickerForTrigger(trigger, anchorNode.getKey());
|
|
198
|
+
});
|
|
199
|
+
}), editor.registerCommand(external_lexical_namespaceObject.KEY_ENTER_COMMAND, (event)=>{
|
|
200
|
+
if (!triggerInfoRef.current) return false;
|
|
201
|
+
if (commitTypedAsChip()) {
|
|
202
|
+
event?.preventDefault();
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
return false;
|
|
206
|
+
}, external_lexical_namespaceObject.COMMAND_PRIORITY_HIGH), editor.registerCommand(external_lexical_namespaceObject.KEY_ESCAPE_COMMAND, ()=>{
|
|
207
|
+
if (!openRef.current && !triggerInfoRef.current) return false;
|
|
208
|
+
closeMenu(true);
|
|
209
|
+
return true;
|
|
210
|
+
}, external_lexical_namespaceObject.COMMAND_PRIORITY_HIGH));
|
|
211
|
+
}, [
|
|
212
|
+
closeMenu,
|
|
213
|
+
commitTypedAsChip,
|
|
214
|
+
editor,
|
|
215
|
+
openPickerForTrigger
|
|
216
|
+
]);
|
|
217
|
+
const handleVariablePickerSelect = (0, external_react_namespaceObject.useCallback)((path)=>{
|
|
218
|
+
const inferredType = (0, autocomplete_segments_cjs_namespaceObject.inferTokenTypeFromPath)(path, optionsRef.current);
|
|
219
|
+
commitChip({
|
|
220
|
+
type: inferredType,
|
|
221
|
+
value: path
|
|
222
|
+
});
|
|
223
|
+
}, [
|
|
224
|
+
commitChip
|
|
225
|
+
]);
|
|
226
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(PromptEditorAutocompleteMenu_cjs_namespaceObject.PromptEditorAutocompleteMenu, {
|
|
227
|
+
open: open,
|
|
228
|
+
anchorEl: anchorEl,
|
|
229
|
+
initialSearch: query,
|
|
230
|
+
options: options,
|
|
231
|
+
onSelect: handleVariablePickerSelect,
|
|
232
|
+
onCommitFreeForm: handleVariablePickerSelect,
|
|
233
|
+
onClose: ()=>closeMenu(true)
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
exports.AutocompletePlugin = __webpack_exports__.AutocompletePlugin;
|
|
237
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
238
|
+
"AutocompletePlugin"
|
|
239
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
240
|
+
Object.defineProperty(exports, '__esModule', {
|
|
241
|
+
value: true
|
|
242
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PromptEditorAutoCompleteOption } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Drives the `$`-trigger flow: detects when the user has typed a `$` in a valid trigger context,
|
|
4
|
+
* opens `<VariablePickerAutocompleteMenu>` anchored to the caret, threads selection back into a
|
|
5
|
+
* Lexical token chip on commit, and handles dismissal (Escape, click-outside, scroll, free-form
|
|
6
|
+
* Enter on a typed-but-unmatched `$prefix.path`).
|
|
7
|
+
*
|
|
8
|
+
* The picker (a wrapper around the canvas-wide `VariablePicker`) owns search, drill-in, and
|
|
9
|
+
* keyboard navigation while it has focus. This plugin only handles the parts that have to live in
|
|
10
|
+
* the Lexical editor: trigger detection, dismissal sentinel, free-form Enter fallback after
|
|
11
|
+
* dismissal, and refocusing the editor when the picker closes.
|
|
12
|
+
*/
|
|
13
|
+
export declare const AutocompletePlugin: ({ options }: {
|
|
14
|
+
options: PromptEditorAutoCompleteOption[];
|
|
15
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
3
|
+
import { mergeRegister } from "@lexical/utils";
|
|
4
|
+
import { $createTextNode, $getRoot, $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_HIGH, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, getDOMSelectionFromTarget } from "lexical";
|
|
5
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
6
|
+
import { PromptEditorAutocompleteMenu } from "../components/PromptEditorAutocompleteMenu.js";
|
|
7
|
+
import { VARIABLE_PATH_REGEX, inferTokenTypeFromPath, shouldSuppressOpenForDismissed } from "../utils/autocomplete-segments.js";
|
|
8
|
+
import { createTokenNodeForOption } from "../utils/insert-token.js";
|
|
9
|
+
const findTrigger = (text, cursorPos)=>{
|
|
10
|
+
let triggerIndex = -1;
|
|
11
|
+
for(let i = cursorPos - 1; i >= 0; i--){
|
|
12
|
+
const char = text[i];
|
|
13
|
+
if (/\s/.test(char)) break;
|
|
14
|
+
if ('$' === char) {
|
|
15
|
+
if (0 === i || /\s/.test(text[i - 1])) triggerIndex = i;
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (-1 === triggerIndex) return null;
|
|
20
|
+
return {
|
|
21
|
+
triggerIndex,
|
|
22
|
+
query: text.slice(triggerIndex + 1, cursorPos)
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const getCaretRectForEditor = (editor)=>{
|
|
26
|
+
const rootElement = editor.getRootElement();
|
|
27
|
+
const fallbackRect = rootElement?.getBoundingClientRect() ?? new DOMRect();
|
|
28
|
+
const domSelection = getDOMSelectionFromTarget(rootElement);
|
|
29
|
+
if (!domSelection || 0 === domSelection.rangeCount) return fallbackRect;
|
|
30
|
+
const range = domSelection.getRangeAt(0).cloneRange();
|
|
31
|
+
range.collapse(false);
|
|
32
|
+
const rects = 'function' == typeof range.getClientRects ? range.getClientRects() : null;
|
|
33
|
+
const rect = rects?.item(0) ?? range.getBoundingClientRect();
|
|
34
|
+
if (!Number.isFinite(rect.x) || !Number.isFinite(rect.y)) return fallbackRect;
|
|
35
|
+
if (0 === rect.width && 0 === rect.height) return fallbackRect;
|
|
36
|
+
return rect;
|
|
37
|
+
};
|
|
38
|
+
const AutocompletePlugin = ({ options })=>{
|
|
39
|
+
const [editor] = useLexicalComposerContext();
|
|
40
|
+
const [open, setOpen] = useState(false);
|
|
41
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
42
|
+
const [query, setQuery] = useState('');
|
|
43
|
+
const triggerInfoRef = useRef(null);
|
|
44
|
+
const dismissedTriggerRef = useRef(null);
|
|
45
|
+
const optionsRef = useRef(options);
|
|
46
|
+
const openRef = useRef(open);
|
|
47
|
+
useEffect(()=>{
|
|
48
|
+
optionsRef.current = options;
|
|
49
|
+
openRef.current = open;
|
|
50
|
+
});
|
|
51
|
+
const closeMenu = useCallback((explicit = false)=>{
|
|
52
|
+
const wasOpen = openRef.current;
|
|
53
|
+
if (explicit && triggerInfoRef.current) dismissedTriggerRef.current = {
|
|
54
|
+
...triggerInfoRef.current
|
|
55
|
+
};
|
|
56
|
+
setOpen(false);
|
|
57
|
+
setAnchorEl(null);
|
|
58
|
+
if (!explicit) triggerInfoRef.current = null;
|
|
59
|
+
if (wasOpen) editor.focus();
|
|
60
|
+
}, [
|
|
61
|
+
editor
|
|
62
|
+
]);
|
|
63
|
+
const commitChip = useCallback((option)=>{
|
|
64
|
+
const triggerInfo = triggerInfoRef.current;
|
|
65
|
+
if (!triggerInfo) return;
|
|
66
|
+
editor.update(()=>{
|
|
67
|
+
const selection = $getSelection();
|
|
68
|
+
if (!selection || !$isRangeSelection(selection)) return;
|
|
69
|
+
const anchorNode = selection.anchor.getNode();
|
|
70
|
+
if (!$isTextNode(anchorNode)) return;
|
|
71
|
+
if (anchorNode.getKey() !== triggerInfo.nodeKey) return;
|
|
72
|
+
const textContent = anchorNode.getTextContent();
|
|
73
|
+
const cursorOffset = selection.anchor.offset;
|
|
74
|
+
const textBefore = textContent.slice(0, triggerInfo.triggerIndex);
|
|
75
|
+
const textAfter = textContent.slice(cursorOffset);
|
|
76
|
+
const tokenNode = createTokenNodeForOption(option);
|
|
77
|
+
if (textBefore) {
|
|
78
|
+
anchorNode.setTextContent(textBefore);
|
|
79
|
+
anchorNode.insertAfter(tokenNode);
|
|
80
|
+
} else anchorNode.replace(tokenNode);
|
|
81
|
+
if (textAfter) {
|
|
82
|
+
const textAfterNode = $createTextNode(textAfter);
|
|
83
|
+
tokenNode.insertAfter(textAfterNode);
|
|
84
|
+
textAfterNode.select(0, 0);
|
|
85
|
+
} else tokenNode.selectNext(0, 0);
|
|
86
|
+
});
|
|
87
|
+
closeMenu();
|
|
88
|
+
}, [
|
|
89
|
+
closeMenu,
|
|
90
|
+
editor
|
|
91
|
+
]);
|
|
92
|
+
const commitTypedAsChip = useCallback(()=>{
|
|
93
|
+
const triggerInfo = triggerInfoRef.current;
|
|
94
|
+
if (!triggerInfo) return false;
|
|
95
|
+
let committed = false;
|
|
96
|
+
editor.read(()=>{
|
|
97
|
+
const selection = $getSelection();
|
|
98
|
+
if (!selection || !$isRangeSelection(selection)) return;
|
|
99
|
+
const anchorNode = selection.anchor.getNode();
|
|
100
|
+
if (!$isTextNode(anchorNode)) return;
|
|
101
|
+
if (anchorNode.getKey() !== triggerInfo.nodeKey) return;
|
|
102
|
+
const textContent = anchorNode.getTextContent();
|
|
103
|
+
const cursorOffset = selection.anchor.offset;
|
|
104
|
+
const typedQuery = textContent.slice(triggerInfo.triggerIndex + 1, cursorOffset);
|
|
105
|
+
if (!VARIABLE_PATH_REGEX.test(typedQuery)) return;
|
|
106
|
+
const inferredType = inferTokenTypeFromPath(typedQuery, optionsRef.current);
|
|
107
|
+
committed = true;
|
|
108
|
+
queueMicrotask(()=>commitChip({
|
|
109
|
+
type: inferredType,
|
|
110
|
+
value: typedQuery
|
|
111
|
+
}));
|
|
112
|
+
});
|
|
113
|
+
return committed;
|
|
114
|
+
}, [
|
|
115
|
+
commitChip,
|
|
116
|
+
editor
|
|
117
|
+
]);
|
|
118
|
+
const openPickerForTrigger = useCallback((trigger, anchorNodeKey)=>{
|
|
119
|
+
triggerInfoRef.current = {
|
|
120
|
+
triggerIndex: trigger.triggerIndex,
|
|
121
|
+
nodeKey: anchorNodeKey
|
|
122
|
+
};
|
|
123
|
+
setQuery(trigger.query);
|
|
124
|
+
try {
|
|
125
|
+
const domSelection = getDOMSelectionFromTarget(editor.getRootElement());
|
|
126
|
+
if (domSelection && domSelection.rangeCount > 0) {
|
|
127
|
+
const editorRoot = editor.getRootElement();
|
|
128
|
+
const caretRect = getCaretRectForEditor(editor);
|
|
129
|
+
const editorRect = editorRoot?.getBoundingClientRect() ?? new DOMRect();
|
|
130
|
+
const offsetTop = caretRect.top - editorRect.top;
|
|
131
|
+
const offsetLeft = caretRect.left - editorRect.left;
|
|
132
|
+
const caretWidth = caretRect.width;
|
|
133
|
+
const caretHeight = caretRect.height;
|
|
134
|
+
setAnchorEl({
|
|
135
|
+
getBoundingClientRect: ()=>{
|
|
136
|
+
const live = editorRoot?.getBoundingClientRect() ?? new DOMRect();
|
|
137
|
+
return new DOMRect(live.left + offsetLeft, live.top + offsetTop, caretWidth, caretHeight);
|
|
138
|
+
},
|
|
139
|
+
contextElement: editorRoot ?? void 0
|
|
140
|
+
});
|
|
141
|
+
setOpen(true);
|
|
142
|
+
} else closeMenu();
|
|
143
|
+
} catch {
|
|
144
|
+
closeMenu();
|
|
145
|
+
}
|
|
146
|
+
}, [
|
|
147
|
+
closeMenu,
|
|
148
|
+
editor
|
|
149
|
+
]);
|
|
150
|
+
useEffect(()=>{
|
|
151
|
+
let lastText = editor.getEditorState().read(()=>$getRoot().getTextContent());
|
|
152
|
+
return mergeRegister(editor.registerUpdateListener(({ editorState })=>{
|
|
153
|
+
const currText = editorState.read(()=>$getRoot().getTextContent());
|
|
154
|
+
const textChanged = currText !== lastText;
|
|
155
|
+
lastText = currText;
|
|
156
|
+
if (textChanged) dismissedTriggerRef.current = null;
|
|
157
|
+
editorState.read(()=>{
|
|
158
|
+
const selection = $getSelection();
|
|
159
|
+
if (!selection || !$isRangeSelection(selection) || !selection.isCollapsed()) return void closeMenu();
|
|
160
|
+
const anchorNode = selection.anchor.getNode();
|
|
161
|
+
if (!$isTextNode(anchorNode)) return void closeMenu();
|
|
162
|
+
const textContent = anchorNode.getTextContent();
|
|
163
|
+
const trigger = findTrigger(textContent, selection.anchor.offset);
|
|
164
|
+
if (!trigger) return void closeMenu();
|
|
165
|
+
if (shouldSuppressOpenForDismissed({
|
|
166
|
+
triggerIndex: trigger.triggerIndex,
|
|
167
|
+
nodeKey: anchorNode.getKey()
|
|
168
|
+
}, dismissedTriggerRef.current)) return;
|
|
169
|
+
openPickerForTrigger(trigger, anchorNode.getKey());
|
|
170
|
+
});
|
|
171
|
+
}), editor.registerCommand(KEY_ENTER_COMMAND, (event)=>{
|
|
172
|
+
if (!triggerInfoRef.current) return false;
|
|
173
|
+
if (commitTypedAsChip()) {
|
|
174
|
+
event?.preventDefault();
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
}, COMMAND_PRIORITY_HIGH), editor.registerCommand(KEY_ESCAPE_COMMAND, ()=>{
|
|
179
|
+
if (!openRef.current && !triggerInfoRef.current) return false;
|
|
180
|
+
closeMenu(true);
|
|
181
|
+
return true;
|
|
182
|
+
}, COMMAND_PRIORITY_HIGH));
|
|
183
|
+
}, [
|
|
184
|
+
closeMenu,
|
|
185
|
+
commitTypedAsChip,
|
|
186
|
+
editor,
|
|
187
|
+
openPickerForTrigger
|
|
188
|
+
]);
|
|
189
|
+
const handleVariablePickerSelect = useCallback((path)=>{
|
|
190
|
+
const inferredType = inferTokenTypeFromPath(path, optionsRef.current);
|
|
191
|
+
commitChip({
|
|
192
|
+
type: inferredType,
|
|
193
|
+
value: path
|
|
194
|
+
});
|
|
195
|
+
}, [
|
|
196
|
+
commitChip
|
|
197
|
+
]);
|
|
198
|
+
return /*#__PURE__*/ jsx(PromptEditorAutocompleteMenu, {
|
|
199
|
+
open: open,
|
|
200
|
+
anchorEl: anchorEl,
|
|
201
|
+
initialSearch: query,
|
|
202
|
+
options: options,
|
|
203
|
+
onSelect: handleVariablePickerSelect,
|
|
204
|
+
onCommitFreeForm: handleVariablePickerSelect,
|
|
205
|
+
onClose: ()=>closeMenu(true)
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
export { AutocompletePlugin };
|
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
CopyPastePlugin: ()=>CopyPastePlugin
|
|
28
|
+
});
|
|
29
|
+
const external_react_namespaceObject = require("react");
|
|
30
|
+
const clipboard_namespaceObject = require("@lexical/clipboard");
|
|
31
|
+
const LexicalComposerContext_namespaceObject = require("@lexical/react/LexicalComposerContext");
|
|
32
|
+
const utils_namespaceObject = require("@lexical/utils");
|
|
33
|
+
const external_lexical_namespaceObject = require("lexical");
|
|
34
|
+
const index_cjs_namespaceObject = require("../nodes/index.cjs");
|
|
35
|
+
const external_utils_index_cjs_namespaceObject = require("../utils/index.cjs");
|
|
36
|
+
const LEXICAL_MIME = 'application/x-lexical-editor';
|
|
37
|
+
const copySelectionToClipboard = (editor, clipboardData, selection)=>{
|
|
38
|
+
const tokens = (0, external_utils_index_cjs_namespaceObject.getEditorTokensFromSelection)(selection);
|
|
39
|
+
if (0 === tokens.length) return false;
|
|
40
|
+
clipboardData.setData('text/plain', (0, external_utils_index_cjs_namespaceObject.tokensToClipboardString)(tokens));
|
|
41
|
+
const lexicalJson = (0, clipboard_namespaceObject.$getLexicalContent)(editor, selection);
|
|
42
|
+
if (lexicalJson) clipboardData.setData(LEXICAL_MIME, lexicalJson);
|
|
43
|
+
return true;
|
|
44
|
+
};
|
|
45
|
+
const tryPasteLexicalContent = (editor, clipboardData, selection)=>{
|
|
46
|
+
const lexicalJson = clipboardData.getData(LEXICAL_MIME);
|
|
47
|
+
if (!lexicalJson) return false;
|
|
48
|
+
try {
|
|
49
|
+
const parsed = JSON.parse(lexicalJson);
|
|
50
|
+
if (!parsed.nodes || !Array.isArray(parsed.nodes)) return false;
|
|
51
|
+
const nodes = (0, clipboard_namespaceObject.$generateNodesFromSerializedNodes)(parsed.nodes);
|
|
52
|
+
if (0 === nodes.length) return false;
|
|
53
|
+
(0, clipboard_namespaceObject.$insertGeneratedNodes)(editor, nodes, selection);
|
|
54
|
+
return true;
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const insertTokensAtSelection = (tokens, selection)=>{
|
|
60
|
+
if (!(0, external_lexical_namespaceObject.$isRangeSelection)(selection)) return;
|
|
61
|
+
if (!selection.isCollapsed()) selection.removeText();
|
|
62
|
+
for (const token of tokens)if ('text' === token.type) {
|
|
63
|
+
const lines = token.value.split('\n');
|
|
64
|
+
for(let i = 0; i < lines.length; i++){
|
|
65
|
+
if (lines[i]) selection.insertText(lines[i]);
|
|
66
|
+
if (i < lines.length - 1) selection.insertParagraph();
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
let tokenNode;
|
|
70
|
+
switch(token.type){
|
|
71
|
+
case 'input':
|
|
72
|
+
tokenNode = (0, index_cjs_namespaceObject.createInputTokenNode)(token.value);
|
|
73
|
+
break;
|
|
74
|
+
case 'output':
|
|
75
|
+
tokenNode = (0, index_cjs_namespaceObject.createOutputTokenNode)(token.value);
|
|
76
|
+
break;
|
|
77
|
+
case 'state':
|
|
78
|
+
tokenNode = (0, index_cjs_namespaceObject.createStateTokenNode)(token.value);
|
|
79
|
+
break;
|
|
80
|
+
case 'resource':
|
|
81
|
+
tokenNode = (0, index_cjs_namespaceObject.createResourceTokenNode)(token.value);
|
|
82
|
+
break;
|
|
83
|
+
default:
|
|
84
|
+
throw new Error('Unknown token type');
|
|
85
|
+
}
|
|
86
|
+
if (tokenNode) selection.insertNodes([
|
|
87
|
+
tokenNode
|
|
88
|
+
]);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const pasteTextContent = (text, selection)=>{
|
|
92
|
+
if (!text) return false;
|
|
93
|
+
const tokens = (0, external_utils_index_cjs_namespaceObject.clipboardStringToTokens)(text);
|
|
94
|
+
if (0 === tokens.length) return false;
|
|
95
|
+
insertTokensAtSelection(tokens, selection);
|
|
96
|
+
return true;
|
|
97
|
+
};
|
|
98
|
+
const CopyPastePlugin = ()=>{
|
|
99
|
+
const [editor] = (0, LexicalComposerContext_namespaceObject.useLexicalComposerContext)();
|
|
100
|
+
(0, external_react_namespaceObject.useEffect)(()=>(0, utils_namespaceObject.mergeRegister)(editor.registerCommand(external_lexical_namespaceObject.COPY_COMMAND, (event)=>{
|
|
101
|
+
if (!event || !('clipboardData' in event) || !event.clipboardData) return false;
|
|
102
|
+
let handled = false;
|
|
103
|
+
editor.read(()=>{
|
|
104
|
+
let selection = (0, external_lexical_namespaceObject.$getSelection)();
|
|
105
|
+
if (!selection || (0, external_lexical_namespaceObject.$isRangeSelection)(selection) && selection.isCollapsed()) {
|
|
106
|
+
const domSelection = window.getSelection();
|
|
107
|
+
const rootElement = editor.getRootElement();
|
|
108
|
+
if (domSelection && rootElement && !domSelection.isCollapsed) selection = (0, external_lexical_namespaceObject.$createRangeSelectionFromDom)(domSelection, editor);
|
|
109
|
+
}
|
|
110
|
+
if (!selection || (0, external_lexical_namespaceObject.$isRangeSelection)(selection) && selection.isCollapsed()) return;
|
|
111
|
+
handled = copySelectionToClipboard(editor, event.clipboardData, selection);
|
|
112
|
+
});
|
|
113
|
+
if (handled) event.preventDefault();
|
|
114
|
+
return handled;
|
|
115
|
+
}, external_lexical_namespaceObject.COMMAND_PRIORITY_CRITICAL), editor.registerCommand(external_lexical_namespaceObject.CUT_COMMAND, (event)=>{
|
|
116
|
+
if (!event || !('clipboardData' in event) || !event.clipboardData) return false;
|
|
117
|
+
let handled = false;
|
|
118
|
+
editor.read(()=>{
|
|
119
|
+
let selection = (0, external_lexical_namespaceObject.$getSelection)();
|
|
120
|
+
if (!selection || (0, external_lexical_namespaceObject.$isRangeSelection)(selection) && selection.isCollapsed()) {
|
|
121
|
+
const domSelection = window.getSelection();
|
|
122
|
+
const rootElement = editor.getRootElement();
|
|
123
|
+
if (domSelection && rootElement && !domSelection.isCollapsed) selection = (0, external_lexical_namespaceObject.$createRangeSelectionFromDom)(domSelection, editor);
|
|
124
|
+
}
|
|
125
|
+
if (!selection || (0, external_lexical_namespaceObject.$isRangeSelection)(selection) && selection.isCollapsed()) return;
|
|
126
|
+
handled = copySelectionToClipboard(editor, event.clipboardData, selection);
|
|
127
|
+
});
|
|
128
|
+
if (handled) {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
editor.update(()=>{
|
|
131
|
+
const selection = (0, external_lexical_namespaceObject.$getSelection)();
|
|
132
|
+
if (selection && (0, external_lexical_namespaceObject.$isRangeSelection)(selection)) selection.removeText();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return handled;
|
|
136
|
+
}, external_lexical_namespaceObject.COMMAND_PRIORITY_CRITICAL), editor.registerCommand(external_lexical_namespaceObject.PASTE_COMMAND, (event)=>{
|
|
137
|
+
if (!event || !('clipboardData' in event) || !event.clipboardData) return false;
|
|
138
|
+
const clipboardData = event.clipboardData;
|
|
139
|
+
const hasLexicalJson = Boolean(clipboardData.getData(LEXICAL_MIME));
|
|
140
|
+
const plainText = clipboardData.getData('text/plain');
|
|
141
|
+
const hasPlainText = Boolean(plainText);
|
|
142
|
+
if (!hasLexicalJson && !hasPlainText) return false;
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
editor.update(()=>{
|
|
145
|
+
const selection = (0, external_lexical_namespaceObject.$getSelection)();
|
|
146
|
+
if (!selection) return;
|
|
147
|
+
if (hasLexicalJson && tryPasteLexicalContent(editor, clipboardData, selection)) return;
|
|
148
|
+
if (hasPlainText) pasteTextContent(plainText, selection);
|
|
149
|
+
}, {
|
|
150
|
+
discrete: true
|
|
151
|
+
});
|
|
152
|
+
return true;
|
|
153
|
+
}, external_lexical_namespaceObject.COMMAND_PRIORITY_CRITICAL)), [
|
|
154
|
+
editor
|
|
155
|
+
]);
|
|
156
|
+
return null;
|
|
157
|
+
};
|
|
158
|
+
exports.CopyPastePlugin = __webpack_exports__.CopyPastePlugin;
|
|
159
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
160
|
+
"CopyPastePlugin"
|
|
161
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
162
|
+
Object.defineProperty(exports, '__esModule', {
|
|
163
|
+
value: true
|
|
164
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CopyPastePlugin: () => null;
|