Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): nested list-item boundary merges on delete keys (#2630)

Nick Gomez2152b0df5c7e
diff --git a/.changeset/list-boundary-merge-nested.md b/.changeset/list-boundary-merge-nested.md
new file mode 100644
index 000000000..bc1c9bbcc
--- /dev/null
+++ b/.changeset/list-boundary-merge-nested.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Fixes Backspace/Delete merges at nested list-item boundaries (inkeep/open-knowledge#609). Backspace at the start of an item whose previous sibling has a nested sublist no longer lifts the item out of the list as a bare paragraph with no bullet or checkbox, and forward Delete at the end of a nested item before a shallower item no longer re-nests that item at the wrong depth or silently drops its checkbox. Both fixes cover the Mod-Backspace/Mod-Delete variants; flat-list merges, first-item lift-out, and autoformat undo behavior are unchanged. Supersedes and credits inkeep/open-knowledge#613 by @blokboy.
diff --git a/packages/app/src/editor/list-boundary-merge.test.ts b/packages/app/src/editor/list-boundary-merge.test.ts
new file mode 100644
index 000000000..a89c87009
--- /dev/null
+++ b/packages/app/src/editor/list-boundary-merge.test.ts
@@ -0,0 +1,439 @@
+/**
+ * Backspace/Delete merges at NESTED list-item boundaries (#609).
+ *
+ * StarterKit's ListKeymap sub-extension (@tiptap/extension-list, configured
+ * for the unified schema in core shared.ts) misfires in two of its branches
+ * at nested boundaries — schema-independently, by upstream design:
+ *
+ * Orphan mint: Backspace at the start of item B when the PREVIOUS
+ * sibling item A has a nested sublist. handleBackspace's
+ * `previousListItemHasSubList` check skips joinItemBackward and falls
+ * through to `liftListItem`, lifting B clean out of the list into a
+ * bare paragraph with no bullet/checkbox.
+ * Depth + data loss: Delete at the end of a NESTED item when the
+ * next item is SHALLOWER. handleDelete's `nextListIsHigher` branch
+ * runs `joinForward().joinBackward()`, re-nesting the next item at the
+ * wrong depth and silently dropping its `checked` attr
+ * (`- [ ] d` becomes ` - d`).
+ *
+ * The ListBoundaryMerge extension (core) preempts exactly those two
+ * configurations with joinTextblockBackward/joinTextblockForward and falls
+ * through everywhere else, so ListKeymap's good branches (flat joins,
+ * first-item lift, undoInputRule, trailing-paragraph rejoin, empty-nested-
+ * item removal) keep running — pinned by the control blocks below.
+ *
+ * Each test mounts a real TipTap editor over the core schema and dispatches
+ * a real `keydown` through `view.someProp('handleKeyDown', ...)` — the same
+ * path a live keypress takes — so the assertions cover the actual
+ * registered keymap-plugin precedence, not a single command in isolation.
+ *
+ * Test scenarios credited to inkeep/open-knowledge#613 by @blokboy.
+ */
+
+import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
+import { MarkdownManager, sharedExtensions } from '@inkeep/open-knowledge-core';
+import { Editor, Extension, type JSONContent } from '@tiptap/core';
+import { Plugin, TextSelection } from '@tiptap/pm/state';
+import { installDomGlobals } from './walk-currency-test-harness';
+
+const mdManager = new MarkdownManager({ extensions: sharedExtensions });
+
+let restoreDomGlobals: (() => void) | null = null;
+const editors: Editor[] = [];
+
+beforeAll(() => {
+ restoreDomGlobals = installDomGlobals();
+});
+
+afterAll(() => {
+ restoreDomGlobals?.();
+ restoreDomGlobals = null;
+});
+
+afterEach(() => {
+ while (editors.length > 0) editors.pop()?.destroy();
+});
+
+function mountEditor(md: string, extraExtensions: Extension[] = []): Editor {
+ const host = document.createElement('div');
+ document.body.appendChild(host);
+ const editor = new Editor({
+ element: host,
+ content: mdManager.parse(md) as JSONContent,
+ extensions: [...sharedExtensions, ...extraExtensions],
+ });
+ editors.push(editor);
+ return editor;
+}
+
+/** Doc position at the start or end of the nth listItem's first paragraph. */
+function itemPos(editor: Editor, n: number, where: 'start' | 'end'): number {
+ let i = 0;
+ let found: number | null = null;
+ editor.state.doc.descendants((node, pos) => {
+ if (found !== null) return false;
+ if (node.type.name === 'listItem') {
+ if (i === n) {
+ const para = node.firstChild;
+ found = where === 'start' ? pos + 2 : pos + 2 + (para ? para.content.size : 0);
+ return false;
+ }
+ i++;
+ }
+ return true;
+ });
+ if (found === null) throw new Error(`listItem ${n} not found`);
+ return found;
+}
+
+function setCaret(editor: Editor, pos: number): void {
+ editor.view.dispatch(editor.state.tr.setSelection(TextSelection.create(editor.state.doc, pos)));
+}
+
+// prosemirror-keymap resolves `Mod-` per platform (Meta on mac, Ctrl
+// elsewhere) — mirror its detection so Mod-key tests bind on both.
+const IS_MAC = /Mac|iP(hone|[oa]d)/.test(navigator.platform ?? '');
+
+function press(editor: Editor, key: string, mods: { mod?: boolean } = {}): unknown {
+ const event = new KeyboardEvent('keydown', {
+ key,
+ code: key,
+ metaKey: (mods.mod ?? false) && IS_MAC,
+ ctrlKey: (mods.mod ?? false) && !IS_MAC,
+ bubbles: true,
+ cancelable: true,
+ });
+ return editor.view.someProp('handleKeyDown', (f) => f(editor.view, event));
+}
+
+function serialize(editor: Editor): string {
+ return mdManager.serialize(editor.getJSON() as JSONContent);
+}
+
+/** A bare/unmarked line sitting below the list where an item used to be. */
+function hasOrphanParagraph(md: string): boolean {
+ return /\n\n[a-z]/i.test(md);
+}
+
+describe('nested-boundary Backspace (D1 — orphan mint)', () => {
+ test('Backspace at start of an item whose previous sibling has a nested sublist merges into the list, no orphan paragraph', () => {
+ const editor = mountEditor('- [ ] top\n - [ ] child\n- [ ] next');
+ setCaret(editor, itemPos(editor, 2, 'start')); // start of "next"
+ expect(press(editor, 'Backspace')).toBe(true);
+
+ const md = serialize(editor);
+ expect(hasOrphanParagraph(md)).toBe(false);
+ // The merge target keeps its checkbox and nested depth — a merge that
+ // dropped child's checkbox would be the same corruption class as the
+ // Delete-side defect.
+ expect(md).toMatch(/^ {2}- \[ \] childnext$/m);
+ expect(md).toContain('- [ ] top');
+ });
+
+ test('Mod-Backspace at the same boundary does not orphan either', () => {
+ const editor = mountEditor('- [ ] top\n - [ ] child\n- [ ] next');
+ setCaret(editor, itemPos(editor, 2, 'start'));
+ expect(press(editor, 'Backspace', { mod: true })).toBe(true);
+
+ const md = serialize(editor);
+ expect(hasOrphanParagraph(md)).toBe(false);
+ expect(md).toMatch(/^ {2}- \[ \] childnext$/m);
+ });
+
+ test('ordered nested boundary: Backspace merges instead of orphaning', () => {
+ const editor = mountEditor('1. top\n 1. child\n2. next');
+ setCaret(editor, itemPos(editor, 2, 'start'));
+ expect(press(editor, 'Backspace')).toBe(true);
+
+ const md = serialize(editor);
+ expect(hasOrphanParagraph(md)).toBe(false);
+ // Merge target keeps its ordered marker and nested indent.
+ expect(md).toMatch(/^ {3}1\. childnext$/m);
+ });
+});
+
+describe('nested-boundary Delete (D2 — wrong depth + checked loss)', () => {
+ test('Delete at end of a nested item merges the next shallower task item at the nested depth, checked attr intact', () => {
+ const editor = mountEditor('- [ ] a\n - [ ] b\n - [ ] c\n- [ ] d');
+ setCaret(editor, itemPos(editor, 2, 'end')); // end of "c"
+ expect(press(editor, 'Delete')).toBe(true);
+
+ const md = serialize(editor);
+ // The exact pre-fix corruption is ` - d` — plain bullet, wrong depth,
+ // checkbox dropped. The merged text must land on "c" with its checkbox.
+ expect(md).toContain(' - [ ] cd');
+ expect(md).not.toMatch(/^ {2}- d$/m);
+ expect(hasOrphanParagraph(md)).toBe(false);
+ });
+
+ test('Mod-Delete at the same boundary preserves depth and checkbox too', () => {
+ const editor = mountEditor('- [ ] a\n - [ ] b\n - [ ] c\n- [ ] d');
+ setCaret(editor, itemPos(editor, 2, 'end'));
+ expect(press(editor, 'Delete', { mod: true })).toBe(true);
+
+ const md = serialize(editor);
+ expect(md).toContain(' - [ ] cd');
+ expect(md).not.toMatch(/^ {2}- d$/m);
+ });
+
+ test('plain bullet variant: Delete at end of nested item merges shallower item without re-nesting artifacts', () => {
+ const editor = mountEditor('- a\n - b\n- c');
+ setCaret(editor, itemPos(editor, 1, 'end')); // end of "b"
+ expect(press(editor, 'Delete')).toBe(true);
+
+ const md = serialize(editor);
+ expect(md).toContain(' - bc');
+ expect(hasOrphanParagraph(md)).toBe(false);
+ });
+});
+
+describe('preserved stock behaviors (controls — must hold before and after the fix)', () => {
+ test('flat-list Backspace merge stays clean (ListKeymap joinItemBackward)', () => {
+ const editor = mountEditor('- [ ] alpha\n- [ ] bravo\n- [x] charlie');
+ setCaret(editor, itemPos(editor, 2, 'start'));
+ expect(press(editor, 'Backspace')).toBe(true);
+
+ const md = serialize(editor);
+ expect(md).toContain('- [ ] bravocharlie');
+ expect(hasOrphanParagraph(md)).toBe(false);
+ });
+
+ test('flat-list Delete merge stays clean (ListKeymap joinItemForward)', () => {
+ const editor = mountEditor('- [ ] alpha\n- [ ] bravo\n- [x] charlie');
+ setCaret(editor, itemPos(editor, 1, 'end'));
+ expect(press(editor, 'Delete')).toBe(true);
+
+ const md = serialize(editor);
+ expect(md).toContain('- [ ] bravocharlie');
+ });
+
+ test('Backspace at the very start of the FIRST item lifts it out to a standalone paragraph (stock un-list)', () => {
+ const editor = mountEditor('above\n\n- alpha\n- bravo');
+ setCaret(editor, itemPos(editor, 0, 'start'));
+ press(editor, 'Backspace');
+
+ const md = serialize(editor);
+ // Stock semantics: alpha lifts to its own paragraph — it is NOT glued
+ // into the "above" paragraph, and bravo stays a list item.
+ expect(md).toContain('above');
+ expect(md).not.toContain('abovealpha');
+ expect(md).toMatch(/^alpha$/m);
+ expect(md).toContain('- bravo');
+ });
+
+ test('Backspace right after a "- " autoformat undoes the input rule (stock undoInputRule)', () => {
+ const editor = mountEditor('seed paragraph');
+ // Place cursor in a fresh empty paragraph below and simulate typing "- ".
+ editor.commands.setContent({ type: 'doc', content: [{ type: 'paragraph' }] });
+ const { view } = editor;
+ editor.commands.insertContentAt(1, '-');
+ const from = view.state.selection.from;
+ const to = view.state.selection.to;
+ const handled = view.someProp('handleTextInput', (f) =>
+ f(view, from, to, ' ', () => view.state.tr.insertText(' ', from, to)),
+ );
+ // The wrapping input rule must have fired for this control to be
+ // meaningful; guard so a silent no-op cannot fake a pass.
+ expect(handled).toBe(true);
+ expect(editor.state.doc.firstChild?.type.name).toBe('list');
+
+ press(editor, 'Backspace');
+ // Stock semantics: the fresh item dissolves back — no list remains, and
+ // nothing merged into a previous block.
+ expect(editor.state.doc.firstChild?.type.name).toBe('paragraph');
+ });
+
+ test('Backspace on the empty paragraph after a list rejoins the list (no stray bullet)', () => {
+ const editor = mountEditor('- item one\n');
+ setCaret(editor, editor.state.doc.content.size - 1);
+ press(editor, 'Enter'); // empty second item
+ press(editor, 'Enter'); // lifts out to a plain paragraph below the list
+ press(editor, 'Backspace'); // must rejoin the list, not spawn a bullet
+
+ const md = serialize(editor).trim();
+ expect(md).toBe('- item one');
+ expect(md).not.toMatch(/^- *$/m);
+ });
+
+ test('Backspace on an empty nested item removes it', () => {
+ const editor = mountEditor('- top\n - sub\n');
+ setCaret(editor, editor.state.doc.content.size - 1);
+ press(editor, 'Enter'); // empty nested item after "sub"
+ press(editor, 'Backspace'); // removes the empty item
+
+ const md = serialize(editor);
+ expect(md).toMatch(/^- top\n {2}- sub\n?$/m);
+ expect(md.match(/- sub/g)).toHaveLength(1);
+ });
+
+ test('a ranged selection spanning the nested boundary deletes via the normal path', () => {
+ const editor = mountEditor('- [ ] top\n - [ ] child\n- [ ] next');
+ const from = itemPos(editor, 1, 'start'); // start of "child"
+ const to = itemPos(editor, 2, 'start'); // start of "next"
+ editor.view.dispatch(
+ editor.state.tr.setSelection(TextSelection.create(editor.state.doc, from, to)),
+ );
+ // Neither Backspace handler owns ranged selections — dispatch falls
+ // through to the default deleteSelection path.
+ press(editor, 'Backspace');
+
+ const md = serialize(editor);
+ expect(md).toContain('- [ ] top');
+ expect(md).not.toContain('child');
+ // The trailing item survives the ranged delete intact — not orphaned,
+ // not corrupted.
+ expect(md).toContain('next');
+ expect(hasOrphanParagraph(md)).toBe(false);
+ });
+});
+
+describe('keymap layering (precedent #48 control)', () => {
+ /**
+ * The app's slash-command popup consumes Enter/Tab through a plain
+ * priority-100 plugin registered AFTER the shared extensions (the
+ * @tiptap/suggestion pattern). A core list extension must never out-race
+ * it — the rejected #613 `priority: 101` delivery did exactly that. This
+ * probe replicates the arrangement: a later-registered priority-100
+ * key consumer must still see Enter and Tab first inside a list item.
+ */
+ function keyConsumerProbe(seen: string[]): Extension {
+ return Extension.create({
+ name: 'keyConsumerProbe',
+ addProseMirrorPlugins() {
+ return [
+ new Plugin({
+ props: {
+ handleKeyDown(_view, event) {
+ if (event.key === 'Enter' || event.key === 'Tab') {
+ seen.push(event.key);
+ return true;
+ }
+ return false;
+ },
+ },
+ }),
+ ];
+ },
+ });
+ }
+
+ test('a later-registered priority-100 Enter/Tab consumer still receives Enter inside a list item', () => {
+ const seen: string[] = [];
+ const editor = mountEditor('- [ ] alpha\n- [ ] bravo', [keyConsumerProbe(seen)]);
+ setCaret(editor, itemPos(editor, 0, 'end'));
+ const before = editor.state.doc.toString();
+ expect(press(editor, 'Enter')).toBe(true);
+
+ expect(seen).toEqual(['Enter']);
+ expect(editor.state.doc.toString()).toBe(before); // no split happened
+ });
+
+ test('the same consumer still receives Tab inside a list item', () => {
+ const seen: string[] = [];
+ const editor = mountEditor('- [ ] alpha\n- [ ] bravo', [keyConsumerProbe(seen)]);
+ setCaret(editor, itemPos(editor, 1, 'end'));
+ const before = editor.state.doc.toString();
+ expect(press(editor, 'Tab')).toBe(true);
+
+ expect(seen).toEqual(['Tab']);
+ expect(editor.state.doc.toString()).toBe(before); // no sink happened
+ });
+});
+
+describe('three-level nesting', () => {
+ test('Backspace at start of a top-level item after a 3-level nested chain merges into the deepest textblock', () => {
+ const editor = mountEditor('- a\n - b\n - c\n- d');
+ setCaret(editor, itemPos(editor, 3, 'start')); // start of "d"
+ expect(press(editor, 'Backspace')).toBe(true);
+
+ const md = serialize(editor);
+ expect(hasOrphanParagraph(md)).toBe(false);
+ // "d" lands on "c" at its level-3 depth — not one or two levels
+ // shallower.
+ expect(md).toMatch(/^ {4}- cd$/m);
+ expect(md).toContain('- a');
+ });
+
+ test('Delete at end of a 3rd-level item merges the next shallower item at the deep depth', () => {
+ const editor = mountEditor('- a\n - b\n - c\n - d');
+ setCaret(editor, itemPos(editor, 2, 'end')); // end of "c" (3rd level)
+ expect(press(editor, 'Delete')).toBe(true);
+
+ const md = serialize(editor);
+ // "d" lands at c's level-3 depth (4-space indent) — not one level too
+ // shallow, which would be the same wrong-depth class as the 2-level
+ // defect.
+ expect(md).toMatch(/^ {4}- cd$/m);
+ expect(md).not.toMatch(/^ {2}- cd$/m);
+ expect(hasOrphanParagraph(md)).toBe(false);
+ expect(md).toContain(' - b');
+ });
+});
+
+describe('unusual merge targets in the owned configuration', () => {
+ test('Backspace merges into a code block when it is the deepest preceding textblock', () => {
+ const editor = mountEditor('- top\n - child\n\n ```\n fence\n ```\n- next');
+ setCaret(editor, itemPos(editor, 2, 'start')); // start of "next"
+ expect(press(editor, 'Backspace')).toBe(true);
+
+ const md = serialize(editor);
+ // joinTextblockBackward descends to the code block and merges there —
+ // no fallthrough to the upstream lift, no orphan paragraph.
+ expect(md).toContain('fencenext');
+ expect(md).not.toMatch(/\n\nnext/);
+ });
+
+ test('Backspace on a fresh autoformatted empty item at the nested boundary dissolves it into the list', () => {
+ const editor = mountEditor('- top\n - child\n\nx');
+ const { view } = editor;
+ let paraPos = -1;
+ editor.state.doc.descendants((node, pos) => {
+ if (node.type.name === 'paragraph' && node.textContent === 'x') {
+ paraPos = pos;
+ return false;
+ }
+ return true;
+ });
+ editor.view.dispatch(editor.state.tr.insertText('-', paraPos + 1, paraPos + 2));
+ const from = paraPos + 2;
+ editor.view.dispatch(
+ editor.state.tr.setSelection(TextSelection.create(editor.state.doc, from)),
+ );
+ const handled = view.someProp('handleTextInput', (f) =>
+ f(view, from, from, ' ', () => view.state.tr.insertText(' ', from, from)),
+ );
+ expect(handled).toBe(true);
+ // The wrapping rule joined the fresh empty item into the list whose
+ // previous item has a sublist — the exact owned configuration.
+ press(editor, 'Backspace');
+
+ const md = serialize(editor);
+ // The empty item dissolves into the list. No bare `- ` bullet remains
+ // and no empty orphan paragraph is minted between list and trailing
+ // content (the lift path would leave one).
+ expect(md).not.toMatch(/^- *$/m);
+ expect(md.trim()).toBe('- top\n - child');
+ });
+});
+
+describe('multi-paragraph and structure preservation', () => {
+ test('D1 boundary where the merged item has a second paragraph loses no content', () => {
+ const editor = mountEditor('- top\n - child\n- next\n\n second para');
+ setCaret(editor, itemPos(editor, 2, 'start')); // start of "next"
+ press(editor, 'Backspace');
+
+ const md = serialize(editor);
+ expect(md).toContain('childnext');
+ expect(md).toContain('second para');
+ });
+
+ test('D2 boundary where the shallower next item has a second paragraph loses no content', () => {
+ const editor = mountEditor('- a\n - b\n- d\n\n d two');
+ setCaret(editor, itemPos(editor, 1, 'end')); // end of "b"
+ press(editor, 'Delete');
+
+ const md = serialize(editor);
+ expect(md).toContain('bd');
+ expect(md).toContain('d two');
+ });
+});
diff --git a/packages/app/tests/stress/list-keymap.e2e.ts b/packages/app/tests/stress/list-keymap.e2e.ts
index f5f454aed..471530cb1 100644
--- a/packages/app/tests/stress/list-keymap.e2e.ts
+++ b/packages/app/tests/stress/list-keymap.e2e.ts
@@ -368,3 +368,66 @@ test.describe('OQ1: Tab/Shift-Tab scoping by cursor context', () => {
expect(ytext).not.toMatch(/^- /m);
});
});
+
+// #609's remaining orphan source: upstream ListKeymap's lift/depth branches
+// misfire at NESTED item boundaries (as distinct from cause 1's paste
+// mis-placement, covered by handle-paste.list-placement.test.ts). The
+// ListBoundaryMerge core extension preempts exactly those configurations
+// with joinTextblockBackward/Forward — see
+// packages/core/src/extensions/list-boundary-merge.ts. Unit-tier coverage:
+// packages/app/src/editor/list-boundary-merge.test.ts. These pins assert the
+// persisted Y.Text bytes through the full CRDT bridge.
+// Test scenarios credited to inkeep/open-knowledge#613 by @blokboy.
+test.describe('Nested list-item boundary merges (Backspace/Delete)', () => {
+ test('Backspace merging into a previous item with a nested sublist does not orphan the merged item', async ({
+ page,
+ api,
+ }) => {
+ const docName = uniqueDocName('bksp-merge-sublist');
+ await openDoc(api, page, docName);
+ await seedMarkdown(api, page, docName, '- [ ] top\n - [ ] child\n- [ ] next\n');
+
+ await page.locator('.ProseMirror:not(.composer-prosemirror)').focus();
+ // Click into "next" — a top-level item whose preceding sibling ("top")
+ // has a nested sublist.
+ await page.locator('.ProseMirror li', { hasText: 'next' }).last().click();
+ await page.keyboard.press('Home');
+ await waitForPmSelectionInNode(page, 'listItem');
+
+ await page.keyboard.press('Backspace');
+
+ // "next" must merge as text into the list (onto "child", the deepest
+ // preceding textblock) — never survive as a bare paragraph with no
+ // bullet/checkbox sitting outside any list item.
+ await expect.poll(() => getYText(page)).toContain('childnext');
+ const ytext = await getYText(page);
+ expect(ytext).not.toMatch(/\n\nnext/);
+ expect(ytext).toContain('- [ ] top');
+ });
+
+ test('Delete at the end of a nested item merges the next top-level item at the correct depth', async ({
+ page,
+ api,
+ }) => {
+ const docName = uniqueDocName('del-merge-depth');
+ await openDoc(api, page, docName);
+ await seedMarkdown(api, page, docName, '- [ ] a\n - [ ] b\n - [ ] c\n- [ ] d\n');
+
+ await page.locator('.ProseMirror:not(.composer-prosemirror)').focus();
+ await page.locator('.ProseMirror li').filter({ hasText: /^c$/ }).last().click();
+ await page.keyboard.press('End');
+ await waitForPmSelectionInNode(page, 'listItem');
+
+ await page.keyboard.press('Delete');
+
+ // "d" merges onto "c" at the nested depth, keeping "c"'s checkbox on the
+ // surviving item and its indentation. The pre-fix corruption was the
+ // indented plain-bullet form ` - d` (wrong depth AND checkbox dropped) —
+ // assert against exactly that, not just a top-level `- d` leftover.
+ await expect.poll(() => getYText(page)).toMatch(/^ {2}- \[ \] cd$/m);
+ const ytext = await getYText(page);
+ expect(ytext).toContain('- [ ] a');
+ expect(ytext).not.toMatch(/^ {2}- d$/m);
+ expect(ytext).not.toMatch(/^- d$/m);
+ });
+});
diff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.ts
index 8f9d95287..c014b1413 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/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/merge-three-way.ts b/packages/core/src/bridge/merge-three-way.ts
index 3c927eb47..3ab9cc6ef 100644
--- a/packages/core/src/bridge/merge-three-way.ts
+++ b/packages/core/src/bridge/merge-three-way.ts
@@ -38,7 +38,6 @@ function mergeThreeWayImpl(baseline: string, userText: string, agentText: string
return parts.join('\n');
}
-
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 592f0b956..e67f33b40 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/list-boundary-merge.ts b/packages/core/src/extensions/list-boundary-merge.ts
new file mode 100644
index 000000000..478ea74fe
--- /dev/null
+++ b/packages/core/src/extensions/list-boundary-merge.ts
@@ -0,0 +1,157 @@
+/**
+ * Nested list-item boundary merges for Backspace/Delete.
+ *
+ * StarterKit's ListKeymap sub-extension drives GFM-correct Backspace/Delete
+ * in lists (see shared.ts's `listKeymap` wiring), but two of its branches
+ * misfire at NESTED item boundaries — schema-independently, by upstream
+ * design (@tiptap/extension-list, keymap handleBackspace/handleDelete):
+ *
+ * - Backspace at the start of item B whose PREVIOUS sibling item A has a
+ * nested sublist: the `previousListItemHasSubList` check skips
+ * joinItemBackward and falls through to `liftListItem` — the fallthrough
+ * meant for the FIRST item in a list — lifting B clean out into a bare
+ * paragraph with no bullet/checkbox (issue #609's orphan rows).
+ * - Delete at the end of a NESTED item when the next item sits SHALLOWER:
+ * the `nextListIsHigher` branch runs `joinForward().joinBackward()`,
+ * re-nesting the next item at the wrong depth and silently dropping its
+ * `checked` attr (`- [ ] d` becomes ` - d`).
+ *
+ * This extension preempts EXACTLY those two configurations (all four key
+ * bindings ListKeymap holds: Backspace/Delete and their Mod- variants) with
+ * prosemirror-commands' joinTextblockBackward/joinTextblockForward, which
+ * descend through container nodes to the adjacent textblocks and merge only
+ * those — never re-parenting, never dropping the surviving item's attrs.
+ * Every other configuration returns false so ListKeymap's good branches
+ * (flat joins, first-item lift, undoInputRule, trailing-paragraph rejoin,
+ * empty-nested-item removal) keep running unchanged.
+ *
+ * Registration order is load-bearing: this extension sits AFTER StarterKit
+ * in sharedExtensions at the DEFAULT priority. At equal priority the
+ * later-registered extension's key handler runs first, which is the whole
+ * delivery mechanism — no priority escalation, so suggestion-layer plugins
+ * (slash command, tag/wiki-link at the 200 band, precedent #48) keep their
+ * Enter/Tab precedence untouched.
+ */
+
+import { Extension } from '@tiptap/core';
+import { joinTextblockBackward, joinTextblockForward } from '@tiptap/pm/commands';
+import type { Node as PmNode, ResolvedPos } from '@tiptap/pm/model';
+import { type EditorState, TextSelection } from '@tiptap/pm/state';
+
+/** Depth of the nearest `listItem` ancestor, or null when outside a list. */
+function listItemDepth($pos: ResolvedPos): number | null {
+ for (let d = $pos.depth; d > 0; d--) {
+ if ($pos.node(d).type.name === 'listItem') return d;
+ }
+ return null;
+}
+
+// Recursive on purpose: mirrors upstream ListKeymap's descendants-based
+// `listItemHasSubList`, so this guard fires exactly when upstream's lift
+// branch would misfire. A shallow direct-child scan diverges for legal
+// shapes like listItem > blockquote > list (listItem content is
+// `paragraph block*`), where upstream still lifts but a shallow guard
+// would not preempt.
+function itemContainsSublist(item: PmNode): boolean {
+ let found = false;
+ item.descendants((child) => {
+ if (found) return false;
+ if (child.type.name === 'list') found = true;
+ return !found;
+ });
+ return found;
+}
+
+/** Resolved cursor, or null for ranged/Node selections (never handled). */
+function cursorOf(state: EditorState): ResolvedPos | null {
+ const { selection } = state;
+ return selection instanceof TextSelection ? selection.$cursor : null;
+}
+
+/**
+ * Mirror of the exact configuration where ListKeymap's handleBackspace
+ * falls through to `liftListItem` despite a previous sibling existing:
+ * cursor at the very start of an item's first textblock, previous sibling
+ * item present, and that sibling contains a nested list.
+ */
+function isNestedBoundaryBackspace(state: EditorState): boolean {
+ const $cursor = cursorOf(state);
+ if (!$cursor || $cursor.parentOffset !== 0) return false;
+ const li = listItemDepth($cursor);
+ if (li === null) return false;
+ if ($cursor.depth !== li + 1 || $cursor.index(li) !== 0) return false;
+ const itemIndex = $cursor.index(li - 1);
+ if (itemIndex === 0) return false; // first item: stock lift-out is correct
+ const prevItem = $cursor.node(li - 1).child(itemIndex - 1);
+ return itemContainsSublist(prevItem);
+}
+
+/**
+ * Depth of the list item that starts immediately after the item at depth
+ * `li`, descending through wrapper lists; null when what follows is not a
+ * list item (end of document, trailing paragraph, ...).
+ */
+function nextListItemDepthAfter($cursor: ResolvedPos, li: number): number | null {
+ for (let d = li - 1; d >= 0; d--) {
+ const parent = $cursor.node(d);
+ const idx = $cursor.index(d);
+ if (idx < parent.childCount - 1) {
+ let node = parent.child(idx + 1);
+ let depth = d + 1;
+ while (node.type.name === 'list' && node.firstChild) {
+ node = node.firstChild;
+ depth += 1;
+ }
+ return node.type.name === 'listItem' ? depth : null;
+ }
+ }
+ return null;
+}
+
+/**
+ * Mirror of the exact configuration where ListKeymap's handleDelete takes
+ * its `nextListIsHigher` branch: cursor at the very end of a listItem (its
+ * last textblock, last-child chain all the way up) and the next item in
+ * document order sits shallower than the cursor's item.
+ */
+function isNestedBoundaryDelete(state: EditorState): boolean {
+ const $cursor = cursorOf(state);
+ if (!$cursor || $cursor.parentOffset !== $cursor.parent.content.size) return false;
+ const li = listItemDepth($cursor);
+ if (li === null) return false;
+ for (let d = $cursor.depth; d > li; d--) {
+ if ($cursor.index(d - 1) !== $cursor.node(d - 1).childCount - 1) return false;
+ }
+ const nextDepth = nextListItemDepthAfter($cursor, li);
+ return nextDepth !== null && nextDepth < li;
+}
+
+export const ListBoundaryMerge = Extension.create({
+ name: 'listBoundaryMerge',
+
+ addKeyboardShortcuts() {
+ const backspace = () => {
+ const { editor } = this;
+ if (!isNestedBoundaryBackspace(editor.state)) return false;
+ // ListKeymap consults undoInputRule before anything else; preserve
+ // that precedence in the one configuration this extension owns (a
+ // fresh `- ` autoformat can land in this configuration when the new
+ // item joins a list whose last item has a sublist).
+ if (editor.commands.undoInputRule()) return true;
+ const { state, view } = editor;
+ return joinTextblockBackward(state, view.dispatch, view);
+ };
+ const forwardDelete = () => {
+ const { editor } = this;
+ if (!isNestedBoundaryDelete(editor.state)) return false;
+ const { state, view } = editor;
+ return joinTextblockForward(state, view.dispatch, view);
+ };
+ return {
+ Backspace: backspace,
+ 'Mod-Backspace': backspace,
+ Delete: forwardDelete,
+ 'Mod-Delete': forwardDelete,
+ };
+ },
+});
diff --git a/packages/core/src/extensions/shared.ts b/packages/core/src/extensions/shared.ts
index 076976818..fe73ffcee 100644
--- a/packages/core/src/extensions/shared.ts
+++ b/packages/core/src/extensions/shared.ts
@@ -25,6 +25,7 @@ import { JsxInline } from './jsx-inline.ts';
import { LinkFidelity } from './link-fidelity.ts';
import { LinkRefDefFidelity } from './link-ref-def-fidelity.ts';
import { List, ListItem } from './list.ts';
+import { ListBoundaryMerge } from './list-boundary-merge.ts';
import { MathInline } from './math-inline.ts';
import { RawMdxFallback } from './raw-mdx-fallback.ts';
import { SourceLiteralMark } from './source-literal-mark.ts';
@@ -124,6 +125,11 @@ export const sharedExtensions = [
width: 2,
},
}),
+ // Preempts ListKeymap's two nested-boundary misfires (orphan lift on
+ // Backspace, wrong-depth/checked-loss on Delete). MUST stay registered
+ // after StarterKit: at equal priority the later-registered extension's
+ // key handlers run first, which is the entire delivery mechanism.
+ ListBoundaryMerge,
// TableFidelity wraps Table with a `sourceDashCounts` attr: the GFM
// alignment-row dash counts captured at parse time and threaded back to
// the to-markdown handler so `:---:` round-trips byte-equal.
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/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.ts
index 47f0d07e4..193e286b0 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/fence-regions.ts b/packages/core/src/markdown/fence-regions.ts
index fb5ac8e8a..c7518d614 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 7a22e8016..f758cf737 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 2f082e6d0..78fdfeb02 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 { Root as HastRoot } from 'hast';
import type { Root as MdastRoot } from 'mdast';
import rehypeParse from 'rehype-parse';
@@ -76,8 +75,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 ceb72c4da..48f665bc0 100644
--- a/packages/core/src/markdown/index.ts
+++ b/packages/core/src/markdown/index.ts
@@ -1,4 +1,3 @@
-
import {
type FromProseMirrorOptions,
fromPmMark,
@@ -197,7 +196,6 @@ export class MarkdownManager {
}
}
-
const registry = createRegistry();
function destructureAttrs(
@@ -246,7 +244,6 @@ function destructureAttrs(
return result;
}
-
function hasDirtyDescendant(node: PmNode): boolean {
let found = false;
node.descendants((child) => {
@@ -266,7 +263,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 ?? [];
@@ -335,7 +331,6 @@ function extractTextFromMdastNodes(nodes: MdastNodes[]): string {
return out;
}
-
import {
AUDIO_EXTENSIONS,
FILE_ATTACHMENT_EXTENSIONS,
@@ -585,7 +580,6 @@ function buildMdastToPmHandlers(
}));
}
-
if (m.emphasis) {
handlers.emphasis = toPmMark(m.emphasis, (node: Emphasis) => ({
sourceDelimiter: node.data?.sourceDelimiter ?? '*',
@@ -665,7 +659,6 @@ function buildMdastToPmHandlers(
}));
}
-
if (m.link) {
const sourceLiteralMark = m.sourceLiteral;
handlers.link = (node: Link, _parent: MdastParent, state: MdastToPmState) => {
@@ -944,7 +937,6 @@ function buildMdastToPmHandlers(
};
}
-
const blockUnknownHandler = (node: {
type: string;
position?: { start: { offset: number }; end: { offset: number } };
@@ -1070,7 +1062,6 @@ function buildMdastToPmHandlers(
return handlers as RemarkProseMirrorOptions['handlers'];
}
-
function buildPmToMdastHandlers(
schema: Schema,
freshness: FreshnessCheckerHolder,
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 f84967798..679c72ef7 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 5b9550e90..5d6db7aa8 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 f8f5e8530..5a5e4c42a 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';
diff --git a/packages/core/src/markdown/position-slice.ts b/packages/core/src/markdown/position-slice.ts
index 860a7b360..51f600876 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';
@@ -470,8 +469,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-helpers.ts b/packages/core/src/markdown/serialize-helpers.ts
index 542204403..46cc6a074 100644
--- a/packages/core/src/markdown/serialize-helpers.ts
+++ b/packages/core/src/markdown/serialize-helpers.ts
@@ -1,4 +1,3 @@
-
import type { Node as PmNode } from '@tiptap/pm/model';
import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import type { PropDef, SerializeContext } from '../registry/types.ts';
diff --git a/packages/core/src/markdown/single-dollar-math-promoter.ts b/packages/core/src/markdown/single-dollar-math-promoter.ts
index fe73659e6..be97d4d62 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 94b9afd29..935a1641d 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';
diff --git a/packages/core/src/markdown/unknown-mdast-guard.ts b/packages/core/src/markdown/unknown-mdast-guard.ts
index c5bfd2386..cd245c38c 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 1b75ba564..a100cad76 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/schema-snapshot.json b/packages/core/src/schema-snapshot.json
index 8b6ff0b22..dbd9ae711 100644
--- a/packages/core/src/schema-snapshot.json
+++ b/packages/core/src/schema-snapshot.json
@@ -659,6 +659,7 @@
"docFidelity",
"sourceLiteral",
"starterKit",
+ "listBoundaryMerge",
"table",
"tableRow",
"tableHeader",