Commit cf75357
authored
fix(content-controls): mutate locked SDTs via AttrSteps and inner-range writes (SD-3123) (#3287)
* fix(content-controls): mutate locked SDTs via AttrSteps and inner-range writes (SD-3123)
Per ECMA-376, sdtLocked protects the SDT wrapper from removal but the content
stays editable. Before this fix, programmatic mutations flowed through
editor.commands.updateStructuredContentById, which dispatches
tr.replaceWith(pos, pos + node.nodeSize, ...) spanning the entire SDT. The
structured-content lock plugin's filterTransaction reads that as wrapper
damage and silently filters the transaction on sdtLocked controls -
producing false-success no-ops on operations the API allows (text.setValue,
replaceContent, appendContent, prependContent, setLockMode).
Two engine changes:
- applyAttrsUpdate (sdt-properties-write.ts) - switch from
editor.commands.updateStructuredContentById to per-key tr.setNodeAttribute.
AttrSteps have no from/to range and are explicitly skipped by the lock
plugin's filterTransaction. This is the path that patch, setLockMode,
patchRawProperties, setType, and the date/binding/multiline family use.
- replaceSdtTextContent (content-controls-wrappers.ts) - replace the SDT's
inner content range (pos+1 to pos+nodeSize-1) instead of rewriting the
whole wrapper. The lock plugin classifies inner-range steps as
wouldModifyContent: allowed on sdtLocked, still blocked on contentLocked
/ sdtContentLocked (both per spec).
The search in applyAttrsUpdate uses SDT_NODE_NAMES (imported from
target-resolution.ts) so it resolves the same nodes the upstream
resolveSdtByTarget would resolve. documentSection / documentPartObject are
intentionally excluded - they have their own write paths and could collide
on id.
No changes to API-level lock guards (assertNotSdtLocked on patch, setType,
setBinding, etc.) - relaxing those is a separate behavior decision and out
of scope here.
Tests:
- 4 new regression tests for sdtLocked (setLockMode, text.setValue,
text.clearValue, replaceContent) that assert the actual inner-range
positions (pos+1, pos+nodeSize-1), not just call counts.
- 11 existing tests migrated from "expect updateStructuredContentById
called" to "expect tr.setNodeAttribute / tr.replaceWith / tr.delete".
- 19 metadata-mutation operations added to CC_DIRECT_DISPATCH_OPS in
conformance (no synthetic-failure mode after this refactor, matching the
existing precedent for wrap/unwrap/etc.).
All pass: 46 wrappers + 1170 conformance + 104 SDT-adjacent + 1398
document-api. Zero new TypeScript errors.
Related: SD-3131, SD-3139, IT-1046.
* test(content-controls): add clearContent sdtLocked regression test (SD-3123)1 parent f390043 commit cf75357
4 files changed
Lines changed: 339 additions & 89 deletions
File tree
- packages/super-editor/src/editors/v1/document-api-adapters
- __conformance__
- helpers/content-controls
- plan-engine
Lines changed: 51 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
627 | 627 | | |
628 | 628 | | |
629 | 629 | | |
| 630 | + | |
630 | 631 | | |
631 | 632 | | |
632 | 633 | | |
| |||
1294 | 1295 | | |
1295 | 1296 | | |
1296 | 1297 | | |
| 1298 | + | |
1297 | 1299 | | |
1298 | 1300 | | |
1299 | 1301 | | |
| |||
1638 | 1640 | | |
1639 | 1641 | | |
1640 | 1642 | | |
1641 | | - | |
1642 | | - | |
1643 | | - | |
1644 | | - | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
1645 | 1646 | | |
1646 | | - | |
1647 | | - | |
1648 | | - | |
1649 | | - | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
1650 | 1663 | | |
1651 | 1664 | | |
1652 | 1665 | | |
| |||
1661 | 1674 | | |
1662 | 1675 | | |
1663 | 1676 | | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
1664 | 1699 | | |
1665 | 1700 | | |
1666 | 1701 | | |
| |||
2367 | 2402 | | |
2368 | 2403 | | |
2369 | 2404 | | |
| 2405 | + | |
2370 | 2406 | | |
2371 | 2407 | | |
2372 | 2408 | | |
| |||
2439 | 2475 | | |
2440 | 2476 | | |
2441 | 2477 | | |
| 2478 | + | |
2442 | 2479 | | |
2443 | 2480 | | |
2444 | 2481 | | |
| |||
2513 | 2550 | | |
2514 | 2551 | | |
2515 | 2552 | | |
| 2553 | + | |
2516 | 2554 | | |
2517 | 2555 | | |
2518 | 2556 | | |
| |||
2675 | 2713 | | |
2676 | 2714 | | |
2677 | 2715 | | |
| 2716 | + | |
2678 | 2717 | | |
2679 | 2718 | | |
2680 | 2719 | | |
| |||
2769 | 2808 | | |
2770 | 2809 | | |
2771 | 2810 | | |
| 2811 | + | |
2772 | 2812 | | |
2773 | 2813 | | |
2774 | 2814 | | |
| |||
2888 | 2928 | | |
2889 | 2929 | | |
2890 | 2930 | | |
| 2931 | + | |
2891 | 2932 | | |
2892 | 2933 | | |
2893 | 2934 | | |
| |||
2953 | 2994 | | |
2954 | 2995 | | |
2955 | 2996 | | |
| 2997 | + | |
2956 | 2998 | | |
2957 | 2999 | | |
2958 | 3000 | | |
| |||
11984 | 12026 | | |
11985 | 12027 | | |
11986 | 12028 | | |
| 12029 | + | |
11987 | 12030 | | |
11988 | 12031 | | |
11989 | 12032 | | |
| |||
Lines changed: 57 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
73 | 98 | | |
74 | 99 | | |
75 | | - | |
76 | | - | |
77 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
78 | 129 | | |
79 | 130 | | |
80 | 131 | | |
| |||
0 commit comments