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
+3 -3
View File
@@ -195,7 +195,7 @@ function parseShapeFragment(
// semantic tree; the byte-fidelity side's anchor.originalXml stays the original fragment.
// <a:fld> (slide number/date) gets the same treatment: it is structurally an a:r,
// and rewriting the tag (attributes kept, so @_type survives for run.field) keeps
// fields in document order instead of being appended after all plain runs (#88).
// fields in document order instead of being appended after all plain runs.
const semanticXml = fragXml
.replace(/<a:br\b[^>]*\/>|<a:br\b[\s\S]*?<\/a:br>/g, '<a:r><a:t>\n</a:t></a:r>')
.replace(/<a:fld\b/g, '<a:r')
@@ -292,7 +292,7 @@ function parseSpShape(
fill = tplFill ?? (phClr ? { type: 'solid', color: phClr } : undefined)
}
}
// explicit <a:ln><a:noFill/> (stroke === null) wins over the lnRef template (#102)
// explicit <a:ln><a:noFill/> (stroke === null) wins over the lnRef template
if (stroke === undefined) stroke = styleRefStroke(node, ctx)
if (!shadow && !glow) {
const ref = style['a:effectRef']
@@ -419,7 +419,7 @@ function parseConnector(node: any, anchor: ByteAnchor, ctx: ParseContext): TextE
'#000000'
const explicitStroke = parseStroke(spPr, ctx, spPr?.['a:ln'] ? fallback : undefined)
// null = author explicitly disabled the outline; only an *absent* a:ln
// falls back (so an unstyled connector never turns invisible, #102)
// falls back (so an unstyled connector never turns invisible)
const stroke =
explicitStroke === null
? undefined
@@ -1,5 +1,5 @@
/**
* <a:fld> in-paragraph ordering (#88): a field must stay at its document
* <a:fld> in-paragraph ordering: a field must stay at its document
* position relative to plain runs — "fld(2) + r(h)" renders as "2h", not "h2".
*/
import { describe, it, expect } from 'vitest'
@@ -24,7 +24,7 @@ const runsOf = (spTree: string, paraIndex = 0) => {
return el.text!.paragraphs[paraIndex]!.runs
}
describe('a:fld document-order preservation (#88)', () => {
describe('a:fld document-order preservation', () => {
it('fld before a plain run stays first (fld("2") + r("h") → "2h")', () => {
const runs = runsOf(
textBox(
+1 -1
View File
@@ -252,7 +252,7 @@ describe('groupElements integration', () => {
})
})
// ── #43-A: mixed-type group children keep document order ─────────────────────
// ── mixed-type group children keep document order ────────────────────────────
const SLIDE_NS =
'xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" ' +
@@ -727,7 +727,7 @@ describe('field runs & wordart & preset shapes', () => {
})
})
describe('per-data-point chart colors (#90)', () => {
describe('per-data-point chart colors', () => {
it('pointColors patch writes <c:dPt>, survives save/reopen and later style-only rebuilds', async () => {
const opened = await openPptx(fx('01_standard_business.pptx'))
const r = addChart(opened, 0, {
@@ -173,7 +173,7 @@ describe('multi-level indentation indentDelta', () => {
})
})
describe('per-paragraph paraIndices (#85 editing-mode selection)', () => {
describe('per-paragraph paraIndices (editing-mode selection)', () => {
const TWO_PARAS =
'<a:bodyPr/><a:p><a:r><a:t>Heading</a:t></a:r></a:p>' +
'<a:p><a:pPr marL="228600" indent="-228600"><a:buChar char="•"/></a:pPr><a:r><a:t>Body</a:t></a:r></a:p>'
+2 -2
View File
@@ -199,7 +199,7 @@ describe('setElementFont (change font family/size for a whole selected element)'
if (pic) expect(setElementFont(slide, pic.id, { fontFamily: 'Arial' })).toBe(false)
})
it('table: sizes cells with text and leaves a persisted marker on empty cells (#205)', async () => {
it('table: sizes cells with text and leaves a persisted marker on empty cells', async () => {
const opened = await openPptx(fx('01_standard_business.pptx'))
const r = addTable(opened, 0, {
rows: 2,
@@ -224,7 +224,7 @@ describe('setElementFont (change font family/size for a whole selected element)'
expect(tbl2.rows[0]![1]!.text!.paragraphs[0]!.runs[0]!.fontSize).toBe(14)
})
it('table with only empty cells still reports a change (#205)', async () => {
it('table with only empty cells still reports a change', async () => {
const opened = await openPptx(fx('01_standard_business.pptx'))
const r = addTable(opened, 0, {
rows: 2,
@@ -1,5 +1,5 @@
/**
* Run-level hyperlinks (#146): parse-time rId resolution + hlink styling, rels allocation
* Run-level hyperlinks: parse-time rId resolution + hlink styling, rels allocation
* for links set in-session, patch-path <a:hlinkClick> surgery, and live lookup for the show.
*/
import { describe, it, expect } from 'vitest'
@@ -1,4 +1,4 @@
/** #43-D/E: non-shape spTree children between two shapes (mc:AlternateContent etc.) are preserved verbatim on rebuild. */
/** Non-shape spTree children between two shapes (mc:AlternateContent etc.) are preserved verbatim on rebuild. */
import { describe, it, expect } from 'vitest'
import JSZip from 'jszip'
import { openPptx, savePptx, addElement, createBlankPptx, patchSlideXml } from '../src/index'
@@ -85,7 +85,11 @@ describe('parseTheme fmtScheme', () => {
describe('p:style references -> fmtScheme templates', () => {
const parse = () =>
parseSlide({ path: 'ppt/slides/slide1.xml', slideXml: slideWith(shapeWithStyle(STYLE_REFS)), ctx: { theme } })
parseSlide({
path: 'ppt/slides/slide1.xml',
slideXml: slideWith(shapeWithStyle(STYLE_REFS)),
ctx: { theme },
})
it('fillRef idx=2 -> linear gradient template, phClr substituted with accent2 and modifiers applied', () => {
const el = parse().elements[0] as TextElement
@@ -125,12 +129,17 @@ describe('p:style references -> fmtScheme templates', () => {
const style =
'<a:lnRef idx="0"/><a:fillRef idx="1001"><a:schemeClr val="accent3"/></a:fillRef>' +
'<a:effectRef idx="0"/><a:fontRef idx="minor"/>'
const slide = parseSlide({ path: 'ppt/slides/slide1.xml', slideXml: slideWith(shapeWithStyle(style)), ctx: { theme } })
const slide = parseSlide({
path: 'ppt/slides/slide1.xml',
slideXml: slideWith(shapeWithStyle(style)),
ctx: { theme },
})
expect((slide.elements[0] as TextElement).fill).toEqual({ type: 'solid', color: '#A5A5A5' })
})
it('explicit spPr fill/stroke wins over style references (not overridden by templates)', () => {
const explicit = '<a:solidFill><a:srgbClr val="112233"/></a:solidFill><a:ln w="25400"><a:solidFill><a:srgbClr val="445566"/></a:solidFill></a:ln>'
const explicit =
'<a:solidFill><a:srgbClr val="112233"/></a:solidFill><a:ln w="25400"><a:solidFill><a:srgbClr val="445566"/></a:solidFill></a:ln>'
const slide = parseSlide({
path: 'ppt/slides/slide1.xml',
slideXml: slideWith(shapeWithStyle(STYLE_REFS, explicit)),
@@ -141,7 +150,7 @@ describe('p:style references -> fmtScheme templates', () => {
expect(el.stroke?.width).toBe(25400)
})
it('explicit <a:ln><a:noFill/> wins over lnRef: no stroke is drawn (#102)', () => {
it('explicit <a:ln><a:noFill/> wins over lnRef: no stroke is drawn', () => {
const noOutline = '<a:ln><a:noFill/></a:ln>'
const slide = parseSlide({
path: 'ppt/slides/slide1.xml',
@@ -151,7 +160,7 @@ describe('p:style references -> fmtScheme templates', () => {
expect((slide.elements[0] as TextElement).stroke).toBeUndefined()
})
it('connector with explicit <a:ln><a:noFill/> draws no stroke; absent a:ln still falls back (#102)', () => {
it('connector with explicit <a:ln><a:noFill/> draws no stroke; absent a:ln still falls back', () => {
const cxn = (ln: string) =>
'<p:cxnSp><p:nvCxnSpPr><p:cNvPr id="7" name="C"/><p:cNvCxnSpPr/><p:nvPr/></p:nvCxnSpPr>' +
'<p:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="1000" cy="1000"/></a:xfrm>' +
@@ -165,7 +174,11 @@ describe('p:style references -> fmtScheme templates', () => {
it('theme without fmtScheme (legacy behavior): falls back to reference-color solid + 1pt', () => {
const bare: any = { colors: { accent1: '#4472C4', accent2: '#ED7D31', dk1: '#000000' } }
const slide = parseSlide({ path: 'ppt/slides/slide1.xml', slideXml: slideWith(shapeWithStyle(STYLE_REFS)), ctx: { theme: bare } })
const slide = parseSlide({
path: 'ppt/slides/slide1.xml',
slideXml: slideWith(shapeWithStyle(STYLE_REFS)),
ctx: { theme: bare },
})
const el = slide.elements[0] as TextElement
expect(el.fill?.type).toBe('solid')
expect(el.stroke?.width).toBe(12700)