@artibox/slate-underline

<div align="center"> <img src="https://raw.githubusercontent.com/ianstormtaylor/slate/master/docs/images/banner.png" height="200" /> </div>

Usage no npm install needed!

<script type="module">
  import artiboxSlateUnderline from 'https://cdn.skypack.dev/@artibox/slate-underline';
</script>

README

@artibox/slate-underline

Slate underline.

npm package npm downloads

Installation

npm install @artibox/slate-underline --save

or

$ yarn add @artibox/slate-underline

Usage

Editor

import React from 'react';
import { Underline as UnderlineIcon } from '@artibox/icons';
import { createArtiboxEditor } from '@artibox/slate-editor';
import { Toolbar } from '@artibox/slate-toolbar';
import { createUnderline } from '@artibox/slate-underline';

const Underline = createUnderline();

const plugins = [
  Underline.forPlugin(),
  Toolbar.forPlugin({
    expandedTools: [{ icon: UnderlineIcon, hook: Underline.forToolHook() }]
  })
];

const Editor = createArtiboxEditor({
  plugins
});

export default Editor;

Jsx Serializer

import { createJsxSerializer } from '@artibox/slate-jsx-serializer';
import { createUnderlineJsxSerializerRule } from '@artibox/slate-underline';

const jsxSerializer = createJsxSerializer({
  marks: [
    createUnderlineJsxSerializerRule()
  ]
});

...

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

API

This package is based on based on @artibox/slate-toggle-mark.

Hotkey

OS Shortcut
Apple Logo +u
Windows Logo ctrl+u