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:
@@ -30,7 +30,7 @@ await runSmoke("links/fileDragLinks", async ({ page }) => {
|
||||
await page.mouse.up();
|
||||
}
|
||||
const writerSource = () => page.evaluate(() => window.dragWriter.state.doc.toString());
|
||||
const ideSource = () => page.evaluate(() => window.dragMonaco.getValue());
|
||||
const ideSource = () => page.evaluate(() => window.dragSource.state.doc.toString());
|
||||
|
||||
await page.goto(smokeUrl);
|
||||
await row("notes").click();
|
||||
@@ -60,21 +60,21 @@ await runSmoke("links/fileDragLinks", async ({ page }) => {
|
||||
console.log("PASS: Writer drags insert escaped document links and image embeds, and undo restores the source");
|
||||
|
||||
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");
|
||||
window.dragMonaco = monaco.editor.getEditors().find(editor => editor.getDomNode()?.isConnected);
|
||||
const { EditorView } = await import("/node_modules/@codemirror/view/dist/index.js");
|
||||
window.dragSource = EditorView.findFromDOM(document.querySelector(".source-editor .cm-content"));
|
||||
});
|
||||
const originalIde = await ideSource();
|
||||
await drag("files/report [Q1] (#1).pdf", ".monaco-editor .view-lines");
|
||||
await page.waitForFunction(() => window.dragMonaco.getValue().includes(".pdf)"));
|
||||
await drag("files/report [Q1] (#1).pdf", ".source-editor .cm-content");
|
||||
await page.waitForFunction(() => window.dragSource.state.doc.toString().includes(".pdf)"));
|
||||
assert.ok((await ideSource()).includes("[report \\[Q1\\] (#1).pdf](../files/report%20%5BQ1%5D%20%28%231%29.pdf)"));
|
||||
await page.evaluate(() => window.dragMonaco.focus());
|
||||
assert.equal(await page.evaluate(() => window.dragMonaco.hasTextFocus()), true);
|
||||
await page.evaluate(() => window.dragSource.focus());
|
||||
assert.equal(await page.evaluate(() => window.dragSource.hasFocus), true);
|
||||
await page.keyboard.press("Control+z");
|
||||
await page.waitForFunction(expected => window.dragMonaco.getValue() === expected, originalIde, { timeout: 3000 });
|
||||
await page.waitForFunction(expected => window.dragSource.state.doc.toString() === expected, originalIde, { timeout: 3000 });
|
||||
assert.equal(await ideSource(), originalIde, "IDE undo restores the exact source");
|
||||
await drag("images/diagram (#1).svg", ".monaco-editor .view-lines");
|
||||
await drag("images/diagram (#1).svg", ".source-editor .cm-content");
|
||||
assert.ok((await ideSource()).includes(""));
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.calls.filter(call => ["workspace_rename", "workspace_write_bytes"].includes(call.command)).length), 0);
|
||||
console.log("PASS: IDE drags insert escaped document links and image embeds, undo restores the source, and no file moves");
|
||||
|
||||
@@ -108,10 +108,10 @@ await runSmoke("links/linkMenus", async ({ page }) => {
|
||||
await page.getByRole('group', { name: 'Document view', exact: true }).hover();
|
||||
await page.getByRole('button',{name:'Edit',exact:true}).click();
|
||||
await page.getByRole('group', { name:'Editor layout',exact:true }).hover(); await page.getByRole('button',{name:'IDE',exact:true}).click();
|
||||
await page.locator('.monaco-editor').waitFor();
|
||||
await page.evaluate(async () => { const {monaco}=await import('/src/lib/editor/monacoEnv.ts'); const editor=monaco.editor.getEditors()[0]; const model=editor.getModel(); const pos=model.getPositionAt(model.getValue().indexOf('Web label')+2); editor.setPosition(pos); editor.focus(); });
|
||||
await page.locator('.source-editor .cm-content').waitFor();
|
||||
await page.evaluate(async () => { 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.toString().indexOf('Web label')+2}}); view.focus(); });
|
||||
await page.keyboard.press('Shift+F10'); await item('Edit link').click();
|
||||
assert.equal(await page.evaluate(async () => { const {monaco}=await import('/src/lib/editor/monacoEnv.ts'); const editor=monaco.editor.getEditors()[0]; return editor.getModel().getValueInRange(editor.getSelection()); }), 'https://example.com/path');
|
||||
assert.equal(await page.evaluate(async () => { const {EditorView}=await import('/node_modules/@codemirror/view/dist/index.js'); const {state}=EditorView.findFromDOM(document.querySelector('.source-editor .cm-content')); return state.sliceDoc(state.selection.main.from,state.selection.main.to); }), 'https://example.com/path');
|
||||
await page.screenshot({ path: `${output}/ide-edit-url-${theme}.png` });
|
||||
await page.getByRole('group', { name:'Editor layout',exact:true }).hover(); await page.getByRole('button',{name:'Writer',exact:true}).click();
|
||||
await page.locator('.cm-content').getByText('Selected reading text.', {exact:true}).click();
|
||||
|
||||
@@ -112,13 +112,13 @@ await runSmoke("links/sectionLinks", async ({ page }) => {
|
||||
await page.screenshot({ path:`${output}/split-${theme}-${width}.png` });
|
||||
await choose('Document view', 'edit');
|
||||
await choose('Editor layout', 'Ide');
|
||||
await page.locator('.monaco-editor').waitFor();
|
||||
await page.locator('.source-editor .cm-content').waitFor();
|
||||
await choose('Document view', 'read');
|
||||
await page.locator('.md-page').evaluate(node => { node.scrollTop = 0; });
|
||||
await readerJump('Linux setup', 'Linux (Intel/AMD 64-bit)');
|
||||
await choose('Document view', 'edit');
|
||||
await page.waitForFunction(() => {
|
||||
const node = document.querySelector('.monaco-editor .view-lines');
|
||||
const node = document.querySelector('.source-editor .cm-content');
|
||||
return node?.textContent.includes('Linux');
|
||||
});
|
||||
await page.screenshot({ path:`${output}/ide-${theme}-${width}.png` });
|
||||
|
||||
Reference in New Issue
Block a user