Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

feat(ok): inline JSX renders as live, editable widgets (#3028)

Abraham7d98389b436e
diff --git a/.changeset/inline-descriptor-dispatch-mvp.md b/.changeset/inline-descriptor-dispatch-mvp.md
new file mode 100644
index 000000000..a8b3db1a5
--- /dev/null
+++ b/.changeset/inline-descriptor-dispatch-mvp.md
@@ -0,0 +1,6 @@
+---
+'@inkeep/open-knowledge-core': minor
+'@inkeep/open-knowledge-app': minor
+---
+
+Inline JSX components now render as real widgets. Write `<Callout type="warning" title="heads up" />` in the middle of a sentence and it renders live instead of showing source text — click it to edit its properties in a popover, and the markdown on disk updates cleanly. Paired bodies (`<Callout>text</Callout>`) render too, and unregistered component names keep showing as plain source.
diff --git a/knip.config.ts b/knip.config.ts
index f004e6bc3..13582ee18 100644
--- a/knip.config.ts
+++ b/knip.config.ts
@@ -123,9 +123,7 @@ export default {
'packages/server': {
entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],
project: 'src/**',
- ignoreDependencies: [
- '@types/shell-quote',
- ],
+ ignoreDependencies: ['@types/shell-quote'],
},
'packages/cli': {
entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],
diff --git a/packages/app/src/editor/extensions/JsxInlineView.dom.test.tsx b/packages/app/src/editor/extensions/JsxInlineView.dom.test.tsx
new file mode 100644
index 000000000..f6642b9d3
--- /dev/null
+++ b/packages/app/src/editor/extensions/JsxInlineView.dom.test.tsx
@@ -0,0 +1,145 @@
+/**
+ * Pins the registered-inline-widget contract:
+ *
+ * 1. A `jsxInline` node with `componentName` renders the descriptor's
+ * component (not source text); the thin shape still renders source.
+ * 2. NodeSelection on the widget opens the PropPanel popover.
+ * 3. A PropPanel commit rewrites `props` and stamps `sourceDirty` so the
+ * serializer reconstructs from the edit.
+ *
+ * Tier: `.dom.test.tsx` (jsdom) — drives a mounted TipTap Editor.
+ */
+
+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
+import type { Editor } from '@tiptap/core';
+import { EditorContent, useEditor } from '@tiptap/react';
+import { useEffect, useState } from 'react';
+import { createPortal } from 'react-dom';
+import { afterEach, describe, expect, test } from 'vitest';
+import { sharedExtensions } from './shared';
+
+// React NodeViews only mount under the @tiptap/react host (`EditorContent`),
+// so the harness renders a real host instead of a bare `new Editor()`.
+// Portalled per the H6 cross-doc DOM bleed contract (no-unportaled-editor-content).
+function Host({ content, onEditor }: { content: object; onEditor: (e: Editor) => void }) {
+ const editor = useEditor({
+ extensions: sharedExtensions,
+ editable: true,
+ content,
+ immediatelyRender: true,
+ });
+ const [portalTarget] = useState(() => document.createElement('div'));
+ useEffect(() => {
+ document.body.appendChild(portalTarget);
+ return () => portalTarget.remove();
+ }, [portalTarget]);
+ if (editor) onEditor(editor);
+ return createPortal(
+ // biome-ignore lint/plugin/no-unportaled-editor-content: portalled per the H6 contract — this IS the sanctioned createPortal shape, in a test harness with a per-render exclusive target
+ <EditorContent editor={editor} />,
+ portalTarget,
+ );
+}
+
+function mountEditor(content: object): {
+ getEditor: () => Editor;
+ view: ReturnType<typeof render>;
+} {
+ let captured: Editor | null = null;
+ const view = render(
+ <Host
+ content={content}
+ onEditor={(e) => {
+ captured = e;
+ }}
+ />,
+ );
+ return {
+ getEditor: () => {
+ if (!captured) throw new Error('editor not mounted');
+ return captured;
+ },
+ view,
+ };
+}
+
+function docWithInline(attrs: Record<string, unknown>, text?: string) {
+ return {
+ type: 'doc',
+ content: [
+ {
+ type: 'paragraph',
+ content: [
+ { type: 'text', text: 'before ' },
+ {
+ type: 'jsxInline',
+ attrs,
+ ...(text ? { content: [{ type: 'text', text }] } : {}),
+ },
+ { type: 'text', text: ' after' },
+ ],
+ },
+ ],
+ };
+}
+
+afterEach(cleanup);
+
+describe('JsxInlineView', () => {
+ test('a registered componentName renders the descriptor widget', async () => {
+ mountEditor(
+ docWithInline({
+ componentName: 'Callout',
+ sourceRaw: '<Callout type="warning" title="careful" />',
+ props: { type: 'warning', title: 'careful' },
+ }),
+ );
+ await waitFor(() => {
+ // The React NodeView's widget span, not renderHTML's fallback DOM.
+ expect(document.querySelector('[data-jsx-inline-widget]')).toBeTruthy();
+ });
+ // The rendered widget shows the Callout chrome, not the raw source.
+ expect(document.body.textContent).not.toContain('<Callout');
+ });
+
+ test('the thin shape still renders raw source text', async () => {
+ mountEditor(docWithInline({ componentName: '' }, '<Unregistered />'));
+ await waitFor(() => {
+ expect(document.body.textContent).toContain('<Unregistered />');
+ });
+ });
+
+ test('NodeSelection opens the PropPanel popover and a commit stamps sourceDirty', async () => {
+ const { getEditor } = mountEditor(
+ docWithInline({
+ componentName: 'Callout',
+ sourceRaw: '<Callout type="warning" title="careful" />',
+ props: { type: 'warning', title: 'careful' },
+ }),
+ );
+ await waitFor(() => {
+ expect(document.querySelector('[data-jsx-inline-widget]')).toBeTruthy();
+ });
+ const editor = getEditor();
+ {
+ // The widget sits after 'before ' (pos 1 + 7 text chars).
+ editor.commands.setNodeSelection(1 + 'before '.length);
+
+ const titleInput = await screen.findByDisplayValue('careful');
+ fireEvent.change(titleInput, { target: { value: 'updated' } });
+
+ await waitFor(() => {
+ let dirty = false;
+ let title = '';
+ editor.state.doc.descendants((node) => {
+ if (node.type.name === 'jsxInline') {
+ dirty = node.attrs.sourceDirty === true;
+ title = (node.attrs.props as Record<string, string>).title;
+ }
+ });
+ expect(dirty).toBe(true);
+ expect(title).toBe('updated');
+ });
+ }
+ });
+});
diff --git a/packages/app/src/editor/extensions/JsxInlineView.tsx b/packages/app/src/editor/extensions/JsxInlineView.tsx
new file mode 100644
index 000000000..82e02b84b
--- /dev/null
+++ b/packages/app/src/editor/extensions/JsxInlineView.tsx
@@ -0,0 +1,216 @@
+/**
+ * JsxInlineView — descriptor-dispatched inline NodeView.
+ *
+ * Two branches:
+ * - `componentName` set → registered inline descriptor. Renders the
+ * descriptor's React component with sanitized structured props (paired
+ * bodies arrive as `props.children`). Widget is atomic
+ * (contentEditable={false}) so users can't drift the body from sourceRaw.
+ * Click selects the node (NodeSelection) and opens a PropPanel popover —
+ * the same selection-sync + position-targeted-commit contract as
+ * MathInlineView, with `sourceDirty: true` on every prop write so the
+ * serializer reconstructs from the edit instead of re-emitting stale
+ * sourceRaw. Wrapped in an ErrorBoundary that emits the shared
+ * `jsx-render-failure` telemetry event, matching the block
+ * `JsxComponentView` contract.
+ * - `componentName === ''` → thin shape. The text children carry the raw
+ * source; surface them via a plain span so unregistered inline JSX still
+ * round-trips as visible source text.
+ */
+import { incrementJsxRenderFailure } from '@inkeep/open-knowledge-core';
+import { Trans } from '@lingui/react/macro';
+import type { NodeViewProps } from '@tiptap/core';
+import { NodeSelection, TextSelection } from '@tiptap/pm/state';
+import { NodeViewContent, NodeViewWrapper } from '@tiptap/react';
+import { useEffect, useRef, useState } from 'react';
+import { ErrorBoundary } from 'react-error-boundary';
+import { Button } from '../../components/ui/button.tsx';
+import { Popover, PopoverContent, PopoverTrigger } from '../../components/ui/popover.tsx';
+import { PropPanel } from '../components/PropPanel.tsx';
+import { getDescriptor } from '../registry/index.ts';
+import { extractPrimitiveProps, stableHash } from './JsxComponentView.tsx';
+
+export function JsxInlineView(viewProps: NodeViewProps) {
+ const { node } = viewProps;
+ const name = (node.attrs.componentName as string) || '';
+
+ if (!name) {
+ return (
+ <NodeViewWrapper as="span" data-jsx-inline="">
+ <NodeViewContent<'span'> as="span" />
+ </NodeViewWrapper>
+ );
+ }
+
+ return <RegisteredInlineView {...viewProps} name={name} />;
+}
+
+function RegisteredInlineView({
+ node,
+ selected,
+ editor,
+ getPos,
+ name,
+}: NodeViewProps & { name: string }) {
+ const descriptor = getDescriptor(name);
+ const { Component } = descriptor;
+ const [popoverOpen, setPopoverOpen] = useState(false);
+ const wasSelected = useRef(false);
+
+ // Route props through the shared extractor so URL-schemes / dangerous
+ // handlers / `dangerouslySetInnerHTML` get stripped before render — same
+ // sanitization contract as JsxComponentView.
+ const primitiveProps = extractPrimitiveProps(node.attrs, descriptor.reactNodePropNames);
+ // The paired body is captured as a plain STRING in `props.children`; the
+ // extractor strips reactNode-classified props, so re-attach it — a string
+ // child is inert (no elements, no handlers) and is exactly what the
+ // source `<Name>body</Name>` said.
+ const bodyText = (node.attrs.props as Record<string, unknown> | undefined)?.children;
+ if (typeof bodyText === 'string' && bodyText !== '') {
+ (primitiveProps as Record<string, unknown>).children = bodyText;
+ }
+ // `stableHash` sorts keys recursively so a props re-serialization that
+ // reorders insertion order doesn't remount the ErrorBoundary mid-render.
+ const resetKey = `${descriptor.name}::${stableHash(primitiveProps)}`;
+
+ // Popover follows a NodeSelection at THIS widget's position, driven off
+ // the editor's selectionUpdate event. MathInlineView gates on TipTap's
+ // `selected` prop instead; that prop is true for any range selection
+ // crossing the widget (drag-select, Cmd+A) and its delivery is unreliable
+ // for jsxInline nested inside a jsxComponent's children — the
+ // position-exact check covers both, hence the deliberate divergence. Open on select, close on
+ // navigate-away; Radix handles Escape/outside-click on its own.
+ useEffect(() => {
+ const sync = () => {
+ const p = typeof getPos === 'function' ? getPos() : undefined;
+ const sel = editor.state.selection;
+ const mine = sel instanceof NodeSelection && typeof p === 'number' && sel.from === p;
+ if (mine && !wasSelected.current) setPopoverOpen(true);
+ else if (!mine && wasSelected.current) setPopoverOpen(false);
+ wasSelected.current = mine;
+ };
+ editor.on('selectionUpdate', sync);
+ sync();
+ return () => {
+ editor.off('selectionUpdate', sync);
+ };
+ }, [editor, getPos]);
+
+ const structuredProps = (node.attrs.props ?? {}) as Record<string, unknown>;
+ // `children` is the captured paired body, not a PropDef — PropPanel only
+ // renders descriptor-declared props, so it never surfaces; keep it out of
+ // the values map anyway so a future PropDef named `children` can't
+ // accidentally bind to it.
+ const { children: _body, ...panelValues } = structuredProps;
+
+ return (
+ <NodeViewWrapper
+ as="span"
+ data-jsx-inline=""
+ data-component-name={name}
+ contentEditable={false}
+ className={selected ? 'jsx-inline-selected' : undefined}
+ >
+ <Popover open={popoverOpen} onOpenChange={setPopoverOpen}>
+ <PopoverTrigger asChild>
+ {/* Click → NodeSelection is handled PM-natively by the extension's
+ handleClickOn plugin (see jsx-inline.ts) — a React handler here
+ loses the race against PM's own mousedown handling. */}
+ <span data-jsx-inline-widget="">
+ <ErrorBoundary
+ resetKeys={[resetKey]}
+ onError={(error, info) => {
+ const err = error instanceof Error ? error : new Error(String(error));
+ console.warn(
+ JSON.stringify({
+ event: 'jsx-render-failure',
+ component: descriptor.name === '*' ? 'wildcard' : descriptor.name,
+ rawComponentName: name.slice(0, 200),
+ error: String(err),
+ stack: info.componentStack,
+ }),
+ );
+ incrementJsxRenderFailure(descriptor.name);
+ }}
+ fallbackRender={() => (
+ <span className="text-xs font-mono text-destructive">[{name}]</span>
+ )}
+ >
+ <Component {...primitiveProps} />
+ </ErrorBoundary>
+ </span>
+ </PopoverTrigger>
+ <PopoverContent
+ className="z-[60] w-72 p-3"
+ side="bottom"
+ align="start"
+ onOpenAutoFocus={(e) => {
+ // Let PropPanel's autoFocus land on its first input.
+ e.preventDefault();
+ }}
+ onCloseAutoFocus={(e) => {
+ // Hand focus back to the editor with the caret AFTER the widget
+ // so the author keeps typing — MathInlineView's dismiss contract.
+ e.preventDefault();
+ // Radix fires this async on unmount too — after teardown the
+ // editor is destroyed and `editor.view` is the throwing proxy.
+ if (editor.isDestroyed) return;
+ const p = typeof getPos === 'function' ? getPos() : undefined;
+ if (typeof p === 'number') {
+ const state = editor.state;
+ const widget = state.doc.nodeAt(p);
+ if (widget?.type.name === 'jsxInline') {
+ const after = p + widget.nodeSize;
+ if (after <= state.doc.content.size) {
+ editor.view.dispatch(
+ state.tr.setSelection(TextSelection.create(state.doc, after)),
+ );
+ }
+ }
+ }
+ editor.view.focus();
+ }}
+ >
+ <div className="text-xs font-medium text-muted-foreground mb-2">
+ <Trans>{descriptor.displayName ?? name} Properties</Trans>
+ </div>
+ <PropPanel
+ descriptor={descriptor}
+ values={panelValues}
+ onChange={(propName, value) => {
+ // Target by position, not selection — the popover input holds
+ // DOM focus, so selection-based updateAttributes would no-op.
+ // Re-apply the NodeSelection after the markup change so the
+ // selection-sync effect doesn't dismiss the popover on the
+ // first keystroke (MathInlineView's commit contract).
+ const p = typeof getPos === 'function' ? getPos() : undefined;
+ if (typeof p !== 'number') return;
+ const curNode = editor.state.doc.nodeAt(p);
+ if (!curNode || curNode.type.name !== 'jsxInline') return;
+ const nextProps = { ...curNode.attrs.props, [propName]: value };
+ // `sourceDirty: true` routes the serializer onto the
+ // reconstruct-from-props path — without it the stale
+ // sourceRaw would be re-emitted and the edit silently lost.
+ const tr = editor.state.tr.setNodeMarkup(p, null, {
+ ...curNode.attrs,
+ props: nextProps,
+ sourceDirty: true,
+ });
+ tr.setSelection(NodeSelection.create(tr.doc, p));
+ editor.view.dispatch(tr);
+ }}
+ onDismiss={() => setPopoverOpen(false)}
+ />
+ <Button
+ variant="secondary"
+ size="sm"
+ className="mt-2 w-full"
+ onClick={() => setPopoverOpen(false)}
+ >
+ <Trans>Done</Trans>
+ </Button>
+ </PopoverContent>
+ </Popover>
+ </NodeViewWrapper>
+ );
+}
diff --git a/packages/app/src/editor/extensions/jsx-inline.ts b/packages/app/src/editor/extensions/jsx-inline.ts
new file mode 100644
index 000000000..8ef297f98
--- /dev/null
+++ b/packages/app/src/editor/extensions/jsx-inline.ts
@@ -0,0 +1,74 @@
+/**
+ * App-specific JsxInline extension — extends core with React NodeView.
+ *
+ * The core JsxInline handles schema + markdown. This version adds the
+ * React NodeView renderer that dispatches to the descriptor registry so
+ * registered inline components (`<Callout />`, etc.) render as widgets
+ * instead of source text. Mirrors the shape of `./jsx-component.ts`.
+ */
+import { JsxInline as BaseJsxInline } from '@inkeep/open-knowledge-core';
+import { NodeSelection, Plugin } from '@tiptap/pm/state';
+import { ReactNodeViewRenderer } from '@tiptap/react';
+import { JsxInlineView } from './JsxInlineView';
+
+export const JsxInline = BaseJsxInline.extend<{ docName: string }>({
+ addOptions() {
+ return {
+ ...this.parent?.(),
+ docName: '',
+ };
+ },
+
+ addNodeView() {
+ return ReactNodeViewRenderer(JsxInlineView);
+ },
+
+ addProseMirrorPlugins() {
+ return [
+ // Click on a REGISTERED inline widget → NodeSelection (which opens the
+ // PropPanel popover via the view's selection-sync). PM-native
+ // handleClickOn because PM's own mousedown handling wins over React
+ // synthetic handlers on the node view DOM — a React onMouseDown never
+ // fires reliably here. Thin-shape nodes keep default text-caret
+ // behavior (their source text is editable prose).
+ new Plugin({
+ props: {
+ // DOM-anchored: clicks land on the widget's inner chrome and PM's
+ // click-position mapping skips the contentEditable=false subtree,
+ // so `handleClickOn` never surfaces the jsxInline node. Resolve
+ // the node from the clicked element instead and select it —
+ // mousedown (not click) so PM's own caret placement never runs.
+ handleDOMEvents: {
+ mousedown(view, event) {
+ const target = event.target;
+ if (!(target instanceof Element)) return false;
+ const el = target.closest('[data-jsx-inline][data-component-name]');
+ if (!el || !view.dom.contains(el)) return false;
+ if (!el.getAttribute('data-component-name')) return false;
+ let nodePos: number | null = null;
+ try {
+ const inside = view.posAtDOM(el, 0);
+ for (const candidate of [inside - 1, inside]) {
+ const node = candidate >= 0 ? view.state.doc.nodeAt(candidate) : null;
+ if (node?.type.name === 'jsxInline' && node.attrs.componentName) {
+ nodePos = candidate;
+ break;
+ }
+ }
+ } catch {
+ return false;
+ }
+ if (nodePos === null) return false;
+ event.preventDefault();
+ view.dispatch(
+ view.state.tr.setSelection(NodeSelection.create(view.state.doc, nodePos)),
+ );
+ view.focus();
+ return true;
+ },
+ },
+ },
+ }),
+ ];
+ },
+});
diff --git a/packages/app/src/editor/extensions/shared.ts b/packages/app/src/editor/extensions/shared.ts
index 1ee3ef3f1..94ae1b21b 100644
--- a/packages/app/src/editor/extensions/shared.ts
+++ b/packages/app/src/editor/extensions/shared.ts
@@ -36,6 +36,7 @@ import { HeadingAnchors } from './heading-anchors';
import { ImageInlineZoom } from './image-inline-zoom';
import { InternalLink } from './internal-link';
import { JsxComponent } from './jsx-component';
+import { JsxInline } from './jsx-inline';
import { MathInline } from './math-inline';
import { RawMdxFallback } from './raw-mdx-fallback';
import { SelectionStatePlugin } from './selection-state-plugin';
@@ -73,6 +74,7 @@ export const SLASH_ITEM_SOURCES = [
export const sharedExtensions = [
...coreExtensions.map((ext) => {
if (ext.name === 'jsxComponent') return JsxComponent;
+ if (ext.name === 'jsxInline') return JsxInline;
// Spread core's options so any future `ImageSrcFidelity.configure({
// ... })` addition in `core/src/extensions/shared.ts` flows through
// the `.extend()` boundary unchanged. The explicit `inline: true`
diff --git a/packages/app/src/editor/extensions/source-dirty-observer.ts b/packages/app/src/editor/extensions/source-dirty-observer.ts
index 4b1735b61..c47ced88c 100644
--- a/packages/app/src/editor/extensions/source-dirty-observer.ts
+++ b/packages/app/src/editor/extensions/source-dirty-observer.ts
@@ -17,7 +17,9 @@
* Only user-intent transactions (keyboard, PropPanel, paste, drag-drop)
* produce PM transactions without ySyncPluginKey meta — these mark dirty.
*
- * jsxInline is excluded (no sourceDirty attr).
+ * jsxInline dirty-marking is owned by JsxInlineView's PropPanel commit
+ * (position-targeted `setNodeMarkup` with `sourceDirty: true`), not this
+ * observer — inline widgets are atomic, so typing never lands inside them.
*/
import { Extension } from '@tiptap/core';
diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.json
index fc1892dcf..a1107602d 100644
--- a/packages/app/src/locales/en/messages.json
+++ b/packages/app/src/locales/en/messages.json
@@ -2695,6 +2695,7 @@
"hxBHxQ": ["A line with a footnote<0><1>[1]</1></0> and a definition shown below."],
"hxEUVJ": ["Initialize ", ["selectedPackName"]],
"hxYFzm": ["Full sync — your commits push and remote changes pull automatically."],
+ "hxnF0I": [["0"], " Properties"],
"hyCxJY": ["Open that worktree instead"],
"hynz2K": ["Download started"],
"i-ShMB": ["Diagram"],
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index d8bf2dc2e..bcb80f785 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -281,6 +281,11 @@ msgstr "{0} of {1} projects selected"
msgid "{0} of {1} selected"
msgstr "{0} of {1} selected"
+#. placeholder {0}: descriptor.displayName ?? name
+#: src/editor/extensions/JsxInlineView.tsx
+msgid "{0} Properties"
+msgstr "{0} Properties"
+
#. placeholder {0}: hostLabel(h)
#. placeholder {1}: hostLabel(h)
#. placeholder {2}: skill?.name ?? ''
@@ -3897,6 +3902,7 @@ msgstr "done"
#: src/components/PublishToGitHubDialog.tsx
#: src/components/ReportBugDialogBody.tsx
#: src/editor/extensions/JsxComponentView.tsx
+#: src/editor/extensions/JsxInlineView.tsx
#: src/editor/extensions/MathInlineView.tsx
#: src/editor/slash-command/items.tsx
msgid "Done"
diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.json
index ac3230d65..d998859a8 100644
--- a/packages/app/src/locales/pseudo/messages.json
+++ b/packages/app/src/locales/pseudo/messages.json
@@ -2695,6 +2695,7 @@
"hxBHxQ": ["À ĺĩńē ŵĩţĥ à ƒōōţńōţē<0><1>[1]</1></0> àńď à ďēƒĩńĩţĩōń śĥōŵń ƀēĺōŵ."],
"hxEUVJ": ["Ĩńĩţĩàĺĩźē ", ["selectedPackName"]],
"hxYFzm": ["Ƒũĺĺ śŷńć — ŷōũŕ ćōḿḿĩţś ƥũśĥ àńď ŕēḿōţē ćĥàńĝēś ƥũĺĺ àũţōḿàţĩćàĺĺŷ."],
+ "hxnF0I": [["0"], " Ƥŕōƥēŕţĩēś"],
"hyCxJY": ["Ōƥēń ţĥàţ ŵōŕķţŕēē ĩńśţēàď"],
"hynz2K": ["Ďōŵńĺōàď śţàŕţēď"],
"i-ShMB": ["Ďĩàĝŕàḿ"],
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index d7750eb5a..d80a6b437 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -281,6 +281,11 @@ msgstr ""
msgid "{0} of {1} selected"
msgstr ""
+#. placeholder {0}: descriptor.displayName ?? name
+#: src/editor/extensions/JsxInlineView.tsx
+msgid "{0} Properties"
+msgstr ""
+
#. placeholder {0}: hostLabel(h)
#. placeholder {1}: hostLabel(h)
#. placeholder {2}: skill?.name ?? ''
@@ -3893,6 +3898,7 @@ msgstr ""
#: src/components/PublishToGitHubDialog.tsx
#: src/components/ReportBugDialogBody.tsx
#: src/editor/extensions/JsxComponentView.tsx
+#: src/editor/extensions/JsxInlineView.tsx
#: src/editor/extensions/MathInlineView.tsx
#: src/editor/slash-command/items.tsx
msgid "Done"
diff --git a/packages/app/tests/integration/clipboard-dispatcher-reorder.test.ts b/packages/app/tests/integration/clipboard-dispatcher-reorder.test.ts
index 2b428f516..45e68b081 100644
--- a/packages/app/tests/integration/clipboard-dispatcher-reorder.test.ts
+++ b/packages/app/tests/integration/clipboard-dispatcher-reorder.test.ts
@@ -121,10 +121,12 @@ describe('WYSIWYG dispatcher reorder — OK→OK <img/> JSX preserves descriptor
describe('WYSIWYG dispatcher reorder — OK→OK <Callout> JSX preserves source bytes', () => {
test('single-line text/plain `<Callout type="note">body</Callout>` + data-pm-slice html → jsxInline preserves source', () => {
// Single-line MDX JSX with body + closing tag on one line cannot
- // promote to block-level jsxComponent (MDX parsing rule). It parses
- // as `jsxInline` whose text node is the verbatim source — bytes are
- // preserved. The dispatcher reorder ensures the markdown path runs
- // (yielding canonical jsxInline) instead of falling to Branch C
+ // promote to block-level jsxComponent (MDX parsing rule). Registered
+ // inline descriptors (`Callout` here) route through jsxInline with
+ // structured attrs — the raw bytes live on `sourceRaw` (pristine
+ // round-trip anchor); the body text renders through the descriptor's
+ // React component. The dispatcher reorder ensures the markdown path
+ // runs (yielding canonical jsxInline) instead of falling to Branch C
// where CodeBlockFidelity's `<pre>` parseDOM would steal the slice.
const paste = createHandlePaste({ mdManager });
const { view, captured } = fakeView();
@@ -137,11 +139,11 @@ describe('WYSIWYG dispatcher reorder — OK→OK <Callout> JSX preserves source
}),
);
expect(captured.branch).toBe('replaceSelection');
- // jsxInline shape: paragraph > jsxInline > text(source)
+ // jsxInline shape: paragraph > jsxInline (componentName='Callout', sourceRaw = raw source)
const jsxInline = findFirstNode(captured.json, 'jsxInline');
expect(jsxInline).toBeDefined();
- const textNode = jsxInline?.content?.[0];
- expect(textNode?.text).toBe('<Callout type="note">body</Callout>');
+ expect(jsxInline?.attrs?.componentName).toBe('Callout');
+ expect(jsxInline?.attrs?.sourceRaw).toBe('<Callout type="note">body</Callout>');
// No codeBlock should appear — that's the regression Branch C would cause.
expect(findFirstNode(captured.json, 'codeBlock')).toBeUndefined();
});
diff --git a/packages/core/schema-snapshot.json b/packages/core/schema-snapshot.json
index ed9b65742..fe321347c 100644
--- a/packages/core/schema-snapshot.json
+++ b/packages/core/schema-snapshot.json
@@ -311,7 +311,32 @@
"isolating": true
},
"jsxInline": {
- "attrs": {},
+ "attrs": {
+ "attributes": {
+ "hasDefault": true,
+ "default": []
+ },
+ "componentName": {
+ "hasDefault": true,
+ "default": ""
+ },
+ "kind": {
+ "hasDefault": true,
+ "default": "element"
+ },
+ "props": {
+ "hasDefault": true,
+ "default": {}
+ },
+ "sourceDirty": {
+ "hasDefault": true,
+ "default": false
+ },
+ "sourceRaw": {
+ "hasDefault": true,
+ "default": ""
+ }
+ },
"content": "text*",
"marks": "",
"group": "inline",
diff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.ts
index dfd95ef49..d7a845280 100644
--- a/packages/core/src/bridge/bind-frontmatter-doc.ts
+++ b/packages/core/src/bridge/bind-frontmatter-doc.ts
@@ -1,4 +1,3 @@
-
import type * as Y from 'yjs';
import type { Err, Ok, Result } from '../config/result.ts';
import { type FrontmatterValidationError, toFrontmatterIssue } from '../frontmatter/errors.ts';
diff --git a/packages/core/src/bridge/bridge-invariant.ts b/packages/core/src/bridge/bridge-invariant.ts
index 8bfdb40cd..005627195 100644
--- a/packages/core/src/bridge/bridge-invariant.ts
+++ b/packages/core/src/bridge/bridge-invariant.ts
@@ -1,4 +1,3 @@
-
import { fnv1aDigest } from './hash-util.ts';
export type BridgeInvariantSite = 'observer-b' | 'persistence' | 'test-harness';
diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.ts
index 2a597ec3d..f4cc8a286 100644
--- a/packages/core/src/bridge/compose.ts
+++ b/packages/core/src/bridge/compose.ts
@@ -1,4 +1,3 @@
-
import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';
export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';
diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.ts
index c18c086d5..8890f6739 100644
--- a/packages/core/src/bridge/doc-boundary-space.ts
+++ b/packages/core/src/bridge/doc-boundary-space.ts
@@ -1,4 +1,3 @@
-
import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';
const LEADING_BOUNDARY_RE = /^(?:\r?\n)+/;
diff --git a/packages/core/src/bridge/growth-detect.ts b/packages/core/src/bridge/growth-detect.ts
index 463e89595..9d9c244b0 100644
--- a/packages/core/src/bridge/growth-detect.ts
+++ b/packages/core/src/bridge/growth-detect.ts
@@ -1,4 +1,3 @@
-
const DEFAULT_MIN_SUBSTANTIVE_LINE_LENGTH = 16;
export const DUPLICATION_GATE_MIN_LINE_LENGTH = 8;
diff --git a/packages/core/src/bridge/intraline-predicate.ts b/packages/core/src/bridge/intraline-predicate.ts
index 0939885bb..c43fdd7e7 100644
--- a/packages/core/src/bridge/intraline-predicate.ts
+++ b/packages/core/src/bridge/intraline-predicate.ts
@@ -1,4 +1,3 @@
-
export function rawLineCounts(doc: string): Map<string, number> {
const counts = new Map<string, number>();
for (const line of doc.split('\n')) {
diff --git a/packages/core/src/bridge/merge-three-way.ts b/packages/core/src/bridge/merge-three-way.ts
index c0dc65705..251560a35 100644
--- a/packages/core/src/bridge/merge-three-way.ts
+++ b/packages/core/src/bridge/merge-three-way.ts
@@ -65,7 +65,6 @@ export function tryLineLevelCombine(
return { clean: true, merged };
}
-
export type BridgeMergeContentLossSide = 'user' | 'agent';
export type BridgeMergeContentLossWhich = 'substring' | 'order' | 'growth';
diff --git a/packages/core/src/bridge/normalize.ts b/packages/core/src/bridge/normalize.ts
index d35f6b455..da41900cd 100644
--- a/packages/core/src/bridge/normalize.ts
+++ b/packages/core/src/bridge/normalize.ts
@@ -1,4 +1,3 @@
-
const COMMONMARK_ESCAPE_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g;
const TABLE_ALIGN_ROW_RE = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/;
diff --git a/packages/core/src/bridge/pm-structural-equivalence.ts b/packages/core/src/bridge/pm-structural-equivalence.ts
index 0be5203e4..754dc5cc2 100644
--- a/packages/core/src/bridge/pm-structural-equivalence.ts
+++ b/packages/core/src/bridge/pm-structural-equivalence.ts
@@ -32,7 +32,6 @@ const BR_SENTINEL: PmStructuralNode = { type: '__br__' };
const BR_LITERAL_RE = /^<br\s*\/?>$/i;
-
interface DegradeEntry {
readonly label: string;
readonly severity: ToleranceClassSeverity;
@@ -128,7 +127,6 @@ export interface ComparePmStructuralOptions {
ignoreAttrs?: (attrKey: string) => boolean;
}
-
/** Rebuild a node with `fn` applied to each child; identity when childless.
* Shared by the degrade canonicalizers so none re-implements the walk. */
function mapChildren(
@@ -250,7 +248,6 @@ function applyDegrades(tree: PmStructuralNode): {
return { normalized: current, fired };
}
-
export function comparePmStructural(
expected: PmStructuralNode,
actual: PmStructuralNode,
diff --git a/packages/core/src/bridge/subsequence.ts b/packages/core/src/bridge/subsequence.ts
index dca644141..af20de1e2 100644
--- a/packages/core/src/bridge/subsequence.ts
+++ b/packages/core/src/bridge/subsequence.ts
@@ -1,4 +1,3 @@
-
/** True when `needle` is a subsequence of `haystack` (two-pointer, O(n+m)):
* insertions in `haystack` are free; any dropped or substituted `needle` byte
* fails. */
diff --git a/packages/core/src/extensions/jsx-inline.ts b/packages/core/src/extensions/jsx-inline.ts
index 4ae979e88..6d4c3a7d7 100644
--- a/packages/core/src/extensions/jsx-inline.ts
+++ b/packages/core/src/extensions/jsx-inline.ts
@@ -1,22 +1,26 @@
import { Node } from '@tiptap/core';
/**
- * jsxInline — thin inline PM node for MDX inline JSX.
+ * jsxInline — inline PM node for MDX inline JSX (`mdxJsxTextElement`).
*
- * Inline JSX renders as visible source text in WYSIWYG — no live
- * React render, no PropPanel, no descriptor dispatch, no chrome. The node
- * exists only to preserve `<` and `>` characters through the markdown
- * serializer without escape (mdast-util-to-markdown would otherwise escape
- * `<word` patterns per CommonMark safety).
+ * Two rendering paths sit behind one node type:
+ * 1. Attrs-populated (registered inline descriptor) — `componentName` set,
+ * `props` destructured. NodeView dispatches to the descriptor's React
+ * component atomically (contentEditable={false}); source characters are
+ * hidden. Paired bodies land as `props.children`. Analogous to
+ * jsxComponent but at inline flow.
+ * 2. Zero-attrs (legacy thin shape) — `componentName === ''` and the text
+ * children carry raw source. WYSIWYG renders as visible source text
+ * (source-text default for unregistered tags).
*
- * Shape: atom:false, content:'text*', isolating:false, selectable:true.
- * Zero attrs — the text content IS the source. No NodeView, no
- * contentEditable:false, no sourceDirty, no sourceRaw attr.
+ * `content: 'text*'` per Precedent #10 preserves Y.Item identity on
+ * per-keystroke text mutation (thin-shape path uses children for the raw
+ * JSX source).
*
- * content:'text*' per
- * Precedent #10 preserves Y.Item identity on per-keystroke text mutation.
- *
- * See Precedent #10.
+ * Attrs mirror jsxComponent's (componentName / kind / attributes / sourceRaw
+ * / sourceDirty / props) so NodeViews and serialization handlers can share
+ * utilities. `kind` is always `'element'` today; the field is present for
+ * shape parity with jsxComponent (which carries `'element' | 'expression'`).
*/
export const JsxInline = Node.create({
name: 'jsxInline',
@@ -29,14 +33,47 @@ export const JsxInline = Node.create({
priority: 60,
addAttributes() {
- return {};
+ return {
+ // JSX tag name (e.g., 'Callout'). Empty string = legacy thin-shape path
+ // (children carry raw source, WYSIWYG renders as text).
+ componentName: { default: '' },
+ // Shape parity with jsxComponent — currently always 'element' for inline.
+ kind: { default: 'element' },
+ // Preserved mdast MdxJsxAttribute[] for serialize reconstruct.
+ attributes: { default: [] },
+ // Byte-exact source from parse for the pristine serialization path.
+ sourceRaw: { default: '' },
+ // false = pristine (serialize via sourceRaw); true = edited (reconstruct).
+ sourceDirty: { default: false },
+ // Structured props destructured via descriptor.props.
+ props: { default: {} },
+ };
},
parseHTML() {
- return [{ tag: 'span[data-jsx-inline]' }];
+ return [
+ {
+ tag: 'span[data-jsx-inline]',
+ getAttrs: (node) => {
+ if (typeof node === 'string') return false;
+ return {
+ componentName: node.getAttribute('data-component-name') || '',
+ sourceRaw: node.getAttribute('data-source-raw') || '',
+ };
+ },
+ },
+ ];
},
- renderHTML() {
- return ['span', { 'data-jsx-inline': '' }, 0];
+ renderHTML({ HTMLAttributes }) {
+ return [
+ 'span',
+ {
+ 'data-jsx-inline': '',
+ 'data-component-name': HTMLAttributes.componentName,
+ 'data-source-raw': HTMLAttributes.sourceRaw,
+ },
+ 0,
+ ];
},
});
diff --git a/packages/core/src/markdown/callout-transformer.ts b/packages/core/src/markdown/callout-transformer.ts
index a363dfd54..83d47404a 100644
--- a/packages/core/src/markdown/callout-transformer.ts
+++ b/packages/core/src/markdown/callout-transformer.ts
@@ -1,4 +1,3 @@
-
import type { Blockquote, Paragraph, Root } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/code-fence.ts b/packages/core/src/markdown/code-fence.ts
index 4499dbc92..9807a7e82 100644
--- a/packages/core/src/markdown/code-fence.ts
+++ b/packages/core/src/markdown/code-fence.ts
@@ -1,4 +1,3 @@
-
export function selectFenceChar(info: string): '`' | '~' {
return info.includes('`') ? '~' : '`';
}
diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.ts
index 34704165b..7415c474a 100644
--- a/packages/core/src/markdown/comment-promoter.ts
+++ b/packages/core/src/markdown/comment-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/dedent-block-jsx-close.ts b/packages/core/src/markdown/dedent-block-jsx-close.ts
index b6299a948..ece5c02a1 100644
--- a/packages/core/src/markdown/dedent-block-jsx-close.ts
+++ b/packages/core/src/markdown/dedent-block-jsx-close.ts
@@ -1,4 +1,3 @@
-
import { findFencedRegions, isInsideFence } from './fence-regions.ts';
const INDENTED_BLOCK_JSX_CLOSE_RE = /^([ ]{1,3})(<\/[A-Z][A-Za-z0-9_]*\s*>)([ \t]*)$/gm;
diff --git a/packages/core/src/markdown/details-accordion-promoter.ts b/packages/core/src/markdown/details-accordion-promoter.ts
index acd398aa6..54774764a 100644
--- a/packages/core/src/markdown/details-accordion-promoter.ts
+++ b/packages/core/src/markdown/details-accordion-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Paragraph, Parent, Root, Text } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/div-align-promoter.ts b/packages/core/src/markdown/div-align-promoter.ts
index ba9b56384..43ecdc709 100644
--- a/packages/core/src/markdown/div-align-promoter.ts
+++ b/packages/core/src/markdown/div-align-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Paragraph, Parent, Root, Text } from 'mdast';
import type { MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/fence-regions.ts b/packages/core/src/markdown/fence-regions.ts
index 4513da9bb..6d3f3643e 100644
--- a/packages/core/src/markdown/fence-regions.ts
+++ b/packages/core/src/markdown/fence-regions.ts
@@ -1,4 +1,3 @@
-
const FENCE_RE = /^(`{3,}|~{3,})/gm;
export function findFencedRegions(src: string): Array<[number, number]> {
diff --git a/packages/core/src/markdown/fixtures/index.ts b/packages/core/src/markdown/fixtures/index.ts
index 6931623c7..00f5771ee 100644
--- a/packages/core/src/markdown/fixtures/index.ts
+++ b/packages/core/src/markdown/fixtures/index.ts
@@ -1,4 +1,3 @@
-
import { readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -9,7 +8,6 @@ function fixturePath(...segments: string[]): string {
return resolve(FIXTURES_DIR, ...segments);
}
-
interface GfmExample {
section: string;
markdown: string;
@@ -19,7 +17,6 @@ export function loadGfmExamples(): GfmExample[] {
return JSON.parse(readFileSync(fixturePath('gfm', 'examples.json'), 'utf8')) as GfmExample[];
}
-
interface MdxCrashEntry {
id: string;
input: string;
@@ -71,7 +68,6 @@ export function loadLargeEmbedFixtures(): LargeEmbedFixture[] {
) as LargeEmbedFixture[];
}
-
export function loadPrd6955Before(): string {
return readFileSync(fixturePath('regression', 'prd-6955-before.md'), 'utf8');
}
@@ -80,7 +76,6 @@ export function loadPrd6955CorruptedTriplicated(): string {
return readFileSync(fixturePath('regression', 'prd-6955-corrupted-triplicated.md'), 'utf8');
}
-
export interface NgPinnedCase {
id: string;
name: string;
@@ -97,7 +92,6 @@ export function loadNgPinnedCases(): NgPinnedCase[] {
) as NgPinnedCase[];
}
-
export function loadLargeRealistic(): string {
return readFileSync(fixturePath('perf', 'large-realistic.md'), 'utf8');
}
diff --git a/packages/core/src/markdown/fixtures/perf/generate.ts b/packages/core/src/markdown/fixtures/perf/generate.ts
index daa3ef82b..8b1eb8519 100644
--- a/packages/core/src/markdown/fixtures/perf/generate.ts
+++ b/packages/core/src/markdown/fixtures/perf/generate.ts
@@ -1,4 +1,3 @@
-
import { writeFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -11,7 +10,6 @@ const BASELINE_ONLY_COUNTS = [500, 2500] as const;
const SEED = 0xf1de1117;
-
function mulberry32(seed: number): () => number {
let a = seed >>> 0;
return () => {
@@ -38,7 +36,6 @@ function pickWeighted<T>(rand: () => number, items: readonly [T, number][]): T {
return items[items.length - 1][0];
}
-
const WORDS = [
'lorem',
'ipsum',
@@ -156,7 +153,6 @@ function mdxBlock(rand: () => number): string {
return `<${name}>\n\n${sentence(rand)}\n\n</${name}>`;
}
-
type BlockKind = 'paragraph' | 'heading' | 'list' | 'code' | 'table' | 'mdx';
const MIX: readonly [BlockKind, number][] = [
@@ -195,7 +191,6 @@ function generateDocument(blockCount: number, seed: number): string {
return `${blocks.join('\n\n')}\n`;
}
-
function main(): void {
for (const count of [...BLOCK_COUNTS, ...BASELINE_ONLY_COUNTS]) {
const doc = generateDocument(count, SEED);
diff --git a/packages/core/src/markdown/guard-flanking-matrix.ts b/packages/core/src/markdown/guard-flanking-matrix.ts
index 32c055c5b..420dc0fe5 100644
--- a/packages/core/src/markdown/guard-flanking-matrix.ts
+++ b/packages/core/src/markdown/guard-flanking-matrix.ts
@@ -7,7 +7,6 @@ import {
import { BACKSLASH_GUARD_SUBSTITUTIONS, encodeBackslashEscapes } from './backslash-escape-guard.ts';
import { ENTITY_REF_GUARD_SUBSTITUTIONS, encodeEntityRefs } from './entity-ref-guard.ts';
-
export const ATTENTION_DELIMITERS = ['*', '_', '**', '~~', '=='] as const;
export type FlankClass = 'whitespace' | 'punctuation' | 'other';
diff --git a/packages/core/src/markdown/handler-shadow-audit.ts b/packages/core/src/markdown/handler-shadow-audit.ts
index 283913255..2653473da 100644
--- a/packages/core/src/markdown/handler-shadow-audit.ts
+++ b/packages/core/src/markdown/handler-shadow-audit.ts
@@ -1,4 +1,3 @@
-
export interface HandlerShadowWitness {
input: string;
expect: 'byte' | 'byte-and-reparse-type';
diff --git a/packages/core/src/markdown/highlight-promoter.ts b/packages/core/src/markdown/highlight-promoter.ts
index 5d1000cc4..da0a81d23 100644
--- a/packages/core/src/markdown/highlight-promoter.ts
+++ b/packages/core/src/markdown/highlight-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parent, PhrasingContent, Root, Text } from 'mdast';
import type { MdxJsxTextElement } from 'mdast-util-mdx';
import { SKIP, visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/html-to-mdast.ts b/packages/core/src/markdown/html-to-mdast.ts
index 9681c0056..787315157 100644
--- a/packages/core/src/markdown/html-to-mdast.ts
+++ b/packages/core/src/markdown/html-to-mdast.ts
@@ -1,4 +1,3 @@
-
import type { Element as HastElement, Root as HastRoot } from 'hast';
import type { List, Nodes as MdastNodes, Root as MdastRoot } from 'mdast';
import rehypeParse from 'rehype-parse';
@@ -129,8 +128,7 @@ export function htmlToMdast(html: string, options?: HtmlToMdastOptions): MdastRo
throw new HtmlPayloadTooLargeError(html.length, maxBytes);
}
- const processor = unified()
- .use(rehypeParse, { fragment: true });
+ const processor = unified().use(rehypeParse, { fragment: true });
for (const plugin of cleanupPlugins) {
processor.use(plugin);
diff --git a/packages/core/src/markdown/image-promoter.ts b/packages/core/src/markdown/image-promoter.ts
index 994eb6917..706fa9afb 100644
--- a/packages/core/src/markdown/image-promoter.ts
+++ b/packages/core/src/markdown/image-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Image, Paragraph, Root } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/index.ts b/packages/core/src/markdown/index.ts
index 25bc43422..9075aa7f1 100644
--- a/packages/core/src/markdown/index.ts
+++ b/packages/core/src/markdown/index.ts
@@ -1,4 +1,3 @@
-
import {
type FromProseMirrorOptions,
fromPmMark,
@@ -75,6 +74,7 @@ import {
serializeMd,
} from './pipeline.ts';
import { normalizeDocRelativeAssetUrl } from './resolve-image-url.ts';
+import { emitMdxJsxTextFromNode } from './serialize-helpers.ts';
import { flattenCellBlocks } from './table-cell-flatten.ts';
import { toMarkdownHandlers } from './to-markdown-handlers.ts';
import {
@@ -206,7 +206,6 @@ export class MarkdownManager {
}
}
-
const registry = createRegistry();
function destructureAttrs(
@@ -255,12 +254,14 @@ function destructureAttrs(
return result;
}
-
function hasDirtyDescendant(node: PmNode): boolean {
let found = false;
node.descendants((child) => {
if (found) return false; // short-circuit
- if (child.type.name === 'jsxInline') return false; // skip jsxInline subtrees
+ if (child.type.name === 'jsxInline') {
+ if (child.attrs.sourceDirty) found = true;
+ return false;
+ }
if (child.type.name === 'jsxComponent' && child.attrs.sourceDirty) {
found = true;
return false;
@@ -275,7 +276,6 @@ function effectiveDirty(node: PmNode, freshnessChecker?: StructuralFreshnessChec
return freshnessChecker ? freshnessChecker.isDiverged(node.toJSON()) : false;
}
-
function isEmptyMdastParagraph(node: MdastNodes): boolean {
if (node.type !== 'paragraph') return false;
const children = node.children ?? [];
@@ -344,7 +344,6 @@ function extractTextFromMdastNodes(nodes: MdastNodes[]): string {
return out;
}
-
import {
AUDIO_EXTENSIONS,
FILE_ATTACHMENT_EXTENSIONS,
@@ -597,7 +596,6 @@ function buildMdastToPmHandlers(
}));
}
-
if (m.emphasis) {
handlers.emphasis = toPmMark(m.emphasis, (node: Emphasis) => ({
sourceDelimiter: node.data?.sourceDelimiter ?? '*',
@@ -678,7 +676,6 @@ function buildMdastToPmHandlers(
}));
}
-
if (m.link) {
const sourceLiteralMark = m.sourceLiteral;
handlers.link = (node: Link, _parent: MdastParent, state: MdastToPmState) => {
@@ -813,6 +810,25 @@ function buildMdastToPmHandlers(
const value = extractStringAttr(node, 'value') ?? '';
return n.tag.create({ value });
}
+ const inlineName = node.name ?? '';
+ const inlineDescriptor = inlineName ? registry.get(inlineName) : undefined;
+ if (inlineDescriptor && n.jsxInline) {
+ const structuredAttrs = destructureAttrs(node.attributes, inlineDescriptor.props);
+ const raw = rawFromData(node.data) ?? '';
+ const bodyText = (node.children ?? [])
+ .map((c) => (c && typeof c === 'object' && 'value' in c ? String(c.value ?? '') : ''))
+ .join('');
+ if (bodyText) {
+ structuredAttrs.children = bodyText;
+ }
+ return n.jsxInline.createAndFill({
+ componentName: inlineName,
+ attributes: node.attributes,
+ sourceRaw: raw,
+ sourceDirty: false,
+ props: structuredAttrs,
+ });
+ }
if (n.jsxInline) {
const raw = rawFromData(node.data) ?? '';
return n.jsxInline.createAndFill({}, raw ? [schema.text(raw)] : null);
@@ -957,7 +973,6 @@ function buildMdastToPmHandlers(
};
}
-
const blockUnknownHandler = (node: {
type: string;
position?: { start: { offset: number }; end: { offset: number } };
@@ -1083,7 +1098,6 @@ function buildMdastToPmHandlers(
return handlers as RemarkProseMirrorOptions['handlers'];
}
-
function buildPmToMdastHandlers(
schema: Schema,
freshness: FreshnessCheckerHolder,
@@ -1386,11 +1400,16 @@ function buildPmToMdastHandlers(
if (n.jsxInline) {
nodeHandlers.jsxInline = (pmNode: PmNode) => {
- const raw = pmNode.attrs.sourceRaw || pmNode.textContent || '';
+ const componentName = (pmNode.attrs.componentName as string) || '';
+ if (componentName && pmNode.attrs.sourceDirty) {
+ return emitMdxJsxTextFromNode(componentName, pmNode, registry.get(componentName)?.props);
+ }
+ const attrsFromNode = pmNode.attrs.attributes;
+ const raw = (pmNode.attrs.sourceRaw as string) || pmNode.textContent || '';
return {
type: 'mdxJsxTextElement' as const,
- name: null,
- attributes: [],
+ name: componentName || null,
+ attributes: Array.isArray(attrsFromNode) ? attrsFromNode : [],
children: [],
data: { sourceRaw: String(raw) },
};
diff --git a/packages/core/src/markdown/lint/applies-to.ts b/packages/core/src/markdown/lint/applies-to.ts
index b79e9aef7..fa0be9e86 100644
--- a/packages/core/src/markdown/lint/applies-to.ts
+++ b/packages/core/src/markdown/lint/applies-to.ts
@@ -1,4 +1,3 @@
-
import picomatch from 'picomatch';
import { SUPPORTED_DOC_EXTENSIONS } from '../../constants/doc-extensions.ts';
diff --git a/packages/core/src/markdown/lint/config-files.ts b/packages/core/src/markdown/lint/config-files.ts
index 94b34dee1..312c9c74b 100644
--- a/packages/core/src/markdown/lint/config-files.ts
+++ b/packages/core/src/markdown/lint/config-files.ts
@@ -1,4 +1,3 @@
-
const MARKDOWNLINT_JSON_CONFIG_FILES: ReadonlySet<string> = new Set([
'.markdownlint.json',
'.markdownlint.jsonc',
diff --git a/packages/core/src/markdown/lint/config-schemas.ts b/packages/core/src/markdown/lint/config-schemas.ts
index f1262c7c9..ef630ccba 100644
--- a/packages/core/src/markdown/lint/config-schemas.ts
+++ b/packages/core/src/markdown/lint/config-schemas.ts
@@ -38,7 +38,6 @@ const fullPluginShape = Object.fromEntries(
LINT_PLUGINS.map((plugin) => [plugin.id, plugin.sliceSchema]),
) as z.ZodRawShape;
-
export const LinterConfigSchema = z.object({
enabled: z.boolean(),
plugins: z.object(fullPluginShape),
diff --git a/packages/core/src/markdown/lint/default-config.ts b/packages/core/src/markdown/lint/default-config.ts
index a51f2ffb0..d48eea5e4 100644
--- a/packages/core/src/markdown/lint/default-config.ts
+++ b/packages/core/src/markdown/lint/default-config.ts
@@ -6,7 +6,6 @@ export const DEFAULT_MARKDOWNLINT_CONFIG: Record<string, MarkdownlintRuleSetting
MD013: false,
};
-
export function resolveMarkdownlintConfig(
rules: Record<string, MarkdownlintRuleSetting> | undefined,
): Configuration {
diff --git a/packages/core/src/markdown/lint/frontmatter-schema-edit.ts b/packages/core/src/markdown/lint/frontmatter-schema-edit.ts
index 9c9542661..ef478e268 100644
--- a/packages/core/src/markdown/lint/frontmatter-schema-edit.ts
+++ b/packages/core/src/markdown/lint/frontmatter-schema-edit.ts
@@ -1,4 +1,3 @@
-
import { CANONICAL_SCHEMA_DIALECT_URIS, DEFAULT_SCHEMA_DIALECT } from './frontmatter-validate.ts';
export interface FrontmatterFieldConstraint {
diff --git a/packages/core/src/markdown/lint/frontmatter-validate.ts b/packages/core/src/markdown/lint/frontmatter-validate.ts
index d4f3c1164..3b6c5851f 100644
--- a/packages/core/src/markdown/lint/frontmatter-validate.ts
+++ b/packages/core/src/markdown/lint/frontmatter-validate.ts
@@ -1,4 +1,3 @@
-
import Ajv, { type ValidateFunction } from 'ajv';
import Ajv2019 from 'ajv/dist/2019.js';
import Ajv2020 from 'ajv/dist/2020.js';
diff --git a/packages/core/src/markdown/lint/index.ts b/packages/core/src/markdown/lint/index.ts
index 48d260ed6..00d08265a 100644
--- a/packages/core/src/markdown/lint/index.ts
+++ b/packages/core/src/markdown/lint/index.ts
@@ -1,4 +1,3 @@
-
import { LINT_PLUGINS, type LinterConfig } from './plugins.ts';
import type { LintDiagnostic } from './types.ts';
diff --git a/packages/core/src/markdown/lint/plugins.ts b/packages/core/src/markdown/lint/plugins.ts
index be5871ed9..5e832aa19 100644
--- a/packages/core/src/markdown/lint/plugins.ts
+++ b/packages/core/src/markdown/lint/plugins.ts
@@ -1,4 +1,3 @@
-
import { z } from 'zod';
import { DEFAULT_MARKDOWNLINT_CONFIG, resolveMarkdownlintConfig } from './default-config.ts';
import {
@@ -14,7 +13,6 @@ import {
type MarkdownlintSlice,
} from './types.ts';
-
const MarkdownlintRuleSettingSchema = z.union([
z.boolean(),
z.enum(MARKDOWNLINT_RULE_SEVERITIES),
diff --git a/packages/core/src/markdown/lint/types.ts b/packages/core/src/markdown/lint/types.ts
index e23681598..7b91a911b 100644
--- a/packages/core/src/markdown/lint/types.ts
+++ b/packages/core/src/markdown/lint/types.ts
@@ -1,4 +1,3 @@
-
export const LINT_PLUGIN_IDS = ['markdownlint', 'frontmatter'] as const;
export type LintPluginId = (typeof LINT_PLUGIN_IDS)[number];
@@ -71,7 +70,6 @@ export interface FrontmatterSlice {
schemas: ResolvedFrontmatterSchemaEntry[];
}
-
interface RuleOptionSpecBase {
key: string;
description: string;
diff --git a/packages/core/src/markdown/lint/validation-counts.ts b/packages/core/src/markdown/lint/validation-counts.ts
index 437cc539a..98238656e 100644
--- a/packages/core/src/markdown/lint/validation-counts.ts
+++ b/packages/core/src/markdown/lint/validation-counts.ts
@@ -1,4 +1,3 @@
-
export interface ValidationSourceCounts {
errorCount: number;
warningCount: number;
diff --git a/packages/core/src/markdown/math-promoter.ts b/packages/core/src/markdown/math-promoter.ts
index bd79424c7..a5b511f25 100644
--- a/packages/core/src/markdown/math-promoter.ts
+++ b/packages/core/src/markdown/math-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Code, Root } from 'mdast';
import type { Math as MdastMath } from 'mdast-util-math';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
diff --git a/packages/core/src/markdown/mdast-to-hast-handlers.ts b/packages/core/src/markdown/mdast-to-hast-handlers.ts
index 00fbc0035..ed89371d0 100644
--- a/packages/core/src/markdown/mdast-to-hast-handlers.ts
+++ b/packages/core/src/markdown/mdast-to-hast-handlers.ts
@@ -1,4 +1,3 @@
-
import type { Comment, Element, ElementContent, Properties } from 'hast';
import type { FootnoteDefinition, FootnoteReference } from 'mdast';
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx';
diff --git a/packages/core/src/markdown/mdast-to-html.ts b/packages/core/src/markdown/mdast-to-html.ts
index df788a80d..8ce2b2492 100644
--- a/packages/core/src/markdown/mdast-to-html.ts
+++ b/packages/core/src/markdown/mdast-to-html.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root as HastRoot, Text as HastText } from 'hast';
import type { Root as MdastRoot, Text as MdastText } from 'mdast';
import type { Handler } from 'mdast-util-to-hast';
diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.ts
index fa3cfcd86..bfd7e3109 100644
--- a/packages/core/src/markdown/merged-walker.ts
+++ b/packages/core/src/markdown/merged-walker.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parent, Root } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/mermaid-promoter.ts b/packages/core/src/markdown/mermaid-promoter.ts
index 17ed2b829..1a897fca8 100644
--- a/packages/core/src/markdown/mermaid-promoter.ts
+++ b/packages/core/src/markdown/mermaid-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Code, Root } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/parse-with-fallback.ts b/packages/core/src/markdown/parse-with-fallback.ts
index 7e4a9a48b..9864b3b60 100644
--- a/packages/core/src/markdown/parse-with-fallback.ts
+++ b/packages/core/src/markdown/parse-with-fallback.ts
@@ -168,7 +168,6 @@ export function parseRecursive(
}
}
-
interface VFilePlace {
offset?: number;
start?: { offset?: number };
@@ -187,7 +186,6 @@ function extractErrorOffset(err: unknown): number | undefined {
return undefined;
}
-
interface Region {
start: number;
end: number;
@@ -211,7 +209,6 @@ function nearestBlankLineAfter(src: string, offset: number): number | null {
return null;
}
-
export interface TagEvent {
kind: 'open' | 'close' | 'self-close';
name: string;
@@ -358,7 +355,6 @@ function findFallbackRegion(src: string, errorOffset: number): Region {
return { start: blockStart, end: blockEnd };
}
-
interface SourceBlock {
src: string;
start: number;
@@ -456,7 +452,6 @@ function tryPerBlockFallback(
};
}
-
function wholeDocRawText(source: string): JSONContent {
return {
type: 'doc',
diff --git a/packages/core/src/markdown/parser-drop-closure.ts b/packages/core/src/markdown/parser-drop-closure.ts
index 43d420187..e6ab4fd57 100644
--- a/packages/core/src/markdown/parser-drop-closure.ts
+++ b/packages/core/src/markdown/parser-drop-closure.ts
@@ -1,4 +1,3 @@
-
export type DroppedTokenAdjudication =
| {
kind: 'format-dof-axis';
diff --git a/packages/core/src/markdown/pipeline.ts b/packages/core/src/markdown/pipeline.ts
index c21e1fdf1..4426ab46e 100644
--- a/packages/core/src/markdown/pipeline.ts
+++ b/packages/core/src/markdown/pipeline.ts
@@ -1,4 +1,3 @@
-
import {
type FromProseMirrorOptions,
fromProseMirror,
diff --git a/packages/core/src/markdown/position-aware-join.ts b/packages/core/src/markdown/position-aware-join.ts
index ccf06e94d..91cdf658f 100644
--- a/packages/core/src/markdown/position-aware-join.ts
+++ b/packages/core/src/markdown/position-aware-join.ts
@@ -1,4 +1,3 @@
-
import type { Join } from 'mdast-util-to-markdown';
import type { Position } from 'unist';
import { isBlankLineParagraph } from './zero-emission-blocks.ts';
diff --git a/packages/core/src/markdown/position-slice.ts b/packages/core/src/markdown/position-slice.ts
index e5b4c9eba..0f399d34c 100644
--- a/packages/core/src/markdown/position-slice.ts
+++ b/packages/core/src/markdown/position-slice.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Root } from 'mdast';
import { visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
@@ -477,8 +476,7 @@ export function applyPositionSliceToNode(
const first = source[startOff];
if (first !== '[' && first !== '<' && !node.title) {
node.data.sourceStyle = 'gfm-autolink';
- }
- else if (first === '[') {
+ } else if (first === '[') {
const slice = source.slice(startOff, endOff);
const closeBracketIdx = slice.lastIndexOf('](');
if (closeBracketIdx !== -1) {
diff --git a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts
index ca225ce9b..db10fa54b 100644
--- a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts
+++ b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts
@@ -1,4 +1,3 @@
-
import type { Comment, Element, Root, Text } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts
index 3a2524a9a..34068d103 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts
@@ -1,4 +1,3 @@
-
import type { Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts
index 2279a0189..93151d43b 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts
index a0f467c42..188f02d83 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts
index 4e8542a21..4ba2c3418 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts
index a3c96b24a..1a74b1272 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts
@@ -1,4 +1,3 @@
-
import type { Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts
index e95cf43d6..de35e7b79 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts
@@ -1,4 +1,3 @@
-
import type { Comment, Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts
index ffdb4d5b5..b4be1b2ea 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts
@@ -1,4 +1,3 @@
-
import type { Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts
index e2a96d1a7..3c8d88b7c 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/resolve-image-url.ts b/packages/core/src/markdown/resolve-image-url.ts
index 0389575ac..cf2c9da8e 100644
--- a/packages/core/src/markdown/resolve-image-url.ts
+++ b/packages/core/src/markdown/resolve-image-url.ts
@@ -1,4 +1,3 @@
-
import { isRelativeUrl } from './safe-url.ts';
function isDevDiagnosticContext(): boolean {
diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.ts
index 8be632ba4..4d3250d3a 100644
--- a/packages/core/src/markdown/safe-url.ts
+++ b/packages/core/src/markdown/safe-url.ts
@@ -1,4 +1,3 @@
-
export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;
const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');
diff --git a/packages/core/src/markdown/serialize-fidelity.test-helper.ts b/packages/core/src/markdown/serialize-fidelity.test-helper.ts
index 96304e7a5..0dd54070e 100644
--- a/packages/core/src/markdown/serialize-fidelity.test-helper.ts
+++ b/packages/core/src/markdown/serialize-fidelity.test-helper.ts
@@ -1,4 +1,3 @@
-
import type { JSONContent } from '@tiptap/core';
import type { Nodes } from 'mdast';
import { expect } from 'vitest';
diff --git a/packages/core/src/markdown/serialize-helpers.ts b/packages/core/src/markdown/serialize-helpers.ts
index 542204403..7cac5b042 100644
--- a/packages/core/src/markdown/serialize-helpers.ts
+++ b/packages/core/src/markdown/serialize-helpers.ts
@@ -1,6 +1,10 @@
-
import type { Node as PmNode } from '@tiptap/pm/model';
-import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
+import type {
+ MdxJsxAttribute,
+ MdxJsxExpressionAttribute,
+ MdxJsxFlowElement,
+ MdxJsxTextElement,
+} from 'mdast-util-mdx';
import type { PropDef, SerializeContext } from '../registry/types.ts';
function reconstructAttrs(
@@ -135,3 +139,18 @@ export function emitMdxJsx(
data: {},
};
}
+
+export function emitMdxJsxTextFromNode(
+ componentName: string,
+ pmNode: PmNode,
+ props?: readonly PropDef[],
+): MdxJsxTextElement {
+ const body = (pmNode.attrs.props as Record<string, unknown> | undefined)?.children;
+ return {
+ type: 'mdxJsxTextElement',
+ name: componentName,
+ attributes: reconstructAttrs(pmNode, props),
+ children: typeof body === 'string' && body !== '' ? [{ type: 'text', value: body }] : [],
+ data: {},
+ };
+}
diff --git a/packages/core/src/markdown/single-dollar-math-promoter.ts b/packages/core/src/markdown/single-dollar-math-promoter.ts
index 8c08b7a04..b012a5aff 100644
--- a/packages/core/src/markdown/single-dollar-math-promoter.ts
+++ b/packages/core/src/markdown/single-dollar-math-promoter.ts
@@ -1,4 +1,3 @@
-
import type { PhrasingContent, Root, Text } from 'mdast';
import type { InlineMath } from 'mdast-util-math';
import { SKIP, visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/to-markdown-handlers.ts b/packages/core/src/markdown/to-markdown-handlers.ts
index 20ce25dbe..3e79f8cb6 100644
--- a/packages/core/src/markdown/to-markdown-handlers.ts
+++ b/packages/core/src/markdown/to-markdown-handlers.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parents } from 'mdast';
import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import type { Handle, Info, State } from 'mdast-util-to-markdown';
@@ -714,6 +713,12 @@ export const toMarkdownHandlers = {
if (typeof raw === 'string') return raw;
const name = node.name ?? '';
const attrs = serializeMdxJsxAttrs(node.attributes ?? []);
+ const body = (node.children ?? [])
+ .map((c) => (c && typeof c === 'object' && 'value' in c ? String(c.value ?? '') : ''))
+ .join('');
+ if (body) {
+ return attrs ? `<${name} ${attrs}>${body}</${name}>` : `<${name}>${body}</${name}>`;
+ }
return attrs ? `<${name} ${attrs} />` : `<${name}/>`;
},
diff --git a/packages/core/src/markdown/underline-promoter.ts b/packages/core/src/markdown/underline-promoter.ts
index 6e6d73400..0f1b0f27d 100644
--- a/packages/core/src/markdown/underline-promoter.ts
+++ b/packages/core/src/markdown/underline-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parent, Root } from 'mdast';
import type { MdxJsxTextElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/unknown-mdast-guard.ts b/packages/core/src/markdown/unknown-mdast-guard.ts
index 932d7d2a8..1a082bda7 100644
--- a/packages/core/src/markdown/unknown-mdast-guard.ts
+++ b/packages/core/src/markdown/unknown-mdast-guard.ts
@@ -1,4 +1,3 @@
-
import type { Root as MdastRoot } from 'mdast';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/whitespace-char-ref.ts b/packages/core/src/markdown/whitespace-char-ref.ts
index ac9f5239b..d578476a7 100644
--- a/packages/core/src/markdown/whitespace-char-ref.ts
+++ b/packages/core/src/markdown/whitespace-char-ref.ts
@@ -1,4 +1,3 @@
-
const INLINE_WHITESPACE_BY_CODE: ReadonlyMap<number, string> = new Map([
[0x20, ' '],
[0x09, '\t'],
diff --git a/packages/core/src/markdown/wiki-link-micromark.ts b/packages/core/src/markdown/wiki-link-micromark.ts
index afd9936fe..6dad26200 100644
--- a/packages/core/src/markdown/wiki-link-micromark.ts
+++ b/packages/core/src/markdown/wiki-link-micromark.ts
@@ -17,7 +17,6 @@ declare module 'micromark-util-types' {
}
}
-
const CODE_BANG = 33; // !
const CODE_LBRACKET = 91; // [
const CODE_RBRACKET = 93; // ]
@@ -261,7 +260,6 @@ export function wikiLinkSyntax(): Extension {
};
}
-
function enterWikiLink(this: CompileContext, token: Token) {
this.enter(
{
@@ -387,7 +385,6 @@ export const wikiLinkToMarkdown: {
unsafe: [{ character: '[', inConstruct: ['phrasing'] }],
};
-
const MICROMARK_EXT = wikiLinkSyntax();
export function remarkWikiLink(this: Processor) {
diff --git a/packages/core/src/registry/types.ts b/packages/core/src/registry/types.ts
index c897b8bd4..66843c886 100644
--- a/packages/core/src/registry/types.ts
+++ b/packages/core/src/registry/types.ts
@@ -227,8 +227,12 @@ type TranslateProps = (compatProps: Record<string, unknown>) => Record<string, u
/**
* Fields shared by both surfaces of `JsxComponentMeta`.
*
- * Registry tracks block components only. No isInline field — inline JSX
- * is the thin jsxInline node and doesn't use descriptors.
+ * The registry drives BOTH the block `jsxComponent` node view and the
+ * `jsxInline` widget dispatch — the same descriptor is consulted from
+ * `mdxJsxFlowElement` (block) and `mdxJsxTextElement` (inline) parse
+ * handlers. Inline forms render atomically (contentEditable={false}); paired
+ * bodies land as `props.children` while `sourceRaw` stays the round-trip
+ * authority.
*/
interface JsxComponentMetaBase {
/** Component tag name, or '*' for the wildcard fallback. */
diff --git a/packages/core/src/schema-invariant.test.ts b/packages/core/src/schema-invariant.test.ts
index de3227669..93189ed7c 100644
--- a/packages/core/src/schema-invariant.test.ts
+++ b/packages/core/src/schema-invariant.test.ts
@@ -134,8 +134,12 @@ interface AllowedNarrowing {
}
const ALLOWED_NARROWINGS: AllowedNarrowing[] = [
- // jsxInline greenfield narrowing: atom-widening (allowed via content
- // expression exception) plus attr removals listed explicitly.
+ // jsxInline greenfield narrowing: content: 'text*' is a narrowing from the
+ // pre-materialized shape, admitted under the atom-widening exception (R13
+ // schema-throw substitution absorbs any peer that still ships the wider
+ // form). The `attributes` and `sourceRaw` attrs are LIVE on this node now
+ // (registered inline descriptors carry structured attrs) — a future PR that
+ // strips them must earn its own entry with fresh evidence.
{
nodeType: 'jsxInline',
kind: 'content',
@@ -143,22 +147,6 @@ const ALLOWED_NARROWINGS: AllowedNarrowing[] = [
regressionTestRef:
'packages/app/tests/integration/jsx-schema-narrowing-safety.test.ts (SH05: pre-narrowing jsxInline materialization) + packages/app/tests/integration/y-tiptap-schema-throw-substitution.test.ts (R13 substitution on schema throw)',
},
- {
- nodeType: 'jsxInline',
- kind: 'attr-removed',
- attrName: 'attributes',
- specRef: 'specs/2026-04-14-component-blocks-v2/SPEC.md §FR-4 / NG14',
- regressionTestRef:
- 'packages/app/tests/integration/jsx-schema-narrowing-safety.test.ts (SH05: pre-narrowing jsxInline materialization) + packages/app/tests/integration/y-tiptap-schema-throw-substitution.test.ts (R13 substitution on schema throw)',
- },
- {
- nodeType: 'jsxInline',
- kind: 'attr-removed',
- attrName: 'sourceRaw',
- specRef: 'specs/2026-04-14-component-blocks-v2/SPEC.md §FR-4 / NG14',
- regressionTestRef:
- 'packages/app/tests/integration/jsx-schema-narrowing-safety.test.ts (SH05: pre-narrowing jsxInline materialization) + packages/app/tests/integration/y-tiptap-schema-throw-substitution.test.ts (R13 substitution on schema throw)',
- },
// Drop the legacy `content` attr
// on `jsxComponent`. It was dead storage — duplicated on every node but
// never read (the PM `content: 'block*'` content expression handles
diff --git a/packages/core/src/schema-snapshot.json b/packages/core/src/schema-snapshot.json
index f82a60d42..dcd98de11 100644
--- a/packages/core/src/schema-snapshot.json
+++ b/packages/core/src/schema-snapshot.json
@@ -99,7 +99,26 @@
"atom": false
},
"jsxInline": {
- "attrs": {},
+ "attrs": {
+ "componentName": {
+ "hasDefault": true
+ },
+ "kind": {
+ "hasDefault": true
+ },
+ "attributes": {
+ "hasDefault": true
+ },
+ "sourceRaw": {
+ "hasDefault": true
+ },
+ "sourceDirty": {
+ "hasDefault": true
+ },
+ "props": {
+ "hasDefault": true
+ }
+ },
"content": "text*",
"group": "inline",
"inline": true,