Repository: ianstormtaylor/slate
File: packages/slate-react/src/components/editable.tsx (TypeScript)

Code before:
          const [node, offset] = ReactEditor.toDOMPoint(editor, anchor)
          const anchorNode = node.parentElement?.closest('a')

          const window = ReactEditor.getWindow(editor)

          if (
            native &&
            anchorNode &&
            ReactEditor.hasDOMNode(editor, anchorNode)
          ) {
            // Find the last text node inside the anchor.
            const lastText = window.document
              .createTreeWalker(anchorNode, NodeFilter.SHOW_TEXT)
              .lastChild() as DOMText | null

            if (lastText === node && lastText.textContent?.length === offset) {
              native = false
            }
          }

          // Chrome has issues with the presence of tab characters inside elements with whiteSpace = 'pre'
          // causing abnormal insert behavior: https://bugs.chromium.org/p/chromium/issues/detail?id=1219139
          if (
            native &&
            node.parentElement &&
            window.getComputedStyle(node.parentElement).whiteSpace === 'pre'
          ) {
            const block = Editor.above(editor, {
              at: anchor.path,
              match: n => Editor.isBlock(editor, n),
            })

            if (block && Node.string(block[0]).includes('\t')) {
              native = false
            }
          }
        }

        // COMPAT: For the deleting forward/backward input types we don't want
        // to change the selection because it is the range that will be deleted,
        // and those commands determine that for themselves.
        if (!type.startsWith('delete') || type.startsWith('deleteBy')) {
          const [targetRange] = (event as any).getTargetRanges()

          if (targetRange) {
            const range = ReactEditor.toSlateRange(editor, targetRange, {
              exactMatch: false,
              suppressThrow: false,
            })

            if (!selection || !Range.equals(selection, range)) {

Review comment (suggestion):
Probably unnecessary, but for some reason I think I’d feel better with:

```suggestion
            window?.getComputedStyle(node.parentElement)?.whiteSpace === 'pre'
```

Code after:
          const [node, offset] = ReactEditor.toDOMPoint(editor, anchor)
          const anchorNode = node.parentElement?.closest('a')

          const window = ReactEditor.getWindow(editor)

          if (
            native &&
            anchorNode &&
            ReactEditor.hasDOMNode(editor, anchorNode)
          ) {
            // Find the last text node inside the anchor.
            const lastText = window?.document
              .createTreeWalker(anchorNode, NodeFilter.SHOW_TEXT)
              .lastChild() as DOMText | null

            if (lastText === node && lastText.textContent?.length === offset) {
              native = false
            }
          }

          // Chrome has issues with the presence of tab characters inside elements with whiteSpace = 'pre'
          // causing abnormal insert behavior: https://bugs.chromium.org/p/chromium/issues/detail?id=1219139
          if (
            native &&
            node.parentElement &&
            window?.getComputedStyle(node.parentElement)?.whiteSpace === 'pre'
          ) {
            const block = Editor.above(editor, {
              at: anchor.path,
              match: n => Editor.isBlock(editor, n),
            })

            if (block && Node.string(block[0]).includes('\t')) {
              native = false
            }
          }
        }

        // COMPAT: For the deleting forward/backward input types we don't want
        // to change the selection because it is the range that will be deleted,
        // and those commands determine that for themselves.
        if (!type.startsWith('delete') || type.startsWith('deleteBy')) {
          const [targetRange] = (event as any).getTargetRanges()

          if (targetRange) {
            const range = ReactEditor.toSlateRange(editor, targetRange, {
              exactMatch: false,
              suppressThrow: false,
            })

            if (!selection || !Range.equals(selection, range)) {