fix(super-editor): select inline SDT on backspace before run start (SD-3165)#3388
Open
luccas-harbour wants to merge 3 commits into
Open
Conversation
…ng run (SD-3165) Adds a new selectInlineSdtBeforeRunStart command in the Backspace chain. When the caret is at the start of a run whose previous sibling is an inline structuredContent wrapper, Backspace now selects the wrapper as a NodeSelection (for unlocked / contentLocked modes) so a subsequent Backspace deletes it. For sdtLocked / sdtContentLocked wrappers the command consumes the keystroke without changing the selection. The structured-content select plugin ignores selections produced via the new meta flag so it does not collapse the NodeSelection back to a TextSelection.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes SD-3165: a content-locked inline SDT could not be deleted with Backspace when the cursor was placed at the start of the run immediately following it. The run-aware Backspace chain scanned into the SDT's content, so the locked wrapper never became the deletion target.
A new command,
selectInlineSdtBeforeRunStart, runs early in the Backspace chain. When the cursor is at offset 0 of arunwhose previous sibling is astructuredContentnode, it promotes the selection to aNodeSelectionover that wrapper (unlesslockModeissdtLocked/sdtContentLocked, in which case it consumes the keystroke to block deletion). A subsequent Backspace then deletes the now-selected SDT as a unit.The command tags its transaction with a
SELECT_INLINE_SDT_BEFORE_RUN_START_METAmeta so the existing inline-SDT auto-select plugin (structured-content-select-plugin) does not clobber the newNodeSelectionback into aTextSelection.Changes
selectInlineSdtBeforeRunStartcommand and register it in the core command map, index, and types.handleBackspacekeymap chain betweendeleteBlockSdtAtTextBlockStartandbackspaceEmptyRunParagraph.structured-content-select-pluginto skip its normalization when the new meta is present on the dispatched transaction.Tests
selectInlineSdtBeforeRunStartcovering:unlocked/contentLocked(selects wrapper),sdtLocked/sdtContentLocked(consumes without selecting), cursor not at run start, and previous sibling not an inline SDT.core-command-mapdeclaration test asserts the new entry inCoreCommandNames.keymap-backspace-chaintest pins the new command's position in the Backspace chain.structured-content-lock-plugin.test.jsfor the full two-step flow (Backspace selects, second Backspace deletes) on acontentLockedinline SDT.structured-content-select-plugintest verifies the meta escape keeps the Backspace-createdNodeSelectionintact.