@xiongtao.xt/tau-plugins 0.55.0 → 0.57.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/docs/README.md +86 -21
  3. package/docs/ai.md +17 -14
  4. package/docs/app-surfaces.md +267 -0
  5. package/docs/backend.md +5 -6
  6. package/docs/blog-templates.md +199 -0
  7. package/docs/document-body.md +126 -0
  8. package/docs/editor-collaboration.md +135 -49
  9. package/docs/editor-export.md +154 -0
  10. package/docs/editor-interactions.md +254 -0
  11. package/docs/editor-source-media.md +397 -0
  12. package/docs/editor.md +68 -523
  13. package/docs/excerpts.md +22 -6
  14. package/docs/flashcards.md +18 -5
  15. package/docs/getting-started.md +80 -30
  16. package/docs/mcp.md +26 -11
  17. package/docs/notifications-and-voice.md +219 -0
  18. package/docs/pages.md +374 -0
  19. package/docs/permissions.md +126 -0
  20. package/docs/plugin-basics.md +67 -53
  21. package/docs/plugin-content.md +263 -0
  22. package/docs/portability.md +62 -40
  23. package/docs/providers/README.md +153 -41
  24. package/docs/providers/asr.md +104 -11
  25. package/docs/providers/embeddings.md +3 -7
  26. package/docs/providers/images.md +3 -3
  27. package/docs/providers/publish.md +48 -10
  28. package/docs/providers/sync.md +5 -64
  29. package/docs/providers/tts.md +2 -2
  30. package/docs/providers/upload.md +4 -59
  31. package/docs/providers/video.md +37 -6
  32. package/docs/references.md +183 -0
  33. package/docs/release.md +21 -16
  34. package/docs/services.md +15 -9
  35. package/docs/settings-and-commands.md +168 -0
  36. package/docs/site-data.md +30 -9
  37. package/docs/skills.md +14 -7
  38. package/docs/storage-and-network.md +4 -5
  39. package/docs/ui-components.md +92 -0
  40. package/docs/ui.md +25 -813
  41. package/docs/user-data.md +64 -623
  42. package/docs/whiteboard.md +110 -32
  43. package/docs/windows.md +83 -0
  44. package/package.json +1 -1
  45. package/publish-artifacts.js +57 -13
  46. package/tailwind.css +20 -0
  47. package/types/packages/asr/src/types.d.ts +2 -0
  48. package/types/packages/collaboration/src/document-membership.d.ts +4 -0
  49. package/types/packages/collaboration/src/document-operations.d.ts +8 -2
  50. package/types/packages/collaboration/src/document-protocol.d.ts +13 -0
  51. package/types/packages/collaboration/src/encoding.d.ts +1 -1
  52. package/types/packages/collaboration/src/index.d.ts +3 -0
  53. package/types/packages/collaboration/src/member-activities.d.ts +8 -0
  54. package/types/packages/collaboration/src/node-tree.d.ts +4 -1
  55. package/types/packages/collaboration/src/protocol.d.ts +7 -3
  56. package/types/packages/collaboration/src/scoped-content-edit.d.ts +91 -0
  57. package/types/packages/editor/src/core/CoreEditor.d.ts +3 -0
  58. package/types/packages/editor/src/core/api/clipboardFragment.d.ts +14 -0
  59. package/types/packages/editor/src/core/api/drag.d.ts +1 -1
  60. package/types/packages/editor/src/core/api/index.d.ts +3 -0
  61. package/types/packages/editor/src/core/api/marks.d.ts +2 -0
  62. package/types/packages/editor/src/core/index.d.ts +1 -0
  63. package/types/packages/editor/src/core/inlineSuggestion/controller.d.ts +29 -0
  64. package/types/packages/editor/src/core/inlineSuggestion/providerContext.d.ts +3 -0
  65. package/types/packages/editor/src/core/utils/nodeOperations.d.ts +1 -1
  66. package/types/packages/editor/src/extensions/table/src/types.d.ts +4 -0
  67. package/types/packages/editor/text-field-contract.d.ts +3 -0
  68. package/types/packages/plugins/src/contract.d.ts +3 -0
  69. package/types/packages/plugins/src/environment.d.ts +3 -0
  70. package/types/packages/plugins/src/excerpts.d.ts +3 -0
  71. package/types/packages/plugins/src/foreground-host.d.ts +8 -0
  72. package/types/packages/plugins/src/index.d.ts +1 -0
  73. package/types/packages/plugins/src/publish-data.d.ts +4 -0
  74. package/types/packages/plugins/src/windows.d.ts +76 -0
  75. package/types/packages/themes/src/tokenContract.d.ts +1 -0
  76. package/types/packages/ui/src/hooks/scrollbarAutoHide.d.ts +1 -1
