From ab2a472bb1c2e28aca6ad55223db522dd5f7e8bf Mon Sep 17 00:00:00 2001 From: Sandro Circi Date: Sun, 5 Jul 2026 14:33:40 +0200 Subject: [PATCH 1/7] feat(Editor): support external editor instances --- docs/content/docs/2.components/editor.md | 63 +++++++ src/runtime/components/Editor.vue | 173 ++++++++++++++----- src/runtime/composables/useComponentProps.ts | 14 ++ test/components/Editor.spec.ts | 85 ++++++++- 4 files changed, 291 insertions(+), 44 deletions(-) diff --git a/docs/content/docs/2.components/editor.md b/docs/content/docs/2.components/editor.md index 75a26f7beb..713765b01d 100644 --- a/docs/content/docs/2.components/editor.md +++ b/docs/content/docs/2.components/editor.md @@ -155,6 +155,69 @@ const value = ref('

Hello World

\n') Check out the image upload example for creating custom TipTap extensions. :: +### External editor + +When you need full control over the editor — a custom schema, a different `StarterKit`, or a bespoke content lifecycle — you can create the TipTap editor yourself and pass it through the `editor` prop. The Editor then acts as a **shell**: it renders and styles the editor and wires it to the child components ([EditorToolbar](/docs/components/editor-toolbar), menus, …), but leaves the editor's extensions, content and lifecycle entirely to you. + +```vue + + + +``` + +::note +In this mode, the engine props (`starter-kit`, `image`, `mention`, `placeholder`, `markdown`, `content-type`, `model-value`, `extensions`) are **ignored** — the external editor owns its content and schema. You must keep full v-model control on your own editor instance, not UEditor component. +:: + +This is what enables editors backed by an extended starter kit, such as [comark-tiptap](https://github.com/sandros94/comark-tiptap), which provides a lossless markdown ↔ AST ↔ ProseMirror round-trip: + +```vue + + + +``` + +The [EditorToolbar](/docs/components/editor-toolbar) and handlers adapt to your editor's schema, but the mention, emoji and suggestion menus — and `placeholder` — only work once their extensions are registered on your editor (like `Mention` above). + +::note +Nuxt UI automatically injects its `editorProps` (including the theme's base classes) into your editor so it inherits the default styling. Set `:editor-props="false"` to opt out and manage the editor's `editorProps` yourself. +:: + +::tip +Use the `#fallback` slot to render content while an editor that is created asynchronously is not yet available. +:: + ### Placeholder Use the `placeholder` prop to set a placeholder text that shows in empty paragraphs. diff --git a/src/runtime/components/Editor.vue b/src/runtime/components/Editor.vue index 8a5c86c981..40b231f381 100644 --- a/src/runtime/components/Editor.vue +++ b/src/runtime/components/Editor.vue @@ -1,5 +1,5 @@