@@ -16,7 +16,7 @@ import { SuperDocEditor } from '/snippets/components/superdoc-editor.jsx'
1616 const editor = superdoc ?.activeEditor || superdoc ?.editor
1717 if (! editor ?.commands ) return
1818
19- // Find "________" in "Client name:" paragraph and replace with inline field
19+ // Find "________" in "Client name:" paragraph and replace with inline sdtLocked field
2020 let inlinePos = null
2121 editor .state .doc .descendants ((node , pos ) => {
2222 if (node .isText && node .text .includes (' ________' ) && inlinePos === null ) {
@@ -26,12 +26,12 @@ import { SuperDocEditor } from '/snippets/components/superdoc-editor.jsx'
2626 if (inlinePos !== null ) {
2727 editor .commands .setTextSelection ({ from: inlinePos , to: inlinePos + 8 })
2828 editor .commands .insertStructuredContentInline ({
29- attrs: { id: ' 1' , alias: ' Client Name' },
29+ attrs: { id: ' 1' , alias: ' Client Name' , lockMode: ' sdtLocked ' },
3030 text: ' John Doe' ,
3131 })
3232 }
3333
34- // Find the second "________" paragraph and replace with block field
34+ // Find the second "________" paragraph and replace with block sdtLocked field
3535 let blockPos = null
3636 editor .state .doc .descendants ((node , pos ) => {
3737 if (node .isText && node .text .includes (' ________' )) {
@@ -41,7 +41,7 @@ import { SuperDocEditor } from '/snippets/components/superdoc-editor.jsx'
4141 if (blockPos !== null ) {
4242 editor .commands .setTextSelection ({ from: blockPos , to: blockPos + 8 })
4343 editor .commands .insertStructuredContentBlock ({
44- attrs: { id: ' 2' , alias: ' Payment Terms' },
44+ attrs: { id: ' 2' , alias: ' Payment Terms' , lockMode: ' sdtLocked ' },
4545 json: { type: ' paragraph' , content: [{ type: ' text' , text: ' Payment is due within 30 days of invoice date. Late payments incur a 1.5% monthly fee.' }] },
4646 })
4747 }
@@ -67,6 +67,37 @@ import { SuperDocEditor } from '/snippets/components/superdoc-editor.jsx'
6767 }
6868 },
6969 ],
70+ [
71+ {
72+ label: ' Lock inline (sdtContentLocked)' ,
73+ onClick : (superdoc ) => {
74+ const editor = superdoc ?.activeEditor || superdoc ?.editor
75+ if (! editor ?.commands ) return
76+ editor .commands .updateStructuredContentById (' 1' , {
77+ attrs: { lockMode: ' sdtContentLocked' },
78+ });
79+ }
80+ },
81+ {
82+ label: ' Lock block (sdtContentLocked)' ,
83+ onClick : (superdoc ) => {
84+ const editor = superdoc ?.activeEditor || superdoc ?.editor
85+ if (! editor ?.commands ) return
86+ editor .commands .updateStructuredContentById (' 2' , {
87+ attrs: { lockMode: ' sdtContentLocked' },
88+ });
89+ }
90+ },
91+ {
92+ label: ' Unlock all' ,
93+ onClick : (superdoc ) => {
94+ const editor = superdoc ?.activeEditor || superdoc ?.editor
95+ if (! editor ?.commands ) return
96+ editor .commands .updateStructuredContentById (' 1' , { attrs: { lockMode: ' unlocked' } });
97+ editor .commands .updateStructuredContentById (' 2' , { attrs: { lockMode: ' unlocked' } });
98+ }
99+ },
100+ ],
70101 [
71102 {
72103 label: ' Delete all fields' ,
0 commit comments