5.1.0 • Published 6 years ago

@slate-editor/alignment-plugin v5.1.0

Weekly downloads
311
License
MIT
Repository
github
Last release
6 years ago

SlateJS alignment plugin.

npm package npm downloads

Installation

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

yarn add @slate-editor/alignment-plugin

Usage

Here is a quick example to get you started:

import React from 'react'
import { SlateEditor, SlateToolbar, SlateContent } from 'slate-editor'
import { AlignmentPlugin, AlignmentButtonBar } from '@slate-editor/alignment-plugin'

const plugins = [
  AlignmentPlugin()
]

const SlateRichTextEditor = () => (
  <SlateEditor plugins={plugins}>
    <SlateToolbar>
      <AlignmentButtonBar />
    </SlateToolbar>

    <SlateContent />
  </SlateEditor>
)

export default SlateRichTextEditor

Keyboard Shortcut

OSActionShortcut
Apple LogoAlign Left + shift + l
Apple LogoAlign Center + shift + c
Apple LogoAlign Right + shift + r
Windows LogoAlign Leftalt + shift + l
Windows LogoAlign Centeralt + shift + c
Windows LogoAlign Rightalt + shift + r

API

NameDescription
AlignmentNodeComponent that holds the html that will wrap the content with alignment style.
AlignmentUtilsGeneric file that holds the util common functions.
AlignmentButtonBarComponent that holds all action buttons to handle the alignment behaviour.
AlignmentLeftButtonComponent that holds button to handle the left alignment behaviour.
AlignmentCenterButtonComponent that holds button to handle the center alignment behaviour.
AlignmentRightButtonComponent that holds button to handle the right alignment behaviour.
AlignmentKeyboardShortcutKeyboard shortcut file that manipulates onKeyDown event inside SlateJS.

TODO

  • Make keyboard shortcut accepts customization