@huanban/rulego-editor-core 1.3.18 → 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 +153 -2
- package/assets/images/discovery-dark.svg +1 -0
- package/assets/images/discovery.svg +1 -0
- package/assets/images/nacos-dark.svg +1 -0
- package/assets/images/nacos.svg +1 -0
- package/assets/theme-icons/ant-blue/discovery-dark.svg +1 -0
- package/assets/theme-icons/ant-blue/discovery.svg +1 -0
- package/assets/theme-icons/ant-blue/nacos-dark.svg +1 -0
- package/assets/theme-icons/ant-blue/nacos.svg +1 -0
- package/assets/theme-icons/apple/discovery-dark.svg +1 -0
- package/assets/theme-icons/apple/discovery.svg +1 -0
- package/assets/theme-icons/apple/nacos-dark.svg +1 -0
- package/assets/theme-icons/apple/nacos.svg +1 -0
- package/assets/theme-icons/colorful/discovery-dark.svg +1 -0
- package/assets/theme-icons/colorful/discovery.svg +1 -0
- package/assets/theme-icons/colorful/nacos-dark.svg +1 -0
- package/assets/theme-icons/colorful/nacos.svg +1 -0
- package/assets/theme-icons/dark/discovery-dark.svg +1 -0
- package/assets/theme-icons/dark/discovery.svg +1 -0
- package/assets/theme-icons/dark/nacos-dark.svg +1 -0
- package/assets/theme-icons/dark/nacos.svg +1 -0
- package/assets/theme-icons/default/discovery-dark.svg +1 -0
- package/assets/theme-icons/default/discovery.svg +1 -0
- package/assets/theme-icons/default/nacos-dark.svg +1 -0
- package/assets/theme-icons/default/nacos.svg +1 -0
- package/assets/theme-icons/elegant/discovery-dark.svg +1 -0
- package/assets/theme-icons/elegant/discovery.svg +1 -0
- package/assets/theme-icons/elegant/nacos-dark.svg +1 -0
- package/assets/theme-icons/elegant/nacos.svg +1 -0
- package/assets/theme-icons/github/discovery-dark.svg +1 -0
- package/assets/theme-icons/github/discovery.svg +1 -0
- package/assets/theme-icons/github/nacos-dark.svg +1 -0
- package/assets/theme-icons/github/nacos.svg +1 -0
- package/assets/theme-icons/icon-theme-manifest.json +30 -14
- package/assets/theme-icons/icon-theme-overview.svg +1599 -1287
- package/assets/theme-icons/material/discovery-dark.svg +1 -0
- package/assets/theme-icons/material/discovery.svg +1 -0
- package/assets/theme-icons/material/nacos-dark.svg +1 -0
- package/assets/theme-icons/material/nacos.svg +1 -0
- package/assets/theme-icons/modern/discovery-dark.svg +1 -0
- package/assets/theme-icons/modern/discovery.svg +1 -0
- package/assets/theme-icons/modern/nacos-dark.svg +1 -0
- package/assets/theme-icons/modern/nacos.svg +1 -0
- package/assets/theme-icons/nature/discovery-dark.svg +1 -0
- package/assets/theme-icons/nature/discovery.svg +1 -0
- package/assets/theme-icons/nature/nacos-dark.svg +1 -0
- package/assets/theme-icons/nature/nacos.svg +1 -0
- package/assets/theme-icons/tailwind/discovery-dark.svg +1 -0
- package/assets/theme-icons/tailwind/discovery.svg +1 -0
- package/assets/theme-icons/tailwind/nacos-dark.svg +1 -0
- package/assets/theme-icons/tailwind/nacos.svg +1 -0
- package/assets/theme-icons/tech/discovery-dark.svg +1 -0
- package/assets/theme-icons/tech/discovery.svg +1 -0
- package/assets/theme-icons/tech/nacos-dark.svg +1 -0
- package/assets/theme-icons/tech/nacos.svg +1 -0
- package/assets/theme-icons/vscode/discovery-dark.svg +1 -0
- package/assets/theme-icons/vscode/discovery.svg +1 -0
- package/assets/theme-icons/vscode/nacos-dark.svg +1 -0
- package/assets/theme-icons/vscode/nacos.svg +1 -0
- package/dist/ai/copilot-markdown.d.ts +40 -0
- package/dist/ai/copilot-transport.d.ts +39 -0
- package/dist/api/AIManager.d.ts +5 -4
- package/dist/api/ApiProvider.d.ts +17 -69
- package/dist/api/ComponentCatalogCache.d.ts +27 -0
- package/dist/api/DebugSocketClient.d.ts +18 -25
- package/dist/api/RuleChainAPI.d.ts +24 -145
- package/dist/api/StreamParser.d.ts +0 -10
- package/dist/api/index.d.ts +4 -14
- package/dist/api/response-utils.d.ts +4 -22
- package/dist/api/types.d.ts +44 -179
- package/dist/chunks/editor-core-code-editor-CRki2wA_.js +512 -0
- package/dist/chunks/editor-core-default-components-BjF65lar.js +9448 -0
- package/dist/chunks/editor-core-dialogs-CkFLaC8Q.js +17176 -0
- package/dist/chunks/editor-core-icons-BqeFofNA.js +668 -0
- package/dist/chunks/editor-core-json-diff-RHsPeX-w.js +199 -0
- package/dist/chunks/editor-core-locales-i6o28vm2.js +4159 -0
- package/dist/chunks/editor-core-node-patches-BJTT3TuX.js +8060 -0
- package/dist/chunks/editor-core-node-views-BOaPVdmN.js +1288 -0
- package/dist/chunks/editor-core-property-drawers-lLsBIoCa.js +8035 -0
- package/dist/chunks/editor-core-standalone-CHXk3ukc.js +11270 -0
- package/dist/chunks/editor-core-styles-C1TbLgCK.js +8841 -0
- package/dist/chunks/vendor-logicflow-core-runtime-Cp6IBEjB.js +217 -0
- package/dist/chunks/vendor-logicflow-shared-C7YynLDn.js +4 -0
- package/dist/chunks/xlsx-BopDBbWb.js +24176 -0
- package/dist/core/ActionRegistry.d.ts +47 -0
- package/dist/core/AutoLayout.d.ts +1 -48
- package/dist/core/ComponentDocService.d.ts +28 -0
- package/dist/core/ComponentRegistry.d.ts +1 -125
- package/dist/core/DataAdapter.d.ts +4 -89
- package/dist/core/DiagnosticService.d.ts +15 -0
- package/dist/core/EditorCore.d.ts +22 -212
- package/dist/core/EditorWorkspace.d.ts +111 -0
- package/dist/core/EventBus.d.ts +0 -86
- package/dist/core/ExplorerTreeStore.d.ts +43 -0
- package/dist/core/FieldCapabilityRegistry.d.ts +16 -0
- package/dist/core/FieldChangeRegistry.d.ts +48 -0
- package/dist/core/HistoryManager.d.ts +0 -123
- package/dist/core/I18nManager.d.ts +0 -120
- package/dist/core/Optimizations.d.ts +0 -14
- package/dist/core/OptionSourceRegistry.d.ts +38 -0
- package/dist/core/RuleChainChatManager.d.ts +0 -37
- package/dist/core/RuleChainValidator.d.ts +0 -79
- package/dist/core/StateStore.d.ts +4 -140
- package/dist/core/ThemeManager.d.ts +0 -141
- package/dist/core/ValidationEngine.d.ts +0 -103
- package/dist/core/component-palette.d.ts +20 -0
- package/dist/core/component-payload.d.ts +0 -9
- package/dist/core/connection-status.d.ts +77 -0
- package/dist/core/context-menu-position.d.ts +27 -0
- package/dist/core/cron-schedule.d.ts +85 -0
- package/dist/core/debug-panel.d.ts +6 -0
- package/dist/core/editor-capabilities.d.ts +95 -0
- package/dist/core/editor-dock.d.ts +100 -0
- package/dist/core/editor-panel.d.ts +68 -0
- package/dist/core/explorer-tree.d.ts +27 -0
- package/dist/core/field-protocol.d.ts +32 -0
- package/dist/core/foundation-tokens.d.ts +38 -0
- package/dist/core/graph-operations.d.ts +34 -0
- package/dist/core/hover-tools.d.ts +26 -0
- package/dist/core/index.d.ts +68 -16
- package/dist/core/infer-run-input.d.ts +11 -0
- package/dist/core/key-value-editor.d.ts +6 -0
- package/dist/core/overlay-layers.d.ts +28 -0
- package/dist/core/recent-components.d.ts +51 -0
- package/dist/core/run-guard.d.ts +7 -0
- package/dist/core/runtime-field-dictionary.d.ts +68 -0
- package/dist/core/runtime-limits.d.ts +0 -5
- package/dist/core/save-conflict.d.ts +4 -0
- package/dist/core/server-status.d.ts +34 -0
- package/dist/core/simple-array.d.ts +4 -0
- package/dist/core/table-protocol.d.ts +36 -0
- package/dist/core/table-spreadsheet.d.ts +3 -0
- package/dist/core/test-cases.d.ts +54 -0
- package/dist/core/toolbar-icons.d.ts +4 -0
- package/dist/core/topology-rules.d.ts +17 -0
- package/dist/core/virtual-window.d.ts +20 -0
- package/dist/core/workspace-tab-actions.d.ts +13 -0
- package/dist/defaults/components.d.ts +0 -9
- package/dist/defaults/index.d.ts +0 -15
- package/dist/defaults/locale-en-US.d.ts +0 -24
- package/dist/defaults/locale-zh-CN.d.ts +0 -39
- package/dist/defaults/official-component-fallbacks.d.ts +0 -8
- package/dist/extensions/ClipboardExtension.d.ts +0 -23
- package/dist/extensions/KeyboardExtension.d.ts +0 -17
- package/dist/extensions/MenuExtension.d.ts +0 -23
- package/dist/iconRegistry.d.ts +0 -22
- package/dist/index.cjs +11320 -0
- package/dist/index.d.ts +25 -47
- package/dist/index.esm.js +1123 -99614
- package/dist/index.umd.js +3380 -1471
- package/dist/models/BaseNodeModel.d.ts +0 -32
- package/dist/models/index.d.ts +0 -1
- package/dist/nodes/AgentOrchestrationNode.d.ts +0 -24
- package/dist/nodes/GroupNode.d.ts +0 -38
- package/dist/nodes/HeadlessHtmlNode.d.ts +0 -16
- package/dist/nodes/SwitchNode.d.ts +0 -22
- package/dist/nodes/UnknownNodeModel.d.ts +0 -19
- package/dist/standalone/HuanbanRulegoEditor.d.ts +202 -401
- package/dist/standalone/ai-model-policy.d.ts +0 -1
- package/dist/standalone/ai-providers.d.ts +0 -1
- package/dist/standalone/auth-fetch.d.ts +2 -46
- package/dist/standalone/browser-assets.d.ts +0 -8
- package/dist/standalone/canvas-view.d.ts +6 -0
- package/dist/standalone/code-editor-language-loaders.d.ts +2 -0
- package/dist/standalone/code-editor-language-loaders.legacy.d.ts +7 -0
- package/dist/standalone/code-editor.d.ts +3 -87
- package/dist/standalone/connection-status-binding.d.ts +8 -0
- package/dist/standalone/custom-nodes.d.ts +0 -26
- package/dist/standalone/drawer-unsaved-guard.d.ts +2 -9
- package/dist/standalone/edge-label-quick-editor.d.ts +2 -0
- package/dist/standalone/editor-actions.d.ts +4 -0
- package/dist/standalone/editor-chain-info.d.ts +5 -38
- package/dist/standalone/editor-context-menu.d.ts +0 -21
- package/dist/standalone/editor-debug-ws.d.ts +37 -145
- package/dist/standalone/editor-delete.d.ts +0 -1
- package/dist/standalone/editor-dialogs.d.ts +16 -66
- package/dist/standalone/editor-events.d.ts +0 -27
- package/dist/standalone/editor-overlays.d.ts +14 -0
- package/dist/standalone/editor-property-drawers.d.ts +13 -71
- package/dist/standalone/editor-route-settings.d.ts +7 -55
- package/dist/standalone/editor-sidebar.d.ts +0 -18
- package/dist/standalone/editor-styles.d.ts +0 -11
- package/dist/standalone/editor-toast.d.ts +1 -2
- package/dist/standalone/editor-toolbar.d.ts +5 -80
- package/dist/standalone/editor-tour.d.ts +7 -0
- package/dist/standalone/editor-trace-overlay.d.ts +0 -5
- package/dist/standalone/full-json-dialog.d.ts +5 -1
- package/dist/standalone/group-node.d.ts +1 -51
- package/dist/standalone/icon-utils.d.ts +0 -20
- package/dist/standalone/index.d.ts +10 -7
- package/dist/standalone/json-diff.d.ts +0 -1
- package/dist/standalone/keyboard-events.d.ts +0 -1
- package/dist/standalone/layout-scheduler.d.ts +0 -6
- package/dist/standalone/lifecycle.d.ts +0 -5
- package/dist/standalone/logger.d.ts +0 -32
- package/dist/standalone/models-dev-catalog.d.ts +0 -1
- package/dist/standalone/node-copy.d.ts +7 -4
- package/dist/standalone/node-definitions.d.ts +0 -63
- package/dist/standalone/node-identity.d.ts +0 -1
- package/dist/standalone/node-theme.d.ts +8 -0
- package/dist/standalone/node-views-data.d.ts +0 -20
- package/dist/standalone/official-node-view-patches.d.ts +1 -14
- package/dist/standalone/outline-style.d.ts +7 -0
- package/dist/standalone/run-history-format.d.ts +0 -1
- package/dist/standalone/security-utils.d.ts +1 -5
- package/dist/standalone/shared-node-manager.d.ts +31 -0
- package/dist/standalone/themes.d.ts +0 -48
- package/dist/tools/tool-editor.d.ts +0 -1
- package/dist/types/component.d.ts +105 -87
- package/dist/types/editor.d.ts +16 -169
- package/dist/types/events.d.ts +30 -107
- package/dist/types/index.d.ts +3 -10
- package/dist/types/rule-chain.d.ts +0 -90
- package/dist/utils/GraphUtils.d.ts +0 -10
- package/dist/utils/helpers.d.ts +0 -80
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/pinyin-search.d.ts +0 -57
- package/dist/utils/relation-utils.d.ts +0 -1
- package/dist/utils/textUtils.d.ts +0 -12
- package/dist/version.d.ts +2 -3
- package/dist/xlsx-qn1xoUuv.cjs +105 -0
- package/package.json +19 -5
- package/vite-chunks.d.ts +11 -0
- package/vite-chunks.mjs +120 -0
- package/dist/index.cjs.js +0 -9515
package/dist/types/editor.d.ts
CHANGED
|
@@ -1,292 +1,139 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file editor.ts
|
|
3
|
-
* @description 编辑器选项、状态和配置的类型定义
|
|
4
|
-
*
|
|
5
|
-
* 定义了编辑器初始化选项、运行时状态、工具栏配置、
|
|
6
|
-
* API 端点配置等核心类型。这些类型在 EditorCore 和各适配器中通用。
|
|
7
|
-
*/
|
|
8
1
|
import type { RuleChainConfig, RuleNodeConfig, RuleConnectionConfig, RuleChainData } from './rule-chain';
|
|
9
2
|
import type { ComponentDefinition, ComponentGroup, RawComponentData } from './component';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
import type { EditorAction } from '../core/ActionRegistry';
|
|
4
|
+
import type { FieldCapabilityHandler } from '../core/FieldCapabilityRegistry';
|
|
5
|
+
import type { OptionSourceResolver } from '../core/OptionSourceRegistry';
|
|
6
|
+
import type { FieldChangeHandler } from '../core/FieldChangeRegistry';
|
|
7
|
+
import type { ComponentDocProvider } from '../core/ComponentDocService';
|
|
14
8
|
export interface ApiEndpoints {
|
|
15
|
-
/** 组件列表接口 (默认: /api/v1/components) */
|
|
16
9
|
componentsApi: string;
|
|
17
|
-
/** 规则链保存/加载接口 (默认: /api/v1/rule/:id) */
|
|
18
10
|
ruleApi: string;
|
|
19
|
-
/** 调试数据接口 (默认: /api/v1/event/debug) */
|
|
20
11
|
debugDataApi: string;
|
|
21
|
-
/** 消息发送接口 (默认: /api/v1/msg/:chainId/:msgType) */
|
|
22
12
|
msgApi: string;
|
|
23
13
|
}
|
|
24
|
-
/**
|
|
25
|
-
* 通用 HTTP 请求配置
|
|
26
|
-
* 统一所有 API 调用的请求行为
|
|
27
|
-
*/
|
|
28
14
|
export interface RequestConfig {
|
|
29
|
-
/** 后端 API 基础 URL (默认: http://127.0.0.1:9090) */
|
|
30
15
|
baseUrl: string;
|
|
31
|
-
/** 请求超时时间 (毫秒, 默认: 8000) */
|
|
32
16
|
timeout: number;
|
|
33
|
-
/** 自定义请求头 */
|
|
34
17
|
headers?: Record<string, string>;
|
|
35
|
-
/** 自定义 fetch 实现 (可用于注入认证 token 等) */
|
|
36
18
|
fetchImpl?: typeof fetch;
|
|
37
19
|
}
|
|
38
|
-
/**
|
|
39
|
-
* 工具栏按钮显示配置
|
|
40
|
-
*/
|
|
41
20
|
export interface ToolbarConfig {
|
|
42
|
-
/** 显示测试按钮 */
|
|
43
21
|
showTest: boolean;
|
|
44
|
-
/** 显示新建/打开按钮 */
|
|
45
22
|
showNewOrOpen: boolean;
|
|
46
|
-
/** 显示数据查看按钮 */
|
|
47
23
|
showData: boolean;
|
|
48
|
-
/** 显示设置按钮 */
|
|
49
24
|
showSetting: boolean;
|
|
50
|
-
/** 显示文档按钮 */
|
|
51
25
|
showDoc: boolean;
|
|
52
|
-
/** 显示全屏按钮 */
|
|
53
26
|
showFullScreen: boolean;
|
|
54
|
-
/** 显示保存按钮 */
|
|
55
27
|
showSave: boolean;
|
|
56
|
-
/** 显示重置按钮 */
|
|
57
28
|
showReset: boolean;
|
|
58
|
-
/** 显示删除按钮 */
|
|
59
29
|
showDelete: boolean;
|
|
60
30
|
}
|
|
61
|
-
/**
|
|
62
|
-
* 画布网格配置
|
|
63
|
-
*/
|
|
64
31
|
export interface GridConfig {
|
|
65
|
-
/** 是否显示网格 */
|
|
66
32
|
visible: boolean;
|
|
67
|
-
/** 网格类型 (mesh 或 dot) */
|
|
68
33
|
type: 'mesh' | 'dot';
|
|
69
|
-
/** 网格大小 */
|
|
70
34
|
size: number;
|
|
71
|
-
/** 网格颜色配置 */
|
|
72
35
|
config: {
|
|
73
36
|
color: string;
|
|
74
37
|
};
|
|
75
38
|
}
|
|
76
|
-
/**
|
|
77
|
-
* AI 供应商预设选项
|
|
78
|
-
* 与 editorOptions.aiProviders / aiEmbeddingProviders 协议保持兼容。
|
|
79
|
-
*/
|
|
80
39
|
export interface AiProviderOption {
|
|
81
|
-
/** 供应商 ID */
|
|
82
40
|
id?: string;
|
|
83
|
-
/** 兼容 select value 写法 */
|
|
84
41
|
value?: string;
|
|
85
|
-
/** 展示名称 */
|
|
86
42
|
label?: string;
|
|
87
|
-
/** 兼容 name 写法 */
|
|
88
43
|
name?: string;
|
|
89
|
-
/** OpenAI 兼容 API 地址 */
|
|
90
44
|
url?: string;
|
|
91
|
-
/** 默认模型 */
|
|
92
45
|
defaultModel?: string;
|
|
93
|
-
/** 模型下拉选项 */
|
|
94
46
|
models?: Array<string | {
|
|
95
47
|
label?: string;
|
|
96
48
|
value?: string;
|
|
97
49
|
[key: string]: unknown;
|
|
98
50
|
}>;
|
|
99
|
-
/** 数据来源,如 builtin、models.dev 或宿主自定义 */
|
|
100
51
|
source?: string;
|
|
101
|
-
/** 文档地址 */
|
|
102
52
|
doc?: string;
|
|
103
|
-
/** 推荐环境变量名 */
|
|
104
53
|
env?: string[];
|
|
105
|
-
/** 供应商模型数量,用于大目录检索展示 */
|
|
106
54
|
modelCount?: number;
|
|
107
|
-
/** 保留宿主扩展字段 */
|
|
108
55
|
[key: string]: unknown;
|
|
109
56
|
}
|
|
110
|
-
/**
|
|
111
|
-
* 编辑器初始化选项
|
|
112
|
-
* 创建编辑器实例时传入,合并默认值后使用
|
|
113
|
-
*/
|
|
114
57
|
export interface EditorOptions {
|
|
115
|
-
/** 编辑器挂载的 DOM 容器 (CSS 选择器或 HTMLElement) */
|
|
116
58
|
container?: string | HTMLElement;
|
|
117
|
-
/** 后端 API 基础 URL */
|
|
118
59
|
url?: string;
|
|
119
|
-
/** API 端点配置 */
|
|
120
60
|
endpoints?: Partial<ApiEndpoints>;
|
|
121
|
-
/** HTTP 请求配置 */
|
|
122
61
|
request?: Partial<RequestConfig>;
|
|
123
|
-
/** 工具栏配置 */
|
|
124
62
|
toolbar?: Partial<ToolbarConfig>;
|
|
125
|
-
/** 画布网格配置 */
|
|
126
63
|
grid?: Partial<GridConfig>;
|
|
127
|
-
/** 起始节点的 X 坐标 (默认: 280) */
|
|
128
64
|
startX?: number;
|
|
129
|
-
/** 起始节点的 Y 坐标 (默认: 280) */
|
|
130
65
|
startY?: number;
|
|
131
|
-
/** 预加载的组件列表,支持数组或 /api/v1/components 分段返回 */
|
|
132
66
|
components?: RawComponentData;
|
|
133
|
-
/** AI 供应商预设;兼容 editorOptions.aiProviders */
|
|
134
67
|
aiProviders?: AiProviderOption[];
|
|
135
|
-
/** 是否显示工具栏按钮文字,默认 false;设为 true 时显示图标 + 文字 */
|
|
136
68
|
showToolbarButtonLabels?: boolean;
|
|
137
|
-
/** 工具栏是否只显示图标,默认 true;显式 false 时可显示文字 */
|
|
138
69
|
toolbarIconOnly?: boolean;
|
|
139
|
-
/** 运行面板 AI 对话发送到 /rules/{chainId}/v1/chat/completions 的模型名 */
|
|
140
70
|
runChatModel?: string;
|
|
141
|
-
/** 兼容旧集成命名;未设置 runChatModel 时作为运行面板 AI 对话默认模型 */
|
|
142
71
|
defaultChatModel?: string;
|
|
143
|
-
/** Embedding AI 供应商预设;兼容 window.rulegoAiEmbeddingProviders 扩展 */
|
|
144
72
|
aiEmbeddingProviders?: AiProviderOption[];
|
|
145
|
-
/** 组件列表格式转换函数 */
|
|
146
73
|
adapterComponents?: (data: RawComponentData) => ComponentGroup[];
|
|
147
|
-
/** 初始规则链数据 (如果提供则直接渲染) */
|
|
148
74
|
data?: RuleChainData;
|
|
149
|
-
/** 初始规则链配置 */
|
|
150
75
|
ruleChain?: RuleChainConfig;
|
|
151
|
-
/** 是否为 headless 模式 (不渲染内置 UI) */
|
|
152
76
|
headless?: boolean;
|
|
153
|
-
/** 是否允许编辑 (只读模式) */
|
|
154
77
|
readonly?: boolean;
|
|
155
|
-
/** 是否允许拖动画布 */
|
|
156
78
|
stopMoveGraph?: boolean;
|
|
157
|
-
/** 是否显示悬停轮廓 */
|
|
158
79
|
hoverOutline?: boolean;
|
|
159
|
-
/** 是否调整边 */
|
|
160
80
|
adjustEdge?: boolean;
|
|
161
|
-
/** 是否调整边的起终点 */
|
|
162
81
|
adjustEdgeStartAndEnd?: boolean;
|
|
163
|
-
/** 是否允许双击编辑文本 */
|
|
164
82
|
textEdit?: boolean;
|
|
165
|
-
/** 撤销/重做最大步数 (默认: 50) */
|
|
166
83
|
maxHistory?: number;
|
|
167
|
-
/** 语言 (默认: zh-CN) */
|
|
168
84
|
locale?: string;
|
|
169
|
-
/** 自定义 ID 生成器 */
|
|
170
85
|
idGenerator?: (type: string) => string;
|
|
171
|
-
/** 主题名称 (内置: 'light' | 'dark' | 'blue', 也可传入自定义主题名) */
|
|
172
86
|
theme?: string;
|
|
173
|
-
/** 编辑器插件列表 */
|
|
174
87
|
plugins?: EditorPlugin[];
|
|
88
|
+
actionContributions?: EditorAction[];
|
|
89
|
+
capabilityContributions?: Record<string, FieldCapabilityHandler>;
|
|
90
|
+
optionSourceContributions?: Record<string, OptionSourceResolver>;
|
|
91
|
+
fieldChangeContributions?: Record<string, FieldChangeHandler>;
|
|
92
|
+
componentDocProvider?: ComponentDocProvider | null;
|
|
93
|
+
topology?: {
|
|
94
|
+
enabled?: boolean;
|
|
95
|
+
disabledRules?: string[];
|
|
96
|
+
throttleMs?: number;
|
|
97
|
+
};
|
|
175
98
|
}
|
|
176
|
-
|
|
177
|
-
* 面板显示状态枚举
|
|
178
|
-
*/
|
|
99
|
+
export type EditorRuntimeOptionsPatch = Partial<Omit<EditorOptions, 'container'>>;
|
|
179
100
|
export type PanelType = 'none' | 'node-add' | 'node-edit' | 'edge-add' | 'edge-edit';
|
|
180
|
-
/**
|
|
181
|
-
* 编辑器运行时状态
|
|
182
|
-
* 由 StateStore 管理,供 UI 层订阅消费
|
|
183
|
-
*/
|
|
184
101
|
export interface EditorState {
|
|
185
|
-
/** 编辑器是否已就绪 */
|
|
186
102
|
isReady: boolean;
|
|
187
|
-
/** 数据是否已修改 (有未保存的更改) */
|
|
188
103
|
isDirty: boolean;
|
|
189
|
-
/** 是否正在加载 */
|
|
190
104
|
isLoading: boolean;
|
|
191
|
-
/** 当前选中的节点数据 */
|
|
192
105
|
selectedNode: RuleNodeConfig | null;
|
|
193
|
-
/** 当前选中的边数据 */
|
|
194
106
|
selectedEdge: RuleConnectionConfig | null;
|
|
195
|
-
/** 当前活跃的面板类型 */
|
|
196
107
|
activePanel: PanelType;
|
|
197
|
-
/** 规则链配置 */
|
|
198
108
|
ruleChain: RuleChainConfig;
|
|
199
|
-
/** 组件注册表 (type => definition 映射) */
|
|
200
109
|
nodeComponents: Record<string, ComponentDefinition>;
|
|
201
|
-
/** 按分类分组的组件列表 */
|
|
202
110
|
componentGroups: ComponentGroup[];
|
|
203
|
-
/** 当前正在编辑的节点视图定义 (对应的 ComponentDefinition) */
|
|
204
111
|
currentNodeView: ComponentDefinition | null;
|
|
205
|
-
/** 当前正在编辑的节点配置数据 */
|
|
206
112
|
currentNodeModel: Record<string, unknown>;
|
|
207
|
-
/** 当前正在编辑的边配置数据 */
|
|
208
113
|
currentEdgeModel: Record<string, unknown>;
|
|
209
|
-
/** 是否可以撤销 */
|
|
210
114
|
canUndo: boolean;
|
|
211
|
-
/** 是否可以重做 */
|
|
212
115
|
canRedo: boolean;
|
|
213
116
|
}
|
|
214
|
-
/**
|
|
215
|
-
* 编辑器插件接口
|
|
216
|
-
*
|
|
217
|
-
* 用于扩展编辑器功能。插件可以在编辑器的各个生命周期阶段注入自定义逻辑。
|
|
218
|
-
*
|
|
219
|
-
* 钩子方法说明:
|
|
220
|
-
* - onInit: 编辑器实例初始化后调用 (DOM 已挂载)
|
|
221
|
-
* - onDestroy: 编辑器销毁前调用 (用于清理资源)
|
|
222
|
-
* - beforeDataLoad: 数据加载前调用 (可修改原始数据)
|
|
223
|
-
* - beforeDataSave: 数据保存前调用 (可修改导出数据)
|
|
224
|
-
* - beforeNodeAdd: 节点添加前调用 (返回 false 阻止添加)
|
|
225
|
-
* - beforeEdgeAdd: 边添加前调用 (返回 false 阻止添加)
|
|
226
|
-
*
|
|
227
|
-
* @example
|
|
228
|
-
* ```typescript
|
|
229
|
-
* const debugPlugin: EditorPlugin = {
|
|
230
|
-
* name: 'debug',
|
|
231
|
-
* onInit(editor) {
|
|
232
|
-
* console.log('编辑器已初始化')
|
|
233
|
-
* },
|
|
234
|
-
* beforeDataSave(data) {
|
|
235
|
-
* console.log('保存前数据:', data)
|
|
236
|
-
* return data
|
|
237
|
-
* },
|
|
238
|
-
* }
|
|
239
|
-
* ```
|
|
240
|
-
*
|
|
241
|
-
* @see EditorCore.use() 安装插件
|
|
242
|
-
*/
|
|
243
117
|
export interface EditorPlugin {
|
|
244
|
-
/** 插件名称 (唯一标识) */
|
|
245
118
|
name: string;
|
|
246
|
-
/** 插件优先级 (数字越小越先执行, 默认: 100) */
|
|
247
119
|
priority?: number;
|
|
248
|
-
/** 编辑器初始化后的回调 (此时 DOM 已挂载, LogicFlow 已就绪) */
|
|
249
120
|
onInit?(editor: unknown): void;
|
|
250
|
-
/** 编辑器销毁前的回调 (用于清理插件注册的资源) */
|
|
251
121
|
onDestroy?(editor: unknown): void;
|
|
252
|
-
/** 数据加载前回调 (可修改原始数据后返回) */
|
|
253
122
|
beforeDataLoad?(data: RuleChainData): RuleChainData;
|
|
254
|
-
/** 数据保存前回调 (可修改导出数据后返回) */
|
|
255
123
|
beforeDataSave?(data: RuleChainData): RuleChainData;
|
|
256
|
-
/** 节点添加前回调 (返回 false 阻止添加) */
|
|
257
124
|
beforeNodeAdd?(node: RuleNodeConfig): boolean | void;
|
|
258
|
-
/** 边添加前回调 (返回 false 阻止添加) */
|
|
259
125
|
beforeEdgeAdd?(edge: RuleConnectionConfig): boolean | void;
|
|
260
|
-
/**
|
|
261
|
-
* UI 渲染钩子 (可选)
|
|
262
|
-
* 用于向编辑器的特定区域注入自定义 UI 元素
|
|
263
|
-
* 每个函数接收对应区域的容器 HTMLElement
|
|
264
|
-
*/
|
|
265
126
|
ui?: {
|
|
266
|
-
/** 侧边栏区域注入 */
|
|
267
127
|
sidebar?: (container: HTMLElement) => void;
|
|
268
|
-
/** 工具栏区域注入 */
|
|
269
128
|
toolbar?: (container: HTMLElement) => void;
|
|
270
|
-
/** 属性面板区域注入 */
|
|
271
129
|
panel?: (container: HTMLElement) => void;
|
|
272
130
|
};
|
|
273
131
|
}
|
|
274
|
-
/**
|
|
275
|
-
* 编辑器内部运行时数据
|
|
276
|
-
* 对应原版 initData 对象
|
|
277
|
-
*/
|
|
278
132
|
export interface EditorInternalData {
|
|
279
|
-
/** 节点计数器 (用于生成节点 ID) */
|
|
280
133
|
nodeCount: number;
|
|
281
|
-
/** 边计数器 (用于生成边 ID) */
|
|
282
134
|
edgeCount: number;
|
|
283
|
-
/** 起始节点的固定 ID */
|
|
284
135
|
startNodeId: string;
|
|
285
|
-
/** 节点默认宽度 */
|
|
286
136
|
nodeWidth: number;
|
|
287
|
-
/** 关系类型分隔符 (多关系合并显示时用 '/' 连接, 如 'True/False') */
|
|
288
137
|
relationTypeSplit: string;
|
|
289
|
-
/** 当前正在复制的节点 ID (用于 Ctrl+C / Ctrl+V, 默认空字符串) */
|
|
290
138
|
currentCloneNodeId?: string;
|
|
291
139
|
}
|
|
292
|
-
//# sourceMappingURL=editor.d.ts.map
|
package/dist/types/events.d.ts
CHANGED
|
@@ -1,132 +1,71 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file events.ts
|
|
3
|
-
* @description 编辑器事件类型定义 - 强类型事件系统
|
|
4
|
-
*
|
|
5
|
-
* 定义编辑器所有事件的名称和对应的负载类型。
|
|
6
|
-
* 通过 TypeScript 泛型约束,确保事件触发和监听的类型安全。
|
|
7
|
-
*
|
|
8
|
-
* 事件分类:
|
|
9
|
-
* - 节点事件 (node:*)
|
|
10
|
-
* - 边事件 (edge:*)
|
|
11
|
-
* - 画布事件 (canvas:*)
|
|
12
|
-
* - 编辑器事件 (editor:*)
|
|
13
|
-
* - 历史事件 (history:*)
|
|
14
|
-
*/
|
|
15
1
|
import type { RuleNodeConfig, RuleConnectionConfig, RuleChainData, RuleChainConfig } from './rule-chain';
|
|
16
2
|
import type { ComponentGroup } from './component';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
import type { DiagnosticItem } from '../core/topology-rules';
|
|
4
|
+
import type { EditorActionSource } from '../core/ActionRegistry';
|
|
5
|
+
import type { EditorCapabilities } from '../core/editor-capabilities';
|
|
20
6
|
export interface NodeEventPayload {
|
|
21
|
-
/** 节点的 LogicFlow ID */
|
|
22
7
|
id: string;
|
|
23
|
-
/** 节点类型 (simple-node, start-node, chain-node, group-node) */
|
|
24
8
|
type: string;
|
|
25
|
-
/** 节点 X 坐标 */
|
|
26
9
|
x: number;
|
|
27
|
-
/** 节点 Y 坐标 */
|
|
28
10
|
y: number;
|
|
29
|
-
/** 节点显示文本 */
|
|
30
11
|
text: string;
|
|
31
|
-
/** 节点属性 (包含 model 和 view) */
|
|
32
12
|
properties: {
|
|
33
13
|
model: RuleNodeConfig;
|
|
34
14
|
view?: Record<string, unknown>;
|
|
35
15
|
};
|
|
36
16
|
}
|
|
37
|
-
/**
|
|
38
|
-
* 边点击/选择事件的负载
|
|
39
|
-
*/
|
|
40
17
|
export interface EdgeEventPayload {
|
|
41
|
-
/** 边的 LogicFlow ID */
|
|
42
18
|
id: string;
|
|
43
|
-
/** 边类型 */
|
|
44
19
|
type: string;
|
|
45
|
-
/** 源节点 ID */
|
|
46
20
|
sourceNodeId: string;
|
|
47
|
-
/** 目标节点 ID */
|
|
48
21
|
targetNodeId: string;
|
|
49
|
-
/** 边显示文本 */
|
|
50
22
|
text: string;
|
|
51
|
-
/** 边属性 (包含 model) */
|
|
52
23
|
properties: {
|
|
53
24
|
model: RuleConnectionConfig;
|
|
54
25
|
};
|
|
55
26
|
}
|
|
56
|
-
/**
|
|
57
|
-
* 保存事件负载
|
|
58
|
-
*/
|
|
59
27
|
export interface SaveEventPayload {
|
|
60
|
-
/** 保存的规则链数据 */
|
|
61
28
|
data: RuleChainData;
|
|
62
|
-
/** 是否保存成功 */
|
|
63
29
|
success: boolean;
|
|
64
|
-
/** 错误信息 (如果失败) */
|
|
65
30
|
error?: Error;
|
|
66
31
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
32
|
+
export interface SaveLifecycleResultPayload {
|
|
33
|
+
success: boolean;
|
|
34
|
+
mode: 'builtin' | 'host';
|
|
35
|
+
data: RuleChainData;
|
|
36
|
+
chainId: string;
|
|
37
|
+
message?: string;
|
|
38
|
+
verified?: boolean;
|
|
39
|
+
error?: unknown;
|
|
40
|
+
}
|
|
70
41
|
export interface HistoryChangePayload {
|
|
71
|
-
/** 是否可以撤销 */
|
|
72
42
|
canUndo: boolean;
|
|
73
|
-
/** 是否可以重做 */
|
|
74
43
|
canRedo: boolean;
|
|
75
|
-
/** 撤销栈深度 */
|
|
76
44
|
undoCount: number;
|
|
77
|
-
/** 重做栈深度 */
|
|
78
45
|
redoCount: number;
|
|
79
46
|
}
|
|
80
|
-
/**
|
|
81
|
-
* 验证事件负载
|
|
82
|
-
*/
|
|
83
47
|
export interface ValidationPayload {
|
|
84
|
-
/** 验证是否通过 */
|
|
85
48
|
valid: boolean;
|
|
86
|
-
/** 验证错误列表 */
|
|
87
49
|
errors: Array<{
|
|
88
|
-
/** 规则名称 */
|
|
89
50
|
rule: string;
|
|
90
|
-
/** 错误消息 */
|
|
91
51
|
message: string;
|
|
92
|
-
/** 相关的节点/边 ID */
|
|
93
52
|
elementId?: string;
|
|
94
53
|
}>;
|
|
95
54
|
}
|
|
96
|
-
/**
|
|
97
|
-
* 编辑器事件映射表
|
|
98
|
-
* Key 为事件名称, Value 为事件负载类型
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```typescript
|
|
102
|
-
* // 使用:
|
|
103
|
-
* editor.on('node:click', (payload: NodeEventPayload) => { ... })
|
|
104
|
-
* editor.emit('editor:save', { data, success: true })
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
55
|
export interface EditorEventMap {
|
|
108
|
-
/** 节点被点击 */
|
|
109
56
|
'node:click': NodeEventPayload;
|
|
110
|
-
/** 节点被双击 (触发编辑) */
|
|
111
57
|
'node:dbclick': NodeEventPayload;
|
|
112
|
-
/** 节点被选中 */
|
|
113
58
|
'node:selected': NodeEventPayload;
|
|
114
|
-
/** 节点被拖入画布 (外部拖入) */
|
|
115
59
|
'node:dnd-add': NodeEventPayload;
|
|
116
|
-
/** 节点被添加到画布 */
|
|
117
60
|
'node:add': NodeEventPayload;
|
|
118
|
-
/** 节点被删除 */
|
|
119
61
|
'node:delete': {
|
|
120
62
|
id: string;
|
|
121
63
|
};
|
|
122
|
-
/** 节点被拖动/移动 */
|
|
123
64
|
'node:drop': NodeEventPayload;
|
|
124
|
-
/** 节点属性被更新 */
|
|
125
65
|
'node:property-update': {
|
|
126
66
|
id: string;
|
|
127
67
|
properties: Record<string, unknown>;
|
|
128
68
|
};
|
|
129
|
-
/** Headless HTML 节点挂载,用于 Vue/React Portal 渲染 */
|
|
130
69
|
'node:html-mount': {
|
|
131
70
|
id: string;
|
|
132
71
|
type: string;
|
|
@@ -134,82 +73,66 @@ export interface EditorEventMap {
|
|
|
134
73
|
model: unknown;
|
|
135
74
|
el: HTMLElement;
|
|
136
75
|
};
|
|
137
|
-
/** Headless HTML 节点卸载 */
|
|
138
76
|
'node:html-unmount': {
|
|
139
77
|
id: string;
|
|
140
78
|
};
|
|
141
|
-
/** 边被点击 */
|
|
142
79
|
'edge:click': EdgeEventPayload;
|
|
143
|
-
/** 边被双击 (触发编辑) */
|
|
144
80
|
'edge:dbclick': EdgeEventPayload;
|
|
145
|
-
/** 边被添加 */
|
|
146
81
|
'edge:add': EdgeEventPayload;
|
|
147
|
-
/** 边被删除 */
|
|
148
82
|
'edge:delete': {
|
|
149
83
|
id: string;
|
|
150
84
|
};
|
|
151
|
-
/** 边属性被更新 */
|
|
152
85
|
'edge:property-update': {
|
|
153
86
|
id: string;
|
|
154
87
|
properties: Record<string, unknown>;
|
|
155
88
|
};
|
|
156
|
-
/** 画布空白区被点击 (取消选择) */
|
|
157
89
|
'blank:click': void;
|
|
158
|
-
/** 画布缩放 */
|
|
159
90
|
'canvas:zoom': {
|
|
160
91
|
scale: number;
|
|
161
92
|
};
|
|
162
|
-
/** 组件列表加载完成 */
|
|
163
93
|
'editor:components-loaded': ComponentGroup[];
|
|
164
|
-
/** 数据加载完成 (通知适配层渲染 LogicFlow 数据) */
|
|
165
94
|
'editor:data-loaded': {
|
|
166
95
|
lfData: import('../core/DataAdapter').LFGraphData;
|
|
167
96
|
ruleChain: RuleChainConfig;
|
|
168
97
|
};
|
|
169
|
-
/** 编辑器就绪 */
|
|
170
98
|
'editor:ready': void;
|
|
171
|
-
/** 编辑器销毁 */
|
|
172
99
|
'editor:destroy': void;
|
|
173
|
-
/** 保存请求 */
|
|
174
100
|
'editor:save': SaveEventPayload;
|
|
175
|
-
/** 保存成功 */
|
|
176
101
|
'editor:save-ok': RuleChainData;
|
|
177
|
-
/** 保存失败 */
|
|
178
102
|
'editor:save-error': {
|
|
179
103
|
data: RuleChainData;
|
|
180
104
|
error: Error;
|
|
181
105
|
};
|
|
182
|
-
|
|
106
|
+
'save:request': RuleChainData;
|
|
107
|
+
'save:success': SaveLifecycleResultPayload;
|
|
108
|
+
'save:error': SaveLifecycleResultPayload;
|
|
183
109
|
'editor:new': RuleChainConfig;
|
|
184
|
-
/** 打开规则链 */
|
|
185
110
|
'editor:open': RuleChainData;
|
|
186
|
-
/** 配置变更 */
|
|
187
111
|
'editor:setting': Record<string, unknown>;
|
|
188
|
-
/** 全屏切换 */
|
|
189
112
|
'editor:fullscreen': void;
|
|
190
|
-
/** 重置 */
|
|
191
113
|
'editor:reset': void;
|
|
192
|
-
/** 删除选中元素 */
|
|
193
114
|
'editor:delete-selected': void;
|
|
194
|
-
/** 元素已被删除 */
|
|
195
115
|
'editor:deleted': void;
|
|
196
|
-
/** 编辑面板请求 */
|
|
197
116
|
'editor:show-edit-panel': void;
|
|
198
|
-
/** 自动排版 — 手动触发 DAG 分层排版 */
|
|
199
117
|
'editor:auto-layout': void;
|
|
200
|
-
|
|
118
|
+
'editor:options-change': {
|
|
119
|
+
changedKeys: string[];
|
|
120
|
+
};
|
|
121
|
+
'editor:capabilities-change': EditorCapabilities;
|
|
122
|
+
'editor:external-data-conflict': {
|
|
123
|
+
current: RuleChainData | null;
|
|
124
|
+
incoming: RuleChainData;
|
|
125
|
+
};
|
|
126
|
+
'action:complete': {
|
|
127
|
+
id: string;
|
|
128
|
+
source: EditorActionSource;
|
|
129
|
+
success: boolean;
|
|
130
|
+
error?: unknown;
|
|
131
|
+
};
|
|
132
|
+
'diagnostics:change': DiagnosticItem[];
|
|
201
133
|
'history:change': HistoryChangePayload;
|
|
202
|
-
/** 验证完成 */
|
|
203
134
|
'validation:complete': ValidationPayload;
|
|
204
|
-
/** 调试日志写入 */
|
|
205
135
|
'debug:log': unknown;
|
|
206
136
|
}
|
|
207
|
-
/**
|
|
208
|
-
* 事件名称联合类型
|
|
209
|
-
*/
|
|
210
137
|
export type EditorEventName = keyof EditorEventMap;
|
|
211
|
-
/**
|
|
212
|
-
* 通用事件监听器类型
|
|
213
|
-
*/
|
|
214
138
|
export type EventListener<T = unknown> = (payload: T) => void;
|
|
215
|
-
//# sourceMappingURL=events.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file types/index.ts
|
|
3
|
-
* @description 类型统一导出入口
|
|
4
|
-
*
|
|
5
|
-
* 所有类型定义从这里集中导出,
|
|
6
|
-
* 方便外部使用: import type { RuleChainData, EditorOptions } from '@huanban/rulego-editor-core'
|
|
7
|
-
*/
|
|
8
1
|
export type { LayoutInfo, AdditionalInfo, RuleChainConfig, RuleNodeConfig, RuleConnectionConfig, RuleEndpointConfig, RuleChainMetadata, RuleChainData, } from './rule-chain';
|
|
9
|
-
export type { FieldValidation, ComponentField, ComponentCategory, ComponentDefinition, ComponentGroup, RawComponentData, ComponentRegistryOptions, } from './component';
|
|
10
|
-
export
|
|
2
|
+
export type { FieldValidation, FieldDependencyOperator, FieldDependency, FieldAttachment, FieldOptionsSource, AiProviderCapability, ComponentFieldControl, ComponentFieldOption, ComponentFieldControlOption, ComponentFieldGroup, DynamicFieldReference, DynamicFieldsDefinition, ComponentField, ComponentCategory, ComponentDefinition, ComponentGroup, RawComponentData, ComponentRegistryOptions, } from './component';
|
|
3
|
+
export { isComponentFieldOption } from './component';
|
|
4
|
+
export type { ApiEndpoints, RequestConfig, ToolbarConfig, GridConfig, AiProviderOption, EditorOptions, PanelType, EditorState, EditorPlugin, EditorInternalData, EditorRuntimeOptionsPatch, } from './editor';
|
|
11
5
|
export type { NodeEventPayload, EdgeEventPayload, SaveEventPayload, HistoryChangePayload, ValidationPayload, EditorEventMap, EditorEventName, EventListener, } from './events';
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|