feat: jsparse, jscode tooptip (#1303)
Co-authored-by: sealday <zhanglin@daoyoucloud.com> Reviewed-on: https://git.daoyoucloud.com:8443/daoyoucloud/tachybase/pulls/1303
This commit is contained in:
parent
d3b01736a7
commit
627c88ed83
@ -21,6 +21,7 @@
|
||||
"@formily/reactive-react": "2.3.1",
|
||||
"@formily/shared": "2.3.1",
|
||||
"@formily/validator": "2.3.1",
|
||||
"@uiw/codemirror-theme-vscode": "^4.23.0",
|
||||
"@uiw/react-codemirror": "^4.22.2",
|
||||
"antd": "5.19.1",
|
||||
"classnames": "^2.5.1",
|
||||
|
@ -3,6 +3,7 @@ import { connect } from '@tachybase/schema';
|
||||
|
||||
import { autocompletion } from '@codemirror/autocomplete';
|
||||
import { javascript } from '@codemirror/lang-javascript';
|
||||
import { vscodeDark } from '@uiw/codemirror-theme-vscode';
|
||||
import CM from '@uiw/react-codemirror';
|
||||
|
||||
// 定义全局对象和子对象的补全项
|
||||
@ -83,6 +84,7 @@ export const CodeMirror = connect(({ value, onChange, ...otherProps }) => {
|
||||
value={value || ''}
|
||||
onChange={onChange}
|
||||
{...otherProps}
|
||||
theme={vscodeDark}
|
||||
extensions={[
|
||||
javascript({ jsx: true }),
|
||||
autocompletion({
|
||||
|
@ -27,6 +27,9 @@ export class JSParseInstruction extends Instruction {
|
||||
type: 'string',
|
||||
title: tval('JSCode expression'),
|
||||
'x-decorator': 'FormItem',
|
||||
'x-decorator-props': {
|
||||
tooltip: 'ctx.data\nctx.body\n__ctx\nlib.JSON\nlib.qrcode\ncanvas\nlib.dayjs\nlib.log',
|
||||
},
|
||||
'x-component': 'CodeMirror',
|
||||
required: true,
|
||||
},
|
||||
|
@ -27,7 +27,7 @@ export class JSONParseInstruction extends Instruction {
|
||||
type: 'string',
|
||||
title: tval('Query expression'),
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Input.TextArea',
|
||||
'x-component': 'CodeMirror',
|
||||
},
|
||||
model: {
|
||||
type: 'array',
|
||||
|
@ -1,3 +1,5 @@
|
||||
import crypto from 'crypto';
|
||||
|
||||
import * as canvas from 'canvas';
|
||||
import _ from 'lodash';
|
||||
import qrcode from 'qrcode';
|
||||
@ -19,6 +21,7 @@ export class JSParseInstruction extends Instruction {
|
||||
JSON,
|
||||
canvas,
|
||||
qrcode,
|
||||
crypto,
|
||||
log: console.log,
|
||||
},
|
||||
});
|
||||
@ -62,7 +65,7 @@ function mapModel(data, model) {
|
||||
}
|
||||
|
||||
async function evalSimulate(jsCode, { ctx, lib }) {
|
||||
const AsyncFunction = async function () {}.constructor;
|
||||
const AsyncFunction: any = async function () {}.constructor;
|
||||
return await new AsyncFunction('$root', `with($root) { ${jsCode}; }`)({
|
||||
ctx,
|
||||
// 允许用户覆盖,这个时候可以使用 _ctx
|
||||
|
@ -674,19 +674,22 @@ importers:
|
||||
version: 2.3.1
|
||||
'@formily/react':
|
||||
specifier: 2.3.1
|
||||
version: 2.3.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(typescript@5.4.5)
|
||||
version: 2.3.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(typescript@5.4.5)
|
||||
'@formily/reactive':
|
||||
specifier: 2.3.1
|
||||
version: 2.3.1
|
||||
'@formily/reactive-react':
|
||||
specifier: 2.3.1
|
||||
version: 2.3.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)
|
||||
version: 2.3.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)
|
||||
'@formily/shared':
|
||||
specifier: 2.3.1
|
||||
version: 2.3.1
|
||||
'@formily/validator':
|
||||
specifier: 2.3.1
|
||||
version: 2.3.1
|
||||
'@uiw/codemirror-theme-vscode':
|
||||
specifier: ^4.23.0
|
||||
version: 4.23.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.28.4)
|
||||
'@uiw/react-codemirror':
|
||||
specifier: ^4.22.2
|
||||
version: 4.22.2(@babel/runtime@7.24.7)(@codemirror/autocomplete@6.16.3)(@codemirror/language@6.10.2)(@codemirror/lint@6.8.1)(@codemirror/search@6.5.6)(@codemirror/state@6.4.1)(@codemirror/theme-one-dark@6.1.2)(@codemirror/view@6.28.4)(codemirror@6.0.1)(react-dom@18.3.1)(react@18.3.1)
|
||||
@ -9744,6 +9747,35 @@ packages:
|
||||
- typescript
|
||||
dev: false
|
||||
|
||||
/@formily/react@2.3.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(typescript@5.4.5):
|
||||
resolution: {integrity: sha512-8KkFJe2OnbsgiXwY/txUcUaCQIfIkfowWQinOSni02U2ssgs2bpb1ifFHlZrFGfrrW/xhce4ANUHRgoVYt7W4Q==}
|
||||
engines: {npm: '>=3.0.0'}
|
||||
peerDependencies:
|
||||
'@types/react': '>=16.8.0'
|
||||
'@types/react-dom': '>=16.8.0'
|
||||
react: '>=16.8.0'
|
||||
react-dom: '>=16.8.0'
|
||||
react-is: '>=16.8.0'
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
dependencies:
|
||||
'@formily/core': 2.3.1
|
||||
'@formily/json-schema': 2.3.1(typescript@5.4.5)
|
||||
'@formily/reactive': 2.3.1
|
||||
'@formily/reactive-react': 2.3.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)
|
||||
'@formily/shared': 2.3.1
|
||||
'@formily/validator': 2.3.1
|
||||
hoist-non-react-statics: 3.3.2
|
||||
react: 18.3.1
|
||||
react-dom: 18.3.1(react@18.3.1)
|
||||
react-is: 18.3.1
|
||||
transitivePeerDependencies:
|
||||
- typescript
|
||||
dev: false
|
||||
|
||||
/@formily/reactive-react@2.3.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1):
|
||||
resolution: {integrity: sha512-r6d94JBWhwXGpsffNLnRzgksQJtmqudD1cq7ky2Oljtxg5Ynl8H0Ppcnsv0bd9NbNSAeDeFs2uwWz56exgDzjA==}
|
||||
engines: {npm: '>=3.0.0'}
|
||||
@ -9768,6 +9800,28 @@ packages:
|
||||
react-is: 18.3.1
|
||||
dev: false
|
||||
|
||||
/@formily/reactive-react@2.3.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1):
|
||||
resolution: {integrity: sha512-r6d94JBWhwXGpsffNLnRzgksQJtmqudD1cq7ky2Oljtxg5Ynl8H0Ppcnsv0bd9NbNSAeDeFs2uwWz56exgDzjA==}
|
||||
engines: {npm: '>=3.0.0'}
|
||||
peerDependencies:
|
||||
'@types/react': '>=16.8.0'
|
||||
'@types/react-dom': '>=16.8.0'
|
||||
react: '>=16.8.0'
|
||||
react-dom: '>=16.8.0'
|
||||
react-is: '>=16.8.0'
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
dependencies:
|
||||
'@formily/reactive': 2.3.1
|
||||
hoist-non-react-statics: 3.3.2
|
||||
react: 18.3.1
|
||||
react-dom: 18.3.1(react@18.3.1)
|
||||
react-is: 18.3.1
|
||||
dev: false
|
||||
|
||||
/@formily/reactive@2.3.1:
|
||||
resolution: {integrity: sha512-IVHOZW7VBc+Gq9eB/gPldi7pEC3wDonDb99KvHlS8SmzsY6+a/iAdrw2mDagXXUficsC2gT4y4EcJ2f1ALMKtQ==}
|
||||
engines: {npm: '>=3.0.0'}
|
||||
@ -13277,6 +13331,28 @@ packages:
|
||||
'@codemirror/view': 6.28.4
|
||||
dev: false
|
||||
|
||||
/@uiw/codemirror-theme-vscode@4.23.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.28.4):
|
||||
resolution: {integrity: sha512-zl1FD7U1b58tqlF216jYv2okvVkTe+FP1ztqO/DF129bcH99QjszkakshyfxQEvvF4ys3zyzqZ7vU3VYBir8tg==}
|
||||
dependencies:
|
||||
'@uiw/codemirror-themes': 4.23.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.28.4)
|
||||
transitivePeerDependencies:
|
||||
- '@codemirror/language'
|
||||
- '@codemirror/state'
|
||||
- '@codemirror/view'
|
||||
dev: false
|
||||
|
||||
/@uiw/codemirror-themes@4.23.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.28.4):
|
||||
resolution: {integrity: sha512-9fiji9xooZyBQozR1i6iTr56YP7j/Dr/VgsNWbqf5Szv+g+4WM1iZuiDGwNXmFMWX8gbkDzp6ASE21VCPSofWw==}
|
||||
peerDependencies:
|
||||
'@codemirror/language': '>=6.0.0'
|
||||
'@codemirror/state': '>=6.0.0'
|
||||
'@codemirror/view': '>=6.0.0'
|
||||
dependencies:
|
||||
'@codemirror/language': 6.10.2
|
||||
'@codemirror/state': 6.4.1
|
||||
'@codemirror/view': 6.28.4
|
||||
dev: false
|
||||
|
||||
/@uiw/react-codemirror@4.22.2(@babel/runtime@7.24.7)(@codemirror/autocomplete@6.16.3)(@codemirror/language@6.10.2)(@codemirror/lint@6.8.1)(@codemirror/search@6.5.6)(@codemirror/state@6.4.1)(@codemirror/theme-one-dark@6.1.2)(@codemirror/view@6.28.4)(codemirror@6.0.1)(react-dom@18.3.1)(react@18.3.1):
|
||||
resolution: {integrity: sha512-okCSl+WJG63gRx8Fdz7v0C6RakBQnbb3pHhuzIgDB+fwhipgFodSnu2n9oOsQesJ5YQ7mSOcKMgX0JEsu4nnfQ==}
|
||||
peerDependencies:
|
||||
|
Loading…
Reference in New Issue
Block a user