How to use the draft-js.RichUtils.toggleBlockType function in draft-js

To help you get started, we’ve selected a few draft-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github artsy / positron / src / client / apps / edit / components / content / sections / text / index.jsx View on Github external
const { hasFeatures, onChangeSectionAction, section } = this.props
    const isBlockquote = block === 'blockquote'
    const hasBlockquote = clone(section.body).includes('<blockquote>')

    if (!hasFeatures &amp;&amp; isBlockquote) {
      return 'handled'
    }

    if (hasFeatures &amp;&amp; isBlockquote) {
      if (hasBlockquote) {
        onChangeSectionAction('layout', null)
      } else {
        return this.toggleBlockQuote()
      }
    }
    this.onChange(RichUtils.toggleBlockType(editorState, block))
    this.setState({ showMenu: false })
    return 'handled'
  }
</blockquote>
github thibaudcolas / draftjs-filters / src / demo / components / FilterableEditor.js View on Github external
toggleBlock(type: string, e: Event) {
    const { editorState } = this.state
    this.onChange(RichUtils.toggleBlockType(editorState, type))

    e.preventDefault()
  }
github niuware / mui-rte / src / MUIRichTextEditor.tsx View on Github external
const toggleBlockType = (blockType: string) => {
        setEditorState(
            RichUtils.toggleBlockType(
                editorState,
                blockType
            )
        )
    }
github lokiuz / redraft / example / src / RichEditor.js View on Github external
_toggleBlockType(blockType) {
    this.onChange(
      RichUtils.toggleBlockType(
        this.props.editorState,
        blockType
      )
    );
  }
github draft-js-plugins / next / packages / block-type-toggle / dist / index.es.js View on Github external
var toggleBlockType = function toggleBlockType() {
        return setEditorState(RichUtils.toggleBlockType(editorState, blockType));
      };
github margox / braft-editor / src / controls / BlockTypes / index.jsx View on Github external
applyBlockTypeControl (type) {
    this.props.onChange(RichUtils.toggleBlockType(this.props.editorState, type))
  }
github niuware / mui-rte / src / MUIRichTextEditor.tsx View on Github external
const handleClearFormat = () => {
        const selectionInfo = getSelectionInfo(editorState)
        let newEditorState = editorState
        selectionInfo.inlineStyle.forEach((effect) => {
            if (effect) {
                newEditorState = RichUtils.toggleInlineStyle(newEditorState, effect)
            }
        })
        newEditorState = RichUtils.toggleBlockType(newEditorState, selectionInfo.blockType)
        setEditorState(newEditorState)
    }
github gregchamberlain / react-dnd-layout / src / components / rich_text.jsx View on Github external
toggleBlockType = blockType => {
    this.onChange(
      RichUtils.toggleBlockType(
        this.state.editorState,
        blockType
      )
    );
  }
github alexolefirenko / react-admin-ui / src / components / FormFields / RichEditor / index.jsx View on Github external
_toggleBlockType(blockType) {
        this.onChange(
            RichUtils.toggleBlockType(
                this.state.editorState,
                blockType
            )
        );
    }
github tubackkhoa / tkframework / client / ui / shared / components / Text / Editor / index.jsx View on Github external
_handleToggleBlockType = (blockType) => {
    this._handleChange(
      RichUtils.toggleBlockType(
        this.state.editorState,
        blockType
      )
    )
  }