Socket
Socket
Sign inDemoInstall

@slate-editor/color-plugin

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slate-editor/color-plugin

SlateJS color mark plugin.


Version published
Weekly downloads
1.1K
increased by2.3%
Maintainers
2
Weekly downloads
 
Created
Source
Nossas logo
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

OSActionShortcut
Apple LogoToggle Color Picker^ + alt + l
Windows LogoToggle Color Picker^ + alt + l

API

NameDescription
ColorMarkComponent that holds the html that will wrap the content with color style.
ColorUtilsGeneric file that holds the util common functions.
ColorButtonButton component that have behaviour to wrap content with color style.
ColorKeyboardShortcutKeyboard shortcut file that manipulates onKeyDown event inside SlateJS.
ColorStateModelClass 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;

Keywords

FAQs

Package last updated on 25 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc