Skip to content

Commit e61a515

Browse files
committed
docs(sdk): only set properties explicitly present in document blocks
1 parent 8da40b0 commit e61a515

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

packages/document-api/src/contract/operation-definitions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ export const INTENT_GROUP_META: Record<string, IntentGroupMeta> = {
150150
'Position markdown inserts with "target" (a BlockNodeAddress like {kind:"block", nodeType, nodeId}) and "placement" (before, after, insideStart, insideEnd). Without a target, content appends at the end of the document. ' +
151151
'IMPORTANT: After a markdown insert, analyze the document context (what kind of document, how titles and body text are styled) and follow up with ONE superdoc_mutations call to format inserted blocks so they look like they belong. ' +
152152
'Each format.apply step accepts "inline" (fontFamily, fontSize, bold, underline, color), "alignment", and "scope" in the same step. ' +
153-
'Use scope: "block" so formatting covers the entire paragraph. ALWAYS include fontSize — especially on headings, which inherit a large default size that must be overridden. ' +
154-
'Copy exact formatting from nearby blocks in the get_content response. Do NOT invent values. Your inserted content must be visually indistinguishable from the rest of the document. ' +
153+
'Use scope: "block" so formatting covers the entire paragraph. ' +
154+
'ONLY set inline properties that are explicitly shown in the existing get_content blocks. If blocks do not show fontSize, do NOT set fontSize (it inherits the document default). Do NOT invent values — mirror exactly what the document blocks show. ' +
155155
'Also supports replace, delete, and undo/redo. For replace and delete, pass a "ref" from superdoc_search or superdoc_get_content blocks. ' +
156156
'A search ref covers only the matched substring; a block ref covers the entire block text, so use block refs when rewriting or shortening whole paragraphs. ' +
157157
'Refs expire after any mutation; always re-search before the next edit. ' +

packages/sdk/tools/prompt-templates/system-prompt-core.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,20 @@ superdoc_edit({action: "insert", type: "markdown",
153153

154154
Use `scope: "block"` so the formatting covers the entire paragraph (not just the matched text). The text pattern only needs to identify which block.
155155

156-
ALWAYS include `fontSize` on every block, especially headings. Markdown headings inherit a large default font size that must be overridden. If a block in get_content doesn't show fontSize, use the fontSize from the nearest block that does.
156+
ONLY include inline properties that are explicitly present in the existing blocks. If the document blocks don't show `fontSize`, do NOT set fontSize (it will inherit the document's default, which is correct). If they don't show `bold`, don't set bold. Mirror exactly what you see, nothing more. Inventing values (like assuming fontSize: 12) causes mismatches.
157157

158-
Example: document has centered, non-bold, 12pt titles and justified 12pt body text:
158+
Example: document blocks show fontFamily and color but NO fontSize, titles are centered:
159159
```
160160
superdoc_mutations({action: "apply", atomic: true, steps: [
161-
{id: "f1", op: "format.apply", where: {by: "select", select: {type: "text", pattern: "Executive Summary"}, require: "first"}, args: {inline: {fontFamily: "Times New Roman, serif", fontSize: 12}, alignment: "center", scope: "block"}},
161+
{id: "f1", op: "format.apply", where: {by: "select", select: {type: "text", pattern: "Executive Summary"}, require: "first"}, args: {inline: {fontFamily: "Times New Roman, serif", color: "#000000"}, alignment: "center", scope: "block"}},
162+
{id: "f2", op: "format.apply", where: {by: "select", select: {type: "text", pattern: "This agreement sets forth"}, require: "first"}, args: {inline: {fontFamily: "Times New Roman, serif", color: "#000000"}, scope: "block"}}
163+
]})
164+
```
165+
166+
Example: document blocks explicitly show fontSize: 12, titles are centered and underlined:
167+
```
168+
superdoc_mutations({action: "apply", atomic: true, steps: [
169+
{id: "f1", op: "format.apply", where: {by: "select", select: {type: "text", pattern: "Executive Summary"}, require: "first"}, args: {inline: {fontFamily: "Times New Roman, serif", fontSize: 12, underline: true}, alignment: "center", scope: "block"}},
162170
{id: "f2", op: "format.apply", where: {by: "select", select: {type: "text", pattern: "This agreement sets forth"}, require: "first"}, args: {inline: {fontFamily: "Times New Roman, serif", fontSize: 12, color: "#000000"}, alignment: "justify", scope: "block"}}
163171
]})
164172
```

packages/sdk/tools/prompt-templates/system-prompt-mcp-header.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ superdoc_mutations({action: "apply", atomic: true, steps: [
3737
{id: "f2", op: "format.apply", where: {by: "select", select: {type: "text", pattern: "This agreement sets forth"}, require: "first"}, args: {inline: {fontFamily: "Times New Roman, serif", fontSize: 12}, alignment: "justify", scope: "block"}}
3838
]})
3939
```
40-
One format.apply step per block. Combine `inline`, `alignment`, and `scope: "block"` in each step. The pattern only needs to identify which paragraph. ALWAYS include `fontSize` on headings — markdown headings inherit a large default size that must be overridden to match the document.
40+
One format.apply step per block. Combine `inline`, `alignment`, and `scope: "block"` in each step. ONLY set properties that are explicitly shown in the existing document blocks. If blocks don't show fontSize, don't set it (the document default will apply correctly). Do NOT invent values.
4141

4242
**When to use which tool:**
4343
- Creating headings, paragraphs, or any block content → `superdoc_edit` with type "markdown" (preferred, even for a single heading + paragraph)

0 commit comments

Comments
 (0)