Skip to content

Inline Code ​

This is the Inline Code extension. It allows you to format text as inline code (monospace font within text).

Usage ​

Default usage of the inline code extension and its control button.

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

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

const editor = new Editor({
  content: 'Select text and click the code button to format it as inline code',
  extensions: [InlineCode, RequiredExtensions.configure({})],
  onUpdate({ editor }) {
    content.value = editor.getText()
    HTML.value = editor.getHTML()
  },
})
</script>

Commands ​

js
// Toggle inline code
editor?.chain().focus().toggleInlineCode().run()

Imports ​

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

Props ​

PropTypeDefaultDescription
editor *Editor-The editor instance
type'inline' | 'block''inline'The type of code formatting
tooltipLabelstringCodeThe tooltip label
tooltipPositionPlacement'top'The tooltip position
languageLanguage'en-US'The language
ariaLabelstringnullThe aria label

Slots ​

SlotDescriptionDefault
iconThe icon to displayCode02Icon

Notes ​

  • Inline code is rendered using the <code> HTML tag
  • It applies monospace font styling to the selected text