Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
feat(ok): <Toggle> descriptor as Accordion's Notion-vocabulary alias (PRD-7774) (#3173)
Abraham4bef786a9e5d
diff --git a/.changeset/toggle-descriptor-alias.md b/.changeset/toggle-descriptor-alias.mdnew file mode 100644index 000000000..d94966f7c--- /dev/null+++ b/.changeset/toggle-descriptor-alias.md@@ -0,0 +1,5 @@+---+'@inkeep/open-knowledge': minor+---++Register `<Toggle>` as a canonical block descriptor — Notion-style vocabulary alias for `<Accordion>`. Same props (`title`, `defaultOpen`, `icon`, `description`, `id`, `name`, children), same expand/collapse component; the two descriptors serialize under their own JSX names so `<Toggle>` and `<Accordion>` both round-trip without rewriting. `/toggle` in the slash menu now inserts a first-class `<Toggle>` instead of routing to `<Accordion>`.diff --git a/packages/app/src/editor/components/componentMap.tsx b/packages/app/src/editor/components/componentMap.tsxindex e2a23e254..727a5a39b 100644--- a/packages/app/src/editor/components/componentMap.tsx+++ b/packages/app/src/editor/components/componentMap.tsx@@ -86,6 +86,13 @@ export const componentMap: Record<string, React.ComponentType<any>> = {// Renders via a cross-origin iframe with `referrerPolicy="no-referrer"`.Embed,Accordion,+ // `Toggle` is Accordion's Notion-vocabulary alias — same render, different+ // stored JSX name. Both descriptors dispatch through the Accordion+ // component; the wrapper injects a `Toggle` title default so an untitled+ // `<Toggle />` renders as "Toggle" in the summary instead of falling+ // through to Accordion.tsx's hardcoded "Accordion" fallback.+ // biome-ignore lint/suspicious/noExplicitAny: mirrors componentMap's heterogeneous prop shape+ Toggle: (props: any) => <Accordion {...props} title={props.title ?? 'Toggle'} />,// `HtmlAlignBlock` — canonical renderer for promoted `<div align>` wrappers// (GitHub-README centered headers). Children stay ordinary editable// blocks; the wrapper only applies text alignment.diff --git a/packages/app/src/editor/slash-command/component-items.test.ts b/packages/app/src/editor/slash-command/component-items.test.tsindex bc700587e..f8a063acc 100644--- a/packages/app/src/editor/slash-command/component-items.test.ts+++ b/packages/app/src/editor/slash-command/component-items.test.ts@@ -61,6 +61,7 @@ describe('getComponentItems (slash menu)', () => {'Mirror Source','PDF','Tabs',+ 'Toggle','Video',].sort(),);@@ -92,6 +93,22 @@ describe('getComponentItems (slash menu)', () => {}});+ test('/toggle query resolves to Toggle, not Accordion', () => {+ // Guards against the alias-collision that shipped in an earlier draft+ // where Accordion.searchTerms carried 'toggle' — the slash menu's+ // stable-sort by registry order would then hand Enter to Accordion+ // and silently ignore the new Toggle descriptor. Toggle's own label+ // ('Toggle') and searchTerms ('toggle', ...) must be the only+ // matches for the literal query 'toggle'.+ const items = getComponentItems();+ const matches = items.filter((i) => {+ const label = i.label.toLowerCase().includes('toggle');+ const alias = (i.aliases ?? []).some((a) => a.toLowerCase().includes('toggle'));+ return label || alias;+ });+ expect(matches.map((m) => m.label)).toEqual(['Toggle']);+ });+test('compat descriptors are absent — fresh inserts are canonical-only', () => {const items = getComponentItems();// The compat descriptors' names: 'CommonMarkImage', 'GFMCallout',@@ -268,11 +285,11 @@ describe('agent-surface ↔ slash-menu filter parity', () => {expect(divergence).toEqual(new Set(SLASH_HIDDEN_CANONICALS));});- test('intersection covers every canonical NOT in either curation set (11 names today)', () => {+ test('intersection covers every canonical NOT in either curation set (12 names today)', () => {const agent = agentCanonicalSet();const slash = slashMenuCanonicalSet();const intersection = new Set([...agent].filter((name) => slash.has(name)));- expect(intersection.size).toBe(11);+ expect(intersection.size).toBe(12);});test('agent surface excludes wildcard descriptor', () => {diff --git a/packages/app/src/editor/slash-command/component-items.tsx b/packages/app/src/editor/slash-command/component-items.tsxindex 7b0a2c4eb..202cecd0c 100644--- a/packages/app/src/editor/slash-command/component-items.tsx+++ b/packages/app/src/editor/slash-command/component-items.tsx@@ -73,6 +73,11 @@ const PREVIEW_CONFIG: Record<string, PreviewConfig> = {props: { title: 'Click to expand', defaultOpen: true },children: 'Hidden content goes here.',},+ Toggle: {+ description: msg`Collapsible content block (Notion-style toggle).`,+ props: { title: 'Click to expand', defaultOpen: true },+ children: 'Hidden content goes here.',+ },img: {description: msg`Embed an image with optional alt text.`,props: { src: imagePreview, alt: 'Sample image' },diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.jsonindex c72329f00..de9385eca 100644--- a/packages/app/src/locales/en/messages.json+++ b/packages/app/src/locales/en/messages.json@@ -2362,6 +2362,7 @@"cRHuuI": ["Couldn't copy path"],"cRm498": ["No schema files in this project yet — create one to start validating."],"cSCbv3": ["BETA"],+ "cT_pW4": ["Collapsible content block (Notion-style toggle)."],"cU-seF": ["Jump to the markdown source for the block at the cursor, centered and highlighted."],diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.poindex 88b4ba391..39685abd2 100644--- a/packages/app/src/locales/en/messages.po+++ b/packages/app/src/locales/en/messages.po@@ -2309,6 +2309,10 @@ msgstr "Collapse graph"msgid "Collapse panel"msgstr "Collapse panel"+#: src/editor/slash-command/component-items.tsx+msgid "Collapsible content block (Notion-style toggle)."+msgstr "Collapsible content block (Notion-style toggle)."+#: src/editor/slash-command/component-items.tsxmsgid "Collapsible section with a clickable summary."msgstr "Collapsible section with a clickable summary."diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.jsonindex b724c0080..97fa7bed1 100644--- a/packages/app/src/locales/pseudo/messages.json+++ b/packages/app/src/locales/pseudo/messages.json@@ -2362,6 +2362,7 @@"cRHuuI": ["Ćōũĺďń'ţ ćōƥŷ ƥàţĥ"],"cRm498": ["Ńō śćĥēḿà ƒĩĺēś ĩń ţĥĩś ƥŕōĴēćţ ŷēţ — ćŕēàţē ōńē ţō śţàŕţ vàĺĩďàţĩńĝ."],"cSCbv3": ["ßĒŢÀ"],+ "cT_pW4": ["Ćōĺĺàƥśĩƀĺē ćōńţēńţ ƀĺōćķ (Ńōţĩōń-śţŷĺē ţōĝĝĺē)."],"cU-seF": ["ĵũḿƥ ţō ţĥē ḿàŕķďōŵń śōũŕćē ƒōŕ ţĥē ƀĺōćķ àţ ţĥē ćũŕśōŕ, ćēńţēŕēď àńď ĥĩĝĥĺĩĝĥţēď."],diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.poindex 5c2b7acd8..5e0782e02 100644--- a/packages/app/src/locales/pseudo/messages.po+++ b/packages/app/src/locales/pseudo/messages.po@@ -2305,6 +2305,10 @@ msgstr ""msgid "Collapse panel"msgstr ""+#: src/editor/slash-command/component-items.tsx+msgid "Collapsible content block (Notion-style toggle)."+msgstr ""+#: src/editor/slash-command/component-items.tsxmsgid "Collapsible section with a clickable summary."msgstr ""diff --git a/packages/core/src/registry/built-ins.ts b/packages/core/src/registry/built-ins.tsindex fdab80971..195bd3e51 100644--- a/packages/core/src/registry/built-ins.ts+++ b/packages/core/src/registry/built-ins.ts@@ -1300,10 +1300,30 @@ export const builtInComponents: JsxComponentMeta[] = [displayName: 'Accordion',description:'Standalone expand/collapse via native HTML5 <details>/<summary>. Group siblings with the `name` prop for exclusive-accordion UX.',- searchTerms: ['toggle', 'accordion', 'expandable', 'details', 'disclosure', 'collapse', 'fold'],+ searchTerms: ['accordion', 'expandable', 'details', 'disclosure', 'collapse', 'fold'],exampleBody: 'Body content revealed when the accordion is expanded.',serialize: (node, ctx) => emitMdxJsx('Accordion', node, ctx, accordionProps),},+ {+ // Toggle is Accordion's Notion-vocabulary alias. Same prop surface, same+ // React component (componentMap['Toggle'] → Accordion); the descriptor+ // exists so authors who reach for `<Toggle …>` in MDX or `/toggle` in the+ // slash menu get a first-class insertion at their preferred name instead+ // of being rewritten to `<Accordion>`. Both descriptors serialize to+ // their own JSX name, so round-trips preserve whichever the author chose.+ name: 'Toggle',+ surface: 'canonical',+ hasChildren: true,+ props: accordionProps,+ icon: 'ChevronRight',+ category: 'content',+ displayName: 'Toggle',+ description:+ 'Standalone expand/collapse block (Notion-style). Same render + props as `<Accordion>` — pick whichever vocabulary matches the vault.',+ searchTerms: ['toggle', 'collapsible', 'expand', 'details', 'disclosure', 'fold'],+ exampleBody: 'Body content revealed when the toggle is expanded.',+ serialize: (node, ctx) => emitMdxJsx('Toggle', node, ctx, accordionProps),+ },// Tabs + Tab canonical pair — Notion-style pill strip + active-panel// container. Pair of jsxComponent descriptors; Tabs holds Tab children,// each Tab holds arbitrary block content.diff --git a/packages/core/src/registry/canonical-compat.test.ts b/packages/core/src/registry/canonical-compat.test.tsindex 73966c7d5..4cccee1ef 100644--- a/packages/core/src/registry/canonical-compat.test.ts+++ b/packages/core/src/registry/canonical-compat.test.ts@@ -28,16 +28,18 @@ describe('canonical/compat split — registry shape', () => {}});- test('exactly 15 canonical descriptors (5-pack + Math + MermaidFence + Pdf + File + Tabs + Tab + Embed + Mirror + MirrorSource + HtmlAlignBlock)', () => {- expect(canonicalDescriptors.length).toBe(15);+ test('exactly 16 canonical descriptors (5-pack + Math + MermaidFence + Pdf + File + Tabs + Tab + Embed + Mirror + MirrorSource + HtmlAlignBlock + Toggle)', () => {+ expect(canonicalDescriptors.length).toBe(16);// Media canonicals with a matching HTML primitive are lowercase// (img/video/audio). Non-native canonicals stay capitalized// (Callout, Accordion, Math, MermaidFence, Pdf, File, Tabs, Tab,- // Embed, Mirror, MirrorSource). The Mermaid canonical is named+ // Embed, Mirror, MirrorSource, Toggle). The Mermaid canonical is named// `MermaidFence` because the only authoring form is the ` ```mermaid `// fence — `Mermaid` is intentionally NOT a registered name so legacy// `<Mermaid />` JSX content falls through to the wildcard. `Mirror` +- // `MirrorSource` are the master/copy block-transclusion pair.+ // `MirrorSource` are the master/copy block-transclusion pair. `Toggle`+ // is Accordion's Notion-vocabulary alias — same component, distinct+ // stored JSX name.expect(canonicalDescriptors.map((m) => m.name).sort()).toEqual(['Accordion',@@ -52,6 +54,7 @@ describe('canonical/compat split — registry shape', () => {'Pdf','Tab','Tabs',+ 'Toggle','audio','img','video',diff --git a/packages/core/src/registry/projection.test.ts b/packages/core/src/registry/projection.test.tsindex 0ce0298b5..9165d1eea 100644--- a/packages/core/src/registry/projection.test.ts+++ b/packages/core/src/registry/projection.test.ts@@ -24,9 +24,9 @@ const PARSE_EXTENSIONS = [mdx()];const PARSE_MDAST_EXTENSIONS = [mdxFromMarkdown()];describe('getCanonicalDescriptors (broad filter)', () => {- test('returns 15 canonicals (matches built-ins snapshot)', () => {+ test('returns 16 canonicals (matches built-ins snapshot)', () => {const canonicals = getCanonicalDescriptors();- expect(canonicals.length).toBe(15);+ expect(canonicals.length).toBe(16);});test('excludes compat surfaces', () => {@@ -48,8 +48,8 @@ describe('getCanonicalDescriptors (broad filter)', () => {});describe('getAgentCanonicalDescriptors (JSX-only agent surface)', () => {- test('returns 13 canonicals — broad set minus fence- and html-kind', () => {- expect(getAgentCanonicalDescriptors().length).toBe(13);+ test('returns 14 canonicals — broad set minus fence- and html-kind', () => {+ expect(getAgentCanonicalDescriptors().length).toBe(14);});test('excludes MermaidFence (no JSX form exists; agents author the fence directly)', () => {diff --git a/packages/core/src/registry/registry.test.ts b/packages/core/src/registry/registry.test.tsindex 707aee8a4..91c7af0a1 100644--- a/packages/core/src/registry/registry.test.ts+++ b/packages/core/src/registry/registry.test.ts@@ -4,8 +4,8 @@ import { builtInComponents, createRegistry, wildcardMeta } from './index.ts';import type { JsxComponentMeta } from './types.ts';describe('createRegistry', () => {- test('returns the 15 canonical + 9 compat descriptors + wildcard', () => {- // 15 canonicals (Callout, Image, Video, Audio, Accordion, Math,+ test('returns the 16 canonical + 9 compat descriptors + wildcard', () => {+ // 16 canonicals (Callout, Image, Video, Audio, Accordion, Toggle, Math,// MermaidFence, Pdf, File, Tabs, Tab, Embed, Mirror, MirrorSource,// HtmlAlignBlock — the `<div align>` HTML form is canonical, per the// MermaidFence fence-only precedent)@@ -24,7 +24,7 @@ describe('createRegistry', () => {// through to the wildcard.const registry = createRegistry();const entries = [...registry.entries()];- expect(entries.length).toBe(25);+ expect(entries.length).toBe(26);});test('get returns registered component by name', () => {@@ -92,6 +92,7 @@ describe('createRegistry', () => {expect(registry.has('video')).toBe(true);expect(registry.has('audio')).toBe(true);expect(registry.has('Accordion')).toBe(true);+ expect(registry.has('Toggle')).toBe(true);expect(registry.has('Math')).toBe(true);expect(registry.has('MermaidFence')).toBe(true);// `<Mermaid />` JSX has no descriptor (canonical is named@@ -118,11 +119,11 @@ describe('createRegistry', () => {});describe('builtInComponents manifest', () => {- test('contains 15 canonical + 9 compat entries (5-pack + Math + MermaidFence + Pdf + File + Tabs + Tab + Embed + Mirror + MirrorSource canonicals; source-form preservation + math syntax + wiki-embed compats; Mermaid is fence-only)', () => {- expect(builtInComponents.length).toBe(24);+ test('contains 16 canonical + 9 compat entries (5-pack + Math + MermaidFence + Pdf + File + Tabs + Tab + Embed + Mirror + MirrorSource + HtmlAlignBlock + Toggle canonicals; source-form preservation + math syntax + wiki-embed compats; Mermaid is fence-only)', () => {+ expect(builtInComponents.length).toBe(25);const canonical = builtInComponents.filter((m) => m.surface === 'canonical');const compat = builtInComponents.filter((m) => m.surface === 'compat');- expect(canonical.length).toBe(15);+ expect(canonical.length).toBe(16);expect(compat.length).toBe(9);});