@bpmn-io/form-js-editor

中文文档
2.2.0发布于 2026/11/06SEE LICENSE IN LICENSETypeScriptESM + CJS近 30 天下载 6.1万

Edit forms - powered by bpmn.io

原始使用文档
文档目录18 节
  1. Installation
  2. Usage
  3. Styling
  4. API
  5. FormEditor
  6. FormEditor#importSchema(schema: Schema) => Promise<Result, …
  7. FormEditor#saveSchema() => Schema
  8. FormEditor#attachTo(parentNode: HTMLElement) => void
  9. FormEditor#detach() => void
  10. FormEditor#on(event, fn) => void
  11. FormEditor#destroy() => void
  12. Events
  13. selection.changed :: { selection }
  14. Properties panel events
  15. Form lifecycle events
  16. Drag events
  17. Form field events
  18. License

@bpmn-io/form-js-editor

An editor to create forms that can be displayed with the form-js viewer.

Installation

npm install @bpmn-io/form-js-editor

Usage

import { FormEditor } from '@bpmn-io/form-js-editor';

const schema = {
  type: 'default',
  components: [
    {
      key: 'creditor',
      label: 'Creditor',
      type: 'textfield',
      validate: {
        required: true,
      },
    },
  ],
};

const formEditor = new FormEditor({
  container: document.querySelector('#form-editor'),
});

await formEditor.importSchema(schema);

Check out a full example.

Styling

For proper styling include the necessary stylesheets, and font used:

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

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

API

FormEditor

Create a new form editor with options { container?: HTMLElement }.

import { FormEditor } from '@bpmn-io/form-js-editor';

const formEditor = new FormEditor({
  container: document.querySelector('#form-editor'),
});

FormEditor#importSchema(schema: Schema) => Promise<Result, Error>

Display and edit a form represented via a form schema.

try {
  await formEditor.importSchema(schema);
} catch (err) {
  console.log('importing form failed', err);
}

FormEditor#saveSchema() => Schema

Export the form schema.

const schema = formEditor.saveSchema(schema);

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

FormEditor#attachTo(parentNode: HTMLElement) => void

Attach the form editor to a parent node.

FormEditor#detach() => void

Detach the form editor from its parent node.

FormEditor#on(event, fn) => void

Subscribe to an event.

FormEditor#destroy() => void

Remove form from editor the document.

Events

selection.changed :: { selection }

Properties panel events

  • propertiesPanel.focusin
  • propertiesPanel.focusout
  • propertiesPanel.showEntry :: { id }
  • propertiesPanel.updated :: { formField }

Form lifecycle events

  • detach
  • attach
  • rendered
  • form.init
  • form.clear
  • form.destroy
  • diagram.clear
  • diagram.destroy
  • dragula.created
  • dragula.destroyed
  • editorActions.init :: { editorActions }

Drag events

  • drag.start :: { element, source }
  • drag.end :: { element }
  • drag.drop :: { element, target, source, sibling }
  • drag.hover :: { element, container, source }
  • drag.out :: { element, container, source }
  • drag.cancel :: { element, container, source }

Form field events

  • formField.add :: { formField }
  • formField.remove :: { formField }
  • formField.updateId :: { formField, newId }

License

Use under the terms of the bpmn.io license.

版本与发布记录

@bpmn-io/form-js-editor 共发布 142 个版本,首次发布于 2021/03/20;过去 12 个月发布了 23 个版本。

版本发布日期距今
2.2.0latest2026/11/062 天前
2.1.12026/10/011 个月前
2.1.02026/09/281 个月前
2.0.22026/09/281 个月前
2.0.12026/09/251 个月前
2.0.02026/09/181 个月前

其他发布通道:backports → 1.15.5,alpha → 2.0.0-alpha.0。

关于 @bpmn-io/form-js-editor 的常见问题

@bpmn-io/form-js-editor 是什么?

Edit forms - powered by bpmn.io

如何安装 @bpmn-io/form-js-editor?

在项目目录运行 npm install @bpmn-io/form-js-editor,或使用 pnpm add / yarn add / bun add。

@bpmn-io/form-js-editor 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bpmn-io/form-js-editor 支持 ESM 还是 CommonJS?

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

@bpmn-io/form-js-editor 可以商用吗?

@bpmn-io/form-js-editor 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@bpmn-io/form-js-editor 的下载量有多少?

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

@bpmn-io/form-js-editor 还在维护吗?

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