@@ -0,0 +1,397 @@
1
+ # 源码块与媒体块
2
+
3
+ 用户写一段源码、下方实时显示结果的块(图表、公式、乐谱、组件演示),用 `SourceBlockEditor` 套上 Tau 统一的源码编辑外壳,不必从头写编辑交互。块里要显示图片、视频、音频时,用 Tau 的媒体组件,本地文件、远程地址和共享文档里的资源都能正确加载。节点的基本写法见[第一个块](editor.md)。
4
+
5
+ ## 源码预览块
6
+
7
+ `SourceBlockEditor` 提供源码编辑、错误提示、删除,以及与相邻块之间的光标移动。源码字段经 `field` 绑定,输入即时写入节点并进入撤销记录,协作时按字符合并;插件不需要自己写回源码。
8
+
9
+ 下面是一个格式化显示 JSON 的块:
10
+
11
+ ```tsx
12
+ import { Braces } from "lucide-react";
13
+ import {
14
+ SourceBlockEditor,
15
+ defineEditorElement,
16
+ defineEditorExtension,
17
+ definePlugin,
18
+ insertSourceBlock,
19
+ sourceBlockParagraphBehavior,
20
+ useReportPreviewError,
21
+ type EditorElementRenderProps,
22
+ } from "@tau/plugins";
23
+
24
+ declare const __PLUGIN_META__: { id: string; name: string; version: string };
25
+
26
+ interface JsonElement {
27
+ type: "yourname.json";
28
+ content: string;
29
+ children: { type: "formatted"; text: string }[];
30
+ }
31
+ declare module "@tau/plugins" {
32
+ interface EditorElementMap {
33
+ "yourname.json": JsonElement;
34
+ }
35
+ }
36
+
37
+ function parse(source: string) {
38
+ if (!source.trim()) return { text: "", error: null };
39
+ try {
40
+ return { text: JSON.stringify(JSON.parse(source), null, 2), error: null };
41
+ } catch (error) {
42
+ return { text: "", error: (error as Error).message };
43
+ }
44
+ }
45
+
46
+ function JsonPreview({ source }: { source: string }) {
47
+ const { text, error } = parse(source);
48
+ // 在源码块里由块统一显示错误;返回 false 时(如博客里)自己显示
49
+ const shownByBlock = useReportPreviewError(error);
50
+ if (error) return shownByBlock ? null : <p>{error}</p>;
51
+ return <pre className="yourname-json">{text}</pre>;
52
+ }
53
+
54
+ function JsonBlock({
55
+ attributes,
56
+ element,
57
+ children,
58
+ }: EditorElementRenderProps<JsonElement>) {
59
+ return (
60
+ <div {...attributes}>
61
+ <SourceBlockEditor
62
+ element={element}
63
+ field="content"
64
+ mode="javascript"
65
+ title="JSON"
66
+ icon={Braces}
67
+ >
68
+ <JsonPreview source={element.content} />
69
+ </SourceBlockEditor>
70
+ {children}
71
+ </div>
72
+ );
73
+ }
74
+
75
+ export default definePlugin({
76
+ ...__PLUGIN_META__,
77
+ editorExtensions: [
78
+ defineEditorExtension({
79
+ id: "yourname.json",
80
+ elements: [
81
+ defineEditorElement<JsonElement>({
82
+ type: "yourname.json",
83
+ dataVersion: 1,
84
+ // field 绑定的字段必须声明为文本字段
85
+ collaboration: { textFields: ["content"] },
86
+ kind: "block",
87
+ isVoid: true,
88
+ drag: true,
89
+ isEmpty: (element) => !element.content,
90
+ render: JsonBlock,
91
+ }),
92
+ ],
93
+ blockPanel: [
94
+ {
95
+ icon: Braces,
96
+ title: "JSON",
97
+ keywords: ["json"],
98
+ description: "格式化显示一段 JSON",
99
+ onClick: (editor) => {
100
+ insertSourceBlock(editor, {
101
+ type: "yourname.json",
102
+ content: "",
103
+ children: [{ type: "formatted", text: "" }],
104
+ });
105
+ },
106
+ },
107
+ ],
108
+ behaviorsFor: {
109
+ paragraph: sourceBlockParagraphBehavior("yourname.json"),
110
+ },
111
+ }),
112
+ ],
113
+ });
114
+ ```
115
+
116
+ `icon` 需要一个 lucide-react 图标,先 `pnpm add lucide-react`。`attributes` 展开在最外层,`children` 渲染在 `SourceBlockEditor` 外面,规则同[渲染组件](editor.md#渲染组件)。
117
+
118
+ | `SourceBlockEditor` 属性 | 说明 |
119
+ | ------------------------ | --------------------------------------------------------------------------------------------------- |
120
+ | `element` | 当前节点 |
121
+ | `field` | 存源码的字段名,需在节点的 `collaboration.textFields` 中声明 |
122
+ | `mode` | 源码的语言,用于语法高亮,如 `javascript`、`htmlmixed`、`stex`、`typst`;没有对应语法时按纯文本显示 |
123
+ | `title`、`icon` | 块的名称和图标,显示在编辑标题、空块占位和手机配件栏上 |
124
+ | `center`、`extend` | 可选。预览内容居中;预览区上下多留一点空间 |
125
+ | `children` | 预览内容 |
126
+
127
+ 桌面上,点块上的「编辑」在块内展开源码,下方实时预览。手机上,正文只显示预览:点一下选中块,配件栏给出「编辑」「复制」和块操作,「编辑」打开上方预览、下方源码的源码页;预览比屏幕宽时在块内横向滚动。两端的交互都由 Tau 提供,插件只需提供预览,不要在块上自己放编辑按钮。
128
+
129
+ 相关工具:
130
+
131
+ | 接口 | 用途 |
132
+ | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
133
+ | `useSourceBlock(element)` | 返回 `update`(修改节点字段)、`theme`(当前主题)和 `compiler`(Tailwind 编译器,可能为空) |
134
+ | `useReportPreviewError(message, { stale })` | 预览出错时上报错误,传 `null` 清除;`stale` 表示是否保留了上一次成功的预览。在源码预览块内由块统一显示错误,返回 `false`(不在块内,如博客)时预览需自己显示 |
135
+ | `insertSourceBlock(editor, element, line?)` | 插入节点并打开源码编辑(桌面在块内,手机打开源码页),适合在块菜单的 `onClick` 中使用 |
136
+ | `sourceBlockParagraphBehavior(type)` | 放进 `behaviorsFor.paragraph`,让用户在段首按退格时进入上方的源码块 |
137
+
138
+ `theme.isDark` 表示当前是否为暗色主题,`theme.token(word)` 读取主题色值,预览应随主题变化。`compiler` 只在桌面编辑器中可用,在博客里为空,此时配合下文的 `styleSources` 使用预先生成的样式。
139
+
140
+ 不要在插件里打包自己的编辑器、Slate 或源码编辑器,直接使用这些组件。
141
+
142
+ ## 行内源码
143
+
144
+ 行内的源码节点(如行内公式)声明 `kind: "inline"`,类型登记在 `EditorInlineElementMap` 里,并使用另一组接口:
145
+
146
+ | 接口 | 用途 |
147
+ | ------------------------------------- | ------------------------------------------------------------- |
148
+ | `useInlineSource(element)` | 返回 `readOnly`、`compiler`、`update(properties)`、`remove()` |
149
+ | `insertInlineSource(editor, element)` | 插入行内节点,适合在菜单中使用 |
150
+ | `InlineSourceBoundary` | 渲染在行内节点组件里,处理光标进出节点的边界 |
151
+
152
+ 行内的源码输入弹层由你用 `@tau/ui` 组件实现。只读时只显示预览,不打开编辑弹层;只读状态下 `update` 和 `remove` 不会写入文档。
153
+
154
+ ## 动态 Tailwind 样式
155
+
156
+ 如果节点的源码里写了 Tailwind 类名(比如用户写的组件演示),在扩展上声明哪个字段是源码:
157
+
158
+ ```ts
159
+ defineEditorExtension({
160
+ id: "yourname.demo",
161
+ elements: [demoElement],
162
+ styleSources: [{ type: "yourname.demo", field: "content", language: "tsx" }],
163
+ });
164
+ ```
165
+
166
+ 桌面编辑器里用 `useSourceBlock(element).compiler` 实时编译;在博客等不能实时编译样式的地方,Tau 会读取这些字段,提前生成对应的样式。
167
+
168
+ - 字段的值必须是字符串,`language` 为 `html` 或 `tsx`,只能登记本插件的节点类型。
169
+ - 类名要完整地写在源码里。拼接出来的类名(如 `` `bg-${color}` ``)扫描不到。
170
+
171
+ 这里说的是用户写在节点里的类名。插件自己组件里的 Tailwind 类名由你在构建时编译,并要加前缀,见[用 Tailwind 时加前缀](ui-components.md#用-tailwind-时加前缀)。
172
+
173
+ ## 图片、视频与音频
174
+
175
+ 节点里存的图片、视频、音频地址可能是本地路径、远程地址或共享文档里的资源,不能直接交给 `<img>`。用 Tau 提供的媒体组件显示,解析方式与 Tau 自带的图片块相同:本地路径转成可加载的地址,远程资源按用户的缓存设置下载,共享文档里的资源照常加载。
176
+
177
+ 下面的照片块显示一张图片,没有图片时让用户选择文件上传,双击打开图片查看器:
178
+
179
+ ```tsx
180
+ import type { ChangeEvent } from "react";
181
+ import {
182
+ MediaImage,
183
+ defineEditorElement,
184
+ useElement,
185
+ useMediaAppearance,
186
+ useMediaViewer,
187
+ useResourceUpload,
188
+ type EditorElementRenderProps,
189
+ type MediaAppearancePreset,
190
+ } from "@tau/plugins";
191
+
192
+ interface PhotoElement {
193
+ type: "yourname.photo";
194
+ url: string;
195
+ caption: string;
196
+ borderRadius?: MediaAppearancePreset;
197
+ children: { type: "formatted"; text: string }[];
198
+ }
199
+ declare module "@tau/plugins" {
200
+ interface EditorElementMap {
201
+ "yourname.photo": PhotoElement;
202
+ }
203
+ }
204
+
205
+ const RADIUS: Record<MediaAppearancePreset, string> = {
206
+ none: "0",
207
+ sm: "var(--tau-radius-sm)",
208
+ md: "var(--tau-radius-md)",
209
+ lg: "var(--tau-radius-lg)",
210
+ };
211
+
212
+ function Photo({
213
+ attributes,
214
+ element,
215
+ children,
216
+ }: EditorElementRenderProps<PhotoElement>) {
217
+ const { update } = useElement(element);
218
+ const appearance = useMediaAppearance();
219
+ const openViewer = useMediaViewer(element);
220
+ const upload = useResourceUpload();
221
+ // 节点自己的设置优先,其次是用户的默认外观,都没有时不加圆角
222
+ const radius = element.borderRadius ?? appearance?.borderRadius ?? "none";
223
+
224
+ const choose = async (event: ChangeEvent<HTMLInputElement>) => {
225
+ const file = event.target.files?.[0];
226
+ if (upload && file) update({ url: await upload(file) });
227
+ };
228
+
229
+ return (
230
+ <div {...attributes}>
231
+ <figure contentEditable={false} className="yourname-photo">
232
+ {element.url ? (
233
+ <MediaImage
234
+ url={element.url}
235
+ alt={element.caption}
236
+ style={{ borderRadius: RADIUS[radius] }}
237
+ onDoubleClick={() => openViewer(0)}
238
+ />
239
+ ) : (
240
+ // 只读编辑器和博客里拿不到上传函数,不显示选择文件
241
+ upload && <input type="file" accept="image/*" onChange={choose} />
242
+ )}
243
+ {element.caption && <figcaption>{element.caption}</figcaption>}
244
+ </figure>
245
+ {children}
246
+ </div>
247
+ );
248
+ }
249
+
250
+ export const photoElement = defineEditorElement<PhotoElement>({
251
+ type: "yourname.photo",
252
+ dataVersion: 1,
253
+ kind: "block",
254
+ isVoid: true,
255
+ drag: true,
256
+ render: Photo,
257
+ resources: [
258
+ { path: "url", kind: "image", alt: "caption", caption: "caption" },
259
+ ],
260
+ });
261
+ ```
262
+
263
+ `photoElement` 放进扩展的 `elements`,写法同[第一个块](editor.md#1-定义节点和扩展)。
264
+
265
+ | 接口 | 用途 |
266
+ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
267
+ | `MediaImage` | 显示图片,参数为 `url`、`alt`、`className`、`style`、`loading`、`onLoadError` 等 |
268
+ | `MediaVideo` / `MediaAudio` | Tau 的视频、音频播放器,参数为 `src` 与原生媒体属性 |
269
+ | `useResource(url, { kind })` | 自己绘制时使用:返回 `src`、`status`(`loading` / `ready` / `error`)与 `retry()`,元素加载失败时调用 `retry` 重新解析 |
270
+ | `useResourceUpload()` | 返回上传函数,把用户选的文件存进当前的资源存储并返回可写入节点的地址;只读编辑器和博客里为 `undefined` |
271
+ | `useMediaAppearance()` | 用户设置的媒体默认外观:`borderRadius`(`none` / `sm` / `md` / `lg`)与 `shadow`(同样四档,或布尔值);博客里取发布设置 |
272
+ | `useMediaViewer(element)` | 返回打开图片查看器的函数,见[查看图片](#查看图片) |
273
+
274
+ `useMediaAppearance()` 可能返回 `undefined`:Tau 还没有读到用户的默认外观设置,或者组件不在 Tau 的编辑器和博客正文里渲染(比如插件页面里),都拿不到。返回了对象,其中的 `borderRadius`、`shadow` 也可能缺省。所以按上例的顺序取值:节点自己的设置,其次 `appearance?.borderRadius`,最后是你的默认值。
275
+
276
+ `kind` 取 `image`、`video`、`audio`、`file`,决定远程资源的缓存方式。上传的文件不需要自己判断本地还是远端存储,也不要把文件内容写进节点。
277
+
278
+ ### 查看图片
279
+
280
+ `useMediaViewer(element)` 返回一个函数,调用后打开 Tau 的图片查看器,浏览文档里的全部图片,并定位到这个节点的第 `index` 张(按[声明的资源字段](#声明资源字段)计,从 0 开始)。照片块只有一张图,所以传 `0`:
281
+
282
+ ```tsx
283
+ const openViewer = useMediaViewer(element);
284
+ <MediaImage url={element.url} onDoubleClick={() => openViewer(0)} />;
285
+ ```
286
+
287
+ ### 声明资源字段
288
+
289
+ 节点里存了图片、视频、音频或文件地址时,在节点声明上用 `resources` 写明是哪些字段。Tau 只按这份声明找资源:导出打包、共享给协作者时上传本地文件、图片查看器里浏览图片、导出 EPUB 时取图,都靠它。没有声明的字段按普通文字原样保留,本地图片不会随内容导出,也不会上传给协作者。
290
+
291
+ 照片块的图片在 `url` 字段;一个节点里有一组图片时,用 `[]` 指向数组的每一项:
292
+
293
+ ```ts
294
+ resources: [
295
+ { path: "images[].url", kind: "image", alt: "desc", caption: "desc" },
296
+ ],
297
+ ```
298
+
299
+ | 字段 | 说明 |
300
+ | --------- | ---------------------------------------------------------------------------------------- |
301
+ | `path` | 资源字段的路径。`url` 是节点上的字段,`images[].url` 表示 `images` 数组每一项的 `url` |
302
+ | `kind` | `image`、`video`、`audio` 或 `file` |
303
+ | `preview` | 可选。同一资源的显示版本(如裁剪结果)所在的字段,与 `path` 末段同层,同样会被导出和上传 |
304
+ | `alt` | 可选。替代文字所在的字段,与 `path` 末段同层,图片查看器里显示 |
305
+ | `caption` | 可选。说明文字所在的字段,与 `path` 末段同层,图片查看器里显示 |
306
+
307
+ 声明会随资料库保存,插件停用或在没装插件的设备上,这些资源照样能导出和共享。已经有文档用了的字段不要改名;新增资源字段时补进声明即可。资源字段不能同时列进 `collaboration.textFields`。
308
+
309
+ ### 完整示例:图册
310
+
311
+ [图册插件](https://github.com/LastKnightCoder/tau-plugin-image-gallery)把这些能力和[块的交互](editor-interactions.md)组合成了一个完整的媒体块,可以对照它的源码写自己的块:
312
+
313
+ | 需要 | 图册的做法 |
314
+ | -------------------------- | ------------------------------------------------------------------------------------------------------- |
315
+ | 点选、删除、右键菜单 | 节点声明 `frame`,Enter 绑定「编辑图册」命令,空格绑定「全屏预览」 |
316
+ | 选中后的属性条 | `useElement(element).selected` 为真时渲染 `BlockToolbar`,切换布局用 `update({ mode })` |
317
+ | 显示图片 | 每张图用 `MediaImage`,圆角与阴影在节点没设置时取 `useMediaAppearance()`,两者都没有时用 `"none"` |
318
+ | 添加图片 | 编辑弹窗里调用 `useResourceUpload()` 返回的函数,拿到地址写进 `images`;返回 `undefined` 时隐藏上传按钮 |
319
+ | 调整顺序 | 编辑弹窗里的图片列表用 `@tau/ui` 的 `Sortable` |
320
+ | 看大图 | 只读时单击、编辑时双击图片,调用 `useMediaViewer(element)(index)`;编辑时单击留给外框选中 |
321
+ | 导出、协作、查看器找到图片 | `resources: [{ path: "images[].url", kind: "image", alt: "desc", caption: "desc" }]` |
322
+ | Markdown 与 HTML 导出 | `editorCodecs` 每张图导出一行图片链接,`htmlSerializers` 输出静态的横向滚动图片组 |
323
+ | 样式 | Tailwind 类名统一加 `ig:` 前缀,见[用 Tailwind 时加前缀](ui-components.md#用-tailwind-时加前缀) |
324
+
325
+ 命令和外框按键只知道节点,打开弹窗却要用组件里的状态。图册的做法是:组件把「打开编辑」登记到以节点对象为键的 `WeakMap` 里,命令收到 `context.element` 后从这里取出来调用。节点被替换后旧键自然失效,不会打开别的图册。
326
+
327
+ ```tsx
328
+ import { useEffect, useState } from "react";
329
+ import {
330
+ defineEditorElement,
331
+ defineEditorExtension,
332
+ useElement,
333
+ type EditorElementRenderProps,
334
+ } from "@tau/plugins";
335
+
336
+ interface GalleryElement {
337
+ type: "yourname.gallery";
338
+ images: { url: string; desc: string }[];
339
+ children: { type: "formatted"; text: string }[];
340
+ }
341
+ declare module "@tau/plugins" {
342
+ interface EditorElementMap {
343
+ "yourname.gallery": GalleryElement;
344
+ }
345
+ }
346
+
347
+ // 以节点对象为键:节点被替换后旧键自然失效
348
+ const galleryActions = new WeakMap<object, { openSettings(): void }>();
349
+
350
+ function Gallery({ element }: EditorElementRenderProps<GalleryElement>) {
351
+ const { readOnly } = useElement(element);
352
+ const [editing, setEditing] = useState(false);
353
+
354
+ // 每次渲染登记当前节点,卸载或换节点时移除
355
+ useEffect(() => {
356
+ galleryActions.set(element, {
357
+ openSettings: () => {
358
+ if (!readOnly) setEditing(true);
359
+ },
360
+ });
361
+ return () => void galleryActions.delete(element);
362
+ });
363
+
364
+ return <div>{editing ? "编辑中" : `${element.images.length} 张图片`}</div>;
365
+ }
366
+
367
+ export const galleryExtension = defineEditorExtension({
368
+ id: "yourname.gallery",
369
+ elements: [
370
+ defineEditorElement<GalleryElement>({
371
+ type: "yourname.gallery",
372
+ dataVersion: 1,
373
+ kind: "block",
374
+ isVoid: true,
375
+ frame: { keys: { Enter: "yourname.gallery.edit" } },
376
+ render: Gallery,
377
+ resources: [
378
+ { path: "images[].url", kind: "image", alt: "desc", caption: "desc" },
379
+ ],
380
+ }),
381
+ ],
382
+ commands: [
383
+ {
384
+ id: "yourname.gallery.edit",
385
+ title: "编辑图册",
386
+ run: (_editor, { element }) => {
387
+ if (element) galleryActions.get(element)?.openSettings();
388
+ },
389
+ },
390
+ ],
391
+ });
392
+ ```
393
+
394
+ ## 下一步
395
+
396
+ - [导出与字数统计](editor-export.md):让块参与 Markdown、HTML 导出,块里的文字计入字数。
397
+ - [块的数据版本与协作](editor-collaboration.md):多人同时编辑源码字段,以及发布后修改数据结构。