drawui-core 0.4.2 → 0.5.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/README.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  配套 React 封装见 [drawui-react](https://www.npmjs.com/package/drawui-react)。
8
8
 
9
+ > 🛠 **图片上传对接**(接 OSS / 自建后端)请看 [IMAGE_UPLOAD.md](./IMAGE_UPLOAD.md):含 30 MB 体积上限、60 s 超时、两种通道(`ImageUploadConfig` 与 `ImageUploader` 函数)、OSS CORS 与 STS 直传示例。
10
+
9
11
  ## 安装
10
12
 
11
13
  ```bash
@@ -61,6 +63,28 @@ interface EditorOptions {
61
63
 
62
64
  ## 更新日志
63
65
 
66
+ ### v0.5.1
67
+
68
+ > 主题:**思维导图四方向布局与交互重做**
69
+
70
+ - 🧭 **`MindMapNode` 新增 `direction` 字段**(`'right' | 'left' | 'up' | 'down'`):根节点无方向,子节点继承父方向;`layoutMindMap` 按四方向布局,根节点把子节点按方向分组各自生长。
71
+ - 🧭 **根节点四方向加号**:`handlePosOf` 对根遍历 `MINDMAP_DIRECTIONS` 生成四个 child 加号;非根节点 = 自身方向 child 加号 + 垂直方向 sibling 加号。
72
+ - 🔧 **连线按子节点方向绘制**:`drawMindMapConnections` 与导出 `mindMapSvg` 改用 `to.direction` 取四方向边缘 + 同构贝塞尔曲线,修复此前根节点的 left/up/down 子节点连线从右侧斜穿的 bug。
73
+ - ⚖️ **根节点一级子节点内边对齐**:布局改用孩子自身尺寸定位(`childSize`),一级孩子朝根内边严格对齐,子树尺寸不同也不会错开。
74
+ - 🔒 **拖拽 = 同方向重排序**(非自由拖):`getMindMapNodeSiblings` + `reorderMindMapNodeInTree`,跨方向互不交换;`calcMindMapReorderTarget` 排除被拖节点自身,需拖过邻节点中心才换位。
75
+ - 🟦 **重排落点预览**:`drawMindMapReorderIndicator` 改为与被拖节点等大的虚线圆角占位框。
76
+ - ✋ **点加号不进编辑态**:`addMindMapNodeFromHandle` 不再调 `beginMindMapEdit`,新节点仅成为活动节点 `mindMapSelectedNode`。
77
+ - 新增导出:`MINDMAP_DIRECTIONS`、`effectiveDirection`、`isHorizontalDirection`、`getMindMapNodeSiblings`、`reorderMindMapNodeInTree`、`MindMapDirection`(类型)。
78
+
79
+ ### v0.5.0
80
+
81
+ > 主题:**图片上传通道**(OSS / 自建后端友好)
82
+
83
+ - 🛡️ **单张图片体积上限 30 MB**:超过上限直接拒绝(抛 `image.tooLarge`),不会真的发请求;接入方可按需通过 `ImageUploadConfig.maxSizeBytes` 自定义。
84
+ - ⏱ **上传超时 30 s → 60 s**:默认 `timeoutMs` 从 30000 调整为 60000;同样支持 `ImageUploadConfig.timeoutMs` 自定义。
85
+ - 🧰 **新增 `ImageUploader` 函数通道**(优先级高于配置):需要自定义上传逻辑(OSS STS 直传、分片、压缩、重试、并发限流)时,传一个 `(file: File) => Promise<string>` 给 `imageUpload` 即可。
86
+ - 📄 **新增 [`IMAGE_UPLOAD.md`](./IMAGE_UPLOAD.md)**:接入方对接指南 —— 两条通道对比、调用链速览、10 个最容易踩的坑、上线前自检 checklist。
87
+
64
88
  ### v0.4.2
65
89
 
66
90
  - 🖱️ **右键菜单所需能力全部内置**:`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`)。
@@ -238,6 +262,28 @@ interface EditorOptions {
238
262
 
239
263
  ## Changelog
240
264
 
265
+ ### v0.5.1
266
+
267
+ > Theme: **Mind map four-direction layout & interaction rework**
268
+
269
+ - 🧭 **`MindMapNode` gains a `direction` field** (`'right' | 'left' | 'up' | 'down'`): the root has no direction; children inherit it from their parent. `layoutMindMap` groups the root's children by direction and grows each group independently.
270
+ - 🧭 **Root gets four-direction "+" handles**: `handlePosOf` walks `MINDMAP_DIRECTIONS` for the root; non-root nodes get one child handle (own direction) plus one sibling handle (perpendicular direction).
271
+ - 🔧 **Connections drawn by child direction**: `drawMindMapConnections` and the exported `mindMapSvg` now use `to.direction` for the four-direction edges with isomorphic bézier curves — fixes the previous bug where a root's `left`/`up`/`down` children were wired out from the right edge.
272
+ - ⚖️ **Root's first-level children align on their inner edge**: layout positions children by their own size, so the inner edge facing the root is strictly aligned even when subtrees differ in size.
273
+ - 🔒 **Drag = same-direction reordering** (no free drag): `getMindMapNodeSiblings` + `reorderMindMapNodeInTree`; cross-direction groups never swap. `calcMindMapReorderTarget` excludes the dragged node itself, so a swap only happens once the pointer passes a neighbour's center.
274
+ - 🟦 **Reorder drop preview**: `drawMindMapReorderIndicator` now draws a dashed rounded placeholder the same size as the dragged node.
275
+ - ✋ **Clicking "+" no longer enters text-edit**: `addMindMapNodeFromHandle` no longer calls `beginMindMapEdit`; the new node only becomes the active node (`mindMapSelectedNode`).
276
+ - New exports: `MINDMAP_DIRECTIONS`, `effectiveDirection`, `isHorizontalDirection`, `getMindMapNodeSiblings`, `reorderMindMapNodeInTree`, `MindMapDirection` (type).
277
+
278
+ ### v0.5.0
279
+
280
+ > Theme: **Image upload channel** (OSS / custom backend friendly)
281
+
282
+ - 🛡️ **30 MB per-image size cap**: oversized images are rejected before any request is sent (throws `image.tooLarge`); the cap can be overridden via `ImageUploadConfig.maxSizeBytes`.
283
+ - ⏱ **Upload timeout 30 s → 60 s**: default `timeoutMs` bumped from 30000 to 60000; still overridable per-config.
284
+ - 🧰 **New `ImageUploader` function channel** (takes priority over config): pass a `(file: File) => Promise<string>` to `imageUpload` whenever you need custom upload logic (OSS STS direct upload, chunking, compression, retries, concurrency limits).
285
+ - 📄 **New [`IMAGE_UPLOAD.md`](./IMAGE_UPLOAD.md)**: integration guide for hosts — both channels, call chain, 10 common OSS pitfalls, pre-release checklist.
286
+
241
287
  ### v0.4.2
242
288
 
243
289
  - 🖱️ **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`).