Skip to content

Color ​

This is the Color extension. It allows you to make text color.

Text Color ​

Default usage of the text color extension and its control button.

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

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

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

Text Highlight ​

Vue
html
<HLTextEditor :editor="editor">
  <template #header>
    <RTEControlColorPicker :editor="editor" />
  </template>
  <template #footer>
    <div>Footer</div>
  </template>
</HLTextEditor>

Disabled ​

Vue
html
<HLTextEditor :editor="editor3">
  <template #header>
    <RTEControlColorPicker :editor="editor3" disabled />
  </template>
</HLTextEditor>

Default Color ​

Vue
html
<template>
  <HLTextEditor :editor="editor">
    <template #header>
      <RTEControlColorPicker :editor="editor" defaultColor="#18A058" />
    </template>
  </HLTextEditor>
</template>
<script setup lang="ts">
  import { ref } from 'vue'
  import {
    RequiredExtensions,
    Color,
    Editor,
    HLTextEditor,
    RTEControlColorPicker,
  } from '@platform-ui/rte'

  const content = ref()
  const HTML = ref()
  const editor = new Editor({
    content: 'Refer to Notes on how to use it Better',
    extensions: [
      Color,
      RequiredExtensions.configure({
        paragraph: {
          HTMLAttributes: {
            style: 'color: #18A058',
          },
        },
        heading: {
          HTMLAttributes: {
            style: 'color: #18A058',
          },
        },
      }),
    ],
    onUpdate({ editor }) {
      content.value = editor.getText()
      HTML.value = editor.getHTML()
    },
  })
</script>

Picker Position ​

Vue
html
<HLTextEditor :editor="editor5">
  <template #header>
    <RTEControlColorPicker :editor="editor5" pickerPosition="right" />
  </template>
</HLTextEditor>

Commands ​

js
editor?.chain().focus().setColor(colorValue).run()
js
editor?.chain().focus().setHighlight({ color: colorValue }).run()

Imports ​

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

Props ​

PropTypeDefaultDescription
editor *Editor-The editor instance
tooltipLabelstringText ColorThe tooltip label
tooltipPositionPlacement'top'The tooltip position
languageLanguage'en-US'The language
ariaLabelstringText ColorThe aria label
pickerPositionstring'bottom'The picker position
disabledbooleanfalseThe disabled state
colorFortext | highlight'text'The color for text or highlight
defaultColorstring'rgba(0, 0, 0, 1)'The default color
typehex | rgba'rgba'The type of color
tostring | HTMLElementundefinedThe target element

Slots ​

SlotDescriptionDefault
iconThe icon to displayColorPickerIcon