Skip to content

Editor

The editor is the main component that allows you to edit the content of the text editor.

Basic Usage

HLTextEditor is the main component that allows you to edit the content of the text editor.

As String

This is the initial HTML

As HTML

<p style="padding-left: 0px!important;">This is the initial HTML</p>

html
<HLTextEditor :editor="editor">
  <template #header>
    <RTEControlHistory :editor="editor" type="undo" />
    <RTEControlHistory :editor="editor" type="redo" />
  </template>
</HLTextEditor>
ts
import { ref } from 'vue'
import {
  AllExtensions,
  History,
  Editor,
  HLTextEditor,
  RTEControlHistory,
} from '@platform-ui/rte'

const content = ref()
const HTML = ref('<p>Refer to Notes on how to use it Better</p>')
const editor = new Editor({
  content: HTML.value,
  extensions: [History, AllExtensions.configure({})],
  onUpdate({ editor }) {
    content.value = editor.getText()
    HTML.value = editor.getHTML()
  },
})

const insertHTML = () => {
  const content = window.prompt('Paste the HTML', HTML.value)
  editor.commands.setContent(content)
  content.value = editor.getText()
  HTML.value = editor.getHTML()
}

Without Paste Formatting

When the formatOnPaste prop is set to false, the pasted content will not be formatted.

Vue
html
<HLTextEditor :editor="editor" :formatOnPaste="false">
  <template #header>
    <RTEControlHistory :editor="editor" type="undo" />
    <RTEControlHistory :editor="editor" type="redo" />
  </template>
</HLTextEditor>

Size

Custom size of the editor can be set using the size prop. Available sizes: 3xs, 2xs, xs, sm, md, lg.

Vue
html
<HLTextEditor :editor="editor" size="3xs">
  <template #header>
    <RTEControlHistory :editor="editor" type="undo" />
    <RTEControlHistory :editor="editor" type="redo" />
  </template>
</HLTextEditor>

Disabled

When the disabled prop is set to true, the editor will be disabled. User will not be able to edit the content.

Vue
html
<HLTextEditor :editor="editor" :disabled="true">
  <template #header>
    <RTEControlHistory :editor="editor" type="undo" />
    <RTEControlHistory :editor="editor" type="redo" />
  </template>
</HLTextEditor>

Error

When the error prop is set to true, the editor will show an error state.

Vue
html
<HLTextEditor :editor="editor" :error="true">
  <template #header>
    <RTEControlHistory :editor="editor" type="undo" />
    <RTEControlHistory :editor="editor" type="redo" />
  </template>
</HLTextEditor>

Non Resizable

When the resizable prop is set to false. User will not be able to resize the editor.

Vue
html
<HLTextEditor :editor="editor" :resizable="false">
  <template #header>
    <RTEControlHistory :editor="editor" type="undo" />
    <RTEControlHistory :editor="editor" type="redo" />
  </template>
</HLTextEditor>

Imports

ts
import { ref } from 'vue'
import {
  AllExtensions,
  History,
  Editor,
  HLTextEditor,
  RTEControlHistory,
} from '@platform-ui/rte'

Props

PropTypeDescriptionDefault
editorEditorThe editor instance.null
containerClassstringThe class to use for the container.''
languageLanguagesThe language to use in the editor.en-US
formatOnPastebooleanWhether to format the pasted content.false
countClassstringThe class to use for the count.''
size3xs | 2xs | xs | sm | md | lgThe size of the editor.'sm'
disabledbooleanWhether the editor is disabled.false
errorbooleanWhether the editor has an error.false
resizablebooleanWhether the editor is resizable.true
fallbackFontSizenumberThe fallback font size.depends on size prop

Slots

SlotDescriptionDefault
aboveHeaderThe slot for the above header.null
headerThe slot for the header.null
belowHeaderThe slot for the below header.null
aboveFooterThe slot for the above footer.null
footerThe slot for the footer.null
belowFooterThe slot for the below footer.null