@domternal/vue

中文文档
1.8.1发布于 2026/11/08MITTypeScriptES Module零依赖近 30 天下载 2446

MIT-licensed Vue 3 components for the Domternal rich text editor

原始使用文档
文档目录6 节
  1. Install
  2. Quick start
  3. Bind content with v-model
  4. Configuration notes
  5. Office paste and custom list labels
  6. Further reading

@domternal/vue

Version MIT License

Vue 3 components and composables for the Domternal rich text editor. Includes toolbar and menu components, v-model support, reactive editor state, and custom node views written as Vue components.

Install

pnpm add @domternal/vue @domternal/core @domternal/theme vue

The package declares Node.js 22 or later for tooling. Requires Vue 3.3 or later and @domternal/core >=1.8.0 <2.0.0. Use version 1.8.1 for all installed Domternal Free packages. Import the theme once in your application for default styling.

Quick start

Use the composable component to arrange the toolbar, content, and menus:

<script setup lang="ts">
import { Domternal } from '@domternal/vue';
import { StarterKit, BubbleMenu } from '@domternal/core';
import '@domternal/theme';

const extensions = [StarterKit, BubbleMenu];
</script>

<template>
  <Domternal :extensions="extensions" content="<p>Hello from Vue!</p>">
    <Domternal.Toolbar />
    <Domternal.Content />
    <Domternal.BubbleMenu :contexts="{ text: ['bold', 'italic', 'underline'] }" />
  </Domternal>
</template>

Domternal creates the editor, provides it to descendants, and destroys it on unmount. The toolbar renders controls contributed by the loaded extensions.

Bind content with v-model

Use DomternalEditor when the document should bind to application state:

<script setup lang="ts">
import { ref } from 'vue';
import { DomternalEditor } from '@domternal/vue';
import { StarterKit, type Content } from '@domternal/core';

const extensions = [StarterKit];
const content = ref<Content>('<p>Start typing...</p>');
</script>

<template>
  <DomternalEditor v-model="content" :extensions="extensions" />
</template>

The model holds HTML by default. Set outputFormat="json" and initialize it with JSON content to bind JSON instead.

For full control, useEditor returns editor, a ShallowRef<Editor | null>, and editorRef, which you bind to the mount element. Use provideEditor(editor) to share it and useEditorState(editor, ed => ed.isActive('bold')) for derived state. See the composable example.

Configuration notes

  • The wrapper includes Document, Paragraph, Text, BaseKeymap, and History. StarterKit adds common formatting.
  • Domternal and DomternalEditor do not forward a history prop. To use another undo manager, call useEditor({ history: false, extensions }) and omit History from those extensions as well. See disabling history.
  • Creation happens in onMounted, so the editor is null during SSR and initial setup. Leave immediatelyRender off for SSR; see Nuxt integration.
  • editable controls read-only mode. preset="notion" is read at creation. Replace i18n to update UI translations without recreating the editor.
  • onContentError reports invalid initial content; onContentDiagnostic reports normalized content values. The Vue guide documents callback options; the Editor API explains diagnostics.
  • Custom icons contain raw SVG. Supply trusted, developer-authored constants.

Office paste and custom list labels

Register PasteCleanup in your editor's extensions to normalize supported Word and Google Docs clipboard HTML. It is not enabled by the wrapper. In 1.5.0, formattingForPaste lets your application choose Preserve or Adapt for each paste without recreating the editor. Add the corresponding formatting, Table and Image extensions for content you want to retain. Use ListLabels for supported custom markers, with the same schema on every collaborative writer.

Further reading

版本与发布记录

@domternal/vue 共发布 37 个版本,首次发布于 2026/04/16;过去 12 个月发布了 37 个版本。

版本发布日期距今
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/vue 的常见问题

@domternal/vue 是什么?

MIT-licensed Vue 3 components for the Domternal rich text editor

如何安装 @domternal/vue?

在项目目录运行 npm install @domternal/vue,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(>=3.3)、@domternal/core(>=1.8.0 <2.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@domternal/vue 支持 TypeScript 吗?

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

@domternal/vue 支持 ESM 还是 CommonJS?

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

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

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

@domternal/vue 可以商用吗?

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

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

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

@domternal/vue 还在维护吗?

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