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/README.md +24 -0
- package/dist/index.cjs +20 -20
- package/dist/index.d.cts +141 -5
- package/dist/index.d.ts +141 -5
- package/dist/index.js +20 -20
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -61,6 +61,18 @@ interface EditorOptions {
|
|
|
61
61
|
|
|
62
62
|
## 更新日志
|
|
63
63
|
|
|
64
|
+
### v0.4.2
|
|
65
|
+
|
|
66
|
+
- 🖱️ **右键菜单所需能力全部内置**:`Editor` 新增一整套编辑操作 API —— `getSelectedShapes()` / `deleteSelected()` / `copySelected()` / `copySelectedAsImage()` / `paste()` / `duplicateSelected()` / `hasClipboard()` / `copyStyle()` / `pasteStyle()` / `hasCopiedStyle()` / `flipSelected('horizontal' | 'vertical')` / `rotateSelected90()` / `setSelectedShapesLocked()` / `setShapeLocked()` / `isShapeLocked()` / `bringToFront()` / `sendToBack()` / `bringForward()` / `sendBackward()`,全部走 `commitHistory()`,可撤销。同时内置对应快捷键(`Ctrl+C` / `Ctrl+Shift+C` / `Ctrl+V` / `Ctrl+D` / `Ctrl+Alt+C` / `Ctrl+Alt+V` / `Ctrl+Alt+L` / `Shift+H` / `Shift+V`)。
|
|
67
|
+
- 🔒 **锁定**:`BaseShape.locked` —— 锁定的图形不参与命中 / 框选 / 拖动 / 缩放 / 删除 / 双击编辑;`Renderer` 在包围盒右上角绘制**白底圆角挂锁标记**(20×20 屏幕像素,缩放不变),SVG / PNG 导出不带标记。新增 `isFlippableShapeType()`。
|
|
68
|
+
- 👥 **分组 = 给多个图形绑一把锁**:`BaseShape.groupId` + `Editor.groupSelected()` / `ungroupSelected()` / `setGroupLocked()` / `getSelectedGroupId()`,`Ctrl+G` / `Ctrl+Shift+G`。
|
|
69
|
+
- 成组时整组立即锁定;解锁后点任一成员即选中整组,拖动 / 删除 / 层级 / 复制整组生效,`Renderer` 画虚线组框。
|
|
70
|
+
- 复制 / 粘贴 / 创建副本时副本**自成新组**(`cloneWithOffset` 会重映射 `groupId`)。
|
|
71
|
+
- ↔️ **水平 / 垂直翻转**:`Shape.flipX` / `flipY`,在旋转后的本地坐标系里做镜像(`ctx.scale`),文字反向缩放保持可读;画布与 SVG 导出同源。文字、线条、箭头、手绘、表格、UML、思维导图、便签不支持翻转。
|
|
72
|
+
- 🖐️ **按住拖拽生成图形**:绘制工具按下后拖动超过 5px,图形锚定按下角随手势实时改尺寸;轻点仍是默认尺寸;`Shift` 拖动锁定默认宽高比;圆取拖拽矩形长边做直径;拖拽中 `Esc` 取消。
|
|
73
|
+
- 🚫 core 侧右键(`pointerdown` `button === 2`)直接短路,不会误入拖拽 / 框选状态,便于宿主自行接管 `contextmenu`。
|
|
74
|
+
- 🐞 **修复**:`setShapeLocked` 补上画布重绘(原先锁定后要等下一次交互才更新)。
|
|
75
|
+
|
|
64
76
|
### v0.4.1
|
|
65
77
|
|
|
66
78
|
- 📊 **新增图形「表格」(`table`)**:工具栏独立按钮 + 8×6 选择器一键插入,双击单元格就地编辑。
|
|
@@ -226,6 +238,18 @@ interface EditorOptions {
|
|
|
226
238
|
|
|
227
239
|
## Changelog
|
|
228
240
|
|
|
241
|
+
### v0.4.2
|
|
242
|
+
|
|
243
|
+
- 🖱️ **Everything a context menu needs, built into `Editor`**: `getSelectedShapes()` / `deleteSelected()` / `copySelected()` / `copySelectedAsImage()` / `paste()` / `duplicateSelected()` / `hasClipboard()` / `copyStyle()` / `pasteStyle()` / `hasCopiedStyle()` / `flipSelected('horizontal' | 'vertical')` / `rotateSelected90()` / `setSelectedShapesLocked()` / `setShapeLocked()` / `isShapeLocked()` / `bringToFront()` / `sendToBack()` / `bringForward()` / `sendBackward()` — all through `commitHistory()`, so every one of them is undoable. Matching shortcuts ship too (`Ctrl+C` / `Ctrl+Shift+C` / `Ctrl+V` / `Ctrl+D` / `Ctrl+Alt+C` / `Ctrl+Alt+V` / `Ctrl+Alt+L` / `Shift+H` / `Shift+V`).
|
|
244
|
+
- 🔒 **Locking**: `BaseShape.locked` — a locked shape is excluded from hit-testing, brushing, dragging, resizing, deleting and double-click editing. The renderer draws a **rounded white padlock badge** (20×20 screen pixels, zoom-independent) at the top-right of its bounds; SVG / PNG exports omit it. New `isFlippableShapeType()` helper.
|
|
245
|
+
- 👥 **Groups = one lock shared by several shapes**: `BaseShape.groupId` plus `Editor.groupSelected()` / `ungroupSelected()` / `setGroupLocked()` / `getSelectedGroupId()`, bound to `Ctrl+G` / `Ctrl+Shift+G`.
|
|
246
|
+
- Grouping locks the whole group immediately. Once unlocked, clicking any member selects the entire group, so dragging / deleting / reordering / copying applies to all of them, and the renderer draws a dashed frame around the group.
|
|
247
|
+
- Copied / pasted / duplicated shapes get a **fresh group id**, so copies never rejoin the original group (`cloneWithOffset` remaps `groupId`).
|
|
248
|
+
- ↔️ **Horizontal / vertical flip**: `Shape.flipX` / `flipY`, applied as `ctx.scale` in the rotated local space (so the flip direction follows rotation, like Feishu). Text is counter-scaled to stay readable, and SVG export mirrors the canvas. Text, lines, arrows, freehand, tables, UML, mind maps and sticky notes are not flippable.
|
|
249
|
+
- 🖐️ **Drag to size while drawing**: after pressing down, dragging more than 5px resizes the shape live, anchored at the press corner; a plain click still yields the default size. Hold `Shift` to lock the shape's default aspect ratio, circles take the longer drag edge as their diameter, and `Esc` mid-drag reverts to the default size.
|
|
250
|
+
- 🚫 Right-click (`pointerdown` with `button === 2`) short-circuits in core, so it never enters drag / brush state — hosts can safely take over `contextmenu`.
|
|
251
|
+
- 🐞 **Fixed**: `setShapeLocked` now repaints the canvas (previously the lock badge only appeared on the next interaction).
|
|
252
|
+
|
|
229
253
|
### v0.4.1
|
|
230
254
|
|
|
231
255
|
- 📊 **New `table` shape**: insert one from its own toolbar button with an 8×6 picker, then double-click any cell to edit in place.
|