Sync snapshot (2026-08-12) (#87)

- Add text insertion and improved text editing in PDF files
- Expand PDF form filling, annotations, highlighting, and visual signature workflows
- Add PDF image crop, flip, transparency, replacement, and background removal
- Improve Sheets validation rendering, undo behavior, and workbook stability
- Add system font discovery and improve shared Office interface consistency
- Improve AI network resilience and response validation

Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
This commit is contained in:
merrick-2002
2026-08-12 08:36:35 +08:00
committed by GitHub
co-authored by GenOffice
parent 2c1f0e821a
commit dc4d7e5927
157 changed files with 10981 additions and 1646 deletions
+8 -6
View File
@@ -499,17 +499,19 @@ function patchRunFont(runXml: string, family: string): string {
// silently doing nothing: a payload's own closing tag can truncate the slice this is given
if (!rPr) return patchRunFontUnscannable(runXml, esc)
const el = runXml.slice(rPr.start, rPr.end)
const rPrOpen = /^<a:rPr\b(?:"[^"]*"|'[^']*'|[^"'>])*?>/.exec(el)?.[0]
// Self-closing rPr → expand to a pair around the slots
if (!rPrOpen) {
const attrs = /^<a:rPr\b((?:"[^"]*"|'[^']*'|[^"'>])*?)\/>$/.exec(el)?.[1]
if (attrs === undefined) return patchRunFontUnscannable(runXml, esc)
// Self-closing rPr → expand to a pair around the slots. Checked before the open-tag match:
// that pattern's [^"'>] accepts '/', so it would swallow a self-closing tag whole and this
// branch could never run.
const selfAttrs = /^<a:rPr\b((?:"[^"]*"|'[^']*'|[^"'>])*?)\/>$/.exec(el)?.[1]
if (selfAttrs !== undefined) {
return (
runXml.slice(0, rPr.start) +
`<a:rPr${attrs}>${fontSlotsXml(esc)}</a:rPr>` +
`<a:rPr${selfAttrs}>${fontSlotsXml(esc)}</a:rPr>` +
runXml.slice(rPr.end)
)
}
const rPrOpen = /^<a:rPr\b(?:"[^"]*"|'[^']*'|[^"'>])*?>/.exec(el)?.[0]
if (!rPrOpen) return patchRunFontUnscannable(runXml, esc)
const innerStart = rPr.start + rPrOpen.length
// the closing tag's own start, since a valid one may carry whitespace before its '>'
const innerEnd = rPr.start + el.lastIndexOf('</')
@@ -200,6 +200,22 @@ describe('complex-script font follows the font change', () => {
expect(out).not.toContain("typeface='Old'")
})
it('expands a self-closing rPr to the full slot group, attributes kept', () => {
// the open-tag pattern's [^"'>] accepts '/', so an unguarded match would swallow a
// self-closing tag whole and route it to the latin/ea-only fallback
const out = refont('<a:r><a:rPr lang="ar-SA" b="1"/><a:t>مرحبا</a:t></a:r>')
// the run attribute writer may add its own attrs (e.g. i="0"); the declared ones survive
expect(out).toMatch(/<a:rPr[^>]*\blang="ar-SA"[^>]*\bb="1"[^>]*>/)
expect(slotOrder(out)).toEqual(['latin', 'ea', 'cs'])
expect(/<a:cs[^>]*typeface="([^"]*)"/.exec(out)?.[1]).toBe('Amiri')
})
it('expands a bare self-closing rPr as well', () => {
const out = refont('<a:r><a:rPr/><a:t>مرحبا</a:t></a:r>')
expect(slotOrder(out)).toEqual(['latin', 'ea', 'cs'])
expect(/<a:cs[^>]*typeface="([^"]*)"/.exec(out)?.[1]).toBe('Amiri')
})
it('does not add a second slot group to a run using mc:AlternateContent', () => {
// the branch children only exist once a consumer picks a branch, so injecting a direct
// group alongside them would leave two a:latin after preprocessing