# @bpmn-io/feel-editor 中文文档

规范地址：https://npmcn.com/package/%40bpmn-io/feel-editor/

版本：2\.8\.1
npm 元数据更新时间：2026-10-28T12:39:08.947Z
中文译文更新时间：2026-11-08T13:05:32.752Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40bpmn-io/feel-editor
原文对照：https://npmcn.com/package/%40bpmn-io/feel-editor/?lang=original
项目主页：https://github.com/bpmn-io/feel-editor#readme
源码仓库：https://github.com/bpmn-io/feel-editor

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：143 kB，6 个文件
- 模块格式：ES Module
- TypeScript 类型：未声明
- 运行依赖：14 个
- 首次发布：2022-06-14T11:36:58.345Z
- 最新版本发布：2026-10-28T12:39:08.601Z
- 近 30 天下载量：368811（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：45（近 12 个月 14 个）

## 中文简介

感受表达式编辑器 .

## 安装

```sh
npm install @bpmn-io/feel-editor
```

也可以使用：`pnpm add @bpmn-io/feel-editor`、`yarn add @bpmn-io/feel-editor`、`bun add @bpmn-io/feel-editor`

## README

# @bpmn-io/feel-编辑器

可嵌入编辑器 [感觉表达式](https://docs.camunda.io/docs/components/modeler/feel/what-is-feel/)。 。 。 .

## 使用量

要开始, 创建一个感觉编辑实例 :

```JavaScript
import FeelEditor from '@bpmn-io/feel-editor';

const editor = new FeelEditor({
  container
});
```

配置感官方言( 表达式或无函数测试) :

```JavaScript
const editor = new FeelEditor({
  container,
  dialect: 'unaryTests' // defaults to 'expression'
});
```

您可以提供起始文档并查看更改:

```JavaScript
const editor = new FeelEditor({
  container,
  onChange,
  onKeyDown,
  onLint,
  value
});
```

### 变量

您可以提供用于自动补全的变量数组 。 嵌入 结构得到支持. 变量需要采用以下格式:

```JavaScript
const editor = new FeelEditor({
  container,
  variables: [
    {
      name: 'variablename to match',
      detail: 'optional inline info',
      info: 'optional pop-out info',
      entries: [
        {
          name: 'nested variable',
          ...
        }
      ]
    }
  ]
});
```

变量可通过 `FeelEditor#setVariables()`数字 :

```javascript
editor.setVariables([
  {
    name: 'newName',
    detail: 'new variable inline info',
    info: 'new pop-out info'
  }
]);
```

### 内容属性

您可以提供将设置在内容可编辑 div 上的属性 :

```javascript
const editor = new FeelEditor({
  container,
  contentAttributes: {
    'aria-label': 'Expression editor'
  }
});
```

### 活动

你可以听编辑发来的消息:

```javascript
const editor = new FeelEditor({
  container
});

editor.on('lint', ({ diagnostics }) => console.log(diagnostics));
```

## 黑客项目

要得到开发设置 确保有 [节点JS](https://nodejs.org/en/download/) 已安装. 设置后立即复制项目并执行

```
npm install
npm start
```

## 许可证

麻省理工学院

## 常见问题

### @bpmn-io/feel-editor 是什么？

感受表达式编辑器 \.

### 如何安装 @bpmn-io/feel-editor？

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

### @bpmn-io/feel-editor 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/bpmn-io\_\_feel-editor 是否存在。

### @bpmn-io/feel-editor 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @bpmn-io/feel-editor 可以商用吗？

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

### @bpmn-io/feel-editor 的下载量有多少？

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

### @bpmn-io/feel-editor 还在维护吗？

最新版本 2\.8\.1 发布于 2026/10/28（11 天前）；至今共发布 45 个版本，其中过去 12 个月发布了 14 个；首次发布于 2022/06/14。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

