@bpmn-nova/studio 0.3.9-preview → 0.4.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.
Files changed (79) hide show
  1. package/README.md +2 -2
  2. package/dist/canvas.js +97 -25
  3. package/dist/config.js +13 -0
  4. package/dist/context-menu.js +41 -32
  5. package/dist/controller.js +45 -19
  6. package/dist/flow-tree.d.ts +4 -0
  7. package/dist/flow-tree.js +14 -0
  8. package/dist/index.d.ts +47 -2
  9. package/dist/index.js +1 -0
  10. package/dist/interactions.js +6 -1
  11. package/dist/modules/bpmn-model/index.d.ts +2 -1
  12. package/dist/modules/bpmn-model/index.js +12 -10
  13. package/dist/modules/core/gateway.js +16 -13
  14. package/dist/modules/core/index.d.ts +6 -4
  15. package/dist/modules/core/model.js +12 -7
  16. package/dist/modules/designer/index.d.ts +5 -1
  17. package/dist/modules/designer/index.js +36 -15
  18. package/dist/modules/export-svg/index.d.ts +12 -5
  19. package/dist/modules/export-svg/preview.js +34 -24
  20. package/dist/modules/export-svg/render.js +102 -50
  21. package/dist/modules/flow-tree/controller.js +364 -0
  22. package/dist/modules/flow-tree/index.d.ts +248 -0
  23. package/dist/modules/flow-tree/index.js +5 -0
  24. package/dist/modules/flow-tree/operations.js +484 -0
  25. package/dist/modules/flow-tree/sample.js +445 -0
  26. package/dist/modules/flow-tree/schema.js +588 -0
  27. package/dist/modules/flow-tree/validate.js +125 -0
  28. package/dist/modules/flow-tree-bpmn/compiler.js +547 -0
  29. package/dist/modules/flow-tree-bpmn/decompiler.js +524 -0
  30. package/dist/modules/flow-tree-bpmn/expression.js +135 -0
  31. package/dist/modules/flow-tree-bpmn/index.d.ts +53 -0
  32. package/dist/modules/flow-tree-bpmn/index.js +14 -0
  33. package/dist/modules/flow-tree-renderer/canvas.js +1003 -0
  34. package/dist/modules/flow-tree-renderer/export-svg.js +325 -0
  35. package/dist/modules/flow-tree-renderer/index.d.ts +143 -0
  36. package/dist/modules/flow-tree-renderer/index.js +3 -0
  37. package/dist/modules/flow-tree-renderer/shell.js +970 -0
  38. package/dist/modules/i18n/index.d.ts +647 -0
  39. package/dist/modules/i18n/index.js +247 -0
  40. package/dist/modules/i18n/locales/en-US.js +1222 -0
  41. package/dist/modules/i18n/locales/zh-CN.js +1204 -0
  42. package/dist/modules/icons/index.js +23 -0
  43. package/dist/modules/node-presentation/index.d.ts +3 -2
  44. package/dist/modules/node-presentation/index.js +14 -11
  45. package/dist/modules/palette/index.d.ts +6 -1
  46. package/dist/modules/palette/index.js +26 -8
  47. package/dist/modules/palette/panel.js +44 -6
  48. package/dist/modules/properties/index.d.ts +2 -1
  49. package/dist/modules/properties/index.js +2 -2
  50. package/dist/modules/properties-activiti/index.js +84 -59
  51. package/dist/modules/properties-bpmn/index.js +151 -128
  52. package/dist/modules/properties-core/index.d.ts +9 -3
  53. package/dist/modules/properties-core/index.js +16 -4
  54. package/dist/modules/properties-flow-tree/index.d.ts +56 -0
  55. package/dist/modules/properties-flow-tree/index.js +2 -0
  56. package/dist/modules/properties-flow-tree/panel.js +1136 -0
  57. package/dist/modules/properties-flow-tree/widgets.js +625 -0
  58. package/dist/modules/properties-flowable/index.js +55 -34
  59. package/dist/modules/properties-renderer/index.d.ts +5 -1
  60. package/dist/modules/properties-renderer/index.js +110 -42
  61. package/dist/modules/renderer-svg/index.d.ts +6 -2
  62. package/dist/modules/renderer-svg/index.js +113 -38
  63. package/dist/modules/runtime/index.d.ts +33 -5
  64. package/dist/modules/runtime/index.js +97 -73
  65. package/dist/modules/runtime/time.js +89 -4
  66. package/dist/modules/runtime/visits.js +6 -4
  67. package/dist/modules/theme/index.d.ts +5 -2
  68. package/dist/modules/theme/index.js +8 -4
  69. package/dist/modules/viewer/index.d.ts +28 -7
  70. package/dist/modules/viewer/index.js +223 -58
  71. package/dist/modules/viewer/runtime-content.js +26 -20
  72. package/dist/modules/viewer/runtime-trace.js +43 -25
  73. package/dist/modules/viewer/timeline.js +103 -36
  74. package/dist/shell.js +258 -75
  75. package/dist/sidebars.js +3 -1
  76. package/dist/styles.css +2371 -2
  77. package/llms-full.txt +586 -47
  78. package/llms.txt +6 -5
  79. package/package.json +7 -3
package/llms-full.txt CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  # BPMN Nova integration runbook
10
10
 
11
- > BPMN Nova is a framework-neutral BPMN 2.0 design, viewing, approval-trace, theme, and pure SVG export toolkit for Flowable and Activiti applications. The current release is Preview.
11
+ > BPMN Nova is a framework-neutral BPMN 2.0 design, structured approval-tree (FlowTree), viewing, approval-trace, theme, and pure SVG export toolkit for Flowable and Activiti applications. The current release is `0.4.1`.
12
12
 
13
13
  Use this file as the executable starting point for installing BPMN Nova. Complete the steps in order. Read the co-located `llms-full.txt` only when the selected branch needs advanced customization or complete Interface reference.
14
14
 
@@ -32,14 +32,14 @@ This step is complete only when one application root, one framework branch, and
32
32
  | React, Next.js, or Remix | `@bpmn-nova/react` | React 18 |
33
33
  | Another confirmed browser JavaScript/TypeScript stack | `@bpmn-nova/studio` | Node 18 for installation/build |
34
34
 
35
- Preserve an already installed public package when it matches the target stack. Do not install historical internal packages such as Core, Designer, Viewer, Runtime, Theme, Export SVG, Properties, or engine profiles. Studio exposes supported `/designer`, `/viewer`, `/runtime`, `/theme`, `/export-svg`, `/flowable`, and `/activiti` subpaths.
35
+ Preserve an already installed public package when it matches the target stack. Do not install historical internal packages such as Core, Designer, Viewer, Runtime, Theme, Export SVG, Properties, or engine profiles. Studio exposes supported `/designer`, `/viewer`, `/runtime`, `/theme`, `/export-svg`, `/flowable`, `/activiti`, and (unreleased) `/flow-tree` subpaths.
36
36
 
37
37
  Install with the application's existing package manager:
38
38
 
39
39
  ```bash
40
- npm install @bpmn-nova/vue@preview
41
- pnpm add @bpmn-nova/vue@preview
42
- yarn add @bpmn-nova/vue@preview
40
+ npm install @bpmn-nova/vue
41
+ pnpm add @bpmn-nova/vue
42
+ yarn add @bpmn-nova/vue
43
43
  ```
44
44
 
45
45
  Replace `vue` with `react` or `studio` only when the selected framework branch requires it. Run one installation command, not all three.
@@ -70,6 +70,7 @@ Choose the smallest Interface that owns the required experience:
70
70
  | Embeddable design canvas without the complete workbench | `BpmnDesigner` |
71
71
  | Read-only BPMN, approval path, or mobile timeline | `BpmnViewer` |
72
72
  | Custom host layout with official Controller, Canvas, Palette, and Properties modules | external Studio Controller plus adapter components/registries |
73
+ | Structured DingTalk/Feishu-style approval tree compiled to Flowable/Activiti BPMN 2.0 XML (unreleased) | `FlowTreeStudio` (Vue/React) or `FlowTreeShell` (`@bpmn-nova/studio/flow-tree`) |
73
74
 
74
75
  Use `engine="flowable"` or `engine="activiti"` explicitly from the host workflow engine. Do not infer the engine from BPMN XML namespace declarations alone.
75
76
 
@@ -323,7 +324,7 @@ Before changing Nova package versions, publishing, or recovering a partial relea
323
324
  - **流程展示**:只读 BPMN、实际审批路径、移动时间线和完整 BPMN 运行态。
324
325
  - **嵌入与扩展**:宿主布局、业务属性、节点内容、主题、审批详情及纯 SVG 导出。
325
326
 
326
- 当前版本为 **`0.3.9-preview`**,使用 `@preview` 安装。组件负责建模、展示和交互;流程执行、审批提交及权限由宿主业务系统负责。完整能力与 Preview 边界见[项目介绍](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/guide/overview.md)。
327
+ 当前版本为 **`0.4.1`**。组件负责建模、展示和交互;流程执行、审批提交及权限由宿主业务系统负责。完整能力与边界见[项目介绍](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/guide/overview.md)。
327
328
 
328
329
  ## 安装
329
330
 
@@ -331,9 +332,9 @@ Before changing Nova package versions, publishing, or recovering a partial relea
331
332
 
332
333
  | 技术栈 | 安装命令 | 接入指南 |
333
334
  | --- | --- | --- |
