Skip to content

Commit 1e7ee83

Browse files
committed
docs(structured-content): address review feedback
- Differentiate lock mode insert example from command section example (use sdtContentLocked/Account ID instead of duplicate sdtLocked/Customer Name) - Wrap enforcement details in Expandable for scannability - Add missing `group` to block insert attrs type - Replace raw tr.setNodeAttribute with updateStructuredContentById in demo
1 parent 1b14795 commit 1e7ee83

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

apps/docs/extensions/structured-content.mdx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ Set the lock mode when inserting:
6767
```javascript Usage
6868
editor.commands.insertStructuredContentInline({
6969
attrs: {
70-
id: '1',
71-
alias: 'Customer Name',
72-
lockMode: 'sdtLocked',
70+
id: '3',
71+
alias: 'Account ID',
72+
lockMode: 'sdtContentLocked',
7373
},
74-
text: 'John Doe',
74+
text: 'ACC-00042',
7575
});
7676
```
7777

@@ -86,11 +86,11 @@ const superdoc = new SuperDoc({
8686
const editor = superdoc.activeEditor;
8787
editor.commands.insertStructuredContentInline({
8888
attrs: {
89-
id: '1',
90-
alias: 'Customer Name',
91-
lockMode: 'sdtLocked',
89+
id: '3',
90+
alias: 'Account ID',
91+
lockMode: 'sdtContentLocked',
9292
},
93-
text: 'John Doe',
93+
text: 'ACC-00042',
9494
});
9595
},
9696
});
@@ -123,13 +123,15 @@ const superdoc = new SuperDoc({
123123
```
124124
</CodeGroup>
125125

126+
<Expandable title="How lock enforcement works">
126127
Lock modes are enforced at the editor plugin level using a three-layer defense:
127128

128129
1. **Key interception** — Delete, Backspace, and Cut are blocked before a transaction is created, preventing cursor jumps
129130
2. **Text input blocking** — Typing is silently blocked in content-locked nodes
130131
3. **Transaction filter** — Safety net that catches paste, drag-drop, and programmatic edits
131132

132133
Users can still place their cursor inside locked content and select text for copying. Only modifications are blocked.
134+
</Expandable>
133135

134136
<Info>
135137
Lock modes round-trip through DOCX. A document with `w:lock` elements in
@@ -696,7 +698,7 @@ type StructuredContentLockMode = 'unlocked' | 'sdtLocked' | 'contentLocked' | 's
696698
ProseMirror JSON
697699
</ResponseField>
698700
<ResponseField name="attrs" type="Object">
699-
Node attributes (`id`, `alias`, `tag`, `lockMode`)
701+
Node attributes (`id`, `alias`, `tag`, `lockMode`, `group`)
700702
</ResponseField>
701703
</Expandable>
702704

apps/docs/snippets/extensions/structured-content.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,28 @@ import { SuperDocEditor } from '/snippets/components/superdoc-editor.jsx'
7272
label: 'Toggle inline lock',
7373
onClick: (superdoc) => {
7474
const editor = superdoc?.activeEditor || superdoc?.editor
75-
if (!editor?.state) return
75+
if (!editor?.commands) return
7676
const tags = editor.helpers.structuredContentCommands.getStructuredContentTags(editor.state)
7777
const field = tags.find(t => String(t.node.attrs.id) === '1')
7878
if (!field) return
7979
const locked = field.node.attrs.lockMode && field.node.attrs.lockMode !== 'unlocked'
80-
const tr = editor.state.tr
81-
tr.setNodeAttribute(field.pos, 'lockMode', locked ? 'unlocked' : 'sdtContentLocked')
82-
editor.view.dispatch(tr)
80+
editor.commands.updateStructuredContentById('1', {
81+
attrs: { lockMode: locked ? 'unlocked' : 'sdtContentLocked' },
82+
})
8383
}
8484
},
8585
{
8686
label: 'Toggle block lock',
8787
onClick: (superdoc) => {
8888
const editor = superdoc?.activeEditor || superdoc?.editor
89-
if (!editor?.state) return
89+
if (!editor?.commands) return
9090
const tags = editor.helpers.structuredContentCommands.getStructuredContentTags(editor.state)
9191
const field = tags.find(t => String(t.node.attrs.id) === '2')
9292
if (!field) return
9393
const locked = field.node.attrs.lockMode && field.node.attrs.lockMode !== 'unlocked'
94-
const tr = editor.state.tr
95-
tr.setNodeAttribute(field.pos, 'lockMode', locked ? 'unlocked' : 'sdtContentLocked')
96-
editor.view.dispatch(tr)
94+
editor.commands.updateStructuredContentById('2', {
95+
attrs: { lockMode: locked ? 'unlocked' : 'sdtContentLocked' },
96+
})
9797
}
9898
},
9999
],

0 commit comments

Comments
 (0)