Skip to main content

SubExtension

Summary

Add a sub mark to the editor. This is used to mark inline text as a subscript snippet.

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 { SubExtension } from 'remirror/extensions';

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

Examples

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

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

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

const SubButton = () => {
const commands = useCommands();
return (
<button
onMouseDown={(event) => event.preventDefault()}
onClick={() => commands.toggleSubscript()}
>
Toggle Subscript
</button>
);
};

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

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

export default Basic;

API