Skip to content

Type Editor


Type Editor / @type-editor/dom-change-util / parse-change/looks-like-backspace-key / looksLikeBackspaceKey

Function: looksLikeBackspaceKey()

ts
function looksLikeBackspaceKey(view, doc, change, $from, $to): boolean;

Defined in: parse-change/looks-like-backspace-key.ts:33

Checks if the change looks like the effect of pressing the Backspace key.

Similar to Enter detection, some backspace operations (especially block joins) are better handled through the Backspace key handler. This function detects if a change looks like a backspace operation by checking:

  • The selection anchor is after the change start (backspacing backwards)
  • The change matches the backspace pattern (see looksLikeBackspace)
  • A handleKeyDown plugin accepts the Backspace key event

The detailed backspace detection logic is in the looksLikeBackspace function.

Parameters

ParameterTypeDescription
viewPmEditorViewThe editor view containing selection state and plugin handlers
docNode_2The current document (before the change)
changeDocumentChangeThe detected document change
$fromResolvedPosStart position in the parsed (new) document (resolved)
$toResolvedPosEnd position in the parsed (new) document (resolved)

Returns

boolean

True if the change looks like Backspace and a key handler accepted it, false if the change should be processed as a normal DOM change

See

looksLikeBackspace for detailed backspace detection logic