Replace Monaco with one CodeMirror editor and nest list items with Tab

Phase 4b. DocumentEditor.svelte replaces LiveWriter.svelte and the Monaco
EditorHost.svelte. Each open document has one CodeMirror state. Write and
Source are two compartment configurations of it, so they share the undo
history. editorStates.ts keeps the state while the tab stays open. The
Monaco model, the diff bridge, its timers, and sessions.ts are gone.

- Source: syntax colors from the theme tokens, lazy language packages,
  line numbers, folding, and the current line in IDE, wrapped lines in
  Writing, several carets, and bracket matching and closing.
- Lists (card 088e778b): Tab nests a list item and Shift+Tab moves it
  up, in Write and Source. Both renumber the list. The source keeps
  "1.". Write and Read show numbers, letters, then Roman numerals.
- Indent (card 696c30ce): a fixed 4 spaces in Write and Source.
- The code menu uses CodeMirror commands. The command palette item and
  the Monaco styles, search, theme, and workers are removed.
- @codemirror/legacy-modes is pinned to 6.5.4. Version 6.5.5 uses
  parser types that do not match @codemirror/language 6.12.
- 26 smoke tests use CodeMirror instead of Monaco. New tests:
  editor/listNesting and the markdownLists unit tests.
- Docs: development, UI design, plugin host, user guide, and UI-040.

pnpm check, pnpm test (341 of 341), and pnpm build pass. The full smoke
suite passes, except one template test that passed on retry.
This commit is contained in:
Knotty Wyvern
2026-10-28 10:48:44 -07:00
parent 80f5d908e0
commit 724402729e
70 changed files with 1583 additions and 1475 deletions
@@ -66,8 +66,8 @@ await runSmoke('settings/displayLanguage', async ({ browser }) => {
}), `${language}: Delete selected table cell keyboard action`);
await settings.screenshot({ path: path.join(output, `${language}-general.png`) });
await main.locator('[data-tree-rel="theme-0.py"]').click();
await main.locator('.monaco-editor textarea').waitFor();
await main.locator('.view-lines').first().click({ button: 'right' });
await main.locator('.source-editor .cm-content').waitFor();
await main.locator('.source-editor .cm-content').click({ button: 'right' });
await main.locator('.rs-menu').waitFor();
const copyLabels = { fr: 'Copier', ja: 'コピー', 'zh-CN': '复制', en: 'Copy' };
await main.locator('.rs-menu .action-label').filter({ hasText: new RegExp('^' + copyLabels[language] + '$') }).waitFor();
+6 -5
View File
@@ -43,8 +43,9 @@ await runSmoke("settings/general", async ({ browser }) => {
}
async function edit(value) {
await page.evaluate(async text => {
const { monaco } = await import("/src/lib/editor/monacoEnv.ts");
monaco.editor.getEditors().find(editor => editor.getDomNode()?.isConnected).setValue(text);
const { EditorView } = await import("/node_modules/@codemirror/view/dist/index.js");
const view = EditorView.findFromDOM(document.querySelector(".source-editor .cm-content"));
view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert: text } });
}, value);
}
const writes = () => page.evaluate(() => window.__TEST__.state.writes.length);
@@ -77,7 +78,7 @@ await runSmoke("settings/general", async ({ browser }) => {
await page.keyboard.press("Control+p");
await page.getByRole("textbox", { name: "Find a file" }).fill("note.txt");
await page.getByRole("dialog").getByRole("button").filter({ hasText: "note.txt" }).first().click();
await page.locator(".monaco-editor textarea").waitFor();
await page.locator(".source-editor .cm-content").waitFor();
await page.clock.pauseAt(new Date(await page.evaluate(() => Date.now()) + 1000));
await showSettings();
await changeSeconds(3);
@@ -99,11 +100,11 @@ await runSmoke("settings/general", async ({ browser }) => {
assert.equal(await writes(), before + 1);
await page.keyboard.press("Control+s");
await page.waitForFunction(count => window.__TEST__.state.writes.length === count, before + 2);
await page.locator(".monaco-editor textarea").focus();
await page.locator(".source-editor .cm-content").focus();
await showSettings(true);
await settings.waitFor();
await closeSettings();
await page.locator(".monaco-editor textarea").focus();
await page.locator(".source-editor .cm-content").focus();
await page.keyboard.press("F1");
await page.getByRole("dialog", { name: "Help and about", exact: true }).waitFor();
await page.keyboard.press("Escape");