5.0.0-alpha.f7181996 • Published 8 years ago

@slate-editor/underline-plugin v5.0.0-alpha.f7181996

Weekly downloads
237
License
MIT
Repository
github
Last release
8 years ago

SlateJS - Underline Plugin

The goal of this plugin is to offers an easy handling of SlateJS underline mark content editable. Providing a simple API and easy usage, basing on concept of plugin-centric by SlateJS framework.

Usage

SlateJS Underline Plugin

import React, { Component } from 'react'
import UnderlinePlugin from 'slate-underline-plugin'

const plugins = [
  UnderlinePlugin()
]

class SlateEditor extends Component {
  onChange(state) {
    this.setState({ state })
  }
  render() {
    return (
      <Editor
        plugins={plugins}
        state={this.state.state}
        onChange={this.onChange.bind(this)}
      />
    )
  }
}

SlateJS Underline Plugin Button

import React, { Component } from 'react'
import { UnderlineButton } from 'slate-underline-plugin'

class SlateEditor extends Component {
  onChange(state) {
    this.setState({ state })
  }
  render() {
    return (
      <div className="editor--toolbar">
        <UnderlineButton
          state={this.state.state}
          onChange={this.onChange.bind(this)}
        />
      </div>
    )
  }
}

Keyboard Shortcut

PlatformShortcut
Apple Logo⌘ + u
Windows Logo^ + u

API

TargetDescription
UnderlineMarkComponent that holds the html that will wrap the content with underline style.
UnderlineKeyboardShortcutKeyboard shortcut file that manipulates onKeyDown event inside SlateJS.
UnderlineUtilsGeneric file that holds the util common functions.
UnderlineButtonButton component that have behaviour to wrap content with underline style.

TODO

  • Make keyboard shortcut accepts customization