From 5e6a3704cf52ab38cb1f7824666eb4ce08966057 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 7 Sep 2026 03:48:00 +0000 Subject: [PATCH] docs(plugin-editor): compile the README's snippets against the shipped surface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The page's UNGATED_DOCS row read "6 parse diagnostic(s) — blocks fenced `ts` that are bare object literals or elided bodies". Measured with the gate's own analyzer, all six were ONE block: the "Schema API" fence, a TYPE shape written as an object literal, one TS1109 per optional member. There was no elided body anywhere on the page, and the four fences are labelled `typescript`, not `ts`. - The "Schema API" fence becomes a Markdown members table. A fence that re-declares a published type is a private copy of the contract; the table points at `CodeEditorSchema` instead of restating it, and carries the one nuance the old comment blurred — the contract is `language?: string`, and the registration's `inputs` manifest narrows the authoring picker to six ids. - The bare `const schema` literal is bound to `CodeEditorSchema`, with the type import the "TypeScript Support" section already teaches. Unannotated, it had nothing to check against: a real type error injected into it left the gate's reading byte-identical. - The manual-registration loop passes `{ namespace: 'plugin-editor' }`, the third argument this plugin's own registration passes; the two-argument form compiles but is the one `Registry.register` warns is deprecated. - Defaults in the table are the renderer's own destructuring defaults. The page now reads zero, so its ledger row is deleted (6 rows -> 5). The strictness region below the `Fence scanning` banner is byte-identical. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr --- packages/plugin-editor/README.md | 37 ++++++++++++++++++----------- scripts/check-doc-snippet-types.mjs | 2 -- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/packages/plugin-editor/README.md b/packages/plugin-editor/README.md index 1083d74c2e..768ad3b194 100644 --- a/packages/plugin-editor/README.md +++ b/packages/plugin-editor/README.md @@ -22,9 +22,10 @@ pnpm add @object-ui/plugin-editor ```typescript // In your app entry point (e.g., App.tsx or main.tsx) import '@object-ui/plugin-editor'; +import type { CodeEditorSchema } from '@object-ui/plugin-editor'; // Now you can use code-editor type in your schemas -const schema = { +const schema: CodeEditorSchema = { type: 'code-editor', value: 'console.log("Hello, World!");', language: 'javascript', @@ -39,9 +40,11 @@ const schema = { import { editorComponents } from '@object-ui/plugin-editor'; import { ComponentRegistry } from '@object-ui/core'; -// Manually register if needed +// Manually register if needed. The third argument is the namespace this plugin's +// own registration passes (`src/index.tsx`); the two-argument form still compiles, +// but `register` warns that it is the deprecated pattern. Object.entries(editorComponents).forEach(([type, component]) => { - ComponentRegistry.register(type, component); + ComponentRegistry.register(type, component, { namespace: 'plugin-editor' }); }); ``` @@ -63,17 +66,23 @@ const schema: CodeEditorSchema = { ## Schema API -```typescript -{ - type: 'code-editor', - value?: string, // Code content - language?: string, // 'javascript' | 'typescript' | 'python' | 'json' | 'html' | 'css' - theme?: 'vs-dark' | 'light', // Editor theme - height?: string, // e.g., '400px' - readOnly?: boolean, // Read-only mode - className?: string // Tailwind classes -} -``` +`CodeEditorSchema` is declared in `@object-ui/types` and re-exported by this +plugin, so the type an author reads and the schema that validates their document +are one declaration. It extends `BaseSchema`, which is where `className` comes +from. + +| Member | Type | Required | Default | Notes | +| --- | --- | --- | --- | --- | +| `type` | `'code-editor'` | yes | — | The registry key this plugin registers. | +| `value` | `string` | no | `''` | Code content. A host-supplied `value` prop wins over it. | +| `language` | `string` | no | `'javascript'` | The contract is `string`: the renderer forwards it verbatim, so any language id Monaco knows resolves. The registration's `inputs` manifest narrows the authoring picker to `javascript`, `typescript`, `python`, `json`, `html` and `css` — a shortlist, not the accepted set. | +| `theme` | `'vs-dark' \| 'light'` | no | `'vs-dark'` | Closed, unlike `language`. | +| `height` | `string` | no | `'400px'` | Forwarded to Monaco as a CSS length. | +| `readOnly` | `boolean` | no | `false` | Whether the editor refuses edits. | +| `className` | `string` | no | `''` | Tailwind classes, from `BaseSchema`. | + +The defaults above are the renderer's own destructuring defaults +(`src/MonacoImpl.tsx`) — what an omitted key actually produces. ## Lazy Loading Architecture diff --git a/scripts/check-doc-snippet-types.mjs b/scripts/check-doc-snippet-types.mjs index 9e23990d8b..4493205203 100644 --- a/scripts/check-doc-snippet-types.mjs +++ b/scripts/check-doc-snippet-types.mjs @@ -777,8 +777,6 @@ const UNGATED_DOCS = { 'what is left is fragment shape, and no gate reads this page\'s import names.', 'packages/fields/README.md': '2 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; 1 unresolved-module diagnostic(s)', - 'packages/plugin-editor/README.md': - '6 parse diagnostic(s) — blocks fenced `ts` that are bare object literals or elided bodies', 'packages/plugin-map/README.md': '1 parse diagnostic(s) — blocks fenced `ts` that are bare object literals or elided bodies; 1 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; plus TS2322x1 — candidate real defects, un-triaged', 'packages/plugin-markdown/README.md':