The formula engine, the rendered results, and the formula help now come from src/lib/formulas/. The editor and the renderer call this module directly. The tableFormulas contribution type is removed. - Add the tableFormulas general setting (default on) and a switch in Settings > General. When it is off, formulas show as source text. - Do not load an installed runestone.table-formulas package. Settings > Plug-ins marks it as included with RuneStone and tells the user that it can be removed. The user's files stay in place. - Translate the formula help and the error descriptions into French, Japanese, and Simplified Chinese. - Port the plugin unit tests. Test the setting and use a test-only contribution for the generic plugin lifecycle tests. - Smoke tests load only Terminal. The formula and lifecycle tests use the built-in feature and its setting. - Remove scripts/buildPlugins.mjs, the build:plugins script, and the plugin-packages requirement of the smoke runner. - Remove RuneStone_Table_Formulas from the menu audit scope. It had no menu surfaces. - Update the README, the user guides, and the developer references.
101 lines
6.1 KiB
JavaScript
101 lines
6.1 KiB
JavaScript
// Link editing in the Writer: link tooltips and source colors, Edit link in prose, table, and wiki cells with undo, multiple links in a cell, and table tooltips at narrow widths.
|
|
import assert from "node:assert/strict";
|
|
import path from "node:path";
|
|
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
|
|
|
await runSmoke("links/linkEditing", async ({ page }) => {
|
|
const output = await outputDir("links/linkEditing");
|
|
await mockTauri(page, {
|
|
commands: test => {
|
|
const note = name => `# ${name}\n\nOriginal [guide](docs/guide.md) text.\n\n| Name | Value |\n| --- | --- |\n| [Roadmap](docs/roadmap.md) | [[guide\\|Guide]] |\n| [One](same.md) + [Two](same.md) | Empty |\n`;
|
|
return {
|
|
...test.workspace({ root: "C:\\tab-menu-workspace", folders: ["notes"], files: Object.fromEntries(["a.md", "b.md", "c.md", "d.md"].map(name => [name, note(name)])) }),
|
|
spelling_menu_install: () => {},
|
|
};
|
|
},
|
|
});
|
|
await page.goto(smokeUrl);
|
|
await page.locator('[data-tree-rel="a.md"]').click();
|
|
await page.locator('.writer-table').waitFor();
|
|
for(const theme of ['dark','light']) {
|
|
await page.evaluate(async mode => (await import('/src/lib/theme/appearance.ts')).saveAppearance({theme:'default',mode}), theme);
|
|
const prose = page.locator('.writer-link').filter({hasText:'guide'}).first();
|
|
await prose.hover();
|
|
// A focused table cell can keep its own tooltip open (src/lib/ui/tooltip.ts:32), so wait for the link's tooltip.
|
|
await page.getByRole('tooltip',{name:'Ctrl+click to open link',exact:true}).waitFor();
|
|
assert.equal(await prose.getAttribute('title'),null);
|
|
await page.screenshot({path:path.join(output, 'editor-link-tooltip-'+theme+'.png')});
|
|
await page.keyboard.press('Escape');
|
|
await prose.click();
|
|
assert.equal(await page.locator('.writer-link-source').count(),1);
|
|
const colored = await page.locator('.writer-link-source').evaluate(el => ({color:getComputedStyle(el).color, parent:getComputedStyle(el.parentElement).color}));
|
|
assert.notEqual(colored.color,colored.parent);
|
|
await page.screenshot({path:path.join(output, 'editor-link-source-'+theme+'.png')});
|
|
const cell=page.locator('.writer-table td').first();
|
|
await cell.locator('a').click({position:{x:22,y:8}});
|
|
assert.ok(await page.evaluate(()=>getSelection().anchorOffset > 0));
|
|
await cell.click({button:'right'});
|
|
await page.getByRole('menuitem',{name:'Edit link',exact:true}).click();
|
|
assert.equal(await page.getByRole('dialog').count(),0);
|
|
assert.equal(await page.evaluate(()=>getSelection().toString()),theme === 'dark' ? 'docs/roadmap.md' : 'docs/new-roadmap.md');
|
|
await page.screenshot({path:path.join(output, 'editor-table-source-'+theme+'.png')});
|
|
await page.keyboard.type('docs/new-roadmap.md');
|
|
await page.keyboard.press('Enter');
|
|
assert.equal(await cell.locator('a').getAttribute('href'),'docs/new-roadmap.md');
|
|
if(theme === 'dark') {
|
|
await page.locator('.cm-line').filter({hasText:'Original'}).click();
|
|
await page.keyboard.press('Control+z');
|
|
assert.equal(await cell.locator('a').getAttribute('href'),'docs/roadmap.md');
|
|
await page.keyboard.press('Control+Shift+z');
|
|
assert.equal(await cell.locator('a').getAttribute('href'),'docs/new-roadmap.md');
|
|
}
|
|
await cell.locator('a').click({position:{x:22,y:8}});
|
|
const selection=await page.evaluate(()=>{const s=getSelection();return {offset:s.anchorOffset,length:s.anchorNode.textContent.length};});
|
|
assert.ok(selection.offset>0 && selection.offset<selection.length,JSON.stringify(selection));
|
|
await page.keyboard.type('X');
|
|
assert.ok((await cell.innerText()).includes('X'));
|
|
await page.keyboard.press('Escape');
|
|
const wiki=page.locator('.writer-table td').nth(1);
|
|
await wiki.click({button:'right'});
|
|
await page.getByRole('menuitem',{name:'Edit link',exact:true}).click();
|
|
assert.equal(await page.evaluate(()=>getSelection().toString()),theme==='dark'?'guide':'new-guide');
|
|
await page.keyboard.type('new-guide');
|
|
await page.keyboard.press('Enter');
|
|
assert.equal(await wiki.locator('a').getAttribute('href'),'new-guide');
|
|
}
|
|
const multi=page.locator('.writer-table td').nth(2);
|
|
await multi.locator('a').nth(1).click({button:'right'});
|
|
await page.getByRole('menuitem',{name:'Edit link',exact:true}).click();
|
|
assert.equal(await page.evaluate(()=>getSelection().toString()),'same.md');
|
|
await page.keyboard.type('second.md');
|
|
await page.keyboard.press('Enter');
|
|
assert.equal(await multi.locator('a').first().getAttribute('href'),'same.md');
|
|
assert.equal(await multi.locator('a').nth(1).getAttribute('href'),'second.md');
|
|
await page.getByRole('button',{name:'Hide outline',exact:true}).click();
|
|
await page.getByRole('button',{name:'Files',exact:true}).click();
|
|
await page.setViewportSize({width:620,height:700});
|
|
await page.waitForTimeout(250);
|
|
await page.locator('.table-add-row').scrollIntoViewIfNeeded();
|
|
await page.waitForTimeout(100);
|
|
await page.locator('.table-add-row').focus();
|
|
await page.locator('.rs-tooltip:popover-open').waitFor();
|
|
const rect=await page.locator('.rs-tooltip:popover-open').boundingBox();
|
|
assert.ok(rect.x>=0 && rect.x+rect.width<=620);
|
|
await page.screenshot({path:path.join(output, 'editor-tooltip-narrow-focus.png')});
|
|
await page.keyboard.press('Escape');
|
|
assert.equal(await page.locator('.rs-tooltip:popover-open').count(),0);
|
|
assert.equal(await page.locator('.table-edit-help:visible').count(),0);
|
|
for (const mode of ['light','dark']) {
|
|
await page.evaluate(async mode => (await import('/src/lib/theme/appearance.ts')).saveAppearance({theme:'default',mode}),mode);
|
|
await page.locator('.writer-table td').nth(1).hover();
|
|
await page.locator('.rs-tooltip:popover-open').waitFor();
|
|
// Table formulas are on by default, so the cell tooltip shows the cell address.
|
|
assert.equal(await page.locator('.rs-tooltip:popover-open').innerText(),'B2');
|
|
await page.screenshot({path:path.join(output, 'editor-cell-tooltip-narrow-'+mode+'.png')});
|
|
await page.keyboard.press('Escape');
|
|
await page.mouse.move(5,90);
|
|
}
|
|
|
|
console.log('Editor link and tooltip checks passed');
|
|
}, { timeout: 15000 });
|