drawui-core 0.4.1 → 0.4.2

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/index.d.cts CHANGED
@@ -32,7 +32,20 @@ interface BaseShape {
32
32
  highlightColor?: string;
33
33
  /** 文字高亮背景透明度(0-1),缺省为 1 */
34
34
  highlightOpacity?: number;
35
+ /** 锁定:不可选中/拖动/缩放/删除(右键菜单可解锁) */
36
+ locked?: boolean;
37
+ /** 水平翻转(围绕自身中心镜像;文字/连线等不适用,见 isFlippableShapeType) */
38
+ flipX?: boolean;
39
+ /** 垂直翻转(围绕自身中心镜像) */
40
+ flipY?: boolean;
41
+ /**
42
+ * 分组 id:同一组的图形「同进同退」——点选任一成员即选中整组(一起拖动/删除/改变层级),
43
+ * 组锁定时整组都不可选中、不可拖动,等同于给多个图形绑了一把锁。
44
+ */
45
+ groupId?: string;
35
46
  }
47
+ /** 该类型的图形是否支持水平/垂直翻转(右键菜单据此禁用) */
48
+ declare function isFlippableShapeType(type: ShapeType): boolean;
36
49
  interface RectangleShape extends BaseShape {
37
50
  type: 'rectangle';
38
51
  width: number;
@@ -682,6 +695,26 @@ declare const zhCN: {
682
695
  readonly 'table.insertColLeft': "在左侧插入列";
683
696
  readonly 'table.insertColRight': "在右侧插入列";
684
697
  readonly 'table.pickHint': "拖选行列数";
698
+ readonly 'ctx.copy': "复制";
699
+ readonly 'ctx.copyAsImage': "复制为图片";
700
+ readonly 'ctx.paste': "粘贴";
701
+ readonly 'ctx.duplicate': "创建副本";
702
+ readonly 'ctx.layer': "层级";
703
+ readonly 'ctx.bringToFront': "置于顶层";
704
+ readonly 'ctx.bringForward': "上移一层";
705
+ readonly 'ctx.sendBackward': "下移一层";
706
+ readonly 'ctx.sendToBack': "置于底层";
707
+ readonly 'ctx.copyStyle': "复制样式";
708
+ readonly 'ctx.pasteStyle': "粘贴样式";
709
+ readonly 'ctx.flipH': "水平翻转";
710
+ readonly 'ctx.flipV': "垂直翻转";
711
+ readonly 'ctx.rotate': "旋转";
712
+ readonly 'ctx.group': "成组";
713
+ readonly 'ctx.ungroup': "解组";
714
+ readonly 'ctx.lock': "锁定";
715
+ readonly 'ctx.unlock': "解锁";
716
+ readonly 'ctx.unlockGroup': "解锁本组";
717
+ readonly 'ctx.delete': "删除";
685
718
  readonly 'toolbar.icon': "图标";
686
719
  readonly 'icon.search': "搜索图标";
687
720
  readonly 'icon.empty': "没有匹配的图标";
@@ -817,6 +850,9 @@ declare class Editor {
817
850
  private stickyNoteColor;
818
851
  /** 连续插入图标时的错开计数(避免每次都叠在同一处) */
819
852
  private iconInsertSeq;
853
+ private clipboardShapes;
854
+ private pasteSeq;
855
+ private copiedStyle;
820
856
  constructor(canvas: HTMLCanvasElement, options?: EditorOptions);
821
857
  private setupEventListeners;
822
858
  /** 窗口失焦(切页签/alt-tab):按下状态与一切瞬态预览都作废,避免"卡住" */
@@ -864,8 +900,43 @@ declare class Editor {
864
900
  private updateBoundArrows;
865
901
  private getBindingPosition;
866
902
  private deleteShape;
867
- private selectShape;
868
- private selectShapes;
903
+ /**
904
+ * 选中图形(additive=true 时切换选中态);id 为空串清空选中。右键菜单/外部控制用。
905
+ * ⚠️ 组感知:点任一成员都会选中它所属的整组(同组的绑行为一致),additive 时整组一起加减。
906
+ */
907
+ selectShape(id: string, additive: boolean): void;
908
+ /** 整体替换选中集(右键菜单/外部控制用);框选结果同样按组扩张 */
909
+ selectShapes(ids: string[]): void;
910
+ /** 某图形所在的整组 id 列表(不在组里就只有它自己) */
911
+ private getGroupMembers;
912
+ /** 选中集是否恰好是完整的一个组(返回 groupId,否则 null) */
913
+ getSelectedGroupId(): string | null;
914
+ /** 选中集里是否包含成组图形(用于右键菜单显示「解组」) */
915
+ hasSelectedGroup(): boolean;
916
+ /** 取某个组的所有成员 id(含锁定的成员) */
917
+ private groupMemberIds;
918
+ /**
919
+ * 成组:把选中图形绑成一个整体,并整组锁定(同飞书「组合后不再被选中」的观感,
920
+ * 用户想改动先解锁,解锁后整组仍同进同退:点任一成员 = 选中整组一起拖)。
921
+ * @returns 新建的 groupId;选中不足 2 个时返回 null
922
+ */
923
+ groupSelected(): string | null;
924
+ /**
925
+ * 解组:清掉这些图形的组标记并顺带解锁(整组一起解,即使只选中了组内一部分成员)。
926
+ * @returns 是否确实解掉了组
927
+ */
928
+ ungroupSelected(): boolean;
929
+ /** 解掉指定 gid 的组(内部统一入口,含 locked 清理) */
930
+ ungroupIds(groupIds: string[]): boolean;
931
+ /** 整组锁定/解锁(groupId 相同的图形一起改) */
932
+ setGroupLocked(groupId: string, locked: boolean): boolean;
933
+ /**
934
+ * 无视「组/锁定」直接选中一个图形(仅供右键菜单:右键命中锁定的组成员要能把整组选上,
935
+ * 否则用户没有任何入口把组解锁)。普通点选一律走 selectShape。
936
+ */
937
+ selectShapeRaw(id: string): void;
938
+ /** 选中集里任一成员所属的组 id(右键菜单「解锁本组」用) */
939
+ getGroupIdOfSelected(): string | null;
869
940
  private setBrushRect;
870
941
  /** 设置对齐参考线(由工具在拖拽过程中调用) */
871
942
  private setSnapGuides;
@@ -927,6 +998,51 @@ declare class Editor {
927
998
  }): void;
928
999
  /** 批量更新选中线条/箭头的连线类型 */
929
1000
  updateConnectionType(connectionType: ConnectionType): void;
1001
+ /** 获取选中的图形(按画布层级顺序,即 shapes 数组顺序) */
1002
+ getSelectedShapes(): Shape[];
1003
+ /** 是否正处于就地编辑(编辑文字/表格/思维导图节点) */
1004
+ isEditing(): boolean;
1005
+ /** 删除选中的图形(锁定的图形跳过),返回是否有删除 */
1006
+ deleteSelected(): boolean;
1007
+ /** 复制选中的图形到内部剪贴板(锁定的图形跳过) */
1008
+ copySelected(): boolean;
1009
+ /** 内部剪贴板里是否有可粘贴的内容 */
1010
+ hasClipboard(): boolean;
1011
+ /** 深拷贝一批图形并生成新 id、平移 offset(连线的世界坐标 points / 手工折点同步平移) */
1012
+ private cloneWithOffset;
1013
+ /** 粘贴内部剪贴板:副本阶梯偏移并选中,一步撤销 */
1014
+ paste(): boolean;
1015
+ /** 在原位创建选中图形的副本(偏移一点并选中副本),一步撤销 */
1016
+ duplicateSelected(): boolean;
1017
+ /** 把选中的图形导出为 PNG 并写入系统剪贴板(透明背景),返回是否成功 */
1018
+ copySelectedAsImage(): Promise<boolean>;
1019
+ /** 复制第一个选中图形的样式(边框/填充/文字色/字号) */
1020
+ copyStyle(): boolean;
1021
+ /** 是否已经复制过样式(右键菜单「粘贴样式」的可用条件) */
1022
+ hasCopiedStyle(): boolean;
1023
+ /** 把复制的样式粘贴到所有选中图形(一步撤销) */
1024
+ pasteStyle(): boolean;
1025
+ /**
1026
+ * 水平/垂直翻转选中的图形(围绕各自中心镜像,toggle 语义)。
1027
+ * 文字/连线/表格/UML/思维导图/便签不支持翻转(isFlippableShapeType),会被跳过。
1028
+ */
1029
+ flipSelected(axis: 'horizontal' | 'vertical'): boolean;
1030
+ /** 选中图形旋转 90°(clockwise=false 为逆时针),一步撤销 */
1031
+ rotateSelected90(clockwise?: boolean): boolean;
1032
+ /** 锁定/解锁选中图形;锁定后自动取消选中(锁定图形不可选中) */
1033
+ setSelectedShapesLocked(locked: boolean): boolean;
1034
+ /** 锁定/解锁指定图形(右键锁定的图形时用它解锁,图形不必在选中集里) */
1035
+ setShapeLocked(id: string, locked: boolean): boolean;
1036
+ /** 某个图形是否被锁定 */
1037
+ isShapeLocked(id: string): boolean;
1038
+ /** 置于顶层:选中的图形整体移到最上面(保持它们之间的相对顺序) */
1039
+ bringToFront(): boolean;
1040
+ /** 置于底层:选中的图形整体移到最下面 */
1041
+ sendToBack(): boolean;
1042
+ /** 上移一层:每个选中图形与它上面相邻的非选中图形交换 */
1043
+ bringForward(): boolean;
1044
+ /** 下移一层:每个选中图形与它下面相邻的非选中图形交换 */
1045
+ sendBackward(): boolean;
930
1046
  /** 批量更新选中箭头的箭头类型 */
931
1047
  updateArrowHeadType(arrowHead: ArrowHeadType): void;
932
1048
  /**
@@ -1654,6 +1770,16 @@ declare class Renderer {
1654
1770
  private drawArrowHeads;
1655
1771
  private drawText;
1656
1772
  private drawFreehand;
1773
+ /**
1774
+ * 锁定标记:图形右上角画一枚小挂锁(尺寸按屏幕像素恒定),
1775
+ * 独立于选中态 —— 锁定的图形通常选不中,得靠这枚锁告诉用户「它为什么点不动」。
1776
+ */
1777
+ private drawLockBadge;
1778
+ /**
1779
+ * 组外框:选中集恰好是一个完整的组(且不止一个成员)时,给整组描一圈虚线,
1780
+ * 提示「这些图形是绑在一起的」。整组锁定的成员画不到(成员不可选),不需要外框。
1781
+ */
1782
+ private drawGroupFrames;
1657
1783
  private drawSelectionOutline;
1658
1784
  private drawSelectionHandles;
1659
1785
  /**
@@ -2137,12 +2263,22 @@ declare function calcUmlClassSize(className: string, attributes: UmlAttribute[],
2137
2263
  };
2138
2264
  declare class ShapeTool extends Tool {
2139
2265
  type: ShapeType;
2266
+ /** 按下点(页面坐标);null = 未按下 */
2267
+ private pressPoint;
2268
+ /** 本次按下的图形 id(按下即生成默认尺寸,拖动只改它的大小) */
2269
+ private draftId;
2270
+ /** 是否已进入拖拽状态(超过阈值) */
2271
+ private dragging;
2140
2272
  constructor(context: ToolContext, shapeType: ShapeType);
2141
2273
  onPointerDown(point: Vec2, _event: PointerEvent): void;
2142
- onPointerMove(_point: Vec2, _event: PointerEvent): void;
2274
+ onPointerMove(point: Vec2, event: PointerEvent): void;
2143
2275
  onPointerUp(_point: Vec2, _event: PointerEvent): void;
2144
- onKeyDown(_event: KeyboardEvent): void;
2276
+ onKeyDown(event: KeyboardEvent): void;
2145
2277
  onKeyUp(_event: KeyboardEvent): void;
2278
+ /** 拖拽生成中 = 一次未结束的交互(指针丢失时编辑器会来收尾) */
2279
+ hasTransientState(): boolean;
2280
+ /** 丢事件自愈:保持图形当前尺寸落定(历史点在按下时已记),清掉拖拽状态 */
2281
+ cancelTransient(): boolean;
2146
2282
  getCursor(point: Vec2): string | null;
2147
2283
  }
2148
2284
 
@@ -2428,4 +2564,4 @@ declare function umlAttrRowText(a: UmlAttribute): string;
2428
2564
  /** 方法行:`+ name(params): returnType`;同上 */
2429
2565
  declare function umlMethodRowText(m: UmlMethod): string;
2430
2566
 
2431
- export { type ArrowBinding, type ArrowHeadType, type ArrowShape, type ArrowStyle, ArrowTool, Camera, type CameraState, type CircleShape, type ConnectionType, DEFAULT_HIGHLIGHTER_COLOR, 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, LANGUAGES, type Language, type LineShape, LineTool, MINDMAP_COLORS, MINDMAP_FONT_SIZE, MINDMAP_MAX_WIDTH, MINDMAP_MIN_WIDTH, MINDMAP_NODE_HEIGHT, MIN_HANDLE_SEGMENT, MIN_JOG, Mat2d, type MessageKey, 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, calcUmlClassSize, cloneMindMapNode, cloneTable, cloneTableCells, collapseRoute, connectorSegmentHandles, countMindMapNodes, createTableCells, downloadBlob, exportToBlob, findMindMapNode, getContentBounds, getIcon, getLanguage, getMindMapNodeDepth, getMindMapParent, getTheme, hasIcon, hexToRgba, hitTableBody, hitTableMoveHandle, iconInk, iconsByCategory, isStubCorner, layoutMindMap, mindMapNodeColor, mindMapNodeSize, offsetConnectorSegment, pickSegmentHandle, pointToSegmentDistance, pruneStubBends, renderSVGString, renderToCanvas, routeToUserPoints, sameRoute, searchIcons, setLanguage, setTheme, shadeColor, subscribeLanguage, subscribeTheme, 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 };
2567
+ export { type ArrowBinding, type ArrowHeadType, type ArrowShape, type ArrowStyle, ArrowTool, Camera, type CameraState, type CircleShape, type ConnectionType, DEFAULT_HIGHLIGHTER_COLOR, 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, LANGUAGES, type Language, type LineShape, LineTool, MINDMAP_COLORS, MINDMAP_FONT_SIZE, MINDMAP_MAX_WIDTH, MINDMAP_MIN_WIDTH, MINDMAP_NODE_HEIGHT, MIN_HANDLE_SEGMENT, MIN_JOG, Mat2d, type MessageKey, 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, calcUmlClassSize, cloneMindMapNode, cloneTable, cloneTableCells, collapseRoute, connectorSegmentHandles, countMindMapNodes, createTableCells, downloadBlob, exportToBlob, findMindMapNode, getContentBounds, getIcon, getLanguage, getMindMapNodeDepth, getMindMapParent, getTheme, hasIcon, hexToRgba, hitTableBody, hitTableMoveHandle, iconInk, iconsByCategory, isFlippableShapeType, isStubCorner, layoutMindMap, mindMapNodeColor, mindMapNodeSize, offsetConnectorSegment, pickSegmentHandle, pointToSegmentDistance, pruneStubBends, renderSVGString, renderToCanvas, routeToUserPoints, sameRoute, searchIcons, setLanguage, setTheme, shadeColor, subscribeLanguage, subscribeTheme, 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 };
package/dist/index.d.ts CHANGED
@@ -32,7 +32,20 @@ interface BaseShape {
32
32
  highlightColor?: string;
33
33
  /** 文字高亮背景透明度(0-1),缺省为 1 */
34
34
  highlightOpacity?: number;
35
+ /** 锁定:不可选中/拖动/缩放/删除(右键菜单可解锁) */
36
+ locked?: boolean;
37
+ /** 水平翻转(围绕自身中心镜像;文字/连线等不适用,见 isFlippableShapeType) */
38
+ flipX?: boolean;
39
+ /** 垂直翻转(围绕自身中心镜像) */
40
+ flipY?: boolean;
41
+ /**
42
+ * 分组 id:同一组的图形「同进同退」——点选任一成员即选中整组(一起拖动/删除/改变层级),
43
+ * 组锁定时整组都不可选中、不可拖动,等同于给多个图形绑了一把锁。
44
+ */
45
+ groupId?: string;
35
46
  }
47
+ /** 该类型的图形是否支持水平/垂直翻转(右键菜单据此禁用) */
48
+ declare function isFlippableShapeType(type: ShapeType): boolean;
36
49
  interface RectangleShape extends BaseShape {
37
50
  type: 'rectangle';
38
51
  width: number;
@@ -682,6 +695,26 @@ declare const zhCN: {
682
695
  readonly 'table.insertColLeft': "在左侧插入列";
683
696
  readonly 'table.insertColRight': "在右侧插入列";
684
697
  readonly 'table.pickHint': "拖选行列数";
698
+ readonly 'ctx.copy': "复制";
699
+ readonly 'ctx.copyAsImage': "复制为图片";
700
+ readonly 'ctx.paste': "粘贴";
701
+ readonly 'ctx.duplicate': "创建副本";
702
+ readonly 'ctx.layer': "层级";
703
+ readonly 'ctx.bringToFront': "置于顶层";
704
+ readonly 'ctx.bringForward': "上移一层";
705
+ readonly 'ctx.sendBackward': "下移一层";
706
+ readonly 'ctx.sendToBack': "置于底层";
707
+ readonly 'ctx.copyStyle': "复制样式";
708
+ readonly 'ctx.pasteStyle': "粘贴样式";
709
+ readonly 'ctx.flipH': "水平翻转";
710
+ readonly 'ctx.flipV': "垂直翻转";
711
+ readonly 'ctx.rotate': "旋转";
712
+ readonly 'ctx.group': "成组";
713
+ readonly 'ctx.ungroup': "解组";
714
+ readonly 'ctx.lock': "锁定";
715
+ readonly 'ctx.unlock': "解锁";
716
+ readonly 'ctx.unlockGroup': "解锁本组";
717
+ readonly 'ctx.delete': "删除";
685
718
  readonly 'toolbar.icon': "图标";
686
719
  readonly 'icon.search': "搜索图标";
687
720
  readonly 'icon.empty': "没有匹配的图标";
@@ -817,6 +850,9 @@ declare class Editor {
817
850
  private stickyNoteColor;
818
851
  /** 连续插入图标时的错开计数(避免每次都叠在同一处) */
819
852
  private iconInsertSeq;
853
+ private clipboardShapes;
854
+ private pasteSeq;
855
+ private copiedStyle;
820
856
  constructor(canvas: HTMLCanvasElement, options?: EditorOptions);
821
857
  private setupEventListeners;
822
858
  /** 窗口失焦(切页签/alt-tab):按下状态与一切瞬态预览都作废,避免"卡住" */
@@ -864,8 +900,43 @@ declare class Editor {
864
900
  private updateBoundArrows;
865
901
  private getBindingPosition;
866
902
  private deleteShape;
867
- private selectShape;
868
- private selectShapes;
903
+ /**
904
+ * 选中图形(additive=true 时切换选中态);id 为空串清空选中。右键菜单/外部控制用。
905
+ * ⚠️ 组感知:点任一成员都会选中它所属的整组(同组的绑行为一致),additive 时整组一起加减。
906
+ */
907
+ selectShape(id: string, additive: boolean): void;
908
+ /** 整体替换选中集(右键菜单/外部控制用);框选结果同样按组扩张 */
909
+ selectShapes(ids: string[]): void;
910
+ /** 某图形所在的整组 id 列表(不在组里就只有它自己) */
911
+ private getGroupMembers;
912
+ /** 选中集是否恰好是完整的一个组(返回 groupId,否则 null) */
913
+ getSelectedGroupId(): string | null;
914
+ /** 选中集里是否包含成组图形(用于右键菜单显示「解组」) */
915
+ hasSelectedGroup(): boolean;
916
+ /** 取某个组的所有成员 id(含锁定的成员) */
917
+ private groupMemberIds;
918
+ /**
919
+ * 成组:把选中图形绑成一个整体,并整组锁定(同飞书「组合后不再被选中」的观感,
920
+ * 用户想改动先解锁,解锁后整组仍同进同退:点任一成员 = 选中整组一起拖)。
921
+ * @returns 新建的 groupId;选中不足 2 个时返回 null
922
+ */
923
+ groupSelected(): string | null;
924
+ /**
925
+ * 解组:清掉这些图形的组标记并顺带解锁(整组一起解,即使只选中了组内一部分成员)。
926
+ * @returns 是否确实解掉了组
927
+ */
928
+ ungroupSelected(): boolean;
929
+ /** 解掉指定 gid 的组(内部统一入口,含 locked 清理) */
930
+ ungroupIds(groupIds: string[]): boolean;
931
+ /** 整组锁定/解锁(groupId 相同的图形一起改) */
932
+ setGroupLocked(groupId: string, locked: boolean): boolean;
933
+ /**
934
+ * 无视「组/锁定」直接选中一个图形(仅供右键菜单:右键命中锁定的组成员要能把整组选上,
935
+ * 否则用户没有任何入口把组解锁)。普通点选一律走 selectShape。
936
+ */
937
+ selectShapeRaw(id: string): void;
938
+ /** 选中集里任一成员所属的组 id(右键菜单「解锁本组」用) */
939
+ getGroupIdOfSelected(): string | null;
869
940
  private setBrushRect;
870
941
  /** 设置对齐参考线(由工具在拖拽过程中调用) */
871
942
  private setSnapGuides;
@@ -927,6 +998,51 @@ declare class Editor {
927
998
  }): void;
928
999
  /** 批量更新选中线条/箭头的连线类型 */
929
1000
  updateConnectionType(connectionType: ConnectionType): void;
1001
+ /** 获取选中的图形(按画布层级顺序,即 shapes 数组顺序) */
1002
+ getSelectedShapes(): Shape[];
1003
+ /** 是否正处于就地编辑(编辑文字/表格/思维导图节点) */
1004
+ isEditing(): boolean;
1005
+ /** 删除选中的图形(锁定的图形跳过),返回是否有删除 */
1006
+ deleteSelected(): boolean;
1007
+ /** 复制选中的图形到内部剪贴板(锁定的图形跳过) */
1008
+ copySelected(): boolean;
1009
+ /** 内部剪贴板里是否有可粘贴的内容 */
1010
+ hasClipboard(): boolean;
1011
+ /** 深拷贝一批图形并生成新 id、平移 offset(连线的世界坐标 points / 手工折点同步平移) */
1012
+ private cloneWithOffset;
1013
+ /** 粘贴内部剪贴板:副本阶梯偏移并选中,一步撤销 */
1014
+ paste(): boolean;
1015
+ /** 在原位创建选中图形的副本(偏移一点并选中副本),一步撤销 */
1016
+ duplicateSelected(): boolean;
1017
+ /** 把选中的图形导出为 PNG 并写入系统剪贴板(透明背景),返回是否成功 */
1018
+ copySelectedAsImage(): Promise<boolean>;
1019
+ /** 复制第一个选中图形的样式(边框/填充/文字色/字号) */
1020
+ copyStyle(): boolean;
1021
+ /** 是否已经复制过样式(右键菜单「粘贴样式」的可用条件) */
1022
+ hasCopiedStyle(): boolean;
1023
+ /** 把复制的样式粘贴到所有选中图形(一步撤销) */
1024
+ pasteStyle(): boolean;
1025
+ /**
1026
+ * 水平/垂直翻转选中的图形(围绕各自中心镜像,toggle 语义)。
1027
+ * 文字/连线/表格/UML/思维导图/便签不支持翻转(isFlippableShapeType),会被跳过。
1028
+ */
1029
+ flipSelected(axis: 'horizontal' | 'vertical'): boolean;
1030
+ /** 选中图形旋转 90°(clockwise=false 为逆时针),一步撤销 */
1031
+ rotateSelected90(clockwise?: boolean): boolean;
1032
+ /** 锁定/解锁选中图形;锁定后自动取消选中(锁定图形不可选中) */
1033
+ setSelectedShapesLocked(locked: boolean): boolean;
1034
+ /** 锁定/解锁指定图形(右键锁定的图形时用它解锁,图形不必在选中集里) */
1035
+ setShapeLocked(id: string, locked: boolean): boolean;
1036
+ /** 某个图形是否被锁定 */
1037
+ isShapeLocked(id: string): boolean;
1038
+ /** 置于顶层:选中的图形整体移到最上面(保持它们之间的相对顺序) */
1039
+ bringToFront(): boolean;
1040
+ /** 置于底层:选中的图形整体移到最下面 */
1041
+ sendToBack(): boolean;
1042
+ /** 上移一层:每个选中图形与它上面相邻的非选中图形交换 */
1043
+ bringForward(): boolean;
1044
+ /** 下移一层:每个选中图形与它下面相邻的非选中图形交换 */
1045
+ sendBackward(): boolean;
930
1046
  /** 批量更新选中箭头的箭头类型 */
931
1047
  updateArrowHeadType(arrowHead: ArrowHeadType): void;
932
1048
  /**
@@ -1654,6 +1770,16 @@ declare class Renderer {
1654
1770
  private drawArrowHeads;
1655
1771
  private drawText;
1656
1772
  private drawFreehand;
1773
+ /**
1774
+ * 锁定标记:图形右上角画一枚小挂锁(尺寸按屏幕像素恒定),
1775
+ * 独立于选中态 —— 锁定的图形通常选不中,得靠这枚锁告诉用户「它为什么点不动」。
1776
+ */
1777
+ private drawLockBadge;
1778
+ /**
1779
+ * 组外框:选中集恰好是一个完整的组(且不止一个成员)时,给整组描一圈虚线,
1780
+ * 提示「这些图形是绑在一起的」。整组锁定的成员画不到(成员不可选),不需要外框。
1781
+ */
1782
+ private drawGroupFrames;
1657
1783
  private drawSelectionOutline;
1658
1784
  private drawSelectionHandles;
1659
1785
  /**
@@ -2137,12 +2263,22 @@ declare function calcUmlClassSize(className: string, attributes: UmlAttribute[],
2137
2263
  };
2138
2264
  declare class ShapeTool extends Tool {
2139
2265
  type: ShapeType;
2266
+ /** 按下点(页面坐标);null = 未按下 */
2267
+ private pressPoint;
2268
+ /** 本次按下的图形 id(按下即生成默认尺寸,拖动只改它的大小) */
2269
+ private draftId;
2270
+ /** 是否已进入拖拽状态(超过阈值) */
2271
+ private dragging;
2140
2272
  constructor(context: ToolContext, shapeType: ShapeType);
2141
2273
  onPointerDown(point: Vec2, _event: PointerEvent): void;
2142
- onPointerMove(_point: Vec2, _event: PointerEvent): void;
2274
+ onPointerMove(point: Vec2, event: PointerEvent): void;
2143
2275
  onPointerUp(_point: Vec2, _event: PointerEvent): void;
2144
- onKeyDown(_event: KeyboardEvent): void;
2276
+ onKeyDown(event: KeyboardEvent): void;
2145
2277
  onKeyUp(_event: KeyboardEvent): void;
2278
+ /** 拖拽生成中 = 一次未结束的交互(指针丢失时编辑器会来收尾) */
2279
+ hasTransientState(): boolean;
2280
+ /** 丢事件自愈:保持图形当前尺寸落定(历史点在按下时已记),清掉拖拽状态 */
2281
+ cancelTransient(): boolean;
2146
2282
  getCursor(point: Vec2): string | null;
2147
2283
  }
2148
2284
 
@@ -2428,4 +2564,4 @@ declare function umlAttrRowText(a: UmlAttribute): string;
2428
2564
  /** 方法行:`+ name(params): returnType`;同上 */
2429
2565
  declare function umlMethodRowText(m: UmlMethod): string;
2430
2566
 
2431
- export { type ArrowBinding, type ArrowHeadType, type ArrowShape, type ArrowStyle, ArrowTool, Camera, type CameraState, type CircleShape, type ConnectionType, DEFAULT_HIGHLIGHTER_COLOR, 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, LANGUAGES, type Language, type LineShape, LineTool, MINDMAP_COLORS, MINDMAP_FONT_SIZE, MINDMAP_MAX_WIDTH, MINDMAP_MIN_WIDTH, MINDMAP_NODE_HEIGHT, MIN_HANDLE_SEGMENT, MIN_JOG, Mat2d, type MessageKey, 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, calcUmlClassSize, cloneMindMapNode, cloneTable, cloneTableCells, collapseRoute, connectorSegmentHandles, countMindMapNodes, createTableCells, downloadBlob, exportToBlob, findMindMapNode, getContentBounds, getIcon, getLanguage, getMindMapNodeDepth, getMindMapParent, getTheme, hasIcon, hexToRgba, hitTableBody, hitTableMoveHandle, iconInk, iconsByCategory, isStubCorner, layoutMindMap, mindMapNodeColor, mindMapNodeSize, offsetConnectorSegment, pickSegmentHandle, pointToSegmentDistance, pruneStubBends, renderSVGString, renderToCanvas, routeToUserPoints, sameRoute, searchIcons, setLanguage, setTheme, shadeColor, subscribeLanguage, subscribeTheme, 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 };
2567
+ export { type ArrowBinding, type ArrowHeadType, type ArrowShape, type ArrowStyle, ArrowTool, Camera, type CameraState, type CircleShape, type ConnectionType, DEFAULT_HIGHLIGHTER_COLOR, 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, LANGUAGES, type Language, type LineShape, LineTool, MINDMAP_COLORS, MINDMAP_FONT_SIZE, MINDMAP_MAX_WIDTH, MINDMAP_MIN_WIDTH, MINDMAP_NODE_HEIGHT, MIN_HANDLE_SEGMENT, MIN_JOG, Mat2d, type MessageKey, 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, calcUmlClassSize, cloneMindMapNode, cloneTable, cloneTableCells, collapseRoute, connectorSegmentHandles, countMindMapNodes, createTableCells, downloadBlob, exportToBlob, findMindMapNode, getContentBounds, getIcon, getLanguage, getMindMapNodeDepth, getMindMapParent, getTheme, hasIcon, hexToRgba, hitTableBody, hitTableMoveHandle, iconInk, iconsByCategory, isFlippableShapeType, isStubCorner, layoutMindMap, mindMapNodeColor, mindMapNodeSize, offsetConnectorSegment, pickSegmentHandle, pointToSegmentDistance, pruneStubBends, renderSVGString, renderToCanvas, routeToUserPoints, sameRoute, searchIcons, setLanguage, setTheme, shadeColor, subscribeLanguage, subscribeTheme, 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 };