{{ message }}
Repository navigation
Commit 82e5201
Clicking an image emitted `muya-transformer` (and the image toolbar's rect)
from the nodes that were in the document at click time, and only then called
`selectImage`. That call nulls `editor.activeContentBlock`, which runs
`Format.blurHandler` -> `checkNeedRender()` -> `update()`, and the inline
renderer's `patch` reassigns the paragraph's `innerHTML`. Every node inside
it, the clicked image's wrapper and container included, is replaced.
`checkNeedRender()` is true whenever the caret sits within one character of a
token's range, so a caret anywhere on the image's own line always triggers it
-- the state a document that opens on an image is already in, since
`Editor.init()` focuses the first block at offset 0. `ImageResizeBar` renders
on a `setTimeout`, so by then it held a detached container: an all-zero
bounding rect, drawing both handles at `left: -5px; top: -25px` instead of on
the image's edges, where only a sliver shows and dragging cannot resize.
`autoUpdate` never recovers, because a detached node never moves. A second
click found the block already blurred, hence no re-render and correct handles.
Select first, then read both references off the live DOM. The clicked image is
re-found by its position among the paragraph's images, which survives the
re-render -- ids do not identify it (images sharing a src and paragraph offset
render with the same id). Taking the toolbar's rect afterwards too fixes the
second manifestation: when the caret revealed markers of another token in the
paragraph, hiding them on blur reflows the line and shifts the image sideways,
so the pre-render rect left the toolbar behind by that offset.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 69f93e4 commit 82e5201
3 files changed
Lines changed: 218 additions & 20 deletions
File tree
- packages/muya
- e2e/tests/drag
- src/selection
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
86 | 92 | | |
87 | 93 | | |
88 | 94 | | |
| |||
130 | 136 | | |
131 | 137 | | |
132 | 138 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
141 | 160 | | |
142 | 161 | | |
143 | 162 | | |
144 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
145 | 168 | | |
146 | 169 | | |
147 | 170 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | 171 | | |
158 | 172 | | |
159 | 173 | | |
160 | 174 | | |
161 | 175 | | |
162 | 176 | | |
163 | | - | |
164 | | - | |
165 | 177 | | |
166 | 178 | | |
167 | 179 | | |
| |||

0 commit comments