@draft-js-enhance-plugins/clear-format
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

DraftJS Clear Format Plugin

This is a plugin for the @draft-js-plugins/editor.

Feature

Clear all inline styles, convert all block types to unstyled except AtomicBlock.

Usage

import { EditorState } from 'draft-js';
import Editor from '@draft-js-plugins/editor';
import createClearFormatPlugin from '@draft-js-enhance-plugins/clear-format';

const clearFormatPlugin = createClearFormatPlugin();

const plugins = [clearFormatPlugin];

function Example() {
  const [editorState, setEditorState] = useState(EditorState.createEmpty());

  const mapKeyToEditorCommand = (event: React.KeyboardEvent) => {
    if (event.key === '/' && KeyBindingUtil.hasCommandModifier(event)) {
      // cmd + '/'
      return 'clear-format';
    }

    return getDefaultKeyBinding(event);
  };

  return (
    <Editor
      editorState={editorState}
      onChange={setEditorState}
      keyBindingFn={mapKeyToEditorCommand}
      plugins={plugins}
    />
  );
}

Package Sidebar

Install

npm i @draft-js-enhance-plugins/clear-format

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

6.65 kB

Total Files

6

Last publish

Collaborators

  • varieget