@xiongtao.xt/tau-plugins 0.45.0 → 0.46.0

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.
@@ -107,20 +107,20 @@ export default definePlugin({ ...__PLUGIN_META__, whiteboardExtensions: [boxExte
107
107
 
108
108
  ### 元素声明
109
109
 
110
- | 字段 | 说明 |
111
- | -------------------------- | ------------------------------------------------------------------------------------ |
112
- | `type` | 元素类型 |
113
- | `render` | 渲染组件,收到 `element`,返回 SVG 内容 |
114
- | `presentation` | 可选。`label`(类型名)、`icon`(图标)、`getName(element)`(列表中显示的名称) |
115
- | `create` | 可选。创建方式,声明后才能注册创建型工具,见[创建工具](#创建工具) |
116
- | `interaction` | 可选。缩放手柄与连接点,见下文 |
117
- | `schema` | 可选。约束 `data` 结构的 [Standard Schema](https://standardschema.dev),必须同步校验 |
118
- | `dataVersion` | 必填正整数;表示业务数据版本,与插件发行版本分开 |
119
- | `collaboration.textFields` | 可选,data 中需要协作编辑的顶层字符串字段 |
120
- | `resources` | 可选,data 中资源位置的纯数据声明;不授予读取或上传权限 |
121
- | `previousVersions`、`migrations` | 可选,直接历史版本与纯业务载荷转换;加载不执行转换 |
122
- | `sketch` | 可选。为 `true` 时元素支持手绘画风,见[手绘画风](#手绘画风) |
123
- | `schematic` | 可选。简略预览,见[简略预览](#简略预览) |
110
+ | 字段 | 说明 |
111
+ | -------------------------------- | ------------------------------------------------------------------------------------ |
112
+ | `type` | 元素类型 |
113
+ | `render` | 渲染组件,收到 `element`,返回 SVG 内容 |
114
+ | `presentation` | 可选。`label`(类型名)、`icon`(图标)、`getName(element)`(列表中显示的名称) |
115
+ | `create` | 可选。创建方式,声明后才能注册创建型工具,见[创建工具](#创建工具) |
116
+ | `interaction` | 可选。缩放手柄与连接点,见下文 |
117
+ | `schema` | 可选。约束 `data` 结构的 [Standard Schema](https://standardschema.dev),必须同步校验 |
118
+ | `dataVersion` | 必填正整数;表示业务数据版本,与插件发行版本分开 |
119
+ | `collaboration.textFields` | 可选,data 中需要协作编辑的顶层字符串字段 |
120
+ | `resources` | 可选,data 中资源位置的纯数据声明;不授予读取或上传权限 |
121
+ | `previousVersions`、`migrations` | 可选,直接历史版本与纯业务载荷转换;加载不执行转换 |
122
+ | `sketch` | 可选。为 `true` 时元素支持手绘画风,见[手绘画风](#手绘画风) |
123
+ | `schematic` | 可选。简略预览,见[简略预览](#简略预览) |
124
124
 
125
125
  用 `defineElement<TData>` 声明 `data` 的类型,或者传入 `schema` 让类型自动推断:
126
126
 
@@ -170,15 +170,17 @@ const sourceV2 = defineElement({
170
170
  dataVersion: 2,
171
171
  collaboration: { textFields: ["code"] },
172
172
  previousVersions: [{ element: sourceV1, access: "read" }],
173
- migrations: [{
174
- from: 1,
175
- migrate(data) {
176
- if (typeof data.source !== "string" || Object.hasOwn(data, "code"))
177
- throw new Error("旧源码无效或目标字段已存在");
178
- const { source, ...rest } = data;
179
- return { ...rest, code: source };
173
+ migrations: [
174
+ {
175
+ from: 1,
176
+ migrate(data) {
177
+ if (typeof data.source !== "string" || Object.hasOwn(data, "code"))
178
+ throw new Error("旧源码无效或目标字段已存在");
179
+ const { source, ...rest } = data;
180
+ return { ...rest, code: source };
181
+ },
180
182
  },
181
- }],
183
+ ],
182
184
  });
183
185
  ```
184
186
 
@@ -253,24 +255,30 @@ panel: ({ run }) => (
253
255
 
254
256
  通过 `api` 修改画布,不要直接修改读到的元素对象:
255
257
 
256
- | 方法 | 用途 |
257
- | ----------------------------------------- | ---------------------------------------------- |
258
- | `api.updateElement(id, patch)` | 修改 name、完整 geometry、style |
259
- | `api.submit(commands, options?)` | 提交 create/set_node/set_data/move_node/remove_nodes 身份命令 |
260
- | `api.select(ids)` | 设置选区 |
261
- | `api.getElement(id)`、`api.getSnapshot()` | 读取元素与画布快照 |
262
- | `api.setActiveTool(id)` | 切换当前工具 |
263
- | `api.readonly` | 画布是否只读 |
258
+ | 方法 | 用途 |
259
+ | ----------------------------------------- | ------------------------------------------------------------- |
260
+ | `api.updateElement(id, patch)` | 修改 name、完整 geometry、style |
261
+ | `api.submit(commands, options?)` | 提交 create/set_node/set_data/move_node/remove_nodes 身份命令 |
262
+ | `api.select(ids)` | 设置选区 |
263
+ | `api.getElement(id)`、`api.getSnapshot()` | 读取元素与画布快照 |
264
+ | `api.setActiveTool(id)` | 切换当前工具 |
265
+ | `api.readonly` | 画布是否只读 |
264
266
 
265
267
  普通业务属性使用 `api.updateElementData(id, patch, { unset?, historyGroup? })`,未指定字段保留;文本字段使用 `api.getTextBinding(id, field)` 的观察修订与增量编辑,不通过普通 patch 覆盖。
266
268
 
267
269
  ```ts
268
270
  const pageId = api.getSnapshot().pageId;
269
- const { createdIds } = api.submit([{
270
- type: "create",
271
- element: { type: BOX, data: {}, geometry: { x: 20, y: 20, width: 120, height: 80, rotation: 0 } },
272
- parent: { kind: "page", id: pageId },
273
- }]);
271
+ const { createdIds } = api.submit([
272
+ {
273
+ type: "create",
274
+ element: {
275
+ type: BOX,
276
+ data: {},
277
+ geometry: { x: 20, y: 20, width: 120, height: 80, rotation: 0 },
278
+ },
279
+ parent: { kind: "page", id: pageId },
280
+ },
281
+ ]);
274
282
  api.updateElementData(createdIds[0], { label: "方块" });
275
283
  ```
276
284
 
package/package.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  validateBackendManifest,
14
14
  validatePluginManifest
15
15
  } from "./client/chunk-M3YEVDN4.js";
16
- import "./client/chunk-CEWYJJKJ.js";
16
+ import "./client/chunk-UTVEXGFI.js";
17
17
  export {
18
18
  PLUGIN_AI_CAPABILITIES,
19
19
  PLUGIN_CATEGORIES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiongtao.xt/tau-plugins",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
package/portable.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  validatePortablePluginManifest
9
9
  } from "./client/chunk-X6MBLKAL.js";
10
10
  import "./client/chunk-M3YEVDN4.js";
11
- import "./client/chunk-CEWYJJKJ.js";
11
+ import "./client/chunk-UTVEXGFI.js";
12
12
  export {
13
13
  PORTABLE_PLATFORMS,
14
14
  PORTABLE_SHARED_MODULES,