5.0.0-alpha.19a19572 • Published 8 years ago

@slate-editor/strikethrough-plugin v5.0.0-alpha.19a19572

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

SlateJS - Strikethrough Plugin

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

Usage

SlateJS Strikethrough Plugin

import React, { Component } from 'react'
import StrikethroughPlugin from 'slate-strikethrough-plugin'

const plugins = [
  StrikethroughPlugin()
]

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

SlateJS Strikethrough Plugin Button

import React, { Component } from 'react'
import { StrikethroughButton } from 'slate-strikethrough-plugin'

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

Keyboard Shortcut

PlatformShortcut
Apple Logo⌘ + ^ + s
Windows Logo^ + alt + s

API

TargetDescription
StrikethroughMarkComponent that holds the html that will wrap the content with strikethrough style.
StrikethroughKeyboardShortcutKeyboard shortcut file that manipulates onKeyDown event inside SlateJS.
StrikethroughUtilsGeneric file that holds the util common functions.
StrikethroughButtonButton component that have behaviour to wrap content with strikethrough style.

TODO

  • Make keyboard shortcut accepts customization