Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/cli/src/__tests__/conformance/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ export const SUCCESS_SCENARIOS = {
'--target-json',
JSON.stringify(target),
'--inline-json',
JSON.stringify({ bold: true }),
JSON.stringify({ bold: 'on' }),
'--out',
harness.createOutputPath('doc-style-apply-output'),
],
Expand Down
8 changes: 4 additions & 4 deletions apps/cli/src/cli/helper-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const CLI_HELPER_COMMANDS: readonly CliHelperCommand[] = [
{
tokens: ['format', 'bold'],
canonicalOperationId: 'format.apply',
defaultInput: { inline: { bold: true } },
defaultInput: { inline: { bold: 'on' } },
description: 'Apply bold formatting to a text range.',
category: 'format',
mutates: true,
Expand All @@ -65,7 +65,7 @@ export const CLI_HELPER_COMMANDS: readonly CliHelperCommand[] = [
{
tokens: ['format', 'italic'],
canonicalOperationId: 'format.apply',
defaultInput: { inline: { italic: true } },
defaultInput: { inline: { italic: 'on' } },
description: 'Apply italic formatting to a text range.',
category: 'format',
mutates: true,
Expand All @@ -74,7 +74,7 @@ export const CLI_HELPER_COMMANDS: readonly CliHelperCommand[] = [
{
tokens: ['format', 'underline'],
canonicalOperationId: 'format.apply',
defaultInput: { inline: { underline: true } },
defaultInput: { inline: { underline: 'on' } },
description: 'Apply underline formatting to a text range.',
category: 'format',
mutates: true,
Expand All @@ -83,7 +83,7 @@ export const CLI_HELPER_COMMANDS: readonly CliHelperCommand[] = [
{
tokens: ['format', 'strikethrough'],
canonicalOperationId: 'format.apply',
defaultInput: { inline: { strike: true } },
defaultInput: { inline: { strike: 'on' } },
description: 'Apply strikethrough formatting to a text range.',
category: 'format',
mutates: true,
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/src/lib/operation-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export async function executeOperation(request: ExecuteOperationRequest): Promis
extraOptionSpecs: request.extraOptionSpecs,
}),
) ?? {}) as Record<string, unknown>;
// Merge helper command defaults (e.g., inline: { bold: true } for `format bold`).
// Merge helper command defaults (e.g., inline: { bold: 'on' } for `format bold`).
// User-provided values take precedence over defaults.
if (request.defaultInput) {
input = { ...request.defaultInput, ...input };
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/document-api/common-workflows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const plan = {
op: 'format.apply',
where: { by: 'ref', ref },
args: {
marks: { bold: true },
inline: { bold: 'on' },
},
},
],
Expand Down Expand Up @@ -122,7 +122,7 @@ const target = { kind: 'text', blockId: 'p1', range: { start: 0, end: 3 } };
if (caps.operations['format.apply'].available) {
editor.doc.format.apply({
target,
marks: { bold: true },
inline: { bold: 'on' },
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,5 +229,5 @@
}
],
"marker": "{/* GENERATED FILE: DO NOT EDIT. Regenerate via `pnpm run docapi:sync`. */}",
"sourceHash": "722ce545fc7c5373e23246fa7bbbc68b381e30bd8e2bc6c21d1616e6c5395ea9"
"sourceHash": "5454f771b591f831325cc10903af71f01a064277b44a8c252b71855ff2b98a7d"
}
109 changes: 95 additions & 14 deletions apps/docs/document-api/reference/capabilities/get.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,20 @@ _No fields._
```json
{
"format": {
"supportedMarks": [
"bold"
]
"properties": {
"bold": {
"directives": [
"example"
],
"kind": "example"
},
"italic": {
"directives": [
"example"
],
"kind": "example"
}
}
},
"global": {
"comments": {
Expand Down Expand Up @@ -735,21 +746,91 @@ _No fields._
"format": {
"additionalProperties": false,
"properties": {
"supportedMarks": {
"items": {
"enum": [
"bold",
"italic",
"underline",
"strike"
],
"type": "string"
"properties": {
"additionalProperties": false,
"properties": {
"bold": {
"additionalProperties": false,
"properties": {
"directives": {
"items": {
"type": "string"
},
"type": "array"
},
"kind": {
"type": "string"
}
},
"required": [
"kind",
"directives"
],
"type": "object"
},
"italic": {
"additionalProperties": false,
"properties": {
"directives": {
"items": {
"type": "string"
},
"type": "array"
},
"kind": {
"type": "string"
}
},
"required": [
"kind",
"directives"
],
"type": "object"
},
"strike": {
"additionalProperties": false,
"properties": {
"directives": {
"items": {
"type": "string"
},
"type": "array"
},
"kind": {
"type": "string"
}
},
"required": [
"kind",
"directives"
],
"type": "object"
},
"underline": {
"additionalProperties": false,
"properties": {
"directives": {
"items": {
"type": "string"
},
"type": "array"
},
"kind": {
"type": "string"
}
},
"required": [
"kind",
"directives"
],
"type": "object"
}
},
"type": "array"
"type": "object"
}
},
"required": [
"supportedMarks"
"properties"
],
"type": "object"
},
Expand Down
28 changes: 22 additions & 6 deletions apps/docs/document-api/reference/format/apply.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ description: Reference for format.apply
```json
{
"inline": {
"bold": true,
"italic": true
"bold": "on",
"italic": "on"
},
"target": {
"blockId": "block-abc123",
Expand Down Expand Up @@ -116,16 +116,32 @@ _No fields._
"minProperties": 1,
"properties": {
"bold": {
"type": "boolean"
"enum": [
"on",
"off",
"clear"
]
},
"italic": {
"type": "boolean"
"enum": [
"on",
"off",
"clear"
]
},
"strike": {
"type": "boolean"
"enum": [
"on",
"off",
"clear"
]
},
"underline": {
"type": "boolean"
"enum": [
"on",
"off",
"clear"
]
}
},
"type": "object"
Expand Down
10 changes: 5 additions & 5 deletions apps/docs/document-api/reference/format/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: Format operation reference from the canonical Document API contract

[Back to full reference](../index)

Canonical formatting mutation with boolean patch semantics.
Canonical formatting mutation with directive semantics ('on', 'off', 'clear').

| Operation | Member path | Mutates | Idempotency | Tracked | Dry run |
| --- | --- | --- | --- | --- | --- |
Expand All @@ -25,8 +25,8 @@ Canonical formatting mutation with boolean patch semantics.

| Alias method | Canonical operation | Behavior |
| --- | --- | --- |
| `editor.doc.format.bold(...)` | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.apply</code></a></span> | Convenience alias for `format.apply` with `inline.bold: true`. |
| `editor.doc.format.italic(...)` | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.apply</code></a></span> | Convenience alias for `format.apply` with `inline.italic: true`. |
| `editor.doc.format.underline(...)` | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.apply</code></a></span> | Convenience alias for `format.apply` with `inline.underline: true`. |
| `editor.doc.format.strikethrough(...)` | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.apply</code></a></span> | Convenience alias for `format.apply` with `inline.strike: true`. |
| `editor.doc.format.bold(...)` | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.apply</code></a></span> | Convenience alias for `format.apply` with `inline.bold: 'on'`. |
| `editor.doc.format.italic(...)` | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.apply</code></a></span> | Convenience alias for `format.apply` with `inline.italic: 'on'`. |
| `editor.doc.format.underline(...)` | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.apply</code></a></span> | Convenience alias for `format.apply` with `inline.underline: 'on'`. |
| `editor.doc.format.strikethrough(...)` | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.apply</code></a></span> | Convenience alias for `format.apply` with `inline.strike: 'on'`. |

10 changes: 5 additions & 5 deletions apps/docs/document-api/reference/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ The tables below are grouped by namespace.

| Operation | API member path | Description |
| --- | --- | --- |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.apply</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.apply(...)</code></span> | Apply explicit inline style changes (bold, italic, underline, strike) to the target range using boolean patch semantics. |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.apply</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.apply(...)</code></span> | Apply explicit inline style changes (bold, italic, underline, strike) to the target range using directive semantics ('on', 'off', 'clear'). |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/font-size"><code>format.fontSize</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.fontSize(...)</code></span> | Set or unset the font size on the target text range. Pass null to remove. |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/font-family"><code>format.fontFamily</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.fontFamily(...)</code></span> | Set or unset the font family on the target text range. Pass null to remove. |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/color"><code>format.color</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.color(...)</code></span> | Set or unset the text color on the target text range. Pass null to remove. |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/align"><code>format.align</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.align(...)</code></span> | Set or unset paragraph alignment on the block containing the target. Pass null to reset to default. |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.bold</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.bold(...)</code></span> | Convenience alias for `format.apply` with `inline.bold: true`. |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.italic</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.italic(...)</code></span> | Convenience alias for `format.apply` with `inline.italic: true`. |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.underline</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.underline(...)</code></span> | Convenience alias for `format.apply` with `inline.underline: true`. |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.strikethrough</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.strikethrough(...)</code></span> | Convenience alias for `format.apply` with `inline.strike: true`. |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.bold</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.bold(...)</code></span> | Convenience alias for `format.apply` with `inline.bold: 'on'`. |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.italic</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.italic(...)</code></span> | Convenience alias for `format.apply` with `inline.italic: 'on'`. |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.underline</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.underline(...)</code></span> | Convenience alias for `format.apply` with `inline.underline: 'on'`. |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/format/apply"><code>format.strikethrough</code></a></span> | <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.strikethrough(...)</code></span> | Convenience alias for `format.apply` with `inline.strike: 'on'`. |

#### Styles

Expand Down
37 changes: 31 additions & 6 deletions apps/docs/document-api/reference/query/match.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ description: Reference for query.match
| --- | --- | --- | --- |
| `evaluatedRevision` | string | yes | |
| `items` | object(matchKind="text") \\| object(matchKind="node")[] | yes | |
| `meta` | object | yes | |
| `page` | PageInfo | yes | PageInfo |
| `total` | integer | yes | |

Expand Down Expand Up @@ -92,12 +93,20 @@ description: Reference for query.match
"ref": "handle:abc123",
"styleId": "style-001",
"styles": {
"bold": true,
"color": "example",
"highlight": "example",
"italic": true,
"strike": true,
"underline": true
"direct": {
"bold": "on",
"italic": "on",
"strike": "on",
"underline": "on"
},
"effective": {
"bold": true,
"italic": true,
"strike": true,
"underline": true
},
"highlight": "example"
},
"text": "Hello, world."
}
Expand All @@ -119,6 +128,9 @@ description: Reference for query.match
"snippet": "...the quick brown fox..."
}
],
"meta": {
"effectiveResolved": true
},
"page": {
"limit": 50,
"offset": 0,
Expand Down Expand Up @@ -336,6 +348,18 @@ description: Reference for query.match
},
"type": "array"
},
"meta": {
"additionalProperties": false,
"properties": {
"effectiveResolved": {
"type": "boolean"
}
},
"required": [
"effectiveResolved"
],
"type": "object"
},
"page": {
"$ref": "#/$defs/PageInfo"
},
Expand All @@ -348,7 +372,8 @@ description: Reference for query.match
"evaluatedRevision",
"total",
"items",
"page"
"page",
"meta"
],
"type": "object"
}
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/document-engine/sdks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ The SDKs expose all operations from the [Document API](/document-api/overview) p

