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.

Editable

On

Basic Usage

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

Extension Guides

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.
useTabbooleanNofalseWhether to let the Tab key insert a tab character. When enabled, it does not insert inside bullet or ordered lists.
theme'light' | 'dark'NolightEditor theme.
extensionsarrayNo[]Extra Tiptap extensions.
showSavebooleanNotrueWhether to show the save button.
showDragHandlerbooleanNofalseWhether to show the block drag handle.
ignoreDragNodeTypearrayNo[]List of node types where the drag handle should be hidden.
dragHandlerNestedbooleanNofalseWhether the drag handle should work inside nested block nodes.
diffInlineBlockTypesstring[]No[]Additional block node types that should still be diffed like inline content. Use this for custom nodes that look block-level but should compare inner inline fragments.
diffContainerBlockTypesstring[]No[]Additional block node types that should be diffed as container nodes. Useful for wrappers, layout containers, and custom nested structures.
diffInsertColorstringNo""Primary highlight color for inserted changes.
diffDeleteColorstringNo""Primary highlight color for deleted changes.
diffInsertColorSecstringNo""Secondary accent color for inserted changes, usually used for borders or supporting decoration.
diffDeleteColorSecstringNo""Secondary accent color for deleted changes.
diffInsertHoverColorstringNo""Hover highlight color for inserted changes.
diffDeleteHoverColorstringNo""Hover highlight color for deleted changes.
diffInsertHoverColorSecstringNo""Secondary hover accent color for inserted changes.
diffDeleteHoverColorSecstringNo""Secondary hover accent color for deleted changes.

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
<script setup>
import { ref } from "vue";

const editor = ref(null);
const mdFileInput = ref(null);

const openMarkdownFile = () => {
    mdFileInput.value?.click();
};

const handleMarkdownImport = async (event) => {
    const file = event.target.files?.[0];

    if (!file) return;

    const markdown = await file.text();
    editor.value?.insertMarkdown(markdown);
    event.target.value = "";
};

const exportMarkdown = async () => {
    const markdown = editor.value?.saveMarkdown?.() ?? "";

    console.log(markdown);
    await navigator.clipboard.writeText(markdown);
};
</script>

<template>
    <input
        ref="mdFileInput"
        type="file"
        accept=".md,.markdown,.txt,text/markdown,text/plain"
        style="display: none;"
        @change="handleMarkdownImport"
    />
    <power-editor ref="editor" :showDragHandler="true">
        <template #custom-buttons="{ defaultClass }">
            <fv-button
                :class="[defaultClass, 'round-btn']"
                border-color="transparent"
                title="Import Markdown"
                @click="openMarkdownFile"
            >
                <i class="ms-Icon ms-Icon--Upload"></i>
            </fv-button>
            <fv-button
                :class="[defaultClass, 'round-btn']"
                border-color="transparent"
                title="Export Markdown"
                @click="exportMarkdown"
            >
                <i class="ms-Icon ms-Icon--Download"></i>
            </fv-button>
        </template>
    </power-editor>
</template>

<style scoped>
.round-btn {
    border-radius: 999px;
}
</style>
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.
editor.compareDiff(sourceDoc, targetDoc)Runs the built-in diff entry and returns the same result shape as computeDiff().
editor.editor()Returns the current Tiptap editor instance so you can call low-level APIs such as getJSON() or editor commands directly.
editor.focus()Moves focus into the editor.

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