@flowgram.ai/form-materials 0.5.4 → 0.5.6
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/cjs/components/batch-outputs/index.js +5 -3
- package/dist/cjs/components/batch-outputs/styles.css +13 -0
- package/dist/cjs/components/code-editor/editor.js +16 -12
- package/dist/cjs/components/code-editor/styles.css +4 -0
- package/dist/cjs/components/code-editor-mini/index.js +2 -16
- package/dist/cjs/components/condition-row/index.js +14 -12
- package/dist/cjs/components/condition-row/styles.css +19 -0
- package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +28 -10
- package/dist/{esm/components/coze-editor-extensions/styles.mjs → cjs/components/coze-editor-extensions/styles.css} +19 -18
- package/dist/cjs/components/db-condition-row/index.js +16 -13
- package/dist/cjs/components/db-condition-row/styles.css +30 -0
- package/dist/cjs/components/display-inputs-values/index.js +3 -2
- package/dist/cjs/components/display-inputs-values/styles.css +6 -0
- package/dist/cjs/components/display-outputs/index.js +3 -2
- package/dist/cjs/components/display-outputs/styles.css +6 -0
- package/dist/cjs/components/display-schema-tag/index.js +7 -4
- package/dist/cjs/components/display-schema-tag/styles.css +21 -0
- package/dist/cjs/components/display-schema-tree/index.js +12 -7
- package/dist/cjs/components/display-schema-tree/styles.css +64 -0
- package/dist/cjs/components/dynamic-value-input/index.js +9 -5
- package/dist/{esm/components/dynamic-value-input/styles.mjs → cjs/components/dynamic-value-input/styles.css} +23 -30
- package/dist/cjs/components/inputs-values/index.js +5 -3
- package/dist/cjs/components/inputs-values/styles.css +13 -0
- package/dist/cjs/components/inputs-values-tree/icon.js +70 -0
- package/dist/cjs/components/inputs-values-tree/index.js +3 -2
- package/dist/cjs/components/inputs-values-tree/row.js +19 -15
- package/dist/cjs/components/inputs-values-tree/styles.css +85 -0
- package/dist/cjs/components/json-schema-editor/default-value.js +2 -2
- package/dist/cjs/components/json-schema-editor/icon.js +70 -0
- package/dist/cjs/components/json-schema-editor/index.js +37 -25
- package/dist/cjs/components/json-schema-editor/styles.css +113 -0
- package/dist/cjs/components/prompt-editor/editor.js +16 -6
- package/dist/cjs/components/prompt-editor/styles.css +10 -0
- package/dist/cjs/components/prompt-editor-with-inputs/index.js +16 -26
- package/dist/cjs/components/prompt-editor-with-variables/index.js +17 -26
- package/dist/cjs/components/variable-selector/context.js +7 -3
- package/dist/cjs/components/variable-selector/index.js +16 -10
- package/dist/{esm/components/variable-selector/styles.mjs → cjs/components/variable-selector/styles.css} +37 -29
- package/dist/cjs/components/variable-selector/use-variable-tree.js +3 -1
- package/dist/esm/components/batch-outputs/index.mjs +5 -3
- package/dist/esm/components/batch-outputs/styles.css +13 -0
- package/dist/esm/components/code-editor/editor.mjs +16 -11
- package/dist/esm/components/code-editor/styles.css +4 -0
- package/dist/esm/components/code-editor-mini/index.mjs +2 -6
- package/dist/esm/components/condition-row/index.mjs +14 -12
- package/dist/esm/components/condition-row/styles.css +19 -0
- package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +29 -11
- package/dist/esm/components/coze-editor-extensions/styles.css +37 -0
- package/dist/esm/components/db-condition-row/index.mjs +16 -13
- package/dist/esm/components/db-condition-row/styles.css +30 -0
- package/dist/esm/components/display-inputs-values/index.mjs +3 -2
- package/dist/esm/components/display-inputs-values/styles.css +6 -0
- package/dist/esm/components/display-outputs/index.mjs +3 -2
- package/dist/esm/components/display-outputs/styles.css +6 -0
- package/dist/esm/components/display-schema-tag/index.mjs +8 -5
- package/dist/esm/components/display-schema-tag/styles.css +21 -0
- package/dist/esm/components/display-schema-tree/index.mjs +12 -7
- package/dist/esm/components/display-schema-tree/styles.css +64 -0
- package/dist/esm/components/dynamic-value-input/index.mjs +9 -5
- package/dist/esm/components/dynamic-value-input/styles.css +48 -0
- package/dist/esm/components/inputs-values/index.mjs +5 -3
- package/dist/esm/components/inputs-values/styles.css +13 -0
- package/dist/esm/components/inputs-values-tree/icon.mjs +26 -0
- package/dist/esm/components/inputs-values-tree/index.mjs +3 -2
- package/dist/esm/components/inputs-values-tree/row.mjs +18 -14
- package/dist/esm/components/inputs-values-tree/styles.css +85 -0
- package/dist/esm/components/json-schema-editor/default-value.mjs +2 -2
- package/dist/esm/components/json-schema-editor/icon.mjs +26 -0
- package/dist/esm/components/json-schema-editor/index.mjs +36 -24
- package/dist/esm/components/json-schema-editor/styles.css +113 -0
- package/dist/esm/components/prompt-editor/editor.mjs +16 -6
- package/dist/esm/components/prompt-editor/styles.css +10 -0
- package/dist/esm/components/prompt-editor-with-inputs/index.mjs +12 -4
- package/dist/esm/components/prompt-editor-with-variables/index.mjs +13 -4
- package/dist/esm/components/variable-selector/context.mjs +7 -3
- package/dist/esm/components/variable-selector/index.mjs +17 -11
- package/{src/components/variable-selector/styles.tsx → dist/esm/components/variable-selector/styles.css} +35 -38
- package/dist/esm/components/variable-selector/use-variable-tree.mjs +3 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/batch-outputs/index.d.ts +1 -0
- package/dist/types/components/code-editor/editor.d.ts +1 -0
- package/dist/types/components/condition-row/index.d.ts +5 -1
- package/dist/types/components/coze-editor-extensions/extensions/variable-tag.d.ts +1 -0
- package/dist/types/components/db-condition-row/index.d.ts +4 -0
- package/dist/types/components/db-condition-row/types.d.ts +0 -1
- package/dist/types/components/display-inputs-values/index.d.ts +1 -0
- package/dist/types/components/display-outputs/index.d.ts +1 -0
- package/dist/types/components/display-schema-tag/index.d.ts +1 -0
- package/dist/types/components/display-schema-tree/index.d.ts +1 -0
- package/dist/types/components/dynamic-value-input/index.d.ts +1 -0
- package/dist/types/components/inputs-values/index.d.ts +1 -0
- package/dist/types/components/inputs-values-tree/icon.d.ts +6 -0
- package/dist/types/components/inputs-values-tree/index.d.ts +1 -0
- package/dist/types/components/inputs-values-tree/row.d.ts +1 -0
- package/dist/types/components/json-schema-editor/icon.d.ts +6 -0
- package/dist/types/components/json-schema-editor/index.d.ts +1 -0
- package/dist/types/components/prompt-editor/editor.d.ts +1 -0
- package/dist/types/components/prompt-editor-with-inputs/index.d.ts +7 -2
- package/dist/types/components/prompt-editor-with-variables/index.d.ts +5 -2
- package/dist/types/components/variable-selector/context.d.ts +16 -3
- package/dist/types/components/variable-selector/index.d.ts +1 -0
- package/package.json +7 -10
- package/src/components/batch-outputs/index.tsx +5 -5
- package/src/components/batch-outputs/{styles.tsx → styles.css} +4 -6
- package/src/components/code-editor/editor.tsx +19 -14
- package/src/components/code-editor/styles.css +11 -0
- package/src/components/code-editor-mini/index.tsx +2 -9
- package/src/components/condition-row/index.tsx +15 -22
- package/src/components/condition-row/{styles.tsx → styles.css} +10 -11
- package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +18 -13
- package/src/components/coze-editor-extensions/{styles.tsx → styles.css} +8 -11
- package/src/components/db-condition-row/index.tsx +17 -26
- package/src/components/db-condition-row/{styles.tsx → styles.css} +14 -16
- package/src/components/db-condition-row/types.ts +0 -1
- package/src/components/display-inputs-values/index.tsx +3 -3
- package/src/components/display-inputs-values/{styles.ts → styles.css} +2 -4
- package/src/components/display-outputs/index.tsx +3 -3
- package/src/components/display-outputs/{styles.ts → styles.css} +2 -4
- package/src/components/display-schema-tag/index.tsx +7 -7
- package/src/components/display-schema-tag/{styles.ts → styles.css} +7 -10
- package/src/components/display-schema-tree/index.tsx +10 -10
- package/src/components/display-schema-tree/{styles.tsx → styles.css} +18 -24
- package/src/components/dynamic-value-input/index.tsx +6 -6
- package/src/components/dynamic-value-input/{styles.tsx → styles.css} +8 -12
- package/src/components/inputs-values/index.tsx +5 -5
- package/src/components/inputs-values/{styles.tsx → styles.css} +4 -6
- package/src/components/inputs-values-tree/icon.tsx +28 -0
- package/src/components/inputs-values-tree/index.tsx +3 -3
- package/src/components/inputs-values-tree/row.tsx +25 -27
- package/src/components/inputs-values-tree/styles.css +94 -0
- package/src/components/json-schema-editor/default-value.tsx +2 -4
- package/src/components/json-schema-editor/icon.tsx +28 -0
- package/src/components/json-schema-editor/index.tsx +45 -50
- package/src/components/json-schema-editor/styles.css +135 -0
- package/src/components/prompt-editor/editor.tsx +18 -7
- package/src/components/prompt-editor/styles.css +14 -0
- package/src/components/prompt-editor-with-inputs/index.tsx +18 -5
- package/src/components/prompt-editor-with-variables/index.tsx +13 -5
- package/src/components/variable-selector/context.tsx +22 -2
- package/src/components/variable-selector/index.tsx +24 -14
- package/src/components/variable-selector/styles.css +70 -0
- package/src/components/variable-selector/use-variable-tree.tsx +9 -1
- package/dist/cjs/components/batch-outputs/styles.js +0 -60
- package/dist/cjs/components/condition-row/styles.js +0 -78
- package/dist/cjs/components/coze-editor-extensions/styles.js +0 -89
- package/dist/cjs/components/db-condition-row/styles.js +0 -94
- package/dist/cjs/components/display-inputs-values/styles.js +0 -51
- package/dist/cjs/components/display-outputs/styles.js +0 -51
- package/dist/cjs/components/display-schema-tag/styles.js +0 -71
- package/dist/cjs/components/display-schema-tree/styles.js +0 -135
- package/dist/cjs/components/dynamic-value-input/styles.js +0 -108
- package/dist/cjs/components/inputs-values/styles.js +0 -60
- package/dist/cjs/components/inputs-values-tree/styles.js +0 -177
- package/dist/cjs/components/json-schema-editor/styles.js +0 -231
- package/dist/cjs/components/prompt-editor/styles.js +0 -55
- package/dist/cjs/components/prompt-editor-with-inputs/editor.js +0 -47
- package/dist/cjs/components/prompt-editor-with-variables/editor.js +0 -48
- package/dist/cjs/components/variable-selector/styles.js +0 -114
- package/dist/esm/components/batch-outputs/styles.mjs +0 -13
- package/dist/esm/components/condition-row/styles.mjs +0 -22
- package/dist/esm/components/db-condition-row/styles.mjs +0 -32
- package/dist/esm/components/display-inputs-values/styles.mjs +0 -7
- package/dist/esm/components/display-outputs/styles.mjs +0 -7
- package/dist/esm/components/display-schema-tag/styles.mjs +0 -21
- package/dist/esm/components/display-schema-tree/styles.mjs +0 -79
- package/dist/esm/components/inputs-values/styles.mjs +0 -13
- package/dist/esm/components/inputs-values-tree/styles.mjs +0 -105
- package/dist/esm/components/json-schema-editor/styles.mjs +0 -138
- package/dist/esm/components/prompt-editor/styles.mjs +0 -11
- package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +0 -13
- package/dist/esm/components/prompt-editor-with-variables/editor.mjs +0 -14
- package/dist/types/components/batch-outputs/styles.d.ts +0 -6
- package/dist/types/components/condition-row/styles.d.ts +0 -9
- package/dist/types/components/coze-editor-extensions/styles.d.ts +0 -9
- package/dist/types/components/db-condition-row/styles.d.ts +0 -12
- package/dist/types/components/display-inputs-values/styles.d.ts +0 -5
- package/dist/types/components/display-outputs/styles.d.ts +0 -5
- package/dist/types/components/display-schema-tag/styles.d.ts +0 -8
- package/dist/types/components/display-schema-tree/styles.d.ts +0 -11
- package/dist/types/components/dynamic-value-input/styles.d.ts +0 -8
- package/dist/types/components/inputs-values/styles.d.ts +0 -6
- package/dist/types/components/inputs-values-tree/styles.d.ts +0 -23
- package/dist/types/components/json-schema-editor/styles.d.ts +0 -30
- package/dist/types/components/prompt-editor/styles.d.ts +0 -7
- package/dist/types/components/prompt-editor-with-inputs/editor.d.ts +0 -11
- package/dist/types/components/prompt-editor-with-variables/editor.d.ts +0 -9
- package/dist/types/components/variable-selector/styles.d.ts +0 -14
- package/src/components/inputs-values-tree/styles.tsx +0 -128
- package/src/components/json-schema-editor/styles.tsx +0 -168
- package/src/components/prompt-editor/styles.tsx +0 -18
- package/src/components/prompt-editor-with-inputs/editor.tsx +0 -25
- package/src/components/prompt-editor-with-variables/editor.tsx +0 -20
|
@@ -21,26 +21,12 @@ import { InjectTypeSelector } from '@/components/type-selector';
|
|
|
21
21
|
import { BlurInput } from '@/components/blur-input';
|
|
22
22
|
|
|
23
23
|
import { ConfigType, PropertyValueType } from './types';
|
|
24
|
-
import {
|
|
25
|
-
IconAddChildren,
|
|
26
|
-
UIActions,
|
|
27
|
-
UICollapseTrigger,
|
|
28
|
-
UICollapsible,
|
|
29
|
-
UIContainer,
|
|
30
|
-
UIExpandDetail,
|
|
31
|
-
UILabel,
|
|
32
|
-
UITreeItems,
|
|
33
|
-
UITreeItemLeft,
|
|
34
|
-
UITreeItemMain,
|
|
35
|
-
UITreeItemRight,
|
|
36
|
-
UIRequired,
|
|
37
|
-
UIType,
|
|
38
|
-
} from './styles';
|
|
39
|
-
import { UIName } from './styles';
|
|
40
|
-
import { DefaultValueWrapper, UIRow } from './styles';
|
|
24
|
+
import { IconAddChildren } from './icon';
|
|
41
25
|
import { usePropertiesEdit } from './hooks';
|
|
42
26
|
import { DefaultValue } from './default-value';
|
|
43
27
|
|
|
28
|
+
import './styles.css';
|
|
29
|
+
|
|
44
30
|
const DEFAULT = { type: 'object' };
|
|
45
31
|
|
|
46
32
|
export function JsonSchemaEditor(props: {
|
|
@@ -57,8 +43,8 @@ export function JsonSchemaEditor(props: {
|
|
|
57
43
|
);
|
|
58
44
|
|
|
59
45
|
return (
|
|
60
|
-
<
|
|
61
|
-
<
|
|
46
|
+
<div className="gedit-m-json-schema-editor-container">
|
|
47
|
+
<div className="gedit-m-json-schema-editor-tree-items">
|
|
62
48
|
{propertyList.map((_property) => (
|
|
63
49
|
<PropertyEdit
|
|
64
50
|
readonly={readonly}
|
|
@@ -73,7 +59,7 @@ export function JsonSchemaEditor(props: {
|
|
|
73
59
|
}}
|
|
74
60
|
/>
|
|
75
61
|
))}
|
|
76
|
-
</
|
|
62
|
+
</div>
|
|
77
63
|
<Button
|
|
78
64
|
disabled={readonly}
|
|
79
65
|
size="small"
|
|
@@ -83,7 +69,7 @@ export function JsonSchemaEditor(props: {
|
|
|
83
69
|
>
|
|
84
70
|
{config?.addButtonText ?? I18n.t('Add')}
|
|
85
71
|
</Button>
|
|
86
|
-
</
|
|
72
|
+
</div>
|
|
87
73
|
);
|
|
88
74
|
}
|
|
89
75
|
|
|
@@ -119,17 +105,24 @@ function PropertyEdit(props: {
|
|
|
119
105
|
|
|
120
106
|
return (
|
|
121
107
|
<>
|
|
122
|
-
<
|
|
108
|
+
<div
|
|
109
|
+
className={`gedit-m-json-schema-editor-tree-item-left ${$level > 0 ? 'show-line' : ''} ${
|
|
110
|
+
$isLast ? 'is-last' : ''
|
|
111
|
+
} ${showCollapse ? 'show-collapse' : ''}`}
|
|
112
|
+
>
|
|
123
113
|
{showCollapse && (
|
|
124
|
-
<
|
|
114
|
+
<div
|
|
115
|
+
className="gedit-m-json-schema-editor-collapse-trigger"
|
|
116
|
+
onClick={() => setCollapse((_collapse) => !_collapse)}
|
|
117
|
+
>
|
|
125
118
|
{collapse ? <IconChevronDown size="small" /> : <IconChevronRight size="small" />}
|
|
126
|
-
</
|
|
119
|
+
</div>
|
|
127
120
|
)}
|
|
128
|
-
</
|
|
129
|
-
<
|
|
130
|
-
<
|
|
131
|
-
<
|
|
132
|
-
<
|
|
121
|
+
</div>
|
|
122
|
+
<div className="gedit-m-json-schema-editor-tree-item-right">
|
|
123
|
+
<div className="gedit-m-json-schema-editor-tree-item-main">
|
|
124
|
+
<div className="gedit-m-json-schema-editor-row">
|
|
125
|
+
<div className="gedit-m-json-schema-editor-name">
|
|
133
126
|
<BlurInput
|
|
134
127
|
disabled={readonly}
|
|
135
128
|
placeholder={config?.placeholder ?? I18n.t('Input Variable Name')}
|
|
@@ -137,8 +130,8 @@ function PropertyEdit(props: {
|
|
|
137
130
|
value={name}
|
|
138
131
|
onChange={(value) => onChange('name', value)}
|
|
139
132
|
/>
|
|
140
|
-
</
|
|
141
|
-
<
|
|
133
|
+
</div>
|
|
134
|
+
<div className="gedit-m-json-schema-editor-type">
|
|
142
135
|
<InjectTypeSelector
|
|
143
136
|
value={typeSelectorValue}
|
|
144
137
|
readonly={readonly}
|
|
@@ -149,15 +142,15 @@ function PropertyEdit(props: {
|
|
|
149
142
|
});
|
|
150
143
|
}}
|
|
151
144
|
/>
|
|
152
|
-
</
|
|
153
|
-
<
|
|
145
|
+
</div>
|
|
146
|
+
<div className="gedit-m-json-schema-editor-required">
|
|
154
147
|
<Checkbox
|
|
155
148
|
disabled={readonly}
|
|
156
149
|
checked={isPropertyRequired}
|
|
157
150
|
onChange={(e) => onChange('isPropertyRequired', e.target.checked)}
|
|
158
151
|
/>
|
|
159
|
-
</
|
|
160
|
-
<
|
|
152
|
+
</div>
|
|
153
|
+
<div className="gedit-m-json-schema-editor-actions">
|
|
161
154
|
<IconButton
|
|
162
155
|
disabled={readonly}
|
|
163
156
|
size="small"
|
|
@@ -186,11 +179,13 @@ function PropertyEdit(props: {
|
|
|
186
179
|
icon={<IconMinus size="small" />}
|
|
187
180
|
onClick={onRemove}
|
|
188
181
|
/>
|
|
189
|
-
</
|
|
190
|
-
</
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
191
184
|
{expand && (
|
|
192
|
-
<
|
|
193
|
-
<
|
|
185
|
+
<div className="gedit-m-json-schema-editor-expand-detail">
|
|
186
|
+
<div className="gedit-m-json-schema-editor-label">
|
|
187
|
+
{config?.descTitle ?? I18n.t('Description')}
|
|
188
|
+
</div>
|
|
194
189
|
<BlurInput
|
|
195
190
|
disabled={readonly}
|
|
196
191
|
size="small"
|
|
@@ -202,25 +197,25 @@ function PropertyEdit(props: {
|
|
|
202
197
|
/>
|
|
203
198
|
{$level === 0 && (
|
|
204
199
|
<>
|
|
205
|
-
<
|
|
200
|
+
<div className="gedit-m-json-schema-editor-label" style={{ marginTop: 10 }}>
|
|
206
201
|
{config?.defaultValueTitle ?? I18n.t('Default Value')}
|
|
207
|
-
</
|
|
208
|
-
<
|
|
202
|
+
</div>
|
|
203
|
+
<div className="gedit-m-json-schema-editor-default-value-wrapper">
|
|
209
204
|
<DefaultValue
|
|
210
205
|
value={defaultValue}
|
|
211
206
|
schema={value}
|
|
212
207
|
placeholder={config?.defaultValuePlaceholder ?? I18n.t('Default Value')}
|
|
213
208
|
onChange={(value) => onChange('default', value)}
|
|
214
209
|
/>
|
|
215
|
-
</
|
|
210
|
+
</div>
|
|
216
211
|
</>
|
|
217
212
|
)}
|
|
218
|
-
</
|
|
213
|
+
</div>
|
|
219
214
|
)}
|
|
220
|
-
</
|
|
215
|
+
</div>
|
|
221
216
|
{showCollapse && (
|
|
222
|
-
<
|
|
223
|
-
<
|
|
217
|
+
<div className={`gedit-m-json-schema-editor-collapsible ${collapse ? 'collapse' : ''}`}>
|
|
218
|
+
<div className="gedit-m-json-schema-editor-tree-items shrink">
|
|
224
219
|
{propertyList.map((_property, index) => (
|
|
225
220
|
<PropertyEdit
|
|
226
221
|
readonly={readonly}
|
|
@@ -237,10 +232,10 @@ function PropertyEdit(props: {
|
|
|
237
232
|
$isLast={index === propertyList.length - 1}
|
|
238
233
|
/>
|
|
239
234
|
))}
|
|
240
|
-
</
|
|
241
|
-
</
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
242
237
|
)}
|
|
243
|
-
</
|
|
238
|
+
</div>
|
|
244
239
|
</>
|
|
245
240
|
);
|
|
246
241
|
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.gedit-m-json-schema-editor-container {
|
|
7
|
+
/* & .semi-input {
|
|
8
|
+
background-color: #fff;
|
|
9
|
+
border-radius: 6px;
|
|
10
|
+
height: 24px;
|
|
11
|
+
} */
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.gedit-m-json-schema-editor-row {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: 6px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.gedit-m-json-schema-editor-collapse-trigger {
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
margin-right: 5px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.gedit-m-json-schema-editor-expand-detail {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.gedit-m-json-schema-editor-label {
|
|
31
|
+
font-size: 12px;
|
|
32
|
+
color: #999;
|
|
33
|
+
font-weight: 400;
|
|
34
|
+
margin-bottom: 2px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.gedit-m-json-schema-editor-tree-items {
|
|
38
|
+
display: grid;
|
|
39
|
+
grid-template-columns: auto 1fr;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.gedit-m-json-schema-editor-tree-items.shrink {
|
|
43
|
+
padding-left: 3px;
|
|
44
|
+
margin-top: 10px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.gedit-m-json-schema-editor-tree-item-left {
|
|
48
|
+
grid-column: 1;
|
|
49
|
+
position: relative;
|
|
50
|
+
width: 16px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.gedit-m-json-schema-editor-tree-item-left.show-line::before {
|
|
54
|
+
/* 竖线 */
|
|
55
|
+
content: "";
|
|
56
|
+
height: var(--line-height, 100%);
|
|
57
|
+
position: absolute;
|
|
58
|
+
left: -14px;
|
|
59
|
+
top: -16px;
|
|
60
|
+
width: 1px;
|
|
61
|
+
background: #d9d9d9;
|
|
62
|
+
display: block;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.gedit-m-json-schema-editor-tree-item-left.show-line::after {
|
|
66
|
+
/* 横线 */
|
|
67
|
+
content: "";
|
|
68
|
+
position: absolute;
|
|
69
|
+
left: -14px; /* 横线起点和竖线对齐 */
|
|
70
|
+
top: 8px; /* 跟随你的行高调整 */
|
|
71
|
+
width: var(--line-width, 30px); /* 横线长度 */
|
|
72
|
+
height: 1px;
|
|
73
|
+
background: #d9d9d9;
|
|
74
|
+
display: block;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.gedit-m-json-schema-editor-tree-item-left.show-line.is-last::before {
|
|
78
|
+
height: 24px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.gedit-m-json-schema-editor-tree-item-left.show-line.show-collapse::after {
|
|
82
|
+
width: 12px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.gedit-m-json-schema-editor-tree-item-right {
|
|
86
|
+
grid-column: 2;
|
|
87
|
+
margin-bottom: 10px;
|
|
88
|
+
|
|
89
|
+
&:last-child {
|
|
90
|
+
margin-bottom: 0px;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.gedit-m-json-schema-editor-tree-item-main {
|
|
95
|
+
display: flex;
|
|
96
|
+
flex-direction: column;
|
|
97
|
+
gap: 10px;
|
|
98
|
+
position: relative;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.gedit-m-json-schema-editor-collapsible {
|
|
102
|
+
display: none;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.gedit-m-json-schema-editor-collapsible.collapse {
|
|
106
|
+
display: block;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.gedit-m-json-schema-editor-name {
|
|
110
|
+
flex-grow: 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.gedit-m-json-schema-editor-type {
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.gedit-m-json-schema-editor-required {
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.gedit-m-json-schema-editor-actions {
|
|
120
|
+
white-space: nowrap;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.gedit-m-json-schema-editor-default-value-wrapper {
|
|
124
|
+
margin: 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.gedit-m-json-schema-editor-constant-input-wrapper {
|
|
128
|
+
flex-grow: 1;
|
|
129
|
+
|
|
130
|
+
& .semi-tree-select,
|
|
131
|
+
& .semi-input-number,
|
|
132
|
+
& .semi-select {
|
|
133
|
+
width: 100%;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -14,11 +14,12 @@ import {
|
|
|
14
14
|
import preset, { EditorAPI } from '@flowgram.ai/coze-editor/preset-prompt';
|
|
15
15
|
|
|
16
16
|
import { PropsType } from './types';
|
|
17
|
-
import { UIContainer } from './styles';
|
|
18
17
|
import MarkdownHighlight from './extensions/markdown';
|
|
19
18
|
import LanguageSupport from './extensions/language-support';
|
|
20
19
|
import JinjaHighlight from './extensions/jinja';
|
|
21
20
|
|
|
21
|
+
import './styles.css';
|
|
22
|
+
|
|
22
23
|
type Preset = typeof preset;
|
|
23
24
|
type Options = Partial<InferValues<Preset[number]>>;
|
|
24
25
|
|
|
@@ -42,22 +43,32 @@ export function PromptEditor(props: PromptEditorPropsType) {
|
|
|
42
43
|
|
|
43
44
|
const editorRef = useRef<EditorAPI | null>(null);
|
|
44
45
|
|
|
46
|
+
const editorValue = String(value?.content || '');
|
|
47
|
+
|
|
45
48
|
useEffect(() => {
|
|
46
49
|
// listen to value change
|
|
47
|
-
if (editorRef.current?.getValue() !==
|
|
48
|
-
|
|
50
|
+
if (editorRef.current?.getValue() !== editorValue) {
|
|
51
|
+
// apply updates on readonly mode
|
|
52
|
+
const editorView = editorRef.current?.$view;
|
|
53
|
+
editorView?.dispatch({
|
|
54
|
+
changes: {
|
|
55
|
+
from: 0,
|
|
56
|
+
to: editorView?.state.doc.length,
|
|
57
|
+
insert: editorValue,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
49
60
|
}
|
|
50
|
-
}, [
|
|
61
|
+
}, [editorValue]);
|
|
51
62
|
|
|
52
63
|
return (
|
|
53
|
-
<
|
|
64
|
+
<div className={`gedit-m-prompt-editor-container ${hasError ? 'has-error' : ''}`} style={style}>
|
|
54
65
|
<EditorProvider>
|
|
55
66
|
<Renderer
|
|
56
67
|
didMount={(editor: EditorAPI) => {
|
|
57
68
|
editorRef.current = editor;
|
|
58
69
|
}}
|
|
59
70
|
plugins={preset}
|
|
60
|
-
defaultValue={
|
|
71
|
+
defaultValue={editorValue}
|
|
61
72
|
options={{
|
|
62
73
|
readOnly: readonly,
|
|
63
74
|
editable: !readonly,
|
|
@@ -76,6 +87,6 @@ export function PromptEditor(props: PromptEditorPropsType) {
|
|
|
76
87
|
<JinjaHighlight />
|
|
77
88
|
{children}
|
|
78
89
|
</EditorProvider>
|
|
79
|
-
</
|
|
90
|
+
</div>
|
|
80
91
|
);
|
|
81
92
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.gedit-m-prompt-editor-container {
|
|
7
|
+
background-color: var(--semi-color-fill-0);
|
|
8
|
+
padding-left: 10px;
|
|
9
|
+
padding-right: 6px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.gedit-m-prompt-editor-container.has-error {
|
|
13
|
+
border: 1px solid var(--semi-color-danger-6);
|
|
14
|
+
}
|
|
@@ -3,10 +3,23 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import React from 'react';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import type { IInputsValues } from '@/shared/flow-value';
|
|
9
|
+
import { PromptEditor, PromptEditorPropsType } from '@/components/prompt-editor';
|
|
10
|
+
import { EditorInputsTree } from '@/components/coze-editor-extensions';
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export interface PromptEditorWithInputsProps extends PromptEditorPropsType {
|
|
13
|
+
inputsValues: IInputsValues;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function PromptEditorWithInputs({
|
|
17
|
+
inputsValues,
|
|
18
|
+
...restProps
|
|
19
|
+
}: PromptEditorWithInputsProps) {
|
|
20
|
+
return (
|
|
21
|
+
<PromptEditor {...restProps}>
|
|
22
|
+
<EditorInputsTree inputsValues={inputsValues} />
|
|
23
|
+
</PromptEditor>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -3,10 +3,18 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import React from 'react';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
8
|
+
import { PromptEditor, PromptEditorPropsType } from '@/components/prompt-editor';
|
|
9
|
+
import { EditorVariableTree, EditorVariableTagInject } from '@/components/coze-editor-extensions';
|
|
11
10
|
|
|
12
|
-
export
|
|
11
|
+
export interface PromptEditorWithVariablesProps extends PromptEditorPropsType {}
|
|
12
|
+
|
|
13
|
+
export function PromptEditorWithVariables(props: PromptEditorWithVariablesProps) {
|
|
14
|
+
return (
|
|
15
|
+
<PromptEditor {...props}>
|
|
16
|
+
<EditorVariableTree />
|
|
17
|
+
<EditorVariableTagInject />
|
|
18
|
+
</PromptEditor>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -5,10 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
import React, { createContext, useContext, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
+
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
8
9
|
import { BaseVariableField } from '@flowgram.ai/editor';
|
|
9
10
|
|
|
11
|
+
type VariableField = BaseVariableField<{
|
|
12
|
+
icon?: string | JSX.Element;
|
|
13
|
+
title?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
|
|
10
17
|
export const VariableSelectorContext = createContext<{
|
|
11
|
-
|
|
18
|
+
includeSchema?: IJsonSchema | IJsonSchema[];
|
|
19
|
+
excludeSchema?: IJsonSchema | IJsonSchema[];
|
|
20
|
+
skipVariable?: (variable: VariableField) => boolean;
|
|
12
21
|
}>({});
|
|
13
22
|
|
|
14
23
|
export const useVariableSelectorContext = () => useContext(VariableSelectorContext);
|
|
@@ -16,11 +25,22 @@ export const useVariableSelectorContext = () => useContext(VariableSelectorConte
|
|
|
16
25
|
export const VariableSelectorProvider = ({
|
|
17
26
|
children,
|
|
18
27
|
skipVariable,
|
|
28
|
+
includeSchema,
|
|
29
|
+
excludeSchema,
|
|
19
30
|
}: {
|
|
20
31
|
skipVariable?: (variable?: BaseVariableField) => boolean;
|
|
32
|
+
includeSchema?: IJsonSchema | IJsonSchema[];
|
|
33
|
+
excludeSchema?: IJsonSchema | IJsonSchema[];
|
|
21
34
|
children: React.ReactNode;
|
|
22
35
|
}) => {
|
|
23
|
-
const context = useMemo(
|
|
36
|
+
const context = useMemo(
|
|
37
|
+
() => ({
|
|
38
|
+
skipVariable,
|
|
39
|
+
includeSchema,
|
|
40
|
+
excludeSchema,
|
|
41
|
+
}),
|
|
42
|
+
[skipVariable, includeSchema, excludeSchema]
|
|
43
|
+
);
|
|
24
44
|
|
|
25
45
|
return (
|
|
26
46
|
<VariableSelectorContext.Provider value={context}>{children}</VariableSelectorContext.Provider>
|
|
@@ -9,15 +9,16 @@ import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
|
9
9
|
import { I18n } from '@flowgram.ai/editor';
|
|
10
10
|
import { type TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
|
|
11
11
|
import { type TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
|
|
12
|
-
import { Popover } from '@douyinfe/semi-ui';
|
|
12
|
+
import { Popover, Tag, TreeSelect } from '@douyinfe/semi-ui';
|
|
13
13
|
import { IconChevronDownStroked, IconIssueStroked } from '@douyinfe/semi-icons';
|
|
14
14
|
|
|
15
15
|
import { createInjectMaterial } from '@/shared';
|
|
16
16
|
|
|
17
17
|
import { useVariableTree } from './use-variable-tree';
|
|
18
|
-
import { UIPopoverContent, UIRootTitle, UITag, UITreeSelect, UIVarName } from './styles';
|
|
19
18
|
import { useVariableSelectorContext } from './context';
|
|
20
19
|
|
|
20
|
+
import './styles.css';
|
|
21
|
+
|
|
21
22
|
export interface VariableSelectorProps {
|
|
22
23
|
value?: string[];
|
|
23
24
|
config?: {
|
|
@@ -75,62 +76,71 @@ export const VariableSelector = ({
|
|
|
75
76
|
|
|
76
77
|
return (
|
|
77
78
|
<>
|
|
78
|
-
<
|
|
79
|
+
<TreeSelect
|
|
80
|
+
className={`gedit-m-variable-selector-tree-select ${hasError ? 'error' : ''}`}
|
|
79
81
|
dropdownMatchSelectWidth={false}
|
|
80
82
|
disabled={readonly}
|
|
81
83
|
treeData={treeData}
|
|
82
84
|
size="small"
|
|
83
85
|
value={treeValue}
|
|
84
86
|
clearIcon={null}
|
|
85
|
-
$error={hasError}
|
|
86
87
|
style={style}
|
|
87
88
|
validateStatus={hasError ? 'error' : undefined}
|
|
89
|
+
dropdownClassName="gedit-m-variable-selector-dropdown"
|
|
88
90
|
onChange={(_, _config) => {
|
|
89
91
|
onChange((_config as TreeNodeData).keyPath as string[]);
|
|
90
92
|
}}
|
|
91
93
|
renderSelectedItem={(_option: TreeNodeData) => {
|
|
92
94
|
if (!_option?.keyPath) {
|
|
93
95
|
return (
|
|
94
|
-
<
|
|
96
|
+
<Tag
|
|
97
|
+
className="gedit-m-variable-selector-tag"
|
|
95
98
|
prefixIcon={<IconIssueStroked />}
|
|
96
99
|
color="amber"
|
|
97
100
|
closable={!readonly}
|
|
98
101
|
onClose={() => onChange(undefined)}
|
|
99
102
|
>
|
|
100
103
|
{config?.notFoundContent ?? 'Undefined'}
|
|
101
|
-
</
|
|
104
|
+
</Tag>
|
|
102
105
|
);
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
106
109
|
|
|
107
110
|
const rootTitle = (
|
|
108
|
-
<
|
|
111
|
+
<div className="gedit-m-variable-selector-root-title">
|
|
109
112
|
{_option.rootMeta?.title
|
|
110
113
|
? `${_option.rootMeta?.title} ${_option.isRoot ? '' : '-'} `
|
|
111
114
|
: null}
|
|
112
|
-
</
|
|
115
|
+
</div>
|
|
113
116
|
);
|
|
114
117
|
|
|
115
118
|
return (
|
|
116
119
|
<div>
|
|
117
120
|
<Popover
|
|
118
121
|
content={
|
|
119
|
-
<
|
|
122
|
+
<div className="gedit-m-variable-selector-tag-pop">
|
|
120
123
|
{rootIcon}
|
|
121
124
|
{rootTitle}
|
|
122
|
-
<
|
|
123
|
-
|
|
125
|
+
<div className="gedit-m-variable-selector-var-name">
|
|
126
|
+
{_option.keyPath.slice(1).join('.')}
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
124
129
|
}
|
|
125
130
|
>
|
|
126
|
-
<
|
|
131
|
+
<Tag
|
|
132
|
+
className="gedit-m-variable-selector-tag"
|
|
127
133
|
prefixIcon={rootIcon}
|
|
128
134
|
closable={!readonly}
|
|
129
135
|
onClose={() => onChange(undefined)}
|
|
130
136
|
>
|
|
131
137
|
{rootTitle}
|
|
132
|
-
{!_option.isRoot &&
|
|
133
|
-
|
|
138
|
+
{!_option.isRoot && (
|
|
139
|
+
<div className="gedit-m-variable-selector-var-name in-selector">
|
|
140
|
+
{_option.label}
|
|
141
|
+
</div>
|
|
142
|
+
)}
|
|
143
|
+
</Tag>
|
|
134
144
|
</Popover>
|
|
135
145
|
</div>
|
|
136
146
|
);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.gedit-m-variable-selector-root-title {
|
|
7
|
+
margin-right: 4px;
|
|
8
|
+
min-width: 20px;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
text-overflow: ellipsis;
|
|
11
|
+
white-space: nowrap;
|
|
12
|
+
color: var(--semi-color-text-2);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.gedit-m-variable-selector-var-name {
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
text-overflow: ellipsis;
|
|
18
|
+
white-space: nowrap;
|
|
19
|
+
|
|
20
|
+
&.in-selector {
|
|
21
|
+
min-width: 50%;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.gedit-m-variable-selector-tag {
|
|
26
|
+
width: 100%;
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: flex-start;
|
|
30
|
+
margin: 0;
|
|
31
|
+
height: 22px;
|
|
32
|
+
|
|
33
|
+
.semi-tag-content-center {
|
|
34
|
+
justify-content: flex-start;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.gedit-m-variable-selector-tree-select {
|
|
39
|
+
outline: none;
|
|
40
|
+
|
|
41
|
+
&.error {
|
|
42
|
+
outline: 1px solid red;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.semi-tree-select-selection {
|
|
46
|
+
padding: 0px;
|
|
47
|
+
height: 22px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.semi-tree-select-selection-content {
|
|
51
|
+
width: 100%;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.semi-tree-select-selection-placeholder {
|
|
55
|
+
padding-left: 10px;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.gedit-m-variable-selector-tag-pop {
|
|
60
|
+
padding: 10px;
|
|
61
|
+
display: inline-flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
justify-content: flex-start;
|
|
64
|
+
white-space: nowrap;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.gedit-m-variable-selector-dropdown {
|
|
68
|
+
max-height: 300px;
|
|
69
|
+
overflow: auto;
|
|
70
|
+
}
|