Skip to main content

HorizontalRuleExtension

Summary

Adds a horizontal line to the editor.

Usage

Installation

This extension is installed for you when you install the main remirror package.

You can use the imports in the following way:

import { HorizontalRuleExtension } from 'remirror/extensions';

The extension is provided by the @remirror/extension-horizontal-rule package.

Examples

Source code
import 'remirror/styles/all.css';

import { htmlToProsemirrorNode } from 'remirror';
import { HorizontalRuleExtension } from 'remirror/extensions';
import { Remirror, ThemeProvider, useCommands, useRemirror } from '@remirror/react';

const extensions = () => [new HorizontalRuleExtension()];

const HorizontalRuleButton = () => {
const commands = useCommands();
return <button onClick={() => commands.insertHorizontalRule()}>Insert</button>;
};

const Basic = (): JSX.Element => {
const { manager, state, onChange } = useRemirror({
extensions: extensions,
content: '<p>Text in <hr />with horizontal rule</p>',
stringHandler: htmlToProsemirrorNode,
});

return (
<ThemeProvider>
<Remirror
manager={manager}
autoFocus
onChange={onChange}
initialContent={state}
autoRender='end'
>
<HorizontalRuleButton />
</Remirror>
</ThemeProvider>
);
};

export default Basic;

API