1.2.0 • Published 4 years ago

@artibox/slate-separation-line v1.2.0

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

Slate separation line.

npm package npm downloads

Installation

npm install @artibox/slate-separation-line --save

or

$ yarn add @artibox/slate-separation-line

Usage

Editor

import React from 'react';
import { SeparationLine as SeparationLineIcon } from '@artibox/icons';
import { createArtiboxEditor } from '@artibox/slate-editor';
import { Toolbar } from '@artibox/slate-toolbar';
import { createSeparationLine } from '@artibox/slate-separation-line';

const SeparationLine = createSeparationLine();

const plugins = [
  SeparationLine.forPlugin(),
  Toolbar.forPlugin({
    collapsedTools: [{ icon: SeparationLine, hook: SeparationLine.forToolHook() }]
  })
];

const Editor = createArtiboxEditor({
  plugins
});

export default Editor;

Jsx Serializer

import { createJsxSerializer } from '@artibox/slate-jsx-serializer';
import { createSeparationLineJsxSerializerRule } from '@artibox/slate-separation-line';

const jsxSerializer = createJsxSerializer({
  blocks: [
    createSeparationLineJsxSerializerRule()
  ]
});

...

return (
  <div>
    {jsxSerializer(valueJSON /* from slate */)}
  </div>
);

API