Skip to content

Subscript

This is the Subscript extension. It allows you to format text as subscript (text that appears slightly below the normal line).

Usage

Default usage of the subscript extension and its control button.

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

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

const editor = new Editor({
  content:
    'Select text and click the subscript button. Great for chemical formulas like H<sub>2</sub>O',
  extensions: [Subscript, RequiredExtensions.configure({})],
  onUpdate({ editor }) {
    content.value = editor.getText()
    HTML.value = editor.getHTML()
  },
})
</script>

Imports

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

Commands

js
editor?.chain().focus().toggleSubscript().run()

Props

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

Slots

SlotDescriptionDefault
iconThe icon to displayMaterialSubscriptIcon