Repository navigation
[pull] main from facebook:main - #92
Conversation
…e in token mode (#7602)
Reviewer's GuideThis PR deepens TabNode’s integration into token-based handling by constraining its text mutations, exposing a new token-or-tab utility, updating selection and event logic to treat tabs as tokens, adding boundary insertion tests, and refactors text synchronization to consistently use setTextContent. Sequence Diagram for TabNode setTextContent and spliceText OperationssequenceDiagram
participant C as Caller
participant TN as TabNode
C->>TN: setTextContent("any text")
TN->>TN: super.setTextContent('\t') // Internally enforces '\t'
TN-->>C: returns self
alt Valid spliceText (e.g., delete and insert tab)
C->>TN: spliceText(0, 1, "\t")
TN-->>C: returns self // Constrained behavior, no actual text content change beyond ensuring it's a tab
else Invalid spliceText (e.g., arbitrary text change)
C->>TN: spliceText(0, 0, "a")
TN-->>C: throws InvariantError
end
Sequence Diagram for Text Insertion Logic with $isTokenOrTab UtilitysequenceDiagram
actor User
participant Editor
participant RS as RangeSelection
participant Node as "TextNode (e.g., TabNode)"
participant LU as LexicalUtils
User->>Editor: Types character "a"
Editor->>RS: insertText("a")
RS->>Node: getProperties()
RS->>LU: $isTokenOrTab(Node)
activate LU
LU-->>RS: true (if Node is TabNode or Token)
deactivate LU
RS->>Node: applyTokenLikeInsertionLogic() // e.g., replace node, or disallow partial modification
RS-->>Editor: Update EditorState
Editor-->>User: Display updated text
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.1)
Can you help keep this open source service alive? 💖 Please sponsor : )
Summary by Sourcery
Treat TabNode as a first-class token in editing operations by introducing $isTokenOrTab, enforcing immutability of TabNode text, updating selection and text utilities to handle TabNode correctly, and adding tests for boundary insertion behavior.
Bug Fixes:
Enhancements:
Tests: