Skip to content

Context and Commands

useProEditor returns ProEditorContext. Adapter toolbars consume it internally, and custom UI can use it directly.

ts
interface ProEditorContext {
  editor: Ref<Editor | undefined>
  loaded: Ref<boolean>
  isActive: (name: string | Record<string, unknown>, attrs?: Record<string, unknown>) => boolean
  commands: ProEditorCommands
  getHTML: () => string
  getJSON: () => object
  getMarkdown: () => string
  importMarkdown: (md: string) => void
  wordCount: Ref<{ characters: number; words: number }>
  setEditable: (editable: boolean) => void
  notify: NotifyFn
}

Common Commands

CategoryCommands
Historyundo(), redo()
Inline formattingbold(), italic(), strike(), underline(), code(), superscript(), subscript()
Block structuretoggleHeading(level), blockquote(), codeBlock(language), hr(variant?)
MermaidinsertMermaidBlock(source?, viewMode?), setMermaidViewMode('code' | 'diagram' | 'split')
ListsbulletList(), orderedList(), taskList()
TypographysetFontFamily(value), setFontSize(value), setLineHeight(value), increaseIndent(), decreaseIndent()
ColorsetColor(color), toggleHighlight(color)
Alignmentalign('left' | 'center' | 'right' | 'justify')
LinksetLink(href, opts), insertLinkText(href, text, opts)
ImagesetImage(src, alt), uploadAndInsertImage(file), setImageAlign(align), setImageSize(preset), setImageCaption(caption), removeImage()
Video / audio / fileinsertVideo(asset), uploadAndInsertVideo(file), insertAudio(asset), uploadAndInsertAudio(file), insertFile(asset), uploadAndInsertFile(file)
TableinsertTable(rows, cols), selectRow(rowIndex?), selectColumn(columnIndex?), selectTable(), selectCellRange(anchor, head), addRowBefore(), addRowAfter(), moveRowUp(), moveRowDown(), deleteRow(), addColumnBefore(), addColumnAfter(), moveColumnLeft(), moveColumnRight(), deleteColumn(), mergeCells(), splitCell(), toggleHeaderRow(), toggleHeaderColumn(), deleteTable()
CleanupclearNodes(), clearTypography(), clearFormat()

Custom Toolbar Example

vue
<template>
  <button :class="{ active: ctx.isActive('bold') }" @click="ctx.commands.bold()">
    Bold
  </button>
  <button @click="ctx.commands.align('center')">
    Center
  </button>
</template>

insertVideo and insertAudio read editorBehaviorOptions.media.video.render.displayMode / media.audio.render.displayMode. When configured as player, they insert a native player. When configured as file, they insert a file card.

hr(variant?) accepts solid, thick, dashed, or dotted. Omitting the variant inserts a plain solid divider.

Table selection commands use zero-based coordinates. For example, selectCellRange({ row: 0, col: 0 }, { row: 1, col: 1 }) selects the top-left 2 × 2 range. The built-in adapters use these commands for Shift range selection, Ctrl/⌘ + A table selection, and Feishu-style row/column grips.

A community package built on Tiptap v3 + Vue 3.