Sync snapshot (2026-08-03) (#6)

- Fix AI table read/write column integrity in Sheets (cell text escaping, set_range validation)
- Slides: canvas follows window resize; restyle the AI quick-action toolbar
- Improve onboarding: stable card height, expanded copy across all 19 locales

Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
This commit is contained in:
merrick-2002
2026-08-03 22:02:22 +08:00
committed by GitHub
co-authored by GenOffice
parent 0127f6289a
commit 4da673d4df
121 changed files with 2400 additions and 831 deletions
+120
View File
@@ -0,0 +1,120 @@
// The AI panel stays mounted while collapsed (rail only),
// so the conversation, draft, and in-flight runs survive collapse/expand.
import { beforeAll, describe, expect, it, vi } from 'vitest'
import { act, createElement } from 'react'
import { createRoot, type Root } from 'react-dom/client'
import { Editor } from '@tiptap/core'
import { editorExtensions } from '../src/renderer/editor/extensions'
import { AiPanel } from '../src/renderer/ai/AiPanel'
import { AI_PROVIDERS, type AiSettings } from '../src/shared/ipc'
const settings: AiSettings = {
provider: 'anthropic',
providers: Object.fromEntries(
AI_PROVIDERS.map((p) => [p.id, { apiKey: '', model: p.defaultModel }]),
) as AiSettings['providers'],
}
function createEditor(): Editor {
return new Editor({
element: document.createElement('div'),
extensions: editorExtensions,
content: {
type: 'doc',
content: [
{
type: 'docParagraph',
attrs: { docxIndex: 0 },
content: [{ type: 'text', text: 'EVs market research' }],
},
],
},
})
}
function mount(element: React.ReactElement): {
container: HTMLElement
root: Root
cleanup: () => void
} {
const container = document.createElement('div')
document.body.appendChild(container)
const root = createRoot(container)
act(() => root.render(element))
return {
container,
root,
cleanup: () => {
act(() => root.unmount())
container.remove()
},
}
}
function panelProps(editor: Editor, overrides: Record<string, unknown> = {}) {
return {
editor,
blocks: [],
settings,
open: true,
onExpand: () => {},
onCollapse: () => {},
...overrides,
}
}
/** Simulate typing into React's controlled textarea */
function typeInto(textarea: HTMLTextAreaElement, text: string) {
const setter = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value')!.set!
act(() => {
setter.call(textarea, text)
textarea.dispatchEvent(new Event('input', { bubbles: true }))
})
}
beforeAll(() => {
// jsdom has no scrollTo; the panel auto-scrolls its chat log
Element.prototype.scrollTo ??= () => {}
})
describe('AiPanel collapse', () => {
it('keeps the draft input across a collapse/expand cycle', () => {
const editor = createEditor()
const { container, root, cleanup } = mount(createElement(AiPanel, panelProps(editor)))
const textarea = container.querySelector<HTMLTextAreaElement>('.ai-input-box textarea')
expect(textarea).not.toBeNull()
typeInto(textarea!, 'unsent draft')
expect(textarea!.value).toBe('unsent draft')
// collapse: only the rail is rendered, but the component stays mounted
act(() => root.render(createElement(AiPanel, panelProps(editor, { open: false }))))
expect(container.querySelector('.ai-input-box textarea')).toBeNull()
expect(container.querySelector('.ai-rail')).not.toBeNull()
// expand: the draft is still there
act(() => root.render(createElement(AiPanel, panelProps(editor, { open: true }))))
const restored = container.querySelector<HTMLTextAreaElement>('.ai-input-box textarea')
expect(restored).not.toBeNull()
expect(restored!.value).toBe('unsent draft')
cleanup()
editor.destroy()
})
it('expands back through the rail button', () => {
const editor = createEditor()
const onExpand = vi.fn()
const { container, cleanup } = mount(
createElement(AiPanel, panelProps(editor, { open: false, onExpand })),
)
const rail = container.querySelector<HTMLButtonElement>('.ai-rail')
expect(rail).not.toBeNull()
act(() => rail!.click())
expect(onExpand).toHaveBeenCalledTimes(1)
cleanup()
editor.destroy()
})
})
+2 -2
View File
@@ -40,7 +40,7 @@ async function saveAndUnzip(editor: Editor, parsed: Awaited<ReturnType<typeof pa
return { bytes, xml }
}
describe('list toggle inside a table cell (#156)', () => {
describe('list toggle inside a table cell', () => {
it('setNode docListItem succeeds in a cell and saves w:numPr into the tc', async () => {
const { editor, parsed } = await openBlank()
insertTableAt(editor, 2, 2)
@@ -83,7 +83,7 @@ describe('list toggle inside a table cell (#156)', () => {
})
})
describe('insert table inside a table cell (#156)', () => {
describe('insert table inside a table cell', () => {
it('nests the new table in the cell instead of splitting the outer table', async () => {
const { editor, parsed } = await openBlank()
insertTableAt(editor, 2, 2)
+1 -1
View File
@@ -45,7 +45,7 @@ describe('collectDocFonts', () => {
})
})
describe('checkMissingFonts (#75)', () => {
describe('checkMissingFonts', () => {
it('reports a missing font with its first available substitute', () => {
stubCanvas(['STFangsong', 'STKaiti'])
// fresh module per stub: the 2d context is cached module-wide
+1 -1
View File
@@ -343,7 +343,7 @@ describe('cssFontFamily', () => {
)
})
it('Simplified-Chinese office fonts map to real macOS/Windows families (#75)', () => {
it('Simplified-Chinese office fonts map to real macOS/Windows families', () => {
expect(cssFontFamily('仿宋_GB2312')).toBe(
"'仿宋_GB2312','STFangsong','FangSong','Noto Serif CJK SC',serif",
)
+1 -1
View File
@@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core'
import { noteMarkText, toRoman } from '../src/renderer/note-format'
import { editorExtensions } from '../src/renderer/editor/extensions'
describe('note numbering (#153)', () => {
describe('note numbering', () => {
it('endnotes number in lowercase roman, footnotes stay arabic', () => {
expect(toRoman(1)).toBe('i')
expect(toRoman(4)).toBe('iv')
+1 -1
View File
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'
import { asianCharCount, countWords, nonAsianWordCount } from '../src/renderer/word-count'
describe('word count CJK rule (#93)', () => {
describe('word count CJK rule', () => {
it('counts asian chars one by one, punctuation included', () => {
expect(asianCharCount('深圳市人民政府')).toBe(7)
expect(asianCharCount('残疾预防,从我做起。')).toBe(10)