@ant-design/agentic-ui 2.18.0 → 2.20.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/MarkdownEditor/editor/elements/Head.js +3 -17
- package/dist/MarkdownEditor/editor/elements/Paragraph.js +7 -20
- package/dist/MarkdownEditor/editor/style.js +0 -30
- package/dist/Plugins/code/components/CodeRenderer.js +6 -1
- package/dist/Schema/SchemaEditor/index.d.ts +23 -6
- package/dist/Schema/SchemaEditor/index.js +101 -20
- package/package.json +1 -1
- package/dist/MarkdownEditor/editor/keyframes.css +0 -20
|
@@ -97,28 +97,16 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
97
97
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
98
98
|
}
|
|
99
99
|
import classNames from "classnames";
|
|
100
|
-
import React, { createElement
|
|
100
|
+
import React, { createElement } from "react";
|
|
101
101
|
import { Node } from "slate";
|
|
102
|
-
import { useSlate } from "slate-react";
|
|
103
102
|
import { useSelStatus } from "../../hooks/editor";
|
|
104
103
|
import { useEditorStore } from "../store";
|
|
105
104
|
import { DragHandle } from "../tools/DragHandle";
|
|
106
105
|
import { slugify } from "../utils/dom";
|
|
107
106
|
export function Head(param) {
|
|
108
107
|
var element = param.element, attributes = param.attributes, children = param.children;
|
|
109
|
-
var
|
|
110
|
-
var _useEditorStore = useEditorStore(), _useEditorStore_store = _useEditorStore.store, store = _useEditorStore_store === void 0 ? {} : _useEditorStore_store, markdownContainerRef = _useEditorStore.markdownContainerRef, typewriter = _useEditorStore.typewriter;
|
|
111
|
-
var editor = useSlate();
|
|
108
|
+
var _useEditorStore = useEditorStore(), _useEditorStore_store = _useEditorStore.store, store = _useEditorStore_store === void 0 ? {} : _useEditorStore_store, markdownContainerRef = _useEditorStore.markdownContainerRef;
|
|
112
109
|
var _useSelStatus = _sliced_to_array(useSelStatus(element), 2), selected = _useSelStatus[0], path = _useSelStatus[1];
|
|
113
|
-
var isLast = useMemo(function() {
|
|
114
|
-
if (editor.children.length === 0) return false;
|
|
115
|
-
if (!typewriter) return false;
|
|
116
|
-
return store.isLatestNode(element);
|
|
117
|
-
}, [
|
|
118
|
-
(_editor_children_at = (_editor_children = editor.children).at) === null || _editor_children_at === void 0 ? void 0 : _editor_children_at.call(_editor_children, path.at(0)),
|
|
119
|
-
(_editor_children_at1 = (_editor_children1 = editor.children).at) === null || _editor_children_at1 === void 0 ? void 0 : _editor_children_at1.call(_editor_children1, path.at(0) + 1),
|
|
120
|
-
typewriter
|
|
121
|
-
]);
|
|
122
110
|
var str = Node.string(element);
|
|
123
111
|
return React.useMemo(function() {
|
|
124
112
|
var _obj;
|
|
@@ -127,12 +115,10 @@ export function Head(param) {
|
|
|
127
115
|
}, _define_property(_obj, 'data-be', 'head'), _define_property(_obj, 'data-head', slugify(Node.string(element) || '')), _define_property(_obj, 'data-title', (path === null || path === void 0 ? void 0 : path[0]) === 0), _define_property(_obj, "onDragStart", function(e) {
|
|
128
116
|
return store.dragStart(e, markdownContainerRef.current);
|
|
129
117
|
}), _define_property(_obj, 'data-empty', !str && selected ? 'true' : undefined), _define_property(_obj, 'data-align', element.align), _define_property(_obj, 'data-drag-el', true), _define_property(_obj, "className", classNames({
|
|
130
|
-
empty: !str
|
|
131
|
-
typewriter: isLast && typewriter
|
|
118
|
+
empty: !str
|
|
132
119
|
})), _obj)), /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(DragHandle, null), children));
|
|
133
120
|
}, [
|
|
134
121
|
element.level,
|
|
135
|
-
isLast,
|
|
136
122
|
str,
|
|
137
123
|
element.children,
|
|
138
124
|
selected,
|
|
@@ -97,27 +97,17 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
97
97
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
98
98
|
}
|
|
99
99
|
import classNames from "classnames";
|
|
100
|
-
import React, { useContext
|
|
100
|
+
import React, { useContext } from "react";
|
|
101
101
|
import { Node } from "slate";
|
|
102
102
|
import { I18nContext } from "../../../I18n";
|
|
103
103
|
import { useSelStatus } from "../../hooks/editor";
|
|
104
104
|
import { useEditorStore } from "../store";
|
|
105
105
|
import { DragHandle } from "../tools/DragHandle";
|
|
106
106
|
export var Paragraph = function(props) {
|
|
107
|
-
var
|
|
108
|
-
var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef,
|
|
107
|
+
var _markdownEditorRef_current;
|
|
108
|
+
var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, readonly = _useEditorStore.readonly, editorProps = _useEditorStore.editorProps;
|
|
109
109
|
var locale = useContext(I18nContext).locale;
|
|
110
|
-
var _useSelStatus = _sliced_to_array(useSelStatus(props.element),
|
|
111
|
-
var isLast = useMemo(function() {
|
|
112
|
-
var _markdownEditorRef_current;
|
|
113
|
-
if (((_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children.length) === 0) return false;
|
|
114
|
-
if (!typewriter) return false;
|
|
115
|
-
return store.isLatestNode(props.element);
|
|
116
|
-
}, [
|
|
117
|
-
(_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : (_markdownEditorRef_current_children_at = (_markdownEditorRef_current_children = _markdownEditorRef_current.children).at) === null || _markdownEditorRef_current_children_at === void 0 ? void 0 : _markdownEditorRef_current_children_at.call(_markdownEditorRef_current_children, path.at(0)),
|
|
118
|
-
(_markdownEditorRef_current1 = markdownEditorRef.current) === null || _markdownEditorRef_current1 === void 0 ? void 0 : (_markdownEditorRef_current_children_at1 = (_markdownEditorRef_current_children1 = _markdownEditorRef_current1.children).at) === null || _markdownEditorRef_current_children_at1 === void 0 ? void 0 : _markdownEditorRef_current_children_at1.call(_markdownEditorRef_current_children1, path.at(0) + 1),
|
|
119
|
-
typewriter
|
|
120
|
-
]);
|
|
110
|
+
var _useSelStatus = _sliced_to_array(useSelStatus(props.element), 1), selected = _useSelStatus[0];
|
|
121
111
|
return React.useMemo(function() {
|
|
122
112
|
var _markdownEditorRef_current, _props_element_children_every, _props_element_children, _props_element, _props_children;
|
|
123
113
|
var str = Node.string(props.element).trim();
|
|
@@ -128,8 +118,7 @@ export var Paragraph = function(props) {
|
|
|
128
118
|
"data-be": 'paragraph',
|
|
129
119
|
"data-drag-el": true,
|
|
130
120
|
className: classNames({
|
|
131
|
-
empty: isEmpty
|
|
132
|
-
typewriter: isLast && typewriter
|
|
121
|
+
empty: isEmpty
|
|
133
122
|
}),
|
|
134
123
|
"data-align": props.element.align,
|
|
135
124
|
"data-slate-placeholder": isEmpty ? editorProps.titlePlaceholderContent || (locale === null || locale === void 0 ? void 0 : locale.inputPlaceholder) || '请输入内容...' : undefined,
|
|
@@ -146,9 +135,7 @@ export var Paragraph = function(props) {
|
|
|
146
135
|
props.element.align,
|
|
147
136
|
readonly,
|
|
148
137
|
selected,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
editorProps.titlePlaceholderContent,
|
|
152
|
-
typewriter
|
|
138
|
+
(_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children.length,
|
|
139
|
+
editorProps.titlePlaceholderContent
|
|
153
140
|
]);
|
|
154
141
|
};
|
|
@@ -50,32 +50,11 @@ function _object_spread_props(target, source) {
|
|
|
50
50
|
}
|
|
51
51
|
return target;
|
|
52
52
|
}
|
|
53
|
-
import { Keyframes } from "@ant-design/cssinjs";
|
|
54
53
|
import { MOBILE_BREAKPOINT } from "../../Constants/mobile";
|
|
55
54
|
import { resetComponent, useEditorStyleRegister } from "../../Hooks/useStyle";
|
|
56
55
|
import "./code.css";
|
|
57
56
|
// 导入统一的标签样式配置
|
|
58
57
|
import { TAG_STYLES } from "./tagStyles";
|
|
59
|
-
// 定义关键帧动画
|
|
60
|
-
var typing = new Keyframes('typing', {
|
|
61
|
-
from: {
|
|
62
|
-
width: 0
|
|
63
|
-
},
|
|
64
|
-
to: {
|
|
65
|
-
width: '100%'
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
var blinkCaret = new Keyframes('blink-caret', {
|
|
69
|
-
from: {
|
|
70
|
-
borderColor: 'transparent'
|
|
71
|
-
},
|
|
72
|
-
to: {
|
|
73
|
-
borderColor: 'transparent'
|
|
74
|
-
},
|
|
75
|
-
'50%': {
|
|
76
|
-
borderColor: 'var(--color-primary-control-fill-primary)'
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
58
|
var COMMENT_HIGHLIGHT_COLOR = 'var(--agentic-comment-highlight-color, rgba(21, 0, 255, 0.15))';
|
|
80
59
|
var genStyle = function(token) {
|
|
81
60
|
var _obj;
|
|
@@ -535,15 +514,6 @@ var genStyle = function(token) {
|
|
|
535
514
|
padding: '0',
|
|
536
515
|
height: '0',
|
|
537
516
|
margin: 'var(--margin-8x) 0'
|
|
538
|
-
},
|
|
539
|
-
// 打字机效果样式
|
|
540
|
-
'.ant-agentic-md-editor-content .typewriter:last-of-type > *:last-of-type span[data-slate-leaf]:last-of-type span[data-slate-string]': {
|
|
541
|
-
borderRight: '0.15em solid var(--color-primary-control-fill-primary)',
|
|
542
|
-
animationName: "".concat(typing.getName(), ", ").concat(blinkCaret.getName()),
|
|
543
|
-
animationDuration: '3.5s, 0.5s',
|
|
544
|
-
animationTimingFunction: 'steps(30, end), step-end',
|
|
545
|
-
animationIterationCount: '1, infinite',
|
|
546
|
-
animationFillMode: 'forwards, both'
|
|
547
517
|
}
|
|
548
518
|
}), _define_property(_obj, "".concat(token.componentCls, "-compact"), {
|
|
549
519
|
'div[data-be="paragraph"]': {
|
|
@@ -127,7 +127,12 @@ import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview,
|
|
|
127
127
|
// 选中状态管理
|
|
128
128
|
var _React_useState = _sliced_to_array(React.useState(false), 2), isSelected = _React_useState[0], setIsSelected = _React_useState[1];
|
|
129
129
|
// 视图模式状态管理(用于HTML和Markdown)
|
|
130
|
-
|
|
130
|
+
// 如果是 markdown 或 html,默认打开预览模式
|
|
131
|
+
var _useState2 = _sliced_to_array(useState(function() {
|
|
132
|
+
var _props_element_language, _props_element;
|
|
133
|
+
var language = (_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_language = _props_element.language) === null || _props_element_language === void 0 ? void 0 : _props_element_language.toLowerCase();
|
|
134
|
+
return language === 'html' || language === 'markdown' ? 'preview' : 'code';
|
|
135
|
+
}), 2), viewMode = _useState2[0], setViewMode = _useState2[1];
|
|
131
136
|
// 使用Ace编辑器Hook
|
|
132
137
|
var _AceEditor = AceEditor({
|
|
133
138
|
element: props.element,
|
|
@@ -22,11 +22,28 @@ export interface SchemaEditorProps {
|
|
|
22
22
|
ALLOWED_TAGS?: string[];
|
|
23
23
|
ALLOWED_ATTR?: string[];
|
|
24
24
|
};
|
|
25
|
+
/** 自定义操作按钮,插入到 HTML 编辑器头部按钮区域 */
|
|
26
|
+
htmlActions?: React.ReactNode[];
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
export interface SchemaEditorRef {
|
|
29
|
+
/** 设置 Schema 数据 */
|
|
30
|
+
setSchema: (schema: LowCodeSchema) => void;
|
|
31
|
+
/** 设置 HTML 模板内容 */
|
|
32
|
+
setHtmlContent: (html: string) => void;
|
|
33
|
+
/** 设置 Schema JSON 字符串 */
|
|
34
|
+
setSchemaString: (jsonString: string) => void;
|
|
35
|
+
/** 获取当前 Schema 数据 */
|
|
36
|
+
getSchema: () => LowCodeSchema;
|
|
37
|
+
/** 获取当前 HTML 模板内容 */
|
|
38
|
+
getHtmlContent: () => string;
|
|
39
|
+
/** 获取当前 Schema JSON 字符串 */
|
|
40
|
+
getSchemaString: () => string;
|
|
41
|
+
/** 运行预览 */
|
|
42
|
+
run: () => void;
|
|
43
|
+
/** 复制 HTML 内容 */
|
|
44
|
+
copyHtml: () => void;
|
|
45
|
+
/** 复制 JSON 内容 */
|
|
46
|
+
copyJson: () => void;
|
|
47
|
+
}
|
|
48
|
+
export declare const SchemaEditor: React.ForwardRefExoticComponent<SchemaEditorProps & React.RefAttributes<SchemaEditorRef>>;
|
|
32
49
|
export default SchemaEditor;
|
|
@@ -100,7 +100,7 @@ import { CircleDashed, Copy, Play } from "@sofa-design/icons";
|
|
|
100
100
|
import { Button, ConfigProvider, message } from "antd";
|
|
101
101
|
import classNames from "classnames";
|
|
102
102
|
import copy from "copy-to-clipboard";
|
|
103
|
-
import React, { useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
103
|
+
import React, { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useState } from "react";
|
|
104
104
|
import { I18nContext } from "../../I18n";
|
|
105
105
|
import { SchemaRenderer } from "../SchemaRenderer";
|
|
106
106
|
import { mdDataSchemaValidator } from "../validator";
|
|
@@ -110,8 +110,8 @@ import { useStyle } from "./style";
|
|
|
110
110
|
* Schema编辑器组件
|
|
111
111
|
*
|
|
112
112
|
* 提供schema的实时编辑和预览功能,底层使用AceEditor编辑schema中的HTML内容
|
|
113
|
-
*/
|
|
114
|
-
var initialSchema = param.initialSchema, _param_initialValues = param.initialValues, initialValues = _param_initialValues === void 0 ? {} : _param_initialValues, _param_height = param.height, height = _param_height === void 0 ? 600 : _param_height, _param_readonly = param.readonly, readonly = _param_readonly === void 0 ? false : _param_readonly, onChange = param.onChange, _param_className = param.className, className = _param_className === void 0 ? '' : _param_className, _param_showPreview = param.showPreview, showPreview = _param_showPreview === void 0 ? true : _param_showPreview, previewConfig = param.previewConfig;
|
|
113
|
+
*/ var SchemaEditorComponent = /*#__PURE__*/ forwardRef(function(param, ref) {
|
|
114
|
+
var initialSchema = param.initialSchema, _param_initialValues = param.initialValues, initialValues = _param_initialValues === void 0 ? {} : _param_initialValues, _param_height = param.height, height = _param_height === void 0 ? 600 : _param_height, _param_readonly = param.readonly, readonly = _param_readonly === void 0 ? false : _param_readonly, onChange = param.onChange, _param_className = param.className, className = _param_className === void 0 ? '' : _param_className, _param_showPreview = param.showPreview, showPreview = _param_showPreview === void 0 ? true : _param_showPreview, previewConfig = param.previewConfig, htmlActions = param.htmlActions;
|
|
115
115
|
// 使用 ConfigProvider 获取前缀类名
|
|
116
116
|
var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
|
|
117
117
|
var prefixCls = getPrefixCls('schema-editor');
|
|
@@ -134,6 +134,26 @@ import { useStyle } from "./style";
|
|
|
134
134
|
var _useState4 = _sliced_to_array(useState(''), 2), validationError = _useState4[0], setValidationError = _useState4[1];
|
|
135
135
|
var _useState5 = _sliced_to_array(useState({}), 2), renderedSchema = _useState5[0], setRenderedSchema = _useState5[1];
|
|
136
136
|
var _useState6 = _sliced_to_array(useState(false), 2), isSchemaRendered = _useState6[0], setIsSchemaRendered = _useState6[1];
|
|
137
|
+
// 使用 ref 存储最新值,确保 ref 方法能立即获取到最新状态
|
|
138
|
+
var schemaRef = React.useRef(schema);
|
|
139
|
+
var htmlContentRef = React.useRef(htmlContent);
|
|
140
|
+
var schemaStringRef = React.useRef(schemaString);
|
|
141
|
+
// 同步更新 ref 值
|
|
142
|
+
React.useEffect(function() {
|
|
143
|
+
schemaRef.current = schema;
|
|
144
|
+
}, [
|
|
145
|
+
schema
|
|
146
|
+
]);
|
|
147
|
+
React.useEffect(function() {
|
|
148
|
+
htmlContentRef.current = htmlContent;
|
|
149
|
+
}, [
|
|
150
|
+
htmlContent
|
|
151
|
+
]);
|
|
152
|
+
React.useEffect(function() {
|
|
153
|
+
schemaStringRef.current = schemaString;
|
|
154
|
+
}, [
|
|
155
|
+
schemaString
|
|
156
|
+
]);
|
|
137
157
|
// 将schema转换为JSON字符串
|
|
138
158
|
var schemaToJson = useCallback(function(schemaData) {
|
|
139
159
|
try {
|
|
@@ -159,8 +179,14 @@ import { useStyle } from "./style";
|
|
|
159
179
|
// 初始化schema字符串
|
|
160
180
|
useEffect(function() {
|
|
161
181
|
var _schema_component;
|
|
162
|
-
|
|
163
|
-
|
|
182
|
+
var jsonString = schemaToJson(schema);
|
|
183
|
+
var html = ((_schema_component = schema.component) === null || _schema_component === void 0 ? void 0 : _schema_component.schema) || '';
|
|
184
|
+
setSchemaString(jsonString);
|
|
185
|
+
setHtmlContent(html);
|
|
186
|
+
// 同步更新 ref 值
|
|
187
|
+
schemaRef.current = schema;
|
|
188
|
+
schemaStringRef.current = jsonString;
|
|
189
|
+
htmlContentRef.current = html;
|
|
164
190
|
}, [
|
|
165
191
|
schema,
|
|
166
192
|
schemaToJson
|
|
@@ -195,24 +221,27 @@ import { useStyle } from "./style";
|
|
|
195
221
|
// 处理HTML内容变更
|
|
196
222
|
var handleHtmlChange = useCallback(function(newHtml) {
|
|
197
223
|
setHtmlContent(newHtml);
|
|
198
|
-
|
|
199
|
-
|
|
224
|
+
htmlContentRef.current = newHtml;
|
|
225
|
+
var newSchema = _object_spread_props(_object_spread({}, schemaRef.current), {
|
|
226
|
+
component: _object_spread_props(_object_spread({}, schemaRef.current.component), {
|
|
200
227
|
schema: newHtml
|
|
201
228
|
})
|
|
202
229
|
});
|
|
203
230
|
handleSchemaChange(newSchema);
|
|
204
231
|
}, [
|
|
205
|
-
schema,
|
|
206
232
|
handleSchemaChange
|
|
207
233
|
]);
|
|
208
234
|
// 处理JSON编辑器变更
|
|
209
235
|
var handleJsonChange = useCallback(function(newJsonString) {
|
|
210
236
|
setSchemaString(newJsonString);
|
|
237
|
+
schemaStringRef.current = newJsonString;
|
|
211
238
|
var newSchema = jsonToSchema(newJsonString);
|
|
212
239
|
if (newSchema) {
|
|
213
240
|
var _newSchema_component;
|
|
241
|
+
var html = ((_newSchema_component = newSchema.component) === null || _newSchema_component === void 0 ? void 0 : _newSchema_component.schema) || '';
|
|
214
242
|
handleSchemaChange(newSchema);
|
|
215
|
-
setHtmlContent(
|
|
243
|
+
setHtmlContent(html);
|
|
244
|
+
htmlContentRef.current = html;
|
|
216
245
|
}
|
|
217
246
|
}, [
|
|
218
247
|
jsonToSchema,
|
|
@@ -220,18 +249,14 @@ import { useStyle } from "./style";
|
|
|
220
249
|
]);
|
|
221
250
|
// 处理运行按钮点击
|
|
222
251
|
var handleRunClick = useCallback(function() {
|
|
223
|
-
|
|
252
|
+
var currentSchema = schemaRef.current;
|
|
253
|
+
setRenderedSchema(_object_spread({}, currentSchema));
|
|
224
254
|
// 更新values状态,使用schema中的initialValues
|
|
225
|
-
if (
|
|
226
|
-
setValues(
|
|
255
|
+
if (currentSchema.initialValues) {
|
|
256
|
+
setValues(currentSchema.initialValues);
|
|
227
257
|
}
|
|
228
258
|
setIsSchemaRendered(true);
|
|
229
|
-
}, [
|
|
230
|
-
schema,
|
|
231
|
-
setRenderedSchema,
|
|
232
|
-
setValues,
|
|
233
|
-
setIsSchemaRendered
|
|
234
|
-
]);
|
|
259
|
+
}, []);
|
|
235
260
|
// 复制函数
|
|
236
261
|
var handleCopyContent = useCallback(function(content, type) {
|
|
237
262
|
if (!content || !content.trim()) {
|
|
@@ -266,6 +291,59 @@ import { useStyle } from "./style";
|
|
|
266
291
|
schemaString,
|
|
267
292
|
handleCopyContent
|
|
268
293
|
]);
|
|
294
|
+
// 暴露 ref 方法
|
|
295
|
+
useImperativeHandle(ref, function() {
|
|
296
|
+
return {
|
|
297
|
+
setSchema: function(newSchema) {
|
|
298
|
+
var _newSchema_component, _newSchema_component1;
|
|
299
|
+
handleSchemaChange(newSchema);
|
|
300
|
+
var newJsonString = schemaToJson(newSchema);
|
|
301
|
+
setSchemaString(newJsonString);
|
|
302
|
+
setHtmlContent(((_newSchema_component = newSchema.component) === null || _newSchema_component === void 0 ? void 0 : _newSchema_component.schema) || '');
|
|
303
|
+
// 立即更新 ref 值,确保 get 方法能立即获取到最新值
|
|
304
|
+
schemaRef.current = newSchema;
|
|
305
|
+
schemaStringRef.current = newJsonString;
|
|
306
|
+
htmlContentRef.current = ((_newSchema_component1 = newSchema.component) === null || _newSchema_component1 === void 0 ? void 0 : _newSchema_component1.schema) || '';
|
|
307
|
+
},
|
|
308
|
+
setHtmlContent: function(newHtml) {
|
|
309
|
+
handleHtmlChange(newHtml);
|
|
310
|
+
// 立即更新 ref 值
|
|
311
|
+
htmlContentRef.current = newHtml;
|
|
312
|
+
},
|
|
313
|
+
setSchemaString: function(newJsonString) {
|
|
314
|
+
handleJsonChange(newJsonString);
|
|
315
|
+
// 立即更新 ref 值
|
|
316
|
+
schemaStringRef.current = newJsonString;
|
|
317
|
+
var newSchema = jsonToSchema(newJsonString);
|
|
318
|
+
if (newSchema) {
|
|
319
|
+
var _newSchema_component;
|
|
320
|
+
schemaRef.current = newSchema;
|
|
321
|
+
htmlContentRef.current = ((_newSchema_component = newSchema.component) === null || _newSchema_component === void 0 ? void 0 : _newSchema_component.schema) || '';
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
getSchema: function() {
|
|
325
|
+
return schemaRef.current;
|
|
326
|
+
},
|
|
327
|
+
getHtmlContent: function() {
|
|
328
|
+
return htmlContentRef.current;
|
|
329
|
+
},
|
|
330
|
+
getSchemaString: function() {
|
|
331
|
+
return schemaStringRef.current;
|
|
332
|
+
},
|
|
333
|
+
run: handleRunClick,
|
|
334
|
+
copyHtml: handleCopyHtml,
|
|
335
|
+
copyJson: handleCopyJson
|
|
336
|
+
};
|
|
337
|
+
}, [
|
|
338
|
+
handleSchemaChange,
|
|
339
|
+
handleHtmlChange,
|
|
340
|
+
handleJsonChange,
|
|
341
|
+
handleRunClick,
|
|
342
|
+
handleCopyHtml,
|
|
343
|
+
handleCopyJson,
|
|
344
|
+
schemaToJson,
|
|
345
|
+
jsonToSchema
|
|
346
|
+
]);
|
|
269
347
|
// 渲染预览区域
|
|
270
348
|
var renderPreview = useMemo(function() {
|
|
271
349
|
if (!showPreview) return null;
|
|
@@ -331,7 +409,7 @@ import { useStyle } from "./style";
|
|
|
331
409
|
}
|
|
332
410
|
}),
|
|
333
411
|
onClick: handleCopyHtml
|
|
334
|
-
}))), /*#__PURE__*/ React.createElement("div", {
|
|
412
|
+
}), htmlActions)), /*#__PURE__*/ React.createElement("div", {
|
|
335
413
|
className: classNames("".concat(prefixCls, "-html-content"), hashId)
|
|
336
414
|
}, /*#__PURE__*/ React.createElement(AceEditorWrapper, {
|
|
337
415
|
value: htmlContent,
|
|
@@ -347,6 +425,7 @@ import { useStyle } from "./style";
|
|
|
347
425
|
locale,
|
|
348
426
|
handleRunClick,
|
|
349
427
|
handleCopyHtml,
|
|
428
|
+
htmlActions,
|
|
350
429
|
prefixCls
|
|
351
430
|
]);
|
|
352
431
|
// 渲染JSON编辑器
|
|
@@ -397,5 +476,7 @@ import { useStyle } from "./style";
|
|
|
397
476
|
}, renderPreview), /*#__PURE__*/ React.createElement("div", {
|
|
398
477
|
className: classNames("".concat(prefixCls, "-right"), hashId)
|
|
399
478
|
}, renderHtmlEditor, renderJsonEditor))));
|
|
400
|
-
}
|
|
479
|
+
});
|
|
480
|
+
SchemaEditorComponent.displayName = 'SchemaEditor';
|
|
481
|
+
export var SchemaEditor = SchemaEditorComponent;
|
|
401
482
|
export default SchemaEditor;
|
package/package.json
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/* The typing effect */
|
|
2
|
-
@keyframes typing {
|
|
3
|
-
from {
|
|
4
|
-
width: 0;
|
|
5
|
-
}
|
|
6
|
-
to {
|
|
7
|
-
width: 100%;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/* The typewriter cursor effect */
|
|
12
|
-
@keyframes blink-caret {
|
|
13
|
-
from,
|
|
14
|
-
to {
|
|
15
|
-
border-color: transparent;
|
|
16
|
-
}
|
|
17
|
-
50% {
|
|
18
|
-
border-color: #1677ff;
|
|
19
|
-
}
|
|
20
|
-
}
|