Commit b5556f1
authored
fix(editor): preserve expanded headings in readonly mode (#15549)
## Description
Closes #13579.
On readonly shared pages, selecting text under a heading persisted as
collapsed caused reactive selection handling to restore the persisted
collapsed value over the viewer-local expanded state. This closed the
heading again and prevented selecting or copying its revealed content.
This change:
- separates persisted collapsed-state synchronization from selection
cleanup;
- makes the readonly-local collapsed state reactive for both BlockSuite
effects and Lit rendering;
- preserves selection and copying while a readonly heading is locally
expanded;
- still clears hidden text selection when the heading is collapsed
again;
- adds a Playwright regression covering collapse → readonly → expand →
drag-select → copy → re-collapse.
## Checklist
- [x] I have signed the [AFFiNE Contributor License
Agreement](https://cla-assistant.io/toeverything/AFFiNE) — required
before merge; the `license/cla` check must be green ([how it
works](https://github.com/toeverything/AFFiNE/blob/canary/docs/BUILDING.md#sign-the-cla-first))
- [x] The PR targets the `canary` branch and its title follows
[Conventional Commits](https://www.conventionalcommits.org/)
- [x] Tests are added or updated where it makes sense
- [x] `yarn lint` and `yarn typecheck` pass locally
## Testing
- Focused Chromium regression: 1 passed
- Adjacent readonly paragraph scenarios: 3 passed
- Targeted `oxfmt --check`: passed
- Targeted `oxlint --deny-warnings`: passed
- `git diff --check`: passed
`yarn typecheck` could not be confirmed in this checkout because
required generated workspace declaration outputs are missing.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved collapsed heading behavior in read-only mode.
* Preserved local heading expansion and text selection when copying
content and collapsing the heading.
* Ensured local expansion state resets correctly when switching out of
and back into read-only mode.
* **Tests**
* Added coverage for read-only heading expansion, keyboard copying,
clipboard access, mode switching, and text selection.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 8c59371 commit b5556f1
2 files changed
Lines changed: 93 additions & 8 deletions
File tree
- blocksuite/affine/blocks/paragraph/src
- tests/blocksuite/e2e
Lines changed: 20 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
70 | 77 | | |
71 | 78 | | |
72 | 79 | | |
| |||
185 | 192 | | |
186 | 193 | | |
187 | 194 | | |
188 | | - | |
189 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
190 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
191 | 206 | | |
192 | 207 | | |
193 | 208 | | |
| |||
244 | 259 | | |
245 | 260 | | |
246 | 261 | | |
247 | | - | |
| 262 | + | |
248 | 263 | | |
249 | 264 | | |
250 | 265 | | |
| |||
324 | 339 | | |
325 | 340 | | |
326 | 341 | | |
327 | | - | |
| 342 | + | |
328 | 343 | | |
329 | 344 | | |
330 | 345 | | |
| |||
380 | 395 | | |
381 | 396 | | |
382 | 397 | | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | 398 | | |
387 | 399 | | |
388 | 400 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| |||
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
| 62 | + | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
| |||
1329 | 1333 | | |
1330 | 1334 | | |
1331 | 1335 | | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
1332 | 1405 | | |
1333 | 1406 | | |
1334 | 1407 | | |
| |||
0 commit comments