@huanban/rulego-editor-ui 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 +13 -5
- package/dist/components/ContextMenu.d.ts +8 -100
- package/dist/components/DebugConsole.d.ts +1 -1
- package/dist/components/PropertyPanel.d.ts +0 -117
- package/dist/components/Sidebar.d.ts +0 -87
- package/dist/components/Toolbar.d.ts +5 -74
- package/dist/components/WorkflowExplorer.d.ts +45 -0
- package/dist/components/safeIcon.d.ts +0 -5
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +4 -37
- package/dist/index.esm.js +393 -232
- package/dist/index.umd.js +2 -2
- package/dist/style.css +1 -0
- package/package.json +11 -6
- package/dist/index.cjs.js +0 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
## ✨ 特性
|
|
9
9
|
|
|
10
10
|
- **零框架依赖** — 纯原生 DOM 操作,可用于任何前端框架
|
|
11
|
-
- **组件丰富** — 提供 Sidebar、Toolbar、PropertyPanel、ContextMenu
|
|
11
|
+
- **组件丰富** — 提供 Sidebar、Toolbar、PropertyPanel、ContextMenu、DebugConsole
|
|
12
12
|
- **自动绑定** — 组件自动连接 EditorCore 实例,响应状态变化
|
|
13
13
|
- **样式内聚** — 每个组件自带完整样式,即插即用
|
|
14
14
|
|
|
@@ -23,17 +23,24 @@ npm install @huanban/rulego-editor-ui @huanban/rulego-editor-core
|
|
|
23
23
|
```typescript
|
|
24
24
|
import { EditorCore } from '@huanban/rulego-editor-core'
|
|
25
25
|
import { Sidebar, Toolbar, PropertyPanel, ContextMenu } from '@huanban/rulego-editor-ui'
|
|
26
|
+
import '@huanban/rulego-editor-ui/style.css'
|
|
26
27
|
|
|
27
28
|
const core = new EditorCore({ container: document.getElementById('editor')! })
|
|
28
29
|
|
|
29
30
|
// 挂载侧边栏 (组件分类拖拽面板)
|
|
30
31
|
new Sidebar(document.getElementById('sidebar')!, { core })
|
|
31
32
|
|
|
32
|
-
//
|
|
33
|
-
new Toolbar(document.getElementById('toolbar')!, {
|
|
33
|
+
// 挂载工具栏。保存属于宿主业务,必须显式提供真实保存入口。
|
|
34
|
+
new Toolbar(document.getElementById('toolbar')!, {
|
|
35
|
+
core,
|
|
36
|
+
onSave: () => hostSave(core),
|
|
37
|
+
})
|
|
34
38
|
|
|
35
39
|
// 挂载属性面板 (节点配置编辑)
|
|
36
40
|
new PropertyPanel(document.getElementById('panel')!, { core })
|
|
41
|
+
|
|
42
|
+
// 调试日志面板,销毁时会自动解除 debug:log 订阅。
|
|
43
|
+
new DebugConsole(document.getElementById('debug')!, { core })
|
|
37
44
|
```
|
|
38
45
|
|
|
39
46
|
## 📖 组件说明
|
|
@@ -41,9 +48,10 @@ new PropertyPanel(document.getElementById('panel')!, { core })
|
|
|
41
48
|
| 组件 | 说明 |
|
|
42
49
|
|------|------|
|
|
43
50
|
| `Sidebar` | 左侧组件分类面板,支持拖拽添加节点 |
|
|
44
|
-
| `Toolbar` |
|
|
51
|
+
| `Toolbar` | 顶部工具栏,内置撤销/重做/缩放/删除;保存必须由宿主通过 `onSave` 提供真实实现 |
|
|
45
52
|
| `PropertyPanel` | 右侧属性面板,动态渲染节点配置表单 |
|
|
46
|
-
| `ContextMenu` |
|
|
53
|
+
| `ContextMenu` | 右键上下文菜单;复制和全选分别通过 `onCopy`、`onSelectAll` 提供真实实现 |
|
|
54
|
+
| `DebugConsole` | 结构化调试日志面板,销毁时解除事件订阅 |
|
|
47
55
|
|
|
48
56
|
## 🔗 相关包
|
|
49
57
|
|
|
@@ -1,147 +1,55 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file components/ContextMenu.ts
|
|
3
|
-
* @description 右键上下文菜单 — 纯 DOM 实现 (零框架依赖)
|
|
4
|
-
*
|
|
5
|
-
* 功能:
|
|
6
|
-
* - 支持节点右键菜单 (编辑 / 删除 / 复制 等)
|
|
7
|
-
* - 支持画布空白处右键菜单 (粘贴 / 全选 等)
|
|
8
|
-
* - 支持边右键菜单 (删除连线 / 编辑标签 等)
|
|
9
|
-
* - 自动定位到鼠标位置
|
|
10
|
-
* - 点击外部自动关闭
|
|
11
|
-
* - 支持自定义菜单项扩展
|
|
12
|
-
*
|
|
13
|
-
* 使用方式:
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { ContextMenu } from '@huanban/editor-ui'
|
|
16
|
-
*
|
|
17
|
-
* const menu = new ContextMenu(container, {
|
|
18
|
-
* core: editorCore,
|
|
19
|
-
* items: [...] // 可选: 自定义菜单项
|
|
20
|
-
* })
|
|
21
|
-
* menu.destroy()
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
1
|
import type { EditorCore } from '@huanban/rulego-editor-core';
|
|
25
2
|
import { type SafeIcon } from './safeIcon';
|
|
26
|
-
/**
|
|
27
|
-
* 菜单项类型
|
|
28
|
-
*/
|
|
29
3
|
export type MenuItemType = 'node' | 'edge' | 'canvas' | 'all';
|
|
30
|
-
/**
|
|
31
|
-
* 菜单项定义
|
|
32
|
-
*/
|
|
33
4
|
export interface MenuItem {
|
|
34
|
-
/** 菜单项唯一标识 */
|
|
35
5
|
id: string;
|
|
36
|
-
/** 显示文本 */
|
|
37
6
|
label: string;
|
|
38
|
-
/** 图标。字符串按纯文本渲染;SVG 必须显式传 trusted-svg。 */
|
|
39
7
|
icon?: string | SafeIcon;
|
|
40
|
-
/** 适用的目标类型 */
|
|
41
8
|
target: MenuItemType | MenuItemType[];
|
|
42
|
-
/** 是否禁用 (可动态) */
|
|
43
9
|
disabled?: boolean | (() => boolean);
|
|
44
|
-
/** 是否在此项之后添加分隔线 */
|
|
45
10
|
separator?: boolean;
|
|
46
|
-
/** 点击回调, 接收目标元素的信息 */
|
|
47
11
|
onClick: (context: MenuContext) => void;
|
|
48
12
|
}
|
|
49
|
-
/**
|
|
50
|
-
* 菜单上下文 — 右键时附带的目标信息
|
|
51
|
-
*/
|
|
52
13
|
export interface MenuContext {
|
|
53
|
-
/** 目标类型 */
|
|
54
14
|
type: MenuItemType;
|
|
55
|
-
/** 目标元素 ID (节点/边 LogicFlow ID) */
|
|
56
15
|
id?: string;
|
|
57
|
-
/** 鼠标坐标 */
|
|
58
16
|
position: {
|
|
59
17
|
x: number;
|
|
60
18
|
y: number;
|
|
61
19
|
};
|
|
62
|
-
/** 附加数据 */
|
|
63
20
|
data?: Record<string, unknown>;
|
|
64
21
|
}
|
|
65
|
-
/**
|
|
66
|
-
* ContextMenu 配置选项
|
|
67
|
-
*/
|
|
68
22
|
export interface ContextMenuOptions {
|
|
69
|
-
/** EditorCore 实例 (必须) */
|
|
70
23
|
core: EditorCore;
|
|
71
|
-
/** 自定义菜单项 (追加到内置菜单项之后) */
|
|
72
24
|
items?: MenuItem[];
|
|
73
|
-
/** 是否包含内置菜单项, 默认 true */
|
|
74
25
|
includeBuiltin?: boolean;
|
|
26
|
+
onCopy?: (context: MenuContext) => void;
|
|
27
|
+
onSelectAll?: (context: MenuContext) => void;
|
|
75
28
|
}
|
|
76
|
-
/**
|
|
77
|
-
* 纯 DOM 实现的右键上下文菜单
|
|
78
|
-
*
|
|
79
|
-
* 生命周期:
|
|
80
|
-
* 1. 构造时创建隐藏的菜单 DOM
|
|
81
|
-
* 2. 监听右键事件, 判断目标类型并显示对应菜单
|
|
82
|
-
* 3. 点击菜单项后执行回调并关闭
|
|
83
|
-
* 4. 点击外部区域自动关闭
|
|
84
|
-
*/
|
|
85
29
|
export declare class ContextMenu {
|
|
86
|
-
/** 画布容器 (用于事件监听范围) */
|
|
87
30
|
private container;
|
|
88
|
-
/** EditorCore 引用 */
|
|
89
31
|
private core;
|
|
90
|
-
/** 菜单项列表 */
|
|
91
32
|
private items;
|
|
92
|
-
/** 菜单根 DOM 元素 */
|
|
93
33
|
private menuEl;
|
|
94
|
-
/** 当前上下文 */
|
|
95
34
|
private currentContext;
|
|
96
|
-
/** 外部点击关闭的监听函数引用 */
|
|
97
35
|
private outsideClickHandler;
|
|
36
|
+
private contextMenuHandler;
|
|
37
|
+
private escapeKeyHandler;
|
|
38
|
+
private positionFrame;
|
|
39
|
+
private options;
|
|
98
40
|
constructor(container: HTMLElement, options: ContextMenuOptions);
|
|
99
|
-
/**
|
|
100
|
-
* 创建菜单 DOM (初始隐藏)
|
|
101
|
-
*/
|
|
102
41
|
private mount;
|
|
103
|
-
/**
|
|
104
|
-
* 绑定事件
|
|
105
|
-
*/
|
|
106
42
|
private bindEvents;
|
|
107
|
-
/**
|
|
108
|
-
* 销毁菜单
|
|
109
|
-
*/
|
|
110
43
|
destroy(): void;
|
|
111
|
-
/**
|
|
112
|
-
* 处理右键事件
|
|
113
|
-
*/
|
|
114
44
|
private handleContextMenu;
|
|
115
|
-
/**
|
|
116
|
-
* 解析右键目标的上下文
|
|
117
|
-
*/
|
|
118
45
|
private resolveContext;
|
|
119
|
-
/**
|
|
120
|
-
* 渲染并显示菜单
|
|
121
|
-
*/
|
|
122
46
|
private renderMenu;
|
|
123
|
-
/**
|
|
124
|
-
* 隐藏菜单
|
|
125
|
-
*/
|
|
126
47
|
hide(): void;
|
|
127
|
-
|
|
128
|
-
* 获取内置菜单项
|
|
129
|
-
*/
|
|
48
|
+
private cancelPendingPosition;
|
|
130
49
|
private getBuiltinItems;
|
|
131
|
-
/**
|
|
132
|
-
* 动态添加菜单项
|
|
133
|
-
* @param item - 菜单项定义
|
|
134
|
-
*/
|
|
135
50
|
addItem(item: MenuItem): void;
|
|
136
51
|
private text;
|
|
137
|
-
|
|
138
|
-
* 移除菜单项
|
|
139
|
-
* @param id - 菜单项 ID
|
|
140
|
-
*/
|
|
52
|
+
private toolbarIcon;
|
|
141
53
|
removeItem(id: string): void;
|
|
142
|
-
/**
|
|
143
|
-
* 获取菜单 DOM 元素
|
|
144
|
-
*/
|
|
145
54
|
getElement(): HTMLElement | null;
|
|
146
55
|
}
|
|
147
|
-
//# sourceMappingURL=ContextMenu.d.ts.map
|
|
@@ -10,6 +10,7 @@ export declare class DebugConsole {
|
|
|
10
10
|
private logs;
|
|
11
11
|
private consoleEl;
|
|
12
12
|
private listEl;
|
|
13
|
+
private unsubscribe;
|
|
13
14
|
constructor(container: HTMLElement, options: DebugConsoleOptions);
|
|
14
15
|
private t;
|
|
15
16
|
private mount;
|
|
@@ -18,4 +19,3 @@ export declare class DebugConsole {
|
|
|
18
19
|
clear(): void;
|
|
19
20
|
destroy(): void;
|
|
20
21
|
}
|
|
21
|
-
//# sourceMappingURL=DebugConsole.d.ts.map
|
|
@@ -1,156 +1,39 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file components/PropertyPanel.ts
|
|
3
|
-
* @description 节点/边属性面板 — 纯 DOM 实现 (零框架依赖)
|
|
4
|
-
*
|
|
5
|
-
* 功能:
|
|
6
|
-
* - 监听节点/边选中事件, 自动展示对应的属性表单
|
|
7
|
-
* - 根据组件定义动态生成表单字段
|
|
8
|
-
* - 支持字段类型: string, int, bool, select, code, json
|
|
9
|
-
* - 字段变更实时回传给 EditorCore
|
|
10
|
-
* - 空白处点击时自动关闭面板
|
|
11
|
-
*
|
|
12
|
-
* 使用方式:
|
|
13
|
-
* ```typescript
|
|
14
|
-
* import { PropertyPanel } from '@huanban/editor-ui'
|
|
15
|
-
*
|
|
16
|
-
* const panel = new PropertyPanel(container, { core: editorCore })
|
|
17
|
-
* panel.destroy()
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @see ComponentField — 字段定义类型
|
|
21
|
-
* @see EditorCore — 编辑器核心引擎
|
|
22
|
-
*/
|
|
23
1
|
import type { EditorCore } from '@huanban/rulego-editor-core';
|
|
24
2
|
import type { ComponentDefinition } from '@huanban/rulego-editor-core';
|
|
25
|
-
/**
|
|
26
|
-
* PropertyPanel 配置选项
|
|
27
|
-
*/
|
|
28
3
|
export interface PropertyPanelOptions {
|
|
29
|
-
/** EditorCore 实例 (必须) */
|
|
30
4
|
core: EditorCore;
|
|
31
|
-
/** 面板标题文本 */
|
|
32
5
|
title?: string;
|
|
33
|
-
/** 宽度, 默认 '320px' */
|
|
34
6
|
width?: string;
|
|
35
|
-
/** 位置, 默认 'right' */
|
|
36
7
|
position?: 'left' | 'right';
|
|
37
8
|
}
|
|
38
|
-
/**
|
|
39
|
-
* 纯 DOM 实现的属性编辑面板
|
|
40
|
-
*
|
|
41
|
-
* 工作流:
|
|
42
|
-
* 1. 监听 core.store 中 currentNodeView / currentNodeModel 变化
|
|
43
|
-
* 2. 根据 ComponentDefinition.fields 动态生成表单
|
|
44
|
-
* 3. 字段变更时通过 core.eventBus 发送 'node:property-update' 事件
|
|
45
|
-
* 4. 画布空白点击时清空面板内容
|
|
46
|
-
*/
|
|
47
9
|
export declare class PropertyPanel {
|
|
48
|
-
/** 外层容器 */
|
|
49
10
|
private container;
|
|
50
|
-
/** EditorCore 引用 */
|
|
51
11
|
private core;
|
|
52
|
-
/** 配置选项 */
|
|
53
12
|
private options;
|
|
54
|
-
/** 根 DOM 元素 */
|
|
55
13
|
private rootEl;
|
|
56
|
-
/** 表单容器 */
|
|
57
14
|
private formContainer;
|
|
58
|
-
/** 面板标题元素 */
|
|
59
15
|
private titleEl;
|
|
60
|
-
/** 状态订阅取消函数 */
|
|
61
16
|
private unsubscribe;
|
|
62
|
-
/** 事件取消列表 */
|
|
63
17
|
private eventCleanups;
|
|
64
|
-
/** 当前编辑的节点 LF ID */
|
|
65
18
|
private currentNodeId;
|
|
66
19
|
constructor(container: HTMLElement, options: PropertyPanelOptions);
|
|
67
|
-
/**
|
|
68
|
-
* 创建面板 DOM
|
|
69
|
-
*/
|
|
70
20
|
private mount;
|
|
71
|
-
/**
|
|
72
|
-
* 绑定事件监听
|
|
73
|
-
*/
|
|
74
21
|
private bindEvents;
|
|
75
|
-
/**
|
|
76
|
-
* 销毁面板
|
|
77
|
-
*/
|
|
78
22
|
destroy(): void;
|
|
79
|
-
/**
|
|
80
|
-
* 显示面板并渲染表单
|
|
81
|
-
* @param view - 组件定义 (含字段列表)
|
|
82
|
-
* @param model - 当前节点模型数据
|
|
83
|
-
*/
|
|
84
23
|
private showPanel;
|
|
85
|
-
/**
|
|
86
|
-
* 清空面板并隐藏
|
|
87
|
-
*/
|
|
88
24
|
private clearPanel;
|
|
89
|
-
/**
|
|
90
|
-
* 渲染基础信息区 (节点名称等)
|
|
91
|
-
* @param model - 节点模型
|
|
92
|
-
*/
|
|
93
25
|
private renderBasicInfo;
|
|
94
|
-
/**
|
|
95
|
-
* 创建单个表单字段元素
|
|
96
|
-
* @param field - 字段定义
|
|
97
|
-
* @param model - 节点模型数据
|
|
98
|
-
* @returns 字段 wrapper HTMLElement
|
|
99
|
-
*/
|
|
100
26
|
private createFieldElement;
|
|
101
|
-
/**
|
|
102
|
-
* 文本输入框
|
|
103
|
-
*/
|
|
104
27
|
private createTextField;
|
|
105
|
-
/**
|
|
106
|
-
* 数值输入框
|
|
107
|
-
*/
|
|
108
28
|
private createNumberField;
|
|
109
|
-
/**
|
|
110
|
-
* 布尔开关
|
|
111
|
-
*/
|
|
112
29
|
private createBoolField;
|
|
113
|
-
/**
|
|
114
|
-
* 下拉选择
|
|
115
|
-
*/
|
|
116
30
|
private createSelectField;
|
|
117
|
-
/**
|
|
118
|
-
* 多行文本 / 代码编辑器
|
|
119
|
-
*/
|
|
120
31
|
private createTextareaField;
|
|
121
|
-
/**
|
|
122
|
-
* 从模型中获取字段当前值
|
|
123
|
-
* @param field - 字段定义
|
|
124
|
-
* @param model - 节点模型
|
|
125
|
-
* @returns 字段值
|
|
126
|
-
*/
|
|
127
32
|
private getModelValue;
|
|
128
|
-
/**
|
|
129
|
-
* 处理字段变更, 通知 EditorCore
|
|
130
|
-
* @param fieldName - 字段名
|
|
131
|
-
* @param value - 新值
|
|
132
|
-
*/
|
|
133
33
|
private handleFieldChange;
|
|
134
|
-
/**
|
|
135
|
-
* 获取根 DOM 元素
|
|
136
|
-
*/
|
|
137
34
|
getElement(): HTMLElement | null;
|
|
138
|
-
/**
|
|
139
|
-
* 手动设置当前编辑的节点 ID
|
|
140
|
-
* @param nodeId - LogicFlow 节点 ID
|
|
141
|
-
*/
|
|
142
35
|
setCurrentNodeId(nodeId: string): void;
|
|
143
|
-
/**
|
|
144
|
-
* 手动显示面板
|
|
145
|
-
* @param view - 组件定义
|
|
146
|
-
* @param model - 节点模型
|
|
147
|
-
* @param nodeId - 节点 ID
|
|
148
|
-
*/
|
|
149
36
|
show(view: ComponentDefinition, model: Record<string, unknown>, nodeId?: string): void;
|
|
150
|
-
/**
|
|
151
|
-
* 手动隐藏面板
|
|
152
|
-
*/
|
|
153
37
|
hide(): void;
|
|
154
38
|
private text;
|
|
155
39
|
}
|
|
156
|
-
//# sourceMappingURL=PropertyPanel.d.ts.map
|
|
@@ -1,117 +1,30 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file components/Sidebar.ts
|
|
3
|
-
* @description 组件侧边栏 — 纯 DOM 实现 (零框架依赖)
|
|
4
|
-
*
|
|
5
|
-
* 功能:
|
|
6
|
-
* - 按分类分组展示可用组件
|
|
7
|
-
* - 支持关键字搜索过滤
|
|
8
|
-
* - 支持分组折叠/展开
|
|
9
|
-
* - 拖拽组件到画布 (DnD)
|
|
10
|
-
* - 自动监听 EditorCore 状态变化, 更新组件列表
|
|
11
|
-
*
|
|
12
|
-
* 使用方式:
|
|
13
|
-
* ```typescript
|
|
14
|
-
* import { Sidebar } from '@huanban/editor-ui'
|
|
15
|
-
*
|
|
16
|
-
* const sidebar = new Sidebar(container, { core: editorCore })
|
|
17
|
-
* // 卸载时
|
|
18
|
-
* sidebar.destroy()
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @see ComponentGroup — 组件分组定义
|
|
22
|
-
* @see EditorCore — 编辑器核心引擎
|
|
23
|
-
*/
|
|
24
1
|
import type { EditorCore } from '@huanban/rulego-editor-core';
|
|
25
|
-
/**
|
|
26
|
-
* Sidebar 配置选项
|
|
27
|
-
*/
|
|
28
2
|
export interface SidebarOptions {
|
|
29
|
-
/** EditorCore 实例 (必须) */
|
|
30
3
|
core: EditorCore;
|
|
31
|
-
/** 是否显示搜索框, 默认 true */
|
|
32
4
|
searchable?: boolean;
|
|
33
|
-
/** 默认折叠状态, 默认 false (全部展开) */
|
|
34
5
|
defaultCollapsed?: boolean;
|
|
35
|
-
/** 搜索框占位符文本 */
|
|
36
6
|
searchPlaceholder?: string;
|
|
37
|
-
/** 宽度 (CSS值), 默认 '220px' */
|
|
38
7
|
width?: string;
|
|
39
8
|
}
|
|
40
|
-
/**
|
|
41
|
-
* 纯 DOM 实现的组件侧边栏
|
|
42
|
-
*
|
|
43
|
-
* 内部维护:
|
|
44
|
-
* - componentGroups: 当前显示的组件分组
|
|
45
|
-
* - collapsedGroups: 折叠状态 Set
|
|
46
|
-
* - searchKeyword: 搜索关键字
|
|
47
|
-
*
|
|
48
|
-
* 通过 EditorCore.store.subscribe 监听状态更新
|
|
49
|
-
*/
|
|
50
9
|
export declare class Sidebar {
|
|
51
|
-
/** 外层容器 */
|
|
52
10
|
private container;
|
|
53
|
-
/** EditorCore 引用 */
|
|
54
11
|
private core;
|
|
55
|
-
/** 配置选项 */
|
|
56
12
|
private options;
|
|
57
|
-
/** 已折叠的分组 Set */
|
|
58
13
|
private collapsedGroups;
|
|
59
|
-
/** 当前搜索关键字 */
|
|
60
14
|
private searchKeyword;
|
|
61
|
-
/** 根 DOM 元素 */
|
|
62
15
|
private rootEl;
|
|
63
|
-
/** 状态订阅取消函数 */
|
|
64
16
|
private unsubscribe;
|
|
65
17
|
constructor(container: HTMLElement, options: SidebarOptions);
|
|
66
|
-
/**
|
|
67
|
-
* 挂载侧边栏 DOM 到容器
|
|
68
|
-
*/
|
|
69
18
|
private mount;
|
|
70
|
-
/**
|
|
71
|
-
* 销毁侧边栏, 清理所有 DOM 和事件
|
|
72
|
-
*/
|
|
73
19
|
destroy(): void;
|
|
74
|
-
/**
|
|
75
|
-
* 渲染所有组件分组
|
|
76
|
-
* @param groups - 原始组件分组列表
|
|
77
|
-
*/
|
|
78
20
|
private renderGroups;
|
|
79
|
-
/**
|
|
80
|
-
* 创建单个分组 DOM 元素
|
|
81
|
-
* @param group - 组件分组定义
|
|
82
|
-
* @returns 分组 HTMLElement
|
|
83
|
-
*/
|
|
84
21
|
private createGroupElement;
|
|
85
|
-
/**
|
|
86
|
-
* 创建单个组件 DOM 元素 (可拖拽)
|
|
87
|
-
* @param comp - 组件定义
|
|
88
|
-
* @param groupColor - 分组颜色
|
|
89
|
-
* @returns 组件 HTMLElement
|
|
90
|
-
*/
|
|
91
22
|
private createComponentElement;
|
|
92
|
-
/**
|
|
93
|
-
* 根据搜索关键字过滤组件分组
|
|
94
|
-
* @param groups - 原始分组列表
|
|
95
|
-
* @returns 过滤后的分组列表 (空分组会被移除)
|
|
96
|
-
*/
|
|
97
23
|
private filterGroups;
|
|
98
|
-
/**
|
|
99
|
-
* 手动触发刷新
|
|
100
|
-
*/
|
|
101
24
|
refresh(): void;
|
|
102
|
-
/**
|
|
103
|
-
* 展开所有分组
|
|
104
|
-
*/
|
|
105
25
|
expandAll(): void;
|
|
106
|
-
/**
|
|
107
|
-
* 折叠所有分组
|
|
108
|
-
*/
|
|
109
26
|
collapseAll(): void;
|
|
110
|
-
/**
|
|
111
|
-
* 获取根 DOM 元素
|
|
112
|
-
*/
|
|
113
27
|
getElement(): HTMLElement | null;
|
|
114
28
|
private text;
|
|
115
29
|
private componentLabel;
|
|
116
30
|
}
|
|
117
|
-
//# sourceMappingURL=Sidebar.d.ts.map
|
|
@@ -1,107 +1,38 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file components/Toolbar.ts
|
|
3
|
-
* @description 编辑器工具栏 — 纯 DOM 实现 (零框架依赖)
|
|
4
|
-
*
|
|
5
|
-
* 功能:
|
|
6
|
-
* - 撤销 / 重做 按钮
|
|
7
|
-
* - 删除选中元素
|
|
8
|
-
* - 保存 / 全屏切换
|
|
9
|
-
* - 缩放控制 (放大 / 缩小 / 适应画布)
|
|
10
|
-
* - 自定义按钮扩展
|
|
11
|
-
* - 自动监听 EditorCore 状态, 按钮禁用联动
|
|
12
|
-
*
|
|
13
|
-
* 使用方式:
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { Toolbar } from '@huanban/editor-ui'
|
|
16
|
-
*
|
|
17
|
-
* const toolbar = new Toolbar(container, { core: editorCore })
|
|
18
|
-
* toolbar.destroy()
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
1
|
import type { EditorCore } from '@huanban/rulego-editor-core';
|
|
22
2
|
import { type SafeIcon } from './safeIcon';
|
|
23
|
-
/**
|
|
24
|
-
* 工具栏按钮定义
|
|
25
|
-
*/
|
|
26
3
|
export interface ToolbarButton {
|
|
27
|
-
/** 按钮唯一标识 */
|
|
28
4
|
id: string;
|
|
29
|
-
/** 按钮显示文本 (可选, 图标模式下可不设) */
|
|
30
5
|
label?: string;
|
|
31
|
-
/** 按钮图标。字符串按纯文本渲染;SVG 必须显式传 trusted-svg。 */
|
|
32
6
|
icon: string | SafeIcon;
|
|
33
|
-
/** 提示文本 (tooltip) */
|
|
34
7
|
title: string;
|
|
35
|
-
/** 是否禁用 (可以是函数, 动态判断) */
|
|
36
8
|
disabled?: boolean | (() => boolean);
|
|
37
|
-
/** 分隔线 (在此按钮之前插入分隔线) */
|
|
38
9
|
divider?: boolean;
|
|
39
|
-
/** 点击回调 */
|
|
40
10
|
onClick: () => void;
|
|
41
11
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Toolbar 配置选项
|
|
44
|
-
*/
|
|
45
12
|
export interface ToolbarOptions {
|
|
46
|
-
/** EditorCore 实例 (必须) */
|
|
47
13
|
core: EditorCore;
|
|
48
|
-
/** 自定义按钮列表 (追加到内置按钮之后) */
|
|
49
14
|
extraButtons?: ToolbarButton[];
|
|
50
|
-
/** 是否显示缩放控制, 默认 true */
|
|
51
15
|
showZoom?: boolean;
|
|
52
|
-
/** 高度 (CSS值), 默认 '40px' */
|
|
53
16
|
height?: string;
|
|
17
|
+
onSave?: () => void | Promise<void>;
|
|
18
|
+
onDelete?: () => void;
|
|
19
|
+
onFullscreen?: () => void;
|
|
20
|
+
onAutoLayout?: () => void;
|
|
54
21
|
}
|
|
55
|
-
/**
|
|
56
|
-
* 纯 DOM 实现的编辑器工具栏
|
|
57
|
-
*
|
|
58
|
-
* 内置按钮:
|
|
59
|
-
* - ↩ 撤销 | ↪ 重做 | 🗑 删除 | 💾 保存 | ⛶ 全屏
|
|
60
|
-
* - 🔍+ 放大 | 🔍- 缩小 | 🔲 适应画布
|
|
61
|
-
*
|
|
62
|
-
* 通过 EditorCore.store.subscribe 监听 canUndo/canRedo 等状态,
|
|
63
|
-
* 动态切换按钮的 disabled 状态。
|
|
64
|
-
*/
|
|
65
22
|
export declare class Toolbar {
|
|
66
|
-
/** 外层容器 */
|
|
67
23
|
private container;
|
|
68
|
-
/** EditorCore 引用 */
|
|
69
24
|
private core;
|
|
70
|
-
/** 配置选项 */
|
|
71
25
|
private options;
|
|
72
|
-
/** 根 DOM 元素 */
|
|
73
26
|
private rootEl;
|
|
74
|
-
/** 状态订阅取消函数 */
|
|
75
27
|
private unsubscribe;
|
|
76
|
-
/** 按钮 DOM 映射 (id => element) */
|
|
77
28
|
private buttonElements;
|
|
78
29
|
constructor(container: HTMLElement, options: ToolbarOptions);
|
|
79
|
-
/**
|
|
80
|
-
* 挂载工具栏 DOM
|
|
81
|
-
*/
|
|
82
30
|
private mount;
|
|
83
|
-
/**
|
|
84
|
-
* 销毁工具栏
|
|
85
|
-
*/
|
|
86
31
|
destroy(): void;
|
|
87
|
-
/**
|
|
88
|
-
* 获取内置按钮列表
|
|
89
|
-
* @returns 内置按钮定义数组
|
|
90
|
-
*/
|
|
91
32
|
private getBuiltinButtons;
|
|
92
|
-
|
|
93
|
-
* 根据 EditorCore 的状态更新按钮的 disabled 属性
|
|
94
|
-
*/
|
|
33
|
+
private toolbarIcon;
|
|
95
34
|
private updateButtonStates;
|
|
96
|
-
/**
|
|
97
|
-
* 获取根 DOM 元素
|
|
98
|
-
*/
|
|
99
35
|
getElement(): HTMLElement | null;
|
|
100
36
|
private text;
|
|
101
|
-
/**
|
|
102
|
-
* 动态添加自定义按钮
|
|
103
|
-
* @param button - 按钮定义
|
|
104
|
-
*/
|
|
105
37
|
addButton(button: ToolbarButton): void;
|
|
106
38
|
}
|
|
107
|
-
//# sourceMappingURL=Toolbar.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ExplorerTreeStore, type EditorStatePersistenceOptions, type ExplorerTreePersistenceState, type ExplorerTreeState } from '@huanban/rulego-editor-core';
|
|
2
|
+
import type { WorkflowItem } from '@huanban/rulego-editor-core';
|
|
3
|
+
export interface WorkflowExplorerOptions {
|
|
4
|
+
workflows?: readonly WorkflowItem[];
|
|
5
|
+
store?: ExplorerTreeStore;
|
|
6
|
+
persistence?: EditorStatePersistenceOptions<ExplorerTreePersistenceState>;
|
|
7
|
+
activeChainId?: string;
|
|
8
|
+
keyword?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
emptyText?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
onKeywordChange?: (keyword: string) => void;
|
|
13
|
+
onOpen?: (workflow: WorkflowItem) => void;
|
|
14
|
+
virtualization?: {
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
threshold?: number;
|
|
17
|
+
itemHeight?: number;
|
|
18
|
+
viewportHeight?: number;
|
|
19
|
+
overscan?: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare class WorkflowExplorer {
|
|
23
|
+
private readonly container;
|
|
24
|
+
private readonly store;
|
|
25
|
+
private readonly ownedStore;
|
|
26
|
+
private readonly options;
|
|
27
|
+
private rootEl;
|
|
28
|
+
private searchInputEl;
|
|
29
|
+
private treeEl;
|
|
30
|
+
private unsubscribe;
|
|
31
|
+
private virtualScrollTop;
|
|
32
|
+
private autoScrolledActiveChainId;
|
|
33
|
+
private destroyed;
|
|
34
|
+
constructor(container: HTMLElement, options?: WorkflowExplorerOptions);
|
|
35
|
+
getState(): ExplorerTreeState;
|
|
36
|
+
getStore(): ExplorerTreeStore;
|
|
37
|
+
setWorkflows(workflows: readonly WorkflowItem[]): void;
|
|
38
|
+
setActiveChainId(chainId: string): void;
|
|
39
|
+
setKeyword(keyword: string): void;
|
|
40
|
+
destroy(): void;
|
|
41
|
+
private mount;
|
|
42
|
+
private renderState;
|
|
43
|
+
private createRow;
|
|
44
|
+
}
|
|
45
|
+
export default WorkflowExplorer;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file components/safeIcon.ts
|
|
3
|
-
* @description Safe icon rendering for DOM UI components.
|
|
4
|
-
*/
|
|
5
1
|
export type SafeIcon = {
|
|
6
2
|
kind: 'text';
|
|
7
3
|
value: string;
|
|
@@ -10,4 +6,3 @@ export type SafeIcon = {
|
|
|
10
6
|
svg: string;
|
|
11
7
|
};
|
|
12
8
|
export declare function appendSafeIcon(parent: HTMLElement, icon: SafeIcon | string | undefined): void;
|
|
13
|
-
//# sourceMappingURL=safeIcon.d.ts.map
|