@camunda/form-playground

中文文档
0.28.0发布于 2026/10/20MITESM + CJS近 30 天下载 1.8万

卡蒙达格式游戏场.

中文使用文档
文档目录24 节
  1. 使用量
  2. 样式
  3. API 密码
  4. createCamundaFormPlayground => Promise<Result, Error>
  5. CamundaFormPlayground
  6. 选项
  7. CamundaFormPlayground#open(containers?: string[]) => void
  8. CamundaFormPlayground#collapse(containers?: string[]) => vo…
  9. CamundaFormPlayground#get(type: String, strict: Boolean) =>…
  10. CamundaFormPlayground#getDataEditor() => JSONEditor
  11. CamundaFormPlayground#getEditor() => FormEditor
  12. CamundaFormPlayground#getForm() => Form
  13. CamundaFormPlayground#getResultView() => JSONEditor
  14. CamundaFormPlayground#getSchema() => any
  15. CamundaFormPlayground#setSchema(schema: any) => void
  16. CamundaFormPlayground#saveSchema() => any
  17. CamundaFormPlayground#attachTo(parent: HTMLElement) => void
  18. CamundaFormPlayground#detach() => void
  19. CamundaFormPlayground#fire(event) => void
  20. CamundaFormPlayground#on(event, fn) => void
  21. CamundaFormPlayground#off(event, fn) => void
  22. CamundaFormPlayground#destroy() => void
  23. 黑客项目
  24. 许可证

@ camunda/ 形式游戏场

CI

卡蒙达格式游戏场.

使用量

将游乐场融入您的应用程序 :

import { createCamundaFormPlayground } from 'camunda/form-playground';

const formPlayground = await createCamundaFormPlayground({
  container: document.querySelector('#container'),
  data,
  schema
});

// open preview
formPlayground.open();

// close preview
formPlayground.collapse();

// listen on editor events
const formEditor = formPlayground.getEditor();

formEditor.on('selection.changed', () => { ... });

样式

适当的样式包括必要的样式表和使用的字体:

<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,600;1,400&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&display=swap" rel="stylesheet">

<link rel="stylesheet" href="https://unpkg.com/@camunda/[email protected]/dist/assets/form-js.css">
<link rel="stylesheet" href="https://unpkg.com/@camunda/[email protected]/dist/assets/form-js-editor.css">
<link rel="stylesheet" href="https://unpkg.com/@camunda/[email protected]/dist/assets/camunda-form-playground.css">

API 密码

createCamundaFormPlayground => Promise<Result, Error>

创建一个已完全渲染的窗体操场 有选项。 。 。 .

import { createFormPlayground } from '@camunda/form-playground';

const formPlayground = await createFormPlayground({
  container: document.querySelector('#form-playground'),
  data,
  schema
});

CamundaFormPlayground

创建新窗体操场 有选项。 。 。 .

import { CamundaFormPlayground } from '@camunda/form-playground';

const formPlayground = new CamundaFormPlayground({
  container: document.querySelector('#form-playground'),
  data,
  schema
});

选项

有几个选项可以传递给 createFormPlayground 或者说 CamundaFormPlayground数字 :

{
  container: HTMLElement,               // optional - the container to render the form playground into
  data: {},                             // required - set the initial form data
  schema: {},                           // required - set the initial form schema
  exporter: { name: '', version: '' },  // optional - set the schema exporter name and version
  layout: {},                           // optional - set the initial form layout
  editorAdditionalModules: [],          // optional - add additional modules to the form editor
  viewerAdditionalModules: [],          // optional - add additional modules to the form preview
  editorProperties: {},                 // optional - set the initial form editor properties
  viewerProperties: {},                 // optional - set the initial form preview properties
}

例如,你可以使用 viewerProperties 在新标签中覆盖打开外部链接的默认行为 :

viewerProperties: {
  textLinkTarget: '_blank'
}

CamundaFormPlayground#open(containers?: string[]) => void

打开所有或特定的游乐场容器.

// open all
formPlayground.open();

// open specific
formPlayground.open([ 'form-preview' ]);

CamundaFormPlayground#collapse(containers?: string[]) => void

折叠所有或特定游乐场容器.

// collapse all
formPlayground.collapse();

// collapse specific
formPlayground.collapse([ 'form-preview' ]);

CamundaFormPlayground#get(type: String, strict: Boolean) => any

从嵌入式格式编辑器获取服务 .

const eventBus = formPlayground.get('eventBus');

CamundaFormPlayground#getDataEditor() => JSONEditor

获取嵌入式输入数据编辑器 .

const dataEditor = formPlayground.getDataEditor();

const data = dataEditor.getValue();

CamundaFormPlayground#getEditor() => FormEditor

获取嵌入式格式编辑器 .

const editor = formPlayground.getEditor();

editor.on('selection.changed', () => { ... });

CamundaFormPlayground#getForm() => Form

获取嵌入式预览表 .

const form = formPlayground.getForm();

form.on('submit', event => {
  console.log('Form <submit>', event);
});

CamundaFormPlayground#getResultView() => JSONEditor

获取嵌入式输出数据视图 .

const resultView = formPlayground.getResultView();

const data = resultView.getValue();

CamundaFormPlayground#getSchema() => any

获取当前表单计划 .

CamundaFormPlayground#setSchema(schema: any) => void

设置表单方案.

CamundaFormPlayground#saveSchema() => any

从嵌入的窗体编辑器导出窗体计划 .

const schema = formPlayground.saveSchema(schema);

console.log('exported schema', schema);

CamundaFormPlayground#attachTo(parent: HTMLElement) => void

将表单游乐场附加到父节点上.

CamundaFormPlayground#detach() => void

将形式游乐场从母节点分离出.

CamundaFormPlayground#fire(event) => void

开个会.

CamundaFormPlayground#on(event, fn) => void

订阅一个事件.

CamundaFormPlayground#off(event, fn) => void

从一个事件取消订阅 .

CamundaFormPlayground#destroy() => void

从文档中删除窗体操场.

黑客项目

要得到开发设置 确保有 节点JS 已安装. 设置后立即复制项目并执行

npm install
npm start

许可证

麻省理工学院

版本与发布记录

@camunda/form-playground 共发布 54 个版本,首次发布于 2022/09/30;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.28.0latest2026/10/2020 天前
0.27.02026/09/181 个月前
0.26.02026/08/242 个月前
0.25.02026/07/074 个月前
0.24.02026/02/098 个月前
0.23.02025/10/251 年前

其他发布通道:next → 0.13.0-alpha.1。

关于 @camunda/form-playground 的常见问题

@camunda/form-playground 是什么?

卡蒙达格式游戏场.

如何安装 @camunda/form-playground?

在项目目录运行 npm install @camunda/form-playground,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@bpmn-io/form-js(^2.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@camunda/form-playground 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/camunda__form-playground 是否存在。

@camunda/form-playground 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@camunda/form-playground 可以商用吗?

@camunda/form-playground 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@camunda/form-playground 的下载量有多少?

根据 npm 官方下载统计,@camunda/form-playground 在 2026/10/09 – 2026/11/07 这 30 天内被下载 17,526 次,日均约 584 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@camunda/form-playground 还在维护吗?

最新版本 0.28.0 发布于 2026/10/20(20 天前);至今共发布 54 个版本,其中过去 12 个月发布了 5 个;首次发布于 2022/09/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。