Text Editor - Slots and Contexts

Reference for the editor parts and their Vue context accessors.

#Import

import { TextEditor, useTextEditorContext, useBlockMenuContext, useMentionMenuContext, useTableControlsContext } from '@primeui/vue-texteditor';

#Parts

The host mounts the visible UI; each part renders an empty surface and exposes its commands, state, and request data through a matching context accessor. A part turns on its feature when it is present in the tree.

PartSurface
TextEditor.RootEditor container; owns document, commands, and state
TextEditor.ToolbarStatic toolbar surface
TextEditor.ContentThe editable region
TextEditor.ContextToolbarSelection-anchored floating toolbar
TextEditor.ContextToolbarMoreOverflow panel of the context toolbar
TextEditor.BlockControlsBlock-mode hover bar with add and drag handles
TextEditor.BlockMenu / TextEditor.BlockSubmenuPer-block options menu and its nested submenu
TextEditor.SlashMenuSlash-command popover
TextEditor.MentionMenu@-mention popover
TextEditor.ImageUpload / TextEditor.DocumentUploadUpload overlay, with Dropzone and Progress slots
TextEditor.TableControlsFloating table add-row and add-column controls
TextEditor.TableColumnMenu / RowMenu / CellMenuColumn, row, and cell action menus and their submenus
TextEditor.NavigatorHeading-outline minimap, with Trigger and Menu parts

#Context Hooks

Call a context hook inside a widget rendered under the matching part. The hook returns the part's context object and throws if it runs outside that part, so a misplaced widget fails on mount rather than rendering silently broken.

HookRender insideMain fields
useTextEditorContext()TextEditor.Root (and its toolbars)commands, state, pluginCommands, headings, disabled, readonly, the value formats (getHTML, getJSON, getBlocks, getText, setValue)
useContextToolbarContext()TextEditor.ContextToolbarcommands, state, moreActive, toggleMore, setMoreTrigger, moreTrigger, dismiss
useBlockControlsContext()TextEditor.BlockControlsindex, blockType, addBlock, onDragStart, onDragEnd, onDragHandleClick
useBlockMenuContext()TextEditor.BlockMenublockIndex, blockType, commands, state, submenu, dismiss
useSlashMenuContext()TextEditor.SlashMenucommands, state, filterText, position, dismiss
useMentionMenuContext<T>()TextEditor.MentionMenuitems, commands, filterText, position, dismiss
useUploadContext()TextEditor.ImageUpload or TextEditor.DocumentUploadkind, uploads, selectFiles, onDrop, dismiss
useTableControlsContext()TextEditor.TableControlsposition, commands (addRow, addColumn)
useTableColumnMenuContext()TextEditor.TableColumnMenucolIndex, colCount, commands, submenu, dismiss
useTableRowMenuContext()TextEditor.TableRowMenurowIndex, rowCount, commands, submenu, dismiss
useTableCellMenuContext()TextEditor.TableCellMenuisMultiCellSelected, isCellMerged, commands, submenu, dismiss
useNavigatorContext()TextEditor.Navigatorheadings, activeIndex, menuOpen, openMenu, closeMenu, scrollTo

The useMentionMenuContext<T>() hook is generic over the item type. Pass the candidate shape so items and commands.select(item) come back typed.

#Reading Context Values

A context object groups its reactive fields as Vue Refs alongside plain methods. Read a reactive field through .value; call a method directly.

<!-- BlockOptions.vue -->
<script setup lang="ts">
import { useBlockMenuContext } from '@primeui/vue-texteditor';

const { blockType, commands, dismiss } = useBlockMenuContext();
</script>

<template>
    <button
        @click="
            commands.duplicate();
            dismiss();
        "
    >
        Duplicate {{ blockType }}
    </button>
</template>

In script logic, the same fields are read through .value:

import { computed } from 'vue';
import { useBlockMenuContext } from '@primeui/vue-texteditor';

const { blockType } = useBlockMenuContext();
const isHeading = computed(() => blockType.value.startsWith('heading'));

#Slot Props or Context

Both patterns reach the same data. Use slot props when the widget is local to the page:

<TextEditor.BlockMenu v-slot="{ commands, dismiss }">
    <button @click="commands.duplicate(); dismiss()">Duplicate</button>
</TextEditor.BlockMenu>

Use a context hook when the widget is a reusable component, so the authored tree stays short:

<TextEditor.BlockMenu>
    <BlockOptions />
</TextEditor.BlockMenu>