@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,122 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Bold, Italic, List, ListOrdered, Maximize2, Strikethrough } from "lucide-react";
|
|
3
|
+
import { cn } from "../../../../lib/index.js";
|
|
4
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../../tooltip.js";
|
|
5
|
+
const ToolbarButton = ({ icon: Icon, label, disabled, onClick })=>/*#__PURE__*/ jsxs(Tooltip, {
|
|
6
|
+
children: [
|
|
7
|
+
/*#__PURE__*/ jsx(TooltipTrigger, {
|
|
8
|
+
asChild: true,
|
|
9
|
+
children: /*#__PURE__*/ jsx("button", {
|
|
10
|
+
type: "button",
|
|
11
|
+
"aria-label": label,
|
|
12
|
+
disabled: disabled,
|
|
13
|
+
onClick: onClick,
|
|
14
|
+
className: cn('inline-flex h-7 w-7 items-center justify-center rounded text-muted-foreground', 'hover:bg-accent hover:text-accent-foreground', 'disabled:opacity-50 disabled:pointer-events-none'),
|
|
15
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
16
|
+
className: "h-3.5 w-3.5"
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
}),
|
|
20
|
+
/*#__PURE__*/ jsx(TooltipContent, {
|
|
21
|
+
side: "bottom",
|
|
22
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
23
|
+
className: "text-xs",
|
|
24
|
+
children: label
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
const ToolbarSeparator = ()=>/*#__PURE__*/ jsx("span", {
|
|
30
|
+
"aria-hidden": true,
|
|
31
|
+
className: "mx-1 h-4 w-px bg-border/60"
|
|
32
|
+
});
|
|
33
|
+
const EditorToolbar = ({ mode, onModeChange, disabled, actionsRef, onFullscreen })=>{
|
|
34
|
+
const isEditMode = 'edit' === mode;
|
|
35
|
+
const handleFormat = (actionName)=>()=>{
|
|
36
|
+
if (!disabled && isEditMode) {
|
|
37
|
+
const fn = actionsRef?.current?.[actionName];
|
|
38
|
+
if ('function' == typeof fn) fn();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
42
|
+
className: "relative flex items-center justify-between gap-1 overflow-hidden rounded-t-md border border-b-0 bg-background px-2 py-1",
|
|
43
|
+
"data-testid": "editor-toolbar",
|
|
44
|
+
children: [
|
|
45
|
+
/*#__PURE__*/ jsx("span", {
|
|
46
|
+
"aria-hidden": true,
|
|
47
|
+
"data-testid": "editor-toolbar-separator",
|
|
48
|
+
className: "pointer-events-none absolute bottom-0 left-0 h-px w-full bg-border/40"
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ jsx("div", {
|
|
51
|
+
className: "flex items-center gap-1 shrink-0",
|
|
52
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
53
|
+
className: "flex items-center rounded-md bg-muted p-0.5",
|
|
54
|
+
children: [
|
|
55
|
+
/*#__PURE__*/ jsx("button", {
|
|
56
|
+
type: "button",
|
|
57
|
+
className: cn('rounded px-2 py-0.5 text-[11px] font-semibold transition-colors', 'edit' === mode ? 'bg-primary/20 text-primary' : 'text-foreground hover:bg-accent'),
|
|
58
|
+
disabled: disabled,
|
|
59
|
+
onClick: ()=>onModeChange('edit'),
|
|
60
|
+
children: "Edit"
|
|
61
|
+
}),
|
|
62
|
+
/*#__PURE__*/ jsx("button", {
|
|
63
|
+
type: "button",
|
|
64
|
+
className: cn('rounded px-2 py-0.5 text-[11px] font-semibold transition-colors', 'preview' === mode ? 'bg-primary/20 text-primary' : 'text-foreground hover:bg-accent'),
|
|
65
|
+
disabled: disabled,
|
|
66
|
+
onClick: ()=>onModeChange('preview'),
|
|
67
|
+
children: "Preview"
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
}),
|
|
72
|
+
/*#__PURE__*/ jsxs("div", {
|
|
73
|
+
className: "flex items-center gap-0.5 overflow-hidden",
|
|
74
|
+
children: [
|
|
75
|
+
/*#__PURE__*/ jsx(ToolbarButton, {
|
|
76
|
+
icon: Bold,
|
|
77
|
+
label: "Bold",
|
|
78
|
+
disabled: disabled || !isEditMode,
|
|
79
|
+
onClick: handleFormat('formatBold')
|
|
80
|
+
}),
|
|
81
|
+
/*#__PURE__*/ jsx(ToolbarButton, {
|
|
82
|
+
icon: Italic,
|
|
83
|
+
label: "Italic",
|
|
84
|
+
disabled: disabled || !isEditMode,
|
|
85
|
+
onClick: handleFormat('formatItalic')
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ jsx(ToolbarButton, {
|
|
88
|
+
icon: Strikethrough,
|
|
89
|
+
label: "Strikethrough",
|
|
90
|
+
disabled: disabled || !isEditMode,
|
|
91
|
+
onClick: handleFormat('formatStrikethrough')
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ jsx(ToolbarSeparator, {}),
|
|
94
|
+
/*#__PURE__*/ jsx(ToolbarButton, {
|
|
95
|
+
icon: ListOrdered,
|
|
96
|
+
label: "Numbered List",
|
|
97
|
+
disabled: disabled || !isEditMode,
|
|
98
|
+
onClick: handleFormat('formatNumberedList')
|
|
99
|
+
}),
|
|
100
|
+
/*#__PURE__*/ jsx(ToolbarButton, {
|
|
101
|
+
icon: List,
|
|
102
|
+
label: "Bulleted List",
|
|
103
|
+
disabled: disabled || !isEditMode,
|
|
104
|
+
onClick: handleFormat('formatBulletedList')
|
|
105
|
+
}),
|
|
106
|
+
onFullscreen && /*#__PURE__*/ jsxs(Fragment, {
|
|
107
|
+
children: [
|
|
108
|
+
/*#__PURE__*/ jsx(ToolbarSeparator, {}),
|
|
109
|
+
/*#__PURE__*/ jsx(ToolbarButton, {
|
|
110
|
+
icon: Maximize2,
|
|
111
|
+
label: "Expand",
|
|
112
|
+
disabled: disabled,
|
|
113
|
+
onClick: onFullscreen
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
})
|
|
117
|
+
]
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
export { EditorToolbar };
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
MarkdownPreview: ()=>MarkdownPreview
|
|
37
|
+
});
|
|
38
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
39
|
+
const external_dompurify_namespaceObject = require("dompurify");
|
|
40
|
+
var external_dompurify_default = /*#__PURE__*/ __webpack_require__.n(external_dompurify_namespaceObject);
|
|
41
|
+
const external_marked_namespaceObject = require("marked");
|
|
42
|
+
const external_react_namespaceObject = require("react");
|
|
43
|
+
const external_token_icon_markup_cjs_namespaceObject = require("./token-icon-markup.cjs");
|
|
44
|
+
const marked = new external_marked_namespaceObject.Marked({
|
|
45
|
+
async: false,
|
|
46
|
+
gfm: true,
|
|
47
|
+
breaks: true
|
|
48
|
+
});
|
|
49
|
+
const MARKDOWN_PREVIEW_STYLES = `
|
|
50
|
+
.prompt-editor-preview { color: var(--color-foreground); }
|
|
51
|
+
.prompt-editor-preview-empty { color: var(--color-muted-foreground); }
|
|
52
|
+
.prompt-editor-preview h1 { font-size: 1.5em; font-weight: 700; margin: 0.5em 0 0.25em; line-height: 1.3; }
|
|
53
|
+
.prompt-editor-preview h2 { font-size: 1.25em; font-weight: 700; margin: 0.5em 0 0.25em; line-height: 1.3; }
|
|
54
|
+
.prompt-editor-preview h3 { font-size: 1.1em; font-weight: 600; margin: 0.4em 0 0.2em; line-height: 1.3; }
|
|
55
|
+
.prompt-editor-preview h4, .prompt-editor-preview h5, .prompt-editor-preview h6 { font-size: 1em; font-weight: 600; margin: 0.4em 0 0.2em; line-height: 1.3; }
|
|
56
|
+
.prompt-editor-preview p { margin: 0.25em 0; }
|
|
57
|
+
.prompt-editor-preview code { font-family: 'Fira Code', 'Consolas', monospace; font-size: 0.875em; padding: 0.15em 0.4em; border-radius: 4px; background-color: var(--color-muted); color: var(--color-foreground); }
|
|
58
|
+
.prompt-editor-preview pre { margin: 0.5em 0; padding: 0.75em 1em; border-radius: 6px; overflow-x: auto; background-color: var(--color-muted); color: var(--color-foreground); }
|
|
59
|
+
.prompt-editor-preview pre code { padding: 0; background: none; font-size: 0.85em; }
|
|
60
|
+
.prompt-editor-preview blockquote { margin: 0.5em 0; padding: 0.25em 0.75em; border-left: 3px solid var(--color-border); color: var(--color-muted-foreground); }
|
|
61
|
+
.prompt-editor-preview ul, .prompt-editor-preview ol { margin: 0.25em 0; padding-left: 1.5em; }
|
|
62
|
+
.prompt-editor-preview ul { list-style-type: disc; }
|
|
63
|
+
.prompt-editor-preview ol { list-style-type: decimal; }
|
|
64
|
+
.prompt-editor-preview li { margin: 0.1em 0; }
|
|
65
|
+
.prompt-editor-preview a { color: var(--color-primary); text-decoration: underline; text-underline-offset: 2px; }
|
|
66
|
+
.prompt-editor-preview a:hover { opacity: 0.8; }
|
|
67
|
+
.prompt-editor-preview hr { margin: 0.75em 0; border: none; border-top: 1px solid var(--color-border); }
|
|
68
|
+
.prompt-editor-preview table { border-collapse: collapse; margin: 0.5em 0; width: 100%; }
|
|
69
|
+
.prompt-editor-preview th, .prompt-editor-preview td { border: 1px solid var(--color-border); padding: 0.35em 0.75em; text-align: left; }
|
|
70
|
+
.prompt-editor-preview th { font-weight: 600; background-color: var(--color-muted); }
|
|
71
|
+
.prompt-editor-preview strong { font-weight: 700; }
|
|
72
|
+
.prompt-editor-preview em { font-style: italic; }
|
|
73
|
+
.prompt-editor-preview .token-pill { display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 4px; border-radius: 4px; font-size: 13px; line-height: 20px; vertical-align: middle; background: var(--color-primary-lighter); color: var(--color-foreground); }
|
|
74
|
+
.prompt-editor-preview .token-pill svg { display: block; flex-shrink: 0; color: var(--color-primary); width: 14px; height: 14px; }
|
|
75
|
+
`;
|
|
76
|
+
const PURIFY_CONFIG = {
|
|
77
|
+
ALLOWED_TAGS: [
|
|
78
|
+
'p',
|
|
79
|
+
'br',
|
|
80
|
+
'span',
|
|
81
|
+
'strong',
|
|
82
|
+
'em',
|
|
83
|
+
'b',
|
|
84
|
+
'i',
|
|
85
|
+
'u',
|
|
86
|
+
's',
|
|
87
|
+
'del',
|
|
88
|
+
'ins',
|
|
89
|
+
'mark',
|
|
90
|
+
'sub',
|
|
91
|
+
'sup',
|
|
92
|
+
'small',
|
|
93
|
+
'h1',
|
|
94
|
+
'h2',
|
|
95
|
+
'h3',
|
|
96
|
+
'h4',
|
|
97
|
+
'h5',
|
|
98
|
+
'h6',
|
|
99
|
+
'ul',
|
|
100
|
+
'ol',
|
|
101
|
+
'li',
|
|
102
|
+
'code',
|
|
103
|
+
'pre',
|
|
104
|
+
'blockquote',
|
|
105
|
+
'hr',
|
|
106
|
+
'div',
|
|
107
|
+
'a',
|
|
108
|
+
'table',
|
|
109
|
+
'thead',
|
|
110
|
+
'tbody',
|
|
111
|
+
'tr',
|
|
112
|
+
'th',
|
|
113
|
+
'td',
|
|
114
|
+
'svg',
|
|
115
|
+
'path',
|
|
116
|
+
'line',
|
|
117
|
+
'polyline',
|
|
118
|
+
'polygon',
|
|
119
|
+
'circle',
|
|
120
|
+
'ellipse',
|
|
121
|
+
'rect',
|
|
122
|
+
'g'
|
|
123
|
+
],
|
|
124
|
+
ALLOWED_ATTR: [
|
|
125
|
+
'class',
|
|
126
|
+
'href',
|
|
127
|
+
'rel',
|
|
128
|
+
'viewBox',
|
|
129
|
+
'xmlns',
|
|
130
|
+
'width',
|
|
131
|
+
'height',
|
|
132
|
+
'fill',
|
|
133
|
+
'stroke',
|
|
134
|
+
'stroke-width',
|
|
135
|
+
'stroke-linecap',
|
|
136
|
+
'stroke-linejoin',
|
|
137
|
+
'fill-rule',
|
|
138
|
+
'clip-rule',
|
|
139
|
+
'd',
|
|
140
|
+
'x1',
|
|
141
|
+
'x2',
|
|
142
|
+
'y1',
|
|
143
|
+
'y2',
|
|
144
|
+
'points',
|
|
145
|
+
'cx',
|
|
146
|
+
'cy',
|
|
147
|
+
'r',
|
|
148
|
+
'x',
|
|
149
|
+
'y',
|
|
150
|
+
'rx',
|
|
151
|
+
'ry',
|
|
152
|
+
'colspan',
|
|
153
|
+
'rowspan'
|
|
154
|
+
]
|
|
155
|
+
};
|
|
156
|
+
const escapeHtml = (str)=>str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
157
|
+
const tokensToMarkdownWithPills = (tokens)=>{
|
|
158
|
+
let md = '';
|
|
159
|
+
for (const token of tokens)if ('text' === token.type) md += token.value;
|
|
160
|
+
else {
|
|
161
|
+
const iconSvg = (0, external_token_icon_markup_cjs_namespaceObject.buildTokenIconSvgMarkup)(token.type);
|
|
162
|
+
md += `<span class="token-pill">${iconSvg}${escapeHtml(token.value)}</span>`;
|
|
163
|
+
}
|
|
164
|
+
return md;
|
|
165
|
+
};
|
|
166
|
+
const LINE_HEIGHT = 20;
|
|
167
|
+
const VERTICAL_PADDING = 8;
|
|
168
|
+
const EMPTY_MESSAGE = 'Nothing to preview';
|
|
169
|
+
const MarkdownPreview = ({ tokens, minRows = 4 })=>{
|
|
170
|
+
const html = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
171
|
+
if (0 === tokens.length) return `<p class="prompt-editor-preview-empty">${escapeHtml(EMPTY_MESSAGE)}</p>`;
|
|
172
|
+
const md = tokensToMarkdownWithPills(tokens);
|
|
173
|
+
const rawHtml = marked.parse(md);
|
|
174
|
+
return external_dompurify_default().sanitize(rawHtml, PURIFY_CONFIG);
|
|
175
|
+
}, [
|
|
176
|
+
tokens
|
|
177
|
+
]);
|
|
178
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
179
|
+
children: [
|
|
180
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("style", {
|
|
181
|
+
children: MARKDOWN_PREVIEW_STYLES
|
|
182
|
+
}),
|
|
183
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
184
|
+
className: "prompt-editor-preview",
|
|
185
|
+
style: {
|
|
186
|
+
padding: '8px 12px',
|
|
187
|
+
minHeight: `${minRows * LINE_HEIGHT + 2 * VERTICAL_PADDING}px`,
|
|
188
|
+
fontFamily: "'Noto Sans', sans-serif",
|
|
189
|
+
fontSize: '14px',
|
|
190
|
+
lineHeight: '20px'
|
|
191
|
+
},
|
|
192
|
+
dangerouslySetInnerHTML: {
|
|
193
|
+
__html: html
|
|
194
|
+
}
|
|
195
|
+
})
|
|
196
|
+
]
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
exports.MarkdownPreview = __webpack_exports__.MarkdownPreview;
|
|
200
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
201
|
+
"MarkdownPreview"
|
|
202
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
203
|
+
Object.defineProperty(exports, '__esModule', {
|
|
204
|
+
value: true
|
|
205
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type PromptEditorToken } from '../types';
|
|
2
|
+
export interface MarkdownPreviewProps {
|
|
3
|
+
tokens: PromptEditorToken[];
|
|
4
|
+
minRows?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Renders the prompt tokens as sanitized markdown for preview mode.
|
|
8
|
+
*
|
|
9
|
+
* Preview is **visual-only**: every variable token renders as a pill regardless of whether its path
|
|
10
|
+
* still exists in `autoCompleteOptions`. Unlike edit mode — where `ValidateTokensPlugin` flags
|
|
11
|
+
* stale/unknown tokens as invalid — preview does not receive the option set and so does not reflect
|
|
12
|
+
* token validity. Switch to edit mode to see validation state.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MarkdownPreview: ({ tokens, minRows }: MarkdownPreviewProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import dompurify from "dompurify";
|
|
3
|
+
import { Marked } from "marked";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { buildTokenIconSvgMarkup } from "./token-icon-markup.js";
|
|
6
|
+
const marked = new Marked({
|
|
7
|
+
async: false,
|
|
8
|
+
gfm: true,
|
|
9
|
+
breaks: true
|
|
10
|
+
});
|
|
11
|
+
const MARKDOWN_PREVIEW_STYLES = `
|
|
12
|
+
.prompt-editor-preview { color: var(--color-foreground); }
|
|
13
|
+
.prompt-editor-preview-empty { color: var(--color-muted-foreground); }
|
|
14
|
+
.prompt-editor-preview h1 { font-size: 1.5em; font-weight: 700; margin: 0.5em 0 0.25em; line-height: 1.3; }
|
|
15
|
+
.prompt-editor-preview h2 { font-size: 1.25em; font-weight: 700; margin: 0.5em 0 0.25em; line-height: 1.3; }
|
|
16
|
+
.prompt-editor-preview h3 { font-size: 1.1em; font-weight: 600; margin: 0.4em 0 0.2em; line-height: 1.3; }
|
|
17
|
+
.prompt-editor-preview h4, .prompt-editor-preview h5, .prompt-editor-preview h6 { font-size: 1em; font-weight: 600; margin: 0.4em 0 0.2em; line-height: 1.3; }
|
|
18
|
+
.prompt-editor-preview p { margin: 0.25em 0; }
|
|
19
|
+
.prompt-editor-preview code { font-family: 'Fira Code', 'Consolas', monospace; font-size: 0.875em; padding: 0.15em 0.4em; border-radius: 4px; background-color: var(--color-muted); color: var(--color-foreground); }
|
|
20
|
+
.prompt-editor-preview pre { margin: 0.5em 0; padding: 0.75em 1em; border-radius: 6px; overflow-x: auto; background-color: var(--color-muted); color: var(--color-foreground); }
|
|
21
|
+
.prompt-editor-preview pre code { padding: 0; background: none; font-size: 0.85em; }
|
|
22
|
+
.prompt-editor-preview blockquote { margin: 0.5em 0; padding: 0.25em 0.75em; border-left: 3px solid var(--color-border); color: var(--color-muted-foreground); }
|
|
23
|
+
.prompt-editor-preview ul, .prompt-editor-preview ol { margin: 0.25em 0; padding-left: 1.5em; }
|
|
24
|
+
.prompt-editor-preview ul { list-style-type: disc; }
|
|
25
|
+
.prompt-editor-preview ol { list-style-type: decimal; }
|
|
26
|
+
.prompt-editor-preview li { margin: 0.1em 0; }
|
|
27
|
+
.prompt-editor-preview a { color: var(--color-primary); text-decoration: underline; text-underline-offset: 2px; }
|
|
28
|
+
.prompt-editor-preview a:hover { opacity: 0.8; }
|
|
29
|
+
.prompt-editor-preview hr { margin: 0.75em 0; border: none; border-top: 1px solid var(--color-border); }
|
|
30
|
+
.prompt-editor-preview table { border-collapse: collapse; margin: 0.5em 0; width: 100%; }
|
|
31
|
+
.prompt-editor-preview th, .prompt-editor-preview td { border: 1px solid var(--color-border); padding: 0.35em 0.75em; text-align: left; }
|
|
32
|
+
.prompt-editor-preview th { font-weight: 600; background-color: var(--color-muted); }
|
|
33
|
+
.prompt-editor-preview strong { font-weight: 700; }
|
|
34
|
+
.prompt-editor-preview em { font-style: italic; }
|
|
35
|
+
.prompt-editor-preview .token-pill { display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 4px; border-radius: 4px; font-size: 13px; line-height: 20px; vertical-align: middle; background: var(--color-primary-lighter); color: var(--color-foreground); }
|
|
36
|
+
.prompt-editor-preview .token-pill svg { display: block; flex-shrink: 0; color: var(--color-primary); width: 14px; height: 14px; }
|
|
37
|
+
`;
|
|
38
|
+
const PURIFY_CONFIG = {
|
|
39
|
+
ALLOWED_TAGS: [
|
|
40
|
+
'p',
|
|
41
|
+
'br',
|
|
42
|
+
'span',
|
|
43
|
+
'strong',
|
|
44
|
+
'em',
|
|
45
|
+
'b',
|
|
46
|
+
'i',
|
|
47
|
+
'u',
|
|
48
|
+
's',
|
|
49
|
+
'del',
|
|
50
|
+
'ins',
|
|
51
|
+
'mark',
|
|
52
|
+
'sub',
|
|
53
|
+
'sup',
|
|
54
|
+
'small',
|
|
55
|
+
'h1',
|
|
56
|
+
'h2',
|
|
57
|
+
'h3',
|
|
58
|
+
'h4',
|
|
59
|
+
'h5',
|
|
60
|
+
'h6',
|
|
61
|
+
'ul',
|
|
62
|
+
'ol',
|
|
63
|
+
'li',
|
|
64
|
+
'code',
|
|
65
|
+
'pre',
|
|
66
|
+
'blockquote',
|
|
67
|
+
'hr',
|
|
68
|
+
'div',
|
|
69
|
+
'a',
|
|
70
|
+
'table',
|
|
71
|
+
'thead',
|
|
72
|
+
'tbody',
|
|
73
|
+
'tr',
|
|
74
|
+
'th',
|
|
75
|
+
'td',
|
|
76
|
+
'svg',
|
|
77
|
+
'path',
|
|
78
|
+
'line',
|
|
79
|
+
'polyline',
|
|
80
|
+
'polygon',
|
|
81
|
+
'circle',
|
|
82
|
+
'ellipse',
|
|
83
|
+
'rect',
|
|
84
|
+
'g'
|
|
85
|
+
],
|
|
86
|
+
ALLOWED_ATTR: [
|
|
87
|
+
'class',
|
|
88
|
+
'href',
|
|
89
|
+
'rel',
|
|
90
|
+
'viewBox',
|
|
91
|
+
'xmlns',
|
|
92
|
+
'width',
|
|
93
|
+
'height',
|
|
94
|
+
'fill',
|
|
95
|
+
'stroke',
|
|
96
|
+
'stroke-width',
|
|
97
|
+
'stroke-linecap',
|
|
98
|
+
'stroke-linejoin',
|
|
99
|
+
'fill-rule',
|
|
100
|
+
'clip-rule',
|
|
101
|
+
'd',
|
|
102
|
+
'x1',
|
|
103
|
+
'x2',
|
|
104
|
+
'y1',
|
|
105
|
+
'y2',
|
|
106
|
+
'points',
|
|
107
|
+
'cx',
|
|
108
|
+
'cy',
|
|
109
|
+
'r',
|
|
110
|
+
'x',
|
|
111
|
+
'y',
|
|
112
|
+
'rx',
|
|
113
|
+
'ry',
|
|
114
|
+
'colspan',
|
|
115
|
+
'rowspan'
|
|
116
|
+
]
|
|
117
|
+
};
|
|
118
|
+
const escapeHtml = (str)=>str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
119
|
+
const tokensToMarkdownWithPills = (tokens)=>{
|
|
120
|
+
let md = '';
|
|
121
|
+
for (const token of tokens)if ('text' === token.type) md += token.value;
|
|
122
|
+
else {
|
|
123
|
+
const iconSvg = buildTokenIconSvgMarkup(token.type);
|
|
124
|
+
md += `<span class="token-pill">${iconSvg}${escapeHtml(token.value)}</span>`;
|
|
125
|
+
}
|
|
126
|
+
return md;
|
|
127
|
+
};
|
|
128
|
+
const LINE_HEIGHT = 20;
|
|
129
|
+
const VERTICAL_PADDING = 8;
|
|
130
|
+
const EMPTY_MESSAGE = 'Nothing to preview';
|
|
131
|
+
const MarkdownPreview = ({ tokens, minRows = 4 })=>{
|
|
132
|
+
const html = useMemo(()=>{
|
|
133
|
+
if (0 === tokens.length) return `<p class="prompt-editor-preview-empty">${escapeHtml(EMPTY_MESSAGE)}</p>`;
|
|
134
|
+
const md = tokensToMarkdownWithPills(tokens);
|
|
135
|
+
const rawHtml = marked.parse(md);
|
|
136
|
+
return dompurify.sanitize(rawHtml, PURIFY_CONFIG);
|
|
137
|
+
}, [
|
|
138
|
+
tokens
|
|
139
|
+
]);
|
|
140
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
141
|
+
children: [
|
|
142
|
+
/*#__PURE__*/ jsx("style", {
|
|
143
|
+
children: MARKDOWN_PREVIEW_STYLES
|
|
144
|
+
}),
|
|
145
|
+
/*#__PURE__*/ jsx("div", {
|
|
146
|
+
className: "prompt-editor-preview",
|
|
147
|
+
style: {
|
|
148
|
+
padding: '8px 12px',
|
|
149
|
+
minHeight: `${minRows * LINE_HEIGHT + 2 * VERTICAL_PADDING}px`,
|
|
150
|
+
fontFamily: "'Noto Sans', sans-serif",
|
|
151
|
+
fontSize: '14px',
|
|
152
|
+
lineHeight: '20px'
|
|
153
|
+
},
|
|
154
|
+
dangerouslySetInnerHTML: {
|
|
155
|
+
__html: html
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
]
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
export { MarkdownPreview };
|