Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lexical][lexical-utils][lexical-selection][lexical-table] Feature: NodeCaret abstraction for traversals and ranges #7046

Merged
merged 82 commits into from
Feb 8, 2025
Merged
Changes from 1 commit
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
531bb8d
WIP lexical caret
etrepum Jan 3, 2025
23c493b
wip iterCarets
etrepum Jan 7, 2025
b45db8e
WIP iterators
etrepum Jan 8, 2025
724c6c5
test
etrepum Jan 8, 2025
65c6d8d
Merge remote-tracking branch 'origin/main' into lexical-caret
etrepum Jan 13, 2025
7891ca7
update-packages
etrepum Jan 13, 2025
4591c91
ci-check workaround
etrepum Jan 13, 2025
f84e1b0
support old node and its lack of toReversed
etrepum Jan 13, 2025
3489483
$dfs
etrepum Jan 13, 2025
1937dad
remove @ampproject/rollup-plugin-closure-compiler
etrepum Jan 14, 2025
9b1a26a
Merge remote-tracking branch 'origin/main' into lexical-caret
etrepum Jan 14, 2025
fdfca01
Merge branch 'main' into lexical-caret
etrepum Jan 14, 2025
7410964
clean up utils
etrepum Jan 14, 2025
47b9ec8
Merge branch 'main' into lexical-caret
etrepum Jan 15, 2025
ed62d15
TextSlice abstraction
etrepum Jan 16, 2025
df84980
Merge remote-tracking branch 'origin/main' into lexical-caret
etrepum Jan 16, 2025
29302a2
WIP TextSliceCaret
etrepum Jan 16, 2025
32aa889
fix docs
etrepum Jan 16, 2025
c8d1432
WIP
etrepum Jan 19, 2025
51d279f
caret slices
etrepum Jan 22, 2025
145620a
$removeCaretText and TextNodeCaret refactor
etrepum Jan 26, 2025
15886e8
Merge remote-tracking branch 'origin/main' into lexical-caret
etrepum Jan 26, 2025
64fdec3
more tests
etrepum Jan 27, 2025
a139561
more tests
etrepum Jan 27, 2025
f8c0781
Finish tests for multiple nodes in one paragraph
etrepum Jan 27, 2025
8754a46
cases for multiple blocks
etrepum Jan 27, 2025
04f750e
reorganize into two modules
etrepum Jan 27, 2025
34ef1bc
refactor tests and fix $setPointFromCaret
etrepum Jan 27, 2025
7f5950a
Replace RangeSelection.removeText()
etrepum Jan 28, 2025
20dae45
WIP selection fixes
etrepum Jan 28, 2025
eb02346
fix under-selection
etrepum Jan 28, 2025
f28c774
work around more selection edge cases
etrepum Jan 29, 2025
9826108
Preserve indent and format in $setBlocksType
etrepum Jan 29, 2025
6878a53
Merge remote-tracking branch 'origin/main' into lexical-caret
etrepum Jan 29, 2025
cfa3a7c
handle disappearing anchors
etrepum Jan 29, 2025
225ccca
fix block merge order
etrepum Jan 29, 2025
3b657dc
fix splice order
etrepum Jan 29, 2025
e0e5076
fix tests for block merge order
etrepum Jan 29, 2025
ea4acc4
clean up unit test
etrepum Jan 29, 2025
d702e11
Merge remote-tracking branch 'origin/main' into lexical-caret
etrepum Jan 30, 2025
e01e001
Modify reverseDfs implementation to be compliant with expectations
etrepum Jan 30, 2025
9dc52c9
expand the caret range to handle focus boundary
etrepum Jan 30, 2025
f5e6f21
Fix splitText bias
etrepum Jan 30, 2025
9822263
Merge remote-tracking branch 'origin/main' into lexical-caret
etrepum Jan 30, 2025
2bc076a
Fix dependency cycle
etrepum Jan 30, 2025
7c118a5
wip table example
etrepum Jan 31, 2025
cdf7dbd
$normalizeCaret
etrepum Jan 31, 2025
7eb46f7
$normalizeCaret
etrepum Jan 31, 2025
19e43f2
change link test selection normalization expectations
etrepum Jan 31, 2025
8cf7d44
$ensureForwardRangeSelection
etrepum Jan 31, 2025
59e3c67
Conditional forward range selection
etrepum Jan 31, 2025
563ae70
Merge remote-tracking branch 'origin/main' into lexical-caret
etrepum Feb 1, 2025
5a7c8c7
renames
etrepum Feb 1, 2025
524a1d2
Start on docs
etrepum Feb 1, 2025
651ddae
WIP docs
etrepum Feb 1, 2025
6136ba3
Fix nested admonition
etrepum Feb 1, 2025
8666aa4
notes on future directions
etrepum Feb 1, 2025
885b300
Start on renaming
etrepum Feb 2, 2025
18b81e4
rename depth -> child
etrepum Feb 2, 2025
9d86fa2
breadth -> sibling rename
etrepum Feb 2, 2025
15396f8
find and replace case fix
etrepum Feb 2, 2025
4a7d68f
more renames and polish
etrepum Feb 2, 2025
071537b
simplify further
etrepum Feb 2, 2025
a49bbae
simplify getTextSlices
etrepum Feb 2, 2025
f45240b
clarify $getChildCaretAtIndex
etrepum Feb 2, 2025
01c4351
Big refactor for more safety with TextPointCaret
etrepum Feb 3, 2025
f58da4e
clean up copy
etrepum Feb 3, 2025
2e52712
tighten up text
etrepum Feb 3, 2025
2cb9ee2
Fix #7081
etrepum Feb 3, 2025
15d7245
Regression test for #7076
etrepum Feb 3, 2025
8fb7c6e
simplify $forEachSelectedTextNode
etrepum Feb 3, 2025
54d97d4
remove vestigial is method
etrepum Feb 3, 2025
b70aed5
Add terminology section
etrepum Feb 4, 2025
b2c6c18
further cleanup of splitText
etrepum Feb 4, 2025
fd61dad
Merge remote-tracking branch 'origin/main' into lexical-caret
etrepum Feb 4, 2025
b0526b7
Ensure getNodes() returns at most one node for a collapsed selection
etrepum Feb 4, 2025
52b90a6
Merge remote-tracking branch 'origin/main' into lexical-caret
etrepum Feb 5, 2025
162cf72
Merge remote-tracking branch 'origin/main' into lexical-caret
etrepum Feb 7, 2025
e5142eb
add more docs & test the docs
etrepum Feb 7, 2025
92b708e
flow types for node caret
etrepum Feb 8, 2025
efca772
update hermes and use boolean instead of guard syntax it does not parse
etrepum Feb 8, 2025
92e3c89
refactor StepwiseIteratorConfig stop to hasNext so the guards do not lie
etrepum Feb 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ci-check workaround
etrepum committed Jan 13, 2025
commit 4591c915da7970a690372100f6d5f94b9f760e84
3 changes: 2 additions & 1 deletion packages/lexical/src/LexicalCaret.ts
Original file line number Diff line number Diff line change
@@ -213,7 +213,8 @@ abstract class AbstractCaret<T extends LexicalNode, D extends CaretDirection>
// TODO: Optimize this to work directly with node internals
for (const node of nodeIter) {
if (nodesToRemove.size > 0) {
const target = caret.getNodeAtCaret();
// TODO: For some reason `npm run tsc-extension` needs this annotation?
const target: null | LexicalNode = caret.getNodeAtCaret();
invariant(
target !== null,
'NodeCaret.splice: Underflow of expected nodesToRemove during splice (keys: %s)',