Commit 3c16da4
committed
refactor(core): simplify the BlockInfo API and make it the single vocabulary for block/children plumbing
Consolidates the ~8 vocabularies that answered "where do this block's
children live?" down to two: `getBlockRegions` resolves block shape in one
place, and `BlockInfo` is the position-annotated view everything reads.
BlockInfo shape:
- `bnBlock` -> `block`, `blockContent` -> `content`,
`childContainer` -> `children`, `isWrappedBlock` -> `hasContent`
- precomputed `contentStart`/`contentEnd`, `children.childrenStart`/`childrenEnd`,
`contentKind`, `isContentEmpty` replace hand arithmetic at 40+ call sites
- still a discriminated union on `hasContent`, so narrowing guards keep working
Producers: 6 -> 4. `getBlockInfo` and `getBlockInfoFromResolvedPos` are gone;
`getBlockInfoWithManualOffset`, `getBlockInfoAtNearest` and
`getBottomNestedBlockInfo` become `getBlockInfoFromNode`, `getBlockInfoNearPos`
and `getLastDescendantBlockInfo`.
Navigation helpers (`getParentBlockInfo`, `getPrevBlockInfo`, `getNextBlockInfo`,
`getLastDescendantBlockInfo`) move from `mergeBlocks.ts` to
`getBlockInfoFromPos.ts` and become public. `getParentBlockInfo` now has
block-model semantics: a block inside a column parents to the column, not the
columnList. This fixes the Delete-at-end climb running its seal check on the
wrong node for container children.
Deleted synonym vocabularies and bare-property-read helpers: `childrenHolder.ts`,
`ChildrenWriteTarget`, `fixContainer`'s private repair targets, `getChildrenConfig`,
`isContainerType`, `isPlaceableAnywhere`, `isInsertableChild`,
`flattenNonInsertableBlocks`, `seedRefillChildren`, `assertSchemaInvariants.ts`,
and most of `validateChildren.ts` (which duplicated checks ProseMirror already
enforces).
`descendToFirstInsertionPos`/`descendToLastInsertionPos` merge into
`descendToInsertionPos(info, nodeType, edge, opts)`. `setSelection` and
`setTextCursorPosition` drop their manual table arithmetic and content-type
switches in favour of `blockEdgePos`/`blockEdgeSelection`. `canNestBlock` and
`canUnnestBlock` now dry-run the real command instead of re-deriving its
preconditions.
`insertBlocks` placements `"start"`/`"end"` are renamed to `"first-child"`/
`"last-child"`. The cursor-placement vocabulary of `setTextCursorPosition` is
unrelated and unchanged.1 parent 7ec114f commit 3c16da4
59 files changed
Lines changed: 2150 additions & 2053 deletions
File tree
- docs/content/docs
- features/custom-schemas
- reference/editor
- packages
- core/src
- api
- blockManipulation
- commands
- insertBlocks
- mergeBlocks
- moveBlocks
- nestBlock
- replaceBlocks
- splitBlock
- updateBlock
- containers
- getBlock
- selections
- clipboard/fromClipboard
- exporters/html/util
- nodeConversions
- blocks
- ListItem
- NumberedListItem
- utils
- editor
- managers
- ExtensionManager
- exporter
- extensions/tiptap-extensions/KeyboardShortcuts
- pm-nodes
- schema
- blocks
- react/src/schema
- xl-ai/src
- api/formats/html-blocks
- prosemirror
- testUtil/cases
- xl-multi-column/src/extensions/DropCursor
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
| 172 | + | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
Lines changed: 24 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 16 | + | |
20 | 17 | | |
21 | 18 | | |
22 | | - | |
23 | | - | |
24 | | - | |
| 19 | + | |
| 20 | + | |
25 | 21 | | |
26 | 22 | | |
27 | 23 | | |
28 | 24 | | |
29 | 25 | | |
30 | | - | |
| 26 | + | |
31 | 27 | | |
32 | 28 | | |
33 | 29 | | |
| |||
51 | 47 | | |
52 | 48 | | |
53 | 49 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | 50 | | |
60 | 51 | | |
61 | 52 | | |
| |||
66 | 57 | | |
67 | 58 | | |
68 | 59 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
74 | 71 | | |
75 | 72 | | |
76 | 73 | | |
77 | 74 | | |
78 | | - | |
79 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
80 | 79 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | 80 | | |
95 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
96 | 84 | | |
97 | 85 | | |
98 | 86 | | |
| |||
134 | 122 | | |
135 | 123 | | |
136 | 124 | | |
137 | | - | |
| 125 | + | |
138 | 126 | | |
139 | 127 | | |
140 | 128 | | |
| |||
Lines changed: 45 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
| |||
95 | 103 | | |
96 | 104 | | |
97 | 105 | | |
98 | | - | |
99 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
100 | 116 | | |
101 | 117 | | |
102 | 118 | | |
| |||
120 | 136 | | |
121 | 137 | | |
122 | 138 | | |
123 | | - | |
124 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
125 | 149 | | |
126 | 150 | | |
127 | 151 | | |
| |||
137 | 161 | | |
138 | 162 | | |
139 | 163 | | |
140 | | - | |
141 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
142 | 174 | | |
143 | 175 | | |
144 | 176 | | |
| |||
157 | 189 | | |
158 | 190 | | |
159 | 191 | | |
160 | | - | |
| 192 | + | |
161 | 193 | | |
162 | 194 | | |
163 | 195 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
0 commit comments