Sync snapshot (2026-08-20) (#123)

- Add fully local PDF to Word, PowerPoint, and Excel conversion
- Add bring-your-own-key AI providers - Claude, OpenAI, Gemini, DeepSeek, Kimi, GLM, Qwen, Doubao, MiniMax, Grok, Mistral, OpenRouter, and custom OpenAI-compatible endpoints - with a refreshed AI settings UI
- Rework the Slides AI editing surface: canonical edit-op registry, atomic transactions with rollback, durable element ids, and batched apply_ops
- Improve Slides fidelity: chart, font, gradient, table-style, and text-shaping fixes, plus PPT-parity line editing and adjust handles
- Polish Docs: password-protection dialogs, anchored-image wrapping fixes, and selection and clipboard fixes
- Add themed dropdowns suite-wide with accent-derived selection states

Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
This commit is contained in:
merrick-2002
2026-08-21 00:33:18 +08:00
committed by GitHub
co-authored by GenOffice
parent fe2e17403c
commit f68df70e22
326 changed files with 47473 additions and 4332 deletions
+24 -12
View File
@@ -786,6 +786,8 @@ function buildChartNodeInner(
// ── Category labels (all shown: horizontal, wrapped horizontal, or rotated when crowded) ──
const n = Math.max(model.categories.length, 1)
const slotW = plot.w / n
// c:orientation maxMin on the category axis flips the category order (first slot on the right)
const catSlot = model.catAxis?.reversed ? (i: number) => n - 1 - i : (i: number) => i
// Category-axis vertical gridlines: majors at slot boundaries, minors at slot midpoints
const catGrid = majorGridColor(model.catAxis, model)
const catMinor = minorGridColor(model.catAxis, model)
@@ -837,7 +839,7 @@ function buildChartNodeInner(
const catLabelBase = catAtZero ? crossY : plot.y + plot.h
if (!catLabelsOff)
model.categories.forEach((cat, i) => {
const cx = plot.x + (i + 0.5) * slotW
const cx = plot.x + (catSlot(i) + 0.5) * slotW
if (drawRotate) {
// Rotation is about the text's origin (left end). Negative angles slant up-right:
// place the origin down-left so the right end lands just below the tick. Positive
@@ -878,9 +880,14 @@ function buildChartNodeInner(
const gy = plot.y + plot.h + catReserve + catLabelSizePx * 0.35
const nCatsG = Math.max(model.categories.length, 1)
const slotWG = plot.w / nCatsG
const revG = !!model.catAxis?.reversed
model.categoryGroups.forEach((g, gi) => {
const end = model.categoryGroups![gi + 1]?.start ?? nCatsG
const cxG = plot.x + ((g.start + end) / 2) * slotWG
// maxMin remaps category i to slot n-1-i, so the span [start, end) lands
// on slots [n-end, n-start) and the divider boundary flips with it
const lo = revG ? nCatsG - end : g.start
const hi = revG ? nCatsG - g.start : end
const cxG = plot.x + ((lo + hi) / 2) * slotWG
node.labels.push({
text: g.label,
x: cxG - measure(g.label, catLabelSizePx) / 2,
@@ -888,11 +895,12 @@ function buildChartNodeInner(
fontSizePx: catLabelSizePx,
color: catLabelColor,
})
const bx = revG ? nCatsG - g.start : g.start
if (g.start > 0)
node.axisLines.push({
x1: plot.x + g.start * slotWG,
x1: plot.x + bx * slotWG,
y1: plot.y + plot.h,
x2: plot.x + g.start * slotWG,
x2: plot.x + bx * slotWG,
y2: plot.y + plot.h + catReserve + catLabelSizePx * 1.5,
color: model.catAxis?.lineColor ?? '#888888',
widthPx: 1,
@@ -921,7 +929,7 @@ function buildChartNodeInner(
const gap = (model.gapWidthPct ?? 150) / 100
const barW = slotW / (1 + gap)
for (let i = 0; i < n; i++) {
const x = plot.x + i * slotW + (slotW - barW) / 2
const x = plot.x + catSlot(i) * slotW + (slotW - barW) / 2
let posAcc = 0
let negAcc = 0
barSeriesIdx.forEach((si) => {
@@ -955,7 +963,7 @@ function buildChartNodeInner(
const color = seriesColor(si)
ser.values.forEach((v, i) => {
if (v == null || i >= n) return
const x = plot.x + i * slotW + (slotW - groupW) / 2 + slot * step
const x = plot.x + catSlot(i) * slotW + (slotW - groupW) / 2 + slot * step
const yTop = Math.min(yOf(v), yOf(base))
const yBot = Math.max(yOf(v), yOf(base))
// Explicit per-point colors (c:dPt, varyColors multi-color single-series bars) win over the series color
@@ -1008,7 +1016,7 @@ function buildChartNodeInner(
for (let i = 0; i < n; i++) {
let v = ser.values[i] ?? 0
if (grouping === 'percentStacked') v = (v / (areaTotals[i] || 1)) * 100
const x = plot.x + (i + 0.5) * slotW
const x = plot.x + (catSlot(i) + 0.5) * slotW
const y0 = yOf(areaCum[i]!)
bottom.push(x, y0)
areaCum[i]! += v
@@ -1025,7 +1033,7 @@ function buildChartNodeInner(
const pts: number[] = []
ser.values.forEach((v, i) => {
if (v == null || i >= n) return
const x = plot.x + (i + 0.5) * slotW
const x = plot.x + (catSlot(i) + 0.5) * slotW
let vv = v
if (lineStack) {
vv = lineCum[i]! + (valueAt(si, i) ?? 0)
@@ -1078,7 +1086,7 @@ function buildChartNodeInner(
for (let i = 0; i < n; i++) {
const vals = stockSers.map((s) => s.values[i]).filter((v): v is number => v != null)
if (vals.length < 2) continue
const x = plot.x + (i + 0.5) * slotW
const x = plot.x + (catSlot(i) + 0.5) * slotW
if (model.stock.hiLowLines) {
node.axisLines.push({
x1: x,
@@ -1369,12 +1377,16 @@ function buildPieNode(
const r = innerR > 0 ? (innerR + outerR) / 2 : outerR * 0.66
const valueText = model.dataLabelsPct ? `${Math.round((v / total) * 100)}%` : fmtNum(v)
const text = composeDataLabel(model, 0, i, valueText)
const dlSize = model.dataLabelPt ? ptToPx(model.dataLabelPt, vp.scale) : labelSizePx * 0.9
const dlBold = !!model.dataLabelBold
const dlW = metrics.measure(text, { ...style, fontSizePx: dlSize, bold: dlBold })
node.labels.push({
text,
x: cx + dx + Math.cos(midRad) * (p3d ? rx * 0.66 : r) - measure(text) / 2,
y: cy + dy + Math.sin(midRad) * (p3d ? ry * 0.66 : r) - labelSizePx * 0.55,
fontSizePx: labelSizePx * 0.9,
x: cx + dx + Math.cos(midRad) * (p3d ? rx * 0.66 : r) - dlW / 2,
y: cy + dy + Math.sin(midRad) * (p3d ? ry * 0.66 : r) - dlSize * 0.55,
fontSizePx: dlSize,
color: '#FFFFFF',
...(dlBold ? { bold: true } : {}),
})
}
angle += sweep
+33 -4
View File
@@ -17,6 +17,7 @@ import type {
// Subpath import: the renderer bundles this package, so pulling the engine's index
// (Node-only imports like node:crypto) would break the browser build
import { tableRowGridCols } from '@genoffice/pptx-engine/table-grid'
import { elementDurableId, groupChildDurableId } from '@genoffice/pptx-engine/identity'
import { isBackgroundLikeElement } from '@genoffice/pptx-engine/background-promote'
import { buildChartNode } from './build-chart'
import type {
@@ -191,6 +192,26 @@ function buildNode(
metrics: FontMetricsProvider,
media: MediaResolver | undefined,
parentOffset: ParentPlacement,
parentGroup?: SlideElement,
): RenderNode | null {
const node = buildNodeInner(el, vp, metrics, media, parentOffset)
// Durable id attached centrally so every node kind (charts and placeholder
// chips included) carries it — the AI projection prefers it over sourceId.
// Group children resolve through the parent's bytes (their creationId lives
// there), keeping the id continuous across group/ungroup.
if (node) {
const durable = parentGroup ? groupChildDurableId(parentGroup, el) : elementDurableId(el)
if (durable) node.durableId = durable
}
return node
}
function buildNodeInner(
el: SlideElement,
vp: Viewport,
metrics: FontMetricsProvider,
media: MediaResolver | undefined,
parentOffset: ParentPlacement,
): RenderNode | null {
const box = placeTransform(el.transform, vp, parentOffset)
switch (el.type) {
@@ -353,6 +374,8 @@ function buildShape(
...(el.placeholder ? { placeholder: el.placeholder } : {}),
...(el.presetGeometry ? { presetGeometry: el.presetGeometry } : {}),
}
// Raw avLst values ride along for the edit layer (yellow adjust handles)
if (el.adjust) node.adjust = { ...el.adjust }
// custGeom: the normalized path is scaled to local px by the element box (mutually exclusive with preset, takes priority)
if (el.customGeometry) {
const g = el.customGeometry
@@ -519,6 +542,7 @@ function buildPicture(
// tdf113163's black master bg shows through); other keys leave the DC white
...(metafileDcColor(isMetafile, el.clrChange) ?? {}),
...(el.duotone ? { duotone: el.duotone } : {}),
...(el.lum ? { lum: el.lum } : {}),
...(el.clrChange ? { clrChange: el.clrChange } : {}),
}
const stroke = resolveStroke(el.stroke, vp)
@@ -565,7 +589,7 @@ function buildGroup(
const children: RenderNode[] = []
for (const child of el.children ?? []) {
const c = buildNode(child, vp, metrics, media, parentOffset)
const c = buildNode(child, vp, metrics, media, parentOffset, el)
if (c) children.push(c)
}
return {
@@ -649,10 +673,13 @@ function buildTable(
const gridSpan = cell.gridSpan ?? 1
if (cell.merged) return
const rowSpan = cell.rowSpan ?? 1
const x = colX[cIdx] ?? 0
const xLogical = colX[cIdx] ?? 0
const y = rowY[r] ?? 0
const w = (colX[Math.min(cIdx + gridSpan, colX.length - 1)] ?? x) - x
const w = (colX[Math.min(cIdx + gridSpan, colX.length - 1)] ?? xLogical) - xLogical
const h = (rowY[Math.min(r + rowSpan, rowY.length - 1)] ?? y) - y
// rtl="1" mirrors the grid: logical column 1 renders rightmost (style banding and
// firstCol/lastCol regions stay on logical indices; only geometry flips)
const x = el.rtl ? totalW - xLogical - w : xLogical
const out: TableCellRender = {
x,
y,
@@ -667,7 +694,8 @@ function buildTable(
const borders: NonNullable<TableCellRender['borders']> = {}
for (const k of ['l', 'r', 't', 'b'] as const) {
const s = resolveStroke(cell.borders?.[k], vp)
if (s) borders[k] = s
// Mirrored geometry puts a cell's logical-left edge on the visual right
if (s) borders[el.rtl && k === 'l' ? 'r' : el.rtl && k === 'r' ? 'l' : k] = s
}
if (Object.keys(borders).length) out.borders = borders
if (cell.text && cell.text.paragraphs.length) {
@@ -693,6 +721,7 @@ function buildTable(
...(el.bgFill ? { bgFill: resolveFill(el.bgFill, vp, media) } : {}),
gridX: colX,
gridY: rowY,
...(el.rtl ? { rtl: true } : {}),
...(el.styleFlags ? { styleFlags: el.styleFlags } : {}),
}
}
+14 -1
View File
@@ -47,6 +47,7 @@ export function resolveFill(
...(fill.alpha != null ? { alpha: fill.alpha } : {}),
...(fill.fillRect ? { fillRect: fill.fillRect } : {}),
...(fill.duotone ? { duotone: fill.duotone } : {}),
...(fill.lum ? { lum: fill.lum } : {}),
...(fill.clrChange ? { clrChange: fill.clrChange } : {}),
...(fill.tile
? {
@@ -79,17 +80,29 @@ export function resolveStroke(stroke: Stroke | undefined, vp: Viewport): RenderS
if (!stroke) return undefined
const rf = stroke.fill
let color = '#000000'
let gradient: RenderStroke['gradient']
if (rf.type === 'solid') color = rf.color
else if (rf.type === 'none') return undefined
else if (rf.type === 'gradient' && rf.stops.length) {
gradient = {
stops: rf.stops.map((s) => ({ pos: s.pos, color: s.color })),
angleDeg: rf.angle != null ? rf.angle / 60000 : 0,
}
color = rf.stops[0]!.color
} else if (rf.type === 'none') return undefined
const widthPx = Math.max(emuToPx(stroke.width || 12700, vp.scale), 0.5)
const widthPt = (stroke.width || 12700) / EMU_PER_PT
const dash = dashPreset(stroke.dash, widthPx)
const capMap = { flat: 'butt', round: 'round', square: 'square' } as const
return {
color,
widthPx,
widthPt,
...(dash ? { dash } : {}),
...(stroke.dash && stroke.dash !== 'solid' ? { dashPreset: stroke.dash } : {}),
...(stroke.cap ? { cap: capMap[stroke.cap] } : {}),
...(stroke.join ? { join: stroke.join } : {}),
...(stroke.compound ? { compound: stroke.compound } : {}),
...(gradient ? { gradient } : {}),
}
}
+21 -1
View File
@@ -29,6 +29,9 @@ export interface RenderNodeBase {
box: PlacedBox
/** Source Slide element id, used by the edit layer to locate write-backs */
sourceId: string
/** Durable element id ("e_*", from a16:creationId / cNvPr bytes): survives
save→reopen, reparse and group/ungroup — what the AI layer shows and accepts */
durableId?: string
/** master/layout decoration node: read-only display, not selectable/draggable/snappable */
decoration?: boolean
/**
@@ -63,6 +66,8 @@ export type RenderFill =
fillRect?: { l: number; t: number; r: number; b: number }
/** [dark, light] duotone colors mapped over image luminance */
duotone?: [string, string]
/** Legacy brightness/contrast picture adjustment (-1..1 each) */
lum?: { bright: number; contrast: number }
/** clrChange: pixels matching `from` become `to` (#RRGGBB or #RRGGBBAA) */
clrChange?: { from: string; to: string }
/** Tile grid: scale in px-per-image-px, anchor offsets in px, and the algn anchor */
@@ -86,6 +91,14 @@ export interface RenderStroke {
dash?: number[]
/** OOXML prstDash preset name (for property panel display/editing) */
dashPreset?: string
/** Canvas line cap (from <a:ln cap>; canvas default butt when absent) */
cap?: 'butt' | 'round' | 'square'
/** Canvas line join (from <a:round>/<a:bevel>/<a:miter>) */
join?: 'round' | 'bevel' | 'miter'
/** Compound line type (<a:ln cmpd>; drawn single on canvas, kept for editing round-trip) */
compound?: 'sng' | 'dbl' | 'thickThin' | 'thinThick' | 'tri'
/** Gradient line (<a:ln><a:gradFill>); color then holds the first stop as a fallback */
gradient?: { stops: Array<{ pos: number; color: string }>; angleDeg: number }
}
/** Outer shadow converted to px. */
@@ -224,6 +237,8 @@ export interface ShapeRenderNode extends RenderNodeBase {
/** Placeholder type (title/ctrTitle/subTitle/body/…); empty placeholders draw hint text on the canvas */
placeholder?: string
presetGeometry?: string
/** Raw avLst adjust values (OOXML units) for the edit layer's adjust handles */
adjust?: Record<string, number>
/** Exact corner radius for roundRect-style geometry (px, computed from avLst adj; 50% of the min side = pill) */
cornerRadiusPx?: number
/** Point list of closed-polygon preset geometry (triangle/diamond/arrow…) (local px, drawn closed) */
@@ -262,6 +277,8 @@ export interface PictureRenderNode extends RenderNodeBase {
fill?: RenderFill
/** [dark, light] duotone colors applied to the picture pixels */
duotone?: [string, string]
/** Brightness/contrast applied to the picture pixels (-1..1 each) */
lum?: { bright: number; contrast: number }
/** clrChange applied to the picture pixels before duotone */
clrChange?: { from: string; to: string }
/** Picture shape-geometry clip (picture styles): three channels matching shape geometry; clip when any is set */
@@ -325,9 +342,12 @@ export interface TableRenderNode extends RenderNodeBase {
cells: TableCellRender[]
/** Table-style <a:tblBg>: drawn under the cells (alpha band fills composite over it) */
bgFill?: TableCellRender['fill']
/** Grid line offsets relative to the box (px): gridX has nCols+1 entries, gridY nRows+1 */
/** Grid line offsets relative to the box (px): gridX has nCols+1 entries, gridY nRows+1.
gridX stays in logical column order; when rtl is set, visual x = table width − gridX. */
gridX: number[]
gridY: number[]
/** tblPr rtl="1": cell geometry is mirrored (logical column 1 rendered rightmost) */
rtl?: boolean
/** tblPr header-row / banded-row toggles (for the Ribbon "Table Design" display) */
styleFlags?: { firstRow: boolean; bandRow: boolean }
}
+21 -2
View File
@@ -387,6 +387,16 @@ function symbolBulletText(font: string | undefined, char: string): string | unde
return cp >= 0x20 && cp <= 0xff ? String.fromCodePoint(0xf000 + cp) : char
}
// ── East-Asian kinsoku (PowerPoint default rules) ───────────────────
// Closing marks / small kana must not begin a line; opening brackets must not end one.
// Only single-grapheme tokens participate (CJK tokenization emits one token per wide char).
const KINSOKU_NO_START = new Set(
'、。々,.!?:;)]}%,.!?:;)]}%〉》」』】〕〟。」、・ー゙゚・ーぁぃぅぇぉっゃゅょゎゕゖァィゥェォッャュョヮヵヶ゛゜ゝゞヽヾ',
)
const KINSOKU_NO_END = new Set('([{$([{$〈《「『【〔〝「£¥£¥')
const kinsokuNoStart = (t: Token) => KINSOKU_NO_START.has(t.text)
const kinsokuNoEnd = (t: Token) => KINSOKU_NO_END.has(t.text)
/** Southeast Asian scripts without spaces (Thai/Burmese/Khmer/Lao); word boundaries need ICU dictionary segmentation. */
const SEA_RE = /[฀-໿က-႟ក-៿]/
const WORD_SEG: Intl.Segmenter | null =
@@ -581,9 +591,18 @@ function layoutParagraph(
// lazily because the soft wrap right below can end line 0 for this same token
const lineAvail = () => (lines.length === 0 ? availWidth - firstLineShrinkPx : availWidth)
if (wrap && cur.length && curW + w > lineAvail() && !tok.isSpace) {
// Kinsoku: pull the predecessor down when the new line would start with a closing
// mark, push an opening bracket down when it would end the old line.
const carry: Token[] = []
while (cur.length > 1) {
const head = carry[0] ?? tok
const last = cur[cur.length - 1]!
if (last.isSpace || (!kinsokuNoStart(head) && !kinsokuNoEnd(last))) break
carry.unshift(cur.pop()!)
}
pushLine(cur)
cur = []
curW = 0
cur = carry
curW = carry.reduce((s, t) => s + tokenWidth(t, metrics), 0)
}
// Hard-break over-long words (a single token wider than the line)
if (wrap && !cur.length && w > lineAvail() && tok.text.length > 1 && !tok.isSpace) {
@@ -599,6 +599,24 @@ describe('chart wave2: palette idx colors, multi-level cats, barH hidden labels'
expect(ca.y).toBeGreaterThan(leaf.y)
})
it('reversed category axis (maxMin) mirrors the group label spans', () => {
const m: ChartModel = {
kind: 'bar',
categories: ['SF', 'LA', 'NY', 'Albany'],
series: [{ values: [1, 2, 3, 4] }],
catAxis: { reversed: true },
categoryGroups: [
{ label: 'CA', start: 0 },
{ label: 'NY2', start: 2 },
],
} as any
const node = buildChartNode('r_1', 'el1', m, box, vp, metrics)!
const ca = node.labels.find((l) => l.text === 'CA')!
const ny = node.labels.find((l) => l.text === 'NY2')!
// categories render right-to-left, so CA's span now sits on the right
expect(ca.x).toBeGreaterThan(ny.x)
})
it('barH with tickLblPos none draws no category labels', () => {
const m: ChartModel = {
kind: 'bar',
@@ -361,6 +361,39 @@ describe('buildRenderSlide (end-to-end on real fixture)', () => {
expect(table.cells[0].w).toBeCloseTo(952500 / emuPerPx, 0)
})
it('rtl table mirrors the grid: logical column 1 renders rightmost, borders swap sides', async () => {
const { deck } = await openPptx(enginePptx('01_standard_business.pptx'))
const slide = deck.slides[0]!
const stroke = { fill: { type: 'solid', color: '#FF0000' }, widthPt: 1 }
const el: any = {
id: 'tbl_rtl',
type: 'table',
anchor: { spIndex: -1, originalXml: '', range: [0, 0] },
transform: {
offset: { x: 0, y: 0, cx: 2857500, cy: 952500 },
rot: 0,
flipH: false,
flipV: false,
},
rtl: true,
colWidths: [952500, 1905000],
rowHeights: [952500],
rows: [[{ borders: { l: stroke } }, {}]],
}
const rs = buildRenderSlide({ ...slide, elements: [el], decorations: [] }, deck.size, {
fitWidthPx: 1280,
})
const node = rs.nodes[0] as any
const [c0, c1] = node.cells
// logical col 0 (narrow) sits at the right edge, col 1 at x=0
expect(c1.x).toBeCloseTo(0, 1)
expect(c0.x).toBeCloseTo(c1.w, 1)
expect(c0.x + c0.w).toBeCloseTo(node.box.w, 1)
// the logical-left border of col 0 lands on its visual right edge
expect(c0.borders?.r).toBeTruthy()
expect(c0.borders?.l).toBeUndefined()
})
it('cells after a mid-row merge keep their grid position (continuation tc is not double-counted)', async () => {
const { deck } = await openPptx(enginePptx('01_standard_business.pptx'))
const slide = deck.slides[0]!
@@ -890,3 +923,36 @@ describe('metafile pictures get an opaque white backdrop (PlanS academy banner)'
expect(build({ from: '#FFFFFF', to: '#00FF0080' }).bgColor).toBe('#00FF0080')
})
})
describe('durable ids on render nodes', () => {
it('nodes carry the durable id resolved from the element bytes', async () => {
const { deck } = await openPptx(enginePptx('01_standard_business.pptx'))
const slide = deck.slides[0]!
const rs = buildRenderSlide(slide, deck.size, { fitWidthPx: 1280 })
// Every element has at least the cNvPr fallback in its bytes
for (const n of rs.nodes) {
expect(n.durableId).toMatch(/^e_/)
}
// Ids are unique per slide
const ids = rs.nodes.map((n) => n.durableId)
expect(new Set(ids).size).toBe(ids.length)
})
})
describe('durable ids on chart nodes', () => {
it('charts (and their placeholder chips) carry durable ids too', async () => {
const opened = await openPptx(enginePptx('01_standard_business.pptx'))
const { addChart } = await import('@genoffice/pptx-engine')
const r = addChart(opened, 0, {
kind: 'bar',
categories: ['Q1', 'Q2'],
series: [{ name: 'Rev', values: [3, 5] }],
offset: { x: 914400, y: 914400, cx: 4572000, cy: 2743200 },
})
expect(r).toBeTruthy()
const rs = buildRenderSlide(opened.deck.slides[0]!, opened.deck.size, { fitWidthPx: 1280 })
const chart = rs.nodes.find((n) => n.type === 'chart' || n.type === 'placeholder-chip')
expect(chart).toBeTruthy()
expect(chart!.durableId).toMatch(/^e_[0-9a-f]{8}$/)
})
})
@@ -145,6 +145,46 @@ describe('2.3 text layout', () => {
expect(layout.lines.length).toBeGreaterThan(1)
})
it('kinsoku: a closing mark never starts a line (its predecessor is pulled down)', () => {
// 4 chars fit per line (4 × 24px = 96px); without kinsoku 、would head line 2
const layout = layoutText({
body: body({ paragraphs: [{ runs: [{ text: 'ああああ、いい', fontSize: 24 }] }] }),
boxWidthPx: 96,
boxHeightPx: 3000,
metrics: new HeuristicMetrics(),
vp,
})
const lines = layout.lines.map((l) => l.runs.map((r) => r.text).join(''))
expect(lines[0]).toBe('あああ')
expect(lines[1]!.startsWith('あ、')).toBe(true)
})
it('kinsoku: chained closing marks pull the whole tail down', () => {
const layout = layoutText({
body: body({ paragraphs: [{ runs: [{ text: 'あああ。」いい', fontSize: 24 }] }] }),
boxWidthPx: 96,
boxHeightPx: 3000,
metrics: new HeuristicMetrics(),
vp,
})
const lines = layout.lines.map((l) => l.runs.map((r) => r.text).join(''))
expect(lines[0]).toBe('ああ')
expect(lines[1]!.startsWith('あ。」')).toBe(true)
})
it('kinsoku: an opening bracket never ends a line', () => {
const layout = layoutText({
body: body({ paragraphs: [{ runs: [{ text: 'あああ「いいい', fontSize: 24 }] }] }),
boxWidthPx: 96,
boxHeightPx: 3000,
metrics: new HeuristicMetrics(),
vp,
})
const lines = layout.lines.map((l) => l.runs.map((r) => r.text).join(''))
expect(lines[0]).toBe('あああ')
expect(lines[1]!.startsWith('「い')).toBe(true)
})
it('autofit=shrink reduces font scale when content overflows height', () => {
const many = Array.from({ length: 30 }, (_, i) => ({
runs: [{ text: `Line ${i} of text`, fontSize: 40 }],
+1
View File
@@ -7,6 +7,7 @@
"paths": {
"@genoffice/pptx-engine": ["../pptx-engine/src/index.ts"],
"@genoffice/pptx-engine/table-grid": ["../pptx-engine/src/table-grid.ts"],
"@genoffice/pptx-engine/identity": ["../pptx-engine/src/identity.ts"],
"@genoffice/pptx-engine/background-promote": ["../pptx-engine/src/background-promote.ts"]
}
},
+1
View File
@@ -10,6 +10,7 @@ export default defineConfig({
alias: {
// Subpath before the bare name: string aliases are prefix replacements
'@genoffice/pptx-engine/table-grid': resolve(here, '../pptx-engine/src/table-grid.ts'),
'@genoffice/pptx-engine/identity': resolve(here, '../pptx-engine/src/identity.ts'),
'@genoffice/pptx-engine/background-promote': resolve(
here,
'../pptx-engine/src/background-promote.ts',