Skip to content

Commit

Permalink
core: only check doc.textBetween if other checks pass
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodrr committed Feb 23, 2023
1 parent 8bf8fd2 commit 914f32d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/extensions/keymap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ export const Keymap = Extension.create({
const allFrom = Selection.atStart(oldState.doc).from
const allEnd = Selection.atEnd(oldState.doc).to
const allWasSelected = from === allFrom && to === allEnd
const isEmpty = newState.doc.textBetween(0, newState.doc.content.size, ' ', ' ').length === 0

if (empty || !allWasSelected || !isEmpty) {
if (empty || !allWasSelected) {
return
}

const isEmpty = newState.doc.textBetween(0, newState.doc.content.size, ' ', ' ').length === 0
if (!isEmpty) {
return
}

Expand Down

0 comments on commit 914f32d

Please sign in to comment.