# @editorjs/warning 中文文档

规范地址：https://npmcn.com/package/%40editorjs/warning/

版本：1\.4\.1
npm 元数据更新时间：2024-11-21T16:07:51.137Z
中文译文更新时间：2026-11-13T07:08:12.229Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40editorjs/warning
原文对照：https://npmcn.com/package/%40editorjs/warning/?lang=original
源码仓库：https://github.com/editor-js/warning

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

- 包体积（解压后）：17 kB，8 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：2 个
- 首次发布：2019-03-18T14:06:32.214Z
- 最新版本发布：2024-11-21T16:07:50.901Z
- 近 30 天下载量：126448（2026-10-13 至 2026-11-11，npm 官方下载统计）
- 已发布版本数：6（近 12 个月 0 个）

## 中文简介

用于编辑器.js的警告工具

## 安装

```sh
npm install @editorjs/warning
```

也可以使用：`pnpm add @editorjs/warning`、`yarn add @editorjs/warning`、`bun add @editorjs/warning`

## README

![](https://badgen.net/badge/CodeX%20Editor/v2.0/blue)

# 警告工具

提供警告块 [代码X 编辑器](https://ifmo.su/editor). Block 有标题和消息。 例如,它可用于编辑通知或上诉.

![](https://npmcn.com/package/%40editorjs/warning/assets/2d7b7bc1-ac46-4020-89c9-390d1a7297e2.jpg)

## 安装

拿到包裹

```shell
yarn add @editorjs/warning
```

在您的应用程序中包含模块

```javascript
import Warning from '@editorjs/warning';
```

您可以选择从 CDN 装入此工具 [JsDelivr CDN (英语)](https://cdn.jsdelivr.net/npm/@editorjs/warning@latest)

## 使用量

添加新工具到 `tools` 属性.

```javascript
var editor = CodexEditor({
  ...
  
  tools: {
    ...
    warning: Warning,
  },
  
  ...
});
```

或带有额外设置的输入警告工具

```javascript
var editor = CodexEditor({
  ...
  
  tools: {
    ...
    warning: {
      class: Warning,
      inlineToolbar: true,
      shortcut: 'CMD+SHIFT+W',
      config: {
        titlePlaceholder: 'Title',
        messagePlaceholder: 'Message',
      },
    },
  },
  
  ...
});
```

## 配置参数

| 外地 | 类型 | 说明 |
| --- | --- | --- |
| 标题 | `string` | 警告工具的标题占位符 |
| 信件显示符 | `string` | 警告工具的信息占位符 |

## 产出数据

| 外地 | 类型 | 说明 |
| --- | --- | --- |
| 标题 | `string` | 警告的标题 |
| 消息 | `string` | 警告的信息 |

```json
{
    "type" : "warning",
    "data" : {
        "title" : "Note:",
        "message" : "Avoid using this method just for lulz. It can be very dangerous opposite your daily fun stuff."
    }
}
```

## 常见问题

### @editorjs/warning 是什么？

用于编辑器\.js的警告工具

### 如何安装 @editorjs/warning？

在项目目录运行 npm install @editorjs/warning，或使用 pnpm add / yarn add / bun add。

### @editorjs/warning 支持 TypeScript 吗？

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

### @editorjs/warning 支持 ESM 还是 CommonJS？

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

### @editorjs/warning 可以商用吗？

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

### @editorjs/warning 的下载量有多少？

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

### @editorjs/warning 还在维护吗？

最新版本 1\.4\.1 发布于 2024/11/22（2 年前）；至今共发布 6 个版本，其中过去 12 个月发布了 0 个；首次发布于 2019/03/18。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

