Skip to content

Commit 7e8ecf5

Browse files
committed
docs(structured-content): add toggle lock buttons for inline and block
1 parent 88edde8 commit 7e8ecf5

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,34 @@ import { SuperDocEditor } from '/snippets/components/superdoc-editor.jsx'
6767
}
6868
},
6969
],
70+
[
71+
{
72+
label: 'Toggle inline lock',
73+
onClick: (superdoc) => {
74+
const editor = superdoc?.activeEditor || superdoc?.editor
75+
if (!editor?.commands) return
76+
const tags = editor.helpers.structuredContentCommands.getStructuredContentTags(editor.state)
77+
const field = tags.find(t => String(t.id) === '1')
78+
const locked = field?.lockMode && field.lockMode !== 'unlocked'
79+
editor.commands.updateStructuredContentById('1', {
80+
attrs: { lockMode: locked ? 'unlocked' : 'sdtContentLocked' },
81+
});
82+
}
83+
},
84+
{
85+
label: 'Toggle block lock',
86+
onClick: (superdoc) => {
87+
const editor = superdoc?.activeEditor || superdoc?.editor
88+
if (!editor?.commands) return
89+
const tags = editor.helpers.structuredContentCommands.getStructuredContentTags(editor.state)
90+
const field = tags.find(t => String(t.id) === '2')
91+
const locked = field?.lockMode && field.lockMode !== 'unlocked'
92+
editor.commands.updateStructuredContentById('2', {
93+
attrs: { lockMode: locked ? 'unlocked' : 'sdtContentLocked' },
94+
});
95+
}
96+
},
97+
],
7098
[
7199
{
72100
label: 'Delete all fields',

0 commit comments

Comments
 (0)