Skip to content

Commit e346c87

Browse files
committed
fix(docs): access node.attrs for lock toggle state detection
getStructuredContentTags returns {node, pos} objects — attrs are on node.attrs, not directly on the object.
1 parent 7e8ecf5 commit e346c87

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ import { SuperDocEditor } from '/snippets/components/superdoc-editor.jsx'
7474
const editor = superdoc?.activeEditor || superdoc?.editor
7575
if (!editor?.commands) return
7676
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'
77+
const field = tags.find(t => String(t.node.attrs.id) === '1')
78+
const locked = field?.node.attrs.lockMode && field.node.attrs.lockMode !== 'unlocked'
7979
editor.commands.updateStructuredContentById('1', {
8080
attrs: { lockMode: locked ? 'unlocked' : 'sdtContentLocked' },
8181
});
@@ -87,8 +87,8 @@ import { SuperDocEditor } from '/snippets/components/superdoc-editor.jsx'
8787
const editor = superdoc?.activeEditor || superdoc?.editor
8888
if (!editor?.commands) return
8989
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'
90+
const field = tags.find(t => String(t.node.attrs.id) === '2')
91+
const locked = field?.node.attrs.lockMode && field.node.attrs.lockMode !== 'unlocked'
9292
editor.commands.updateStructuredContentById('2', {
9393
attrs: { lockMode: locked ? 'unlocked' : 'sdtContentLocked' },
9494
});

0 commit comments

Comments
 (0)