Skip to content
This repository has been archived by the owner on May 2, 2019. It is now read-only.

It is a plugin for generating inline-style formats conveniently

Notifications You must be signed in to change notification settings

blackcater/slate-style-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slate-Style-Plugin

It is a plugin for generating inline-style formats conveniently.

中文文档

Usage

Appending single value inline-style formats

import StylePlugin from 'slate-style-plugin'

const { single } = StylePlugin
const plugins = [
    single({
        type: 'bold',
        mark: props => <strong {...props.attributes}>{props.children}</strong>,
        key: 'b',
    })
]

key: shortcut key for inline-style format, value b means that the shortcut is Ctrl + B. isShift: when the key value is b, the shortcut is Ctrl + Shift + B

Appending multiple value inline-style formats

In some cases, some inline-style formats are mutually exclusive and can not be applied at the same time. For example the size of font and the color of font.

import StylePlugin from 'slate-style-plugin'
        
const { group } = StylePlugin
const plugins = [
    group([
        {
            type: "red",
            mark: props => <span {...props.attributes} style={{  color: "red"}}>{props.children}</span>,
            key: 'r',
        },
        {
            type: "blue",
            mark: props => <span {...props.attributes} style={{  color: "blue"}}>{props.children}</span>,
            key: 'b',
            isShift: true,
        }
    ])
]

About

It is a plugin for generating inline-style formats conveniently

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published