Text Editor - Superscript

Toggle superscript formatting on the current selection with the superscript command and pressed state.

#Usage

import { TextEditor } from '@primeui/vue-texteditor';
<TextEditor.Root v-model="value">
    <TextEditor.Toolbar>
        <SuperscriptButton />
    </TextEditor.Toolbar>
    <TextEditor.Content />
</TextEditor.Root>

Superscript raises text above the baseline for exponents or ordinals. A toolbar button toggles the mark on the selection with commands.superscript() and reflects pressed state with state.superscript, both from useTextEditorContext().

#Command

commands.superscript() toggles the mark on the selected text. Superscript and subscript are mutually exclusive, so applying superscript over a subscript run clears the subscript.

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

const { commands, state } = useTextEditorContext();
</script>

<template>
    <button @click="commands.superscript()" :aria-pressed="state.superscript">x²</button>
</template>

#Example

Loading Demo...

#API

commands.superscript() and state.superscript come from useTextEditorContext(). See API for the full reference.