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:
@@ -68,22 +68,21 @@ await runSmoke("editor/undoHistory", async ({ page }) => {
|
||||
assert.equal(await page.evaluate(() => window.__WRITER__.state.selection.main.head), (original + ' first edit').length);
|
||||
console.log('PASS: Writer undo and redo survive window focus refresh and restore the caret');
|
||||
await page.keyboard.press('Control+e');
|
||||
await page.locator('.monaco-editor textarea').waitFor();
|
||||
await page.locator('.source-editor .cm-content').waitFor();
|
||||
await page.evaluate(async () => {
|
||||
const { monaco } = await import('/src/lib/editor/monacoEnv.ts');
|
||||
const editor = monaco.editor.getEditors().find(view => view.getDomNode()?.isConnected);
|
||||
editor.setPosition({ lineNumber: editor.getModel().getLineCount(), column: editor.getModel().getLineMaxColumn(editor.getModel().getLineCount()) });
|
||||
editor.focus();
|
||||
window.__IDE__ = editor;
|
||||
const { EditorView } = await import('/node_modules/@codemirror/view/dist/index.js');
|
||||
const view = EditorView.findFromDOM(document.querySelector('.source-editor .cm-content'));
|
||||
view.dispatch({ selection: { anchor: view.state.doc.length } });
|
||||
view.focus();
|
||||
window.__IDE__ = view;
|
||||
});
|
||||
await page.keyboard.type(' second edit');
|
||||
assert.equal(await page.evaluate(() => window.__IDE__.getDomNode()?.isConnected), true, 'Typing keeps the same IDE editor mounted');
|
||||
assert.equal(await page.evaluate(() => window.__IDE__.getValue()), original + ' first edit second edit');
|
||||
assert.equal(await page.evaluate(() => window.__IDE__.dom.isConnected), true, 'Typing keeps the same IDE editor mounted');
|
||||
assert.equal(await page.evaluate(() => window.__IDE__.state.doc.toString()), original + ' first edit second edit');
|
||||
await page.keyboard.press('Control+e');
|
||||
await expectWriter(original + ' first edit second edit');
|
||||
await page.locator('.cm-content').click();
|
||||
await page.keyboard.press('Control+z');
|
||||
await expectWriter(original + ' first edit second');
|
||||
// One burst of typing is one undo step, in Source as in Write.
|
||||
await page.keyboard.press('Control+z');
|
||||
await expectWriter(original + ' first edit');
|
||||
await page.keyboard.press('Control+z');
|
||||
@@ -91,8 +90,6 @@ await runSmoke("editor/undoHistory", async ({ page }) => {
|
||||
await page.keyboard.press('Control+y');
|
||||
await expectWriter(original + ' first edit');
|
||||
await page.keyboard.press('Control+y');
|
||||
await expectWriter(original + ' first edit second');
|
||||
await page.keyboard.press('Control+y');
|
||||
await expectWriter(original + ' first edit second edit');
|
||||
console.log('PASS: Writer undo includes edits from IDE mode');
|
||||
const tableSource = '# Table\n\n| A | B |\n| --- | --- |\n| One | Two |\n\nTail.\n';
|
||||
|
||||
Reference in New Issue
Block a user