drawui-core 0.5.3 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/icons-catalog-LG6WL446.cjs +4 -0
- package/dist/icons-catalog-TDWDJPEW.js +4 -0
- package/dist/index.cjs +40 -32
- package/dist/index.d.cts +257 -13
- package/dist/index.d.ts +257 -13
- package/dist/index.js +40 -32
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -80,6 +80,13 @@ interface HexagonShape extends BaseShape {
|
|
|
80
80
|
type: 'hexagon';
|
|
81
81
|
width: number;
|
|
82
82
|
height: number;
|
|
83
|
+
/**
|
|
84
|
+
* 六边形朝向(缺省 `'pointy'`,老文档行为不变):
|
|
85
|
+
* - `'pointy'`:上下为尖、左右为竖边(原行为)
|
|
86
|
+
* - `'flat'`:上下为平边、左右为尖 —— 蜂窝图要用这个,
|
|
87
|
+
* 它的六个邻居正好落在 30°/90°/150°/210°/270°/330°,上下左右都能拼上。
|
|
88
|
+
*/
|
|
89
|
+
orientation?: 'pointy' | 'flat';
|
|
83
90
|
}
|
|
84
91
|
interface ParallelogramShape extends BaseShape {
|
|
85
92
|
type: 'parallelogram';
|
|
@@ -90,6 +97,13 @@ interface TrapezoidShape extends BaseShape {
|
|
|
90
97
|
type: 'trapezoid';
|
|
91
98
|
width: number;
|
|
92
99
|
height: number;
|
|
100
|
+
/**
|
|
101
|
+
* 上边每侧内缩的距离(页面单位)。缺省 = `width * 0.15`(老文档行为不变)。
|
|
102
|
+
*
|
|
103
|
+
* 用来堆金字塔:每层给出精确的缩进量,侧边才能连成**同一条斜线**;
|
|
104
|
+
* 靠默认的 15% 比例会让每层斜率各不相同,堆起来像歪的楼梯。
|
|
105
|
+
*/
|
|
106
|
+
topInset?: number;
|
|
93
107
|
}
|
|
94
108
|
interface PentagonShape extends BaseShape {
|
|
95
109
|
type: 'pentagon';
|
|
@@ -239,6 +253,10 @@ interface LineShape extends BaseShape {
|
|
|
239
253
|
start: Vec2;
|
|
240
254
|
end: Vec2;
|
|
241
255
|
};
|
|
256
|
+
/** 手工艺状态的自动走线基线(见 ArrowShape.userPointsBase) */
|
|
257
|
+
userPointsBase?: Vec2[];
|
|
258
|
+
/** 纯装饰线(见 ArrowShape.freeform) */
|
|
259
|
+
freeform?: boolean;
|
|
242
260
|
}
|
|
243
261
|
type ConnectionType = 'straight' | 'polyline' | 'orthogonal' | 'curve';
|
|
244
262
|
/** 生成点位创建上下文:from 为源点(生成点位),to 为目标落点 */
|
|
@@ -328,6 +346,22 @@ interface ArrowShape extends BaseShape {
|
|
|
328
346
|
start: Vec2;
|
|
329
347
|
end: Vec2;
|
|
330
348
|
};
|
|
349
|
+
/**
|
|
350
|
+
* 写下手工艺状态那一刻的**自动走线**(世界坐标,含两端)。
|
|
351
|
+
*
|
|
352
|
+
* 只用来判断手工折点是否已经过期:自动走线的形状签名(折点数 + 首末段轴向)只由布局决定,
|
|
353
|
+
* 一旦当前自动走线的签名和这里记的不一样,说明「当初为了绕开什么而折」的前提没了 ——
|
|
354
|
+
* 这时折点只会让线凭空多绕一圈(见 connectorEdit.userPointsAreStale)。
|
|
355
|
+
*/
|
|
356
|
+
userPointsBase?: Vec2[];
|
|
357
|
+
/**
|
|
358
|
+
* 纯装饰线/箭头:**不把端点吸附到附近图形的轮廓上**。
|
|
359
|
+
*
|
|
360
|
+
* 模板里的分隔线、网格线、肋骨、标注线往往是**故意画在容器图形内部**的;
|
|
361
|
+
* 默认的「端点落进图形就吸到轮廓」会把它们拽到容器边上(画布上看是"线自己跑了"),
|
|
362
|
+
* 而且导出侧从不做这个吸附 → 画布与导出还会对不上。
|
|
363
|
+
*/
|
|
364
|
+
freeform?: boolean;
|
|
331
365
|
}
|
|
332
366
|
interface TextShape extends BaseShape {
|
|
333
367
|
type: 'text';
|
|
@@ -698,7 +732,7 @@ declare const zhCN: {
|
|
|
698
732
|
readonly 'style.solid': "实线";
|
|
699
733
|
readonly 'style.opacity': "不透明度";
|
|
700
734
|
readonly 'style.connection.straight': "直线";
|
|
701
|
-
readonly 'style.connection.polyline': "
|
|
735
|
+
readonly 'style.connection.polyline': "圆角折线";
|
|
702
736
|
readonly 'style.connection.orthogonal': "直角折线";
|
|
703
737
|
readonly 'style.connection.curve': "曲线";
|
|
704
738
|
readonly 'style.arrowhead.none': "无箭头";
|
|
@@ -805,8 +839,13 @@ declare const zhCN: {
|
|
|
805
839
|
readonly 'ctx.ungroup': "解组";
|
|
806
840
|
readonly 'ctx.lock': "锁定";
|
|
807
841
|
readonly 'ctx.unlock': "解锁";
|
|
842
|
+
readonly 'ctx.unlockAll': "全部解锁";
|
|
808
843
|
readonly 'ctx.delete': "删除";
|
|
809
844
|
readonly 'toolbar.icon': "图标 (S)";
|
|
845
|
+
readonly 'toolbar.template': "模板";
|
|
846
|
+
readonly 'template.search': "搜索模板";
|
|
847
|
+
readonly 'template.all': "全部";
|
|
848
|
+
readonly 'template.empty': "没有匹配的模板";
|
|
810
849
|
readonly 'toolbar.image': "图片";
|
|
811
850
|
readonly 'toolbar.more': "更多";
|
|
812
851
|
readonly 'toolbar.pageTheme': "页面主题";
|
|
@@ -859,12 +898,24 @@ declare function t(key: MessageKey, params?: Record<string, string | number>): s
|
|
|
859
898
|
|
|
860
899
|
type ExportFormat = 'png' | 'svg' | 'pdf';
|
|
861
900
|
interface ExportOptions {
|
|
862
|
-
/**
|
|
901
|
+
/**
|
|
902
|
+
* 输出缩放倍数(仅位图 PNG 生效,默认 2,矢量 SVG 始终无损)。
|
|
903
|
+
* 语义:内容 1 个页面单位 → 输出 scale 个设备像素(就是最终图与内容的尺寸比)。
|
|
904
|
+
*/
|
|
863
905
|
scale?: number;
|
|
864
906
|
/** 内容四周留白(页面坐标,默认 24) */
|
|
865
907
|
padding?: number;
|
|
866
908
|
/** 背景色,null = 透明;不传默认白色('#ffffff') */
|
|
867
909
|
background?: string | null;
|
|
910
|
+
/**
|
|
911
|
+
* 输出最长边的像素上限(默认不限制)。超过时按比例压低 scale,**保证整幅内容完整、不裁切**。
|
|
912
|
+
*
|
|
913
|
+
* 缩略图 / 预览图这类"显示尺寸远小于内容尺寸"的场景务必传:
|
|
914
|
+
* 内容跨度大时(把一个图形拖到几千像素外)输出画布面积会平方增长,
|
|
915
|
+
* 不仅编码要几百毫秒,还会触及浏览器 canvas 面积上限(Chrome 约 16384×16384,
|
|
916
|
+
* 约 2.68 亿像素 / 1GB),超限后 toDataURL 直接返回 `data:,` —— 图变空白。
|
|
917
|
+
*/
|
|
918
|
+
maxSize?: number;
|
|
868
919
|
}
|
|
869
920
|
/** 计算所有图形的并集包围盒(含留白),用于导出画布尺寸与视口 */
|
|
870
921
|
declare function getContentBounds(shapes: Shape[], padding?: number): {
|
|
@@ -1055,6 +1106,8 @@ declare class Editor {
|
|
|
1055
1106
|
private editingShapeId;
|
|
1056
1107
|
private textInput;
|
|
1057
1108
|
private textOverlay;
|
|
1109
|
+
/** 延迟创建就地输入框的 rAF 句柄:退出编辑/销毁时必须取消,否则会挂出无人认领的孤儿 textarea */
|
|
1110
|
+
private textInputRaf;
|
|
1058
1111
|
private isNewTextShape;
|
|
1059
1112
|
private originalTextValue;
|
|
1060
1113
|
private undoStack;
|
|
@@ -1066,6 +1119,12 @@ declare class Editor {
|
|
|
1066
1119
|
private genPreview;
|
|
1067
1120
|
private hoverAnchorShapeId;
|
|
1068
1121
|
private hoverConnectorId;
|
|
1122
|
+
/**
|
|
1123
|
+
* 悬停中的**锁定**图形:锁标记不再常驻(一屏三把锁比锁本身更吵),
|
|
1124
|
+
* 只在指针落在这个锁定图形上时才亮出来 —— 顺带告诉用户「它为什么点不动」,
|
|
1125
|
+
* 而且那枚锁是可以直接点开解锁的(见 pointerdown 里的锁徽标命中)。
|
|
1126
|
+
*/
|
|
1127
|
+
private hoverLockedShapeId;
|
|
1069
1128
|
private eraserPoint;
|
|
1070
1129
|
/**
|
|
1071
1130
|
* 橡皮擦「渐隐」中的图形:id → 开始时间戳。
|
|
@@ -1154,6 +1213,17 @@ declare class Editor {
|
|
|
1154
1213
|
private handlePointerUp;
|
|
1155
1214
|
/** 根据当前工具的命中结果更新鼠标样式(伸缩手柄↔/↕、拖拽 grabbing 等) */
|
|
1156
1215
|
private updateCursor;
|
|
1216
|
+
/**
|
|
1217
|
+
* 锁定图形的悬停跟踪:只有悬停中的锁定图形才亮出锁徽标(默认不画,见 Renderer.visibleLockBadges)。
|
|
1218
|
+
*
|
|
1219
|
+
* 除了"指针在图形上",还要认"指针在锁徽标上" —— 徽标压在包围盒外侧,
|
|
1220
|
+
* 指针移过去的瞬间已经离开了图形本身,不认就会闪掉、点不到。
|
|
1221
|
+
*/
|
|
1222
|
+
private updateLockHover;
|
|
1223
|
+
/** 命中「锁徽标」(世界坐标点);返回要解锁的目标。命中范围比视觉上略大一圈,好点 */
|
|
1224
|
+
private lockBadgeAtPoint;
|
|
1225
|
+
/** 点锁徽标 → 解锁(组锁整组解),一步撤销 */
|
|
1226
|
+
private unlockFromBadge;
|
|
1157
1227
|
/**
|
|
1158
1228
|
* 滚轮:普通滚动平移视口(内容跟随常规滚动方向),
|
|
1159
1229
|
* Ctrl/Cmd + 滚轮以光标为中心缩放,Shift + 滚轮水平平移。
|
|
@@ -1163,7 +1233,24 @@ declare class Editor {
|
|
|
1163
1233
|
private handleKeyUp;
|
|
1164
1234
|
private handleResize;
|
|
1165
1235
|
private screenToPage;
|
|
1236
|
+
/**
|
|
1237
|
+
* 插入一组图形(模板库的落地入口)。
|
|
1238
|
+
*
|
|
1239
|
+
* - 模板坐标是「相对自己的中心」,这里整体平移到**当前视口中心**,插到用户正在看的地方;
|
|
1240
|
+
* - 整批插入只打**一个**历史快照,撤销一次就整块拿掉;
|
|
1241
|
+
* - 插入后自动选中这批图形,用户可以直接拖动/改样式;
|
|
1242
|
+
* - 连线要平移 `points`(`shape.x/y` 对连线只是渲染原点,平移它视觉上不动)。
|
|
1243
|
+
*/
|
|
1244
|
+
insertTemplate(shapes: Shape[]): void;
|
|
1166
1245
|
private addShape;
|
|
1246
|
+
/**
|
|
1247
|
+
* 文档里出现了「大目录」里的图标(表情/贴纸/补充图标)就把它拉回来,回来后重绘一次。
|
|
1248
|
+
*
|
|
1249
|
+
* 图标目录是懒加载的:首包只带手绘线稿那部分。打开一份含表情的文档时,
|
|
1250
|
+
* 第一次渲染会短暂缺图 —— 这里补一次加载,加载完 requestRender 补画上。
|
|
1251
|
+
* 全部图标都在首包时 `ensureIcons` 是纯同步空转,不会产生任何网络请求。
|
|
1252
|
+
*/
|
|
1253
|
+
private prefetchShapeIcons;
|
|
1167
1254
|
private updateShape;
|
|
1168
1255
|
/**
|
|
1169
1256
|
* 表格尺寸变化时保持「左上角」不动:行高变化向下伸缩、列宽变化向右伸缩,
|
|
@@ -1198,6 +1285,15 @@ declare class Editor {
|
|
|
1198
1285
|
selectShape(id: string, additive: boolean): void;
|
|
1199
1286
|
/** 整体替换选中集(右键菜单/外部控制用);框选结果同样按组扩张 */
|
|
1200
1287
|
selectShapes(ids: string[]): void;
|
|
1288
|
+
/**
|
|
1289
|
+
* 全选(Ctrl/Cmd + A):选中画布上所有图形。
|
|
1290
|
+
*
|
|
1291
|
+
* 锁定图形**跳过** —— 它们本来就不接受选中(点不中、拖不动),
|
|
1292
|
+
* 混进选区只会让「删除/移动/改样式」这些操作对它们做无用功,
|
|
1293
|
+
* 还会让状态栏的「已选 N 个」数字对不上能操作的图形数。
|
|
1294
|
+
* 要处理锁定的图形,先解锁(悬停点锁 / 右键解锁 / 空白右键「全部解锁」)。
|
|
1295
|
+
*/
|
|
1296
|
+
selectAll(): boolean;
|
|
1201
1297
|
/** 某图形所在的整组 id 列表(不在组里就只有它自己) */
|
|
1202
1298
|
private getGroupMembers;
|
|
1203
1299
|
/** 选中集是否恰好是完整的一个组(返回 groupId,否则 null) */
|
|
@@ -1333,6 +1429,14 @@ declare class Editor {
|
|
|
1333
1429
|
setShapeLocked(id: string, locked: boolean): boolean;
|
|
1334
1430
|
/** 某个图形是否被锁定 */
|
|
1335
1431
|
isShapeLocked(id: string): boolean;
|
|
1432
|
+
/** 画布上是否存在锁定图形(右键菜单决定要不要显示「全部解锁」) */
|
|
1433
|
+
hasLockedShapes(): boolean;
|
|
1434
|
+
/**
|
|
1435
|
+
* 全部解锁(一步撤销)。
|
|
1436
|
+
* 兜底入口:锁定的图形点不中、框选也框不中,如果用户忘了自己锁过什么、
|
|
1437
|
+
* 或者锁的量比较多,挨个悬停点锁太麻烦 —— 空白处右键就能一次清掉。
|
|
1438
|
+
*/
|
|
1439
|
+
unlockAll(): boolean;
|
|
1336
1440
|
/** 置于顶层:选中的图形整体移到最上面(保持它们之间的相对顺序) */
|
|
1337
1441
|
bringToFront(): boolean;
|
|
1338
1442
|
/** 置于底层:选中的图形整体移到最下面 */
|
|
@@ -1789,12 +1893,25 @@ declare class Editor {
|
|
|
1789
1893
|
getEditingShapeId(): string | null;
|
|
1790
1894
|
canEditShape(shape: Shape): boolean;
|
|
1791
1895
|
enterEditing(shapeId: string): void;
|
|
1896
|
+
/** 取消尚未落地的就地输入框创建(退出编辑、切换编辑目标、销毁时都要调) */
|
|
1897
|
+
private cancelTextInputRaf;
|
|
1792
1898
|
exitEditing(): void;
|
|
1899
|
+
/**
|
|
1900
|
+
* 批量替换画布内容(插模板 / setShapes / 导入 JSON)前,把就地编辑收干净。
|
|
1901
|
+
* 不写回文字、不写历史:这批操作本来就要换掉当前数据,挂着的 textarea 会停在
|
|
1902
|
+
* 旧图形的屏幕坐标上浮在新内容之上,看起来就是「凭空冒出一个输入框」。
|
|
1903
|
+
*
|
|
1904
|
+
* 无条件清理(不 early return):状态字段可能已被别处清过而 DOM 还挂着,
|
|
1905
|
+
* 那种「无所有者的输入框」正是这里要兜住的东西。
|
|
1906
|
+
*/
|
|
1907
|
+
private closeInlineEditing;
|
|
1793
1908
|
private removeTextInput;
|
|
1794
1909
|
private createTextInput;
|
|
1795
1910
|
private getShapeScreenBounds;
|
|
1796
1911
|
getShapeAtScreenPoint(screenPoint: Vec2): Shape | null;
|
|
1797
1912
|
getShapeAtPoint(point: Vec2, excludeId?: string): Shape | null;
|
|
1913
|
+
/** 点是否落在连线的**实际走线**上(与画面一致:含出/入桩、绕行、手工折点) */
|
|
1914
|
+
private isPointOnConnector;
|
|
1798
1915
|
/** 橡皮擦:返回与圆形笔刷相交的所有图形(不含线条的命中由其线段距离判定) */
|
|
1799
1916
|
getShapesInBrushRadius(point: Vec2, radius: number): Shape[];
|
|
1800
1917
|
private shapeIntersectsBrush;
|
|
@@ -1875,6 +1992,27 @@ declare function collapseRoute(pts: Vec2[]): Vec2[];
|
|
|
1875
1992
|
declare function routeToUserPoints(route: Vec2[]): Vec2[];
|
|
1876
1993
|
/** 两条走线是否几何等价(点数相同、逐点重合)——「拖回原来的线」=没改过 */
|
|
1877
1994
|
declare function sameRoute(a: Vec2[], b: Vec2[], tol?: number): boolean;
|
|
1995
|
+
/**
|
|
1996
|
+
* 把「裂成两条」的台阶合并掉 —— 正交走线的**归一化**。
|
|
1997
|
+
*
|
|
1998
|
+
* 现象:一条线在同一方向上出现两条相距几像素的平行段,中间用一个小折角相连。
|
|
1999
|
+
* 视觉上就是「明明是一条直线,却分成了两条」(用户报的『重新变成一条直线后,还是会分开』)。
|
|
2000
|
+
*
|
|
2001
|
+
* 成因有三类,最终都表现为「两个平行台阶的间距 < MIN_JOG」:
|
|
2002
|
+
* - 历史数据里冻着手调折点,之后图形/端点又动过几像素;
|
|
2003
|
+
* - 某次调整后桩拐角被写进 userPoints,跟新生成的桩错开;
|
|
2004
|
+
* - 布局变化让两段本来同高的线被「跟随端点」拉出了细微高差。
|
|
2005
|
+
*
|
|
2006
|
+
* 判据只用几何:**同轴的相邻台阶间距 < MIN_JOG 就是噪声**。这是安全的 ——
|
|
2007
|
+
* 拖线段时的磁吸(offsetConnectorSegment)根本做不出 < MIN_JOG 的台阶,
|
|
2008
|
+
* 所以这个范围内的间距不可能是用户意图。
|
|
2009
|
+
*
|
|
2010
|
+
* 合并方向:**以靠前的那条为准**(首段贴着起点锚、末段贴着终点锚,都不动),
|
|
2011
|
+
* 于是「把线拖回原位」永远收敛到起点那一侧,不会来回跳。
|
|
2012
|
+
*
|
|
2013
|
+
* @param route 已是横平竖直的走线(首尾是两端端点)
|
|
2014
|
+
*/
|
|
2015
|
+
declare function mergeShallowSteps(route: Vec2[], minJog?: number): Vec2[];
|
|
1878
2016
|
/**
|
|
1879
2017
|
* 端点旁的出/入桩拐角:距端点不超过一个桩长(≈24px),且与端点同轴(只差一个轴向坐标)。
|
|
1880
2018
|
* 自动走线的第一个 / 最后一个中间折点就是它 —— 每次渲染都会由桩重新算出来。
|
|
@@ -1898,6 +2036,19 @@ interface SnapGuide {
|
|
|
1898
2036
|
start: number;
|
|
1899
2037
|
end: number;
|
|
1900
2038
|
}
|
|
2039
|
+
/** 一枚锁徽标(世界坐标矩形 + 点击它要解锁的目标)—— 绘制与命中共用 */
|
|
2040
|
+
interface LockBadgeTarget {
|
|
2041
|
+
x: number;
|
|
2042
|
+
y: number;
|
|
2043
|
+
/** 边长(屏幕 20px 换算到世界单位) */
|
|
2044
|
+
size: number;
|
|
2045
|
+
/** 单图形锁定:解锁它本身 */
|
|
2046
|
+
shapeId?: string;
|
|
2047
|
+
/** 组锁定:解锁整组 */
|
|
2048
|
+
groupId?: string;
|
|
2049
|
+
/** 组锁的所有成员 id(用于判断"悬停/选中是否在这个组上") */
|
|
2050
|
+
memberIds: string[];
|
|
2051
|
+
}
|
|
1901
2052
|
declare class Renderer {
|
|
1902
2053
|
private ctx;
|
|
1903
2054
|
private width;
|
|
@@ -1922,6 +2073,11 @@ declare class Renderer {
|
|
|
1922
2073
|
} | null): void;
|
|
1923
2074
|
/** 当前悬停的图形 id(由每帧 render 写入),仅用于表格拖动把手等提示性绘制 */
|
|
1924
2075
|
private hoverShapeId;
|
|
2076
|
+
/**
|
|
2077
|
+
* 本帧是否是「多选」(选中集 > 1)。多选时每个图形只描发丝轮廓、不再画手柄,
|
|
2078
|
+
* 手柄收敛到整体范围框上(见 drawMultiSelectionBounds)。
|
|
2079
|
+
*/
|
|
2080
|
+
private multiSelection;
|
|
1925
2081
|
private static readonly TEXT_CACHE_LIMIT;
|
|
1926
2082
|
constructor(canvas: HTMLCanvasElement, dpr?: number);
|
|
1927
2083
|
resize(width: number, height: number): void;
|
|
@@ -2075,6 +2231,14 @@ declare class Renderer {
|
|
|
2075
2231
|
getConnectorRoute(shape: Shape, shapeMap: Map<string, Shape>, options?: {
|
|
2076
2232
|
ignoreUserPoints?: boolean;
|
|
2077
2233
|
}): Vec2[];
|
|
2234
|
+
/**
|
|
2235
|
+
* 连线最终走线(世界坐标)+ 生效的连线类型 —— **绘制、命中、导出判定都走这里**。
|
|
2236
|
+
*
|
|
2237
|
+
* 手工折点会先过一道「过期检查」(connectorEdit.userPointsAreStale):
|
|
2238
|
+
* 走线压到自己连的图形、或者布局已经变到自动走线的形状都不一样了,就丢弃手工折点。
|
|
2239
|
+
* 这样「旧布局下绕出来的大回环」不会跟着图形被带进新布局,默认永远是最少突兀的那条线。
|
|
2240
|
+
*/
|
|
2241
|
+
private connectorWorldPath;
|
|
2078
2242
|
/**
|
|
2079
2243
|
* 选中连线时:在每段(够长的)线段中点画一个可拖动的小手柄(飞书式「拖线段调位置」)。
|
|
2080
2244
|
* 拖动交互在 SelectTool 的 'dragging-segment' 状态里。
|
|
@@ -2217,16 +2381,22 @@ declare class Renderer {
|
|
|
2217
2381
|
private drawText;
|
|
2218
2382
|
private drawFreehand;
|
|
2219
2383
|
/**
|
|
2220
|
-
*
|
|
2221
|
-
*
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
*
|
|
2226
|
-
*
|
|
2227
|
-
*
|
|
2228
|
-
*/
|
|
2229
|
-
|
|
2384
|
+
* 当前**可见**的锁标记(世界坐标矩形 + 解锁目标)。
|
|
2385
|
+
*
|
|
2386
|
+
* 绘制与「点锁解锁」的命中共用这一份 —— 看到哪就能点到哪,不会出现"看不见却能点"。
|
|
2387
|
+
*
|
|
2388
|
+
* 为什么不再给每个锁定图形常驻画一把锁:一条流程图里锁三个图形就冒出三把锁,
|
|
2389
|
+
* 满屏徽标比锁本身更干扰。现在只在**需要解释的时候**出现:
|
|
2390
|
+
* 指针悬停在这个锁定图形上,或它刚被右键选中(右键是选中锁定图形的入口)。
|
|
2391
|
+
* 组锁仍然整组一把(挂在组包围盒顶部居中),条件同上:悬停/选中任一成员。
|
|
2392
|
+
*/
|
|
2393
|
+
visibleLockBadges(shapes: Shape[], selectedIds: Set<string>, zoom: number): LockBadgeTarget[];
|
|
2394
|
+
/** 所有「锁定图形」的徽标位置(不考虑是否显示)—— 命中测试与悬停判定用 */
|
|
2395
|
+
lockBadgeTargets(shapes: Shape[], zoom: number): LockBadgeTarget[];
|
|
2396
|
+
private allLockBadges;
|
|
2397
|
+
/** 悬停的锁定图形 id(由 Editor 在指针移动时写入):只有它才会亮出锁徽标 */
|
|
2398
|
+
private lockHoverId;
|
|
2399
|
+
setLockHover(id: string | null): void;
|
|
2230
2400
|
/** 在指定位置(徽标左上角,世界坐标)画一枚挂锁徽标 */
|
|
2231
2401
|
private drawLockBadgeAt;
|
|
2232
2402
|
/**
|
|
@@ -2234,6 +2404,13 @@ declare class Renderer {
|
|
|
2234
2404
|
* 提示「这些图形是绑在一起的」。整组锁定的成员画不到(成员不可选),不需要外框。
|
|
2235
2405
|
*/
|
|
2236
2406
|
private drawGroupFrames;
|
|
2407
|
+
/**
|
|
2408
|
+
* 多选时每个图形的「发丝轮廓」:1px、不填充、不画任何手柄。
|
|
2409
|
+
* 目的是告诉用户「这个也在选区里」,而不是喧宾夺主。
|
|
2410
|
+
*/
|
|
2411
|
+
private drawMultiSelectOutline;
|
|
2412
|
+
/** 多选的整体范围框:一个蓝框圈住全部选中图形(不带手柄) */
|
|
2413
|
+
private drawMultiSelectionBounds;
|
|
2237
2414
|
private drawSelectionOutline;
|
|
2238
2415
|
private drawSelectionHandles;
|
|
2239
2416
|
/**
|
|
@@ -2346,6 +2523,20 @@ interface IconDef {
|
|
|
2346
2523
|
};
|
|
2347
2524
|
}
|
|
2348
2525
|
declare const ICONS: IconDef[];
|
|
2526
|
+
/** 大目录是否已并入(同步查询) */
|
|
2527
|
+
declare function isIconCatalogLoaded(): boolean;
|
|
2528
|
+
/**
|
|
2529
|
+
* 加载大目录。可重复调用(共享同一个 Promise);失败会重置状态,允许下次重试。
|
|
2530
|
+
* 宿主一般不用直接调 —— 图标面板与 `Editor` 会自动触发。
|
|
2531
|
+
*/
|
|
2532
|
+
declare function loadIconCatalog(): Promise<void>;
|
|
2533
|
+
/**
|
|
2534
|
+
* 预取一批图标(通常是文档里出现过的 iconId)。
|
|
2535
|
+
*
|
|
2536
|
+
* 全部已在首包里时**不会触发任何加载**,所以「没有表情/贴纸」的文档完全不受影响;
|
|
2537
|
+
* 只要有一个不认识,就说明文档用了大目录里的图标,此时整份目录拉一次(浏览器会缓存)。
|
|
2538
|
+
*/
|
|
2539
|
+
declare function ensureIcons(ids: Iterable<string>): Promise<void>;
|
|
2349
2540
|
declare function getIcon(id: string): IconDef | undefined;
|
|
2350
2541
|
/** 存在该 id 的图标(写入图形/读文档时校验,避免引用到不存在的图标) */
|
|
2351
2542
|
declare function hasIcon(id: string): boolean;
|
|
@@ -2372,6 +2563,39 @@ declare const ICON_CATEGORY_INK: Record<IconCategoryId, string>;
|
|
|
2372
2563
|
/** 取某个图标的默认墨色:图标自带 ink 优先(全彩贴纸),否则用分类主色,最后退回全局默认 */
|
|
2373
2564
|
declare function iconInk(icon: IconDef): string;
|
|
2374
2565
|
|
|
2566
|
+
/**
|
|
2567
|
+
* 内置模板库(数据层,不含 UI)。
|
|
2568
|
+
*
|
|
2569
|
+
* 设计约定(每一条都踩过坑):
|
|
2570
|
+
* - `build()` **现场生成**图形,不共享可变数组 —— 否则插两次会复用同一批 id。
|
|
2571
|
+
* - 坐标是**相对模板中心**的,插入时整体平移到视口中心;`x/y` 是**图形中心**。
|
|
2572
|
+
* - **连线段必须绑定到图形**(`startBinding`/`endBinding`)。不绑的话拖动盒子线不动,
|
|
2573
|
+
* 整个模板当场散架。走线交给路由算法(同一侧引出的多条线会自动共用主干)。
|
|
2574
|
+
* - 一个视觉整体由多个图形拼成时(表头+字段行、卡片+按钮),用 `groupId` 绑成组,
|
|
2575
|
+
* 拖动才会整块走。
|
|
2576
|
+
* - 想要「只有字、没有框」必须用 `type: 'text'`:`strokeWidth: 0` 并不会去掉矩形边框。
|
|
2577
|
+
* - 想加模板:往 `TEMPLATES` 里加一项,UI 与搜索会自动带上。
|
|
2578
|
+
*/
|
|
2579
|
+
type TemplateCategoryId = 'flow' | 'org' | 'analysis' | 'plan' | 'uml' | 'tech';
|
|
2580
|
+
declare const TEMPLATE_CATEGORIES: {
|
|
2581
|
+
id: TemplateCategoryId;
|
|
2582
|
+
zh: string;
|
|
2583
|
+
en: string;
|
|
2584
|
+
}[];
|
|
2585
|
+
interface TemplateDef {
|
|
2586
|
+
id: string;
|
|
2587
|
+
cat: TemplateCategoryId;
|
|
2588
|
+
zh: string;
|
|
2589
|
+
en: string;
|
|
2590
|
+
/** 搜索关键词(中英混排,空格分词) */
|
|
2591
|
+
kw: string;
|
|
2592
|
+
build: () => Shape[];
|
|
2593
|
+
}
|
|
2594
|
+
declare const TEMPLATES: TemplateDef[];
|
|
2595
|
+
declare function templateById(id: string): TemplateDef | undefined;
|
|
2596
|
+
/** 搜索模板:中/英文名 + 关键词,空格分词全部命中 */
|
|
2597
|
+
declare function searchTemplates(query: string): TemplateDef[];
|
|
2598
|
+
|
|
2375
2599
|
/**
|
|
2376
2600
|
* 画板范围(Board Extent)—— 宿主用来决定「画板这块 DOM / 可滚区域该多大」。
|
|
2377
2601
|
*
|
|
@@ -2450,6 +2674,12 @@ interface ToolContext {
|
|
|
2450
2674
|
eraseShape(id: string): void;
|
|
2451
2675
|
selectShape(id: string, additive: boolean): void;
|
|
2452
2676
|
selectShapes(ids: string[]): void;
|
|
2677
|
+
/**
|
|
2678
|
+
* 绕过「组扩张」直接只选这一个图形。
|
|
2679
|
+
* 用于「点第二次进入组」:组已经被整组选中时,再点某个成员就把它单独选出来
|
|
2680
|
+
* (否则组内成员永远只能整组操作,改一个标签得先解组)。
|
|
2681
|
+
*/
|
|
2682
|
+
selectShapeRaw(id: string): void;
|
|
2453
2683
|
getShapes(): Shape[];
|
|
2454
2684
|
getSelectedIds(): string[];
|
|
2455
2685
|
setActiveTool(tool: ToolType): void;
|
|
@@ -2585,6 +2815,11 @@ declare class SelectTool extends Tool {
|
|
|
2585
2815
|
/** 把生成点位打包成创建上下文(from 为源点,to 为目标落点) */
|
|
2586
2816
|
private genContext;
|
|
2587
2817
|
onPointerDown(point: Vec2, event: PointerEvent): void;
|
|
2818
|
+
/**
|
|
2819
|
+
* 是否已经「进入」了 shape 所在的组:当前选区非空,且是这一组**严格子集**的成员。
|
|
2820
|
+
* 用于「组内逐成员切换」—— 进了组以后点同组其他成员不再整组扩张。
|
|
2821
|
+
*/
|
|
2822
|
+
private isInsideGroup;
|
|
2588
2823
|
/**
|
|
2589
2824
|
* 命中「表格左上角拖动把手」的表格。把手画在表格包围盒之外、普通 hitTest 命中不到,
|
|
2590
2825
|
* 所以这里单独判定;落点上若有别的图形则不抢(避免盖住别人的点击)。
|
|
@@ -2632,6 +2867,10 @@ declare class SelectTool extends Tool {
|
|
|
2632
2867
|
*
|
|
2633
2868
|
* 另外还要丢掉「其实属于自动走线的折点」(两端出/入桩的拐角,见 pruneStubBends):
|
|
2634
2869
|
* 它们是自动生成的,冻进 userPoints 后会让之后移动图形时端点旁长出小钩子。
|
|
2870
|
+
*
|
|
2871
|
+
* 同时记下 `userPointsBase`(这一刻的自动走线):之后布局一变(自动走线的形状签名变了),
|
|
2872
|
+
* 这些折点就按「过期」处理,连线自动回到当前布局下最简单的走线 —— 否则旧布局下
|
|
2873
|
+
* 绕出来的大回环会被一路带到新布局里,看着就像凭空多出一圈。
|
|
2635
2874
|
*/
|
|
2636
2875
|
private writeConnectorRoute;
|
|
2637
2876
|
/**
|
|
@@ -2684,6 +2923,11 @@ declare class SelectTool extends Tool {
|
|
|
2684
2923
|
/** 生成点位命中阈值 / 单击 vs 拖动判定阈值 */
|
|
2685
2924
|
private static readonly GEN_HIT_THRESHOLD;
|
|
2686
2925
|
private static readonly CLICK_MOVE_THRESHOLD;
|
|
2926
|
+
/**
|
|
2927
|
+
* 拖动起始阈值:小于这个距离的移动不生效。
|
|
2928
|
+
* 点击时鼠标/触控板的抖动(1~2px)以前会把图形真的挪动一点 —— 看着像"点一下就偏了"。
|
|
2929
|
+
*/
|
|
2930
|
+
private static readonly DRAG_START_THRESHOLD;
|
|
2687
2931
|
/**
|
|
2688
2932
|
* 「点击锚点生成图形」时源图形与新图形之间的默认间距(页面单位,**边到边**)。
|
|
2689
2933
|
* 旧实现是「中心沿法线外移 96」:对默认矩形(120×60)实际边距只有 36,看着太挤;
|
|
@@ -3123,4 +3367,4 @@ declare function imageDataUrl(src: string): string | null;
|
|
|
3123
3367
|
/** 清空缓存(测试/卸载时用;会释放自己创建的 blob 地址) */
|
|
3124
3368
|
declare function clearImageCache(): void;
|
|
3125
3369
|
|
|
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 };
|
|
3370
|
+
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, TEMPLATES, TEMPLATE_CATEGORIES, THEME, type TableCell, type TableShape, type TemplateCategoryId, type TemplateDef, 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, ensureIcons, ensureImagesLoaded, exportToBlob, findMindMapNode, getContentBounds, getIcon, getLanguage, getMindMapNodeDepth, getMindMapNodeSiblings, getMindMapParent, getTheme, hasIcon, hexToRgba, hitTableBody, hitTableMoveHandle, iconInk, iconsByCategory, imageDataUrl, isEmptyRect, isFlippableShapeType, isHorizontalDirection, isIconCatalogLoaded, isImageFailed, isImageLoading, isStubCorner, isUploaderFunction, layoutMindMap, loadIconCatalog, loadImage, mergeShallowSteps, mindMapHandleAtLocalPoint, mindMapNodeColor, mindMapNodeHandles, mindMapNodeSize, moveMindMapNodeInTree, offsetConnectorSegment, parseUploadResponse, peekImage, pickSegmentHandle, pointToSegmentDistance, promoteMindMapNodeInTree, pruneStubBends, rectsIntersect, renderSVGString, renderToCanvas, reorderMindMapNodeInTree, routeToUserPoints, sameRoute, searchIcons, searchTemplates, 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, templateById, umlAttrRowText, umlMethodRowText, unionRect, uploadImageViaConfig };
|