- **New app: GenOffice HTML.** Open, edit and generate .html pages: a source pane with a sandboxed live preview, click-to-select elements with a floating toolbar and style panel, device-size preview, image tools and a present mode. AI generates whole pages from a brief with style directions and offers page-wide Restyle, Theme and Summarize. Export to Word runs locally through the built-in html2docx converter (native, editable OOXML; no print-to-PDF detour). - **AI:** separate BYOK providers for web search, image generation and image/video analysis; new Codex App Server provider; Ask AI quotes the selected text and keeps it highlighted while it runs; custom AI panel text size; blocked requests retry through the Chromium network stack. - **App:** global AutoSave setting shared by every editor; AI panel text size and chat spellcheck toggles (genoffice#249); Czech (cs) UI locale (genoffice#259); Save As defaults to the document's folder; PDF export no longer aborts on CJK file paths on Windows. - **Docs:** Export as HTML; comments and replies edit in place from the comments pane; the caret can leave a trailing table (genoffice#266); spellcheck re-marks text as soon as it is re-enabled; AI edits are character-precise on partial selections; zoom keeps the scroll position; pasting a cell from Sheets takes the destination font. - **Sheets:** Find no longer freezes on wide or streamed grids; Replace searches as you type; cached values of external-workbook formulas are kept instead of #ERROR! (genoffice#235); "number stored as text" is a warning, not an error (genoffice#236); paste repeats into the target range like Excel; filter criteria survive save/reopen; saves retry when Windows locks the file; many Excel-fidelity fixes for column widths, row heights, charts, slicers, number formats and CJK fonts. - **Slides:** PDF export works for large presentations (genoffice#264); EMF/WMF picture fonts and East Asian theme fonts resolve correctly; decks with missing layouts or embedded styles still open; outline-only pie slices render. - **PDF:** highlight and underline geometry aligns with the text; Shift+arrows extend the selection instead of paging. - **Markdown:** Find and replace (Ctrl+F / Ctrl+H) (genoffice#253); mermaid code blocks render as diagrams (genoffice#263); better print quality. - Thanks to community contributors @GoodScholar, @aniruddhaadak80 and @Sun8854, and to @hanyscz, @qgzln, @zyp997, @bisslot, @krakotay and @Ben03151 for the reports. Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
189 lines
6.5 KiB
TypeScript
189 lines
6.5 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
import type { Page } from '@playwright/test'
|
|
import { launchShell, closeAndSaveVideo, waitForPageWithUrl, screenshotPath } from './helpers'
|
|
|
|
// the preload exposes window.__genofficeDebug only under this env var
|
|
process.env.GENOFFICE_DEBUG_HOOKS = '1'
|
|
|
|
interface CellRect {
|
|
left: number
|
|
top: number
|
|
right: number
|
|
bottom: number
|
|
}
|
|
|
|
function cellRect(page: Page, row: number, column: number): Promise<CellRect> {
|
|
return page.evaluate(
|
|
([r, c]) => {
|
|
const debug = (window as unknown as Record<string, unknown>).__genofficeDebug as {
|
|
univerAPI: { getActiveWorkbook(): { getActiveSheet(): unknown } }
|
|
}
|
|
const sheet = debug.univerAPI.getActiveWorkbook().getActiveSheet() as {
|
|
getRange(row: number, column: number): { getCellRect(): CellRect }
|
|
}
|
|
const { left, top, right, bottom } = sheet.getRange(r, c).getCellRect()
|
|
return { left, top, right, bottom }
|
|
},
|
|
[row, column],
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Largest channel spread over a band of the worksheet canvas (sheet coords):
|
|
* gridlines, text and the page are grey, a SelectionControl border is not.
|
|
*/
|
|
function maxSpread(page: Page, x: number, y: number, w: number, h: number): Promise<number> {
|
|
return page.evaluate(
|
|
([x, y, w, h]) => {
|
|
let grid: HTMLCanvasElement | null = null
|
|
for (const canvas of document.querySelectorAll('canvas')) {
|
|
const rect = canvas.getBoundingClientRect()
|
|
if (rect.width > 500 && rect.height > 300) grid = canvas
|
|
}
|
|
if (!grid) throw new Error('worksheet canvas not found')
|
|
const dpr = grid.width / grid.getBoundingClientRect().width
|
|
const ctx = grid.getContext('2d')
|
|
if (!ctx) throw new Error('worksheet canvas has no 2d context')
|
|
const data = ctx.getImageData(
|
|
Math.round(x * dpr),
|
|
Math.round(y * dpr),
|
|
Math.max(1, Math.round(w * dpr)),
|
|
Math.max(1, Math.round(h * dpr)),
|
|
).data
|
|
let spread = 0
|
|
for (let i = 0; i < data.length; i += 4) {
|
|
const r = data[i]
|
|
const g = data[i + 1]
|
|
const b = data[i + 2]
|
|
spread = Math.max(spread, Math.max(r, g, b) - Math.min(r, g, b))
|
|
}
|
|
return spread
|
|
},
|
|
[x, y, w, h],
|
|
)
|
|
}
|
|
|
|
const BAND = 2
|
|
|
|
function bottomEdge(page: Page, rect: CellRect): Promise<number> {
|
|
const inset = 6
|
|
return maxSpread(
|
|
page,
|
|
rect.left + inset,
|
|
rect.bottom - BAND,
|
|
rect.right - rect.left - 2 * inset,
|
|
2 * BAND + 1,
|
|
)
|
|
}
|
|
|
|
function rightEdge(page: Page, rect: CellRect): Promise<number> {
|
|
const inset = 6
|
|
return maxSpread(
|
|
page,
|
|
rect.right - BAND,
|
|
rect.top + inset,
|
|
2 * BAND + 1,
|
|
rect.bottom - rect.top - 2 * inset,
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Regression for "a mysterious outer border appeared" (alpha
|
|
* feedback): Univer's filter render controller paints a selection-style border
|
|
* around the whole filter range whenever a sheet has a filter. Excel draws
|
|
* no such outline; the range painter is stubbed out at render-module
|
|
* registration (see filter-range-outline.ts). The pixel probe asserts the
|
|
* border colour is gone from the edges the outline used to cover, and the
|
|
* same probe on the parked active cell proves it does see a selection border.
|
|
*/
|
|
test.describe('sheets: no outline around a filtered range', () => {
|
|
test('creating a filter draws funnel buttons but no range border', async () => {
|
|
const launched = await launchShell({
|
|
onboardingSeen: true,
|
|
videoDir: 'sheets-filter-outline',
|
|
})
|
|
try {
|
|
const { app, page } = launched
|
|
|
|
await expect(page.locator('.quick-card').nth(1)).toContainText('AI Sheets')
|
|
await page.locator('.quick-card').nth(1).click()
|
|
|
|
const sheets = await waitForPageWithUrl(app, 'sheets/out')
|
|
await sheets.waitForFunction(() => document.body.textContent?.includes('Sheet1'), null, {
|
|
timeout: 30_000,
|
|
})
|
|
await sheets.waitForTimeout(1_500)
|
|
|
|
await sheets.evaluate(async () => {
|
|
const debug = (window as unknown as Record<string, unknown>).__genofficeDebug as {
|
|
univerAPI: { getActiveWorkbook(): { getActiveSheet(): unknown } }
|
|
}
|
|
const sheet = debug.univerAPI.getActiveWorkbook().getActiveSheet() as {
|
|
getRange(
|
|
row: number,
|
|
column: number,
|
|
rows: number,
|
|
columns: number,
|
|
): { setValues(values: unknown[][]): Promise<unknown>; createFilter(): unknown }
|
|
}
|
|
await sheet.getRange(0, 0, 3, 2).setValues([
|
|
['Name', 'Cat'],
|
|
['a', 'keep'],
|
|
['b', 'drop'],
|
|
])
|
|
sheet.getRange(0, 0, 3, 2).createFilter()
|
|
})
|
|
await sheets.waitForTimeout(1_000)
|
|
|
|
// deselect: park the selection far from the filter range so its own
|
|
// selection border cannot be mistaken for the filter outline
|
|
await sheets.evaluate(() => {
|
|
const debug = (window as unknown as Record<string, unknown>).__genofficeDebug as {
|
|
univerAPI: { getActiveWorkbook(): { getActiveSheet(): unknown } }
|
|
}
|
|
const sheet = debug.univerAPI.getActiveWorkbook().getActiveSheet() as {
|
|
getRange(
|
|
row: number,
|
|
column: number,
|
|
rows: number,
|
|
columns: number,
|
|
): { activate(): unknown }
|
|
}
|
|
sheet.getRange(19, 7, 1, 1).activate()
|
|
})
|
|
await sheets.waitForTimeout(500)
|
|
|
|
await sheets.screenshot({ path: screenshotPath('sheets-filter-outline') })
|
|
|
|
const hasFilter = await sheets.evaluate(() => {
|
|
const debug = (window as unknown as Record<string, unknown>).__genofficeDebug as {
|
|
univerAPI: { getActiveWorkbook(): { getActiveSheet(): unknown } }
|
|
}
|
|
const sheet = debug.univerAPI.getActiveWorkbook().getActiveSheet() as {
|
|
getFilter(): unknown
|
|
}
|
|
return sheet.getFilter() != null
|
|
})
|
|
expect(hasFilter).toBe(true)
|
|
|
|
// positive control: the parked active cell's own selection border is
|
|
// what the filter outline looked like, and the probe must see it
|
|
const parked = await cellRect(sheets, 19, 7)
|
|
expect(await bottomEdge(sheets, parked)).toBeGreaterThan(80)
|
|
|
|
const topLeft = await cellRect(sheets, 0, 0)
|
|
const bottomRight = await cellRect(sheets, 2, 1)
|
|
const range = {
|
|
left: topLeft.left,
|
|
top: topLeft.top,
|
|
right: bottomRight.right,
|
|
bottom: bottomRight.bottom,
|
|
}
|
|
expect(await bottomEdge(sheets, range)).toBeLessThan(40)
|
|
expect(await rightEdge(sheets, range)).toBeLessThan(40)
|
|
} finally {
|
|
await closeAndSaveVideo(launched, 'sheets-filter-outline')
|
|
}
|
|
})
|
|
})
|