@huanban/rulego-editor-react 1.3.17 → 1.4.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/README.md +304 -10
- package/dist/components/AIAssistant.d.ts +1 -7
- package/dist/components/ComponentSidebar.d.ts +13 -52
- package/dist/components/ContextMenu.d.ts +1 -59
- package/dist/components/CopilotChat.d.ts +27 -22
- package/dist/components/DataViewDialog.d.ts +0 -33
- package/dist/components/DebugPanel.d.ts +5 -65
- package/dist/components/DynamicForm.d.ts +0 -40
- package/dist/components/EdgePropertyDrawer.d.ts +0 -35
- package/dist/components/EditorConnectionStatus.d.ts +12 -0
- package/dist/components/EditorEdgeHoverTools.d.ts +11 -0
- package/dist/components/EditorIcon.d.ts +7 -0
- package/dist/components/EditorNodeHoverTools.d.ts +16 -0
- package/dist/components/EditorPanelDock.d.ts +18 -0
- package/dist/components/EditorStatusBar.d.ts +34 -0
- package/dist/components/EditorToolbar.d.ts +2 -62
- package/dist/components/ImportExportDialog.d.ts +1 -37
- package/dist/components/LogViewer.d.ts +0 -29
- package/dist/components/MiniMap.d.ts +0 -46
- package/dist/components/NodePropertyDrawer.d.ts +19 -102
- package/dist/components/ProblemsPanel.d.ts +21 -0
- package/dist/components/RuleChainSettings.d.ts +0 -45
- package/dist/components/RuleGoEditor.d.ts +37 -147
- package/dist/components/RuleMaintenancePanel.d.ts +0 -1
- package/dist/components/SearchPanel.d.ts +0 -39
- package/dist/components/SearchableSelect.d.ts +0 -1
- package/dist/components/ValidationPanel.d.ts +0 -39
- package/dist/components/WorkflowExplorer.d.ts +24 -0
- package/dist/components/WorkflowInfoPanel.d.ts +1 -36
- package/dist/components/WorkflowList.d.ts +2 -69
- package/dist/components/WorkspaceTabs.d.ts +17 -0
- package/dist/components/properties/AgentOrchestrationProperties.d.ts +2 -1
- package/dist/hooks/useBoundStore.d.ts +8 -0
- package/dist/hooks/useClipboard.d.ts +2 -63
- package/dist/hooks/useEditorCore.d.ts +0 -79
- package/dist/hooks/useEditorI18n.d.ts +0 -26
- package/dist/hooks/useEditorPanels.d.ts +23 -0
- package/dist/hooks/useEditorShell.d.ts +35 -0
- package/dist/hooks/useEditorTheme.d.ts +0 -30
- package/dist/hooks/useEditorWorkspace.d.ts +25 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts +4 -44
- package/dist/i18n.d.ts +6 -4
- package/dist/index.cjs +17 -0
- package/dist/index.d.ts +28 -62
- package/dist/index.esm.js +6218 -104179
- package/dist/style.css +1 -1
- package/package.json +13 -8
- package/dist/index.cjs.js +0 -9338
|
@@ -1,83 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file components/MiniMap.tsx
|
|
3
|
-
* @description 小地图导航组件 — React 实现
|
|
4
|
-
*
|
|
5
|
-
* 功能:
|
|
6
|
-
* - 显示画布全局缩略视图
|
|
7
|
-
* - 标记所有节点位置(按类型着色)
|
|
8
|
-
* - 标记当前视口范围(拖拽移动)
|
|
9
|
-
* - 标记选中节点(高亮)
|
|
10
|
-
* - 可折叠/展开
|
|
11
|
-
* - 零 UI 框架依赖(纯 React + CSS)
|
|
12
|
-
*
|
|
13
|
-
* @see MiniMapProps — 参数类型
|
|
14
|
-
*/
|
|
15
1
|
import React from 'react';
|
|
16
2
|
import type { LocaleMessages } from '@huanban/rulego-editor-core';
|
|
17
3
|
import type { EditorTranslate } from '../i18n';
|
|
18
|
-
/** 小地图中的节点数据 */
|
|
19
4
|
export interface MiniMapNode {
|
|
20
|
-
/** 节点 ID */
|
|
21
5
|
id: string;
|
|
22
|
-
/** X 坐标 */
|
|
23
6
|
x: number;
|
|
24
|
-
/** Y 坐标 */
|
|
25
7
|
y: number;
|
|
26
|
-
/** 宽度 */
|
|
27
8
|
width?: number;
|
|
28
|
-
/** 高度 */
|
|
29
9
|
height?: number;
|
|
30
|
-
/** 节点类型 */
|
|
31
10
|
type?: string;
|
|
32
|
-
/** 是否选中 */
|
|
33
11
|
selected?: boolean;
|
|
34
|
-
/** 显示颜色 */
|
|
35
12
|
color?: string;
|
|
36
13
|
}
|
|
37
|
-
/** 小地图中的视口数据 */
|
|
38
14
|
export interface MiniMapViewport {
|
|
39
|
-
/** 视口左上角 X */
|
|
40
15
|
x: number;
|
|
41
|
-
/** 视口左上角 Y */
|
|
42
16
|
y: number;
|
|
43
|
-
/** 视口宽度 */
|
|
44
17
|
width: number;
|
|
45
|
-
/** 视口高度 */
|
|
46
18
|
height: number;
|
|
47
19
|
}
|
|
48
|
-
/** MiniMap Props */
|
|
49
20
|
export interface MiniMapProps {
|
|
50
|
-
/** 所有节点列表 */
|
|
51
21
|
nodes: MiniMapNode[];
|
|
52
|
-
/** 当前视口范围 */
|
|
53
22
|
viewport?: MiniMapViewport;
|
|
54
|
-
/** 小地图宽度(默认 200) */
|
|
55
23
|
width?: number;
|
|
56
|
-
/** 小地图高度(默认 150) */
|
|
57
24
|
height?: number;
|
|
58
|
-
/** 是否默认折叠 */
|
|
59
25
|
defaultCollapsed?: boolean;
|
|
60
|
-
/** 位置(右下角/左下角/右上角/左上角) */
|
|
61
26
|
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
62
|
-
/** 视口拖拽回调 — 返回画布坐标 */
|
|
63
27
|
onViewportChange?: (center: {
|
|
64
28
|
x: number;
|
|
65
29
|
y: number;
|
|
66
30
|
}) => void;
|
|
67
|
-
/** 节点点击回调 */
|
|
68
31
|
onNodeClick?: (nodeId: string) => void;
|
|
69
|
-
/** Current locale. Defaults to zh-CN. */
|
|
70
32
|
locale?: string;
|
|
71
|
-
/** Extra locale messages merged into the selected locale. */
|
|
72
33
|
messages?: LocaleMessages;
|
|
73
|
-
/** Host-provided translation function. */
|
|
74
34
|
t?: EditorTranslate;
|
|
75
35
|
}
|
|
76
|
-
/**
|
|
77
|
-
* MiniMap 组件
|
|
78
|
-
*
|
|
79
|
-
* 显示画布全局缩略图,方便大型规则链的导航。
|
|
80
|
-
*/
|
|
81
36
|
declare const MiniMap: React.FC<MiniMapProps>;
|
|
82
37
|
export default MiniMap;
|
|
83
|
-
//# sourceMappingURL=MiniMap.d.ts.map
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file components/NodePropertyDrawer.tsx
|
|
3
|
-
* @description 节点属性编辑抽屉 — React 实现
|
|
4
|
-
*
|
|
5
|
-
* 功能:
|
|
6
|
-
* - 双击节点弹出侧边抽屉,编辑节点配置
|
|
7
|
-
* - 根据组件 fields 定义动态渲染表单(string/bool/int/float/map/array/script)
|
|
8
|
-
* - 支持节点 ID、名称、调试模式、描述等基础字段
|
|
9
|
-
* - 提交后通过 onSubmit 回调更新节点属性
|
|
10
|
-
* - 零 UI 框架依赖(纯 React + CSS)
|
|
11
|
-
*
|
|
12
|
-
* @see ComponentField — 字段定义类型
|
|
13
|
-
*/
|
|
14
1
|
import React from 'react';
|
|
15
|
-
import
|
|
2
|
+
import { OptionSourceRegistry, FieldChangeRegistry } from '@huanban/rulego-editor-core';
|
|
3
|
+
import type { AiProviderOption, ComponentDefinition, ComponentField, LocaleMessages } from '@huanban/rulego-editor-core';
|
|
16
4
|
import type { EditorTranslate } from '../i18n';
|
|
17
5
|
export type FieldOption = string | {
|
|
18
6
|
label?: string;
|
|
19
|
-
value?:
|
|
7
|
+
value?: unknown;
|
|
20
8
|
name?: string;
|
|
21
9
|
id?: string;
|
|
22
10
|
[key: string]: unknown;
|
|
@@ -63,137 +51,66 @@ export interface RuleChainFetchResult {
|
|
|
63
51
|
data?: unknown;
|
|
64
52
|
[key: string]: unknown;
|
|
65
53
|
}
|
|
66
|
-
|
|
67
|
-
export interface FieldDef {
|
|
68
|
-
/** 字段名 */
|
|
69
|
-
name: string;
|
|
70
|
-
/** 字段类型 */
|
|
71
|
-
type?: string;
|
|
72
|
-
/** 显示标签 */
|
|
73
|
-
label?: string;
|
|
74
|
-
/** 字段描述 */
|
|
75
|
-
desc?: string;
|
|
76
|
-
/** 默认值 */
|
|
77
|
-
defaultValue?: unknown;
|
|
78
|
-
/** component 协议 */
|
|
79
|
-
component?: {
|
|
80
|
-
type?: string;
|
|
81
|
-
caseType?: string;
|
|
82
|
-
source?: string;
|
|
83
|
-
options?: FieldOption[];
|
|
84
|
-
multiple?: boolean;
|
|
85
|
-
filterable?: boolean;
|
|
86
|
-
allowCreate?: boolean;
|
|
87
|
-
placeholder?: string;
|
|
88
|
-
disabled?: boolean;
|
|
89
|
-
rows?: number;
|
|
90
|
-
};
|
|
91
|
-
/** 兼容旧字段选项协议 */
|
|
92
|
-
options?: FieldOption[];
|
|
93
|
-
/** 嵌套字段定义,struct/table/switch 类字段会使用 */
|
|
94
|
-
fields?: FieldDef[];
|
|
95
|
-
/** ref 协议:primary/shared 字段会随连接模式联动隐藏 */
|
|
96
|
-
ref?: string;
|
|
97
|
-
/** providerType 协议:embedding 字段使用 embedding provider 预设 */
|
|
98
|
-
providerType?: string;
|
|
99
|
-
/** 是否禁用 */
|
|
100
|
-
disabled?: boolean;
|
|
101
|
-
/** 校验规则 */
|
|
102
|
-
rules?: unknown[];
|
|
103
|
-
}
|
|
104
|
-
/** 节点模型数据 */
|
|
54
|
+
export type FieldDef = ComponentField;
|
|
105
55
|
export interface NodeModel {
|
|
106
|
-
/** LogicFlow 节点 ID */
|
|
107
56
|
id: string;
|
|
108
|
-
/** RuleGo 节点 ID */
|
|
109
57
|
nodeId?: string;
|
|
110
|
-
/** 节点类型 */
|
|
111
58
|
type: string;
|
|
112
|
-
/** 节点名称 */
|
|
113
59
|
name: string;
|
|
114
|
-
/** 调试模式 */
|
|
115
60
|
debugMode?: boolean;
|
|
116
|
-
/** 节点配置 */
|
|
117
61
|
configuration?: Record<string, unknown>;
|
|
118
|
-
/** 附加信息(描述等) */
|
|
119
62
|
additionalInfo?: Record<string, unknown>;
|
|
120
|
-
/** 额外属性 */
|
|
121
63
|
[key: string]: unknown;
|
|
122
64
|
}
|
|
123
|
-
/** 节点视图定义(组件定义) */
|
|
124
65
|
export interface NodeView {
|
|
125
|
-
/** 组件类型 */
|
|
126
66
|
type: string;
|
|
127
|
-
/** 显示标签 */
|
|
128
67
|
label?: string;
|
|
129
|
-
/** 描述 */
|
|
130
68
|
desc?: string;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
69
|
+
fields?: FieldDef[] | null;
|
|
70
|
+
dynamicFields?: ComponentDefinition['dynamicFields'];
|
|
71
|
+
capabilities?: ComponentDefinition['capabilities'];
|
|
72
|
+
groups?: ComponentDefinition['groups'];
|
|
134
73
|
[key: string]: unknown;
|
|
135
74
|
}
|
|
136
|
-
/** NodePropertyDrawer Props */
|
|
137
75
|
export interface NodePropertyDrawerProps {
|
|
138
|
-
/** 是否显示 */
|
|
139
76
|
visible: boolean;
|
|
140
|
-
/** 节点模型数据 */
|
|
141
77
|
nodeModel: NodeModel | null;
|
|
142
|
-
/** 节点视图/组件定义 */
|
|
143
78
|
nodeView: NodeView | null;
|
|
144
|
-
|
|
145
|
-
onSubmit: (model: NodeModel) => void;
|
|
146
|
-
/** 关闭回调 */
|
|
79
|
+
onSubmit: (model: NodeModel) => void | Promise<void>;
|
|
147
80
|
onClose: () => void;
|
|
148
|
-
/** Current locale. Defaults to zh-CN. */
|
|
149
81
|
locale?: string;
|
|
150
|
-
/** Extra locale messages merged into the selected locale. */
|
|
151
82
|
messages?: LocaleMessages;
|
|
152
|
-
/** Host-provided translation function. */
|
|
153
83
|
t?: EditorTranslate;
|
|
154
|
-
/** Current graph nodes for component.source=nodes hydration. */
|
|
155
84
|
graphNodes?: GraphNodeOptionSource[];
|
|
156
|
-
/** Rule chain list for component.source=ruleChains hydration. */
|
|
157
85
|
ruleItems?: RuleChainOptionSource[];
|
|
158
|
-
/** Current rule chain used to avoid selecting itself in rule-chain fields. */
|
|
159
86
|
currentRuleChain?: RuleChainOptionSource | null;
|
|
160
|
-
/** Explicit /rules endpoint. If omitted, apiBase + /rules is used. */
|
|
161
87
|
rulesApi?: string;
|
|
162
|
-
/** API base ending at /api/v1 for remote rule-chain selector loading. */
|
|
163
88
|
apiBase?: string;
|
|
164
|
-
/** Page size for rule-chain selector modal. Defaults to 12. */
|
|
165
89
|
rulePageSize?: number;
|
|
166
|
-
/** Host override for remote rule-chain selector loading. */
|
|
167
90
|
fetchRuleChains?: (params: RuleChainFetchParams) => Promise<RuleChainFetchResult | RuleChainOptionSource[] | unknown>;
|
|
168
|
-
/** Components API payload, used for builtins["ai/tools"].tools and skillPath parity. */
|
|
169
91
|
componentsPayload?: Record<string, unknown>;
|
|
170
|
-
/** Legacy alias for componentsPayload. */
|
|
171
92
|
componentPayload?: Record<string, unknown>;
|
|
172
|
-
/** Host-provided builtin AI tools. Accepts the original /components builtins["ai/tools"].tools rows. */
|
|
173
93
|
builtinTools?: unknown[];
|
|
174
|
-
/** Official editorOptions.tools alias. */
|
|
175
94
|
tools?: unknown[];
|
|
176
|
-
/** Global skill directory returned by /components. */
|
|
177
95
|
skillPath?: string;
|
|
178
|
-
/** Host override for loading /components payload or builtin tools. */
|
|
179
96
|
fetchBuiltinTools?: (params: {
|
|
180
97
|
signal?: AbortSignal;
|
|
181
98
|
}) => Promise<unknown>;
|
|
182
|
-
/** Open the AI assistant or skill manager from a builtin skill tool helper. */
|
|
183
99
|
onOpenAiAssistant?: (options: {
|
|
184
100
|
section?: string;
|
|
185
101
|
}) => void;
|
|
186
|
-
/** AI provider presets, aligned with editorOptions.aiProviders. */
|
|
187
102
|
aiProviders?: AiProviderOption[];
|
|
188
|
-
/** Embedding provider presets, aligned with editorOptions.aiEmbeddingProviders. */
|
|
189
103
|
aiEmbeddingProviders?: AiProviderOption[];
|
|
104
|
+
resolveFieldsByType?: (type: string) => ComponentField[] | undefined;
|
|
105
|
+
optionSourceRegistry?: OptionSourceRegistry;
|
|
106
|
+
fieldChangeRegistry?: FieldChangeRegistry;
|
|
107
|
+
onFieldChangeError?: (error: unknown, context: {
|
|
108
|
+
field: ComponentField;
|
|
109
|
+
fieldPath: string;
|
|
110
|
+
handlerName: string;
|
|
111
|
+
generation: number;
|
|
112
|
+
}) => void;
|
|
113
|
+
initializeDefaults?: boolean;
|
|
190
114
|
}
|
|
191
|
-
/**
|
|
192
|
-
* NodePropertyDrawer 组件
|
|
193
|
-
*
|
|
194
|
-
* 纯 React 实现的节点属性编辑抽屉,无 antd 依赖。
|
|
195
|
-
* 根据组件 fields 动态渲染表单,支持多种字段类型。
|
|
196
|
-
*/
|
|
197
115
|
declare const NodePropertyDrawer: React.FC<NodePropertyDrawerProps>;
|
|
198
116
|
export default NodePropertyDrawer;
|
|
199
|
-
//# sourceMappingURL=NodePropertyDrawer.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DiagnosticItem, LocaleMessages } from '@huanban/rulego-editor-core';
|
|
3
|
+
import type { EditorTranslate } from '../i18n';
|
|
4
|
+
export interface ProblemsPanelProps {
|
|
5
|
+
items: readonly DiagnosticItem[];
|
|
6
|
+
visible?: boolean;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
title?: string;
|
|
9
|
+
onValidate?: () => void;
|
|
10
|
+
onLocate?: (item: DiagnosticItem) => void;
|
|
11
|
+
onClear?: () => void;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
locale?: string;
|
|
14
|
+
messages?: LocaleMessages;
|
|
15
|
+
t?: EditorTranslate;
|
|
16
|
+
}
|
|
17
|
+
export declare function ProblemsPanel({ items, visible, loading, title, onValidate, onLocate, onClear, onClose, locale, messages, t, }: ProblemsPanelProps): React.JSX.Element | null;
|
|
18
|
+
export declare namespace ProblemsPanel {
|
|
19
|
+
var displayName: string;
|
|
20
|
+
}
|
|
21
|
+
export default ProblemsPanel;
|
|
@@ -1,82 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file components/RuleChainSettings.tsx
|
|
3
|
-
* @description 规则链设置对话框 — React 实现
|
|
4
|
-
*
|
|
5
|
-
* 功能:
|
|
6
|
-
* - 编辑规则链元数据(名称/描述/调试模式等)
|
|
7
|
-
* - 管理规则链全局配置
|
|
8
|
-
* - 模态对话框展示
|
|
9
|
-
* - 表单验证
|
|
10
|
-
* - 零 UI 框架依赖(纯 React + CSS)
|
|
11
|
-
*
|
|
12
|
-
* @see RuleChainSettingsProps — 设置参数
|
|
13
|
-
*/
|
|
14
1
|
import React from 'react';
|
|
15
2
|
import type { LocaleMessages } from '@huanban/rulego-editor-core';
|
|
16
3
|
import type { EditorTranslate } from '../i18n';
|
|
17
|
-
/** 规则链设置数据 */
|
|
18
4
|
export interface RuleChainSettingsData {
|
|
19
|
-
/** 规则链 ID */
|
|
20
5
|
id?: string;
|
|
21
|
-
/** 规则链名称 */
|
|
22
6
|
name: string;
|
|
23
|
-
/** 是否为根链 */
|
|
24
7
|
root?: boolean;
|
|
25
|
-
/** 是否开启调试模式 */
|
|
26
8
|
debugMode?: boolean;
|
|
27
|
-
/** 描述 */
|
|
28
9
|
description?: string;
|
|
29
|
-
/** 额外配置(JSON) */
|
|
30
10
|
additionalInfo?: Record<string, unknown>;
|
|
31
|
-
/** 自定义字段 */
|
|
32
11
|
[key: string]: unknown;
|
|
33
12
|
}
|
|
34
|
-
/** RuleChainSettings Props */
|
|
35
13
|
export interface RuleChainSettingsProps {
|
|
36
|
-
/** 是否可见 */
|
|
37
14
|
visible: boolean;
|
|
38
|
-
/** 当前设置数据 */
|
|
39
15
|
data: RuleChainSettingsData;
|
|
40
|
-
/** 是否只读 */
|
|
41
16
|
readOnly?: boolean;
|
|
42
|
-
/** 对话框标题 */
|
|
43
17
|
title?: string;
|
|
44
|
-
/** 额外的自定义字段定义 */
|
|
45
18
|
customFields?: Array<{
|
|
46
|
-
/** 字段名 */
|
|
47
19
|
key: string;
|
|
48
|
-
/** 显示名称 */
|
|
49
20
|
label: string;
|
|
50
|
-
/** 字段类型 */
|
|
51
21
|
type: 'text' | 'number' | 'select' | 'textarea' | 'switch';
|
|
52
|
-
/** select 的选项 */
|
|
53
22
|
options?: Array<{
|
|
54
23
|
label: string;
|
|
55
24
|
value: string;
|
|
56
25
|
}>;
|
|
57
|
-
/** 默认值 */
|
|
58
26
|
defaultValue?: unknown;
|
|
59
|
-
/** 提示 */
|
|
60
27
|
placeholder?: string;
|
|
61
|
-
/** 帮助文本 */
|
|
62
28
|
help?: string;
|
|
63
29
|
}>;
|
|
64
|
-
/** 保存回调 */
|
|
65
30
|
onSave?: (data: RuleChainSettingsData) => void;
|
|
66
|
-
/** 取消 / 关闭 */
|
|
67
31
|
onClose: () => void;
|
|
68
|
-
/** Current locale. Defaults to zh-CN. */
|
|
69
32
|
locale?: string;
|
|
70
|
-
/** Extra locale messages merged into the selected locale. */
|
|
71
33
|
messages?: LocaleMessages;
|
|
72
|
-
/** Host-provided translation function. */
|
|
73
34
|
t?: EditorTranslate;
|
|
74
35
|
}
|
|
75
|
-
/**
|
|
76
|
-
* RuleChainSettings 组件
|
|
77
|
-
*
|
|
78
|
-
* 模态对话框形式的规则链设置面板。
|
|
79
|
-
*/
|
|
80
36
|
declare const RuleChainSettings: React.FC<RuleChainSettingsProps>;
|
|
81
37
|
export default RuleChainSettings;
|
|
82
|
-
//# sourceMappingURL=RuleChainSettings.d.ts.map
|
|
@@ -1,170 +1,82 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file components/RuleGoEditor.tsx
|
|
3
|
-
* @description React 薄封装 — 直接复用 @huanban/rulego-editor-core 的 HuanbanRulegoEditor
|
|
4
|
-
*
|
|
5
|
-
* 设计理念:
|
|
6
|
-
* - 所有编辑器核心逻辑(工具栏、侧边栏、组件列表、上下文菜单、属性面板、
|
|
7
|
-
* 小地图、键盘快捷键等)全部在 editor-core 的 HuanbanRulegoEditor 中实现
|
|
8
|
-
* - React 版只负责: 挂载 DOM → 创建实例 → 代理 Props → 卸载时销毁
|
|
9
|
-
* - 这样 React / Vue / Angular 的封装都只需 ~100 行, 功能自动与 JS 版对齐
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```tsx
|
|
13
|
-
* import { RuleGoEditor } from '@huanban/rulego-editor-react'
|
|
14
|
-
*
|
|
15
|
-
* function App() {
|
|
16
|
-
* return (
|
|
17
|
-
* <RuleGoEditor
|
|
18
|
-
* apiBase="http://127.0.0.1:9090/api/v1"
|
|
19
|
-
* data={ruleChainData}
|
|
20
|
-
* components={componentsList}
|
|
21
|
-
* onSave={(data) => console.log('保存', data)}
|
|
22
|
-
* onReady={({ lf, core }) => console.log('就绪')}
|
|
23
|
-
* />
|
|
24
|
-
* )
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @see HuanbanRulegoEditor — 核心引擎 (editor-core)
|
|
29
|
-
*/
|
|
30
1
|
import React from 'react';
|
|
31
2
|
import { HuanbanRulegoEditor } from '@huanban/rulego-editor-core';
|
|
32
|
-
import type { AIAssistantOpenOptions, HuanbanRulegoEditorOptions } from '@huanban/rulego-editor-core';
|
|
3
|
+
import type { AIAssistantOpenOptions, ComponentManageDialogTab, EditorOptionsUpdateResult, EditorActionSource, EditorSaveHandler, EditorSaveMode, EditorSaveResult, ExternalDataUpdatePolicy, EditorMode, EditorCapabilitiesOverride, ConnectionStatusState, HuanbanRulegoEditorOptions, HuanbanRulegoEditorLoadOptions, NodePickerOpenOptions } from '@huanban/rulego-editor-core';
|
|
33
4
|
import type { EditorCore } from '@huanban/rulego-editor-core';
|
|
34
5
|
import type { RuleChainData, RawComponentData } from '@huanban/rulego-editor-core';
|
|
35
6
|
import LogicFlow from '@logicflow/core';
|
|
36
|
-
/**
|
|
37
|
-
* RuleGoEditor 组件 Props
|
|
38
|
-
*
|
|
39
|
-
* 大部分选项直接透传给 HuanbanRulegoEditor (editor-core)
|
|
40
|
-
* React 特有的只有: className, style, width, height, ref
|
|
41
|
-
*/
|
|
42
7
|
export interface RuleGoEditorProps {
|
|
43
|
-
/** 容器高度, 默认 '100%' */
|
|
44
8
|
height?: string | number;
|
|
45
|
-
/** 容器宽度, 默认 '100%' */
|
|
46
9
|
width?: string | number;
|
|
47
|
-
/** className */
|
|
48
10
|
className?: string;
|
|
49
|
-
/** style */
|
|
50
11
|
style?: React.CSSProperties;
|
|
51
|
-
/** API 基础地址 (如 'http://127.0.0.1:9090/api/v1') */
|
|
52
12
|
apiBase?: string;
|
|
53
|
-
/** 请求超时毫秒数, 默认 5000 */
|
|
54
13
|
fetchTimeout?: number;
|
|
55
|
-
/**
|
|
56
|
-
* 自定义请求头 — 用于注入 Authorization Token 等认证信息
|
|
57
|
-
* 支持静态对象或动态函数(每次请求时调用获取最新 Token)
|
|
58
|
-
*/
|
|
59
14
|
fetchHeaders?: Record<string, string> | (() => Record<string, string>);
|
|
60
|
-
|
|
61
|
-
* 自定义 fetch 函数 — 完全替换原生 fetch
|
|
62
|
-
* 当需要自定义请求逻辑(如统一认证拦截、请求签名、错误重试等)时使用
|
|
63
|
-
* 函数签名: (url: string, init: RequestInit) => Promise<Response>
|
|
64
|
-
*/
|
|
15
|
+
apiCacheKey?: string;
|
|
65
16
|
customFetch?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
66
|
-
/** 初始规则链数据 */
|
|
67
17
|
data?: RuleChainData | null;
|
|
68
|
-
|
|
18
|
+
dataUpdatePolicy?: ExternalDataUpdatePolicy;
|
|
69
19
|
components?: RawComponentData;
|
|
70
|
-
|
|
20
|
+
enableConnectionStatus?: boolean;
|
|
21
|
+
onConnectionStatusChange?: (state: Readonly<ConnectionStatusState>) => void;
|
|
71
22
|
showToolbar?: boolean;
|
|
72
|
-
|
|
23
|
+
mode?: EditorMode;
|
|
24
|
+
capabilities?: EditorCapabilitiesOverride;
|
|
25
|
+
disabled?: boolean;
|
|
73
26
|
toolbarTitle?: string;
|
|
74
|
-
/** 是否显示工具栏按钮文字,默认 false;设为 true 时显示图标 + 文字 */
|
|
75
27
|
showToolbarButtonLabels?: boolean;
|
|
76
|
-
/** 工具栏是否只显示图标,默认 true;显式 false 时可显示文字 */
|
|
77
28
|
toolbarIconOnly?: boolean;
|
|
78
|
-
/** 是否显示侧边栏, 默认 true */
|
|
79
29
|
showSidebar?: boolean;
|
|
80
|
-
/** 侧边栏宽度, 默认 220 */
|
|
81
30
|
sidebarWidth?: number;
|
|
82
|
-
/** 侧边栏是否默认收起 */
|
|
83
31
|
sidebarCollapsed?: boolean;
|
|
84
|
-
/** 是否显示信息按钮 */
|
|
85
32
|
showInfoButton?: boolean;
|
|
86
|
-
/** 是否显示 AI 助手按钮 */
|
|
87
33
|
showAiChatButton?: boolean;
|
|
88
|
-
/** 是否显示设置按钮 */
|
|
89
34
|
showSettingsButton?: boolean;
|
|
90
|
-
/** 是否显示调试面板按钮 */
|
|
91
35
|
showDebugConsoleButton?: boolean;
|
|
92
|
-
|
|
36
|
+
showDiagnosticsButton?: boolean;
|
|
93
37
|
showClearDebugHighlightButton?: boolean;
|
|
94
|
-
/** 是否显示框选按钮 */
|
|
95
38
|
showSelectionButton?: boolean;
|
|
96
|
-
/** 是否显示导出按钮, 默认 true */
|
|
97
39
|
showExportDialog?: boolean;
|
|
98
|
-
/** 是否显示运行按钮 */
|
|
99
40
|
showRunButton?: boolean;
|
|
100
|
-
/** 是否显示组件管理按钮 */
|
|
101
41
|
showComponentManage?: boolean;
|
|
102
|
-
/** 是否显示部署按钮, 默认 true */
|
|
103
42
|
showDeployButton?: boolean;
|
|
104
|
-
|
|
43
|
+
showRestartButton?: boolean;
|
|
105
44
|
showReloadButton?: boolean;
|
|
106
|
-
/** 是否显示运行记录按钮 */
|
|
107
45
|
showRunHistory?: boolean;
|
|
108
|
-
/** 运行记录 URL (支持 {chainId} 占位符) */
|
|
109
46
|
runHistoryUrl?: string;
|
|
110
|
-
/** 是否在工具栏显示「链追溯」按钮, 默认 false */
|
|
111
47
|
showTraceButton?: boolean;
|
|
112
|
-
/** 是否显示调试日志 Tab */
|
|
113
48
|
showDebugTab?: boolean;
|
|
114
|
-
/** 语言设置, 默认 'zh_cn' */
|
|
115
49
|
locale?: string;
|
|
116
|
-
/** 初始/受控主题;支持 default/dark/nature/elegant/tech/modern,兼容 light/blue */
|
|
117
50
|
theme?: string;
|
|
118
|
-
/** LogicFlow 额外配置 (与默认配置合并) */
|
|
119
51
|
lfOptions?: Record<string, unknown>;
|
|
120
|
-
/** LogicFlow 插件数组 */
|
|
121
52
|
lfPlugins?: any[];
|
|
122
|
-
/** EditorCore 额外配置 */
|
|
123
53
|
coreOptions?: Record<string, unknown>;
|
|
124
|
-
/** 直接透传给 HuanbanRulegoEditor 的扩展配置,显式 props 会覆盖这里的同名字段 */
|
|
125
54
|
options?: Partial<HuanbanRulegoEditorOptions>;
|
|
126
|
-
/** 编辑器就绪 */
|
|
127
55
|
onReady?: (ctx: {
|
|
128
56
|
lf: LogicFlow;
|
|
129
57
|
core: EditorCore;
|
|
130
58
|
}) => void;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
success?: boolean;
|
|
138
|
-
msg?: string;
|
|
139
|
-
message?: string;
|
|
140
|
-
}>;
|
|
141
|
-
/** 节点点击 */
|
|
59
|
+
onSave?: (data: RuleChainData) => void;
|
|
60
|
+
saveMode?: EditorSaveMode;
|
|
61
|
+
saveHandler?: EditorSaveHandler;
|
|
62
|
+
onSaveSuccess?: (result: EditorSaveResult) => void;
|
|
63
|
+
onSaveError?: (result: EditorSaveResult) => void;
|
|
64
|
+
onExternalDataConflict?: HuanbanRulegoEditorOptions['onExternalDataConflict'];
|
|
142
65
|
onNodeClick?: (data: unknown) => void;
|
|
143
|
-
/** 节点双击 */
|
|
144
66
|
onNodeDbClick?: (data: unknown) => void;
|
|
145
|
-
/** 边点击 */
|
|
146
67
|
onEdgeClick?: (data: unknown) => void;
|
|
147
|
-
/** 数据变化 */
|
|
148
68
|
onChange?: () => void;
|
|
149
|
-
/** 点击信息按钮 */
|
|
150
69
|
onInfoClick?: (chainInfo: any) => void;
|
|
151
|
-
/** 劫持导出 */
|
|
152
70
|
onExportDSL?: (data: {
|
|
153
71
|
json: string;
|
|
154
72
|
imageDataUrl?: string;
|
|
155
73
|
}) => void;
|
|
156
|
-
/** 劫持导入;不设则 core 内置导入会直接 loadData */
|
|
157
74
|
onImportDSL?: (data: RuleChainData) => void;
|
|
158
|
-
/** 劫持运行 */
|
|
159
75
|
onRunClick?: (chainId: string) => void;
|
|
160
|
-
/** 点击「链追溯」按钮回调,回传当前完整的规则链数据 (用于构建追溯底图) */
|
|
161
76
|
onTraceClick?: (chainInfo: any) => void;
|
|
162
|
-
|
|
163
|
-
onComponentManage?: () => void;
|
|
164
|
-
/** 语言切换回调 */
|
|
77
|
+
onComponentManage?: (initialTab?: ComponentManageDialogTab) => void;
|
|
165
78
|
onLocaleChange?: (locale: string) => void;
|
|
166
|
-
|
|
167
|
-
onDeploy?: (chainId: string, action: 'start' | 'stop' | 'reload') => void | boolean | {
|
|
79
|
+
onDeploy?: (chainId: string, action: 'start' | 'stop') => void | boolean | {
|
|
168
80
|
success?: boolean;
|
|
169
81
|
msg?: string;
|
|
170
82
|
message?: string;
|
|
@@ -173,66 +85,44 @@ export interface RuleGoEditorProps {
|
|
|
173
85
|
msg?: string;
|
|
174
86
|
message?: string;
|
|
175
87
|
}>;
|
|
176
|
-
|
|
88
|
+
onRestart?: HuanbanRulegoEditorOptions['onRestart'];
|
|
177
89
|
onSelectRuleChain?: (ruleChain: any) => void;
|
|
178
|
-
/** 删除规则链 */
|
|
179
90
|
onDeleteRuleChain?: (chainId: string) => void;
|
|
180
|
-
/** 劫持运行记录 */
|
|
181
91
|
onRunHistory?: (chainId: string) => void;
|
|
182
|
-
/** 规则链列表数据 */
|
|
183
92
|
ruleItems?: any[];
|
|
184
|
-
/** 规则链 API 地址 */
|
|
185
93
|
rulesApi?: string;
|
|
186
|
-
/**
|
|
187
|
-
* 自定义无头节点渲染器
|
|
188
|
-
* 当使用 HeadlessHtmlNode 时,核心引擎会派发 `node:html-mount` 事件。
|
|
189
|
-
* React 适配层会捕获该事件并调用本函数,将返回的 React 节点通过 Portal 挂载到画布内部。
|
|
190
|
-
*/
|
|
191
94
|
renderNode?: (type: string, data: any, model: any) => React.ReactNode;
|
|
192
95
|
}
|
|
193
|
-
/**
|
|
194
|
-
* RuleGoEditor 的命令式 API
|
|
195
|
-
* 通过 useRef + forwardRef 暴露给父组件
|
|
196
|
-
*/
|
|
197
96
|
export interface RuleGoEditorRef {
|
|
198
|
-
/** HuanbanRulegoEditor 实例 (editor-core) */
|
|
199
97
|
editor: HuanbanRulegoEditor | null;
|
|
200
|
-
/** LogicFlow 实例 */
|
|
201
98
|
lf: LogicFlow | null;
|
|
202
|
-
/** EditorCore 实例 */
|
|
203
99
|
core: EditorCore | null;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
100
|
+
capabilities: HuanbanRulegoEditor['capabilities'] | null;
|
|
101
|
+
connectionStatus: HuanbanRulegoEditor['connectionStatus'] | null;
|
|
102
|
+
runtimeFields: HuanbanRulegoEditor['runtimeFields'];
|
|
103
|
+
loadData: (data: RuleChainData, options?: HuanbanRulegoEditorLoadOptions) => void;
|
|
104
|
+
activateWorkspaceTab: (tabId: string) => boolean;
|
|
207
105
|
loadComponents: (components: RawComponentData) => void;
|
|
208
|
-
/** 导出数据 */
|
|
209
106
|
exportData: () => RuleChainData | null;
|
|
210
|
-
/** 切换小地图 */
|
|
211
107
|
toggleMiniMap: () => void;
|
|
212
|
-
/** 手动触发自动排版 — 基于 DAG 拓扑排序重新排列节点 */
|
|
213
108
|
autoLayout: () => void;
|
|
214
|
-
/** 打开独立设置弹窗 */
|
|
215
109
|
openSettings: (initialTab?: 'user' | 'setting' | 'ai' | 'skills') => void;
|
|
216
|
-
/** 打开 AI 助手侧栏 */
|
|
217
110
|
openAiAssistant: (options?: AIAssistantOpenOptions) => void;
|
|
218
|
-
/** 关闭 AI 助手侧栏 */
|
|
219
111
|
closeAiAssistant: () => void;
|
|
220
|
-
|
|
112
|
+
startTour: () => boolean;
|
|
113
|
+
closeTour: () => void;
|
|
221
114
|
setTheme: (theme: string) => void;
|
|
115
|
+
updateOptions: (patch: Partial<Omit<HuanbanRulegoEditorOptions, 'container'>>) => EditorOptionsUpdateResult | null;
|
|
116
|
+
refreshConnectionStatuses: () => void;
|
|
117
|
+
acquireSharedConnectionStatuses: () => () => void;
|
|
118
|
+
invokeAction: (id: string, source?: EditorActionSource) => Promise<boolean>;
|
|
119
|
+
openCommandPalette: () => void;
|
|
120
|
+
openShortcutHelp: () => void;
|
|
121
|
+
openNodePicker: (options?: NodePickerOpenOptions) => void;
|
|
122
|
+
openComponentDocs: (componentType?: string) => Promise<void>;
|
|
123
|
+
openComponentManager: (initialTab?: ComponentManageDialogTab) => void;
|
|
124
|
+
closeOverlay: () => void;
|
|
125
|
+
closeAllOverlays: () => void;
|
|
222
126
|
}
|
|
223
|
-
/**
|
|
224
|
-
* RuleGoEditor — React 封装组件
|
|
225
|
-
*
|
|
226
|
-
* 内部直接使用 editor-core 的 HuanbanRulegoEditor,
|
|
227
|
-
* 所有功能与原生 JS 版完全一致:
|
|
228
|
-
* - 工具栏 (保存/撤销/重做/导出/部署/运行/语言/主题)
|
|
229
|
-
* - 组件侧边栏 (分类折叠/搜索/拖拽添加)
|
|
230
|
-
* - 画布 (LogicFlow 2.x)
|
|
231
|
-
* - 右键菜单
|
|
232
|
-
* - 节点/边属性抽屉
|
|
233
|
-
* - 小地图
|
|
234
|
-
* - 键盘快捷键
|
|
235
|
-
*/
|
|
236
127
|
declare const RuleGoEditor: React.ForwardRefExoticComponent<RuleGoEditorProps & React.RefAttributes<RuleGoEditorRef>>;
|
|
237
128
|
export default RuleGoEditor;
|
|
238
|
-
//# sourceMappingURL=RuleGoEditor.d.ts.map
|