334
- | JavaScript / TypeScript | `npm install @bpmn-nova/studio@preview` | [Studio](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/guide/studio.md) |
335
- | React 18+ | `npm install @bpmn-nova/react@preview` | [React](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/guide/react.md) |
336
- | Vue 3.3+ | `npm install @bpmn-nova/vue@preview` | [Vue](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/guide/vue.md) |
335
+ | JavaScript / TypeScript | `npm install @bpmn-nova/studio` | [Studio](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/guide/studio.md) |
336
+ | React 18+ | `npm install @bpmn-nova/react` | [React](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/guide/react.md) |
337
+ | Vue 3.3+ | `npm install @bpmn-nova/vue` | [Vue](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/guide/vue.md) |
337
338
 
338
339
  所有包提供 ESM 与 TypeScript 声明。React / Vue 会自动依赖匹配版本的 Studio;公共类型也从所选框架包导入,无需额外安装内部包。
339
340
 
@@ -412,7 +413,7 @@ npm run docs:ai:check
412
413
  BPMN Nova 提供可嵌入的流程设计器、只读 Viewer、运行态审批轨迹、实例级主题、纯 SVG 导出,以及 React / Vue 适配。项目使用独立的 DOM / SVG 渲染实现,不依赖 `bpmn-js`,并为 Flowable 与 Activiti 提供 XML Profile 和属性扩展。
413
414
 
414
415
  > [!IMPORTANT]
415
- > 当前版本为 `0.3.9-preview`。它适合 SDK 评估、产品集成验证和企业审批原型;公开 Interface、BPMN XML round-trip 与引擎兼容能力仍在持续稳定中,建议使用 `@preview` 安装并在生产接入前完成目标流程验证。
416
+ > 当前版本为 `0.4.1`。组件支持直接通过 npm 安装并嵌入 Vue、React 或原生 JavaScript/TypeScript 项目;在生产接入前请结合业务流程完成目标 BPMN XML 与引擎扩展验证。
416
417
 
