@artibox/slate-heading
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

@artibox/slate-heading

Slate heading.

npm package npm downloads

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

Utils

Components

Hotkey

OS Shortcut
Apple Logo ctrl+opt+level
Windows Logo ctrl+alt+level

Readme

Keywords

none

Package Sidebar

Install

npm i @artibox/slate-heading

Weekly Downloads

0

Version

1.2.0

License

MIT

Unpacked Size

53.8 kB

Total Files

82

Last publish

Collaborators

  • fantasywind