5.1.0 ā€¢ Published 6 years ago

@slate-editor/link-plugin v5.1.0

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

SlateJS link plugin.

npm package npm downloads

Installation

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

yarn add @slate-editor/link-plugin

Usage

Here is a quick example to get you started:

import React from 'react'
import { SlateEditor, SlateToolbar, SlateContent } from 'slate-editor'
import { LinkPlugin, LinkButton } from '@slate-editor/link-plugin'

const plugins = [
  LinkPlugin()
]

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

    <SlateContent />
  </SlateEditor>
)

export default SlateRichTextEditor

Keyboard Shortcut

OSShortcut
Apple LogoāŒ˜ + k
Windows Logo^ + k

API

NameDescription
LinkNodeComponent that holds the html that will wrap the content with link.
LinkKeyboardShortcutKeyboard shortcut file that manipulates onKeyDown event inside SlateJS.
LinkUtilsGeneric file that holds the util common functions.
LinkButtonButton component that have behaviour to wrap content with link.

TODO

  • Make keyboard shortcut accepts customization;
  • Add behaviour to catch onPaste command and identify if it is an url and ask if wants to link it;