Skip to content

PowerEditor

PowerEditor is the core rich text editor component in PowerEditor3. It is built with Vue 3, Tiptap and VFluent3, and provides a ready-to-use toolbar, theme switching, image preview, Markdown conversion, read-only display and slot-based customization.

Basic Usage

vue
<template>
    <power-editor
        v-model="content"
        theme="light"
        placeholder="Write something..."
        @change="handleChange"
        @save-html="handleSaveHtml"
        @save-json="handleSaveJson"
    />
</template>

Props

PropTypeRequiredDefaultDescription
modelValuestringNo<p>I'm running PowerEditor with Vue.js.</p>Editor content. Plain text and HTML are supported.
editablebooleanNotrueWhether the editor is editable. Set it to false for read-only mode.
placeholderstringNoWrite something...Placeholder text.
disabledPlaceholderbooleanNofalseWhether to disable the placeholder.
contentMaxWidthnumberNo900Maximum content width in pixels.
editorBackgroundstringNo-Inner editor background color.
editorOutSideBackgroundstringNo-Outer editor background color.
mobileDisplayWidthnumberNo768Width threshold for mobile layout.
showToolBarbooleanNotrueWhether to show the toolbar.
toolbarHeightnumberNo70Toolbar height.
toolbarBackgroundstringNo-Toolbar background color.
toolbarBorderRadiusnumberNo8Toolbar border radius.
editablePaddingTopnumberNo-Top padding in editable mode. Internal default is used when omitted.
readOnlyPaddingTopnumberNo5Top padding in read-only mode.
editablePaddingBottomnumberNo315Bottom padding in editable mode.
readOnlyPaddingBottomnumberNo55Bottom padding in read-only mode.
imgInterceptorfunctionNo-Image interceptor for upload, replacement and status control. See ImgInterceptor.
mentionItemAttrobjectNo-MentionItem configuration. See MentionItem.
starterKitobjectNo() => ({})Custom configuration for Tiptap StarterKit.
showControlOnReadonlybooleanNotrueWhether to show controls in read-only mode.
mdDecNodeFuncsPluginsobjectNo-Custom Markdown decoder functions. See Markdown Decoder Plugins.
mdFlagsobjectNo-Custom Markdown decoder traversal flags.
foregroundstringNo#958DF1Editor accent color.
linkColorstringNo#958DF1Link color.
selectionBackgroundstringNorgba(144, 145, 234, 0.3)Selection background color.
selectionForegroundstringNo-Selection foreground color.
tableDragColorstringNorgba(144, 145, 234, 0.6)Table drag handle color.
codeColorstringNo-Inline code or code block color.
imgPreviewbooleanNotrueWhether to enable image preview.
imgLazyLoadbooleanNofalseWhether to lazy-load images.
theme'light' | 'dark'NolightEditor theme.
extensionsarrayNo[]Extra Tiptap extensions.
showSavebooleanNotrueWhether to show the save button.

Events

EventArgsDescription
on-mountededitorEmitted after the editor is initialized. Returns the current Tiptap editor instance.
container-scrolleventEmitted when the editor container scrolls.
changepayloadEmitted when editor content changes.
content-changepayloadEmitted when external content is synchronized into the editor.
save-jsonstringEmitted with JSON content after saving.
save-htmlstringEmitted with HTML content after saving.

Methods

Use a template ref to call exposed editor methods.

vue
<power-editor ref="editor" />
MethodDescription
editor.save()Saves the current content and emits save-json and save-html.
editor.saveMarkdown()Converts the current editor content to Markdown.
editor.computeMarkdown(markdown)Parses Markdown into editor content.
editor.insertMarkdown(markdown)Inserts Markdown at the current position.

Slots

custom-buttons

Adds custom buttons to the toolbar. You can also use custom-buttons-front or custom-buttons-[index] to control the position. index starts from 0 and goes up to 4. When no position is provided, the button is inserted at the right end of the toolbar.

Slot props:

PropDescription
editorCurrent Tiptap editor instance.
defaultClassDefault toolbar button class.
vue
<power-editor>
    <template #custom-buttons="{ defaultClass }">
        <fv-button :class="[defaultClass]">Custom</fv-button>
    </template>
</power-editor>

front-content

Adds custom content before the document body.

vue
<power-editor>
    <template #front-content>
        <div class="front-content-block">Before editor content</div>
    </template>
</power-editor>

MIT Licensed