umd/fieldstack.js
/**
   * Toggle the specified inline style for the selection. If the
   * user's selection is collapsed, apply or remove the style for the
   * internal state. If it is not collapsed, apply the change directly
   * to the document state.
   */
Toggle the specified inline style for the selection. If the
user's selection is collapsed, apply or remove the style for the
internal state. If it is not collapsed, apply the change directly
to the document state.
Toggle the specified inline style for the selection . If the user ' s selection is collapsed apply or remove the style for the internal state . If it is not collapsed apply the change directly to the document state .
function toggleInlineStyle(editorState, inlineStyle) {
    var selection = editorState.getSelection();
    var currentStyle = editorState.getCurrentInlineStyle();
    if (selection.isCollapsed()) {
      return EditorState_1.setInlineStyleOverride(editorState, currentStyle.has(inlineStyle) ? currentStyle.remove(inlineStyle) : currentStyle.add(inlineStyle));
    }
    var content = editorState.getCurrentContent();
    var newContent;
    if (currentStyle.has(inlineStyle)) {
      newContent = DraftModifier_1.removeInlineStyle(content, selection, inlineStyle);
    } else {
      newContent = DraftModifier_1.applyInlineStyle(content, selection, inlineStyle);
    }
    return EditorState_1.push(editorState, newContent, 'change-inline-style');
  }
function toggleInlineStyle ( editorState , inlineStyle ) { var selection = editorState . getSelection ( ) ; var currentStyle = editorState . getCurrentInlineStyle ( ) ; if ( selection . isCollapsed ( ) ) { return EditorState_1 . setInlineStyleOverride ( editorState , currentStyle . has ( inlineStyle ) ? currentStyle . remove ( inlineStyle ) : currentStyle . add ( inlineStyle ) ) ; } var content = editorState . getCurrentContent ( ) ; var newContent ; if ( currentStyle . has ( inlineStyle ) ) { newContent = DraftModifier_1 . removeInlineStyle ( content , selection , inlineStyle ) ; } else { newContent = DraftModifier_1 . applyInlineStyle ( content , selection , inlineStyle ) ; } return EditorState_1 . push ( editorState , newContent , 'change-inline-style' ) ; }
Toggle the specified inline style for the selection.
Toggle the specified inline style for the selection .
// If the selection is collapsed, toggle the specified style on or off and // set the result as the new inline style override. This will then be // used as the inline style for the next character to be inserted. // If characters are selected, immediately apply or remove the // inline style on the document state itself. // If the style is already present for the selection range, remove it. // Otherwise, apply it.