@atlaskit/editor-palette

中文文档
3.5.95发布于 2026/11/07Apache-2.0TypeScriptESM + CJS近 30 天下载 12.4万

The editor palette

原始使用文档
文档目录3 节
  1. Usage
  2. APIs
  3. Installation

Editor palette

When adding support for themed content to tooling which interacts with adf content -- the decision was made to treat existing hex codes as a unique id, and link them to design tokens which have theme specific versions.

By providing a design token, this enables ADF content to be rendered in new themes such as dark mode.

Usage

Detailed docs and example usage can be found here.

APIs

Installation

yarn add @atlaskit/editor-palette

hexToBackgroundPaletteColor

This takes an adf hex color and returns a matching background palette color.

import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';

const cssValue = hexToBackgroundPaletteColor('#FFFFFF');
//     ^? const cssValue: 'var(--ds-surface, #FFFFFF)'
<div style={{backgroundColor: cssValue}} />

The names of tokens can change over time, and the values of tokens will differ between themes. The exact output of this function is an implementation detail and should only be used when rendering content to the user, on a client with a matching major version of @atlaskit/tokens.

  • DO NOT: store the output of these functions in any user-generated content or back-end.
  • DO: store the ADF hex color, and use these utilities at render time to display the themed version of the color

hexToTextPaletteColor

This takes an adf hex color and returns a matching text palette color.

import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette';

const cssValue = hexToEditorTextPaletteColor('#0747A6');
//     ^? const cssValue: 'var(--ds-text-accent-blue, #0747A6)'
<span style={{textColor: cssValue}} />

The names of tokens can change over time, and the values of tokens will differ between themes. The exact output of this function is an implementation detail and should only be used when rendering content to the user, on a client with a matching major version of @atlaskit/tokens.

  • DO NOT: store the output of these functions in any user-generated content or back-end.
  • DO: store the ADF hex color, and use these utilities at render time to display the themed version of the color

hexToEditorBorderPaletteColor

This takes an adf hex color and returns a matching border palette color.

import { hexToEditorBorderPaletteColor } from '@atlaskit/editor-palette';

const cssValue = hexToEditorBorderPaletteColor('#091E4224');
//     ^? const cssValue: 'var(--ds-border, #091E4224)'
<span style={{borderColor: cssValue}} />

The names of tokens can change over time, and the values of tokens will differ between themes. The exact output of this function is an implementation detail and should only be used when rendering content to the user, on a client with a matching major version of @atlaskit/tokens.

  • DO NOT: store the output of these functions in any user-generated content or back-end.
  • DO: store the ADF hex color, and use these utilities at render time to display the themed version of the color

版本与发布记录

@atlaskit/editor-palette 共发布 190 个版本,首次发布于 2022/12/21;过去 12 个月发布了 154 个版本。

版本发布日期距今
3.5.95latest2026/11/07今天
3.5.942026/11/061 天前
3.5.932026/11/061 天前
3.5.922026/11/061 天前
3.5.912026/11/062 天前
3.5.902026/11/053 天前

其他发布通道:next → 1.4.2。

关于 @atlaskit/editor-palette 的常见问题

@atlaskit/editor-palette 是什么?

The editor palette

如何安装 @atlaskit/editor-palette?

在项目目录运行 npm install @atlaskit/editor-palette,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.2.0 || ^19.2.0)、react-dom(^18.2.0 || ^19.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@atlaskit/editor-palette 支持 TypeScript 吗?

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

@atlaskit/editor-palette 支持 ESM 还是 CommonJS?

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

@atlaskit/editor-palette 可以商用吗?

@atlaskit/editor-palette 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@atlaskit/editor-palette 的下载量有多少?

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

@atlaskit/editor-palette 还在维护吗?

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