@domternal/theme

中文文档
1.8.1发布于 2026/11/08MITTypeScriptCommonJS零依赖近 30 天下载 3278

Light and dark CSS theme for the Domternal rich text editor

原始使用文档
文档目录6 节
  1. Install
  2. Usage
  3. Light and dark mode
  4. Customize the theme
  5. Rendering and print behavior
  6. Entry points

@domternal/theme

Version MIT License

Default styles for the Domternal editor, toolbar, menus, pickers, and document content. Includes light and dark themes, CSS custom properties for customization, and print styles. This package contains CSS and Sass source, with no JavaScript runtime.

Install

pnpm add @domternal/theme

The package declares Node.js 22 or later for tooling and has no peer dependencies. Use version 1.8.1 for the theme, editor and framework wrapper so component markup and styles stay aligned.

Usage

Import once in your application's entry point:

import '@domternal/theme';

For a Sass pipeline, use the source entry point instead:

@use '@domternal/theme/scss';

React, Vue, and Angular components add the editor's .dm-editor class. With @domternal/core or @domternal/vanilla, add that class to the host yourself.

Light and dark mode

Light is the default. Add a theme class to a common ancestor of the editor and its UI so sibling toolbars and menus receive the same palette:

<div class="dm-theme-dark">
  <div class="dm-toolbar">...</div>
  <div class="dm-editor">...</div>
</div>

Use dm-theme-auto to follow the system preference, or dm-theme-light to force a light palette. Toggle the class at runtime without recreating the editor. For a borderless document layout, create the editor with preset: 'notion'; see Notion mode.

Customize the theme

Load overrides after the theme. Defaults live on the component elements, so target .dm-editor and .dm-toolbar rather than setting variables only on an ancestor:

.my-app .dm-editor,
.my-app .dm-toolbar {
  --dm-accent: #e11d48;
  --dm-accent-hover: #be123c;
  --dm-accent-surface: rgba(225, 29, 72, 0.1);
}

.my-app .dm-editor {
  --dm-editor-bg: #fefce8;
  --dm-editor-border-radius: 0.5rem;
}

The theming guide covers custom palettes, separately mounted UI, scrolling, Sass, and the complete CSS property reference.

Rendering and print behavior

  • Print styles hide editor controls and use a light palette, including when the screen theme is dark. To isolate the editor from your application's surrounding UI, use the Print extension. Color overrides for print need !important in a later @media print rule; see printing.
  • Core, Table and theme 1.6.0 support eligible multirow print headers through the Print extension and standard Table node view. The print-only header group leaves document JSON and selection unchanged; browser pagination still applies. Core's optional resource preparation can wait for live images and fonts before command-driven printing. See optional print preparation.
  • Highlights and shaded table cells retain authored backgrounds. In the live editor, text without an authored color adapts to that background. This behavior is not serialized into getHTML(); use a read-only editor to display saved content with the same contrast handling. See text on kept backgrounds for custom themes, browser fallbacks, and experimental tone helpers.
  • Core and theme 1.5.0 also preserve literal full-width paragraph and heading fills through BlockColor, including empty blocks. Default text uses a readable tone on known backgrounds; explicit text colors follow the selected contrast policy. See block backgrounds.
  • Pending image files show a localized loading status with reduced-motion support. The indicator is view-only and hidden in print. Custom themes should style .domternal-image-uploading and its __spinner and __label children.
  • Core and theme 1.4.0 add TextColor.configure({ contrast: 'auto' }) for literal text colors. It is off by default; enable it in the Core extension. The live editor adjusts an opaque literal color only when its measured contrast is below 4.5:1 on a known solid background. The original color remains in stored content, HTML, clipboard output, export and print. Tokens, translucent text and uncertain paint are unchanged. See the Core README for the supported paint, custom mark views and stylesheet requirements.
  • Core 1.8.0 exposes TextColorStorage.preview(root, marks) for literal-color adjustment in isolated DOM previews using the same theme stylesheet. See read-only previews for the required markup and preview lifecycle.
  • The native hidden attribute hides themed elements; hidden="until-found" keeps its browser behavior.
  • The stylesheet includes PasteCleanup feedback and floating-menu descriptions. Load the corresponding extensions or components to enable those features.

Entry points

ImportContents
@domternal/themeCompiled CSS, or Sass source with Sass-aware resolution
@domternal/theme/cssExplicit compiled CSS
@domternal/theme/scssSass source

版本与发布记录

@domternal/theme 共发布 47 个版本,首次发布于 2026/03/22;过去 12 个月发布了 47 个版本。

版本发布日期距今
1.8.1latest2026/11/085 天前
1.8.02026/10/2123 天前
1.7.02026/10/2024 天前
1.6.02026/10/1925 天前
1.5.12026/10/1628 天前
1.5.02026/10/1628 天前

关于 @domternal/theme 的常见问题

@domternal/theme 是什么?

Light and dark CSS theme for the Domternal rich text editor

如何安装 @domternal/theme?

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

@domternal/theme 支持 TypeScript 吗?

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

@domternal/theme 支持 ESM 还是 CommonJS?

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

@domternal/theme 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@domternal/theme 可以商用吗?

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

@domternal/theme 的下载量有多少?

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

@domternal/theme 还在维护吗?

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