Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
fix(ok): cap selection surfaces to the editor pane width (PRD-7166) (#3831)
Andrew Mikofalvy66cfdd2ceca8
diff --git a/.changeset/thick-pears-smile.md b/.changeset/thick-pears-smile.mdnew file mode 100644index 000000000..afb8edc23--- /dev/null+++ b/.changeset/thick-pears-smile.md@@ -0,0 +1,7 @@+---+'@inkeep/open-knowledge': patch+---++Keep the formatting bar and comment composer inside the editor pane when a session dock narrows it++Docking the terminal or the agents rail beside a dragged-in editor column left the pane narrower than the formatting bar, and the bar painted its tail controls on top of the dock. Boundary-aware positioning could not fix it on its own: a clamp relocates a surface but cannot shrink one, so a fixed-width bar overhangs a narrower pane from every coordinate. Selection-anchored surfaces now cap their width to the pane, and the bar wraps to a second row rather than overflowing.diff --git a/knip.config.ts b/knip.config.tsindex b61debe5e..8ad68f996 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -124,7 +124,9 @@ 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/comments/CommentSelectionAffordance.tsx b/packages/app/src/comments/CommentSelectionAffordance.tsxindex c4344540a..fe62de06a 100644--- a/packages/app/src/comments/CommentSelectionAffordance.tsx+++ b/packages/app/src/comments/CommentSelectionAffordance.tsx@@ -23,7 +23,7 @@// biome-ignore-all lint/plugin/no-physical-direction-utility: pre-rule backlog — physical margin/padding/inset utilities predate the rule; drain by swapping ml/mr → ms/me, pl/pr → ps/pe, left/right → start/end, then deleting this line. See https://github.com/inkeep/open-knowledge/blob/main/biome-plugins/README.md#no-physical-direction-utilitygrit-import { autoUpdate, computePosition, flip, offset, shift } from '@floating-ui/dom';+import { autoUpdate, computePosition, flip, offset, shift, size } from '@floating-ui/dom';import { commentQuoteText } from '@inkeep/open-knowledge-core';import { Trans, useLingui } from '@lingui/react/macro';import { posToDOMRect } from '@tiptap/core';@@ -38,6 +38,7 @@ import {import {deriveEditorClipOptions,deriveEditorShiftOptions,+ deriveEditorSizeOptions,SELECTION_SURFACE_GAP_PX,} from '@/editor/utils/editor-visible-region';import { getEditorView } from '@/editor/utils/get-editor-view';@@ -158,6 +159,12 @@ export function CommentSelectionAffordance({// boundary as well as the clamp that keeps it inside it.flip(deriveEditorClipOptions(editor)),shift(deriveEditorShiftOptions(editor)),+ // The card's `w-80` is wider than the editor pane once a terminal or+ // rail is docked beside a narrowed column, and a clamp cannot place+ // a card that does not fit. Capping its width to the region keeps it+ // off the neighbour; the card is a flex column, so the cap costs it+ // reflow rather than reachable controls.+ size(deriveEditorSizeOptions(editor)),// No hide(): unlike the formatting bar, this card holds a draft and// owns focus, so stamping `visibility: hidden` on it would drop the// caret to <body> mid-sentence. Scrolling the captured passage outdiff --git a/packages/app/src/editor/bubble-menu/BubbleMenuBar.tsx b/packages/app/src/editor/bubble-menu/BubbleMenuBar.tsxindex 97df8be30..230a79672 100644--- a/packages/app/src/editor/bubble-menu/BubbleMenuBar.tsx+++ b/packages/app/src/editor/bubble-menu/BubbleMenuBar.tsx@@ -1,4 +1,4 @@-import { autoUpdate, computePosition, flip, hide, offset, shift } from '@floating-ui/dom';+import { autoUpdate, computePosition, flip, hide, offset, shift, size } from '@floating-ui/dom';import { posToDOMRect } from '@tiptap/core';import type { Editor } from '@tiptap/react';import { useEditorState } from '@tiptap/react';@@ -9,6 +9,7 @@ import { Separator } from '@/components/ui/separator';import {deriveEditorClipOptions,deriveEditorShiftOptions,+ deriveEditorSizeOptions,SELECTION_SURFACE_GAP_PX,} from '../utils/editor-visible-region';import { BlockTypeSelector } from './BlockTypeSelector';@@ -69,6 +70,12 @@ export function BubbleMenuBar({// The clamp that keeps the bar inside that region. The boundary alone only// detects the overflow.const shiftOptions = deriveEditorShiftOptions(editor);+ // The clamp can only place a bar that FITS. This bar is the widest surface+ // anchored in the pane (~450px with every control up), so against a pane+ // narrowed by a docked terminal it overhangs from any coordinate — see+ // `deriveEditorSizeOptions`. Capping its width is what leaves the clamp+ // something it can satisfy; `flex-wrap` below is what the cap costs.+ const sizeOptions = deriveEditorSizeOptions(editor);const onShow = () => {const popup = menuRef.current;@@ -82,6 +89,11 @@ export function BubbleMenuBar({offset(SELECTION_SURFACE_GAP_PX),flip(clipOptions),shift(shiftOptions),+ // After the clamp, mirroring where tiptap's plugin fixes `size` in+ // its own array, so both writers run the same chain in the same+ // order. `size()` resets the pass when it narrows the bar, so the+ // clamp above re-runs against the width it actually has.+ size(sizeOptions),hide(clipOptions),],})@@ -142,9 +154,16 @@ export function BubbleMenuBar({shift: deriveEditorShiftOptions(editor, {pendingOffsetPx: SELECTION_SURFACE_GAP_PX,}),+ size: sizeOptions,hide: clipOptions,}}- className="z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md"+ // `flex-wrap` is the cap's other half: `max-width` alone bounds the box,+ // not the row inside it, so a nowrap bar would keep painting its tail+ // controls past a pane-width cap and nothing would have changed on+ // screen. Wrapping spends height — which the clamp already bounds — to+ // keep every control reachable, rather than scrolling them behind an+ // affordance nobody would look for on a toolbar.+ className="z-50 flex flex-wrap items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md">{isImageMode ? (<ImageAlignButtons key={`${tooltipKey}-img-align`} editor={editor} />diff --git a/packages/app/src/editor/extensions/markdown-lint-decorations.ts b/packages/app/src/editor/extensions/markdown-lint-decorations.tsindex 54aa6e75d..9b1e0b3b7 100644--- a/packages/app/src/editor/extensions/markdown-lint-decorations.ts+++ b/packages/app/src/editor/extensions/markdown-lint-decorations.ts@@ -30,7 +30,7 @@* re-check at the end of each pass rather than an observer.*/-import { autoUpdate, computePosition, flip, offset, shift } from '@floating-ui/dom';+import { autoUpdate, computePosition, flip, offset, shift, size } from '@floating-ui/dom';import {sharedExtensions as coreExtensions,isFrontmatterScoped,@@ -55,6 +55,7 @@ import {import {deriveEditorClipOptions,deriveEditorShiftOptions,+ deriveEditorSizeOptions,} from '@/editor/utils/editor-visible-region';import { cn } from '@/lib/utils';import { blockIndexForLine, comparableChildCount, computeSourceBlockSpans } from '../block-spans';@@ -68,6 +69,15 @@ import { runScrollNavigation } from '../scroll-restore-coordination';*/const LINT_CALLOUT_GAP_PX = 6;+/**+ * Mirrors the `max-width` on `.ok-lint-tooltip` in `globals.css`. Restated+ * here because the pane cap is written as an INLINE `max-width`, which+ * outranks the stylesheet: the region producer has to be told the author's+ * ceiling to fold it in with `min()` instead of replacing it. Drifting from+ * the rule widens the callout on a roomy pane; it cannot make it escape.+ */+const LINT_CALLOUT_MAX_WIDTH = '22rem';+const markdownLintDecorationKey = new PluginKey<DecorationSet>('markdownLintDecorations');/** CSS classes consumed by `.ProseMirror .ok-lint-block*` in globals.css. */@@ -278,11 +288,26 @@ function createLintTooltip(// painting across the toolbar.const clipOptions = deriveEditorClipOptions(opts.editor);const shiftOptions = deriveEditorShiftOptions(opts.editor);+ // `.ok-lint-tooltip` caps itself at 22rem, which is wider than the pane once+ // a terminal or rail is docked beside a narrowed column — and the clamp can+ // only place a callout that fits. Handing that same 22rem back as the+ // author cap keeps this a narrowing: the inline `max-width` an unqualified+ // producer writes would outrank the stylesheet and let a roomy pane stretch+ // the callout past the width the rule picked for it. The body is prose, so+ // the narrowing costs reflow and nothing else.+ const sizeOptions = deriveEditorSizeOptions(opts.editor, {+ authorMaxWidth: LINT_CALLOUT_MAX_WIDTH,+ });function position() {computePosition(virtualEl, tooltip, {placement: 'top-start',- middleware: [offset(LINT_CALLOUT_GAP_PX), flip(clipOptions), shift(shiftOptions)],+ middleware: [+ offset(LINT_CALLOUT_GAP_PX),+ flip(clipOptions),+ shift(shiftOptions),+ size(sizeOptions),+ ],}).then(({ x, y }) => {if (tooltip.isConnected) {diff --git a/packages/app/src/editor/utils/editor-visible-region.dom.test.tsx b/packages/app/src/editor/utils/editor-visible-region.dom.test.tsxindex 122b81d29..4776b2043 100644--- a/packages/app/src/editor/utils/editor-visible-region.dom.test.tsx+++ b/packages/app/src/editor/utils/editor-visible-region.dom.test.tsx@@ -1,10 +1,12 @@/**- * DOM-tier tests for both halves of the editor's visible-region contract:+ * DOM-tier tests for all three parts of the editor's visible-region contract:* `deriveEditorClipOptions`, which describes the region (scroll container* minus the toolbar band and the live bottom-composer / conflict-footer- * overlays), and `deriveEditorShiftOptions`, which clamps a surface into it.- * The consumers are the formatting bubble bar and the comment composer, so- * neither the module nor these tests belong to either one.+ * overlays), `deriveEditorShiftOptions`, which clamps a surface into it, and+ * `deriveEditorSizeOptions`, which caps a surface that would not fit inside it+ * at any coordinate. The consumers are the formatting bubble bar, the comment+ * composer, and the lint callout, so neither the module nor these tests belong+ * to any one of them.** DOM tier because the derivable resolves the `.editor-doc-scroll` ancestor* via `closest()` on a rendered tree and reads the overlay-height CSS vars@@ -22,7 +24,11 @@ import { cleanup, render } from '@testing-library/react';import type { Editor } from '@tiptap/react';import { afterEach, describe, expect, test } from 'vitest';import { TOOLBAR_HEIGHT } from '../extensions/frozen-table-headers';-import { deriveEditorClipOptions, deriveEditorShiftOptions } from './editor-visible-region';+import {+ deriveEditorClipOptions,+ deriveEditorShiftOptions,+ deriveEditorSizeOptions,+} from './editor-visible-region';/** Renders the editor-DOM shape the derivable walks: a `.editor-doc-scroll`* scroll container wrapping the ProseMirror mount the editor points at. */@@ -251,3 +257,75 @@ describe('deriveEditorShiftOptions', () => {expect(options.padding.top).toBe(TOOLBAR_HEIGHT);});});++describe('deriveEditorSizeOptions', () => {+ const PANE_WIDTH_PX = 300;++ /** jsdom gives every element a zero rect, so the region has to be stated. */+ function renderEditorInPaneOfWidth(widthPx: number): {+ editor: Editor;+ floating: HTMLElement;+ } {+ const { editor, scroller } = renderEditorInScroller();+ scroller.getBoundingClientRect = () => new DOMRect(0, 0, widthPx, 800);+ return { editor, floating: document.createElement('div') };+ }++ test('caps the surface at the pane less both gutters', () => {+ const { editor, floating } = renderEditorInPaneOfWidth(PANE_WIDTH_PX);+ deriveEditorSizeOptions(editor)().apply({ elements: { floating } });+ expect(floating.style.maxWidth).toBe(`${PANE_WIDTH_PX - EXPECTED_PANE_GUTTER_PX * 2}px`);+ });++ test('folds an author cap in with min() rather than replacing it', () => {+ const { editor, floating } = renderEditorInPaneOfWidth(PANE_WIDTH_PX);+ // The inline write outranks the stylesheet, so a producer that ignored the+ // author's ceiling would WIDEN a capped surface on a roomy pane. `min()`+ // is what keeps this a ceiling in both directions.+ deriveEditorSizeOptions(editor, { authorMaxWidth: '22rem' })().apply({+ elements: { floating },+ });+ expect(floating.style.maxWidth).toBe(+ `min(22rem, ${PANE_WIDTH_PX - EXPECTED_PANE_GUTTER_PX * 2}px)`,+ );+ });++ test('re-reads the region on every invocation', () => {+ const { editor, scroller } = renderEditorInScroller();+ const floating = document.createElement('div');+ const derive = deriveEditorSizeOptions(editor);+ scroller.getBoundingClientRect = () => new DOMRect(0, 0, 500, 800);+ derive().apply({ elements: { floating } });+ expect(floating.style.maxWidth).toBe(`${500 - EXPECTED_PANE_GUTTER_PX * 2}px`);+ // The pane resizes under a live surface whenever a session dock is dragged,+ // which is the very geometry this cap exists for.+ scroller.getBoundingClientRect = () => new DOMRect(0, 0, 200, 800);+ derive().apply({ elements: { floating } });+ expect(floating.style.maxWidth).toBe(`${200 - EXPECTED_PANE_GUTTER_PX * 2}px`);+ });++ test('never emits a negative cap for a pane narrower than its gutters', () => {+ const { editor, floating } = renderEditorInPaneOfWidth(4);+ deriveEditorSizeOptions(editor)().apply({ elements: { floating } });+ expect(floating.style.maxWidth).toBe('0px');+ });++ test('clears the cap when no scroll container is resolvable', () => {+ const { container } = render(<div data-testid="pm-mount" />);+ const dom = container.querySelector('[data-testid="pm-mount"]') as HTMLElement;+ const editor = { editorView: { dom } } as unknown as Editor;+ const floating = document.createElement('div');+ floating.style.maxWidth = '123px';+ deriveEditorSizeOptions(editor)().apply({ elements: { floating } });+ // Cleared, not left stale: a surface that outlived its pane must not stay+ // pinned to the width that pane used to have.+ expect(floating.style.maxWidth).toBe('');+ });++ test('pre-mount editor clears the cap rather than throwing', () => {+ const floating = document.createElement('div');+ floating.style.maxWidth = '123px';+ deriveEditorSizeOptions(preMountEditor())().apply({ elements: { floating } });+ expect(floating.style.maxWidth).toBe('');+ });+});diff --git a/packages/app/src/editor/utils/editor-visible-region.ts b/packages/app/src/editor/utils/editor-visible-region.tsindex f63a81a8c..885badd68 100644--- a/packages/app/src/editor/utils/editor-visible-region.ts+++ b/packages/app/src/editor/utils/editor-visible-region.ts@@ -42,6 +42,23 @@ type EditorShiftOptions = Omit<ShiftOptions, 'boundary' | 'padding' | 'mainAxis'padding: SurfaceInsets;};+/**+ * What `deriveEditorSizeOptions` emits. `apply` states only the one field it+ * reads instead of floating-ui's full `MiddlewareState & { availableWidth,+ * availableHeight }`: the producer derives its cap from the region itself, and+ * narrowing the parameter is what makes reaching for `availableWidth` — the+ * position-dependent number this deliberately does not use — a compile error+ * rather than a silent behaviour change. A handler that accepts less is still+ * assignable where floating-ui passes more.+ *+ * No `boundary`/`padding` here: `size()`'s own `detectOverflow` pass feeds+ * numbers we ignore, so stating a boundary for it would advertise an input+ * this producer does not consume.+ */+interface EditorSizeOptions {+ apply: (state: Pick<MiddlewareState, 'elements'>) => void;+}+/*** Floating-UI clipping options that keep selection-anchored menus inside the* editor's *visible* content region, not just inside the viewport.@@ -62,7 +79,9 @@ type EditorShiftOptions = Omit<ShiftOptions, 'boundary' | 'padding' | 'mainAxis'* `deriveEditorShiftOptions` below, which converts this description of the* region into the clamp that keeps a surface inside it. A boundary handed to* `flip()`/`hide()` alone detects the overflow and then declines to correct- * it, so the two producers are consumed together.+ * it, so the producers are consumed together — and where the surface can be+ * wider than the pane, with `deriveEditorSizeOptions` as well, since the+ * clamp has nowhere to put a surface that does not fit.** Floating UI is the canonical positioning primitive for selection-anchored* overlays (precedent #35), and this module owns the visible-region half of@@ -77,11 +96,7 @@ type EditorShiftOptions = Omit<ShiftOptions, 'boundary' | 'padding' | 'mainAxis'*/export function deriveEditorClipOptions(editor: Editor): () => EditorClipOptions {return () => {- // `getEditorView` rather than `editor.view`, which is a proxy that throws- // until the ProseMirror view mounts (recycle/remount race). A try/catch- // around that throw swallows every other one too, and a missing boundary- // is invisible: the clamp quietly falls back to the viewport.- const boundary = getEditorView(editor)?.dom.closest('.editor-doc-scroll') ?? null;+ const boundary = resolveRegionBoundary(editor);const padding = {top: editorToolbarOverlapPx(),bottom:@@ -94,6 +109,18 @@ export function deriveEditorClipOptions(editor: Editor): () => EditorClipOptions};}+/**+ * The editor's scroll box — the element every producer here bounds against.+ *+ * `getEditorView` rather than `editor.view`, which is a proxy that throws+ * until the ProseMirror view mounts (recycle/remount race). A try/catch around+ * that throw swallows every other one too, and a missing boundary is+ * invisible: the clamp quietly falls back to the viewport.+ */+function resolveRegionBoundary(editor: Editor): Element | null {+ return getEditorView(editor)?.dom.closest('.editor-doc-scroll') ?? null;+}+/** Gap a selection-anchored surface keeps between itself and its anchor. */export const SELECTION_SURFACE_GAP_PX = 8;@@ -160,6 +187,68 @@ export function deriveEditorShiftOptions(};}+/**+ * The third member of the contract: a cap that keeps a surface NARROWER than+ * the editor's visible content region.+ *+ * `shift()` relocates; it cannot shrink. Its clamp can satisfy both pane edges+ * only while the surface FITS between them, so a surface with a fixed width —+ * the formatting bar is ~450px, the comment composer's card 320px, the lint+ * callout 352px — overhangs a pane narrower than itself from every coordinate+ * the clamp could choose. Docking the terminal to the right of a narrowed+ * editor column is how that happens in the product: the surplus paints on the+ * terminal — the same escape the two producers above close for position+ * alone.+ *+ * The cap is measured off the boundary element rather than read from+ * floating-ui's `availableWidth`, and that is deliberate. `availableWidth` is+ * position-dependent until `shift()` has run — while `middlewareData.shift` is+ * absent floating-ui reports `min(overflowAvailableWidth,+ * maximumClippingWidth)`, the room to the right of wherever the surface+ * currently sits — so a chain that sized before it clamped would squeeze a+ * surface in a pane with room to spare. Measuring the region states the+ * invariant the product wants (a surface is at most as wide as the pane it+ * belongs to) and makes this producer correct at ANY index in the middleware+ * array. That matters because we do not own every array: tiptap's BubbleMenu+ * plugin assembles its own as `flip -> shift -> offset -> arrow -> size ->+ * hide` and gives us no way to reorder it.+ *+ * `size()` re-runs the chain whenever `apply` changed the surface's+ * dimensions, so `shift()` re-clamps against the narrowed rect rather than the+ * one it was about to overflow with.+ *+ * `authorMaxWidth` is for a surface whose stylesheet ALREADY caps its width —+ * the lint callout's `22rem`. An inline `max-width` outranks that rule, so+ * writing the region width bare would WIDEN such a surface on a roomy pane+ * instead of only narrowing it on a cramped one. Naming the author's cap here+ * folds the two into `min()` and keeps this producer a ceiling, never a floor.+ * A surface with no stylesheet cap (the bar) or one that sets `width` rather+ * than `max-width` (the comment card's `w-80`, which `max-width` already+ * beats) omits it.+ *+ * No resolvable region (detached view, non-doc host): clear the cap rather+ * than pin the surface to a stale width. The same fallback the other two+ * producers take.+ */+export function deriveEditorSizeOptions(+ editor: Editor,+ { authorMaxWidth }: { authorMaxWidth?: string } = {},+): () => EditorSizeOptions {+ return () => ({+ apply({ elements }) {+ const boundary = resolveRegionBoundary(editor);+ if (!boundary) {+ elements.floating.style.maxWidth = '';+ return;+ }+ const regionWidth = Math.max(0, boundary.getBoundingClientRect().width - PANE_GUTTER_PX * 2);+ elements.floating.style.maxWidth = authorMaxWidth+ ? `min(${authorMaxWidth}, ${regionWidth}px)`+ : `${regionWidth}px`;+ },+ });+}+/*** Both overlay heights are published as inline styles on the document root* (BottomComposer and use-conflict-footer-height.ts), so read the inlinediff --git a/packages/app/tests/stress/selection-surface-pane-clip.e2e.ts b/packages/app/tests/stress/selection-surface-pane-clip.e2e.tsindex a61f4ccce..5e9e4da2e 100644--- a/packages/app/tests/stress/selection-surface-pane-clip.e2e.ts+++ b/packages/app/tests/stress/selection-surface-pane-clip.e2e.ts@@ -1026,6 +1026,238 @@ test('comment composer stays inside the pane when anchored at the text column leexpectInsideVisibleRegionHorizontally(geometry, 'comment composer');});+/**+ * The pane NARROWER than the surface anchored in it.+ *+ * Everything above turns on WHERE a surface is put. This turns on how WIDE it+ * is: `shift()` relocates but cannot shrink, and its clamp can satisfy both+ * pane edges only while the surface fits between them. A surface with a fixed+ * width overhangs a narrower pane from every coordinate the clamp could pick,+ * so a boundary-aware chain still paints it on the neighbour — the escape the+ * position fix could not reach.+ *+ * In the product the narrowing is a docked session panel: dragging the+ * terminal's (or the agents rail's) handle inward takes the editor column down+ * to its 5% floor while the bar keeps its ~450px of controls. Neither dock+ * exists on the web host these tests run against — the terminal needs a pty —+ * so the window is the lever that reaches the same geometry. It is the same+ * lever either way: every assertion here is a function of the pane's own+ * width, never of what occupies the space beyond it.+ */++/**+ * Shrink the window until the editor pane is about `targetPaneWidthPx` wide.+ *+ * Derives the window width from the CURRENT chrome rather than hardcoding one,+ * so a sidebar or gutter change moves the window instead of quietly widening+ * the pane back out of the regime under test — the failure mode that turns a+ * containment test into a tautology. `expectPaneNarrowerThan` is the assertion+ * that catches it if a responsive breakpoint defeats this anyway.+ */+async function narrowPaneTo(page: Page, targetPaneWidthPx: number): Promise<void> {+ const initial = page.viewportSize();+ if (!initial) throw new Error('narrowPaneTo: no viewport to resize');+ // Converge instead of solving for the window once. The chrome beside the+ // pane is not a constant: the sidebar collapses to an icon rail below its+ // own breakpoint and HANDS ITS WIDTH BACK to the editor, so a single+ // `window = chrome + target` lands the pane wider than it started. Each+ // round re-measures the chrome the app actually has at that width.+ for (let round = 0; round < 6; round += 1) {+ const paneWidth = await readPaneWidth(page);+ // Sub-pixel slack: the window is set in whole pixels, so the pane lands a+ // fraction wide of an exactly-computed target and an exact comparison+ // never terminates.+ if (paneWidth <= targetPaneWidthPx + 1) {+ await nextLayoutFrame(page);+ return;+ }+ const viewport = page.viewportSize();+ if (!viewport) throw new Error('narrowPaneTo: viewport disappeared mid-resize');+ const chromeWidth = viewport.width - paneWidth;+ await page.setViewportSize({+ width: Math.max(MIN_VIEWPORT_WIDTH_PX, Math.round(chromeWidth + targetPaneWidthPx) - 1),+ height: initial.height,+ });+ await waitForPaneWidthSettled(page);+ }+ throw new Error(+ `narrowPaneTo: pane still ${await readPaneWidth(page)}px after 6 rounds, wanted ` ++ `<= ${targetPaneWidthPx}px`,+ );+}++/**+ * Wait until the pane's width stops moving.+ *+ * Stability rather than "it changed": the pane is a `react-resizable-panels`+ * member whose relayout is driven by a ResizeObserver on the group, so it+ * still reads the pre-resize width for several frames — but a round that+ * lands on the width it already had is a legitimate convergence, and a+ * must-have-changed predicate would fail there instead of finishing.+ */+async function waitForPaneWidthSettled(page: Page): Promise<void> {+ let previous: number | null = null;+ await expect+ .poll(+ async () => {+ const current = Math.round(await readPaneWidth(page));+ const settled = current === previous;+ previous = current;+ return settled;+ },+ { timeout: 10_000, intervals: [100, 100, 200] },+ )+ .toBe(true);+}++/**+ * Floor for the converging resize — the narrowest viewport the app is expected+ * to lay out in. A pane that still will not shrink at this width is a layout+ * finding rather than a test that needs a smaller window, so the loop reports+ * it instead of shrinking further.+ *+ * It is also the ceiling on how narrow a pane these tests can construct, which+ * is why the group covers the bar and the comment composer but not the lint+ * callout: at this floor the pane is still wider than a callout, so there is+ * no overhang to contain. The callout's cap is pinned at the producer tier in+ * `editor-visible-region.dom.test.tsx` instead.+ */+const MIN_VIEWPORT_WIDTH_PX = 320;++/**+ * Narrow the pane as far as the app's own layout allows.+ *+ * The narrow-pane arms want the widest overhang they can get, and the floor+ * is the app's, not a number this file should guess: `narrowPaneTo` converges+ * against whatever chrome the layout keeps at each width and stops at+ * `MIN_VIEWPORT_WIDTH_PX`. Asking for zero and swallowing the resulting+ * "could not reach it" is how we ask for that floor without restating it.+ * `expectPaneNarrowerThan` is what then proves the floor was low enough for+ * the surface under test.+ */+async function narrowPaneAsFarAsPossible(page: Page): Promise<void> {+ await narrowPaneTo(page, 0).catch(() => {});+}++/**+ * How far below the scroll container's top the selection is parked once the+ * pane has been narrowed.+ *+ * Narrowing reflows the prose, so the selected block ends up somewhere else —+ * often below the region's floor, where `hide()` correctly blanks the bar and+ * the containment assertion would pass on nothing. A plain+ * `scrollIntoView()` is not enough either: it settles the block against the+ * nearest edge, which is under the Ask AI composer's band. This inset clears+ * the toolbar band at the top and the composer band at the bottom by more+ * than a bar height on a 720px-tall window.+ */+const SELECTION_MID_PANE_INSET_PX = 200;++/** Width of the painted editor scroll container. */+async function readPaneWidth(page: Page): Promise<number> {+ return page.evaluate((scrollerSel) => {+ const scroller = Array.from(document.querySelectorAll(scrollerSel)).find(+ (element): element is HTMLElement =>+ element instanceof HTMLElement && element.getClientRects().length > 0,+ );+ if (!scroller) throw new Error('readPaneWidth: no painted scroll container');+ return scroller.getBoundingClientRect().width;+ }, SCROLLER);+}++/**+ * Assert the pane really is too narrow to host the surface at its natural+ * width. Without this the containment assertions pass on a pane that never+ * squeezed anything, and the whole group goes quietly green the day the+ * surface loses a control or the chrome gains one.+ */+function expectPaneNarrowerThan(+ geometry: SurfaceGeometry,+ naturalWidthPx: number,+ label: string,+): void {+ const regionWidth = geometry.regionRight - geometry.regionLeft;+ expect(+ regionWidth,+ `${label}: the pane (${regionWidth}px) must be narrower than the surface's natural ` ++ `width (${naturalWidthPx}px) for the width cap to be under test`,+ ).toBeLessThan(naturalWidthPx);+}++/** The surface's width with no pane cap biting — measured, never assumed. */+async function readNaturalSurfaceWidth(page: Page, testId: string): Promise<number> {+ const geometry = await readSurfaceGeometry(page, testId);+ expect(geometry.visible, 'surface must be on screen to measure its natural width').toBe(true);+ return geometry.right - geometry.left;+}++test('bubble bar stays inside a pane narrower than the bar', async ({ page, api }) => {+ await openTallDoc(page, api, 'clip-bar-narrow');+ await selectSingleMarker(page, blockMarker(40));+ await expect(page.getByTestId(BUBBLE_BAR)).toBeVisible();+ await waitForSurfaceSettled(page, BUBBLE_BAR);++ const naturalWidth = await readNaturalSurfaceWidth(page, BUBBLE_BAR);+ await narrowPaneAsFarAsPossible(page);+ // Re-anchor: narrowing reflows the prose, so the block the selection lives+ // in leaves the visible region, at which point `hide()` fires and the+ // containment assertion passes vacuously on an invisible bar.+ await parkSelectionTopAtPaneInset(page, SELECTION_MID_PANE_INSET_PX);+ await waitForSurfaceSettled(page, BUBBLE_BAR);++ const geometry = await readSurfaceGeometry(page, BUBBLE_BAR);+ expect(geometry.present, 'bubble bar still mounted').toBe(true);+ expectPaneNarrowerThan(geometry, naturalWidth, 'bubble bar');+ await expectAnchorInsideRegionHorizontally(page, geometry);+ expectInsideVisibleRegionHorizontally(geometry, 'bubble bar (narrow pane)');+});++test('bubble bar stays inside a narrow pane when the plugin repositions it', async ({+ page,+ api,+}) => {+ await openTallDoc(page, api, 'clip-bar-narrow-plugin');+ await selectSingleMarker(page, blockMarker(40));+ await expect(page.getByTestId(BUBBLE_BAR)).toBeVisible();+ await waitForSurfaceSettled(page, BUBBLE_BAR);++ const naturalWidth = await readNaturalSurfaceWidth(page, BUBBLE_BAR);+ await narrowPaneAsFarAsPossible(page);+ await parkSelectionTopAtPaneInset(page, SELECTION_MID_PANE_INSET_PX);+ await waitForSurfaceSettled(page, BUBBLE_BAR);++ // The plugin fixes `size` after `shift` in an array we cannot reorder, so+ // this arm is what proves the cap is stated on BOTH writers rather than+ // inherited from whichever one happened to run last.+ const written = await repositionViaPluginPath(page);++ const geometry = await readSurfaceGeometry(page, BUBBLE_BAR);+ expect(geometry.present, 'bubble bar still mounted').toBe(true);+ expectGeometryIsThePluginsWrite(written, geometry, 'bubble bar in a narrow pane');+ expectPaneNarrowerThan(geometry, naturalWidth, 'bubble bar (plugin pass)');+ await expectAnchorInsideRegionHorizontally(page, geometry);+ expectInsideVisibleRegionHorizontally(geometry, 'bubble bar (narrow pane, plugin pass)');+});++test('comment composer stays inside a pane narrower than the card', async ({ page, api }) => {+ await openTallDoc(page, api, 'clip-composer-narrow');+ await selectSingleMarker(page, blockMarker(40));+ await expect(page.getByTestId(BUBBLE_BAR)).toBeVisible();++ await page.getByTestId('comment-bubble-button').click();+ await expect(page.getByTestId(COMMENT_COMPOSER)).toBeVisible();+ await waitForSurfaceSettled(page, COMMENT_COMPOSER);++ const naturalWidth = await readNaturalSurfaceWidth(page, COMMENT_COMPOSER);+ await narrowPaneAsFarAsPossible(page);+ await waitForSurfaceSettled(page, COMMENT_COMPOSER);++ const geometry = await readSurfaceGeometry(page, COMMENT_COMPOSER);+ expect(geometry.present, 'comment composer still mounted').toBe(true);+ expectPaneNarrowerThan(geometry, naturalWidth, 'comment composer');+ expectInsideVisibleRegionHorizontally(geometry, 'comment composer (narrow pane)');+});+/*** The same contract at the two remaining editor-anchored floating surfaces:* the suggestion picker (slash / wiki-link / tag) and the markdown-lint hoverdiff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.tsindex d7a845280..dfd95ef49 100644--- a/packages/core/src/bridge/bind-frontmatter-doc.ts+++ b/packages/core/src/bridge/bind-frontmatter-doc.ts@@ -1,3 +1,4 @@+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.tsindex 005627195..8bfdb40cd 100644--- a/packages/core/src/bridge/bridge-invariant.ts+++ b/packages/core/src/bridge/bridge-invariant.ts@@ -1,3 +1,4 @@+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.tsindex f4cc8a286..2a597ec3d 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,3 +1,4 @@+import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';diff --git a/packages/core/src/bridge/divergence-locate.ts b/packages/core/src/bridge/divergence-locate.tsindex 6b505314d..d979f4b39 100644--- a/packages/core/src/bridge/divergence-locate.ts+++ b/packages/core/src/bridge/divergence-locate.ts@@ -1,3 +1,4 @@+import { findFirstDivergenceIndex } from './tolerance-telemetry.ts';export const BRIDGE_LINE_KINDS = [diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex 8fb428b90..01ef76a9f 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,3 +1,4 @@+import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';diff --git a/packages/core/src/bridge/growth-detect.ts b/packages/core/src/bridge/growth-detect.tsindex 9d9c244b0..463e89595 100644--- a/packages/core/src/bridge/growth-detect.ts+++ b/packages/core/src/bridge/growth-detect.ts@@ -1,3 +1,4 @@+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.tsindex c43fdd7e7..0939885bb 100644--- a/packages/core/src/bridge/intraline-predicate.ts+++ b/packages/core/src/bridge/intraline-predicate.ts@@ -1,3 +1,4 @@+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.tsindex 251560a35..c0dc65705 100644--- a/packages/core/src/bridge/merge-three-way.ts+++ b/packages/core/src/bridge/merge-three-way.ts@@ -65,6 +65,7 @@ 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.tsindex 01ac80099..dcc5b0690 100644--- a/packages/core/src/bridge/normalize.ts+++ b/packages/core/src/bridge/normalize.ts@@ -1,3 +1,4 @@+import { stripFrontmatter } from '../extensions/frontmatter.ts';import { bodyEdgeEmpties } from './doc-boundary-space.ts';diff --git a/packages/core/src/bridge/pm-structural-equivalence.ts b/packages/core/src/bridge/pm-structural-equivalence.tsindex 754dc5cc2..0be5203e4 100644--- a/packages/core/src/bridge/pm-structural-equivalence.ts+++ b/packages/core/src/bridge/pm-structural-equivalence.ts@@ -32,6 +32,7 @@ const BR_SENTINEL: PmStructuralNode = { type: '__br__' };const BR_LITERAL_RE = /^<br\s*\/?>$/i;+interface DegradeEntry {readonly label: string;readonly severity: ToleranceClassSeverity;@@ -127,6 +128,7 @@ 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(@@ -248,6 +250,7 @@ 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.tsindex af20de1e2..dca644141 100644--- a/packages/core/src/bridge/subsequence.ts+++ b/packages/core/src/bridge/subsequence.ts@@ -1,3 +1,4 @@+/** 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/markdown/callout-transformer.ts b/packages/core/src/markdown/callout-transformer.tsindex 83d47404a..a363dfd54 100644--- a/packages/core/src/markdown/callout-transformer.ts+++ b/packages/core/src/markdown/callout-transformer.ts@@ -1,3 +1,4 @@+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.tsindex 9807a7e82..4499dbc92 100644--- a/packages/core/src/markdown/code-fence.ts+++ b/packages/core/src/markdown/code-fence.ts@@ -1,3 +1,4 @@+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.tsindex 7415c474a..34704165b 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,3 +1,4 @@+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.tsindex ece5c02a1..b6299a948 100644--- a/packages/core/src/markdown/dedent-block-jsx-close.ts+++ b/packages/core/src/markdown/dedent-block-jsx-close.ts@@ -1,3 +1,4 @@+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.tsindex 54774764a..acd398aa6 100644--- a/packages/core/src/markdown/details-accordion-promoter.ts+++ b/packages/core/src/markdown/details-accordion-promoter.ts@@ -1,3 +1,4 @@+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.tsindex 43ecdc709..ba9b56384 100644--- a/packages/core/src/markdown/div-align-promoter.ts+++ b/packages/core/src/markdown/div-align-promoter.ts@@ -1,3 +1,4 @@+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.tsindex 6d3f3643e..4513da9bb 100644--- a/packages/core/src/markdown/fence-regions.ts+++ b/packages/core/src/markdown/fence-regions.ts@@ -1,3 +1,4 @@+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.tsindex 00f5771ee..6931623c7 100644--- a/packages/core/src/markdown/fixtures/index.ts+++ b/packages/core/src/markdown/fixtures/index.ts@@ -1,3 +1,4 @@+import { readFileSync } from 'node:fs';import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';@@ -8,6 +9,7 @@ function fixturePath(...segments: string[]): string {return resolve(FIXTURES_DIR, ...segments);}+interface GfmExample {section: string;markdown: string;@@ -17,6 +19,7 @@ export function loadGfmExamples(): GfmExample[] {return JSON.parse(readFileSync(fixturePath('gfm', 'examples.json'), 'utf8')) as GfmExample[];}+interface MdxCrashEntry {id: string;input: string;@@ -68,6 +71,7 @@ export function loadLargeEmbedFixtures(): LargeEmbedFixture[] {) as LargeEmbedFixture[];}+export function loadPrd6955Before(): string {return readFileSync(fixturePath('regression', 'prd-6955-before.md'), 'utf8');}@@ -76,6 +80,7 @@ export function loadPrd6955CorruptedTriplicated(): string {return readFileSync(fixturePath('regression', 'prd-6955-corrupted-triplicated.md'), 'utf8');}+export interface NgPinnedCase {id: string;name: string;@@ -92,6 +97,7 @@ 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.tsindex 8b1eb8519..daa3ef82b 100644--- a/packages/core/src/markdown/fixtures/perf/generate.ts+++ b/packages/core/src/markdown/fixtures/perf/generate.ts@@ -1,3 +1,4 @@+import { writeFileSync } from 'node:fs';import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';@@ -10,6 +11,7 @@ const BASELINE_ONLY_COUNTS = [500, 2500] as const;const SEED = 0xf1de1117;+function mulberry32(seed: number): () => number {let a = seed >>> 0;return () => {@@ -36,6 +38,7 @@ function pickWeighted<T>(rand: () => number, items: readonly [T, number][]): T {return items[items.length - 1][0];}+const WORDS = ['lorem','ipsum',@@ -153,6 +156,7 @@ 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][] = [@@ -191,6 +195,7 @@ 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.tsindex 420dc0fe5..32c055c5b 100644--- a/packages/core/src/markdown/guard-flanking-matrix.ts+++ b/packages/core/src/markdown/guard-flanking-matrix.ts@@ -7,6 +7,7 @@ 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.tsindex 2653473da..283913255 100644--- a/packages/core/src/markdown/handler-shadow-audit.ts+++ b/packages/core/src/markdown/handler-shadow-audit.ts@@ -1,3 +1,4 @@+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.tsindex da0a81d23..5d1000cc4 100644--- a/packages/core/src/markdown/highlight-promoter.ts+++ b/packages/core/src/markdown/highlight-promoter.ts@@ -1,3 +1,4 @@+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.tsindex 787315157..9681c0056 100644--- a/packages/core/src/markdown/html-to-mdast.ts+++ b/packages/core/src/markdown/html-to-mdast.ts@@ -1,3 +1,4 @@+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';@@ -128,7 +129,8 @@ export function htmlToMdast(html: string, options?: HtmlToMdastOptions): MdastRothrow 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.tsindex 706fa9afb..994eb6917 100644--- a/packages/core/src/markdown/image-promoter.ts+++ b/packages/core/src/markdown/image-promoter.ts@@ -1,3 +1,4 @@+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.tsindex 779e27500..ec1ac1b7e 100644--- a/packages/core/src/markdown/index.ts+++ b/packages/core/src/markdown/index.ts@@ -1,3 +1,4 @@+import {type FromProseMirrorOptions,fromPmMark,@@ -206,6 +207,7 @@ export class MarkdownManager {}}+const registry = createRegistry();function destructureAttrs(@@ -254,6 +256,7 @@ function destructureAttrs(return result;}+function hasDirtyDescendant(node: PmNode): boolean {let found = false;node.descendants((child) => {@@ -276,6 +279,7 @@ function effectiveDirty(node: PmNode, freshnessChecker?: StructuralFreshnessChecreturn freshnessChecker ? freshnessChecker.isDiverged(node.toJSON()) : false;}+function isEmptyMdastParagraph(node: MdastNodes): boolean {if (node.type !== 'paragraph') return false;const children = node.children ?? [];@@ -344,6 +348,7 @@ function extractTextFromMdastNodes(nodes: MdastNodes[]): string {return out;}+import {AUDIO_EXTENSIONS,FILE_ATTACHMENT_EXTENSIONS,@@ -596,6 +601,7 @@ function buildMdastToPmHandlers(}));}+if (m.emphasis) {handlers.emphasis = toPmMark(m.emphasis, (node: Emphasis) => ({sourceDelimiter: node.data?.sourceDelimiter ?? '*',@@ -676,6 +682,7 @@ function buildMdastToPmHandlers(}));}+if (m.link) {const sourceLiteralMark = m.sourceLiteral;handlers.link = (node: Link, _parent: MdastParent, state: MdastToPmState) => {@@ -973,6 +980,7 @@ function buildMdastToPmHandlers(};}+const blockUnknownHandler = (node: {type: string;position?: { start: { offset: number }; end: { offset: number } };@@ -1098,6 +1106,7 @@ function buildMdastToPmHandlers(return handlers as RemarkProseMirrorOptions['handlers'];}+function buildPmToMdastHandlers(schema: Schema,freshness: FreshnessCheckerHolder,diff --git a/packages/core/src/markdown/lint/applies-to.ts b/packages/core/src/markdown/lint/applies-to.tsindex fa0be9e86..b79e9aef7 100644--- a/packages/core/src/markdown/lint/applies-to.ts+++ b/packages/core/src/markdown/lint/applies-to.ts@@ -1,3 +1,4 @@+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.tsindex 312c9c74b..94b34dee1 100644--- a/packages/core/src/markdown/lint/config-files.ts+++ b/packages/core/src/markdown/lint/config-files.ts@@ -1,3 +1,4 @@+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.tsindex 1a81aa524..fbbd309df 100644--- a/packages/core/src/markdown/lint/config-schemas.ts+++ b/packages/core/src/markdown/lint/config-schemas.ts@@ -52,6 +52,7 @@ 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.tsindex d48eea5e4..a51f2ffb0 100644--- a/packages/core/src/markdown/lint/default-config.ts+++ b/packages/core/src/markdown/lint/default-config.ts@@ -6,6 +6,7 @@ export const DEFAULT_MARKDOWNLINT_CONFIG: Record<string, MarkdownlintRuleSettingMD013: 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.tsindex ef478e268..9c9542661 100644--- a/packages/core/src/markdown/lint/frontmatter-schema-edit.ts+++ b/packages/core/src/markdown/lint/frontmatter-schema-edit.ts@@ -1,3 +1,4 @@+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.tsindex 5f953d667..b0e7833fd 100644--- a/packages/core/src/markdown/lint/frontmatter-validate.ts+++ b/packages/core/src/markdown/lint/frontmatter-validate.ts@@ -1,3 +1,4 @@+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.tsindex 11b5abdfd..ffd277a90 100644--- a/packages/core/src/markdown/lint/index.ts+++ b/packages/core/src/markdown/lint/index.ts@@ -1,3 +1,4 @@+import { LINT_PLUGINS, type LinterConfig } from './plugins.ts';import type { LintDiagnostic } from './types.ts';diff --git a/packages/core/src/markdown/lint/okf-frontmatter/materialize.ts b/packages/core/src/markdown/lint/okf-frontmatter/materialize.tsindex 7a5af097e..f438f1b16 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/materialize.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/materialize.ts@@ -1,3 +1,4 @@+import type { OkfRuleId } from '../okf-rule-meta.ts';import { fileNameFor, OKF_SCHEMA_DIR, okfSchemaPathFor } from './paths.ts';import { OKF_FRONTMATTER_REGISTRY } from './registry.ts';diff --git a/packages/core/src/markdown/lint/okf-frontmatter/paths.ts b/packages/core/src/markdown/lint/okf-frontmatter/paths.tsindex 1ee913527..c290b6878 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/paths.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/paths.ts@@ -1,3 +1,4 @@+import type { OkfRuleId } from '../okf-rule-meta.ts';export const OKF_SCHEMA_DIR = '.ok/okf';diff --git a/packages/core/src/markdown/lint/okf-frontmatter/registry.ts b/packages/core/src/markdown/lint/okf-frontmatter/registry.tsindex f325fbbb4..53ecb619d 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/registry.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/registry.ts@@ -1,3 +1,4 @@+import { compileAppliesTo } from '../applies-to.ts';import { validateFrontmatterSource } from '../frontmatter-validate.ts';import {diff --git a/packages/core/src/markdown/lint/okf-frontmatter/schemas.ts b/packages/core/src/markdown/lint/okf-frontmatter/schemas.tsindex f1c37671b..89845d3d5 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/schemas.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/schemas.ts@@ -1,3 +1,4 @@+// file-level form is deliberate: the sibling `biome-ignore` must sit on the line// oxlint-disable unicorn/no-thenablediff --git a/packages/core/src/markdown/lint/okf-project/rules.ts b/packages/core/src/markdown/lint/okf-project/rules.tsindex 6d691ae2b..8b476332e 100644--- a/packages/core/src/markdown/lint/okf-project/rules.ts+++ b/packages/core/src/markdown/lint/okf-project/rules.ts@@ -1,3 +1,4 @@+import { SUPPORTED_DOC_EXTENSIONS } from '../../../constants/doc-extensions.ts';import { isOkfRuleEnabled, type OkfRuleId, type OkfRuleToggles } from '../okf-rule-meta.ts';diff --git a/packages/core/src/markdown/lint/okf-rule-meta.ts b/packages/core/src/markdown/lint/okf-rule-meta.tsindex 4de50d79f..44913a9dc 100644--- a/packages/core/src/markdown/lint/okf-rule-meta.ts+++ b/packages/core/src/markdown/lint/okf-rule-meta.ts@@ -1,3 +1,4 @@+export const OKF_RULE_IDS = ['no-wiki-links','log-shape',diff --git a/packages/core/src/markdown/lint/okf-rules.ts b/packages/core/src/markdown/lint/okf-rules.tsindex 1d5538421..d0999b62e 100644--- a/packages/core/src/markdown/lint/okf-rules.ts+++ b/packages/core/src/markdown/lint/okf-rules.ts@@ -1,3 +1,4 @@+import { isOkfRuleEnabled, type OkfRuleId, type OkfRuleToggles } from './okf-rule-meta.ts';import type { OkfRule } from './okf-runner.ts';import { indexShape } from './rules/index-shape.ts';diff --git a/packages/core/src/markdown/lint/okf-runner.ts b/packages/core/src/markdown/lint/okf-runner.tsindex de130e3f4..fabb08d6e 100644--- a/packages/core/src/markdown/lint/okf-runner.ts+++ b/packages/core/src/markdown/lint/okf-runner.ts@@ -1,3 +1,4 @@+import type { Root } from 'mdast';import remarkFrontmatter from 'remark-frontmatter';import remarkGfm from 'remark-gfm';diff --git a/packages/core/src/markdown/lint/plugins.ts b/packages/core/src/markdown/lint/plugins.tsindex 09c8450ee..0a089990e 100644--- a/packages/core/src/markdown/lint/plugins.ts+++ b/packages/core/src/markdown/lint/plugins.ts@@ -1,3 +1,4 @@+import { z } from 'zod';import { DEFAULT_MARKDOWNLINT_CONFIG, resolveMarkdownlintConfig } from './default-config.ts';import {@@ -23,6 +24,7 @@ import {type OkfSlice,} from './types.ts';+const MarkdownlintRuleSettingSchema = z.union([z.boolean(),z.enum(MARKDOWNLINT_RULE_SEVERITIES),diff --git a/packages/core/src/markdown/lint/rules/index-shape.ts b/packages/core/src/markdown/lint/rules/index-shape.tsindex 59fe9b87d..fcbb1b56c 100644--- a/packages/core/src/markdown/lint/rules/index-shape.ts+++ b/packages/core/src/markdown/lint/rules/index-shape.ts@@ -1,3 +1,4 @@+import type { List, ListItem } from 'mdast';import { EXIT, visit } from 'unist-util-visit';import { defineScopedOkfRule } from '../okf-runner.ts';diff --git a/packages/core/src/markdown/lint/rules/log-shape.ts b/packages/core/src/markdown/lint/rules/log-shape.tsindex e0159519f..431e4e9c8 100644--- a/packages/core/src/markdown/lint/rules/log-shape.ts+++ b/packages/core/src/markdown/lint/rules/log-shape.ts@@ -1,3 +1,4 @@+import type { Heading } from 'mdast';import { toString as headingText } from 'mdast-util-to-string';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/lint/rules/no-wiki-links.ts b/packages/core/src/markdown/lint/rules/no-wiki-links.tsindex 2123e977f..f75a04d15 100644--- a/packages/core/src/markdown/lint/rules/no-wiki-links.ts+++ b/packages/core/src/markdown/lint/rules/no-wiki-links.ts@@ -1,3 +1,4 @@+import type { Point } from 'unist';import { visit } from 'unist-util-visit';import { defineOkfRule } from '../okf-runner.ts';diff --git a/packages/core/src/markdown/lint/rules/reserved-casing.ts b/packages/core/src/markdown/lint/rules/reserved-casing.tsindex 89ef3e4a9..c8b4d8f28 100644--- a/packages/core/src/markdown/lint/rules/reserved-casing.ts+++ b/packages/core/src/markdown/lint/rules/reserved-casing.ts@@ -1,3 +1,4 @@+import { SUPPORTED_DOC_EXTENSIONS } from '../../../constants/doc-extensions.ts';import { defineOkfRule } from '../okf-runner.ts';diff --git a/packages/core/src/markdown/lint/types.ts b/packages/core/src/markdown/lint/types.tsindex 6836b962d..c04fa4de0 100644--- a/packages/core/src/markdown/lint/types.ts+++ b/packages/core/src/markdown/lint/types.ts@@ -1,3 +1,4 @@+import type { BrokenLinkReason } from '../../schemas/api/agent-write.ts';import type { OkfRuleId } from './okf-rule-meta.ts';@@ -112,6 +113,7 @@ export interface OkfSlice {generate?: { index?: boolean };}+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.tsindex 98238656e..437cc539a 100644--- a/packages/core/src/markdown/lint/validation-counts.ts+++ b/packages/core/src/markdown/lint/validation-counts.ts@@ -1,3 +1,4 @@+export interface ValidationSourceCounts {errorCount: number;warningCount: number;diff --git a/packages/core/src/markdown/math-promoter.ts b/packages/core/src/markdown/math-promoter.tsindex a5b511f25..bd79424c7 100644--- a/packages/core/src/markdown/math-promoter.ts+++ b/packages/core/src/markdown/math-promoter.ts@@ -1,3 +1,4 @@+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.tsindex ed89371d0..00fbc0035 100644--- a/packages/core/src/markdown/mdast-to-hast-handlers.ts+++ b/packages/core/src/markdown/mdast-to-hast-handlers.ts@@ -1,3 +1,4 @@+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.tsindex 8ce2b2492..df788a80d 100644--- a/packages/core/src/markdown/mdast-to-html.ts+++ b/packages/core/src/markdown/mdast-to-html.ts@@ -1,3 +1,4 @@+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.tsindex bfd7e3109..fa3cfcd86 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,3 +1,4 @@+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.tsindex 1a897fca8..17ed2b829 100644--- a/packages/core/src/markdown/mermaid-promoter.ts+++ b/packages/core/src/markdown/mermaid-promoter.ts@@ -1,3 +1,4 @@+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.tsindex d988f4b8b..4aa0490c4 100644--- a/packages/core/src/markdown/parse-with-fallback.ts+++ b/packages/core/src/markdown/parse-with-fallback.ts@@ -168,6 +168,7 @@ export function parseRecursive(}}+interface VFilePlace {offset?: number;start?: { offset?: number };@@ -186,6 +187,7 @@ function extractErrorOffset(err: unknown): number | undefined {return undefined;}+interface Region {start: number;end: number;@@ -209,6 +211,7 @@ function nearestBlankLineAfter(src: string, offset: number): number | null {return null;}+export interface TagEvent {kind: 'open' | 'close' | 'self-close';name: string;@@ -355,6 +358,7 @@ function findFallbackRegion(src: string, errorOffset: number): Region {return { start: blockStart, end: blockEnd };}+interface SourceBlock {src: string;start: number;@@ -452,6 +456,7 @@ 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.tsindex e6ab4fd57..43d420187 100644--- a/packages/core/src/markdown/parser-drop-closure.ts+++ b/packages/core/src/markdown/parser-drop-closure.ts@@ -1,3 +1,4 @@+export type DroppedTokenAdjudication =| {kind: 'format-dof-axis';diff --git a/packages/core/src/markdown/pipeline.ts b/packages/core/src/markdown/pipeline.tsindex 0e3224206..55736041c 100644--- a/packages/core/src/markdown/pipeline.ts+++ b/packages/core/src/markdown/pipeline.ts@@ -1,3 +1,4 @@+import {type FromProseMirrorOptions,fromProseMirror,diff --git a/packages/core/src/markdown/position-aware-join.ts b/packages/core/src/markdown/position-aware-join.tsindex 91cdf658f..ccf06e94d 100644--- a/packages/core/src/markdown/position-aware-join.ts+++ b/packages/core/src/markdown/position-aware-join.ts@@ -1,3 +1,4 @@+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.tsindex 0f399d34c..e5b4c9eba 100644--- a/packages/core/src/markdown/position-slice.ts+++ b/packages/core/src/markdown/position-slice.ts@@ -1,3 +1,4 @@+import type { Nodes, Root } from 'mdast';import { visit } from 'unist-util-visit';import type { VFile } from 'vfile';@@ -476,7 +477,8 @@ 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.tsindex db10fa54b..ca225ce9b 100644--- a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts+++ b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts@@ -1,3 +1,4 @@+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.tsindex 34068d103..3a2524a9a 100644--- a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts@@ -1,3 +1,4 @@+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.tsindex 93151d43b..2279a0189 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts@@ -1,3 +1,4 @@+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.tsindex 188f02d83..a0f467c42 100644--- a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts@@ -1,3 +1,4 @@+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.tsindex 4ba2c3418..4e8542a21 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts@@ -1,3 +1,4 @@+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.tsindex 1a74b1272..a3c96b24a 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts@@ -1,3 +1,4 @@+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.tsindex de35e7b79..e95cf43d6 100644--- a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts@@ -1,3 +1,4 @@+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.tsindex b4be1b2ea..ffdb4d5b5 100644--- a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts@@ -1,3 +1,4 @@+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.tsindex 3c8d88b7c..e2a96d1a7 100644--- a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts@@ -1,3 +1,4 @@+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.tsindex cf2c9da8e..0389575ac 100644--- a/packages/core/src/markdown/resolve-image-url.ts+++ b/packages/core/src/markdown/resolve-image-url.ts@@ -1,3 +1,4 @@+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.tsindex 4d3250d3a..8be632ba4 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,3 +1,4 @@+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.tsindex 0dd54070e..96304e7a5 100644--- a/packages/core/src/markdown/serialize-fidelity.test-helper.ts+++ b/packages/core/src/markdown/serialize-fidelity.test-helper.ts@@ -1,3 +1,4 @@+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.tsindex 7cac5b042..93798cf83 100644--- a/packages/core/src/markdown/serialize-helpers.ts+++ b/packages/core/src/markdown/serialize-helpers.ts@@ -1,3 +1,4 @@+import type { Node as PmNode } from '@tiptap/pm/model';import type {MdxJsxAttribute,diff --git a/packages/core/src/markdown/single-dollar-math-promoter.ts b/packages/core/src/markdown/single-dollar-math-promoter.tsindex b012a5aff..8c08b7a04 100644--- a/packages/core/src/markdown/single-dollar-math-promoter.ts+++ b/packages/core/src/markdown/single-dollar-math-promoter.ts@@ -1,3 +1,4 @@+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.tsindex 3e79f8cb6..959cc0bd2 100644--- a/packages/core/src/markdown/to-markdown-handlers.ts+++ b/packages/core/src/markdown/to-markdown-handlers.ts@@ -1,3 +1,4 @@+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';diff --git a/packages/core/src/markdown/underline-promoter.ts b/packages/core/src/markdown/underline-promoter.tsindex 0f1b0f27d..6e6d73400 100644--- a/packages/core/src/markdown/underline-promoter.ts+++ b/packages/core/src/markdown/underline-promoter.ts@@ -1,3 +1,4 @@+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.tsindex 1a082bda7..932d7d2a8 100644--- a/packages/core/src/markdown/unknown-mdast-guard.ts+++ b/packages/core/src/markdown/unknown-mdast-guard.ts@@ -1,3 +1,4 @@+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.tsindex d578476a7..ac9f5239b 100644--- a/packages/core/src/markdown/whitespace-char-ref.ts+++ b/packages/core/src/markdown/whitespace-char-ref.ts@@ -1,3 +1,4 @@+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.tsindex 6dad26200..afd9936fe 100644--- a/packages/core/src/markdown/wiki-link-micromark.ts+++ b/packages/core/src/markdown/wiki-link-micromark.ts@@ -17,6 +17,7 @@ declare module 'micromark-util-types' {}}+const CODE_BANG = 33; // !const CODE_LBRACKET = 91; // [const CODE_RBRACKET = 93; // ]@@ -260,6 +261,7 @@ export function wikiLinkSyntax(): Extension {};}+function enterWikiLink(this: CompileContext, token: Token) {this.enter({@@ -385,6 +387,7 @@ export const wikiLinkToMarkdown: {unsafe: [{ character: '[', inConstruct: ['phrasing'] }],};+const MICROMARK_EXT = wikiLinkSyntax();export function remarkWikiLink(this: Processor) {