@artibox/slate-heading
v1.2.0
Published
<div align="center"> <img src="https://raw.githubusercontent.com/ianstormtaylor/slate/master/docs/images/banner.png" height="200" /> </div>
Downloads
28
Readme
Slate heading.
Installation
npm install @artibox/slate-heading --save
or
$ yarn add @artibox/slate-heading
Usage
Editor
import React from 'react';
import { Heading1, Heading2, Heading3 } from '@artibox/icons';
import { createArtiboxEditor } from '@artibox/slate-editor';
import { Toolbar } from '@artibox/slate-toolbar';
import { createHeading } from '@artibox/slate-heading';
const Heading = createHeading();
const plugins = [
Heading.forPlugin({ disabled: [4, 5, 6] }),
Toolbar.forPlugin({
collapsedTools: [
{ icon: Heading1, hook: Heading.forToolHook({ level: 1 }) },
{ icon: Heading2, hook: Heading.forToolHook({ level: 2 }) },
{ icon: Heading3, hook: Heading.forToolHook({ level: 3 }) }
]
})
];
const Editor = createArtiboxEditor({
plugins
});
export default Editor;
Jsx Serializer
import { createJsxSerializer } from '@artibox/slate-jsx-serializer';
import { createHeadingJsxSerializerRule } from '@artibox/slate-heading';
const jsxSerializer = createJsxSerializer({
blocks: [
createHeadingJsxSerializerRule()
]
});
...
return (
<div>
{jsxSerializer(valueJSON /* from slate */)}
</div>
);
API
- constants
- typings
- createHeading
- createHeadingJsxSerializerRule
- Heading.forPlugin
- Heading.forToolHook
- HeadingController
Utils
Components
Hotkey
| OS | Shortcut |
| ------------------------ | ------------------------------------------------- |
| | ctrl+opt+level
|
| | ctrl+alt+level
|