Files
tiptap/docs/api/extensions/color.md
2021-10-14 00:13:50 +02:00

1.4 KiB

description
description
Add text color support to your editor (comes with unlimited colors).

Color

Version Downloads

This extension enables you to set the font color in the editor. It uses the TextStyle mark, which renders a <span> tag (and only that). The font color is applied as inline style then, for example <span style="color: #958DF1">.

Installation

# with npm
npm install @tiptap/extension-text-style @tiptap/extension-color

# with Yarn
yarn add @tiptap/extension-text-style @tiptap/extension-color

This extension requires the TextStyle mark.

Settings

types

A list of marks to which the color attribute should be applied to.

Default: ['textStyle']

Color.configure({
  types: ['textStyle'],
})

Commands

setColor()

Applies the given font color as inline style.

editor.commands.setColor('#ff0000')

unsetColor()

Removes any font color.

editor.commands.unsetColor()

Source code

packages/extension-color/

Usage