@bomdi/codebox

中文文档
2.0.1发布于 2026/11/08ISCCommonJS零依赖构建来源已验证近 30 天下载 7690

Code syntax highlighting tool for Editor.js

此软件包已被标记为弃用

Deprecated: use @clepit/core, whose editor ships a code block. See https://clepit.com

原始使用文档
文档目录7 节
  1. Deprecated
  2. Setup
  3. Usage
  4. Config Params
  5. Output data
  6. Render saved data as component
  7. Author

CodeBox

Deprecated

This package is no longer maintained. Its successor is Clepit.

Clepit is a block-style editor and renderer from the same team. Its editor ships a code block with syntax highlighting, so CodeBox is no longer needed.

Existing installs keep working. The documentation below remains for legacy use.

Code syntax highlighting tool for Editor.js

Setup

Install the package via NPM

npm i @bomdi/codebox

Add to your module/application

import CodeBox from '@bomdi/codebox';
OR
const CodeBox = require('@bomdi/codebox');

Usage

Add CodeBox tools property of the CodeX Editor initial config.

const CodexEditor = require('@editorjs/editorjs');

let editor = new CodexEditor({
  ...

  tools: {
    ...
    codeBox: {
      class: CodeBox,
      config: {
        themeURL: 'https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/dracula.min.css', // Optional
        themeName: 'atom-one-dark', // Optional
        useDefaultTheme: 'light' // Optional. This also determines the background color of the language select drop-down
      }
    },
  }

  ...
});

Config Params

All parameters are optional

FieldTypeDescription
themeURLstringURL pointing to CSS file that can be used by highlight.js. This could also point o your own custom CSS syntax file. If themeURL is provided, themeName and useDefaultTheme will be ignored
themeNamestringAny one of the accepted theme names used by highlight.js. Only the name is required, not the full URL (example "a11y-dark"). If themeName is provided, useDefaultTheme will be ignored
useDefaultThemestringCodeBox has 2 default themes - 1 light and 1 dark. You can specify what default should be applied by passing the string 'light' or 'dark' to this parameter. Note that setting themeURL or themeName overrides this setting for the main code block, however, the background of the language select element/dropdown menu is set by this value

If no parameters are specified, CodeBox defaults to a dark theme.

Output data

CodeBox returns the following data

{
  "type": "codeBox",
  "data": {
    "code": "consttest = newTest();.codeBoxTextArea{\n  width: 100%;\n  min-height: 30px;\n  padding: 10px;\n  border-radius: 2px 2px 2px 0;\n  border: none !important;\n  outline: none !important;\n  font: 14px monospace;\n}\n\n.codeBoxSelectDiv{\n  display: flex;\n  flex-direction: column;\n  justify-content: flex-start;\n  align-items: flex-start;\n  position: relative;\n}",
    "language": "css",
    "theme": "https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/atom-one-dark.min.css"
  }
}

Render saved data as component

If you use react, you can pass your saved data to the library editorjs-react-renderer to render a code block component

import { CodeBoxOutput } from 'editorjs-react-renderer';

const data = {
  "type": "codeBox",
  "data": {
    "code": ".codeBoxTextArea{\n  width: 100%;\n  min-height: 30px;\n  padding: 10px;\n  border-radius: 2px 2px 2px 0;\n  border: none !important;\n  outline: none !important;\n  font: 14px monospace;\n}\n\n.codeBoxSelectDiv{\n  display: flex;\n  flex-direction: column;\n  justify-content: flex-start;\n  align-items: flex-start;\n  position: relative;\n}",
    "language": "css",
    "theme": "https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/atom-one-dark.min.css"
  }
};

const CodeBlock = () => CodeBoxOutput(data);

export default CodeBlock;

Author

Dev Juju

Contact Us

Learn

版本与发布记录

@bomdi/codebox 共发布 15 个版本,首次发布于 2020/02/12;过去 12 个月发布了 1 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.0.1latest2026/11/08今天
2.0.02022/09/064 年前
1.0.122021/04/105 年前
1.0.112021/04/105 年前
1.0.102020/02/206 年前
1.0.92020/02/196 年前

关于 @bomdi/codebox 的常见问题

@bomdi/codebox 是什么?

Code syntax highlighting tool for Editor.js注意:该包已被作者标记为弃用——Deprecated: use @clepit/core, whose editor ships a code block. See https://clepit.com

如何安装 @bomdi/codebox?

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

@bomdi/codebox 支持 TypeScript 吗?

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

@bomdi/codebox 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@bomdi/codebox 可以商用吗?

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

@bomdi/codebox 的下载量有多少?

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

@bomdi/codebox 还在维护吗?

最新版本 2.0.1 发布于 2026/11/08(今天);至今共发布 15 个版本,其中过去 12 个月发布了 1 个;首次发布于 2020/02/12。作者已将其标记为弃用,新项目建议寻找替代方案。