@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.
- package/dist/components/ui/avatar.d.ts +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/command.d.ts +13 -13
- package/dist/components/ui/index.cjs +30 -30
- package/dist/components/ui/prompt-editor/components/EditorToolbar.cjs +101 -68
- package/dist/components/ui/prompt-editor/components/EditorToolbar.d.ts +16 -2
- package/dist/components/ui/prompt-editor/components/EditorToolbar.js +101 -68
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.cjs +13 -8
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.d.ts +13 -1
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.js +13 -8
- package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.cjs +22 -11
- package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.js +23 -12
- package/dist/components/ui/prompt-editor/components/TokenPill.cjs +4 -2
- package/dist/components/ui/prompt-editor/components/TokenPill.js +4 -2
- package/dist/components/ui/prompt-editor/components/TokenPillSlot.cjs +58 -0
- package/dist/components/ui/prompt-editor/components/TokenPillSlot.d.ts +7 -0
- package/dist/components/ui/prompt-editor/components/TokenPillSlot.js +24 -0
- package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.cjs +8 -9
- package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.js +8 -9
- package/dist/components/ui/prompt-editor/index.cjs +152 -9
- package/dist/components/ui/prompt-editor/index.d.ts +13 -1
- package/dist/components/ui/prompt-editor/index.js +11 -1
- package/dist/components/ui/prompt-editor/nodes/InputTokenNode.cjs +2 -2
- package/dist/components/ui/prompt-editor/nodes/InputTokenNode.d.ts +1 -1
- package/dist/components/ui/prompt-editor/nodes/InputTokenNode.js +2 -2
- package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.cjs +2 -2
- package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.d.ts +1 -1
- package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.js +2 -2
- package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.cjs +2 -2
- package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.d.ts +1 -1
- package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.js +2 -2
- package/dist/components/ui/prompt-editor/nodes/StateTokenNode.cjs +2 -2
- package/dist/components/ui/prompt-editor/nodes/StateTokenNode.d.ts +1 -1
- package/dist/components/ui/prompt-editor/nodes/StateTokenNode.js +2 -2
- package/dist/components/ui/prompt-editor/nodes/index.cjs +1 -1
- package/dist/components/ui/prompt-editor/nodes/index.d.ts +5 -5
- package/dist/components/ui/prompt-editor/nodes/index.js +1 -1
- package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.cjs +11 -5
- package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.d.ts +8 -1
- package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.js +12 -6
- package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.cjs +1 -1
- package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.js +1 -1
- package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.cjs +1 -1
- package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.js +1 -1
- package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.cjs +1 -1
- package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.js +1 -1
- package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.cjs +12 -6
- package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.js +13 -7
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.cjs +64 -3
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.d.ts +6 -2
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.js +65 -4
- package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.cjs +4 -9
- package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.js +4 -9
- package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.cjs +10 -5
- package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.d.ts +3 -1
- package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.js +10 -5
- package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.cjs +1 -1
- package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.js +2 -2
- package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.cjs +10 -1
- package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.d.ts +4 -1
- package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.js +8 -2
- package/dist/components/ui/prompt-editor/prompt-editor-config.cjs +69 -0
- package/dist/components/ui/prompt-editor/prompt-editor-config.d.ts +70 -0
- package/dist/components/ui/prompt-editor/prompt-editor-config.js +29 -0
- package/dist/components/ui/prompt-editor/prompt-editor.cjs +198 -88
- package/dist/components/ui/prompt-editor/prompt-editor.d.ts +46 -1
- package/dist/components/ui/prompt-editor/prompt-editor.js +199 -89
- package/dist/components/ui/prompt-editor/types.cjs +5 -5
- package/dist/components/ui/prompt-editor/types.d.ts +18 -2
- package/dist/components/ui/prompt-editor/types.js +5 -5
- package/dist/components/ui/prompt-editor/utils/autocomplete-segments.cjs +10 -5
- package/dist/components/ui/prompt-editor/utils/autocomplete-segments.d.ts +13 -0
- package/dist/components/ui/prompt-editor/utils/autocomplete-segments.js +8 -6
- package/dist/components/ui/prompt-editor/utils/index.cjs +1 -1
- package/dist/components/ui/prompt-editor/utils/index.d.ts +1 -1
- package/dist/components/ui/prompt-editor/utils/index.js +1 -1
- package/dist/components/ui/prompt-editor/utils/insert-token.d.ts +1 -1
- package/dist/components/ui/prompt-editor/utils/rich-serialization.cjs +186 -0
- package/dist/components/ui/prompt-editor/utils/rich-serialization.d.ts +38 -0
- package/dist/components/ui/prompt-editor/utils/rich-serialization.js +140 -0
- package/dist/components/ui/prompt-editor/utils/serialization.cjs +13 -5
- package/dist/components/ui/prompt-editor/utils/serialization.js +14 -6
- package/dist/components/ui/sheet.d.ts +1 -1
- package/dist/components/ui/spinner.d.ts +1 -1
- package/dist/components/ui/switch.d.ts +2 -2
- package/dist/components/ui/toggle-group.d.ts +2 -2
- package/dist/components/ui/toggle.d.ts +2 -2
- package/dist/index.cjs +136 -61
- package/dist/index.d.ts +89 -89
- package/dist/index.js +61 -61
- package/dist/styles.css +15 -0
- package/package.json +3 -1
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
DEFAULT_PROMPT_EDITOR_STRINGS: ()=>DEFAULT_PROMPT_EDITOR_STRINGS,
|
|
28
|
+
PromptEditorConfigProvider: ()=>PromptEditorConfigProvider,
|
|
29
|
+
usePromptEditorConfig: ()=>usePromptEditorConfig
|
|
30
|
+
});
|
|
31
|
+
const external_react_namespaceObject = require("react");
|
|
32
|
+
const DEFAULT_PROMPT_EDITOR_STRINGS = {
|
|
33
|
+
edit: 'Edit',
|
|
34
|
+
preview: 'Preview',
|
|
35
|
+
editorModeLabel: 'Editor mode',
|
|
36
|
+
bold: 'Bold',
|
|
37
|
+
italic: 'Italic',
|
|
38
|
+
strikethrough: 'Strikethrough',
|
|
39
|
+
numberedList: 'Numbered List',
|
|
40
|
+
bulletedList: 'Bulleted List',
|
|
41
|
+
expand: 'Expand',
|
|
42
|
+
searchVariablesPlaceholder: 'Search variables…',
|
|
43
|
+
noVariablesFound: 'No variables found.',
|
|
44
|
+
insertFreeForm: 'Insert {path}',
|
|
45
|
+
tokenTypeInput: 'Input variable',
|
|
46
|
+
tokenTypeOutput: 'Output variable',
|
|
47
|
+
tokenTypeState: 'State variable',
|
|
48
|
+
tokenTypeResource: 'Resource',
|
|
49
|
+
removeToken: 'Remove token',
|
|
50
|
+
nothingToPreview: 'Nothing to preview',
|
|
51
|
+
invalidTokenTitle: 'Variable not found',
|
|
52
|
+
invalidTokenDescription: "{path} isn't available in this scope. Fix or remove this reference before publishing."
|
|
53
|
+
};
|
|
54
|
+
const PromptEditorConfigContext = /*#__PURE__*/ (0, external_react_namespaceObject.createContext)({
|
|
55
|
+
strings: DEFAULT_PROMPT_EDITOR_STRINGS
|
|
56
|
+
});
|
|
57
|
+
const PromptEditorConfigProvider = PromptEditorConfigContext.Provider;
|
|
58
|
+
const usePromptEditorConfig = ()=>(0, external_react_namespaceObject.useContext)(PromptEditorConfigContext);
|
|
59
|
+
exports.DEFAULT_PROMPT_EDITOR_STRINGS = __webpack_exports__.DEFAULT_PROMPT_EDITOR_STRINGS;
|
|
60
|
+
exports.PromptEditorConfigProvider = __webpack_exports__.PromptEditorConfigProvider;
|
|
61
|
+
exports.usePromptEditorConfig = __webpack_exports__.usePromptEditorConfig;
|
|
62
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
63
|
+
"DEFAULT_PROMPT_EDITOR_STRINGS",
|
|
64
|
+
"PromptEditorConfigProvider",
|
|
65
|
+
"usePromptEditorConfig"
|
|
66
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
67
|
+
Object.defineProperty(exports, '__esModule', {
|
|
68
|
+
value: true
|
|
69
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { PromptEditorDiffType, PromptEditorTokenType } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Props handed to a consumer-supplied token-pill renderer. `defaultPill` is the built-in
|
|
5
|
+
* `TokenPillWithTooltip` rendered with the same props, so a consumer can decorate it (wrap it in a
|
|
6
|
+
* richer tooltip / warning affordance) instead of rebuilding the pill from scratch.
|
|
7
|
+
*/
|
|
8
|
+
export interface PromptEditorTokenPillSlotProps {
|
|
9
|
+
/** Variable path without a leading `$` (apollo-wind convention). */
|
|
10
|
+
value: string;
|
|
11
|
+
tokenType: Exclude<PromptEditorTokenType, 'text'>;
|
|
12
|
+
/** Lexical node key of the underlying decorator node (drives NodeSelection / replace commands). */
|
|
13
|
+
nodeKey: string;
|
|
14
|
+
diffType?: PromptEditorDiffType;
|
|
15
|
+
readonly: boolean;
|
|
16
|
+
isInvalid?: boolean;
|
|
17
|
+
onRemove: () => void;
|
|
18
|
+
/** The built-in pill rendered with these same props. */
|
|
19
|
+
defaultPill: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
export type PromptEditorRenderTokenPill = (props: PromptEditorTokenPillSlotProps) => ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Overridable user-facing strings. Apollo-wind has no i18n runtime of its own; hosts that localize
|
|
24
|
+
* (e.g. via react-i18next) pass translated values here. Every key defaults to the built-in English.
|
|
25
|
+
*/
|
|
26
|
+
export interface PromptEditorStrings {
|
|
27
|
+
/** Edit/Preview switcher */
|
|
28
|
+
edit: string;
|
|
29
|
+
preview: string;
|
|
30
|
+
editorModeLabel: string;
|
|
31
|
+
/** Formatting toolbar buttons */
|
|
32
|
+
bold: string;
|
|
33
|
+
italic: string;
|
|
34
|
+
strikethrough: string;
|
|
35
|
+
numberedList: string;
|
|
36
|
+
bulletedList: string;
|
|
37
|
+
expand: string;
|
|
38
|
+
/** `$`-trigger autocomplete menu */
|
|
39
|
+
searchVariablesPlaceholder: string;
|
|
40
|
+
noVariablesFound: string;
|
|
41
|
+
/**
|
|
42
|
+
* Label for the free-form "Insert <path>" item. `{path}` marks where the typed path renders
|
|
43
|
+
* (bold), so verb-last languages can move it; a string without `{path}` is treated as a prefix.
|
|
44
|
+
*/
|
|
45
|
+
insertFreeForm: string;
|
|
46
|
+
/** Token type labels: chip hover tooltip + autocomplete menu's trailing hint. */
|
|
47
|
+
tokenTypeInput: string;
|
|
48
|
+
tokenTypeOutput: string;
|
|
49
|
+
tokenTypeState: string;
|
|
50
|
+
tokenTypeResource: string;
|
|
51
|
+
/** aria-label of the chip's × button. */
|
|
52
|
+
removeToken: string;
|
|
53
|
+
/** Preview-mode placeholder when there is no content. */
|
|
54
|
+
nothingToPreview: string;
|
|
55
|
+
/** Invalid-chip tooltip: title, and a body template whose `{path}` is the chip's variable path. */
|
|
56
|
+
invalidTokenTitle: string;
|
|
57
|
+
invalidTokenDescription: string;
|
|
58
|
+
}
|
|
59
|
+
export declare const DEFAULT_PROMPT_EDITOR_STRINGS: PromptEditorStrings;
|
|
60
|
+
interface PromptEditorConfig {
|
|
61
|
+
renderTokenPill?: PromptEditorRenderTokenPill;
|
|
62
|
+
strings: PromptEditorStrings;
|
|
63
|
+
}
|
|
64
|
+
export declare const PromptEditorConfigProvider: import("react").Provider<PromptEditorConfig>;
|
|
65
|
+
/**
|
|
66
|
+
* Read the active editor config. Token decorator nodes render inside the `LexicalComposer` React
|
|
67
|
+
* tree, so the provider mounted by `PromptEditor` is visible to them (and to plugins).
|
|
68
|
+
*/
|
|
69
|
+
export declare const usePromptEditorConfig: () => PromptEditorConfig;
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const DEFAULT_PROMPT_EDITOR_STRINGS = {
|
|
3
|
+
edit: 'Edit',
|
|
4
|
+
preview: 'Preview',
|
|
5
|
+
editorModeLabel: 'Editor mode',
|
|
6
|
+
bold: 'Bold',
|
|
7
|
+
italic: 'Italic',
|
|
8
|
+
strikethrough: 'Strikethrough',
|
|
9
|
+
numberedList: 'Numbered List',
|
|
10
|
+
bulletedList: 'Bulleted List',
|
|
11
|
+
expand: 'Expand',
|
|
12
|
+
searchVariablesPlaceholder: 'Search variables…',
|
|
13
|
+
noVariablesFound: 'No variables found.',
|
|
14
|
+
insertFreeForm: 'Insert {path}',
|
|
15
|
+
tokenTypeInput: 'Input variable',
|
|
16
|
+
tokenTypeOutput: 'Output variable',
|
|
17
|
+
tokenTypeState: 'State variable',
|
|
18
|
+
tokenTypeResource: 'Resource',
|
|
19
|
+
removeToken: 'Remove token',
|
|
20
|
+
nothingToPreview: 'Nothing to preview',
|
|
21
|
+
invalidTokenTitle: 'Variable not found',
|
|
22
|
+
invalidTokenDescription: "{path} isn't available in this scope. Fix or remove this reference before publishing."
|
|
23
|
+
};
|
|
24
|
+
const PromptEditorConfigContext = /*#__PURE__*/ createContext({
|
|
25
|
+
strings: DEFAULT_PROMPT_EDITOR_STRINGS
|
|
26
|
+
});
|
|
27
|
+
const PromptEditorConfigProvider = PromptEditorConfigContext.Provider;
|
|
28
|
+
const usePromptEditorConfig = ()=>useContext(PromptEditorConfigContext);
|
|
29
|
+
export { DEFAULT_PROMPT_EDITOR_STRINGS, PromptEditorConfigProvider, usePromptEditorConfig };
|
|
@@ -31,8 +31,11 @@ const LexicalComposer_namespaceObject = require("@lexical/react/LexicalComposer"
|
|
|
31
31
|
const LexicalContentEditable_namespaceObject = require("@lexical/react/LexicalContentEditable");
|
|
32
32
|
const LexicalErrorBoundary_namespaceObject = require("@lexical/react/LexicalErrorBoundary");
|
|
33
33
|
const LexicalHistoryPlugin_namespaceObject = require("@lexical/react/LexicalHistoryPlugin");
|
|
34
|
+
const LexicalListPlugin_namespaceObject = require("@lexical/react/LexicalListPlugin");
|
|
35
|
+
const LexicalMarkdownShortcutPlugin_namespaceObject = require("@lexical/react/LexicalMarkdownShortcutPlugin");
|
|
34
36
|
const LexicalOnChangePlugin_namespaceObject = require("@lexical/react/LexicalOnChangePlugin");
|
|
35
37
|
const LexicalPlainTextPlugin_namespaceObject = require("@lexical/react/LexicalPlainTextPlugin");
|
|
38
|
+
const LexicalRichTextPlugin_namespaceObject = require("@lexical/react/LexicalRichTextPlugin");
|
|
36
39
|
const external_lexical_namespaceObject = require("lexical");
|
|
37
40
|
const external_react_namespaceObject = require("react");
|
|
38
41
|
const external_form_field_cjs_namespaceObject = require("../form-field.cjs");
|
|
@@ -50,15 +53,19 @@ const ToolbarActionsPlugin_cjs_namespaceObject = require("./plugins/ToolbarActio
|
|
|
50
53
|
const ValidateTokensPlugin_cjs_namespaceObject = require("./plugins/ValidateTokensPlugin.cjs");
|
|
51
54
|
const ValueSyncPlugin_cjs_namespaceObject = require("./plugins/ValueSyncPlugin.cjs");
|
|
52
55
|
const VariableDropPlugin_cjs_namespaceObject = require("./plugins/VariableDropPlugin.cjs");
|
|
56
|
+
const external_prompt_editor_config_cjs_namespaceObject = require("./prompt-editor-config.cjs");
|
|
53
57
|
const external_utils_index_cjs_namespaceObject = require("./utils/index.cjs");
|
|
58
|
+
const rich_serialization_cjs_namespaceObject = require("./utils/rich-serialization.cjs");
|
|
54
59
|
const DEFAULT_MIN_ROWS = 4;
|
|
55
60
|
const DEFAULT_MAX_ROWS = 20;
|
|
56
61
|
const LINE_HEIGHT = 20;
|
|
57
62
|
const EMPTY_AUTOCOMPLETE_OPTIONS = [];
|
|
58
63
|
const EMPTY_TOKENS = [];
|
|
59
64
|
const toTokenArray = (v)=>void 0 === v ? void 0 : Array.isArray(v) ? v : EMPTY_TOKENS;
|
|
60
|
-
const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)(({ initialValue, value, onChange, autoCompleteOptions = EMPTY_AUTOCOMPLETE_OPTIONS, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, fillHeight, borderless, error, errorId, ariaDescribedBy, mapVarDropToToken, toolbarActionsRef, showToolbar }, ref)=>{
|
|
65
|
+
const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)(({ initialValue, value, onChange, autoCompleteOptions = EMPTY_AUTOCOMPLETE_OPTIONS, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, fillHeight, borderless, error, errorId, ariaDescribedBy, mapVarDropToToken, validationOptions, renderAutocompleteMenu, toolbarActionsRef, showToolbar, children, richText, onActiveFormatsChange }, ref)=>{
|
|
61
66
|
const editorRef = (0, external_react_namespaceObject.useRef)(null);
|
|
67
|
+
const $getTokens = richText ? rich_serialization_cjs_namespaceObject.$getRichEditorTokensInternal : external_utils_index_cjs_namespaceObject.$getEditorTokensInternal;
|
|
68
|
+
const $setTokens = richText ? rich_serialization_cjs_namespaceObject.$setRichEditorTokensInternal : external_utils_index_cjs_namespaceObject.$setEditorTokensInternal;
|
|
62
69
|
const [isEmpty, setIsEmpty] = (0, external_react_namespaceObject.useState)(()=>{
|
|
63
70
|
const seed = initialValue ?? value;
|
|
64
71
|
return !seed || 0 === seed.length;
|
|
@@ -76,7 +83,7 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
76
83
|
(0, external_react_namespaceObject.useImperativeHandle)(ref, ()=>({
|
|
77
84
|
setTokens: (tokens)=>{
|
|
78
85
|
if (editorRef.current) editorRef.current.update(()=>{
|
|
79
|
-
(
|
|
86
|
+
$setTokens(tokens);
|
|
80
87
|
});
|
|
81
88
|
else onChangeRef.current?.(tokens);
|
|
82
89
|
},
|
|
@@ -97,7 +104,9 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
97
104
|
(0, external_utils_index_cjs_namespaceObject.$insertTokenAtCursor)(option);
|
|
98
105
|
});
|
|
99
106
|
}
|
|
100
|
-
}), [
|
|
107
|
+
}), [
|
|
108
|
+
$setTokens
|
|
109
|
+
]);
|
|
101
110
|
const contentEditableStyle = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
102
111
|
const verticalPadding = 8;
|
|
103
112
|
const textColor = borderless ? 'inherit' : 'var(--color-foreground)';
|
|
@@ -146,7 +155,7 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
146
155
|
const handleChange = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
147
156
|
if (!editorRef.current) return;
|
|
148
157
|
editorRef.current.getEditorState().read(()=>{
|
|
149
|
-
const tokens = (
|
|
158
|
+
const tokens = $getTokens();
|
|
150
159
|
const newIsEmpty = 0 === tokens.length || 1 === tokens.length && 'text' === tokens[0].type && '' === tokens[0].value;
|
|
151
160
|
if (newIsEmpty !== isEmptyRef.current) setIsEmpty(newIsEmpty);
|
|
152
161
|
if (!isSyncingRef.current) pendingTokensRef.current = tokens;
|
|
@@ -183,7 +192,7 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
183
192
|
queueMicrotask(()=>{
|
|
184
193
|
if (!editorRef.current || initializedRef.current) return;
|
|
185
194
|
editorRef.current.update(()=>{
|
|
186
|
-
(
|
|
195
|
+
$setTokens(valueToSet);
|
|
187
196
|
setIsEmpty(0 === valueToSet.length);
|
|
188
197
|
initializedRef.current = true;
|
|
189
198
|
});
|
|
@@ -196,7 +205,8 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
196
205
|
disabled
|
|
197
206
|
]);
|
|
198
207
|
const options = Array.isArray(autoCompleteOptions) ? autoCompleteOptions : EMPTY_AUTOCOMPLETE_OPTIONS;
|
|
199
|
-
const
|
|
208
|
+
const shellFocusClasses = showToolbar ? '' : ' focus-within:ring-2 focus-within:ring-ring future:focus-within:ring-offset-2 future:focus-within:ring-offset-background';
|
|
209
|
+
const wrapperClassName = borderless ? 'flex flex-col w-full relative' : `prompt-editor-shell flex flex-col w-full relative border bg-background future:border-0 future:bg-surface-overlay ${showToolbar ? 'border-t-0 rounded-b-md future:rounded-b-xl' : 'rounded-md future:rounded-xl'} ${error ? 'border-error ring-1 ring-error/20 future:ring-error/40' : ''}${shellFocusClasses}`;
|
|
200
210
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
201
211
|
className: wrapperClassName,
|
|
202
212
|
"data-invalid": error ? 'true' : void 0,
|
|
@@ -213,8 +223,18 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
213
223
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("style", {
|
|
214
224
|
children: `
|
|
215
225
|
.prompt-editor-paragraph { padding: 0; margin: 0; }
|
|
216
|
-
${borderless ? '' : '.prompt-editor-shell:not([data-invalid="true"]):focus-within { border-color: var(--color-ring); box-shadow: 0 0 0 1px var(--color-ring); } .future .prompt-editor-shell:not([data-invalid="true"]):focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-ring) 35%, transparent); }'}
|
|
217
226
|
.prompt-editor-root *::selection { background-color: color-mix(in srgb, var(--color-primary) 30%, transparent); }
|
|
227
|
+
${richText ? `
|
|
228
|
+
/* Rich-mode formatting — metrics mirror MarkdownPreview so editing matches rendering. */
|
|
229
|
+
.prompt-editor-text-bold { font-weight: 700; }
|
|
230
|
+
.prompt-editor-text-italic { font-style: italic; }
|
|
231
|
+
.prompt-editor-text-strikethrough { text-decoration: line-through; }
|
|
232
|
+
.prompt-editor-list-ul, .prompt-editor-list-ol { margin: 0.25em 0; padding-left: 1.5em; }
|
|
233
|
+
.prompt-editor-list-ul { list-style-type: disc; }
|
|
234
|
+
.prompt-editor-list-ol { list-style-type: decimal; }
|
|
235
|
+
.prompt-editor-list-item { margin: 0.125em 0; }
|
|
236
|
+
.prompt-editor-list-item-nested { list-style-type: none; }
|
|
237
|
+
` : ''}
|
|
218
238
|
`
|
|
219
239
|
}),
|
|
220
240
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
@@ -229,7 +249,17 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
229
249
|
} : {}
|
|
230
250
|
},
|
|
231
251
|
children: [
|
|
232
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
252
|
+
richText ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalRichTextPlugin_namespaceObject.RichTextPlugin, {
|
|
253
|
+
contentEditable: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalContentEditable_namespaceObject.ContentEditable, {
|
|
254
|
+
style: contentEditableStyle,
|
|
255
|
+
ariaLabel: ariaLabel,
|
|
256
|
+
"aria-invalid": error ? true : void 0,
|
|
257
|
+
"aria-describedby": ariaDescribedBy,
|
|
258
|
+
"aria-errormessage": error ? errorId : void 0
|
|
259
|
+
}),
|
|
260
|
+
placeholder: null,
|
|
261
|
+
ErrorBoundary: LexicalErrorBoundary_namespaceObject.LexicalErrorBoundary
|
|
262
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalPlainTextPlugin_namespaceObject.PlainTextPlugin, {
|
|
233
263
|
contentEditable: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalContentEditable_namespaceObject.ContentEditable, {
|
|
234
264
|
style: contentEditableStyle,
|
|
235
265
|
ariaLabel: ariaLabel,
|
|
@@ -272,23 +302,35 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
272
302
|
value: value,
|
|
273
303
|
editorRef: editorRef,
|
|
274
304
|
lastEmittedValueRef: lastEmittedValueRef,
|
|
275
|
-
isSyncingRef: isSyncingRef
|
|
305
|
+
isSyncingRef: isSyncingRef,
|
|
306
|
+
richText: richText
|
|
276
307
|
}),
|
|
277
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MultilinePlugin_cjs_namespaceObject.MultilinePlugin, {
|
|
308
|
+
!richText && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MultilinePlugin_cjs_namespaceObject.MultilinePlugin, {
|
|
278
309
|
multiline: multiline
|
|
279
310
|
}),
|
|
311
|
+
richText && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
312
|
+
children: [
|
|
313
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalListPlugin_namespaceObject.ListPlugin, {}),
|
|
314
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalMarkdownShortcutPlugin_namespaceObject.MarkdownShortcutPlugin, {
|
|
315
|
+
transformers: rich_serialization_cjs_namespaceObject.PROMPT_EDITOR_RICH_TRANSFORMERS
|
|
316
|
+
})
|
|
317
|
+
]
|
|
318
|
+
}),
|
|
280
319
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalOnChangePlugin_namespaceObject.OnChangePlugin, {
|
|
281
320
|
ignoreSelectionChange: true,
|
|
282
321
|
onChange: handleChange
|
|
283
322
|
}),
|
|
284
323
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ToolbarActionsPlugin_cjs_namespaceObject.ToolbarActionsPlugin, {
|
|
285
|
-
actionsRef: toolbarActionsRef
|
|
324
|
+
actionsRef: toolbarActionsRef,
|
|
325
|
+
richText: richText,
|
|
326
|
+
onActiveFormatsChange: onActiveFormatsChange
|
|
286
327
|
}),
|
|
287
|
-
options.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(AutocompletePlugin_cjs_namespaceObject.AutocompletePlugin, {
|
|
288
|
-
options: options
|
|
328
|
+
(options.length > 0 || renderAutocompleteMenu) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(AutocompletePlugin_cjs_namespaceObject.AutocompletePlugin, {
|
|
329
|
+
options: options,
|
|
330
|
+
renderMenu: renderAutocompleteMenu
|
|
289
331
|
}),
|
|
290
332
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ValidateTokensPlugin_cjs_namespaceObject.ValidateTokensPlugin, {
|
|
291
|
-
options: options
|
|
333
|
+
options: Array.isArray(validationOptions) ? validationOptions : options
|
|
292
334
|
}),
|
|
293
335
|
options.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RenameTokensPlugin_cjs_namespaceObject.RenameTokensPlugin, {
|
|
294
336
|
options: options,
|
|
@@ -297,17 +339,27 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
297
339
|
mapVarDropToToken && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(VariableDropPlugin_cjs_namespaceObject.VariableDropPlugin, {
|
|
298
340
|
mapVarDropToToken: mapVarDropToToken,
|
|
299
341
|
disabled: disabled
|
|
300
|
-
})
|
|
342
|
+
}),
|
|
343
|
+
children
|
|
301
344
|
]
|
|
302
345
|
});
|
|
303
346
|
});
|
|
304
347
|
EditorInner.displayName = 'PromptEditorInner';
|
|
305
|
-
const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar = false, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, error, errorId: providedErrorId, 'aria-describedby': nativeAriaDescribedBy, ariaDescribedBy: legacyAriaDescribedBy, mapVarDropToToken })=>{
|
|
348
|
+
const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar = false, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, error, errorId: providedErrorId, 'aria-describedby': nativeAriaDescribedBy, ariaDescribedBy: legacyAriaDescribedBy, mapVarDropToToken, validationOptions, renderAutocompleteMenu, renderTokenPill, strings: partialStrings, showModeToggle = true, toolbarTrailing, children, richText: richTextProp, previewToken })=>{
|
|
306
349
|
const value = toTokenArray(rawValue);
|
|
307
350
|
const initialValue = toTokenArray(rawInitialValue);
|
|
351
|
+
const [richText] = (0, external_react_namespaceObject.useState)(()=>{
|
|
352
|
+
if (richTextProp && !multiline) {
|
|
353
|
+
console.warn('PromptEditor: richText requires multiline — falling back to the plain editor.');
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
return !!richTextProp;
|
|
357
|
+
});
|
|
308
358
|
const [internalMode, setInternalMode] = (0, external_react_namespaceObject.useState)('edit');
|
|
309
|
-
const
|
|
359
|
+
const modeLocked = richText || showToolbar && !showModeToggle;
|
|
360
|
+
const mode = modeLocked ? 'edit' : controlledMode ?? internalMode;
|
|
310
361
|
const toolbarActionsRef = (0, external_react_namespaceObject.useRef)(null);
|
|
362
|
+
const [activeFormats, setActiveFormats] = (0, external_react_namespaceObject.useState)(void 0);
|
|
311
363
|
const [uncontrolledPreviewTokens, setUncontrolledPreviewTokens] = (0, external_react_namespaceObject.useState)(initialValue ?? []);
|
|
312
364
|
const handleModeChange = (0, external_react_namespaceObject.useCallback)((newMode)=>{
|
|
313
365
|
if (onModeChange) onModeChange(newMode);
|
|
@@ -318,16 +370,34 @@ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange
|
|
|
318
370
|
const initialConfig = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
319
371
|
namespace: 'PromptEditor',
|
|
320
372
|
theme: {
|
|
321
|
-
paragraph: 'prompt-editor-paragraph'
|
|
373
|
+
paragraph: 'prompt-editor-paragraph',
|
|
374
|
+
...richText ? {
|
|
375
|
+
text: {
|
|
376
|
+
bold: 'prompt-editor-text-bold',
|
|
377
|
+
italic: 'prompt-editor-text-italic',
|
|
378
|
+
strikethrough: 'prompt-editor-text-strikethrough'
|
|
379
|
+
},
|
|
380
|
+
list: {
|
|
381
|
+
ul: 'prompt-editor-list-ul',
|
|
382
|
+
ol: 'prompt-editor-list-ol',
|
|
383
|
+
listitem: 'prompt-editor-list-item',
|
|
384
|
+
nested: {
|
|
385
|
+
listitem: 'prompt-editor-list-item-nested'
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
} : {}
|
|
322
389
|
},
|
|
323
390
|
onError: (error)=>console.error('PromptEditor error:', error),
|
|
324
391
|
nodes: [
|
|
325
392
|
index_cjs_namespaceObject.InputTokenNode,
|
|
326
393
|
index_cjs_namespaceObject.OutputTokenNode,
|
|
327
394
|
index_cjs_namespaceObject.StateTokenNode,
|
|
328
|
-
index_cjs_namespaceObject.ResourceTokenNode
|
|
395
|
+
index_cjs_namespaceObject.ResourceTokenNode,
|
|
396
|
+
...richText ? rich_serialization_cjs_namespaceObject.RICH_EDITOR_EXTRA_NODES : []
|
|
329
397
|
]
|
|
330
|
-
}), [
|
|
398
|
+
}), [
|
|
399
|
+
richText
|
|
400
|
+
]);
|
|
331
401
|
const isControlled = void 0 !== value;
|
|
332
402
|
const previewTokens = isControlled ? value : uncontrolledPreviewTokens;
|
|
333
403
|
const generatedErrorId = (0, external_react_namespaceObject.useId)();
|
|
@@ -344,75 +414,115 @@ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange
|
|
|
344
414
|
isControlled,
|
|
345
415
|
onChange
|
|
346
416
|
]);
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
417
|
+
const strings = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
418
|
+
...external_prompt_editor_config_cjs_namespaceObject.DEFAULT_PROMPT_EDITOR_STRINGS,
|
|
419
|
+
...partialStrings
|
|
420
|
+
}), [
|
|
421
|
+
partialStrings
|
|
422
|
+
]);
|
|
423
|
+
const editorConfig = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
424
|
+
renderTokenPill,
|
|
425
|
+
strings
|
|
426
|
+
}), [
|
|
427
|
+
renderTokenPill,
|
|
428
|
+
strings
|
|
429
|
+
]);
|
|
430
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_prompt_editor_config_cjs_namespaceObject.PromptEditorConfigProvider, {
|
|
431
|
+
value: editorConfig,
|
|
432
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tooltip_cjs_namespaceObject.TooltipProvider, {
|
|
433
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
434
|
+
style: {
|
|
435
|
+
display: 'flex',
|
|
436
|
+
flexDirection: 'column',
|
|
437
|
+
width: '100%',
|
|
438
|
+
...fillHeight ? {
|
|
439
|
+
flex: 1,
|
|
440
|
+
minHeight: 0
|
|
441
|
+
} : {}
|
|
442
|
+
},
|
|
443
|
+
children: [
|
|
444
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
445
|
+
className: showToolbar && !borderless ? 'prompt-editor-frame rounded-md future:rounded-xl focus-within:ring-2 focus-within:ring-ring future:focus-within:ring-offset-2 future:focus-within:ring-offset-background' : void 0,
|
|
446
|
+
style: {
|
|
447
|
+
display: 'flex',
|
|
448
|
+
flexDirection: 'column',
|
|
449
|
+
width: '100%',
|
|
450
|
+
...fillHeight ? {
|
|
451
|
+
flex: 1,
|
|
452
|
+
minHeight: 0
|
|
453
|
+
} : {}
|
|
454
|
+
},
|
|
455
|
+
children: [
|
|
456
|
+
showToolbar && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EditorToolbar_cjs_namespaceObject.EditorToolbar, {
|
|
457
|
+
mode: mode,
|
|
458
|
+
disabled: disabled,
|
|
459
|
+
error: Boolean(error),
|
|
460
|
+
actionsRef: toolbarActionsRef,
|
|
461
|
+
onModeChange: handleModeChange,
|
|
462
|
+
onFullscreen: onFullscreen,
|
|
463
|
+
showModeToggle: showModeToggle && !richText,
|
|
464
|
+
trailing: toolbarTrailing,
|
|
465
|
+
strings: strings,
|
|
466
|
+
activeFormats: richText ? activeFormats : void 0
|
|
467
|
+
}),
|
|
468
|
+
'preview' === mode && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
469
|
+
"data-invalid": error ? 'true' : void 0,
|
|
470
|
+
className: borderless ? void 0 : `border bg-background future:border-0 future:bg-surface-overlay ${showToolbar ? 'border-t-0 rounded-b-md future:rounded-b-xl' : 'rounded-md future:rounded-xl'} ${error ? 'border-error ring-1 ring-error/20 future:ring-error/40' : ''}`,
|
|
471
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MarkdownPreview_cjs_namespaceObject.MarkdownPreview, {
|
|
472
|
+
tokens: previewTokens,
|
|
473
|
+
minRows: minRows,
|
|
474
|
+
previewToken: previewToken
|
|
475
|
+
})
|
|
476
|
+
}),
|
|
477
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
478
|
+
style: {
|
|
479
|
+
display: 'preview' === mode ? 'none' : 'flex',
|
|
480
|
+
flexDirection: 'column',
|
|
481
|
+
...fillHeight ? {
|
|
482
|
+
flex: 1,
|
|
483
|
+
minHeight: 0
|
|
484
|
+
} : {}
|
|
485
|
+
},
|
|
486
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalComposer_namespaceObject.LexicalComposer, {
|
|
487
|
+
initialConfig: initialConfig,
|
|
488
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EditorInner, {
|
|
489
|
+
ref: editorRef,
|
|
490
|
+
autoCompleteOptions: autoCompleteOptions,
|
|
491
|
+
disabled: disabled,
|
|
492
|
+
ariaLabel: ariaLabel,
|
|
493
|
+
error: error,
|
|
494
|
+
errorId: error ? errorId : void 0,
|
|
495
|
+
ariaDescribedBy: describedBy || void 0,
|
|
496
|
+
initialValue: initialValue,
|
|
497
|
+
maxRows: maxRows,
|
|
498
|
+
minRows: minRows,
|
|
499
|
+
multiline: multiline,
|
|
500
|
+
placeholder: placeholder,
|
|
501
|
+
fillHeight: fillHeight,
|
|
502
|
+
borderless: borderless,
|
|
503
|
+
mapVarDropToToken: mapVarDropToToken,
|
|
504
|
+
validationOptions: validationOptions,
|
|
505
|
+
renderAutocompleteMenu: renderAutocompleteMenu,
|
|
506
|
+
showToolbar: showToolbar,
|
|
507
|
+
toolbarActionsRef: toolbarActionsRef,
|
|
508
|
+
value: value,
|
|
509
|
+
onChange: handleEditorChange,
|
|
510
|
+
richText: richText,
|
|
511
|
+
onActiveFormatsChange: richText ? setActiveFormats : void 0,
|
|
512
|
+
children: children
|
|
513
|
+
})
|
|
514
|
+
})
|
|
515
|
+
})
|
|
516
|
+
]
|
|
517
|
+
}),
|
|
518
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
519
|
+
id: errorId,
|
|
520
|
+
"data-slot": "prompt-editor-error",
|
|
521
|
+
className: "mt-1",
|
|
522
|
+
children: error
|
|
407
523
|
})
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
id: errorId,
|
|
411
|
-
"data-slot": "prompt-editor-error",
|
|
412
|
-
className: "mt-1",
|
|
413
|
-
children: error
|
|
414
|
-
})
|
|
415
|
-
]
|
|
524
|
+
]
|
|
525
|
+
})
|
|
416
526
|
})
|
|
417
527
|
});
|
|
418
528
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { type MarkdownPreviewProps } from './components/MarkdownPreview';
|
|
2
|
+
import type { PromptEditorAutocompleteMenuProps } from './components/PromptEditorAutocompleteMenu';
|
|
3
|
+
import { type PromptEditorRenderTokenPill, type PromptEditorStrings } from './prompt-editor-config';
|
|
1
4
|
import type { PromptEditorAutoCompleteOption, PromptEditorMode, PromptEditorToken } from './types';
|
|
2
5
|
export interface PromptEditorRef {
|
|
3
6
|
setTokens: (tokens: PromptEditorToken[]) => void;
|
|
@@ -39,5 +42,47 @@ export interface PromptEditorProps {
|
|
|
39
42
|
* `dataTransfer`); omit this prop to disable drop handling entirely.
|
|
40
43
|
*/
|
|
41
44
|
mapVarDropToToken?: (insertPath: string) => PromptEditorAutoCompleteOption;
|
|
45
|
+
/**
|
|
46
|
+
* Token values chips are validated against. Defaults to `autoCompleteOptions`. Pass a wider set
|
|
47
|
+
* when values can be valid without being offered by autocomplete (e.g. runtime-only paths) —
|
|
48
|
+
* merging them into `autoCompleteOptions` instead would pollute the `$`-trigger menu.
|
|
49
|
+
*/
|
|
50
|
+
validationOptions?: PromptEditorAutoCompleteOption[];
|
|
51
|
+
/**
|
|
52
|
+
* Replace the built-in `$`-trigger autocomplete menu with a consumer-supplied one. Receives the
|
|
53
|
+
* exact props the built-in menu would get (anchor, seeded search, options, select/close
|
|
54
|
+
* callbacks). Also enables the `$` trigger when `autoCompleteOptions` is empty, since the
|
|
55
|
+
* consumer's menu may source its own entries.
|
|
56
|
+
*/
|
|
57
|
+
renderAutocompleteMenu?: (props: PromptEditorAutocompleteMenuProps) => React.ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* Replace (or decorate — the built-in pill is passed as `defaultPill`) the rendered token chips.
|
|
60
|
+
*/
|
|
61
|
+
renderTokenPill?: PromptEditorRenderTokenPill;
|
|
62
|
+
/** Overridable user-facing strings for localizing hosts. Merged over the built-in English. */
|
|
63
|
+
strings?: Partial<PromptEditorStrings>;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the toolbar's Edit/Preview switcher renders (only meaningful with `showToolbar`).
|
|
66
|
+
* When false the formatting cluster left-aligns and `toolbarTrailing` right-aligns, and the
|
|
67
|
+
* editor never enters preview mode. Defaults to true.
|
|
68
|
+
*/
|
|
69
|
+
showModeToggle?: boolean;
|
|
70
|
+
/** Consumer-supplied node at the toolbar's right end (e.g. a value-mode menu). */
|
|
71
|
+
toolbarTrailing?: React.ReactNode;
|
|
72
|
+
/** Extra Lexical plugins mounted inside the composer (e.g. host-specific drop/replace plugins). */
|
|
73
|
+
children?: React.ReactNode;
|
|
74
|
+
/**
|
|
75
|
+
* Per-token pill override for PREVIEW mode, so preview pills can match the host's edit-mode pills
|
|
76
|
+
* (icon markup and/or label). See {@link MarkdownPreviewTokenOverride}.
|
|
77
|
+
*/
|
|
78
|
+
previewToken?: MarkdownPreviewProps['previewToken'];
|
|
79
|
+
/**
|
|
80
|
+
* WYSIWYG mode: formatting renders live in the editor (real bold/italic/strike and lists) instead
|
|
81
|
+
* of markdown markers with a separate preview. The `PromptEditorToken[]` contract is unchanged —
|
|
82
|
+
* text tokens still carry markdown; the conversion happens at the editor boundary. Mount-time
|
|
83
|
+
* only (it feeds the composer's frozen `initialConfig`); requires `multiline`. In rich mode the
|
|
84
|
+
* Edit/Preview switcher and `mode='preview'` are inert — the editor IS the preview.
|
|
85
|
+
*/
|
|
86
|
+
richText?: boolean;
|
|
42
87
|
}
|
|
43
|
-
export declare const PromptEditor: ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline, minRows, maxRows, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, error, errorId: providedErrorId, "aria-describedby": nativeAriaDescribedBy, ariaDescribedBy: legacyAriaDescribedBy, mapVarDropToToken, }: PromptEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
88
|
+
export declare const PromptEditor: ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline, minRows, maxRows, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, error, errorId: providedErrorId, "aria-describedby": nativeAriaDescribedBy, ariaDescribedBy: legacyAriaDescribedBy, mapVarDropToToken, validationOptions, renderAutocompleteMenu, renderTokenPill, strings: partialStrings, showModeToggle, toolbarTrailing, children, richText: richTextProp, previewToken, }: PromptEditorProps) => import("react/jsx-runtime").JSX.Element;
|