drawui-core 0.5.1 → 0.5.3
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/IMAGE_UPLOAD.md +203 -0
- package/README.md +45 -3
- package/dist/index.cjs +24 -23
- package/dist/index.d.cts +144 -8
- package/dist/index.d.ts +144 -8
- package/dist/index.js +24 -23
- package/package.json +9 -2
package/dist/index.d.cts
CHANGED
|
@@ -567,6 +567,17 @@ declare function getTheme(): DrawuiTheme;
|
|
|
567
567
|
declare function hexToRgba(hex: string, alpha: number): string;
|
|
568
568
|
/** 颜色变暗/变亮:percent 负数变暗、正数变亮 */
|
|
569
569
|
declare function shadeColor(hex: string, percent: number): string;
|
|
570
|
+
/** 页面主题(画布背景 + UI 色调),与 react 层 theme.less 的 data-theme 一一对应 */
|
|
571
|
+
type PageTheme = 'light' | 'warm' | 'gray' | 'purple' | 'green' | 'eye-care';
|
|
572
|
+
/** 页面主题在 core 层需要覆盖的颜色 */
|
|
573
|
+
interface PageThemePreset {
|
|
574
|
+
/** 网格线颜色 */
|
|
575
|
+
grid: string;
|
|
576
|
+
}
|
|
577
|
+
/** 页面主题预设:网格颜色随背景深浅调整,保证可见但不突兀 */
|
|
578
|
+
declare const PAGE_THEMES: Record<PageTheme, PageThemePreset>;
|
|
579
|
+
/** 默认页面主题 */
|
|
580
|
+
declare const DEFAULT_PAGE_THEME: PageTheme;
|
|
570
581
|
|
|
571
582
|
/**
|
|
572
583
|
* 国际化:框架无关的轻量字典 + 语言切换。
|
|
@@ -662,11 +673,11 @@ declare const zhCN: {
|
|
|
662
673
|
readonly 'toolbar.grid': "网格";
|
|
663
674
|
readonly 'toolbar.undo': "撤销 (Ctrl+Z)";
|
|
664
675
|
readonly 'toolbar.redo': "重做 (Ctrl+Shift+Z)";
|
|
665
|
-
readonly 'toolbar.arrow': "箭头";
|
|
666
|
-
readonly 'toolbar.text': "文本";
|
|
676
|
+
readonly 'toolbar.arrow': "箭头 (A)";
|
|
677
|
+
readonly 'toolbar.text': "文本 (T)";
|
|
667
678
|
readonly 'toolbar.pen': "画笔";
|
|
668
679
|
readonly 'toolbar.highlighter': "荧光笔";
|
|
669
|
-
readonly 'toolbar.eraser': "橡皮擦";
|
|
680
|
+
readonly 'toolbar.eraser': "橡皮擦 (E)";
|
|
670
681
|
readonly 'toolbar.uml-class': "UML 类图";
|
|
671
682
|
readonly 'toolbar.uml-interface': "UML 接口";
|
|
672
683
|
readonly 'zoom.in': "放大";
|
|
@@ -758,6 +769,10 @@ declare const zhCN: {
|
|
|
758
769
|
readonly 'mindmap.expand': "展开";
|
|
759
770
|
readonly 'mindmap.close': "关闭编辑";
|
|
760
771
|
readonly 'mindmap.more': "更多设置";
|
|
772
|
+
readonly 'mindmap.level': "层级";
|
|
773
|
+
readonly 'mindmap.promote1': "升一级";
|
|
774
|
+
readonly 'mindmap.promote2': "升两级";
|
|
775
|
+
readonly 'mindmap.promoteDisabled': "已至顶层";
|
|
761
776
|
readonly 'tool.table': "表格";
|
|
762
777
|
readonly 'toolbar.table': "表格";
|
|
763
778
|
readonly 'shape.table': "表格";
|
|
@@ -773,7 +788,6 @@ declare const zhCN: {
|
|
|
773
788
|
readonly 'table.insertColRight': "在右侧插入列";
|
|
774
789
|
readonly 'table.pickHint': "拖选行列数";
|
|
775
790
|
readonly 'ctx.copy': "复制";
|
|
776
|
-
readonly 'ctx.copyAsImage': "复制为图片";
|
|
777
791
|
readonly 'ctx.paste': "粘贴";
|
|
778
792
|
readonly 'ctx.duplicate': "创建副本";
|
|
779
793
|
readonly 'ctx.layer': "层级";
|
|
@@ -792,8 +806,16 @@ declare const zhCN: {
|
|
|
792
806
|
readonly 'ctx.lock': "锁定";
|
|
793
807
|
readonly 'ctx.unlock': "解锁";
|
|
794
808
|
readonly 'ctx.delete': "删除";
|
|
795
|
-
readonly 'toolbar.icon': "图标";
|
|
809
|
+
readonly 'toolbar.icon': "图标 (S)";
|
|
796
810
|
readonly 'toolbar.image': "图片";
|
|
811
|
+
readonly 'toolbar.more': "更多";
|
|
812
|
+
readonly 'toolbar.pageTheme': "页面主题";
|
|
813
|
+
readonly 'pageTheme.light': "默认";
|
|
814
|
+
readonly 'pageTheme.warm': "暖黄";
|
|
815
|
+
readonly 'pageTheme.gray': "浅灰";
|
|
816
|
+
readonly 'pageTheme.purple': "浅紫";
|
|
817
|
+
readonly 'pageTheme.green': "浅绿";
|
|
818
|
+
readonly 'pageTheme.eye-care': "护眼";
|
|
797
819
|
readonly 'tool.image': "图片";
|
|
798
820
|
readonly 'image.uploadFailed': "图片上传失败";
|
|
799
821
|
readonly 'image.insertFailed': "图片插入失败";
|
|
@@ -812,6 +834,7 @@ declare const zhCN: {
|
|
|
812
834
|
readonly 'iconCat.arrow': "箭头方向";
|
|
813
835
|
readonly 'iconCat.misc': "常用";
|
|
814
836
|
readonly 'iconCat.emoji': "表情";
|
|
837
|
+
readonly 'iconCat.sticker': "贴纸";
|
|
815
838
|
readonly 'iconCat.device': "电脑设备";
|
|
816
839
|
readonly 'iconCat.weather': "天气";
|
|
817
840
|
readonly 'iconCat.transport': "交通";
|
|
@@ -947,6 +970,29 @@ declare function getMindMapNodeSiblings(root: MindMapNode, nodeId: string): {
|
|
|
947
970
|
* newIndex 是相对于同 direction siblings 的索引。
|
|
948
971
|
*/
|
|
949
972
|
declare function reorderMindMapNodeInTree(root: MindMapNode, nodeId: string, newIndex: number): MindMapNode;
|
|
973
|
+
/**
|
|
974
|
+
* 把节点「升级」levels 层:把 node 重新挂到它第 levels 层祖先之下,并紧挨着
|
|
975
|
+
* 它原来的直接祖先(即第 levels 层祖先的子节点)之后。
|
|
976
|
+
*
|
|
977
|
+
* - 升 1 层:node 成为「父节点的兄弟」(新父 = 祖父);
|
|
978
|
+
* - 升 2 层:node 成为「祖父节点的兄弟」(新父 = 曾祖父);
|
|
979
|
+
* - ……依此类推。
|
|
980
|
+
*
|
|
981
|
+
* 节点自身的子树(children)整体跟着一起上移,不会被拆散。
|
|
982
|
+
* 可行性由调用方判断:node 的 depth 必须 ≥ levels + 1(至少要有一个「新父」)。
|
|
983
|
+
* 不满足条件时原样返回 root(不改动)。
|
|
984
|
+
*/
|
|
985
|
+
declare function promoteMindMapNodeInTree(root: MindMapNode, nodeId: string, levels: number): MindMapNode;
|
|
986
|
+
/**
|
|
987
|
+
* 把节点「转移」到另一个父节点下,落在同方向兄弟组的 insertIndex 处。
|
|
988
|
+
* 用于拖拽换层级:把节点拖到某个节点上 → 成为该节点的兄弟。
|
|
989
|
+
*
|
|
990
|
+
* - 子树整体跟随,不被拆散;
|
|
991
|
+
* - 目标父节点落在被移动节点自身子树内(或就是它自己)时,原样返回,避免把树拆坏;
|
|
992
|
+
* - 目标父节点是根节点时,把节点 direction 设为目标兄弟组的方向(否则会被分到错误方向组);
|
|
993
|
+
* 目标是普通节点时清掉显式 direction,改为跟随新父节点的方向。
|
|
994
|
+
*/
|
|
995
|
+
declare function moveMindMapNodeInTree(root: MindMapNode, nodeId: string, targetParentId: string, direction: MindMapDirection, insertIndex: number): MindMapNode;
|
|
950
996
|
|
|
951
997
|
type Listener$1 = () => void;
|
|
952
998
|
type NotificationListener = (message: string) => void;
|
|
@@ -963,6 +1009,11 @@ type UiEvent = {
|
|
|
963
1009
|
| {
|
|
964
1010
|
kind: 'imageError';
|
|
965
1011
|
message: string;
|
|
1012
|
+
}
|
|
1013
|
+
/** 正在拖拽/调整图形(移动/缩放/旋转/拖连线端点或线段/从锚点拉新连线):React 侧据此临时隐藏顶栏工具条 */
|
|
1014
|
+
| {
|
|
1015
|
+
kind: 'drag';
|
|
1016
|
+
active: boolean;
|
|
966
1017
|
};
|
|
967
1018
|
/** Editor 构造选项:主题色 / 语言 / 初始数据 / 本地持久化开关 */
|
|
968
1019
|
interface EditorOptions {
|
|
@@ -997,6 +1048,8 @@ declare class Editor {
|
|
|
997
1048
|
private isPanning;
|
|
998
1049
|
private panStart;
|
|
999
1050
|
private dragStartPositions;
|
|
1051
|
+
/** 是否正处于「拖拽/调整图形」交互中:通过 UiEvent 'drag' 通知 React 临时隐藏顶栏工具条 */
|
|
1052
|
+
private interactionDragging;
|
|
1000
1053
|
private lastClickTime;
|
|
1001
1054
|
private lastClickShapeId;
|
|
1002
1055
|
private editingShapeId;
|
|
@@ -1014,6 +1067,13 @@ declare class Editor {
|
|
|
1014
1067
|
private hoverAnchorShapeId;
|
|
1015
1068
|
private hoverConnectorId;
|
|
1016
1069
|
private eraserPoint;
|
|
1070
|
+
/**
|
|
1071
|
+
* 橡皮擦「渐隐」中的图形:id → 开始时间戳。
|
|
1072
|
+
* 命中后不立刻从 shapes 里删掉,而是先让不透明度在 ERASE_FADE_MS 内降到 0,
|
|
1073
|
+
* 到点再真正移除(这样擦除是「变浅 → 消失」而不是「啪一下不见」)。
|
|
1074
|
+
*/
|
|
1075
|
+
private eraseFades;
|
|
1076
|
+
private eraseFadeRaf;
|
|
1017
1077
|
private mindMapEditingShapeId;
|
|
1018
1078
|
private mindMapSelectedNode;
|
|
1019
1079
|
private mindMapHoverNode;
|
|
@@ -1031,6 +1091,13 @@ declare class Editor {
|
|
|
1031
1091
|
* siblingIds 已按 cross 坐标排好序,方便 Renderer 直接画插入指示线。
|
|
1032
1092
|
*/
|
|
1033
1093
|
private mindMapReorderTarget;
|
|
1094
|
+
/**
|
|
1095
|
+
* 拖拽「换层级」计划。两种落点:
|
|
1096
|
+
* - `sibling`:拖到目标节点的**外侧**(框外 48px 内)→ 成为该节点的同方向兄弟(targetParent = 目标节点的父节点);
|
|
1097
|
+
* - `child`:拖到目标节点的**框内** → 成为该节点的子节点(targetParent = 目标节点自身)。
|
|
1098
|
+
* 与 mindMapReorderTarget 的区别:那个是「同父级内重排序」,这个是「换父级(换层级)」。
|
|
1099
|
+
*/
|
|
1100
|
+
private mindMapReparentPlan;
|
|
1034
1101
|
private tableSelection;
|
|
1035
1102
|
private tableEditing;
|
|
1036
1103
|
private renderScheduled;
|
|
@@ -1110,6 +1177,20 @@ declare class Editor {
|
|
|
1110
1177
|
private updateBoundArrows;
|
|
1111
1178
|
private getBindingPosition;
|
|
1112
1179
|
private deleteShape;
|
|
1180
|
+
/**
|
|
1181
|
+
* 橡皮擦命中:图形先进入「渐隐」再被真正删除(见 eraseFades)。
|
|
1182
|
+
* 历史快照在拖拽开始时已经打过,所以整段擦除仍然只占一个撤销点。
|
|
1183
|
+
*/
|
|
1184
|
+
private eraseShape;
|
|
1185
|
+
/** 渐隐时钟:每帧推进,到点的图形才真正删除;整批结束后停表 */
|
|
1186
|
+
private tickEraseFade;
|
|
1187
|
+
/** 当前帧各渐隐图形的不透明度(0~1);没有渐隐时返回 undefined,避免每帧建 Map */
|
|
1188
|
+
private eraseFadeMap;
|
|
1189
|
+
/**
|
|
1190
|
+
* 丢弃所有未完成的渐隐(撤销 / 重做 / 整体换数据时调用)。
|
|
1191
|
+
* 否则「撤销把图形救回来 → 渐隐计时器到点又把它删掉」会凭空吃掉一次撤销。
|
|
1192
|
+
*/
|
|
1193
|
+
private clearEraseFades;
|
|
1113
1194
|
/**
|
|
1114
1195
|
* 选中图形(additive=true 时切换选中态);id 为空串清空选中。右键菜单/外部控制用。
|
|
1115
1196
|
* ⚠️ 组感知:点任一成员都会选中它所属的整组(同组的绑行为一致),additive 时整组一起加减。
|
|
@@ -1198,6 +1279,8 @@ declare class Editor {
|
|
|
1198
1279
|
connectToExisting(context: GenerationContext, targetShapeId: string, binding?: ArrowBinding): void;
|
|
1199
1280
|
subscribeUi(listener: (payload: UiEvent) => void): () => boolean;
|
|
1200
1281
|
private emitUi;
|
|
1282
|
+
/** 同步「是否正在拖拽图形」状态:仅在实际变化时发出 UiEvent,避免每帧轰炸订阅者 */
|
|
1283
|
+
private setInteractionDragging;
|
|
1201
1284
|
/** 批量更新选中图形的样式(边框色、填充色等),提交历史记录 */
|
|
1202
1285
|
updateSelectedShapesStyle(updates: Partial<ShapeStyle>): void;
|
|
1203
1286
|
/** 批量更新选中图形的文字颜色/高亮背景色/高亮透明度,提交历史记录 */
|
|
@@ -1343,6 +1426,15 @@ declare class Editor {
|
|
|
1343
1426
|
private pageToMindMapLocal;
|
|
1344
1427
|
/** 计算拖拽节点时,在其同方向兄弟列表中的目标插入索引 */
|
|
1345
1428
|
private calcMindMapReorderTarget;
|
|
1429
|
+
/**
|
|
1430
|
+
* 结构变化后补偿导图中心的位移,让**根节点在屏幕上不动**。
|
|
1431
|
+
*
|
|
1432
|
+
* 背景:`layoutMindMap` 末尾会把包围盒中心对齐到导图中心,所以树一变宽/变高,
|
|
1433
|
+
* 所有节点都会整体平移 —— 换层级/增删节点时看起来就是「整张图跳了一下」。
|
|
1434
|
+
* 这里按根节点在旧/新布局中的局部坐标差反向平移导图中心,于是只有受影响的
|
|
1435
|
+
* 子树重排,画面不会整体滑走(XMind 等也是这样,居中主题是视觉锚点)。
|
|
1436
|
+
*/
|
|
1437
|
+
private anchorMindMapAtRoot;
|
|
1346
1438
|
/** 获取选中的思维导图(恰好选中一个时) */
|
|
1347
1439
|
getSelectedMindMap(): MindMapShape | null;
|
|
1348
1440
|
/** 页面坐标下的思维导图节点命中:返回所在导图与节点 id */
|
|
@@ -1361,6 +1453,21 @@ declare class Editor {
|
|
|
1361
1453
|
shapeId: string;
|
|
1362
1454
|
nodeId: string;
|
|
1363
1455
|
} | null;
|
|
1456
|
+
/**
|
|
1457
|
+
* 导图局部坐标下命中「某个节点框」的节点 id(拖拽换层级用)。
|
|
1458
|
+
* 排除 excludeNodeId 及其整棵子树 —— 否则会出现「把节点拖进自己的子树」这种非法落点。
|
|
1459
|
+
*/
|
|
1460
|
+
private hitMindMapNodeBox;
|
|
1461
|
+
/**
|
|
1462
|
+
* 「成为子节点」落点:目标节点 targetId 的子节点组信息。
|
|
1463
|
+
* - `direction`:该组子节点的生长方向(目标非根 = 布局算出的目标方向;目标是根 = 取 cross 上离指针最近的方向组);
|
|
1464
|
+
* - `childIds`:已有的同方向子节点 id(为空表示新节点会成为第一个孩子)。
|
|
1465
|
+
*/
|
|
1466
|
+
private mindMapChildGroup;
|
|
1467
|
+
/** 按 cross 坐标给同方向兄弟排序(Renderer 画落点占位框时要求同源顺序) */
|
|
1468
|
+
private mindMapSortByCross;
|
|
1469
|
+
/** 落点指示只在「真的变了」时更新(避免每帧 scheduleRender 抖动) */
|
|
1470
|
+
private setReorderIndicator;
|
|
1364
1471
|
/** 光标语义命中:仅节点框(含「+」快捷按钮、折叠/展开标记)内才命中,节点间空档不命中 */
|
|
1365
1472
|
getMindMapCursorHitAtPoint(point: Vec2): {
|
|
1366
1473
|
shapeId: string;
|
|
@@ -1427,10 +1534,23 @@ declare class Editor {
|
|
|
1427
1534
|
addMindMapSibling(shapeId: string, nodeId: string): void;
|
|
1428
1535
|
/** 将节点在其同方向兄弟列表中移动到目标索引 */
|
|
1429
1536
|
reorderMindMapNode(shapeId: string, nodeId: string, targetIndex: number): void;
|
|
1537
|
+
/**
|
|
1538
|
+
* 拖拽换层级:把节点移到目标父节点下、同方向兄弟组的 insertIndex 处。
|
|
1539
|
+
* 「拖到某个节点框上」= 成为该节点的同方向兄弟(即 targetParent = 该节点的父节点)。
|
|
1540
|
+
* 非法落点(目标是自己或自己的后代替)不修改文档。
|
|
1541
|
+
*/
|
|
1542
|
+
moveMindMapNodeToParent(shapeId: string, nodeId: string, targetParentId: string, direction: MindMapDirection, insertIndex: number): void;
|
|
1430
1543
|
/** 删除指定节点(含子树);删除根节点则移除整个思维导图 */
|
|
1431
1544
|
deleteMindMapNode(shapeId: string, nodeId: string): void;
|
|
1432
1545
|
/** 折叠/展开指定节点 */
|
|
1433
1546
|
toggleMindMapCollapse(shapeId: string, nodeId: string): void;
|
|
1547
|
+
/** 节点能否「升级」levels 层:depth 必须 ≥ levels + 1(至少得有个新父节点)。根节点不可升级。 */
|
|
1548
|
+
canPromoteMindMapNode(shapeId: string, nodeId: string, levels: number): boolean;
|
|
1549
|
+
/**
|
|
1550
|
+
* 把节点升级 levels 层(升 1 层 = 成为父节点的兄弟;升 2 层 = 成为祖父节点的兄弟)。
|
|
1551
|
+
* 节点自身子树整体上移,不被拆散。不可升级时(已到顶层)直接返回,不改动文档。
|
|
1552
|
+
*/
|
|
1553
|
+
promoteMindMapNode(shapeId: string, nodeId: string, levels: number): void;
|
|
1434
1554
|
/** 获取选中的表格(恰好选中一个时) */
|
|
1435
1555
|
getSelectedTable(): TableShape | null;
|
|
1436
1556
|
private getTableById;
|
|
@@ -1823,13 +1943,17 @@ declare class Renderer {
|
|
|
1823
1943
|
targetIndex: number;
|
|
1824
1944
|
direction: MindMapDirection;
|
|
1825
1945
|
siblingIds: string[];
|
|
1946
|
+
/** 「成为子节点」模式:目标节点 id(高亮它 + 子组为空时定位占位框) */
|
|
1947
|
+
childParentId?: string;
|
|
1826
1948
|
} | null,
|
|
1827
1949
|
/** 导出用:非 null 时先以该颜色铺满整块画布(白底等),默认不铺(透明) */
|
|
1828
1950
|
background?: string | null,
|
|
1829
1951
|
/** 悬停的图形 id:为其绘制四边连接锚点(飞书式悬浮提示),已选中图形由选择手柄负责 */
|
|
1830
1952
|
hoverAnchorShapeId?: string | null,
|
|
1831
1953
|
/** 悬停的连线 id:整条线描一层浅蓝高亮(提示「这条线可点、点开能调线段」) */
|
|
1832
|
-
hoverConnectorId?: string | null
|
|
1954
|
+
hoverConnectorId?: string | null,
|
|
1955
|
+
/** 橡皮擦渐隐:图形 id → 不透明度(0~1)。缺省时不改任何图形的透明度 */
|
|
1956
|
+
eraseFade?: Map<string, number> | null): void;
|
|
1833
1957
|
/** 橡皮擦:半透明主色圆 + 主色描边,半径与笔刷命中范围一致(屏幕像素恒定) */
|
|
1834
1958
|
private drawEraserBrush;
|
|
1835
1959
|
/** 连接进行中,高亮目标图形四边中点的可连锚点 */
|
|
@@ -2185,7 +2309,7 @@ declare const ICON_CATEGORIES: {
|
|
|
2185
2309
|
id: IconCategoryId;
|
|
2186
2310
|
labelKey: MessageKey;
|
|
2187
2311
|
}[];
|
|
2188
|
-
type IconCategoryId = 'status' | 'number' | 'emoji' | 'device' | 'tech' | 'chart' | 'office' | 'media' | 'arrow' | 'misc' | 'weather' | 'transport' | 'nature' | 'building' | 'medical' | 'shopping' | 'science' | 'animal' | 'time' | 'edit' | 'food' | 'communication';
|
|
2312
|
+
type IconCategoryId = 'status' | 'number' | 'emoji' | 'sticker' | 'device' | 'tech' | 'chart' | 'office' | 'media' | 'arrow' | 'misc' | 'weather' | 'transport' | 'nature' | 'building' | 'medical' | 'shopping' | 'science' | 'animal' | 'time' | 'edit' | 'food' | 'communication';
|
|
2189
2313
|
interface IconLayer {
|
|
2190
2314
|
/** 24×24 网格内的路径(语法同 SVG path,统一大写指令) */
|
|
2191
2315
|
d: string;
|
|
@@ -2322,6 +2446,8 @@ interface ToolContext {
|
|
|
2322
2446
|
addShape(shape: Shape): void;
|
|
2323
2447
|
updateShape(id: string, updates: Partial<Shape>): void;
|
|
2324
2448
|
deleteShape(id: string): void;
|
|
2449
|
+
/** 橡皮擦专用:先渐隐再删除(普通删除请用 deleteShape) */
|
|
2450
|
+
eraseShape(id: string): void;
|
|
2325
2451
|
selectShape(id: string, additive: boolean): void;
|
|
2326
2452
|
selectShapes(ids: string[]): void;
|
|
2327
2453
|
getShapes(): Shape[];
|
|
@@ -2416,6 +2542,11 @@ declare abstract class Tool {
|
|
|
2416
2542
|
* @returns 是否确实清理了状态(false = 本来就是空闲态,调用方可跳过重绘)
|
|
2417
2543
|
*/
|
|
2418
2544
|
cancelTransient(): boolean;
|
|
2545
|
+
/**
|
|
2546
|
+
* 是否正处于「拖拽/调整图形」中(移动/缩放/旋转图形、拖连线端点或线段、从锚点拉新连线)。
|
|
2547
|
+
* 默认 false;选择工具等会覆盖,供编辑器据此临时隐藏顶栏工具条。
|
|
2548
|
+
*/
|
|
2549
|
+
isDragging(): boolean;
|
|
2419
2550
|
dispose(): void;
|
|
2420
2551
|
}
|
|
2421
2552
|
|
|
@@ -2510,6 +2641,11 @@ declare class SelectTool extends Tool {
|
|
|
2510
2641
|
*/
|
|
2511
2642
|
private finishSegmentDrag;
|
|
2512
2643
|
hasTransientState(): boolean;
|
|
2644
|
+
/**
|
|
2645
|
+
* 拖拽/调整图形中:移动、缩放、旋转、拖连线端点、拖线段、从锚点拉新连线。
|
|
2646
|
+
* (框选空白、表格内框选单元格不算「拖图形」,不触发顶栏隐藏。)
|
|
2647
|
+
*/
|
|
2648
|
+
isDragging(): boolean;
|
|
2513
2649
|
/**
|
|
2514
2650
|
* 取消一切瞬态交互(拖拽/生成/框选/旋转/连线端点拖拽)并清掉画布上的瞬态预览。
|
|
2515
2651
|
* 触发场景:指针在窗口外松手丢失 pointerup、窗口失焦、点击画布外、无按压的移动、
|
|
@@ -2987,4 +3123,4 @@ declare function imageDataUrl(src: string): string | null;
|
|
|
2987
3123
|
/** 清空缓存(测试/卸载时用;会释放自己创建的 blob 地址) */
|
|
2988
3124
|
declare function clearImageCache(): void;
|
|
2989
3125
|
|
|
2990
|
-
export { type ArrowBinding, type ArrowHeadType, type ArrowShape, type ArrowStyle, ArrowTool, BoardExtentKeeper, type BoardExtentResult, type BoardExtentUpdate, Camera, type CameraState, type CircleShape, type ConnectionType, DEFAULT_HIGHLIGHTER_COLOR, DEFAULT_IMAGE_MAX_SIZE_BYTES, type DiamondShape, type DrawShape, type DrawuiTheme, type DrawuiThemeSelection, Editor, type EditorData, type EditorOptions, type EditorState, type EllipseShape, type ExportFormat, type ExportOptions, type FreehandMode, FreehandTool, type GenerationContext, HandTool, type HexagonShape, ICONS, ICON_CATEGORIES, ICON_CATEGORY_INK, ICON_DEFAULT_INK, ICON_DEFAULT_SIZE, ICON_GRID, type IconCategoryId, type IconDef, type IconLayer, type IconShape, type ImageShape, type ImageUploadConfig, type ImageUploadOption, type ImageUploader, LANGUAGES, type Language, type LineShape, LineTool, MINDMAP_COLORS, MINDMAP_DIRECTIONS, MINDMAP_FONT_SIZE, MINDMAP_HANDLE_HIT_RADIUS, MINDMAP_HANDLE_RADIUS, MINDMAP_MAX_WIDTH, MINDMAP_MIN_WIDTH, MINDMAP_NODE_HEIGHT, MIN_HANDLE_SEGMENT, MIN_JOG, Mat2d, type MessageKey, type MindMapDirection, type MindMapHandleKind, type MindMapHandlePos, type MindMapLayoutResult, type MindMapNode, type MindMapNodePos, type MindMapShape, type OctagonShape, type ParallelogramShape, type PentagonShape, type Rect, type RectangleShape, Renderer, type RoundedRectangleShape, STICKY_FOLD_RATIO, STICKY_NOTE_COLORS, STICKY_NOTE_DEFAULT_COLOR, STICKY_TEXT_SCALE, type SegmentHandle, SelectTool, type Shape, type ShapeStyle, ShapeTool, type ShapeType, type SnapGuide, type StarShape, type StickyNoteShape, TABLE_CELL_PADDING_X, TABLE_CELL_PADDING_Y, TABLE_DEFAULT_COL_WIDTH, TABLE_DEFAULT_ROW_HEIGHT, TABLE_FONT_SIZE, TABLE_HEADER_FILL, TABLE_LINE_HEIGHT_RATIO, TABLE_MAX_AUTO_LINES, TABLE_MIN_COL_WIDTH, TABLE_MIN_ROW_HEIGHT, TABLE_MOVE_HANDLE_GAP, TABLE_MOVE_HANDLE_HEIGHT, TABLE_MOVE_HANDLE_WIDTH, THEME, type TableCell, type TableShape, type TextShape, type ToolType, type TrapezoidShape, type TriangleShape, UML_FONT_SIZE, UML_HEADER_HEIGHT, UML_LINE_HEIGHT, UML_MIN_WIDTH, UML_PADDING_X, UML_PADDING_Y, type UiEvent, type UmlAttribute, type UmlClassShape, type UmlInterfaceShape, type UmlMethod, type UmlVisibility, Vec, type Vec2 as Vec2Type, addImageReadyListener, calcUmlClassSize, clearImageCache, cloneMindMapNode, cloneTable, cloneTableCells, collapseRoute, collectTemporaryImageSrcs, connectorSegmentHandles, countMindMapNodes, createTableCells, downloadBlob, effectiveDirection, ensureImagesLoaded, exportToBlob, findMindMapNode, getContentBounds, getIcon, getLanguage, getMindMapNodeDepth, getMindMapNodeSiblings, getMindMapParent, getTheme, hasIcon, hexToRgba, hitTableBody, hitTableMoveHandle, iconInk, iconsByCategory, imageDataUrl, isEmptyRect, isFlippableShapeType, isHorizontalDirection, isImageFailed, isImageLoading, isStubCorner, isUploaderFunction, layoutMindMap, loadImage, mindMapHandleAtLocalPoint, mindMapNodeColor, mindMapNodeHandles, mindMapNodeSize, offsetConnectorSegment, parseUploadResponse, peekImage, pickSegmentHandle, pointToSegmentDistance, pruneStubBends, rectsIntersect, renderSVGString, renderToCanvas, reorderMindMapNodeInTree, routeToUserPoints, sameRoute, searchIcons, setImageCrossOrigin, setLanguage, setTheme, shadeColor, subscribeLanguage, subscribeTheme, subtractUnion, t, tableAnchorAt, tableCellAtLocalClamped, tableCellLineCount, tableCellLocalRect, tableCellTextStartOffset, tableCoveredMap, tableDeleteColumn, tableDeleteRow, tableExpandRangeToMerges, tableGrowRowHeights, tableInsertColumn, tableInsertRow, tableLocalPoint, tableMerge, tableMoveHandleLocalRect, tablePagePoint, tableRangeHasMerge, tableRangeLocalRect, tableRowAtPoint, tableSplit, tableSplitRange, tableTotalHeight, tableTotalWidth, umlAttrRowText, umlMethodRowText, unionRect, uploadImageViaConfig };
|
|
3126
|
+
export { type ArrowBinding, type ArrowHeadType, type ArrowShape, type ArrowStyle, ArrowTool, BoardExtentKeeper, type BoardExtentResult, type BoardExtentUpdate, Camera, type CameraState, type CircleShape, type ConnectionType, DEFAULT_HIGHLIGHTER_COLOR, DEFAULT_IMAGE_MAX_SIZE_BYTES, DEFAULT_PAGE_THEME, type DiamondShape, type DrawShape, type DrawuiTheme, type DrawuiThemeSelection, Editor, type EditorData, type EditorOptions, type EditorState, type EllipseShape, type ExportFormat, type ExportOptions, type FreehandMode, FreehandTool, type GenerationContext, HandTool, type HexagonShape, ICONS, ICON_CATEGORIES, ICON_CATEGORY_INK, ICON_DEFAULT_INK, ICON_DEFAULT_SIZE, ICON_GRID, type IconCategoryId, type IconDef, type IconLayer, type IconShape, type ImageShape, type ImageUploadConfig, type ImageUploadOption, type ImageUploader, LANGUAGES, type Language, type LineShape, LineTool, MINDMAP_COLORS, MINDMAP_DIRECTIONS, MINDMAP_FONT_SIZE, MINDMAP_HANDLE_HIT_RADIUS, MINDMAP_HANDLE_RADIUS, MINDMAP_MAX_WIDTH, MINDMAP_MIN_WIDTH, MINDMAP_NODE_HEIGHT, MIN_HANDLE_SEGMENT, MIN_JOG, Mat2d, type MessageKey, type MindMapDirection, type MindMapHandleKind, type MindMapHandlePos, type MindMapLayoutResult, type MindMapNode, type MindMapNodePos, type MindMapShape, type OctagonShape, PAGE_THEMES, type PageTheme, type PageThemePreset, type ParallelogramShape, type PentagonShape, type Rect, type RectangleShape, Renderer, type RoundedRectangleShape, STICKY_FOLD_RATIO, STICKY_NOTE_COLORS, STICKY_NOTE_DEFAULT_COLOR, STICKY_TEXT_SCALE, type SegmentHandle, SelectTool, type Shape, type ShapeStyle, ShapeTool, type ShapeType, type SnapGuide, type StarShape, type StickyNoteShape, TABLE_CELL_PADDING_X, TABLE_CELL_PADDING_Y, TABLE_DEFAULT_COL_WIDTH, TABLE_DEFAULT_ROW_HEIGHT, TABLE_FONT_SIZE, TABLE_HEADER_FILL, TABLE_LINE_HEIGHT_RATIO, TABLE_MAX_AUTO_LINES, TABLE_MIN_COL_WIDTH, TABLE_MIN_ROW_HEIGHT, TABLE_MOVE_HANDLE_GAP, TABLE_MOVE_HANDLE_HEIGHT, TABLE_MOVE_HANDLE_WIDTH, THEME, type TableCell, type TableShape, type TextShape, type ToolType, type TrapezoidShape, type TriangleShape, UML_FONT_SIZE, UML_HEADER_HEIGHT, UML_LINE_HEIGHT, UML_MIN_WIDTH, UML_PADDING_X, UML_PADDING_Y, type UiEvent, type UmlAttribute, type UmlClassShape, type UmlInterfaceShape, type UmlMethod, type UmlVisibility, Vec, type Vec2 as Vec2Type, addImageReadyListener, calcUmlClassSize, clearImageCache, cloneMindMapNode, cloneTable, cloneTableCells, collapseRoute, collectTemporaryImageSrcs, connectorSegmentHandles, countMindMapNodes, createTableCells, downloadBlob, effectiveDirection, ensureImagesLoaded, exportToBlob, findMindMapNode, getContentBounds, getIcon, getLanguage, getMindMapNodeDepth, getMindMapNodeSiblings, getMindMapParent, getTheme, hasIcon, hexToRgba, hitTableBody, hitTableMoveHandle, iconInk, iconsByCategory, imageDataUrl, isEmptyRect, isFlippableShapeType, isHorizontalDirection, isImageFailed, isImageLoading, isStubCorner, isUploaderFunction, layoutMindMap, loadImage, mindMapHandleAtLocalPoint, mindMapNodeColor, mindMapNodeHandles, mindMapNodeSize, moveMindMapNodeInTree, offsetConnectorSegment, parseUploadResponse, peekImage, pickSegmentHandle, pointToSegmentDistance, promoteMindMapNodeInTree, pruneStubBends, rectsIntersect, renderSVGString, renderToCanvas, reorderMindMapNodeInTree, routeToUserPoints, sameRoute, searchIcons, setImageCrossOrigin, setLanguage, setTheme, shadeColor, subscribeLanguage, subscribeTheme, subtractUnion, t, tableAnchorAt, tableCellAtLocalClamped, tableCellLineCount, tableCellLocalRect, tableCellTextStartOffset, tableCoveredMap, tableDeleteColumn, tableDeleteRow, tableExpandRangeToMerges, tableGrowRowHeights, tableInsertColumn, tableInsertRow, tableLocalPoint, tableMerge, tableMoveHandleLocalRect, tablePagePoint, tableRangeHasMerge, tableRangeLocalRect, tableRowAtPoint, tableSplit, tableSplitRange, tableTotalHeight, tableTotalWidth, umlAttrRowText, umlMethodRowText, unionRect, uploadImageViaConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -567,6 +567,17 @@ declare function getTheme(): DrawuiTheme;
|
|
|
567
567
|
declare function hexToRgba(hex: string, alpha: number): string;
|
|
568
568
|
/** 颜色变暗/变亮:percent 负数变暗、正数变亮 */
|
|
569
569
|
declare function shadeColor(hex: string, percent: number): string;
|
|
570
|
+
/** 页面主题(画布背景 + UI 色调),与 react 层 theme.less 的 data-theme 一一对应 */
|
|
571
|
+
type PageTheme = 'light' | 'warm' | 'gray' | 'purple' | 'green' | 'eye-care';
|
|
572
|
+
/** 页面主题在 core 层需要覆盖的颜色 */
|
|
573
|
+
interface PageThemePreset {
|
|
574
|
+
/** 网格线颜色 */
|
|
575
|
+
grid: string;
|
|
576
|
+
}
|
|
577
|
+
/** 页面主题预设:网格颜色随背景深浅调整,保证可见但不突兀 */
|
|
578
|
+
declare const PAGE_THEMES: Record<PageTheme, PageThemePreset>;
|
|
579
|
+
/** 默认页面主题 */
|
|
580
|
+
declare const DEFAULT_PAGE_THEME: PageTheme;
|
|
570
581
|
|
|
571
582
|
/**
|
|
572
583
|
* 国际化:框架无关的轻量字典 + 语言切换。
|
|
@@ -662,11 +673,11 @@ declare const zhCN: {
|
|
|
662
673
|
readonly 'toolbar.grid': "网格";
|
|
663
674
|
readonly 'toolbar.undo': "撤销 (Ctrl+Z)";
|
|
664
675
|
readonly 'toolbar.redo': "重做 (Ctrl+Shift+Z)";
|
|
665
|
-
readonly 'toolbar.arrow': "箭头";
|
|
666
|
-
readonly 'toolbar.text': "文本";
|
|
676
|
+
readonly 'toolbar.arrow': "箭头 (A)";
|
|
677
|
+
readonly 'toolbar.text': "文本 (T)";
|
|
667
678
|
readonly 'toolbar.pen': "画笔";
|
|
668
679
|
readonly 'toolbar.highlighter': "荧光笔";
|
|
669
|
-
readonly 'toolbar.eraser': "橡皮擦";
|
|
680
|
+
readonly 'toolbar.eraser': "橡皮擦 (E)";
|
|
670
681
|
readonly 'toolbar.uml-class': "UML 类图";
|
|
671
682
|
readonly 'toolbar.uml-interface': "UML 接口";
|
|
672
683
|
readonly 'zoom.in': "放大";
|
|
@@ -758,6 +769,10 @@ declare const zhCN: {
|
|
|
758
769
|
readonly 'mindmap.expand': "展开";
|
|
759
770
|
readonly 'mindmap.close': "关闭编辑";
|
|
760
771
|
readonly 'mindmap.more': "更多设置";
|
|
772
|
+
readonly 'mindmap.level': "层级";
|
|
773
|
+
readonly 'mindmap.promote1': "升一级";
|
|
774
|
+
readonly 'mindmap.promote2': "升两级";
|
|
775
|
+
readonly 'mindmap.promoteDisabled': "已至顶层";
|
|
761
776
|
readonly 'tool.table': "表格";
|
|
762
777
|
readonly 'toolbar.table': "表格";
|
|
763
778
|
readonly 'shape.table': "表格";
|
|
@@ -773,7 +788,6 @@ declare const zhCN: {
|
|
|
773
788
|
readonly 'table.insertColRight': "在右侧插入列";
|
|
774
789
|
readonly 'table.pickHint': "拖选行列数";
|
|
775
790
|
readonly 'ctx.copy': "复制";
|
|
776
|
-
readonly 'ctx.copyAsImage': "复制为图片";
|
|
777
791
|
readonly 'ctx.paste': "粘贴";
|
|
778
792
|
readonly 'ctx.duplicate': "创建副本";
|
|
779
793
|
readonly 'ctx.layer': "层级";
|
|
@@ -792,8 +806,16 @@ declare const zhCN: {
|
|
|
792
806
|
readonly 'ctx.lock': "锁定";
|
|
793
807
|
readonly 'ctx.unlock': "解锁";
|
|
794
808
|
readonly 'ctx.delete': "删除";
|
|
795
|
-
readonly 'toolbar.icon': "图标";
|
|
809
|
+
readonly 'toolbar.icon': "图标 (S)";
|
|
796
810
|
readonly 'toolbar.image': "图片";
|
|
811
|
+
readonly 'toolbar.more': "更多";
|
|
812
|
+
readonly 'toolbar.pageTheme': "页面主题";
|
|
813
|
+
readonly 'pageTheme.light': "默认";
|
|
814
|
+
readonly 'pageTheme.warm': "暖黄";
|
|
815
|
+
readonly 'pageTheme.gray': "浅灰";
|
|
816
|
+
readonly 'pageTheme.purple': "浅紫";
|
|
817
|
+
readonly 'pageTheme.green': "浅绿";
|
|
818
|
+
readonly 'pageTheme.eye-care': "护眼";
|
|
797
819
|
readonly 'tool.image': "图片";
|
|
798
820
|
readonly 'image.uploadFailed': "图片上传失败";
|
|
799
821
|
readonly 'image.insertFailed': "图片插入失败";
|
|
@@ -812,6 +834,7 @@ declare const zhCN: {
|
|
|
812
834
|
readonly 'iconCat.arrow': "箭头方向";
|
|
813
835
|
readonly 'iconCat.misc': "常用";
|
|
814
836
|
readonly 'iconCat.emoji': "表情";
|
|
837
|
+
readonly 'iconCat.sticker': "贴纸";
|
|
815
838
|
readonly 'iconCat.device': "电脑设备";
|
|
816
839
|
readonly 'iconCat.weather': "天气";
|
|
817
840
|
readonly 'iconCat.transport': "交通";
|
|
@@ -947,6 +970,29 @@ declare function getMindMapNodeSiblings(root: MindMapNode, nodeId: string): {
|
|
|
947
970
|
* newIndex 是相对于同 direction siblings 的索引。
|
|
948
971
|
*/
|
|
949
972
|
declare function reorderMindMapNodeInTree(root: MindMapNode, nodeId: string, newIndex: number): MindMapNode;
|
|
973
|
+
/**
|
|
974
|
+
* 把节点「升级」levels 层:把 node 重新挂到它第 levels 层祖先之下,并紧挨着
|
|
975
|
+
* 它原来的直接祖先(即第 levels 层祖先的子节点)之后。
|
|
976
|
+
*
|
|
977
|
+
* - 升 1 层:node 成为「父节点的兄弟」(新父 = 祖父);
|
|
978
|
+
* - 升 2 层:node 成为「祖父节点的兄弟」(新父 = 曾祖父);
|
|
979
|
+
* - ……依此类推。
|
|
980
|
+
*
|
|
981
|
+
* 节点自身的子树(children)整体跟着一起上移,不会被拆散。
|
|
982
|
+
* 可行性由调用方判断:node 的 depth 必须 ≥ levels + 1(至少要有一个「新父」)。
|
|
983
|
+
* 不满足条件时原样返回 root(不改动)。
|
|
984
|
+
*/
|
|
985
|
+
declare function promoteMindMapNodeInTree(root: MindMapNode, nodeId: string, levels: number): MindMapNode;
|
|
986
|
+
/**
|
|
987
|
+
* 把节点「转移」到另一个父节点下,落在同方向兄弟组的 insertIndex 处。
|
|
988
|
+
* 用于拖拽换层级:把节点拖到某个节点上 → 成为该节点的兄弟。
|
|
989
|
+
*
|
|
990
|
+
* - 子树整体跟随,不被拆散;
|
|
991
|
+
* - 目标父节点落在被移动节点自身子树内(或就是它自己)时,原样返回,避免把树拆坏;
|
|
992
|
+
* - 目标父节点是根节点时,把节点 direction 设为目标兄弟组的方向(否则会被分到错误方向组);
|
|
993
|
+
* 目标是普通节点时清掉显式 direction,改为跟随新父节点的方向。
|
|
994
|
+
*/
|
|
995
|
+
declare function moveMindMapNodeInTree(root: MindMapNode, nodeId: string, targetParentId: string, direction: MindMapDirection, insertIndex: number): MindMapNode;
|
|
950
996
|
|
|
951
997
|
type Listener$1 = () => void;
|
|
952
998
|
type NotificationListener = (message: string) => void;
|
|
@@ -963,6 +1009,11 @@ type UiEvent = {
|
|
|
963
1009
|
| {
|
|
964
1010
|
kind: 'imageError';
|
|
965
1011
|
message: string;
|
|
1012
|
+
}
|
|
1013
|
+
/** 正在拖拽/调整图形(移动/缩放/旋转/拖连线端点或线段/从锚点拉新连线):React 侧据此临时隐藏顶栏工具条 */
|
|
1014
|
+
| {
|
|
1015
|
+
kind: 'drag';
|
|
1016
|
+
active: boolean;
|
|
966
1017
|
};
|
|
967
1018
|
/** Editor 构造选项:主题色 / 语言 / 初始数据 / 本地持久化开关 */
|
|
968
1019
|
interface EditorOptions {
|
|
@@ -997,6 +1048,8 @@ declare class Editor {
|
|
|
997
1048
|
private isPanning;
|
|
998
1049
|
private panStart;
|
|
999
1050
|
private dragStartPositions;
|
|
1051
|
+
/** 是否正处于「拖拽/调整图形」交互中:通过 UiEvent 'drag' 通知 React 临时隐藏顶栏工具条 */
|
|
1052
|
+
private interactionDragging;
|
|
1000
1053
|
private lastClickTime;
|
|
1001
1054
|
private lastClickShapeId;
|
|
1002
1055
|
private editingShapeId;
|
|
@@ -1014,6 +1067,13 @@ declare class Editor {
|
|
|
1014
1067
|
private hoverAnchorShapeId;
|
|
1015
1068
|
private hoverConnectorId;
|
|
1016
1069
|
private eraserPoint;
|
|
1070
|
+
/**
|
|
1071
|
+
* 橡皮擦「渐隐」中的图形:id → 开始时间戳。
|
|
1072
|
+
* 命中后不立刻从 shapes 里删掉,而是先让不透明度在 ERASE_FADE_MS 内降到 0,
|
|
1073
|
+
* 到点再真正移除(这样擦除是「变浅 → 消失」而不是「啪一下不见」)。
|
|
1074
|
+
*/
|
|
1075
|
+
private eraseFades;
|
|
1076
|
+
private eraseFadeRaf;
|
|
1017
1077
|
private mindMapEditingShapeId;
|
|
1018
1078
|
private mindMapSelectedNode;
|
|
1019
1079
|
private mindMapHoverNode;
|
|
@@ -1031,6 +1091,13 @@ declare class Editor {
|
|
|
1031
1091
|
* siblingIds 已按 cross 坐标排好序,方便 Renderer 直接画插入指示线。
|
|
1032
1092
|
*/
|
|
1033
1093
|
private mindMapReorderTarget;
|
|
1094
|
+
/**
|
|
1095
|
+
* 拖拽「换层级」计划。两种落点:
|
|
1096
|
+
* - `sibling`:拖到目标节点的**外侧**(框外 48px 内)→ 成为该节点的同方向兄弟(targetParent = 目标节点的父节点);
|
|
1097
|
+
* - `child`:拖到目标节点的**框内** → 成为该节点的子节点(targetParent = 目标节点自身)。
|
|
1098
|
+
* 与 mindMapReorderTarget 的区别:那个是「同父级内重排序」,这个是「换父级(换层级)」。
|
|
1099
|
+
*/
|
|
1100
|
+
private mindMapReparentPlan;
|
|
1034
1101
|
private tableSelection;
|
|
1035
1102
|
private tableEditing;
|
|
1036
1103
|
private renderScheduled;
|
|
@@ -1110,6 +1177,20 @@ declare class Editor {
|
|
|
1110
1177
|
private updateBoundArrows;
|
|
1111
1178
|
private getBindingPosition;
|
|
1112
1179
|
private deleteShape;
|
|
1180
|
+
/**
|
|
1181
|
+
* 橡皮擦命中:图形先进入「渐隐」再被真正删除(见 eraseFades)。
|
|
1182
|
+
* 历史快照在拖拽开始时已经打过,所以整段擦除仍然只占一个撤销点。
|
|
1183
|
+
*/
|
|
1184
|
+
private eraseShape;
|
|
1185
|
+
/** 渐隐时钟:每帧推进,到点的图形才真正删除;整批结束后停表 */
|
|
1186
|
+
private tickEraseFade;
|
|
1187
|
+
/** 当前帧各渐隐图形的不透明度(0~1);没有渐隐时返回 undefined,避免每帧建 Map */
|
|
1188
|
+
private eraseFadeMap;
|
|
1189
|
+
/**
|
|
1190
|
+
* 丢弃所有未完成的渐隐(撤销 / 重做 / 整体换数据时调用)。
|
|
1191
|
+
* 否则「撤销把图形救回来 → 渐隐计时器到点又把它删掉」会凭空吃掉一次撤销。
|
|
1192
|
+
*/
|
|
1193
|
+
private clearEraseFades;
|
|
1113
1194
|
/**
|
|
1114
1195
|
* 选中图形(additive=true 时切换选中态);id 为空串清空选中。右键菜单/外部控制用。
|
|
1115
1196
|
* ⚠️ 组感知:点任一成员都会选中它所属的整组(同组的绑行为一致),additive 时整组一起加减。
|
|
@@ -1198,6 +1279,8 @@ declare class Editor {
|
|
|
1198
1279
|
connectToExisting(context: GenerationContext, targetShapeId: string, binding?: ArrowBinding): void;
|
|
1199
1280
|
subscribeUi(listener: (payload: UiEvent) => void): () => boolean;
|
|
1200
1281
|
private emitUi;
|
|
1282
|
+
/** 同步「是否正在拖拽图形」状态:仅在实际变化时发出 UiEvent,避免每帧轰炸订阅者 */
|
|
1283
|
+
private setInteractionDragging;
|
|
1201
1284
|
/** 批量更新选中图形的样式(边框色、填充色等),提交历史记录 */
|
|
1202
1285
|
updateSelectedShapesStyle(updates: Partial<ShapeStyle>): void;
|
|
1203
1286
|
/** 批量更新选中图形的文字颜色/高亮背景色/高亮透明度,提交历史记录 */
|
|
@@ -1343,6 +1426,15 @@ declare class Editor {
|
|
|
1343
1426
|
private pageToMindMapLocal;
|
|
1344
1427
|
/** 计算拖拽节点时,在其同方向兄弟列表中的目标插入索引 */
|
|
1345
1428
|
private calcMindMapReorderTarget;
|
|
1429
|
+
/**
|
|
1430
|
+
* 结构变化后补偿导图中心的位移,让**根节点在屏幕上不动**。
|
|
1431
|
+
*
|
|
1432
|
+
* 背景:`layoutMindMap` 末尾会把包围盒中心对齐到导图中心,所以树一变宽/变高,
|
|
1433
|
+
* 所有节点都会整体平移 —— 换层级/增删节点时看起来就是「整张图跳了一下」。
|
|
1434
|
+
* 这里按根节点在旧/新布局中的局部坐标差反向平移导图中心,于是只有受影响的
|
|
1435
|
+
* 子树重排,画面不会整体滑走(XMind 等也是这样,居中主题是视觉锚点)。
|
|
1436
|
+
*/
|
|
1437
|
+
private anchorMindMapAtRoot;
|
|
1346
1438
|
/** 获取选中的思维导图(恰好选中一个时) */
|
|
1347
1439
|
getSelectedMindMap(): MindMapShape | null;
|
|
1348
1440
|
/** 页面坐标下的思维导图节点命中:返回所在导图与节点 id */
|
|
@@ -1361,6 +1453,21 @@ declare class Editor {
|
|
|
1361
1453
|
shapeId: string;
|
|
1362
1454
|
nodeId: string;
|
|
1363
1455
|
} | null;
|
|
1456
|
+
/**
|
|
1457
|
+
* 导图局部坐标下命中「某个节点框」的节点 id(拖拽换层级用)。
|
|
1458
|
+
* 排除 excludeNodeId 及其整棵子树 —— 否则会出现「把节点拖进自己的子树」这种非法落点。
|
|
1459
|
+
*/
|
|
1460
|
+
private hitMindMapNodeBox;
|
|
1461
|
+
/**
|
|
1462
|
+
* 「成为子节点」落点:目标节点 targetId 的子节点组信息。
|
|
1463
|
+
* - `direction`:该组子节点的生长方向(目标非根 = 布局算出的目标方向;目标是根 = 取 cross 上离指针最近的方向组);
|
|
1464
|
+
* - `childIds`:已有的同方向子节点 id(为空表示新节点会成为第一个孩子)。
|
|
1465
|
+
*/
|
|
1466
|
+
private mindMapChildGroup;
|
|
1467
|
+
/** 按 cross 坐标给同方向兄弟排序(Renderer 画落点占位框时要求同源顺序) */
|
|
1468
|
+
private mindMapSortByCross;
|
|
1469
|
+
/** 落点指示只在「真的变了」时更新(避免每帧 scheduleRender 抖动) */
|
|
1470
|
+
private setReorderIndicator;
|
|
1364
1471
|
/** 光标语义命中:仅节点框(含「+」快捷按钮、折叠/展开标记)内才命中,节点间空档不命中 */
|
|
1365
1472
|
getMindMapCursorHitAtPoint(point: Vec2): {
|
|
1366
1473
|
shapeId: string;
|
|
@@ -1427,10 +1534,23 @@ declare class Editor {
|
|
|
1427
1534
|
addMindMapSibling(shapeId: string, nodeId: string): void;
|
|
1428
1535
|
/** 将节点在其同方向兄弟列表中移动到目标索引 */
|
|
1429
1536
|
reorderMindMapNode(shapeId: string, nodeId: string, targetIndex: number): void;
|
|
1537
|
+
/**
|
|
1538
|
+
* 拖拽换层级:把节点移到目标父节点下、同方向兄弟组的 insertIndex 处。
|
|
1539
|
+
* 「拖到某个节点框上」= 成为该节点的同方向兄弟(即 targetParent = 该节点的父节点)。
|
|
1540
|
+
* 非法落点(目标是自己或自己的后代替)不修改文档。
|
|
1541
|
+
*/
|
|
1542
|
+
moveMindMapNodeToParent(shapeId: string, nodeId: string, targetParentId: string, direction: MindMapDirection, insertIndex: number): void;
|
|
1430
1543
|
/** 删除指定节点(含子树);删除根节点则移除整个思维导图 */
|
|
1431
1544
|
deleteMindMapNode(shapeId: string, nodeId: string): void;
|
|
1432
1545
|
/** 折叠/展开指定节点 */
|
|
1433
1546
|
toggleMindMapCollapse(shapeId: string, nodeId: string): void;
|
|
1547
|
+
/** 节点能否「升级」levels 层:depth 必须 ≥ levels + 1(至少得有个新父节点)。根节点不可升级。 */
|
|
1548
|
+
canPromoteMindMapNode(shapeId: string, nodeId: string, levels: number): boolean;
|
|
1549
|
+
/**
|
|
1550
|
+
* 把节点升级 levels 层(升 1 层 = 成为父节点的兄弟;升 2 层 = 成为祖父节点的兄弟)。
|
|
1551
|
+
* 节点自身子树整体上移,不被拆散。不可升级时(已到顶层)直接返回,不改动文档。
|
|
1552
|
+
*/
|
|
1553
|
+
promoteMindMapNode(shapeId: string, nodeId: string, levels: number): void;
|
|
1434
1554
|
/** 获取选中的表格(恰好选中一个时) */
|
|
1435
1555
|
getSelectedTable(): TableShape | null;
|
|
1436
1556
|
private getTableById;
|
|
@@ -1823,13 +1943,17 @@ declare class Renderer {
|
|
|
1823
1943
|
targetIndex: number;
|
|
1824
1944
|
direction: MindMapDirection;
|
|
1825
1945
|
siblingIds: string[];
|
|
1946
|
+
/** 「成为子节点」模式:目标节点 id(高亮它 + 子组为空时定位占位框) */
|
|
1947
|
+
childParentId?: string;
|
|
1826
1948
|
} | null,
|
|
1827
1949
|
/** 导出用:非 null 时先以该颜色铺满整块画布(白底等),默认不铺(透明) */
|
|
1828
1950
|
background?: string | null,
|
|
1829
1951
|
/** 悬停的图形 id:为其绘制四边连接锚点(飞书式悬浮提示),已选中图形由选择手柄负责 */
|
|
1830
1952
|
hoverAnchorShapeId?: string | null,
|
|
1831
1953
|
/** 悬停的连线 id:整条线描一层浅蓝高亮(提示「这条线可点、点开能调线段」) */
|
|
1832
|
-
hoverConnectorId?: string | null
|
|
1954
|
+
hoverConnectorId?: string | null,
|
|
1955
|
+
/** 橡皮擦渐隐:图形 id → 不透明度(0~1)。缺省时不改任何图形的透明度 */
|
|
1956
|
+
eraseFade?: Map<string, number> | null): void;
|
|
1833
1957
|
/** 橡皮擦:半透明主色圆 + 主色描边,半径与笔刷命中范围一致(屏幕像素恒定) */
|
|
1834
1958
|
private drawEraserBrush;
|
|
1835
1959
|
/** 连接进行中,高亮目标图形四边中点的可连锚点 */
|
|
@@ -2185,7 +2309,7 @@ declare const ICON_CATEGORIES: {
|
|
|
2185
2309
|
id: IconCategoryId;
|
|
2186
2310
|
labelKey: MessageKey;
|
|
2187
2311
|
}[];
|
|
2188
|
-
type IconCategoryId = 'status' | 'number' | 'emoji' | 'device' | 'tech' | 'chart' | 'office' | 'media' | 'arrow' | 'misc' | 'weather' | 'transport' | 'nature' | 'building' | 'medical' | 'shopping' | 'science' | 'animal' | 'time' | 'edit' | 'food' | 'communication';
|
|
2312
|
+
type IconCategoryId = 'status' | 'number' | 'emoji' | 'sticker' | 'device' | 'tech' | 'chart' | 'office' | 'media' | 'arrow' | 'misc' | 'weather' | 'transport' | 'nature' | 'building' | 'medical' | 'shopping' | 'science' | 'animal' | 'time' | 'edit' | 'food' | 'communication';
|
|
2189
2313
|
interface IconLayer {
|
|
2190
2314
|
/** 24×24 网格内的路径(语法同 SVG path,统一大写指令) */
|
|
2191
2315
|
d: string;
|
|
@@ -2322,6 +2446,8 @@ interface ToolContext {
|
|
|
2322
2446
|
addShape(shape: Shape): void;
|
|
2323
2447
|
updateShape(id: string, updates: Partial<Shape>): void;
|
|
2324
2448
|
deleteShape(id: string): void;
|
|
2449
|
+
/** 橡皮擦专用:先渐隐再删除(普通删除请用 deleteShape) */
|
|
2450
|
+
eraseShape(id: string): void;
|
|
2325
2451
|
selectShape(id: string, additive: boolean): void;
|
|
2326
2452
|
selectShapes(ids: string[]): void;
|
|
2327
2453
|
getShapes(): Shape[];
|
|
@@ -2416,6 +2542,11 @@ declare abstract class Tool {
|
|
|
2416
2542
|
* @returns 是否确实清理了状态(false = 本来就是空闲态,调用方可跳过重绘)
|
|
2417
2543
|
*/
|
|
2418
2544
|
cancelTransient(): boolean;
|
|
2545
|
+
/**
|
|
2546
|
+
* 是否正处于「拖拽/调整图形」中(移动/缩放/旋转图形、拖连线端点或线段、从锚点拉新连线)。
|
|
2547
|
+
* 默认 false;选择工具等会覆盖,供编辑器据此临时隐藏顶栏工具条。
|
|
2548
|
+
*/
|
|
2549
|
+
isDragging(): boolean;
|
|
2419
2550
|
dispose(): void;
|
|
2420
2551
|
}
|
|
2421
2552
|
|
|
@@ -2510,6 +2641,11 @@ declare class SelectTool extends Tool {
|
|
|
2510
2641
|
*/
|
|
2511
2642
|
private finishSegmentDrag;
|
|
2512
2643
|
hasTransientState(): boolean;
|
|
2644
|
+
/**
|
|
2645
|
+
* 拖拽/调整图形中:移动、缩放、旋转、拖连线端点、拖线段、从锚点拉新连线。
|
|
2646
|
+
* (框选空白、表格内框选单元格不算「拖图形」,不触发顶栏隐藏。)
|
|
2647
|
+
*/
|
|
2648
|
+
isDragging(): boolean;
|
|
2513
2649
|
/**
|
|
2514
2650
|
* 取消一切瞬态交互(拖拽/生成/框选/旋转/连线端点拖拽)并清掉画布上的瞬态预览。
|
|
2515
2651
|
* 触发场景:指针在窗口外松手丢失 pointerup、窗口失焦、点击画布外、无按压的移动、
|
|
@@ -2987,4 +3123,4 @@ declare function imageDataUrl(src: string): string | null;
|
|
|
2987
3123
|
/** 清空缓存(测试/卸载时用;会释放自己创建的 blob 地址) */
|
|
2988
3124
|
declare function clearImageCache(): void;
|
|
2989
3125
|
|
|
2990
|
-
export { type ArrowBinding, type ArrowHeadType, type ArrowShape, type ArrowStyle, ArrowTool, BoardExtentKeeper, type BoardExtentResult, type BoardExtentUpdate, Camera, type CameraState, type CircleShape, type ConnectionType, DEFAULT_HIGHLIGHTER_COLOR, DEFAULT_IMAGE_MAX_SIZE_BYTES, type DiamondShape, type DrawShape, type DrawuiTheme, type DrawuiThemeSelection, Editor, type EditorData, type EditorOptions, type EditorState, type EllipseShape, type ExportFormat, type ExportOptions, type FreehandMode, FreehandTool, type GenerationContext, HandTool, type HexagonShape, ICONS, ICON_CATEGORIES, ICON_CATEGORY_INK, ICON_DEFAULT_INK, ICON_DEFAULT_SIZE, ICON_GRID, type IconCategoryId, type IconDef, type IconLayer, type IconShape, type ImageShape, type ImageUploadConfig, type ImageUploadOption, type ImageUploader, LANGUAGES, type Language, type LineShape, LineTool, MINDMAP_COLORS, MINDMAP_DIRECTIONS, MINDMAP_FONT_SIZE, MINDMAP_HANDLE_HIT_RADIUS, MINDMAP_HANDLE_RADIUS, MINDMAP_MAX_WIDTH, MINDMAP_MIN_WIDTH, MINDMAP_NODE_HEIGHT, MIN_HANDLE_SEGMENT, MIN_JOG, Mat2d, type MessageKey, type MindMapDirection, type MindMapHandleKind, type MindMapHandlePos, type MindMapLayoutResult, type MindMapNode, type MindMapNodePos, type MindMapShape, type OctagonShape, type ParallelogramShape, type PentagonShape, type Rect, type RectangleShape, Renderer, type RoundedRectangleShape, STICKY_FOLD_RATIO, STICKY_NOTE_COLORS, STICKY_NOTE_DEFAULT_COLOR, STICKY_TEXT_SCALE, type SegmentHandle, SelectTool, type Shape, type ShapeStyle, ShapeTool, type ShapeType, type SnapGuide, type StarShape, type StickyNoteShape, TABLE_CELL_PADDING_X, TABLE_CELL_PADDING_Y, TABLE_DEFAULT_COL_WIDTH, TABLE_DEFAULT_ROW_HEIGHT, TABLE_FONT_SIZE, TABLE_HEADER_FILL, TABLE_LINE_HEIGHT_RATIO, TABLE_MAX_AUTO_LINES, TABLE_MIN_COL_WIDTH, TABLE_MIN_ROW_HEIGHT, TABLE_MOVE_HANDLE_GAP, TABLE_MOVE_HANDLE_HEIGHT, TABLE_MOVE_HANDLE_WIDTH, THEME, type TableCell, type TableShape, type TextShape, type ToolType, type TrapezoidShape, type TriangleShape, UML_FONT_SIZE, UML_HEADER_HEIGHT, UML_LINE_HEIGHT, UML_MIN_WIDTH, UML_PADDING_X, UML_PADDING_Y, type UiEvent, type UmlAttribute, type UmlClassShape, type UmlInterfaceShape, type UmlMethod, type UmlVisibility, Vec, type Vec2 as Vec2Type, addImageReadyListener, calcUmlClassSize, clearImageCache, cloneMindMapNode, cloneTable, cloneTableCells, collapseRoute, collectTemporaryImageSrcs, connectorSegmentHandles, countMindMapNodes, createTableCells, downloadBlob, effectiveDirection, ensureImagesLoaded, exportToBlob, findMindMapNode, getContentBounds, getIcon, getLanguage, getMindMapNodeDepth, getMindMapNodeSiblings, getMindMapParent, getTheme, hasIcon, hexToRgba, hitTableBody, hitTableMoveHandle, iconInk, iconsByCategory, imageDataUrl, isEmptyRect, isFlippableShapeType, isHorizontalDirection, isImageFailed, isImageLoading, isStubCorner, isUploaderFunction, layoutMindMap, loadImage, mindMapHandleAtLocalPoint, mindMapNodeColor, mindMapNodeHandles, mindMapNodeSize, offsetConnectorSegment, parseUploadResponse, peekImage, pickSegmentHandle, pointToSegmentDistance, pruneStubBends, rectsIntersect, renderSVGString, renderToCanvas, reorderMindMapNodeInTree, routeToUserPoints, sameRoute, searchIcons, setImageCrossOrigin, setLanguage, setTheme, shadeColor, subscribeLanguage, subscribeTheme, subtractUnion, t, tableAnchorAt, tableCellAtLocalClamped, tableCellLineCount, tableCellLocalRect, tableCellTextStartOffset, tableCoveredMap, tableDeleteColumn, tableDeleteRow, tableExpandRangeToMerges, tableGrowRowHeights, tableInsertColumn, tableInsertRow, tableLocalPoint, tableMerge, tableMoveHandleLocalRect, tablePagePoint, tableRangeHasMerge, tableRangeLocalRect, tableRowAtPoint, tableSplit, tableSplitRange, tableTotalHeight, tableTotalWidth, umlAttrRowText, umlMethodRowText, unionRect, uploadImageViaConfig };
|
|
3126
|
+
export { type ArrowBinding, type ArrowHeadType, type ArrowShape, type ArrowStyle, ArrowTool, BoardExtentKeeper, type BoardExtentResult, type BoardExtentUpdate, Camera, type CameraState, type CircleShape, type ConnectionType, DEFAULT_HIGHLIGHTER_COLOR, DEFAULT_IMAGE_MAX_SIZE_BYTES, DEFAULT_PAGE_THEME, type DiamondShape, type DrawShape, type DrawuiTheme, type DrawuiThemeSelection, Editor, type EditorData, type EditorOptions, type EditorState, type EllipseShape, type ExportFormat, type ExportOptions, type FreehandMode, FreehandTool, type GenerationContext, HandTool, type HexagonShape, ICONS, ICON_CATEGORIES, ICON_CATEGORY_INK, ICON_DEFAULT_INK, ICON_DEFAULT_SIZE, ICON_GRID, type IconCategoryId, type IconDef, type IconLayer, type IconShape, type ImageShape, type ImageUploadConfig, type ImageUploadOption, type ImageUploader, LANGUAGES, type Language, type LineShape, LineTool, MINDMAP_COLORS, MINDMAP_DIRECTIONS, MINDMAP_FONT_SIZE, MINDMAP_HANDLE_HIT_RADIUS, MINDMAP_HANDLE_RADIUS, MINDMAP_MAX_WIDTH, MINDMAP_MIN_WIDTH, MINDMAP_NODE_HEIGHT, MIN_HANDLE_SEGMENT, MIN_JOG, Mat2d, type MessageKey, type MindMapDirection, type MindMapHandleKind, type MindMapHandlePos, type MindMapLayoutResult, type MindMapNode, type MindMapNodePos, type MindMapShape, type OctagonShape, PAGE_THEMES, type PageTheme, type PageThemePreset, type ParallelogramShape, type PentagonShape, type Rect, type RectangleShape, Renderer, type RoundedRectangleShape, STICKY_FOLD_RATIO, STICKY_NOTE_COLORS, STICKY_NOTE_DEFAULT_COLOR, STICKY_TEXT_SCALE, type SegmentHandle, SelectTool, type Shape, type ShapeStyle, ShapeTool, type ShapeType, type SnapGuide, type StarShape, type StickyNoteShape, TABLE_CELL_PADDING_X, TABLE_CELL_PADDING_Y, TABLE_DEFAULT_COL_WIDTH, TABLE_DEFAULT_ROW_HEIGHT, TABLE_FONT_SIZE, TABLE_HEADER_FILL, TABLE_LINE_HEIGHT_RATIO, TABLE_MAX_AUTO_LINES, TABLE_MIN_COL_WIDTH, TABLE_MIN_ROW_HEIGHT, TABLE_MOVE_HANDLE_GAP, TABLE_MOVE_HANDLE_HEIGHT, TABLE_MOVE_HANDLE_WIDTH, THEME, type TableCell, type TableShape, type TextShape, type ToolType, type TrapezoidShape, type TriangleShape, UML_FONT_SIZE, UML_HEADER_HEIGHT, UML_LINE_HEIGHT, UML_MIN_WIDTH, UML_PADDING_X, UML_PADDING_Y, type UiEvent, type UmlAttribute, type UmlClassShape, type UmlInterfaceShape, type UmlMethod, type UmlVisibility, Vec, type Vec2 as Vec2Type, addImageReadyListener, calcUmlClassSize, clearImageCache, cloneMindMapNode, cloneTable, cloneTableCells, collapseRoute, collectTemporaryImageSrcs, connectorSegmentHandles, countMindMapNodes, createTableCells, downloadBlob, effectiveDirection, ensureImagesLoaded, exportToBlob, findMindMapNode, getContentBounds, getIcon, getLanguage, getMindMapNodeDepth, getMindMapNodeSiblings, getMindMapParent, getTheme, hasIcon, hexToRgba, hitTableBody, hitTableMoveHandle, iconInk, iconsByCategory, imageDataUrl, isEmptyRect, isFlippableShapeType, isHorizontalDirection, isImageFailed, isImageLoading, isStubCorner, isUploaderFunction, layoutMindMap, loadImage, mindMapHandleAtLocalPoint, mindMapNodeColor, mindMapNodeHandles, mindMapNodeSize, moveMindMapNodeInTree, offsetConnectorSegment, parseUploadResponse, peekImage, pickSegmentHandle, pointToSegmentDistance, promoteMindMapNodeInTree, pruneStubBends, rectsIntersect, renderSVGString, renderToCanvas, reorderMindMapNodeInTree, routeToUserPoints, sameRoute, searchIcons, setImageCrossOrigin, setLanguage, setTheme, shadeColor, subscribeLanguage, subscribeTheme, subtractUnion, t, tableAnchorAt, tableCellAtLocalClamped, tableCellLineCount, tableCellLocalRect, tableCellTextStartOffset, tableCoveredMap, tableDeleteColumn, tableDeleteRow, tableExpandRangeToMerges, tableGrowRowHeights, tableInsertColumn, tableInsertRow, tableLocalPoint, tableMerge, tableMoveHandleLocalRect, tablePagePoint, tableRangeHasMerge, tableRangeLocalRect, tableRowAtPoint, tableSplit, tableSplitRange, tableTotalHeight, tableTotalWidth, umlAttrRowText, umlMethodRowText, unionRect, uploadImageViaConfig };
|