| Operation | CLI command | Description |
| --- | --- | --- |
| `doc.format.apply` | `format apply` | Apply explicit inline style changes (bold, italic, underline, strike) to the target range using boolean patch semantics. |
| `doc.format.apply` | `format apply` | Apply explicit inline style changes (bold, italic, underline, strike) to the target range using directive semantics ('on', 'off', 'clear'). |
| `doc.format.fontSize` | `format font-size` | Set or unset the font size on the target text range. Pass null to remove. |
| `doc.format.fontFamily` | `format font-family` | Set or unset the font family on the target text range. Pass null to remove. |
| `doc.format.color` | `format color` | Set or unset the text color on the target text range. Pass null to remove. |
Expand Down
8 changes: 4 additions & 4 deletions apps/mcp/src/tools/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import type { SessionManager } from '../session-manager.js';

const STYLES = ['bold', 'italic', 'underline', 'strikethrough'] as const;
const INLINE_BY_STYLE = {
bold: { bold: true },
italic: { italic: true },
underline: { underline: true },
strikethrough: { strike: true },
bold: { bold: 'on' },
italic: { italic: 'on' },
underline: { underline: 'on' },
strikethrough: { strike: 'on' },
} as const;

export function registerFormatTools(server: McpServer, sessions: SessionManager): void {
Expand Down
Loading
Loading