How to use the slate-hotkeys.isExtendBackward 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 / plugins / dom / after.js View on Github external
}

      return editor.moveForward()
    }

    if (Hotkeys.isMoveWordBackward(event)) {
      event.preventDefault()
      return editor.moveWordBackward()
    }

    if (Hotkeys.isMoveWordForward(event)) {
      event.preventDefault()
      return editor.moveWordForward()
    }

    if (Hotkeys.isExtendBackward(event)) {
      const startText = document.getNode(start.path)
      const [prevEntry] = document.texts({
        path: start.path,
        direction: 'backward',
      })

      let isPrevInVoid = false

      if (prevEntry) {
        const [, prevPath] = prevEntry
        isPrevInVoid = document.hasVoidParent(prevPath, editor)
      }

      if (hasVoidParent || isPrevInVoid || startText.text === '') {
        event.preventDefault()
        return editor.moveFocusBackward()