Skip to content

Superscript

This is the Superscript extension. It allows you to format text as superscript (text that appears slightly above the normal line).

Usage

Default usage of the superscript extension and its control button.

Superscript
vue
<template>
  <HLTextEditor :editor="editor">
    <template #header>
      <RTEControlSuperscript :editor="editor" />
    </template>
    <template #footer>
      <div>Footer</div>
    </template>
  </HLTextEditor>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import {
  RequiredExtensions,
  Editor,
  HLTextEditor,
  RTEControlSuperscript,
  Superscript,
} from '@platform-ui/rte'

const content = ref()
const HTML = ref()

const editor = new Editor({
  content:
    'Select text and click the superscript button. Great for exponents like x<sup>2</sup> or ordinal numbers like 1<sup>st</sup>',
  extensions: [Superscript, RequiredExtensions.configure({})],
  onUpdate({ editor }) {
    content.value = editor.getText()
    HTML.value = editor.getHTML()
  },
})
</script>

Imports

ts
import {
  RequiredExtensions,
  Editor,
  HLTextEditor,
  RTEControlSuperscript,
  Superscript,
} from '@platform-ui/rte'

Commands

js
// Toggle superscript
editor?.chain().focus().toggleSuperscript().run()

// Set superscript
editor?.commands.setSuperscript()

// Unset superscript
editor?.commands.unsetSuperscript()

Props

PropTypeDefaultDescription
editor *Editor-The editor instance
tooltipLabelstring-The tooltip label
tooltipPositionPlacement'top'The tooltip position
languageLanguage'en-US'The language
ariaLabelstringSuperscriptThe aria label

Slots

SlotDescriptionDefault
iconThe icon to displayMaterialSuperscriptIcon