@formdown/editor

中文文档
0.26.1发布于 2026/11/09MITTypeScriptESM + CJS构建来源已验证近 30 天下载 2202

Development tool for Formdown syntax with advanced editing features

原始使用文档
文档目录10 节
  1. Installation
  2. Usage
  3. HTML
  4. JavaScript
  5. Properties
  6. Methods
  7. Events
  8. Writing the source
  9. Documentation
  10. License

@formdown/editor

Web component editor for Formdown: the source in a text area, the form it makes beside it.

Installation

npm install @formdown/editor

Importing the package registers <formdown-editor> and the <formdown-ui> its preview draws.

Usage

HTML

<script type="module">
  import '@formdown/editor'
</script>

<formdown-editor mode="split" content="@name: [text required]"></formdown-editor>

JavaScript

import { createFormdownEditor } from '@formdown/editor'

const editor = createFormdownEditor(document.getElementById('editor'), {
  content: '@name: [text required]',
  mode: 'split',
})

editor.addEventListener('contentChange', (event) => {
  console.log('New source:', event.detail.content)
})

Properties

  • content (string) — the Formdown source. Text inside the element is used when content is not set.
  • mode ('edit' | 'split' | 'view', default 'split') — the source, the source and the form, or the form.
  • placeholder (string) — shown in the empty source.
  • header (boolean, default false) — a heading over each panel.
  • toolbar (boolean, default true) — buttons that insert a field of each common type.
  • data (object) — the values of the form's fields.

Methods

  • validate() — the preview form's validation result.
  • getFormData() — the preview form's values.

Events

  • contentChange — the source changed; detail.content is the new source.
  • formdown-data-update — a value in the form changed; detail.formData holds them all.
  • formdown-change — one field changed, as <formdown-ui> reports it: detail.fieldName, detail.value, detail.formData.

Writing the source

As you type, a field you have just started is completed, and one undo takes the completion away:

  • three underscores after other text on the line get an @ for the field's name (Name: ___ → Name: ___@);
  • a space after @name: at the start of a line gets [], with the caret inside for the field's type.

Tab inserts two spaces.

Documentation

For complete documentation, visit the Formdown documentation.

License

MIT

版本与发布记录

@formdown/editor 共发布 58 个版本,首次发布于 2025/06/23;过去 12 个月发布了 39 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.26.1latest2026/11/096 天前
0.26.02026/10/2422 天前
0.25.02026/10/2422 天前
0.24.02026/10/2224 天前
0.23.02026/10/2225 天前
0.22.02026/10/2026 天前

关于 @formdown/editor 的常见问题

@formdown/editor 是什么?

Development tool for Formdown syntax with advanced editing features

如何安装 @formdown/editor?

在项目目录运行 npm install @formdown/editor,或使用 pnpm add / yarn add / bun add。

@formdown/editor 支持 TypeScript 吗?

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

@formdown/editor 支持 ESM 还是 CommonJS?

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

@formdown/editor 可以商用吗?

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

@formdown/editor 的下载量有多少?

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

@formdown/editor 还在维护吗?

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