npm.io
0.1.7 • Published 9 years ago

draft-js-plugin-editor-toolbar-picker

Licence
MIT
Version
0.1.7
Deps
2
Vulns
0
Weekly
0
Stars
1

draft-js-plugin-editor-toolbar-picker

Picker component for draft-js-static-toolbar-plugin and draft-js-inline-toolbar-plugin

Usage

Install via npm:

$ npm i draft-js-plugin-editor-toolbar-picker

And use in your project:

import {
	BlockquoteButton,
	BoldButton,
	CodeBlockButton,
	CodeButton,
	HeadlineOneButton,
	HeadlineThreeButton,
	HeadlineTwoButton,
	ItalicButton,
	OrderedListButton,
	UnderlineButton,
	UnorderedListButton
} from 'draft-js-buttons'

import createPicker, { createTriggerButton } from 'draft-js-plugin-editor-toolbar-picker'
const Picker = createPicker({
	triggerItem: createTriggerButton({ child: 'H' }),
	items: [
		HeadlineOneButton,
		HeadlineTwoButton,
		HeadlineThreeButton
	]
	/* 
	other options:
	autoClose: boolean -> Auto close if click another location, default `true`
	closeButton: ReactNode -> Close button when `autoClose` is `false`
	*/
})

const toolbarPlugin = createToolbarPlugin({
	structure: [
		BoldButton,
		ItalicButton,
		UnderlineButton,
		CodeButton,
		Separator,
		Picker,   // Use `Picker` as an item button
		UnorderedListButton,
		OrderedListButton,
		BlockquoteButton,
		CodeBlockButton
	]
})

License

MIT

Keywords