@slate-editor/color-plugin

5.1.0 • Public • Published
Nossas Cidades logo

@slate-editor/color-plugin

SlateJS color plugin.

npm package npm downloads

Installation

The @slate-editor/color-plugin is available as an npm package.

yarn add @slate-editor/color-plugin

Usage

Here is a quick example to get you started:

import React from 'react'
import { SlateEditor, SlateToolbar, SlateContent } from 'slate-editor'
import { ColorPlugin, ColorButton, ColorStateModel } from '@slate-editor/color-plugin'

const colorPluginOptions = new ColorStateModel().rgba({ r: 100, g: 100, b: 100, a: 1 }).gen()

const plugins = [
  ColorPlugin()
]

const SlateRichTextEditor = () => (
  <SlateEditor plugins={plugins}>
    <SlateToolbar>
      <ColorButton
        initialState={colorPluginOptions}
        pickerDefaultPosition={{ x: -520, y: 17 }}
      />
    </SlateToolbar>

    <SlateContent />
  </SlateEditor>
)

export default SlateRichTextEditor

Keyboard Shortcut

OS Action Shortcut
Apple Logo Toggle Color Picker ^ + alt + l
Windows Logo Toggle Color Picker ^ + alt + l

API

Name Description
ColorMark Component that holds the html that will wrap the content with color style.
ColorUtils Generic file that holds the util common functions.
ColorButton Button component that have behaviour to wrap content with color style.
ColorKeyboardShortcut Keyboard shortcut file that manipulates onKeyDown event inside SlateJS.
ColorStateModel Class that knows the state structure of the plugin

TODO

  • Make keyboard shortcut accepts customization;
  • Add keyboard shortcut to apply color to expanded selection;
  • Add keyboard shortcut to remove color from expanded selection;
  • Add button to apply color to expanded selection;
  • Add button to remove color from expanded selection;
  • Add handle to manipulates collapsed selection to remove color to anchor word;
  • Add behaviour to show which color have applied to collapsed selection;
  • Add behaviour to show which color have applied to expanded selection;

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.1.01,162latest
5.0.0-alpha.9e6f4feb0canary

Version History

VersionDownloads (Last 7 Days)Published
5.1.01,162
5.0.00
5.0.0-alpha.9e6f4feb0
5.0.0-alpha.f4219f700
5.0.0-alpha.f71819960

Package Sidebar

Install

npm i @slate-editor/color-plugin

Weekly Downloads

1,162

Version

5.1.0

License

MIT

Unpacked Size

20 kB

Total Files

14

Last publish

Collaborators

  • rolivegab
  • lpirola
  • igrsantos
  • alalbux
  • nossas