417
418
  AI 或代码生成工具接入必须从 [`llms.txt`](https://github.com/daxiangme/bpmn-nova/blob/dev/llms.txt) 的完整安装流程开始;需要全部接口与定制上下文时再读取 [`llms-full.txt`](https://github.com/daxiangme/bpmn-nova/blob/dev/llms-full.txt)。这两份文件也会随三个公开 npm 包发布。
418
419
 
@@ -558,9 +559,9 @@ BPMN Nova 不负责:
558
559
 
559
560
  | 宿主 | 安装命令 | 选择规则 |
560
561
  | --- | --- | --- |
561
- | React 18+、Next.js、Remix 等 React 应用 | `npm install @bpmn-nova/react@preview` | 使用 React 组件、Hook 和 Ref |
562
- | Vue 3.3+、Nuxt 等 Vue 应用 | `npm install @bpmn-nova/vue@preview` | 使用 Vue 组件、Composable 和 Expose |
563
- | 已确认的其他 JavaScript / TypeScript Web 项目 | `npm install @bpmn-nova/studio@preview` | 使用框架无关 Interface |
562
+ | React 18+、Next.js、Remix 等 React 应用 | `npm install @bpmn-nova/react` | 使用 React 组件、Hook 和 Ref |
563
+ | Vue 3.3+、Nuxt 等 Vue 应用 | `npm install @bpmn-nova/vue` | 使用 Vue 组件、Composable 和 Expose |
564
+ | 已确认的其他 JavaScript / TypeScript Web 项目 | `npm install @bpmn-nova/studio` | 使用框架无关 Interface |
564
565
 
565
566
  已经安装三个公开包之一且与目标技术栈匹配时,沿用现有入口。React 和 Vue 同时存在但无法确定目标应用时先询问用户。`@bpmn-nova/core`、`designer`、`viewer`、`runtime`、`theme`、`export-svg`、`properties` 等历史入口不参与选择;这些能力已经收进 Studio,并通过根入口或受支持子路径提供。
566
567
 
@@ -689,7 +690,7 @@ viewer.destroy()
689
690
  ## 3. React 18+
690
691
 
691
692
  ```bash
692
- npm install @bpmn-nova/react@preview
693
+ npm install @bpmn-nova/react
693
694
  ```
694
695
 
695
696
  ```jsx
@@ -731,7 +732,7 @@ export function WorkflowEditor({ initialXml }) {
731
732
  ## 4. Vue 3.3+
732
733
 
733
734
  ```bash
734
- npm install @bpmn-nova/vue@preview
735
+ npm install @bpmn-nova/vue
735
736
  ```
736
737
 
737
738
  ```vue
@@ -1153,7 +1154,9 @@ import { xml, runtime } from './approval-data'
1153
1154
 
1154
1155
  节点当前摘要只来自 **Effective Visit**。`latestAction` 是这些执行里真正的最新动作,即使没有意见;`latestNonEmptyComment` 是最近一条非空意见,可以来自历史轮次,供详情标注,不能覆盖本轮通过且未填意见的摘要。同一节点上仍有效的独立 Visit 会同时参与状态聚合:任一仍在处理中时,节点不能被另一个已完成 Visit 标成全部完成。会签/或签仍是同一 `visitId` 下的多个工作项,由显式 `approvalMode` 驱动。
1155
1156
 
1156
- 比较时间使用解析后的时间点,显示使用 `formatRuntimeInstant()`。带时区的 ISO 与 `Z` 按绝对时间比较;无时区旧输入仍可解析但会诊断歧义。缺失或非法时间不会被改成数组下标或补 `1ms`。详情、Timeline 与 SVG 共用该格式化入口。
1157
+ 比较时间使用解析后的时间点,显示使用 `formatRuntimeInstant()`。带时区的 ISO 与 `Z` 按绝对时间比较;无时区旧输入仍可解析但会诊断歧义。缺失或非法时间不会被改成数组下标或补 `1ms`。详情、驳回记录、Timeline 与 SVG 共用该格式化入口。
1158
+
1159
+ 自 `0.4.0` 起,宿主可通过 `runtimeTimeFormat`(基于 `Intl.DateTimeFormat` 指定 `timeZone` / `locale` / `dateStyle` / `timeStyle` / `hour12`)或自定义 `formatRuntimeTime(instant, { surface, field, locale })` 覆盖全部四个运行态展示面(`details`、`transition`、`timeline`、`svg`)的时间显示,且不影响排序、访问归并与失效推断;`formatRuntimeTime` 优先于 `runtimeTimeFormat`。详细契约见 [API 文档](../api/index.md#运行态时间格式化)。
1157
1160
 
1158
1161
  `inspectRuntime(snapshot, { model })` 自 `0.3.6-preview` 提供,返回 `{ runtime, diagnostics }`。诊断含 `code`、`level`、`message`、`fieldPath` 及相关 ID,不含审批正文、附件地址或凭证。未知引用会进入诊断,不会被静默丢弃后呈现完整轨迹。`activityState()` 的声明与实现均为访问状态对象,不是状态字符串。
1159
1162
 
@@ -1842,7 +1845,7 @@ export function createAssetResolver(resolveAssetUrl: ResolveAssetUrl): RuntimeAs
1842
1845
 
1843
1846
  # BPMN Nova 快速开始
1844
1847
 
1845
- 本文面向通过 NPM 集成 BPMN Nova 的应用开发者。版本 `0.3.9-preview` 要求现代浏览器;Node.js 18+ 用于构建、SSR 和开发工具。
1848
+ 本文面向通过 NPM 集成 BPMN Nova 的应用开发者。版本 `0.4.1` 要求现代浏览器;Node.js 18+ 用于构建、SSR 和开发工具。
1846
1849
 
1847
1850
  ## 1. 按语言与框架选择入口
1848
1851
 
@@ -1850,11 +1853,11 @@ export function createAssetResolver(resolveAssetUrl: ResolveAssetUrl): RuntimeAs
1850
1853
 
1851
1854
  | 项目环境 | 安装命令 | 后续章节 |
1852
1855
  | --- | --- | --- |
1853
- | Vanilla JavaScript / TypeScript 完整 Studio | `npm install @bpmn-nova/studio@preview` | 第 3 节 |
1854
- | 已有 React 18+ 工程 | `npm install @bpmn-nova/react@preview` | 第 7 节 |
1855
- | 已有 Vue 3.3+ 工程 | `npm install @bpmn-nova/vue@preview` | 第 8 节 |
1856
+ | Vanilla JavaScript / TypeScript 完整 Studio | `npm install @bpmn-nova/studio` | 第 3 节 |
1857
+ | 已有 React 18+ 工程 | `npm install @bpmn-nova/react` | 第 7 节 |
1858
+ | 已有 Vue 3.3+ 工程 | `npm install @bpmn-nova/vue` | 第 8 节 |
1856
1859
 
1857
- JavaScript 与 TypeScript 使用相同的包和导入方式。所有公开包都附带 `.d.ts`,TypeScript 项目无需额外安装类型包。React/Vue 的命令假定宿主工程已经由对应框架脚手架创建;适配包只声明框架 `peerDependencies`,不会替宿主选择、安装或升级框架版本。当前版本处于 Preview 阶段,因此文档统一显式安装 `@preview`,避免未来 `latest` 切换到稳定版后出现版本歧义。
1860
+ JavaScript 与 TypeScript 使用相同的包和导入方式。所有公开包都附带 `.d.ts`,TypeScript 项目无需额外安装类型包。React/Vue 的命令假定宿主工程已经由对应框架脚手架创建;适配包只声明框架 `peerDependencies`,不会替宿主选择、安装或升级框架版本。
1858
1861
 
1859
1862
  Core、Viewer、Runtime、Theme 等目录不再是可直接安装的 NPM 包。Vanilla 项目从 Studio 根入口或受支持子路径导入;React/Vue 项目使用对应 Adapter。
1860
1863
 
@@ -2085,7 +2088,7 @@ viewer.destroy()
2085
2088
  本节面向已有 React 18+ 与 React DOM 18+ 工程,只安装 BPMN Nova 适配包:
2086
2089
 
2087
2090
  ```bash
2088
- npm install @bpmn-nova/react@preview
2091
+ npm install @bpmn-nova/react
2089
2092
  ```
2090
2093
 
2091
2094
  ```jsx
@@ -2135,7 +2138,7 @@ Ref 可访问 `studio`、`shell`、`actions`、实际 `mode`、`setMode()`、`va
2135
2138
  本节面向已有 Vue 3.3+ 工程,只安装 BPMN Nova 适配包:
2136
2139
 
2137
2140
  ```bash
2138
- npm install @bpmn-nova/vue@preview
2141
+ npm install @bpmn-nova/vue
2139
2142
  ```
2140
2143
 
2141
2144
  ```vue
@@ -2318,7 +2321,7 @@ BPMN Nova 的 Vanilla JavaScript / TypeScript 完整入口,提供流程设计
2318
2321
 
2319
2322
  > **English summary:** The complete framework-neutral BPMN Nova package for process design, viewing, approval traces, themes, properties, and pure SVG export.
2320
2323
 
2321
- > 当前版本为 `0.3.9-preview`。请使用 `@preview` 安装,并在生产接入前验证目标 BPMN XML 与引擎扩展。
2324
+ > 当前版本为 `0.4.1`。在生产接入前请验证目标 BPMN XML 与引擎扩展。
2322
2325
 
2323
2326
  ![BPMN Nova 流程设计器](../../assets/bpmn-nova-designer.jpg)
2324
2327
 
@@ -2332,7 +2335,7 @@ BPMN Nova 的 Vanilla JavaScript / TypeScript 完整入口,提供流程设计
2332
2335
  ## 安装
2333
2336
 
2334
2337
  ```bash
2335
- npm install @bpmn-nova/studio@preview
2338
+ npm install @bpmn-nova/studio
2336
2339
  ```
2337
2340
 
2338
2341
  ```js
@@ -2699,6 +2702,32 @@ shell.setRuntimeAppearance({
2699
2702
 
2700
2703
  ![BPMN Nova 深色运行态](../../assets/bpmn-nova-dark-runtime.jpg)
2701
2704
 
2705
+ ## 多语言与运行态时间格式(自 0.4.0 起)
2706
+
2707
+ 内置 `zh-CN`(默认,保持既有文案不变)与 `en-US` 文案包,零第三方 i18n 依赖,支持局部键覆盖与运行中无重建切换:
2708
+
2709
+ ```js
2710
+ const studio = createStudioController({
2711
+ model,
2712
+ locale: 'en-US',
2713
+ messages: { shell: { tools: { beautify: 'Auto Layout' } } },
2714
+ })
2715
+ const shell = createStudioShell({
2716
+ container,
2717
+ studio,
2718
+ config: {
2719
+ viewer: {
2720
+ runtimeTimeFormat: { timeZone: 'Asia/Shanghai', locale: 'zh-CN' },
2721
+ // 或提供自定义回调 formatRuntimeTime(instant, { surface, field, locale })
2722
+ },
2723
+ },
2724
+ })
2725
+
2726
+ shell.setLocale('zh-CN') // 不重建 Controller,保留撤销栈、选中项、视口、作用域与已有节点名称
2727
+ ```
2728
+
2729
+ 完整键名分区、回退规则与 `formatRuntimeTime` / `runtimeTimeFormat` 契约见 [API 文档](../api/index.md#多语言i18n)。
2730
+
2702
2731
  ## SVG 导出
2703
2732
 
2704
2733
  ```js
@@ -2765,14 +2794,14 @@ BPMN Nova 的 Vue 3.3+ Adapter,提供 Studio、Designer、Viewer、审批轨
2765
2794
 
2766
2795
  > **English summary:** Vue 3.3+ components and exposed instance methods for BPMN Nova process design, viewing, approval traces, properties, themes, and SVG export.
2767
2796
 
2768
- > 当前版本为 `0.3.9-preview`。Vue 由宿主工程提供,本包不会替应用选择或升级框架版本。
2797
+ > 当前版本为 `0.4.1`。Vue 由宿主工程提供,本包不会替应用选择或升级框架版本。
2769
2798
 
2770
2799
  ![BPMN Nova Vue 流程工作台](../../assets/bpmn-nova-designer.jpg)
2771
2800
 
2772
2801
  ## 安装
2773
2802
 
2774
2803
  ```bash
2775
- npm install @bpmn-nova/vue@preview
2804
+ npm install @bpmn-nova/vue
2776
2805
  ```
2777
2806
 
2778
2807
  ```js
@@ -3188,6 +3217,22 @@ studioRef.value?.openSvgExportPreview({
3188
3217
 
3189
3218
  主题属性变化会更新现有实例,不会重新挂载画布、清除选择或关闭详情。
3190
3219
 
3220
+ ## 多语言与运行态时间格式(自 0.4.0 起)
3221
+
3222
+ 所有 Vue 视觉组件接受响应式的 `locale`(默认 `'zh-CN'`,内置 `'en-US'`)与 `messages` 局部覆盖,切换时不重新挂载实例,保留撤销历史、选中项、视口、子流程作用域与已有节点名称;`BpmnStudio` 与 `BpmnViewer` 同时接受 `runtime-time-format` 与 `format-runtime-time`:
3223
+
3224
+ ```vue
3225
+ <BpmnStudio
3226
+ ref="studioRef"
3227
+ :xml="xml"
3228
+ :locale="locale"
3229
+ :messages="{ shell: { tools: { validate: 'Check' } } }"
3230
+ :runtime-time-format="{ timeZone: 'Asia/Shanghai', locale }"
3231
+ />
3232
+ ```
3233
+
3234
+ Expose 同时提供 `setLocale(locale?, messages?)` 与 `getLocale()`,根入口同步重导出 `zhCN`、`enUS`、`createI18n` 及全部国际化与运行态时间格式化 TypeScript 类型。详细说明见 [API 文档](../api/index.md#多语言i18n)。
3235
+
3191
3236
  ## Properties 与自定义 Renderer
3192
3237
 
3193
3238
  本包还导出:
@@ -3233,14 +3278,14 @@ BPMN Nova 的 React 18+ Adapter,提供 Studio、Designer、Viewer、审批轨
3233
3278
 
3234
3279
  > **English summary:** React 18+ components and refs for BPMN Nova process design, viewing, approval traces, properties, themes, and SVG export.
3235
3280
 
3236
- > 当前版本为 `0.3.9-preview`。React 与 React DOM 由宿主工程提供,本包不会替应用选择或升级框架版本。
3281
+ > 当前版本为 `0.4.1`。React 与 React DOM 由宿主工程提供,本包不会替应用选择或升级框架版本。
3237
3282
 
3238
3283
  ![BPMN Nova React 流程工作台](../../assets/bpmn-nova-designer.jpg)
3239
3284
 
3240
3285
  ## 安装
3241
3286
 
3242
3287
  ```bash
3243
- npm install @bpmn-nova/react@preview
3288
+ npm install @bpmn-nova/react
3244
3289
  ```
3245
3290
 
3246
3291
  ```jsx
@@ -3611,6 +3656,23 @@ studioRef.current?.openSvgExportPreview({
3611
3656
 
3612
3657
  主题属性变化会更新现有实例,不会重新挂载画布、清除选择或关闭详情。
3613
3658
 
3659
+ ## 多语言与运行态时间格式(自 0.4.0 起)
3660
+
3661
+ 所有 React 视觉组件接受响应式的 `locale`(默认 `'zh-CN'`,内置 `'en-US'`)与 `messages` 局部覆盖,切换时不重新挂载实例,保留撤销历史、选中项、视口、子流程作用域与已有节点名称;`BpmnStudio` 与 `BpmnViewer` 同时接受 `runtimeTimeFormat` 与 `formatRuntimeTime`:
3662
+
3663
+ ```jsx
3664
+ <BpmnStudio
3665
+ ref={studioRef}
3666
+ xml={xml}
3667
+ locale={locale}
3668
+ messages={{ shell: { tools: { validate: 'Check' } } }}
3669
+ runtimeTimeFormat={{ timeZone: 'Asia/Shanghai', locale }}
3670
+ // 或 formatRuntimeTime={(instant, { surface, field, locale }) => ...}
3671
+ />
3672
+ ```
3673
+
3674
+ Ref 同时暴露 `setLocale(locale?, messages?)` 与 `getLocale()`,根入口同步重导出 `zhCN`、`enUS`、`createI18n` 及全部国际化与运行态时间格式化 TypeScript 类型。详细说明见 [API 文档](../api/index.md#多语言i18n)。
3675
+
3614
3676
  ## Properties 与自定义 Renderer
3615
3677
 
3616
3678
  本包还导出:
@@ -3648,11 +3710,200 @@ studioRef.current?.openSvgExportPreview({
3648
3710
  Apache-2.0. See [LICENSE](https://github.com/daxiangme/bpmn-nova/blob/dev/packages/react/LICENSE).
3649
3711
 
3650
3712
 
3713
+ <!-- SOURCE: docs/src/guide/flow-tree.md -->
3714
+
3715
+ # 审批树设计器(钉钉 / 飞书风)
3716
+
3717
+ > [!NOTE]
3718
+ > **适用版本:自 `0.4.1` 起**。本能力作为独立组件集成在 `@bpmn-nova/studio/flow-tree`、`@bpmn-nova/vue` 和 `@bpmn-nova/react` 中,不改变现有自由画布 `BpmnStudio` 的默认行为。
3719
+
3720
+ `FlowTreeStudio` 提供类似钉钉、飞书的**结构化卡片树**审批流程设计体验:无需手工连线或摆放坐标,通过节点下方的 `+` 按钮即可插入审批、抄送、办理、条件分支、并行分支、包容分支、延迟等待、触发器与子流程,并可一键编译为 **Flowable / Activiti 可执行的标准 BPMN 2.0 XML**。
3721
+
3722
+ ## 适用场景与定位
3723
+
3724
+ - **面向业务管理员**:采用单入单出的块树结构(SP-Graph),自动排版、自动汇合,零悬空边与交叉线;
3725
+ - **面向 Flowable / Activiti 后端**:所有 11 类业务节点与可视化条件组均可确定性编译为标准 BPMN 2.0 XML(含多实例会签/或签/依次审批、优先级顺序出边、默认流与 BPMN DI 坐标);
3726
+ - **统一运行态**:编译后的 BPMN 元素保留与审批树卡片一致的稳定节点 ID,同一份 `Runtime Snapshot` 可直接在 **审批树 / BPMN 图 / 垂直审批时间轴** 三种视图之间无缝切换。
3727
+
3728
+ ## 全量 11 类内置节点与 BPMN 2.0 映射
3729
+
3730
+ | 节点类型 (`type`) | 业务用途 | 默认编译目标(BPMN 2.0 + Flowable / Activiti) |
3731
+ | --- | --- | --- |
3732
+ | `starter` | 发起人(固定根节点) | 默认编译为 `StartEvent → UserTask(assignee="${initiator}")`(支持驳回重提),也可切换为仅 `StartEvent` |
3733
+ | `approver` | 审批人(9 种选人、会签/或签/依次/按比例、空处理、去重、超时、按钮与表单权限) | `UserTask` + `multiInstanceLoopCharacteristics` + `<nova:nodeConfig>` |
3734
+ | `cc` | 抄送人(固定抄送 / 允许发起人自选) | `ServiceTask`(`nova:nodeKind="cc"`,`delegateExpression="${novaCcDelegate}"`) |
3735
+ | `handler` | 办理人 / 填写人(补充字段或线下办理) | `UserTask`(`nova:nodeKind="handler"`) |
3736
+ | `conditionRoute` | 条件分支(有序优先级 + 末尾锁定默认兜底分支) | 成对 `ExclusiveGateway`(Diverging / Converging)+ 按优先级排序的 `SequenceFlow` 与 `default` |
3737
+ | `parallelRoute` | 并行分支(全部同时执行并汇合) | 成对 `ParallelGateway`(Diverging / Converging) |
3738
+ | `inclusiveRoute` | 包容分支 / 多条件并行 | 成对 `InclusiveGateway`(Diverging / Converging);Activiti 引擎下自动给出兼容性校验提醒 |
3739
+ | `delay` | 延迟等待(相对时长 / 指定日期 / Cron) | `IntermediateCatchEvent` + `timerEventDefinition`(`PT2H` / `P1D` / `timeDate` / `timeCycle`) |
3740
+ | `trigger` | 触发器(HTTP Webhook / Java Class / Delegate / Expression) | `ServiceTask`(含异步、失败重试周期与 Field Injection) |
3741
+ | `subFlow` | 子流程(调用外部流程 / 内嵌子步骤) | `CallActivity`(含输入/输出参数映射)或 `SubProcess` |
3742
+ | `end` | 流程结束(固定尾节点) | `EndEvent` |
3743
+
3744
+ 此外,可通过 `customNodes` 或 `createDefaultFlowTreeNodeRegistry()` 注册宿主自定义业务卡片及自定义 BPMN 编译逻辑。
3745
+
3746
+ ## 快速接入
3747
+
3748
+
3749
+ **Vue**
3750
+
3751
+ ```vue
3752
+ <script setup>
3753
+ import { ref } from 'vue';
3754
+ import {
3755
+ FlowTreeStudio,
3756
+ createSampleFlowTree,
3757
+ createSampleFlowTreeDataProviders,
3758
+ createSampleFlowTreeRuntime,
3759
+ } from '@bpmn-nova/vue';
3760
+ import '@bpmn-nova/vue/styles.css';
3761
+
3762
+ const studioRef = ref(null);
3763
+ const initialDoc = createSampleFlowTree('flowable');
3764
+ const dataProviders = createSampleFlowTreeDataProviders();
3765
+ const runtime = createSampleFlowTreeRuntime(initialDoc);
3766
+
3767
+ function handleChange({ exportXml }) {
3768
+ const bpmnXml = exportXml('flowable');
3769
+ console.log('Compiled BPMN 2.0 XML length:', bpmnXml.length);
3770
+ }
3771
+ </script>
3772
+
3773
+ <template>
3774
+ <div style="height: 680px">
3775
+ <FlowTreeStudio
3776
+ ref="studioRef"
3777
+ :document="initialDoc"
3778
+ engine="flowable"
3779
+ :data-providers="dataProviders"
3780
+ :runtime="runtime"
3781
+ @change="handleChange"
3782
+ />
3783
+ </div>
3784
+ </template>
3785
+ ```
3786
+
3787
+ **React**
3788
+
3789
+ ```jsx
3790
+ import { useRef } from 'react';
3791
+ import {
3792
+ FlowTreeStudio,
3793
+ createSampleFlowTree,
3794
+ createSampleFlowTreeDataProviders,
3795
+ createSampleFlowTreeRuntime,
3796
+ } from '@bpmn-nova/react';
3797
+ import '@bpmn-nova/react/styles.css';
3798
+
3799
+ const initialDoc = createSampleFlowTree('flowable');
3800
+ const dataProviders = createSampleFlowTreeDataProviders();
3801
+ const runtime = createSampleFlowTreeRuntime(initialDoc);
3802
+
3803
+ export default function ApprovalFlowPage() {
3804
+ const studioRef = useRef(null);
3805
+
3806
+ return (
3807
+ <div style={{ height: 680 }}>
3808
+ <FlowTreeStudio
3809
+ ref={studioRef}
3810
+ document={initialDoc}
3811
+ engine="flowable"
3812
+ dataProviders={dataProviders}
3813
+ runtime={runtime}
3814
+ onChange={({ exportXml }) => {
3815
+ const bpmnXml = exportXml('flowable');
3816
+ console.log('Compiled BPMN 2.0 XML length:', bpmnXml.length);
3817
+ }}
3818
+ />
3819
+ </div>
3820
+ );
3821
+ }
3822
+ ```
3823
+
3824
+ **JavaScript**
3825
+
3826
+ ```js
3827
+ import {
3828
+ FlowTreeShell,
3829
+ createFlowTreeController,
3830
+ createSampleFlowTree,
3831
+ createSampleFlowTreeDataProviders,
3832
+ createSampleFlowTreeRuntime,
3833
+ } from '@bpmn-nova/studio/flow-tree';
3834
+
3835
+ export function mountFlowTreeExample(container, theme = 'light') {
3836
+ const document = createSampleFlowTree('flowable');
3837
+ const controller = createFlowTreeController({ document });
3838
+ const shell = new FlowTreeShell({
3839
+ container,
3840
+ controller,
3841
+ mode: 'design',
3842
+ runtime: createSampleFlowTreeRuntime(document),
3843
+ dataProviders: createSampleFlowTreeDataProviders(),
3844
+ theme: { mode: theme },
3845
+ rightWidth: 336,
3846
+ });
3847
+
3848
+ return {
3849
+ controller,
3850
+ shell,
3851
+ destroy() {
3852
+ shell.destroy();
3853
+ controller.destroy();
3854
+ },
3855
+ };
3856
+ }
3857
+ ```
3858
+
3859
+
3860
+ ## 宿主业务数据接入(`dataProviders`)
3861
+
3862
+ 审批人、角色、部门、表单字段 Schema 与外部子流程列表均通过 `dataProviders` 注入,支持同步返回或 `Promise` 异步检索;未配置时自动降级为自由输入,开箱即可使用:
3863
+
3864
+ ```ts
3865
+ const dataProviders = {
3866
+ users: { search: (query) => api.searchUsers(query) },
3867
+ roles: { list: (query) => api.listRoles(query) },
3868
+ departments: { list: (query) => api.listDepartments(query) },
3869
+ formFields: { list: () => api.getFormFieldSchema(formId) },
3870
+ subProcesses: { list: (query) => api.listSubProcesses(query) },
3871
+ };
3872
+ ```
3873
+
3874
+ ## BPMN 2.0 编译与反编译
3875
+
3876
+ ```js
3877
+ import {
3878
+ compileFlowTreeToBpmn,
3879
+ exportFlowTreeBpmnXml,
3880
+ decompileBpmnToFlowTree,
3881
+ createSampleFlowTree,
3882
+ } from '@bpmn-nova/studio/flow-tree';
3883
+
3884
+ const doc = createSampleFlowTree('flowable');
3885
+ // 1. 编译为 ProcessModel 或直接导出可执行 BPMN 2.0 XML
3886
+ const bpmnModel = compileFlowTreeToBpmn(doc, { engine: 'flowable' });
3887
+ const xml = exportFlowTreeBpmnXml(doc, 'flowable');
3888
+
3889
+ // 2. 反编译回 FlowTree(L1 无损回显 / L2 通用块结构归约)
3890
+ const result = decompileBpmnToFlowTree(xml, 'flowable');
3891
+ if (result.compatible) {
3892
+ console.log(result.restorationLevel, result.document);
3893
+ } else {
3894
+ console.warn('包含非树形自由拓扑:', result.diagnostics);
3895
+ }
3896
+ ```
3897
+
3898
+ - 审批增强配置(选人策略、空处理、去重、按钮权限、表单权限矩阵、可视化条件组)保存在自定义命名空间 `xmlns:nova="urn:bpmn-nova:approval"` 下的 `<nova:nodeConfig>` 与 `<nova:flowTreeMeta>` 中,不影响 Flowable / Activiti 原生引擎属性解析。
3899
+ - 需要体验交互式画布、可视化条件构造器、表单权限矩阵与实时 XML 编译预览,请前往[审批树设计器示例](../examples/flow-tree)。
3900
+
3901
+
3651
3902
  <!-- SOURCE: docs/src/components/index.md -->
3652
3903
 
3653
3904
  # BPMN Nova 组件参数
3654
3905
 
3655
- 本手册记录 `0.3.9-preview` 的公开组件参数、回调和实例方法。所有视觉组件都需要具有实际尺寸的容器,并显式导入所属包的 `styles.css`。
3906
+ 本手册记录 `0.4.1` 的公开组件参数、回调和实例方法。所有视觉组件都需要具有实际尺寸的容器,并显式导入所属包的 `styles.css`。
3656
3907
 
3657
3908
  ## 在线体验
3658
3909
 
@@ -3696,6 +3947,8 @@ Controller 不创建 DOM,负责模型、命令、历史、选择与子流程
3696
3947
  | `extensions` | `StudioExtension[]` | `[]` | Controller 扩展,`setup()` 可返回清理函数 |
3697
3948
  | `allowedNodeTypes` | `Iterable<NodeType> \| null` | `null` | Deprecated 兼容别名;完整模型节点白名单 |
3698
3949
  | `allowedEdgeTypes` | `Iterable<EdgeType> \| null` | `null` | Deprecated 兼容别名;完整模型连线白名单 |
3950
+ | `locale` | `NovaLocale` | `'zh-CN'` | 自 0.4.0 起;界面语言(内置 `'zh-CN'` / `'en-US'`) |
3951
+ | `messages` | `NovaMessagesOverride \| null` | `null` | 自 0.4.0 起;局部文案覆盖对象 |
3699
3952
 
3700
3953
  常用方法:
3701
3954
 
@@ -3711,6 +3964,7 @@ Controller 不创建 DOM,负责模型、命令、历史、选择与子流程
3711
3964
  | `exportXml(engine?)` | `string` | 导出 BPMN XML |
3712
3965
  | `importXml(xml, engine?)` | `ProcessModel` | 导入并替换当前模型;类型白名单或 `nodeLimits` 不满足时抛错,且不改变当前模型与历史 |
3713
3966
  | `validate()` | `StudioValidationIssue[]` | 返回结构化错误和警告,不触发宿主 UI |
3967
+ | `setLocale(locale?, messages?)` / `getLocale()` | `NovaI18nState` | 自 0.4.0 起;运行中无重建切换语言与局部文案 |
3714
3968
  | `undo()` / `redo()` | `boolean` | 执行历史操作 |
3715
3969
  | `destroy()` | `void` | 清理扩展和订阅 |
3716
3970
 
@@ -3751,6 +4005,8 @@ studio.changeNodeType('EndEvent_1', 'startEvent') // 返回 false
3751
4005
  | `leftWidth` | `number` | `244` | Deprecated;使用 `config.ui.sidebarWidth.left` |
3752
4006
  | `rightWidth` | `number` | `360` | Deprecated;使用 `config.ui.sidebarWidth.right` |
3753
4007
  | `theme` | `NovaThemeInput` | `light` | 组件实例主题 |
4008
+ | `locale` / `messages` | `NovaLocale` / `NovaMessagesOverride` | `'zh-CN'` | 自 0.4.0 起;默认同步并共享 `studio.i18n`,支持 `setLocale()` / `getLocale()` 运行时切换 |
4009
+ | `formatRuntimeTime` / `runtimeTimeFormat` | `RuntimeTimeFormatter` / `RuntimeTimeFormatOptions` | 默认 `raw` 格式化 | 自 0.4.0 起;运行态时间展示配置,推荐放入 `config.viewer.*` |
3754
4010
  | `runtimeAppearance` | `RuntimeAppearanceOptions` | 默认语义映射 | 状态、动作、转移的 Tone 映射 |
3755
4011
  | `svgExport` | `SvgExportOptions & Renderer Adapters` | `{}` | Deprecated;使用 `config.export` |
3756
4012
  | `iconRegistry` | `IconRegistry` | 默认 Registry | 图标覆盖入口 |
@@ -3837,9 +4093,11 @@ new BpmnDesigner(options)
3837
4093
  | `onElementClick` | `(payload) => void` | 无 | 基础元素点击 |
3838
4094
  | `onProjectionChange` | `({ requested, active }) => void` | 无 | 实际投影变化 |
3839
4095
  | `theme` | `NovaThemeInput` | `light` | 实例主题 |
4096
+ | `locale` / `messages` | `NovaLocale` / `NovaMessagesOverride` | `'zh-CN'` | 自 0.4.0 起;界面语言与局部文案覆盖 |
4097
+ | `formatRuntimeTime` / `runtimeTimeFormat` | `RuntimeTimeFormatter` / `RuntimeTimeFormatOptions` | 默认格式 | 自 0.4.0 起;统一覆盖详情、驳回记录、时间线和 SVG 的时间显示 |
3840
4098
  | `runtimeAppearance` | `RuntimeAppearanceOptions` | 默认映射 | Runtime 语义外观 |
3841
4099
 
3842
- 实例方法:`setModel()`、`setRuntime()`、`setProjection()`、`setDisplayOptions()`、`refreshPresentation()`、`setTheme()`、`setRuntimeAppearance()`、`fitView()`、`openRuntimeDetails()`、`openRuntimeTransitionDetails()`、`closeRuntimeDetails()` 和 `destroy()`。Compact Runtime Timeline 中 `refreshPresentation()` 安全 No-op。
4100
+ 实例方法:`setModel()`、`setRuntime()`、`setProjection()`、`setDisplayOptions()`、`refreshPresentation()`、`setTheme()`、`setLocale()`、`getLocale()`、`setRuntimeAppearance()`、`fitView()`、`openRuntimeDetails()`、`openRuntimeTransitionDetails()`、`closeRuntimeDetails()` 和 `destroy()`。`refreshPresentation()` 在 `instance` 模式也会按最新格式化配置原地刷新并保留视口、滚动与已打开详情(自 0.4.0 起)。
3843
4101
 
3844
4102
  ## `BpmnCanvas`
3845
4103
 
@@ -3907,7 +4165,7 @@ canvas.setViewportState({ zoom: 0.8, pan: { x: 0, y: 0 } }) // 直
3907
4165
 
3908
4166
  ## React 组件
3909
4167
 
3910
- 所有 React 视觉组件支持 `className`、`style`、`theme` 和 `onThemeChange`。
4168
+ 所有 React 视觉组件支持 `className`、`style`、`theme`、`onThemeChange`,以及 `locale`、`messages` Prop 与 `setLocale()` / `getLocale()` Ref 方法(自 0.4.0 起);`BpmnStudio` 与 `BpmnViewer` 同时支持 `formatRuntimeTime` 和 `runtimeTimeFormat`(`BpmnStudio` 也可通过 `config.viewer` 配置)。
3911
4169
 
3912
4170
  ### `BpmnStudio`
3913
4171
 
@@ -3997,6 +4255,7 @@ Vue 组件与 React 使用同一底层接口,主要差异为:
3997
4255
  - Header Slot Context 的 `mode` 是响应式实际状态。Ref Expose 使用 `getStudio()`、`getShell()`、`getActions()`、`getMode()`、`setMode()`、`setAllowedModes()`、`validate()`、`refreshPresentation()`、`revealElement()` 或 `getInstance()`,不直接暴露可替换字段。`revealElement(id, options?)`(自 0.3.8-preview 起)与 React Ref 同语义;`BpmnCanvas` 的 Expose 另提供 `revealElement()` 与 `setViewportState()`。
3998
4256
  - Studio Prop 与 `useBpmnStudio()` 支持 `config`;Expose 提供 `getConfig()` / `setConfig()`,Header Slot Context 提供响应式只读 `ui`。
3999
4257
  - Studio Expose 提供与 React 相同的五个侧栏/面板选择方法;Header/Right Slot Context 共享响应式 `panelSelection`。
4258
+ - 全部 Vue 视觉组件支持响应式 `locale` / `messages` Prop 与 `setLocale()` / `getLocale()` Expose(自 0.4.0 起),无重建原地切换;`BpmnStudio` 与 `BpmnViewer` 同时支持响应式 `formatRuntimeTime` 与 `runtimeTimeFormat`。
4000
4259
 
4001
4260
  Vue 提供 `BpmnStudio`、`BpmnDesigner`、`BpmnViewer`、`BpmnCanvas`、`BpmnPalettePanel`、`BpmnPropertiesPanel` 和 `useBpmnStudio()`。独立 `BpmnPalettePanel` 复用外部 Studio;传入 Registry 时不会隐式注册 Providers,未传 Registry 时才用 Providers 创建默认 Registry。
4002
4261
 
@@ -4017,6 +4276,20 @@ interface PropertyComponentProps {
4017
4276
 
4018
4277
  Runtime Details、Timeline 和 Transition Details 组件通过对应 `createReact*Component()` / `createVue*Component()` 适配器注册。完整上下文见类型声明和[自定义指南](../customization/index.md)。
4019
4278
 
4279
+ ## FlowTree 审批树组件(自 0.4.1 起)
4280
+
4281
+ 面向钉钉 / 飞书式结构化审批流设计的独立组件族,由 `@bpmn-nova/studio/flow-tree`、`@bpmn-nova/vue` 和 `@bpmn-nova/react` 导出,与自由画布 `BpmnStudio` 相互独立:
4282
+
4283
+ | 组件 / 入口 | 适用包 | 说明 |
4284
+ | --- | --- | --- |
4285
+ | `FlowTreeShell` / `createFlowTreeController` | `@bpmn-nova/studio/flow-tree` | Vanilla JS 完整审批树工作台与控制器 |
4286
+ | `FlowTreeStudio` / `useFlowTree` | `@bpmn-nova/vue`、`@bpmn-nova/react` | 开箱即用的审批树工作台(含三态模式、BPMN 图与时间轴视图、内置完整业务属性面板、XML 预览与 SVG 导出) |
4287
+ | `FlowTreeCanvas` | `@bpmn-nova/studio/flow-tree`、`@bpmn-nova/vue`、`@bpmn-nova/react` | 独立树形画布(支持缩放平移、`+` 插入、分支优先级排序、子树折叠、拖拽移动与运行态叠加) |
4288
+ | `FlowTreePropertiesPanel` | `@bpmn-nova/studio/flow-tree`、`@bpmn-nova/vue`、`@bpmn-nova/react` | 独立内置业务属性面板(审批策略、可视化条件规则构造器、表单字段权限矩阵、按钮/延迟/触发器/子流程配置) |
4289
+
4290
+ - `FlowTreeStudio` 支持 `header` / `headerStart`(Vue `#header-start`)/ `headerActions`(Vue `#header-actions`)/ `right` 原生插槽,宿主可用自定义抽屉或企业组织架构选人器局部或整体接管配置面板。
4291
+ - 完整接入指南见[审批树设计器](../guide/flow-tree.md)。
4292
+
4020
4293
 
4021
4294
  <!-- SOURCE: docs/src/api/index.md -->
4022
4295
 
@@ -4062,6 +4335,8 @@ import type {
4062
4335
 
4063
4336
  自 `0.3.6-preview` 起,Vue/React/Studio 额外导出 `inspectRuntime`、`formatRuntimeInstant`、`parseRuntimeInstant`、`activityState` 以及类型 `RuntimeDiagnostic`、`ActivityVisitState`、`RuntimeInstant`。旧 `0.3.5-preview` 包没有这些 JavaScript 出口。
4064
4337
 
4338
+ 自 `0.4.0` 起,Studio / React / Vue 根入口新增国际化与运行态时间格式化出口:值导出 `zhCN`、`enUS`、`createI18n`、`resolveI18n`、`DEFAULT_LOCALE`;类型导出 `NovaLocale`、`NovaMessages`、`NovaMessagesOverride`、`NovaI18nOptions`、`NovaI18nState`、`I18nController`、`RuntimeTimeSurface`、`RuntimeTimeField`、`RuntimeTimeFormatContext`、`RuntimeTimeFormatter`、`RuntimeTimeFormatOptions`、`FormatRuntimeInstantOptions`。
4339
+
4065
4340
  真实数据转换、ID 关联、完整场景与已发布版本的 Props 类型推导见[审批轨迹接入指南](../guide/runtime.md)。
4066
4341
 
4067
4342
  ## Studio Config Interface
@@ -4114,6 +4389,10 @@ interface BpmnStudioConfig {
4114
4389
  timeline?: ViewerTimelineOptions
4115
4390
  runtimeDetails?: RuntimeDetailsOptions
4116
4391
  runtimeTraceOptions?: RuntimeTraceProjectionOptions
4392
+ /** 自 0.4.0 起:运行态时间自定义格式化回调,优先于 runtimeTimeFormat。 */
4393
+ formatRuntimeTime?: RuntimeTimeFormatter | null
4394
+ /** 自 0.4.0 起:运行态时间内置 Intl.DateTimeFormat 配置(时区/语言/样式)。 */
4395
+ runtimeTimeFormat?: RuntimeTimeFormatOptions | null
4117
4396
  }
4118
4397
  export?: StudioSvgExportOptions
4119
4398
  }
@@ -4960,6 +5239,134 @@ console.log(role.status, role.topologyComplete, role.issues)
4960
5239
 
4961
5240
  `resolveGatewayRole()` 会同时返回声明角色、线路推断角色、结构完成度及 `valid` / `incomplete` / `conflict` / `ambiguous` 状态。业务属性面板据此分别显示并行出口或汇聚入口/后续出口;角色切换和校验不会自动删除、改线或清空已有 Sequence Flow 数据。
4962
5241
 
5242
+ ## 多语言(i18n)
5243
+
5244
+ 自 `0.4.0` 起,内置零第三方依赖的 `zh-CN`(默认,保持与 `0.3.9-preview` 一致)和 `en-US` 文案包,支持初始化传入 `locale` / `messages` 局部覆盖,以及运行中通过 `setLocale(locale?, messages?)` 或框架响应式 Prop 无重建切换:
5245
+
5246
+ ```ts
5247
+ type NovaLocale = 'zh-CN' | 'en-US' | (string & {})
5248
+ type NovaMessageValue<P = Record<string, any>> = string | ((params: P) => string)
5249
+ type NovaMessagesOverride = DeepPartial<NovaMessages>
5250
+
5251
+ interface NovaI18nState {
5252
+ readonly locale: string
5253
+ readonly resolvedLocale: string
5254
+ }
5255
+ ```
5256
+
5257
+ ```js
5258
+ import { createStudioController, createStudioShell, enUS, zhCN } from '@bpmn-nova/studio'
5259
+
5260
+ const studio = createStudioController({
5261
+ model,
5262
+ locale: 'en-US',
5263
+ messages: {
5264
+ shell: { tools: { beautify: 'Auto Arrange' } },
5265
+ },
5266
+ })
5267
+
5268
+ const shell = createStudioShell({ container, studio })
5269
+
5270
+ // 运行中无重建切换语言,保留撤销栈、选中项、视口、子流程作用域与已有节点名称
5271
+ shell.setLocale('zh-CN')
5272
+ shell.setLocale('en-US', { modeling: { nodeLimitExceeded: ({ max, label }) => `Max ${max} ${label}` } })
5273
+ console.log(shell.getLocale()) // { locale: 'en-US', resolvedLocale: 'en-US' }
5274
+ ```
5275
+
5276
+ - **覆盖与回退**:`messages` 允许只覆盖单个键;未命中或缺失键自动回退到 `zh-CN` 对应项(开发模式仅 `console.warn` 一次,不抛异常)。
5277
+ - **已存在内容与新建节点**:切换语言不修改模型中已有元素名称、连线名称与 BPMN XML;之后新创建的节点按当前语言 `elementTypes` 生成默认名称(显式 `preset.name` 优先)。
5278
+ - **组件覆写入口**:`createStudioController`、`createStudioShell`、`BpmnCanvas`、`PalettePanel`、`PropertiesPanel`、`BpmnViewer`、`BpmnDesigner` 及 `@bpmn-nova/react` / `@bpmn-nova/vue` 对应组件均接受 `locale`、`messages` 并暴露 `setLocale()` / `getLocale()`。
5279
+ - **文案分域(`NovaMessages` 顶层键)**:
5280
+
5281
+ | 顶层键 | 覆盖范围 |
5282
+ | --- | --- |
5283
+ | `common` | 列表与问题分隔符 |
5284
+ | `elementTypes` / `edgeTypes` | 60 种 BPMN 节点、并行分支/汇聚、3 种连线类型名称 |
5285
+ | `actions` | 内置审批动作(`submit`、`approve`、`reject`、`return`、`add-sign`、`transfer`、`delegate`、`withdraw`、`comment`、`skip`、`cancel` 等) |
5286
+ | `shell` | 工作台 Header 模式/投影切换、工具栏、布局策略菜单、画布浮动头与面包屑、状态栏、侧栏折叠按钮、只读侧栏详情与导出提示 |
5287
+ | `palette` | 调色板分组标题、并行分支/汇聚说明、不可用原因 |
5288
+ | `contextMenu` | 画布/节点/连线/多选右键菜单分组与全部动作 |
5289
+ | `canvas` | 指针工具栏、选区工具栏、空子流程提示、连线编辑占位、端口与节点操作、快捷添加菜单、网关角色徽标、默认副标题 |
5290
+ | `modeling` | 节点数量上限提示(含英文单复数)、网关分支默认名、默认分组与未命名流程名 |
5291
+ | `validation` | 模型结构校验、并行网关拓扑校验、XML 导入错误前缀 |
5292
+ | `properties` | 属性面板头部、业务/开发者视图切换、通用表单控件、分支编辑器、ID 校验与 BPMN / Flowable / Activiti 字段 |
5293
+ | `runtime` | 运行态节点状态、摘要、驳回/退回文案、动作附件计数、诊断与失效提示、轨迹预测标签 |
5294
+ | `viewer` | 节点详情弹窗、驳回/退回记录弹窗、审批结果标签与附件/图片预览文案 |
5295
+ | `timeline` | 移动时间线默认标题/说明、轮次、参与者折叠、历史动作展开与并行组计数 |
5296
+ | `exportSvg` | SVG 默认视图名、确认预览弹窗与降级警告 |
5297
+
5298
+ ## 运行态时间格式化
5299
+
5300
+ 自 `0.4.0` 起,所有运行态展示面(节点详情 `details`、驳回/退回详情 `transition`、移动时间线 `timeline`、SVG 导出 `svg`)统一经 `formatRuntimeInstant()` 格式化显示时间,不影响排序、访问归并与失效推断:
5301
+
5302
+ ```ts
5303
+ type RuntimeTimeSurface = 'details' | 'transition' | 'timeline' | 'svg'
5304
+ type RuntimeTimeField = 'start' | 'end' | 'occurred' | 'resolved'
5305
+
5306
+ interface RuntimeTimeFormatContext {
5307
+ surface: RuntimeTimeSurface
5308
+ field: RuntimeTimeField
5309
+ locale: string
5310
+ }
5311
+
5312
+ type RuntimeTimeFormatter = (
5313
+ instant: RuntimeInstant,
5314
+ context: RuntimeTimeFormatContext,
5315
+ ) => string
5316
+
5317
+ interface RuntimeTimeFormatOptions {
5318
+ timeZone?: string
5319
+ locale?: string
5320
+ dateStyle?: 'full' | 'long' | 'medium' | 'short'
5321
+ timeStyle?: 'full' | 'long' | 'medium' | 'short'
5322
+ hour12?: boolean
5323
+ }
5324
+ ```
5325
+
5326
+ ```js
5327
+ // 方式 1:内置 Intl.DateTimeFormat 快捷配置(按租户/用户时区展示)
5328
+ const viewer = new BpmnViewer({
5329
+ container,
5330
+ model,
5331
+ runtime,
5332
+ runtimeTimeFormat: { timeZone: 'Asia/Shanghai', locale: 'zh-CN' },
5333
+ })
5334
+
5335
+ // 方式 2:自定义格式化函数(优先级高于 runtimeTimeFormat)
5336
+ viewer.setDisplayOptions({
5337
+ formatRuntimeTime(instant, { surface, field, locale }) {
5338
+ if (instant.kind === 'invalid') return instant.raw
5339
+ if (instant.kind === 'naive') return `${instant.raw} (local)`
5340
+ return new Intl.DateTimeFormat(locale, {
5341
+ timeZone: 'America/New_York',
5342
+ dateStyle: 'medium',
5343
+ timeStyle: 'short',
5344
+ }).format(new Date(instant.ms))
5345
+ },
5346
+ })
5347
+
5348
+ // Studio 通过 config.viewer(或顶层选项)配置,setConfig() 原地刷新且保留视口/滚动与已打开详情
5349
+ shell.setConfig({
5350
+ viewer: {
5351
+ runtimeTimeFormat: { timeZone: 'UTC', locale: 'en-US' },
5352
+ },
5353
+ })
5354
+ ```
5355
+
5356
+ - **优先级**:同时提供 `formatRuntimeTime` 与 `runtimeTimeFormat` 时,`formatRuntimeTime` 优先;`exportSvg()` 也可单次覆盖。
5357
+ - **边界值与兜底**:`instant.kind === 'missing'` 直接返回 `''` 且不调用 `formatRuntimeTime`;`invalid` 与 `naive` 会继续透传给 `formatRuntimeTime` 由宿主决定兜底文案;自定义回调抛错或返回非字符串时,回退默认格式(`raw.trim().replace('T', ' ')`)并在开发模式仅告警一次。
5358
+ - **不破坏语义**:`parseRuntimeInstant()` 仍按绝对时间戳(`ms`)参与排序与回退失效判定;运行中调用 `setDisplayOptions()` / `setConfig()` / `refreshPresentation()` 仅刷新时间展示,保留视口、滚动位置和已打开详情。
5359
+
5360
+ ## FlowTree 审批树子路径 API(自 0.4.1 起)
5361
+
5362
+ 子路径入口:`@bpmn-nova/studio/flow-tree`(Vue / React 包已直接 re-export 同名核心函数与组件)。
5363
+
5364
+ - **模型与控制器**:`createFlowTreeController(options)`、`createEmptyFlowTree(engine)`、`createSampleFlowTree(engine)`、`createSampleFlowTreeRuntime(doc)`、`createSampleFlowTreeDataProviders()`、`createDefaultFlowTreeNodeRegistry(customNodes)`、`validateFlowTree(doc)`、`formatFlowTreeNodeSummary(node)`。
5365
+ - **BPMN 2.0 编译与反编译**:`compileFlowTreeToBpmn(doc, options)`、`exportFlowTreeBpmnXml(doc, engine, options)`、`decompileBpmnToFlowTree(modelOrXml, engineHint, options)`、`compileConditionGroups(groups, options)`、`compileBranchCondition(branch, options)`、`createFlowTreeBpmnCompiler(defaultOptions)`。
5366
+ - **可视化与导出**:`FlowTreeShell`、`FlowTreeCanvas`、`FlowTreePropertiesPanel`、`exportFlowTreeSvg(context, options)`。
5367
+
5368
+ 详细节点字段与编译规则见[审批树设计器指南](../guide/flow-tree.md)。
5369
+
4963
5370
 
4964
5371
  <!-- SOURCE: docs/src/customization/index.md -->
4965
5372
 
@@ -5911,7 +6318,7 @@ Default ●
5911
6318
 
5912
6319
  # BPMN Nova NPM 包与发布
5913
6320
 
5914
- 版本:`0.3.9-preview`。BPMN Nova 只发布三个 `@bpmn-nova` 公共包,均使用 ESM、附带 TypeScript 声明、采用 Apache-2.0 License,并通过 `preview` dist-tag 发布。
6321
+ 版本:`0.4.0`。BPMN Nova 只发布三个 `@bpmn-nova` 公共包,均使用 ESM、附带 TypeScript 声明、采用 Apache-2.0 License,正式版通过默认 `latest` dist-tag 发布(带 `-` 后缀的预发布版本由守卫脚本要求显式使用 `--tag preview`)。
5915
6322
 
5916
6323
  ## 公共包
5917
6324
 
@@ -5919,9 +6326,9 @@ Default ●
5919
6326
 
5920
6327
  | 项目环境 | 安装命令 | 说明 |
5921
6328
  | --- | --- | --- |
5922
- | Vanilla JavaScript / TypeScript | `npm install @bpmn-nova/studio@preview` | 设计、展示、审批轨迹、主题与 SVG 导出 |
5923
- | React 18+ | `npm install @bpmn-nova/react@preview` | React 组件、Hook 与 Ref;依赖 Studio |
5924
- | Vue 3.3+ | `npm install @bpmn-nova/vue@preview` | Vue 组件、Composable 与 Expose;依赖 Studio |
6329
+ | Vanilla JavaScript / TypeScript | `npm install @bpmn-nova/studio` | 设计、展示、审批轨迹、主题与 SVG 导出 |
6330
+ | React 18+ | `npm install @bpmn-nova/react` | React 组件、Hook 与 Ref;依赖 Studio |
6331
+ | Vue 3.3+ | `npm install @bpmn-nova/vue` | Vue 组件、Composable 与 Expose;依赖 Studio |
5925
6332
 
5926
6333
  Core、Model、Renderer、Runtime、Theme、Properties、Node Presentation 和引擎 Profile 是源码内部 Module,不再是可独立安装或独立发布的产品。`NodeSubtitleResolver` 类型从 Studio 根入口公开,但 `node-presentation` 没有 npm 子路径或独立版本。React/Vue 各自只依赖完全相同版本的 `@bpmn-nova/studio`,并通过 peer dependency 使用宿主框架。
5927
6334
 
@@ -5937,6 +6344,8 @@ React/Vue 的声明入口显式重导出宿主常用的 Core 类型:`BpmnEdge`
5937
6344
 
5938
6345
  `0.3.9-preview` 新增 `config.ui.canvasHead`,可关闭画布左上角的“编辑模式”徽标、让作用域路径只在嵌套作用域显示;`allowedModes` 只有一种时默认 Header 不再显示模式切换;容器不超过 1120px 时 Header 保持单行。详见更新日志与组件参数。
5939
6346
 
6347
+ `0.4.0` 新增零第三方依赖的内置多语言(`zh-CN` / `en-US`、`locale` / `messages` 局部覆盖与运行中无重建 `setLocale()` 切换)、统一覆盖四个运行态展示面的时间格式化配置(`formatRuntimeTime` / `runtimeTimeFormat`),并修复移动时间线(`compact`)滚动后底部详情抽屉、大图预览与 SVG 导出预览浮层错位问题。详见更新日志与 API 文档。
6348
+
5940
6349
  ## Studio 子路径
5941
6350
 
5942
6351
  Studio 根入口重新导出稳定的完整能力;以下子路径用于让导入意图更清晰:
@@ -6000,7 +6409,7 @@ node scripts/build-packages.mjs --package vue
6000
6409
 
6001
6410
  发布前先查询三个包的 Registry 版本,选择统一且未被占用的目标版本,再一起更新上述版本和相关文档,执行 `npm run docs:ai` 生成 AI 文档。本地 `release:check-versions` 检查上述一致性,但不能替代发布后的远端检查。已发布版本不可覆盖;部分成功后的处理见本页“部分发布失败”。
6002
6411
 
6003
- 只有三个包的精确目标版本均可安装、Adapter 的 Studio 依赖精确一致、三个包的目标 dist-tag 均解析到 `V`,才算本轮发布完成。当前通道为 `preview`,保持 `latest` 不变;不将“最新版”解释为更新 `latest` 标签。
6412
+ 只有三个包的精确目标版本均可安装、Adapter 的 Studio 依赖精确一致、三个包的目标 dist-tag(正式版为 `latest`,预发布版为 `preview`)均解析到 `V`,才算本轮发布完成。预发布版本不得覆盖 `latest` 标签。
6004
6413
 
6005
6414
  ## 发布前验证
6006
6415
 
@@ -6033,15 +6442,15 @@ git diff --check
6033
6442
 
6034
6443
  ## 发布顺序
6035
6444
 
6036
- 每轮必须发布三个包。先发布 Studio,确认 Registry 已可解析后,再发布 React 和 Vue:
6445
+ 每轮必须发布三个包。先发布 Studio,确认 Registry 已可解析后,再发布 React 和 Vue(正式版走默认 `latest`;带 `-` 的预发布版本显式附加 `--tag preview`):
6037
6446
 
6038
6447
  ```bash
6039
- (cd packages/studio && npm publish --access public --tag preview)
6040
- (cd packages/react && npm publish --access public --tag preview)
6041
- (cd packages/vue && npm publish --access public --tag preview)
6448
+ npm publish /Users/afeng/workspace/bpmn-nova/packages/studio --access public
6449
+ npm publish /Users/afeng/workspace/bpmn-nova/packages/react --access public
6450
+ npm publish /Users/afeng/workspace/bpmn-nova/packages/vue --access public
6042
6451
  ```
6043
6452
 
6044
- 三个 manifest 都设置了 Preview 发布守卫。仍应显式使用 `--tag preview`,避免预览版本意外覆盖稳定版 `latest`。
6453
+ 三个 manifest 都保留了 Preview 发布守卫:带 `-` 后缀的预发布版本必须显式传 `--tag preview`,防止误发到 `latest`;正式版直接发布到 `latest`。
6045
6454
 
6046
6455
  发布后从仓库根目录核对;下面所有版本输出都应等于根版本,两个依赖也应精确等于该值:
6047
6456
 
@@ -6050,9 +6459,9 @@ release_version=$(node -p "require('./package.json').version")
6050
6459
  npm view "@bpmn-nova/studio@$release_version" version
6051
6460
  npm view "@bpmn-nova/react@$release_version" version dependencies --json
6052
6461
  npm view "@bpmn-nova/vue@$release_version" version dependencies --json
6053
- npm view @bpmn-nova/studio@preview version
6054
- npm view @bpmn-nova/react@preview version
6055
- npm view @bpmn-nova/vue@preview version
6462
+ npm view @bpmn-nova/studio@latest version
6463
+ npm view @bpmn-nova/react@latest version
6464
+ npm view @bpmn-nova/vue@latest version
6056
6465
  ```
6057
6466
 
6058
6467
  同时比较发布前后三个包的 `dist-tags.latest`,并在临时消费工程中安装本轮产物验证入口和类型。尚未通过远端核对时,报告为“部分发布”或“待验证”,不能报告全部发布成功。
@@ -6077,7 +6486,7 @@ Registry 清理是不可逆的外部操作,不由构建脚本自动执行。
6077
6486
 
6078
6487
  1. 使用 `npm view` 确认成功发布的包和版本。
6079
6488
  2. 修复身份、网络或顺序问题。
6080
- 3. 已成功发布且内容正确的包无需重复发布;继续发布本轮尚未成功的包,直到三个包及其 `preview` 标签均对齐。这是失败恢复,不是按源码改动跳过包。
6489
+ 3. 已成功发布且内容正确的包无需重复发布;继续发布本轮尚未成功的包,直到三个包及其目标 dist-tag 均对齐。这是失败恢复,不是按源码改动跳过包。
6081
6490
  4. 如果已发布 tarball 内容错误,停止本轮发布,修复后选择新的统一 Preview 版本,重新构建、验证并发布全部三个包,不能只提升一个包的版本。
6082
6491
 
6083
6492
  ## 文档
@@ -6419,6 +6828,135 @@ export function createApprovalProcess({ complete = true } = {}) {
6419
6828
  - [宿主布局定制](../customization/)
6420
6829
 
6421
6830
 
6831
+ <!-- SOURCE: docs/src/examples/flow-tree.md -->
6832
+
6833
+ # 审批树设计器
6834
+
6835
+ > [!NOTE]
6836
+ > **适用版本:自 `0.4.1` 起**。
6837
+
6838
+ 体验钉钉 / 飞书风格的结构化审批流设计器:点击节点下方 `+` 号插入全量 11 类业务节点,拖动卡片到其他 `+` 槽位重排,点击条件分支编辑可视化规则组,点击审批节点配置会签/或签与表单字段权限矩阵,并可在顶部一键查看编译后的 **Flowable / Activiti BPMN 2.0 XML** 或切换至 **审批轨迹(审批树 / BPMN 图 / 垂直时间轴)**。
6839
+
6840
+
6841
+ ## 示例挂载源码
6842
+
6843
+ 本页画布与下方代码共用同一份示例源码:
6844
+
6845
+ ```js
6846
+ import {
6847
+ FlowTreeShell,
6848
+ createFlowTreeController,
6849
+ createSampleFlowTree,
6850
+ createSampleFlowTreeDataProviders,
6851
+ createSampleFlowTreeRuntime,
6852
+ } from '@bpmn-nova/studio/flow-tree';
6853
+
6854
+ export function mountFlowTreeExample(container, theme = 'light') {
6855
+ const document = createSampleFlowTree('flowable');
6856
+ const controller = createFlowTreeController({ document });
6857
+ const shell = new FlowTreeShell({
6858
+ container,
6859
+ controller,
6860
+ mode: 'design',
6861
+ runtime: createSampleFlowTreeRuntime(document),
6862
+ dataProviders: createSampleFlowTreeDataProviders(),
6863
+ theme: { mode: theme },
6864
+ rightWidth: 336,
6865
+ });
6866
+
6867
+ return {
6868
+ controller,
6869
+ shell,
6870
+ destroy() {
6871
+ shell.destroy();
6872
+ controller.destroy();
6873
+ },
6874
+ };
6875
+ }
6876
+ ```
6877
+
6878
+ ## 在 Vue / React 中使用
6879
+
6880
+
6881
+ **Vue**
6882
+
6883
+ ```vue
6884
+ <script setup>
6885
+ import { ref } from 'vue';
6886
+ import {
6887
+ FlowTreeStudio,
6888
+ createSampleFlowTree,
6889
+ createSampleFlowTreeDataProviders,
6890
+ createSampleFlowTreeRuntime,
6891
+ } from '@bpmn-nova/vue';
6892
+ import '@bpmn-nova/vue/styles.css';
6893
+
6894
+ const studioRef = ref(null);
6895
+ const initialDoc = createSampleFlowTree('flowable');
6896
+ const dataProviders = createSampleFlowTreeDataProviders();
6897
+ const runtime = createSampleFlowTreeRuntime(initialDoc);
6898
+
6899
+ function handleChange({ exportXml }) {
6900
+ const bpmnXml = exportXml('flowable');
6901
+ console.log('Compiled BPMN 2.0 XML length:', bpmnXml.length);
6902
+ }
6903
+ </script>
6904
+
6905
+ <template>
6906
+ <div style="height: 680px">
6907
+ <FlowTreeStudio
6908
+ ref="studioRef"
6909
+ :document="initialDoc"
6910
+ engine="flowable"
6911
+ :data-providers="dataProviders"
6912
+ :runtime="runtime"
6913
+ @change="handleChange"
6914
+ />
6915
+ </div>
6916
+ </template>
6917
+ ```
6918
+
6919
+ **React**
6920
+
6921
+ ```jsx
6922
+ import { useRef } from 'react';
6923
+ import {
6924
+ FlowTreeStudio,
6925
+ createSampleFlowTree,
6926
+ createSampleFlowTreeDataProviders,
6927
+ createSampleFlowTreeRuntime,
6928
+ } from '@bpmn-nova/react';
6929
+ import '@bpmn-nova/react/styles.css';
6930
+
6931
+ const initialDoc = createSampleFlowTree('flowable');
6932
+ const dataProviders = createSampleFlowTreeDataProviders();
6933
+ const runtime = createSampleFlowTreeRuntime(initialDoc);
6934
+
6935
+ export default function ApprovalFlowPage() {
6936
+ const studioRef = useRef(null);
6937
+
6938
+ return (
6939
+ <div style={{ height: 680 }}>
6940
+ <FlowTreeStudio
6941
+ ref={studioRef}
6942
+ document={initialDoc}
6943
+ engine="flowable"
6944
+ dataProviders={dataProviders}
6945
+ runtime={runtime}
6946
+ onChange={({ exportXml }) => {
6947
+ const bpmnXml = exportXml('flowable');
6948
+ console.log('Compiled BPMN 2.0 XML length:', bpmnXml.length);
6949
+ }}
6950
+ />
6951
+ </div>
6952
+ );
6953
+ }
6954
+ ```
6955
+
6956
+
6957
+ 进一步了解 BPMN 2.0 节点映射、条件编译与宿主业务数据接入,请参阅[审批树设计器指南](../guide/flow-tree)。
6958
+
6959
+
6422
6960
  <!-- SOURCE: docs/src/examples/index.md -->
6423
6961
 
6424
6962
  # 在真实画布上,试一试
@@ -6428,6 +6966,7 @@ export function createApprovalProcess({ complete = true } = {}) {
6428
6966
  | 示例 | 可以体验什么 |
6429
6967
  | --- | --- |
6430
6968
  | [流程设计](./designer) | 拖动、添加、连线与 XML 导出 |
6969
+ | [审批树设计器](./flow-tree) | 钉钉 / 飞书风卡片树、可视化条件与权限矩阵、编译 BPMN 2.0 XML(自 `0.4.1` 起) |
6431
6970
  | [审批运行态](./runtime) | 已完成节点、当前审批人与流程进度 |
6432
6971
  | [宿主嵌入](./embedded) | 隐藏默认区域,用自己的页面承载画布 |
6433
6972
  | [自定义属性](./properties) | 为审批节点加入业务策略 |
@@ -6814,7 +7353,7 @@ export function previewExampleSvg(shell) {
6814
7353
 
6815
7354
  ## 在 JavaScript 项目中使用
6816
7355
 
6817
- 安装 `@bpmn-nova/studio@preview`,把上面两个文件放在同一文件夹,准备一个具有明确高度的容器,然后挂载示例:
7356
+ 安装 `@bpmn-nova/studio`,把上面两个文件放在同一文件夹,准备一个具有明确高度的容器,然后挂载示例:
6818
7357
 
6819
7358
  ```js
6820
7359
  import '@bpmn-nova/studio/styles.css';