Skip to main content

extension-text-color

package @remirror/extension-text-color

class TextColorExtension

Wraps text with a styled span using the color css property. The name of the wrapper tag should be configurable.

Signature:

export declare class TextColorExtension extends MarkExtension<TextColorOptions> 

Extends: MarkExtension<TextColorOptions>

(Some inherited members may not be shown because they are not represented in the documentation.)

property name

Signature:

get name(): "textColor";

method createMarkSpec

Signature:

createMarkSpec(extra: ApplySchemaAttributes, override: MarkSpecOverride): MarkExtensionSpec;

Parameters:

ParameterTypeDescription
extraApplySchemaAttributes
overrideMarkSpecOverride

Returns:

MarkExtensionSpec

method createTags

Signature:

createTags(): ("formattingMark" | "fontStyle")[];

Returns:

("formattingMark" | "fontStyle")[]

method getHexColor

Get the color from the provided string. The string can be a computed property as well.

Signature:

getHexColor(color: string): Helper<string>;

Parameters:

ParameterTypeDescription
colorstring

Returns:

Helper<string>

method removeTextColor

Remove the color mark from the selection.

Signature:

removeTextColor(options?: SetTextColorOptions): CommandFunction;

Parameters:

ParameterTypeDescription
optionsSetTextColorOptions(Optional)

Returns:

CommandFunction

method setTextColor

Set the text color value for the selected text.

To remove the color you can set the value to null.

Signature:

setTextColor(color: string, options?: SetTextColorOptions): CommandFunction;

Parameters:

ParameterTypeDescription
colorstring
optionsSetTextColorOptions(Optional)

Returns:

CommandFunction

function palette()

The default color palette which uses css properties to update the colors.

Signature:

export declare function palette(t: I18nFormatter): ColorPalette;

Parameters:

ParameterTypeDescription
tI18nFormatter

Returns:

ColorPalette

variable CSS_VAR_REGEX

Signature:

CSS_VAR_REGEX: RegExp

variable setTextColorOptions

Signature:

setTextColorOptions: Remirror.CommandDecoratorOptions

variable TEXT_COLOR_ATTRIBUTE

Signature:

TEXT_COLOR_ATTRIBUTE = "data-text-color-mark"

interface ColorPalette

Signature:

export interface ColorPalette 

property black

Signature:

black: ColorWithLabel;

property hues

Signature:

hues: HuePaletteMap;

property transparent

Signature:

transparent: ColorWithLabel;

property white

Signature:

white: ColorWithLabel;

interface ColorWithLabel

Signature:

export interface ColorWithLabel 

property color

Signature:

color: string;

property label

Signature:

label: string;

interface HuePalette

Signature:

export interface HuePalette 

property hues

Signature:

hues: ColorWithLabelTuple;

property label

Signature:

label: string;

interface SetTextColorOptions

Signature:

export interface SetTextColorOptions 

property selection

Signature:

selection?: PrimitiveSelection;

interface TextColorAttributes

Signature:

export interface TextColorAttributes 

property color

The color of the text. This can be a color value like red #fff rgb(0,0,0) or a computed property like --rmr-color-primary.

Signature:

color?: string;

interface TextColorOptions

Signature:

export interface TextColorOptions 

property defaultColor

The default color value.

Signature:

defaultColor?: Static<string>;

property palette

The color palette which is a function that returns a list of colors and labels for help with ui. It is completely optional and you are free to use use whatever colors you choose.

Signature:

palette?: Palette;

type ColorWithLabelTuple

Signature:

export type ColorWithLabelTuple = TupleOf<ColorWithLabel, 10>;

References: TupleOf, ColorWithLabel

type HuePaletteMap

Signature:

export type HuePaletteMap = Record<keyof Remirror.ThemeHue, HuePalette> & Record<string, HuePalette>;

References: HuePalette

type Palette

Create a palette the t method provided for internalization.

Signature:

export type Palette = (t: I18nFormatter) => ColorPalette;

References: I18nFormatter, ColorPalette