@flowgram.ai/form-materials 0.4.13 → 0.4.14
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/code-editor/editor.js +54 -77
- package/dist/cjs/components/code-editor/index.js +10 -2
- package/dist/cjs/components/code-editor/language-features.js +119 -16
- package/dist/cjs/components/code-editor/theme/dark.js +120 -50
- package/dist/cjs/components/code-editor/theme/light.js +110 -61
- package/dist/cjs/components/condition-context/context.js +59 -0
- package/dist/cjs/components/condition-context/hooks/use-condition.js +97 -0
- package/dist/cjs/components/condition-context/index.js +47 -0
- package/dist/cjs/components/condition-context/op.js +117 -0
- package/dist/cjs/components/condition-row/index.js +43 -26
- package/dist/cjs/components/condition-row/types.js +1 -35
- package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +4 -3
- package/dist/cjs/components/coze-editor-extensions/extensions/variable-tree.js +3 -0
- package/dist/cjs/components/db-condition-row/index.js +59 -34
- package/dist/cjs/form-plugins/infer-inputs-plugin/index.js +30 -3
- package/dist/cjs/plugins/json-schema-preset/create-type-preset-plugin.js +1 -0
- package/dist/cjs/plugins/json-schema-preset/react.js +1 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/array.js +30 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/boolean.js +23 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/date-time.js +31 -2
- package/dist/cjs/plugins/json-schema-preset/type-definition/index.js +9 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/integer.js +34 -1
- package/dist/cjs/{components/code-editor/init-worker.js → plugins/json-schema-preset/type-definition/map.js} +21 -23
- package/dist/cjs/plugins/json-schema-preset/type-definition/number.js +34 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/object.js +6 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/string.js +30 -1
- package/dist/cjs/plugins/json-schema-preset/types.js +18 -0
- package/dist/cjs/shared/flow-value/utils.js +22 -8
- package/dist/esm/components/code-editor/editor.mjs +4 -9
- package/dist/esm/components/code-editor/index.mjs +5 -2
- package/dist/esm/components/code-editor/language-features.mjs +49 -13
- package/dist/esm/components/code-editor/theme/dark.mjs +117 -50
- package/dist/esm/components/code-editor/theme/light.mjs +108 -62
- package/dist/esm/components/condition-context/context.mjs +19 -0
- package/dist/esm/components/condition-context/hooks/use-condition.mjs +63 -0
- package/dist/esm/components/condition-context/index.mjs +4 -0
- package/dist/esm/components/condition-context/op.mjs +80 -0
- package/dist/esm/components/condition-row/index.mjs +45 -28
- package/dist/esm/components/condition-row/types.mjs +0 -18
- package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +4 -3
- package/dist/esm/components/coze-editor-extensions/extensions/variable-tree.mjs +3 -0
- package/dist/esm/components/db-condition-row/index.mjs +59 -34
- package/dist/esm/form-plugins/infer-inputs-plugin/index.mjs +31 -4
- package/dist/esm/plugins/json-schema-preset/create-type-preset-plugin.mjs +2 -1
- package/dist/esm/plugins/json-schema-preset/react.mjs +2 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/array.mjs +30 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/boolean.mjs +23 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/date-time.mjs +31 -2
- package/dist/esm/plugins/json-schema-preset/type-definition/index.mjs +7 -2
- package/dist/esm/plugins/json-schema-preset/type-definition/integer.mjs +34 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/map.mjs +20 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/number.mjs +34 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/object.mjs +6 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/string.mjs +30 -1
- package/dist/esm/plugins/json-schema-preset/types.mjs +0 -0
- package/dist/esm/shared/flow-value/utils.mjs +22 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/code-editor/editor.d.ts +0 -2
- package/dist/types/components/code-editor/language-features.d.ts +4 -1
- package/dist/types/components/code-editor/theme/dark.d.ts +29 -0
- package/dist/types/components/code-editor/theme/light.d.ts +24 -0
- package/dist/types/components/condition-context/context.d.ts +14 -0
- package/dist/types/components/condition-context/hooks/use-condition.d.ts +29 -0
- package/dist/types/components/condition-context/index.d.ts +8 -0
- package/dist/types/components/condition-context/op.d.ts +22 -0
- package/dist/types/components/condition-context/types.d.ts +14 -0
- package/dist/types/components/condition-row/index.d.ts +4 -7
- package/dist/types/components/condition-row/types.d.ts +0 -24
- package/dist/types/components/db-condition-row/index.d.ts +4 -3
- package/dist/types/components/db-condition-row/types.d.ts +0 -8
- package/dist/types/form-plugins/infer-inputs-plugin/index.d.ts +4 -0
- package/dist/types/plugins/json-schema-preset/create-type-preset-plugin.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/index.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/react.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/array.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/boolean.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/date-time.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/index.d.ts +3 -1
- package/dist/types/plugins/json-schema-preset/type-definition/integer.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/map.d.ts +6 -0
- package/dist/types/plugins/json-schema-preset/type-definition/number.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/object.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/string.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/{manager.d.ts → types.d.ts} +5 -0
- package/dist/types/shared/flow-value/utils.d.ts +3 -1
- package/package.json +7 -6
- package/src/components/code-editor/editor.tsx +7 -10
- package/src/components/code-editor/index.tsx +3 -1
- package/src/components/code-editor/language-features.ts +52 -14
- package/src/components/code-editor/theme/dark.ts +62 -77
- package/src/components/code-editor/theme/light.ts +60 -91
- package/src/components/condition-context/context.tsx +28 -0
- package/src/components/condition-context/hooks/use-condition.tsx +99 -0
- package/src/components/condition-context/index.tsx +14 -0
- package/src/components/condition-context/op.ts +86 -0
- package/src/components/condition-context/types.ts +22 -0
- package/src/components/condition-row/index.tsx +44 -22
- package/src/components/condition-row/types.ts +0 -30
- package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +6 -3
- package/src/components/coze-editor-extensions/extensions/variable-tree.tsx +3 -0
- package/src/components/db-condition-row/index.tsx +76 -24
- package/src/components/db-condition-row/types.ts +0 -13
- package/src/form-plugins/infer-inputs-plugin/index.ts +62 -14
- package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +4 -2
- package/src/plugins/json-schema-preset/index.tsx +1 -1
- package/src/plugins/json-schema-preset/react.tsx +5 -2
- package/src/plugins/json-schema-preset/type-definition/array.tsx +10 -1
- package/src/plugins/json-schema-preset/type-definition/boolean.tsx +17 -1
- package/src/plugins/json-schema-preset/type-definition/date-time.tsx +21 -2
- package/src/plugins/json-schema-preset/type-definition/index.tsx +10 -1
- package/src/plugins/json-schema-preset/type-definition/integer.tsx +19 -1
- package/src/plugins/json-schema-preset/type-definition/map.tsx +31 -0
- package/src/plugins/json-schema-preset/type-definition/number.tsx +19 -1
- package/src/plugins/json-schema-preset/type-definition/object.tsx +6 -1
- package/src/plugins/json-schema-preset/type-definition/string.tsx +19 -1
- package/src/plugins/json-schema-preset/{manager.ts → types.ts} +7 -0
- package/src/shared/flow-value/utils.ts +22 -9
- package/dist/cjs/components/condition-row/constants.js +0 -165
- package/dist/cjs/components/condition-row/hooks/useOp.js +0 -78
- package/dist/cjs/components/condition-row/hooks/useRule.js +0 -68
- package/dist/cjs/components/db-condition-row/hooks/use-left.js +0 -86
- package/dist/cjs/components/db-condition-row/hooks/use-op.js +0 -79
- package/dist/esm/components/code-editor/init-worker.mjs +0 -19
- package/dist/esm/components/condition-row/constants.mjs +0 -128
- package/dist/esm/components/condition-row/hooks/useOp.mjs +0 -44
- package/dist/esm/components/condition-row/hooks/useRule.mjs +0 -34
- package/dist/esm/components/db-condition-row/hooks/use-left.mjs +0 -52
- package/dist/esm/components/db-condition-row/hooks/use-op.mjs +0 -45
- package/dist/types/components/code-editor/init-worker.d.ts +0 -5
- package/dist/types/components/condition-row/constants.d.ts +0 -7
- package/dist/types/components/condition-row/hooks/useOp.d.ts +0 -18
- package/dist/types/components/condition-row/hooks/useRule.d.ts +0 -9
- package/dist/types/components/db-condition-row/hooks/use-left.d.ts +0 -18
- package/dist/types/components/db-condition-row/hooks/use-op.d.ts +0 -18
- package/src/components/code-editor/init-worker.ts +0 -27
- package/src/components/condition-row/constants.ts +0 -134
- package/src/components/condition-row/hooks/useOp.tsx +0 -56
- package/src/components/condition-row/hooks/useRule.ts +0 -35
- package/src/components/db-condition-row/hooks/use-left.tsx +0 -66
- package/src/components/db-condition-row/hooks/use-op.tsx +0 -59
- /package/dist/cjs/{plugins/json-schema-preset/manager.js → components/condition-context/types.js} +0 -0
- /package/dist/esm/{plugins/json-schema-preset/manager.mjs → components/condition-context/types.mjs} +0 -0
|
@@ -30,6 +30,7 @@ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
|
30
30
|
require("react");
|
|
31
31
|
const editor_namespaceObject = require("@flowgram.ai/editor");
|
|
32
32
|
const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
|
|
33
|
+
const op_js_namespaceObject = require("../../../components/condition-context/op.js");
|
|
33
34
|
const numberRegistry = {
|
|
34
35
|
type: 'number',
|
|
35
36
|
ConstantRenderer: (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.InputNumber, {
|
|
@@ -38,7 +39,39 @@ const numberRegistry = {
|
|
|
38
39
|
disabled: props.readonly,
|
|
39
40
|
hideButtons: true,
|
|
40
41
|
...props
|
|
41
|
-
})
|
|
42
|
+
}),
|
|
43
|
+
conditionRule: {
|
|
44
|
+
[op_js_namespaceObject.ConditionPresetOp.EQ]: {
|
|
45
|
+
type: 'number'
|
|
46
|
+
},
|
|
47
|
+
[op_js_namespaceObject.ConditionPresetOp.NEQ]: {
|
|
48
|
+
type: 'number'
|
|
49
|
+
},
|
|
50
|
+
[op_js_namespaceObject.ConditionPresetOp.GT]: {
|
|
51
|
+
type: 'number'
|
|
52
|
+
},
|
|
53
|
+
[op_js_namespaceObject.ConditionPresetOp.GTE]: {
|
|
54
|
+
type: 'number'
|
|
55
|
+
},
|
|
56
|
+
[op_js_namespaceObject.ConditionPresetOp.LT]: {
|
|
57
|
+
type: 'number'
|
|
58
|
+
},
|
|
59
|
+
[op_js_namespaceObject.ConditionPresetOp.LTE]: {
|
|
60
|
+
type: 'number'
|
|
61
|
+
},
|
|
62
|
+
[op_js_namespaceObject.ConditionPresetOp.IN]: {
|
|
63
|
+
type: 'array',
|
|
64
|
+
extra: {
|
|
65
|
+
weak: true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
[op_js_namespaceObject.ConditionPresetOp.NIN]: {
|
|
69
|
+
type: 'array',
|
|
70
|
+
extra: {
|
|
71
|
+
weak: true
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
42
75
|
};
|
|
43
76
|
exports.numberRegistry = __webpack_exports__.numberRegistry;
|
|
44
77
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
@@ -29,6 +29,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
30
|
require("react");
|
|
31
31
|
const editor_namespaceObject = require("@flowgram.ai/editor");
|
|
32
|
+
const op_js_namespaceObject = require("../../../components/condition-context/op.js");
|
|
32
33
|
const index_js_namespaceObject = require("../../../components/code-editor-mini/index.js");
|
|
33
34
|
const objectRegistry = {
|
|
34
35
|
type: 'object',
|
|
@@ -38,7 +39,11 @@ const objectRegistry = {
|
|
|
38
39
|
languageId: "json",
|
|
39
40
|
placeholder: editor_namespaceObject.I18n.t('Please Input Object'),
|
|
40
41
|
readonly: props.readonly
|
|
41
|
-
})
|
|
42
|
+
}),
|
|
43
|
+
conditionRule: {
|
|
44
|
+
[op_js_namespaceObject.ConditionPresetOp.IS_EMPTY]: null,
|
|
45
|
+
[op_js_namespaceObject.ConditionPresetOp.IS_NOT_EMPTY]: null
|
|
46
|
+
}
|
|
42
47
|
};
|
|
43
48
|
exports.objectRegistry = __webpack_exports__.objectRegistry;
|
|
44
49
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
@@ -30,6 +30,7 @@ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
|
30
30
|
require("react");
|
|
31
31
|
const editor_namespaceObject = require("@flowgram.ai/editor");
|
|
32
32
|
const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
|
|
33
|
+
const op_js_namespaceObject = require("../../../components/condition-context/op.js");
|
|
33
34
|
const stringRegistry = {
|
|
34
35
|
type: 'string',
|
|
35
36
|
ConstantRenderer: (props)=>props?.enableMultiLineStr ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.TextArea, {
|
|
@@ -43,7 +44,35 @@ const stringRegistry = {
|
|
|
43
44
|
placeholder: editor_namespaceObject.I18n.t('Please Input String'),
|
|
44
45
|
disabled: props.readonly,
|
|
45
46
|
...props
|
|
46
|
-
})
|
|
47
|
+
}),
|
|
48
|
+
conditionRule: {
|
|
49
|
+
[op_js_namespaceObject.ConditionPresetOp.EQ]: {
|
|
50
|
+
type: 'string'
|
|
51
|
+
},
|
|
52
|
+
[op_js_namespaceObject.ConditionPresetOp.NEQ]: {
|
|
53
|
+
type: 'string'
|
|
54
|
+
},
|
|
55
|
+
[op_js_namespaceObject.ConditionPresetOp.CONTAINS]: {
|
|
56
|
+
type: 'string'
|
|
57
|
+
},
|
|
58
|
+
[op_js_namespaceObject.ConditionPresetOp.NOT_CONTAINS]: {
|
|
59
|
+
type: 'string'
|
|
60
|
+
},
|
|
61
|
+
[op_js_namespaceObject.ConditionPresetOp.IN]: {
|
|
62
|
+
type: 'array',
|
|
63
|
+
items: {
|
|
64
|
+
type: 'string'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
[op_js_namespaceObject.ConditionPresetOp.NIN]: {
|
|
68
|
+
type: 'array',
|
|
69
|
+
items: {
|
|
70
|
+
type: 'string'
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
[op_js_namespaceObject.ConditionPresetOp.IS_EMPTY]: null,
|
|
74
|
+
[op_js_namespaceObject.ConditionPresetOp.IS_NOT_EMPTY]: null
|
|
75
|
+
}
|
|
47
76
|
};
|
|
48
77
|
exports.stringRegistry = __webpack_exports__.stringRegistry;
|
|
49
78
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -57,34 +57,48 @@ const external_schema_js_namespaceObject = require("./schema.js");
|
|
|
57
57
|
function* traverse(value, options) {
|
|
58
58
|
const { includeTypes = [
|
|
59
59
|
'ref',
|
|
60
|
-
'template'
|
|
61
|
-
|
|
60
|
+
'template',
|
|
61
|
+
'expression',
|
|
62
|
+
'constant'
|
|
63
|
+
], path = '', pathArr = [] } = options || {};
|
|
62
64
|
if ((0, external_lodash_es_namespaceObject.isPlainObject)(value)) {
|
|
63
65
|
if (isRef(value) && includeTypes.includes('ref')) return void (yield {
|
|
64
66
|
value,
|
|
65
|
-
path
|
|
67
|
+
path,
|
|
68
|
+
pathArr
|
|
66
69
|
});
|
|
67
70
|
if (isTemplate(value) && includeTypes.includes('template')) return void (yield {
|
|
68
71
|
value,
|
|
69
|
-
path
|
|
72
|
+
path,
|
|
73
|
+
pathArr
|
|
70
74
|
});
|
|
71
75
|
if (isExpression(value) && includeTypes.includes('expression')) return void (yield {
|
|
72
76
|
value,
|
|
73
|
-
path
|
|
77
|
+
path,
|
|
78
|
+
pathArr
|
|
74
79
|
});
|
|
75
80
|
if (isConstant(value) && includeTypes.includes('constant')) return void (yield {
|
|
76
81
|
value,
|
|
77
|
-
path
|
|
82
|
+
path,
|
|
83
|
+
pathArr
|
|
78
84
|
});
|
|
79
85
|
for (const [_key, _value] of Object.entries(value))yield* traverse(_value, {
|
|
80
86
|
...options,
|
|
81
|
-
path: `${path}.${_key}`
|
|
87
|
+
path: path ? `${path}.${_key}` : _key,
|
|
88
|
+
pathArr: [
|
|
89
|
+
...pathArr,
|
|
90
|
+
_key
|
|
91
|
+
]
|
|
82
92
|
});
|
|
83
93
|
return;
|
|
84
94
|
}
|
|
85
95
|
if ((0, external_lodash_es_namespaceObject.isArray)(value)) for (const [_idx, _value] of value.entries())yield* traverse(_value, {
|
|
86
96
|
...options,
|
|
87
|
-
path: `${path}[${_idx}]`
|
|
97
|
+
path: path ? `${path}[${_idx}]` : `[${_idx}]`,
|
|
98
|
+
pathArr: [
|
|
99
|
+
...pathArr,
|
|
100
|
+
`[${_idx}]`
|
|
101
|
+
]
|
|
88
102
|
});
|
|
89
103
|
}
|
|
90
104
|
FlowValueUtils.traverse = traverse;
|
|
@@ -2,10 +2,10 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useRef } from "react";
|
|
3
3
|
import { ActiveLinePlaceholder, EditorProvider, createRenderer } from "@flowgram.ai/coze-editor/react";
|
|
4
4
|
import preset_code from "@flowgram.ai/coze-editor/preset-code";
|
|
5
|
+
import { Skeleton } from "@douyinfe/semi-ui";
|
|
5
6
|
import { EditorView } from "@codemirror/view";
|
|
6
7
|
import { getSuffixByLanguageId } from "./utils.mjs";
|
|
7
|
-
import "./
|
|
8
|
-
import "./language-features.mjs";
|
|
8
|
+
import { useDynamicLoadLanguage } from "./language-features.mjs";
|
|
9
9
|
const OriginCodeEditor = createRenderer(preset_code, [
|
|
10
10
|
EditorView.theme({
|
|
11
11
|
'&.cm-focused': {
|
|
@@ -14,19 +14,14 @@ const OriginCodeEditor = createRenderer(preset_code, [
|
|
|
14
14
|
})
|
|
15
15
|
]);
|
|
16
16
|
function CodeEditor({ value, onChange, languageId = 'python', theme = 'light', children, placeholder, activeLinePlaceholder, options, readonly }) {
|
|
17
|
+
const { loaded } = useDynamicLoadLanguage(languageId);
|
|
17
18
|
const editorRef = useRef(null);
|
|
18
19
|
useEffect(()=>{
|
|
19
20
|
if (editorRef.current?.getValue() !== value) editorRef.current?.setValue(String(value || ''));
|
|
20
21
|
}, [
|
|
21
22
|
value
|
|
22
23
|
]);
|
|
23
|
-
|
|
24
|
-
if ("typescript" === languageId) import("./init-worker.mjs").then((module)=>{
|
|
25
|
-
module.initTsWorker();
|
|
26
|
-
});
|
|
27
|
-
}, [
|
|
28
|
-
languageId
|
|
29
|
-
]);
|
|
24
|
+
if (!loaded) return /*#__PURE__*/ jsx(Skeleton, {});
|
|
30
25
|
return /*#__PURE__*/ jsx(EditorProvider, {
|
|
31
26
|
children: /*#__PURE__*/ jsxs(OriginCodeEditor, {
|
|
32
27
|
defaultValue: String(value || ''),
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { lazySuspense } from "../../shared/index.mjs";
|
|
2
|
-
const CodeEditor = lazySuspense(()=>
|
|
3
|
-
|
|
2
|
+
const CodeEditor = lazySuspense(()=>Promise.all([
|
|
3
|
+
import("./editor.mjs"),
|
|
4
|
+
import("./theme/index.mjs")
|
|
5
|
+
]).then(([editorModule])=>({
|
|
6
|
+
default: editorModule.CodeEditor
|
|
4
7
|
})));
|
|
5
8
|
export { CodeEditor };
|
|
@@ -1,15 +1,51 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
1
2
|
import { languages } from "@flowgram.ai/coze-editor/preset-code";
|
|
2
|
-
import { typescript } from "@flowgram.ai/coze-editor/language-typescript";
|
|
3
|
-
import { shell } from "@flowgram.ai/coze-editor/language-shell";
|
|
4
|
-
import { python } from "@flowgram.ai/coze-editor/language-python";
|
|
5
|
-
import { json } from "@flowgram.ai/coze-editor/language-json";
|
|
6
3
|
import { mixLanguages } from "@flowgram.ai/coze-editor";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
languages.register(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
const dynamicLoadLanguages = {
|
|
5
|
+
python: ()=>import("@flowgram.ai/coze-editor/language-python").then((module)=>{
|
|
6
|
+
languages.register('python', module.python);
|
|
7
|
+
}),
|
|
8
|
+
shell: ()=>import("@flowgram.ai/coze-editor/language-shell").then((module)=>{
|
|
9
|
+
languages.register('shell', module.shell);
|
|
10
|
+
}),
|
|
11
|
+
typescript: ()=>import("@flowgram.ai/coze-editor/language-typescript").then((module)=>{
|
|
12
|
+
languages.register("typescript", module.typescript);
|
|
13
|
+
const tsWorker = new Worker(new URL("@flowgram.ai/coze-editor/language-typescript/worker", import.meta.url), {
|
|
14
|
+
type: 'module'
|
|
15
|
+
});
|
|
16
|
+
module.typescript.languageService.initialize(tsWorker, {
|
|
17
|
+
compilerOptions: {
|
|
18
|
+
lib: [
|
|
19
|
+
'es2015',
|
|
20
|
+
'dom'
|
|
21
|
+
],
|
|
22
|
+
noImplicitAny: false
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}),
|
|
26
|
+
json: ()=>import("@flowgram.ai/coze-editor/language-json").then((module)=>{
|
|
27
|
+
languages.register('json', {
|
|
28
|
+
language: mixLanguages({
|
|
29
|
+
outerLanguage: module.json.language
|
|
30
|
+
}),
|
|
31
|
+
languageService: module.json.languageService
|
|
32
|
+
});
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
const useDynamicLoadLanguage = (languageId)=>{
|
|
36
|
+
const [loaded, setLoaded] = useState(useMemo(()=>!!languages.get(languageId), [
|
|
37
|
+
languageId
|
|
38
|
+
]));
|
|
39
|
+
useEffect(()=>{
|
|
40
|
+
if (!loaded && dynamicLoadLanguages[languageId]) dynamicLoadLanguages[languageId]().then(()=>{
|
|
41
|
+
setLoaded(true);
|
|
42
|
+
});
|
|
43
|
+
}, [
|
|
44
|
+
languageId,
|
|
45
|
+
loaded
|
|
46
|
+
]);
|
|
47
|
+
return {
|
|
48
|
+
loaded
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export { dynamicLoadLanguages, useDynamicLoadLanguage };
|
|
@@ -1,24 +1,42 @@
|
|
|
1
1
|
import { createTheme, tags } from "@flowgram.ai/coze-editor/preset-code";
|
|
2
2
|
const colors = {
|
|
3
|
-
background: '#
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
background: '#24292e',
|
|
4
|
+
foreground: '#d1d5da',
|
|
5
|
+
selection: '#3392FF44',
|
|
6
|
+
cursor: '#c8e1ff',
|
|
7
|
+
dropdownBackground: '#24292e',
|
|
8
|
+
dropdownBorder: '#1b1f23',
|
|
9
|
+
activeLine: '#4d566022',
|
|
10
|
+
matchingBracket: '#888892',
|
|
11
|
+
keyword: '#9197F1',
|
|
12
|
+
storage: '#f97583',
|
|
13
|
+
variable: '#ffab70',
|
|
14
|
+
variableName: '#D9DCFA',
|
|
15
|
+
parameter: '#e1e4e8',
|
|
16
|
+
function: '#FFCA66',
|
|
17
|
+
string: '#FF9878',
|
|
18
|
+
constant: '#79b8ff',
|
|
19
|
+
type: '#79b8ff',
|
|
20
|
+
class: '#b392f0',
|
|
21
|
+
number: '#2EC7D9',
|
|
22
|
+
comment: '#568B2A',
|
|
23
|
+
heading: '#79b8ff',
|
|
24
|
+
invalid: '#f97583',
|
|
25
|
+
regexp: '#9ecbff',
|
|
26
|
+
propertyName: '#9197F1',
|
|
27
|
+
separator: '#888892',
|
|
28
|
+
gutters: '#888892',
|
|
29
|
+
moduleKeyword: '#CC4FD4'
|
|
12
30
|
};
|
|
13
31
|
const darkTheme = createTheme({
|
|
14
32
|
variant: 'dark',
|
|
15
33
|
settings: {
|
|
16
34
|
background: colors.background,
|
|
17
|
-
foreground:
|
|
18
|
-
caret:
|
|
19
|
-
selection:
|
|
35
|
+
foreground: colors.foreground,
|
|
36
|
+
caret: colors.cursor,
|
|
37
|
+
selection: colors.selection,
|
|
20
38
|
gutterBackground: colors.background,
|
|
21
|
-
gutterForeground:
|
|
39
|
+
gutterForeground: colors.foreground,
|
|
22
40
|
gutterBorderColor: 'transparent',
|
|
23
41
|
gutterBorderWidth: 0,
|
|
24
42
|
lineHighlight: '#21262D',
|
|
@@ -39,7 +57,8 @@ const darkTheme = createTheme({
|
|
|
39
57
|
backgroundColor: '#21262D'
|
|
40
58
|
},
|
|
41
59
|
completionItemSelected: {
|
|
42
|
-
backgroundColor:
|
|
60
|
+
backgroundColor: colors.selection,
|
|
61
|
+
color: colors.foreground
|
|
43
62
|
},
|
|
44
63
|
completionItemIcon: {
|
|
45
64
|
color: '#8B949E'
|
|
@@ -56,99 +75,147 @@ const darkTheme = createTheme({
|
|
|
56
75
|
},
|
|
57
76
|
styles: [
|
|
58
77
|
{
|
|
59
|
-
tag: tags.
|
|
60
|
-
color: colors.
|
|
78
|
+
tag: tags.keyword,
|
|
79
|
+
color: colors.keyword
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
tag: tags.variableName,
|
|
83
|
+
color: colors.variableName
|
|
61
84
|
},
|
|
62
85
|
{
|
|
63
86
|
tag: [
|
|
64
|
-
tags.
|
|
87
|
+
tags.name,
|
|
88
|
+
tags.deleted,
|
|
89
|
+
tags.character,
|
|
90
|
+
tags.macroName
|
|
65
91
|
],
|
|
66
|
-
color: colors.
|
|
92
|
+
color: colors.variable
|
|
67
93
|
},
|
|
68
94
|
{
|
|
69
95
|
tag: [
|
|
70
|
-
tags.
|
|
96
|
+
tags.propertyName
|
|
71
97
|
],
|
|
72
|
-
color: colors.
|
|
98
|
+
color: colors.propertyName
|
|
73
99
|
},
|
|
74
100
|
{
|
|
75
101
|
tag: [
|
|
76
|
-
tags.
|
|
102
|
+
tags.processingInstruction,
|
|
103
|
+
tags.string,
|
|
104
|
+
tags.inserted,
|
|
105
|
+
tags.special(tags.string)
|
|
77
106
|
],
|
|
78
|
-
color: colors.
|
|
107
|
+
color: colors.string
|
|
79
108
|
},
|
|
80
109
|
{
|
|
81
110
|
tag: [
|
|
82
|
-
tags.
|
|
111
|
+
tags["function"](tags.variableName),
|
|
112
|
+
tags["function"](tags.propertyName),
|
|
113
|
+
tags.labelName
|
|
83
114
|
],
|
|
84
|
-
color: colors.
|
|
115
|
+
color: colors.function
|
|
85
116
|
},
|
|
86
117
|
{
|
|
87
118
|
tag: [
|
|
88
|
-
tags
|
|
119
|
+
tags.moduleKeyword,
|
|
120
|
+
tags.controlKeyword
|
|
89
121
|
],
|
|
90
|
-
color: colors.
|
|
122
|
+
color: colors.moduleKeyword
|
|
91
123
|
},
|
|
92
124
|
{
|
|
93
125
|
tag: [
|
|
94
|
-
tags.
|
|
126
|
+
tags.color,
|
|
127
|
+
tags.constant(tags.name),
|
|
128
|
+
tags.standard(tags.name)
|
|
95
129
|
],
|
|
96
|
-
color: colors.
|
|
130
|
+
color: colors.constant
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
tag: tags.definition(tags.name),
|
|
134
|
+
color: colors.variable
|
|
97
135
|
},
|
|
98
136
|
{
|
|
99
137
|
tag: [
|
|
100
|
-
tags.
|
|
138
|
+
tags.className
|
|
101
139
|
],
|
|
102
|
-
color:
|
|
140
|
+
color: colors.class
|
|
103
141
|
},
|
|
104
142
|
{
|
|
105
143
|
tag: [
|
|
106
|
-
tags.
|
|
144
|
+
tags.number,
|
|
145
|
+
tags.changed,
|
|
146
|
+
tags.annotation,
|
|
147
|
+
tags.modifier,
|
|
148
|
+
tags.self,
|
|
149
|
+
tags.namespace
|
|
107
150
|
],
|
|
108
|
-
color:
|
|
151
|
+
color: colors.number
|
|
109
152
|
},
|
|
110
153
|
{
|
|
111
154
|
tag: [
|
|
112
|
-
tags.
|
|
155
|
+
tags.typeName
|
|
113
156
|
],
|
|
114
|
-
color:
|
|
157
|
+
color: colors.type,
|
|
158
|
+
fontStyle: colors.type
|
|
115
159
|
},
|
|
116
160
|
{
|
|
117
161
|
tag: [
|
|
118
162
|
tags.operatorKeyword
|
|
119
163
|
],
|
|
120
|
-
color:
|
|
164
|
+
color: colors.keyword
|
|
121
165
|
},
|
|
122
166
|
{
|
|
123
167
|
tag: [
|
|
124
|
-
tags.
|
|
168
|
+
tags.url,
|
|
169
|
+
tags.escape,
|
|
170
|
+
tags.regexp,
|
|
171
|
+
tags.link
|
|
125
172
|
],
|
|
126
|
-
color:
|
|
173
|
+
color: colors.regexp
|
|
127
174
|
},
|
|
128
175
|
{
|
|
129
176
|
tag: [
|
|
130
|
-
tags.
|
|
177
|
+
tags.meta,
|
|
178
|
+
tags.comment
|
|
131
179
|
],
|
|
132
|
-
color:
|
|
180
|
+
color: colors.comment
|
|
133
181
|
},
|
|
134
182
|
{
|
|
135
|
-
tag:
|
|
136
|
-
|
|
137
|
-
],
|
|
138
|
-
color: '#34D399'
|
|
183
|
+
tag: tags.strong,
|
|
184
|
+
fontWeight: 'bold'
|
|
139
185
|
},
|
|
140
186
|
{
|
|
141
|
-
tag:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
187
|
+
tag: tags.emphasis,
|
|
188
|
+
fontStyle: 'italic'
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
tag: tags.link,
|
|
192
|
+
textDecoration: 'underline'
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
tag: tags.heading,
|
|
196
|
+
fontWeight: 'bold',
|
|
197
|
+
color: colors.heading
|
|
145
198
|
},
|
|
146
199
|
{
|
|
147
200
|
tag: [
|
|
148
|
-
tags.
|
|
201
|
+
tags.atom,
|
|
202
|
+
tags.bool,
|
|
203
|
+
tags.special(tags.variableName)
|
|
149
204
|
],
|
|
150
|
-
color:
|
|
205
|
+
color: colors.variable
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
tag: tags.invalid,
|
|
209
|
+
color: colors.invalid
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
tag: tags.strikethrough,
|
|
213
|
+
textDecoration: 'line-through'
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
tag: tags.separator,
|
|
217
|
+
color: colors.separator
|
|
151
218
|
}
|
|
152
219
|
]
|
|
153
220
|
});
|
|
154
|
-
export { darkTheme };
|
|
221
|
+
export { colors, darkTheme };
|