How to use the slate-hotkeys.isUndo function in slate-hotkeys

To help you get started, we’ve selected a few slate-hotkeys 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 ianstormtaylor / slate / packages / slate-react / src / components / content.js View on Github external
onEvent(handler, event) {
    debug('onEvent', handler)

    const nativeEvent = event.nativeEvent || event
    const isUndoRedo =
      event.type === 'keydown' &&
      (Hotkeys.isUndo(nativeEvent) || Hotkeys.isRedo(nativeEvent))

    // Ignore `onBlur`, `onFocus` and `onSelect` events generated
    // programmatically while updating selection.
    if (
      (this.tmp.isUpdatingSelection || isUndoRedo) &&
      (handler === 'onSelect' || handler === 'onBlur' || handler === 'onFocus')
    ) {
      return
    }

    // COMPAT: There are situations where a select event will fire with a new
    // native selection that resolves to the same internal position. In those
    // cases we don't need to trigger any changes, since our internal model is
    // already up to date, but we do want to update the native selection again
    // to make sure it is in sync. (2017/10/16)
    //
github ianstormtaylor / slate / packages / slate-react / src / plugins / dom / before.js View on Github external
// elements which will editor the DOM and cause our value to be out of sync,
    // so they need to always be prevented.
    if (
      !IS_IOS &&
      (Hotkeys.isBold(event) ||
        Hotkeys.isDeleteBackward(event) ||
        Hotkeys.isDeleteForward(event) ||
        Hotkeys.isDeleteLineBackward(event) ||
        Hotkeys.isDeleteLineForward(event) ||
        Hotkeys.isDeleteWordBackward(event) ||
        Hotkeys.isDeleteWordForward(event) ||
        Hotkeys.isItalic(event) ||
        Hotkeys.isRedo(event) ||
        Hotkeys.isSplitBlock(event) ||
        Hotkeys.isTransposeCharacter(event) ||
        Hotkeys.isUndo(event))
    ) {
      event.preventDefault()
    }

    isUserActionPerformed = true
    debug('onKeyDown', { event })
    next()
  }
github ianstormtaylor / slate / packages / slate-react / src / plugins / dom / after.js View on Github external
return editor.deleteLineForward()
    }

    if (Hotkeys.isDeleteWordBackward(event)) {
      return editor.deleteWordBackward()
    }

    if (Hotkeys.isDeleteWordForward(event)) {
      return editor.deleteWordForward()
    }

    if (Hotkeys.isRedo(event)) {
      return editor.redo()
    }

    if (Hotkeys.isUndo(event)) {
      return editor.undo()
    }

    // COMPAT: Certain browsers don't handle the selection updates properly. In
    // Chrome, the selection isn't properly extended. And in Firefox, the
    // selection isn't properly collapsed. (2017/10/17)
    if (Hotkeys.isMoveLineBackward(event)) {
      event.preventDefault()
      return editor.moveToStartOfBlock()
    }

    if (Hotkeys.isMoveLineForward(event)) {
      event.preventDefault()
      return editor.moveToEndOfBlock()
    }
github sanity-io / sanity / packages / @sanity / form-builder / src / inputs / BlockEditor / plugins / UndoRedoPlugin.ts View on Github external
onKeyDown(event: React.KeyboardEvent, editor: SlateEditor, next: (arg0: void) => void) {
      if (!(Hotkeys.isUndo(event) || Hotkeys.isRedo(event))) {
        return next()
      }
      if (Hotkeys.isUndo(event)) {
        return handleUndoItem(editor, stack.undo.pop())
      }
      if (Hotkeys.isRedo(event)) {
        return handleRedoItem(editor, stack.redo.pop())
      }
      return editor
    }
  }
github sanity-io / sanity / packages / @sanity / form-builder / src / inputs / BlockEditor / plugins / UndoRedoPlugin.ts View on Github external
onKeyDown(event: React.KeyboardEvent, editor: SlateEditor, next: (arg0: void) => void) {
      if (!(Hotkeys.isUndo(event) || Hotkeys.isRedo(event))) {
        return next()
      }
      if (Hotkeys.isUndo(event)) {
        return handleUndoItem(editor, stack.undo.pop())
      }
      if (Hotkeys.isRedo(event)) {
        return handleRedoItem(editor, stack.redo.pop())
      }
      return editor
    }
  }