jvs-ppt-ui 0.0.28 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jvs-ppt-ui",
3
3
  "private": false,
4
- "version": "0.0.28",
4
+ "version": "0.0.29",
5
5
  "type": "module",
6
6
  "main": "./dist/lib/jvs-ppt-ui.umd.js",
7
7
  "module": "./dist/lib/jvs-ppt-ui.es.js",
@@ -2171,7 +2171,7 @@ const generatePptxBlob = async (): Promise<Blob | null> => {
2171
2171
  pptxSlide.addImage(imgOpts)
2172
2172
  }
2173
2173
  else if (el.type === 'shape') {
2174
- const shapeType = getPredefinedShapeType(el.content, el.pathFormula, (el as any).pptxShapeType)
2174
+ const shapeType = getPredefinedShapeType(el.content, el.pathFormula, (el as any).pptxShapeType || (el as any).shapType)
2175
2175
 
2176
2176
  // Set defaults based on shape types to match CanvasArea.vue styles
2177
2177
  let defaultFill = '#3b82f6'
@@ -2313,7 +2313,10 @@ const generatePptxBlob = async (): Promise<Blob | null> => {
2313
2313
  objectName: el.id
2314
2314
  }
2315
2315
 
2316
- const borderWidth = style.borderWidth ? (parseFloat(style.borderWidth) || 0) : 0
2316
+ const borderWidth = style.borderWidth ? (parseFloat(style.borderWidth) || 0) : 0
2317
+ if ((shapeType === 'roundRect' || shapeType === 'snip1Rect' || shapeType === 'round1Rect') && Array.isArray(el.keypoints) && typeof el.keypoints[0] === 'number') {
2318
+ shapeOpts.rectRadius = Math.max(0, Math.min(0.5, el.keypoints[0])) * Math.min(w, h)
2319
+ }
2317
2320
  const borderColorStr = style.borderColor
2318
2321
  if (borderWidth > 0 && borderColorStr && borderColorStr !== 'transparent' && borderColorStr !== 'none') {
2319
2322
  const borderParsed = parseColor(borderColorStr)
@@ -2352,7 +2355,9 @@ const generatePptxBlob = async (): Promise<Blob | null> => {
2352
2355
  shapeOpts.points = formatPoints(rawPoints, scale, pixelToInch) as any
2353
2356
  }
2354
2357
 
2355
- const shapeText = typeof el.text === 'string' ? el.text : ((el as any).text?.content || (typeof el.content === 'string' && !el.content.startsWith('M') && !el.content.startsWith('m') && el.content !== 'circle' && el.content !== 'triangle' && el.content.replace(/<[^>]+>/g, '').trim().length > 0 ? el.content : ''))
2358
+ const isShapeImgPh = !(el as any).isPlaceholderReplaced && !(el as any).replaced && ((el as any).placeholderType === 'pic' || (el as any).placeholderType === 'image' || (el as any).phType === 'pic' || (el as any).phType === 'picture' || (el as any).phType === 'clipArt' || (el as any).placeholder?.type === 'image' || (el as any).placeholder?.type === 'pic' || (typeof (el as any).name === 'string' && ((el as any).name.includes('Picture Placeholder') || (el as any).name.includes('图片占位符') || (el as any).name.includes('图片框'))))
2359
+ const rawShapeText = isShapeImgPh ? '' : (typeof el.text === 'string' ? el.text : ((el as any).text?.content || (typeof el.content === 'string' && !el.content.startsWith('M') && !el.content.startsWith('m') && el.content !== 'circle' && el.content !== 'triangle' ? el.content : '')))
2360
+ const shapeText = rawShapeText && rawShapeText.replace(/<[^>]+>/g, '').replace(/&nbsp;/gi, ' ').replace(/\u00A0/g, ' ').trim().length > 0 ? rawShapeText : ''
2356
2361
 
2357
2362
  if (shapeText) {
2358
2363
  const shapeTextDefaultColor = style.textColor || style.color || (style.fill === '#ffffff' || style.fill === '#FFFFFF' ? '#475569' : '#ffffff')
@@ -2436,7 +2441,10 @@ const generatePptxBlob = async (): Promise<Blob | null> => {
2436
2441
  fill: nativeFillOpt || shapeFillOpt
2437
2442
  }
2438
2443
  if (shapeOpts.points) {
2439
- shapeTextOpts.points = shapeOpts.points
2444
+ shapeTextOpts.points = shapeOpts.points
2445
+ }
2446
+ if (shapeOpts.rectRadius !== undefined) {
2447
+ shapeTextOpts.rectRadius = shapeOpts.rectRadius
2440
2448
  }
2441
2449
  if (shapeOpts.line) {
2442
2450
  shapeTextOpts.line = shapeOpts.line
@@ -3926,6 +3934,7 @@ const parsePPTXJSONData = (json: any, zipMeta?: any) => {
3926
3934
  id: generateAndRegisterId(el.id),
3927
3935
  name: el.name,
3928
3936
  phType: el.phType,
3937
+ phIdx: el.phIdx,
3929
3938
  isPlaceholder: el.isPlaceholder,
3930
3939
  placeholderType: el.placeholderType,
3931
3940
  placeholder: el.placeholder,
@@ -4066,6 +4075,7 @@ const parsePPTXJSONData = (json: any, zipMeta?: any) => {
4066
4075
  id: generateAndRegisterId(el.id),
4067
4076
  name: el.name,
4068
4077
  phType: el.phType,
4078
+ phIdx: el.phIdx,
4069
4079
  isPlaceholder: el.isPlaceholder,
4070
4080
  placeholderType: el.placeholderType,
4071
4081
  placeholder: el.placeholder,
@@ -4438,6 +4448,7 @@ const parsePPTXJSONData = (json: any, zipMeta?: any) => {
4438
4448
  id: generateAndRegisterId(el.id),
4439
4449
  name: el.name,
4440
4450
  phType: el.phType,
4451
+ phIdx: el.phIdx,
4441
4452
  isPlaceholder: el.isPlaceholder,
4442
4453
  placeholderType: el.placeholderType,
4443
4454
  placeholder: el.placeholder,
@@ -6081,7 +6092,9 @@ const parsePPTXJSONData = (json: any, zipMeta?: any) => {
6081
6092
  const elements: any[] = []
6082
6093
 
6083
6094
  // schemeClr(如 tx2/dk2/accent1) → 主题色 hex,供装饰形状还原真实填充色
6084
- const themeColors: Record<string, string> = (zipMeta as any)?.themeColors || {}
6095
+ const themeColors: Record<string, string> = (zipMeta as any)?.themeColors || {}
6096
+ const clrMap: Record<string, string> = (zipMeta as any)?.clrMap || { bg1: 'lt1', tx1: 'dk1', bg2: 'lt2', tx2: 'dk2' }
6097
+ const resolveSchemeSlot = (v: string) => clrMap[v] || (v === 'tx1' ? 'dk1' : v === 'bg1' ? 'lt1' : v === 'tx2' ? 'dk2' : v === 'bg2' ? 'lt2' : v)
6085
6098
 
6086
6099
  const parseSpGradFill = (gradXml: string): any => {
6087
6100
  const gsList = gradXml.match(/<a:gs\b[\s\S]*?<\/a:gs>/g) || []
@@ -6103,7 +6116,7 @@ const parsePPTXJSONData = (json: any, zipMeta?: any) => {
6103
6116
  const lumOffM = inner.match(/<a:lumOff val="(\d+)"/)
6104
6117
  const lumMod = lumModM ? parseInt(lumModM[1], 10) / 100000 : 1
6105
6118
  const lumOff = lumOffM ? parseInt(lumOffM[1], 10) / 100000 : 0
6106
- const slot = val === 'tx1' ? 'dk1' : val === 'bg1' ? 'lt1' : val === 'tx2' ? 'dk2' : val === 'bg2' ? 'lt2' : val
6119
+ const slot = resolveSchemeSlot(val)
6107
6120
  const baseHex = themeColors[slot] || themeColors[val] || (slot === 'dk1' || slot === 'tx1' ? '#000000' : '#FFFFFF')
6108
6121
  col = (lumMod !== 1 || lumOff !== 0) ? applyLumAdjust(baseHex, lumMod, lumOff) : baseHex
6109
6122
  }
@@ -6203,7 +6216,7 @@ const parsePPTXJSONData = (json: any, zipMeta?: any) => {
6203
6216
  }
6204
6217
  const schemeVal = (inner.match(/<a:schemeClr val="(\w+)"/) || [])[1]
6205
6218
  if (schemeVal) {
6206
- const slot = schemeVal === 'tx1' ? 'dk1' : schemeVal === 'bg1' ? 'lt1' : schemeVal === 'tx2' ? 'dk2' : schemeVal === 'bg2' ? 'lt2' : schemeVal
6219
+ const slot = resolveSchemeSlot(schemeVal)
6207
6220
  const hex = themeColors[slot] || themeColors[schemeVal] || ''
6208
6221
  if (hex) return (lumMod !== 1 || lumOff !== 0) ? applyLumAdjust(hex, lumMod, lumOff) : hex
6209
6222
  }
@@ -6212,7 +6225,7 @@ const parsePPTXJSONData = (json: any, zipMeta?: any) => {
6212
6225
  const refScheme = spXml.match(/<a:fillRef[^>]*>\s*<a:schemeClr val="(\w+)"/)
6213
6226
  if (refScheme) {
6214
6227
  const val = refScheme[1]
6215
- const slot = val === 'tx1' ? 'dk1' : val === 'bg1' ? 'lt1' : val === 'tx2' ? 'dk2' : val === 'bg2' ? 'lt2' : val
6228
+ const slot = resolveSchemeSlot(val)
6216
6229
  return themeColors[slot] || themeColors[val] || ''
6217
6230
  }
6218
6231
  return ''
@@ -6840,7 +6853,22 @@ const importPptxArrayBuffer = async (buffer: ArrayBuffer, fileName?: string): Pr
6840
6853
  return n1 - n2
6841
6854
  }
6842
6855
  // 1. 提前解析主题配色 clrScheme(dk1/lt1/dk2/lt2/accent1-6),供母版、版式背景与装饰形状还原真实颜色
6843
- const themeColors: Record<string, string> = {}
6856
+ const themeColors: Record<string, string> = {}
6857
+ const masterClrMap: Record<string, string> = { bg1: 'lt1', tx1: 'dk1', bg2: 'lt2', tx2: 'dk2' }
6858
+ const resolveSchemeSlot = (v: string) => masterClrMap[v] || (v === 'tx1' ? 'dk1' : v === 'bg1' ? 'lt1' : v === 'tx2' ? 'dk2' : v === 'bg2' ? 'lt2' : v)
6859
+ try {
6860
+ const masterXmlKeys = Object.keys(zip.files).filter(k => k.startsWith('ppt/slideMasters/slideMaster') && !k.includes('_rels') && !zip.files[k].dir).sort(sortSlideXml)
6861
+ if (masterXmlKeys.length > 0) {
6862
+ const m0Txt = await zip.file(masterXmlKeys[0])?.async('text') || ''
6863
+ const clrMapM = m0Txt.match(/<p:clrMap\b([^>]*)\/?>/)
6864
+ if (clrMapM) {
6865
+ for (const k of ['bg1', 'tx1', 'bg2', 'tx2', 'accent1', 'accent2', 'accent3', 'accent4', 'accent5', 'accent6', 'hlink', 'folHlink']) {
6866
+ const km = clrMapM[1].match(new RegExp(`\\b${k}="([^"]+)"`))
6867
+ if (km) masterClrMap[k] = km[1]
6868
+ }
6869
+ }
6870
+ }
6871
+ } catch (e) { }
6844
6872
  try {
6845
6873
  const themeFiles = Object.keys(zip.files).filter(k => /^ppt\/theme\/theme\d+\.xml$/.test(k))
6846
6874
  if (themeFiles.length > 0) {
@@ -6908,7 +6936,7 @@ const importPptxArrayBuffer = async (buffer: ArrayBuffer, fileName?: string): Pr
6908
6936
  const lumOffM = inner.match(/<a:lumOff val="(\d+)"/)
6909
6937
  const lumMod = lumModM ? parseInt(lumModM[1], 10) / 100000 : 1
6910
6938
  const lumOff = lumOffM ? parseInt(lumOffM[1], 10) / 100000 : 0
6911
- const slot = val === 'tx1' ? 'dk1' : val === 'bg1' ? 'lt1' : val === 'tx2' ? 'dk2' : val === 'bg2' ? 'lt2' : val
6939
+ const slot = resolveSchemeSlot(val)
6912
6940
  const baseHex = themeColors[slot] || themeColors[val] || (slot === 'dk1' || slot === 'tx1' ? '#000000' : '#FFFFFF')
6913
6941
  col = (lumMod !== 1 || lumOff !== 0) ? applyLumAdjust(baseHex, lumMod, lumOff) : baseHex
6914
6942
  }
@@ -6967,7 +6995,7 @@ const importPptxArrayBuffer = async (buffer: ArrayBuffer, fileName?: string): Pr
6967
6995
  const lumOffM = inner.match(/<a:lumOff val="(\d+)"/)
6968
6996
  const lumMod = lumModM ? parseInt(lumModM[1], 10) / 100000 : 1
6969
6997
  const lumOff = lumOffM ? parseInt(lumOffM[1], 10) / 100000 : 0
6970
- const slot = val === 'tx1' ? 'dk1' : val === 'bg1' ? 'lt1' : val === 'tx2' ? 'dk2' : val === 'bg2' ? 'lt2' : val
6998
+ const slot = resolveSchemeSlot(val)
6971
6999
  const baseHex = themeColors[slot] || themeColors[val] || (slot === 'dk1' || slot === 'tx1' ? '#000000' : '#FFFFFF')
6972
7000
  return (lumMod !== 1 || lumOff !== 0) ? applyLumAdjust(baseHex, lumMod, lumOff) : baseHex
6973
7001
  }
@@ -7155,7 +7183,7 @@ const importPptxArrayBuffer = async (buffer: ArrayBuffer, fileName?: string): Pr
7155
7183
  const lumOffM = m[2].match(/<a:lumOff val="(\d+)"/)
7156
7184
  const lumMod = lumModM ? parseInt(lumModM[1], 10) / 100000 : 1
7157
7185
  const lumOff = lumOffM ? parseInt(lumOffM[1], 10) / 100000 : 0
7158
- const slot = val === 'tx1' ? 'dk1' : val === 'bg1' ? 'lt1' : val === 'tx2' ? 'dk2' : val === 'bg2' ? 'lt2' : val
7186
+ const slot = resolveSchemeSlot(val)
7159
7187
  const baseHex = themeColors[slot] || themeColors[val] || (slot === 'dk1' || slot === 'tx1' ? '#000000' : '#FFFFFF')
7160
7188
  masterTextColor = (lumMod !== 1 || lumOff !== 0) ? applyLumAdjust(baseHex, lumMod, lumOff) : baseHex
7161
7189
  }
@@ -7175,17 +7203,20 @@ const importPptxArrayBuffer = async (buffer: ArrayBuffer, fileName?: string): Pr
7175
7203
  const valM = clean.match(/val="([^"]+)"/)
7176
7204
  if (!valM) continue
7177
7205
  const val = valM[1]
7178
- if (val === 'phClr') continue
7206
+ if (val === 'phClr') continue
7207
+ if (/<a:(?:tint|shade|alpha|satMod|satOff|hueMod|hueOff)\b/.test(clean)) continue
7179
7208
  const lumModM = clean.match(/<a:lumMod val="(\d+)"/)
7180
7209
  const lumOffM = clean.match(/<a:lumOff val="(\d+)"/)
7181
7210
  const lumMod = lumModM ? parseInt(lumModM[1], 10) / 100000 : 1
7182
7211
  const lumOff = lumOffM ? parseInt(lumOffM[1], 10) / 100000 : 0
7183
- const slot = val === 'tx1' ? 'dk1' : val === 'bg1' ? 'lt1' : val === 'tx2' ? 'dk2' : val === 'bg2' ? 'lt2' : val
7212
+ const slot = resolveSchemeSlot(val)
7184
7213
  const baseHex = themeColors[slot] || themeColors[val] || ''
7185
7214
  if (baseHex) {
7186
7215
  const calcHex = (lumMod !== 1 || lumOff !== 0) ? applyLumAdjust(baseHex, lumMod, lumOff) : baseHex
7187
7216
  const cleanHex = calcHex.replace('#', '').toUpperCase()
7188
- schemeFillMap[cleanHex] = clean
7217
+ if (!schemeFillMap[cleanHex] || schemeFillMap[cleanHex].includes('<a:lum')) {
7218
+ schemeFillMap[cleanHex] = clean
7219
+ }
7189
7220
 
7190
7221
  // 处理 RGB 整数四舍五入 ±1 的容差 (如 8496B0 vs 8497B0)
7191
7222
  const r = parseInt(cleanHex.slice(0, 2), 16)
@@ -7348,7 +7379,8 @@ const importPptxArrayBuffer = async (buffer: ArrayBuffer, fileName?: string): Pr
7348
7379
  slideLayoutMap,
7349
7380
  masterName: masterName || nameWithoutExt,
7350
7381
  masterShapesInfo,
7351
- themeColors,
7382
+ themeColors,
7383
+ clrMap: masterClrMap,
7352
7384
  schemeFillMap,
7353
7385
  masterPhXfrm,
7354
7386
  primaryMasterXml,
@@ -7418,8 +7418,18 @@ function convertPPTistToLocalIfNeed(newSlides: any): Slide[] {
7418
7418
 
7419
7419
  const isTopVertical = checkIsVertical(el)
7420
7420
 
7421
+ if (el.placeholderType === 'pic' && (el.outline?.width > 0 || el.borderWidth > 0)) {
7422
+ style.enableBorder = true
7423
+ }
7424
+
7421
7425
  return {
7422
7426
  id: el.id || Math.random().toString(36).substr(2, 9),
7427
+ name: el.name,
7428
+ phType: el.phType,
7429
+ phIdx: el.phIdx,
7430
+ isPlaceholder: el.isPlaceholder,
7431
+ placeholderType: el.placeholderType,
7432
+ placeholder: el.placeholder,
7423
7433
  type: type,
7424
7434
  vertical: isTopVertical,
7425
7435
  isVertical: isTopVertical,
@@ -8115,7 +8125,8 @@ function extractAndApplyThemeFromImportedContent(newSlides: any, parsedSlides: a
8115
8125
  const lumOffM = m[2].match(/<a:lumOff val="(\d+)"/)
8116
8126
  const lumMod = lumModM ? parseInt(lumModM[1], 10) / 100000 : 1
8117
8127
  const lumOff = lumOffM ? parseInt(lumOffM[1], 10) / 100000 : 0
8118
- const slot = val === 'tx1' ? 'dk1' : val === 'bg1' ? 'lt1' : val === 'tx2' ? 'dk2' : val === 'bg2' ? 'lt2' : val
8128
+ const clrMap = newSlides?.zipMeta?.clrMap || {}
8129
+ const slot = clrMap[val] || (val === 'tx1' ? 'dk1' : val === 'bg1' ? 'lt1' : val === 'tx2' ? 'dk2' : val === 'bg2' ? 'lt2' : val)
8119
8130
  const tc = newSlides.zipMeta.themeColors || {}
8120
8131
  const baseHex = tc[slot] || tc[val] || (slot === 'dk1' || slot === 'tx1' ? '#000000' : '#FFFFFF')
8121
8132
  masterTextColor = (lumMod !== 1 || lumOff !== 0) ? applyLumAdjust(baseHex, lumMod, lumOff) : baseHex
@@ -8132,10 +8143,17 @@ function extractAndApplyThemeFromImportedContent(newSlides: any, parsedSlides: a
8132
8143
  ? newSlides.masters[0].fullThemeColors
8133
8144
  : {}
8134
8145
 
8135
- // 1) 页面背景色:优先从 clrScheme.lt1 或最高频背景色提取
8136
- const rawLt1 = clrScheme.lt1 || dominantBgColor || '#FFFFFF'
8137
- const isDarkBg = getHsl(rawLt1).l < 30
8138
- const bgColor = isDarkBg ? (clrScheme.dk1 || '#0F172A') : (clrScheme.lt1 || dominantBgColor || '#FFFFFF')
8146
+ // 1) 页面背景色:优先从实际页面/母版主背景色 (dominantBgColor) 或 clrMap.bg1 提取,准确识别深色背景主题
8147
+ const clrMapBgSlot = newSlides?.zipMeta?.clrMap?.bg1 || 'lt1'
8148
+ const mappedBgColor = clrScheme[clrMapBgSlot] || ''
8149
+ const isDominantBgMajority = maxBgCount >= Math.max(1, Math.ceil((parsedSlides?.length || 1) / 2))
8150
+ const effectiveBgCandidate = (dominantBgColor && dominantBgColor !== '#FFFFFF' && (isDominantBgMajority || !mappedBgColor))
8151
+ ? dominantBgColor
8152
+ : (mappedBgColor || dominantBgColor || clrScheme.lt1 || '#FFFFFF')
8153
+ const isDarkBg = getHsl(effectiveBgCandidate).l < 30
8154
+ const bgColor = isDarkBg
8155
+ ? (effectiveBgCandidate || clrScheme.dk1 || '#0F172A')
8156
+ : (mappedBgColor || clrScheme.lt1 || dominantBgColor || '#FFFFFF')
8139
8157
 
8140
8158
  // 2) 主品牌强调色 (Primary Accent)
8141
8159
  // 核心规范:PPTX 规范欽定 clrScheme.accent1(如粉红 #FDA6D8 或科技蓝 #1381BD)
@@ -434,6 +434,59 @@ function processGroupNodesInSlideXml(
434
434
  return slideXml.replace(/<p:spTree>[\s\S]*?<\/p:spTree>/, `<p:spTree>${newSpTreeContent}</p:spTree>`)
435
435
  }
436
436
 
437
+ function injectPlaceholderAndShapeMetaInSlideXml(slideXml: string, elements: any[]): string {
438
+ if (!elements || !elements.length) return slideXml
439
+ const elById = new Map<string, any>()
440
+ const collectEls = (arr: any[]) => {
441
+ for (const item of arr) {
442
+ if (!item) continue
443
+ if (item.id !== undefined && item.id !== null) elById.set(String(item.id), item)
444
+ if (item.type === 'group' && Array.isArray(item.elements)) collectEls(item.elements)
445
+ }
446
+ }
447
+ collectEls(elements)
448
+ if (!elById.size) return slideXml
449
+
450
+ const escapeXmlAttr = (s: string) => s.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
451
+
452
+ return slideXml.replace(/<p:sp\b[\s\S]*?<\/p:sp>/g, (spXml) => {
453
+ const nameM = spXml.match(/<p:cNvPr\b[^>]*?\bname="([^"]*)"/)
454
+ if (!nameM) return spXml
455
+ const el = elById.get(nameM[1])
456
+ if (!el) return spXml
457
+
458
+ let updatedSp = spXml
459
+ const isImgPh = !el.isPlaceholderReplaced && !el.replaced && (
460
+ el.placeholderType === 'pic' ||
461
+ el.placeholderType === 'image' ||
462
+ el.phType === 'pic' ||
463
+ el.phType === 'picture' ||
464
+ el.phType === 'clipArt' ||
465
+ el.placeholder?.type === 'image' ||
466
+ el.placeholder?.type === 'pic' ||
467
+ (typeof el.name === 'string' && (el.name.includes('Picture Placeholder') || el.name.includes('图片占位符') || el.name.includes('图片框')))
468
+ )
469
+
470
+ if (isImgPh) {
471
+ const phType = (el.phType === 'clipArt' || el.phType === 'media') ? el.phType : 'pic'
472
+ const phIdx = el.phIdx !== undefined ? String(el.phIdx) : '1'
473
+ updatedSp = updatedSp.replace(/<p:nvPr\s*\/>|<p:nvPr>[\s\S]*?<\/p:nvPr>/, `<p:nvPr><p:ph idx="${escapeXmlAttr(phIdx)}" type="${escapeXmlAttr(phType)}"/></p:nvPr>`)
474
+ const restoredName = (typeof el.name === 'string' && el.name.trim()) ? el.name.trim() : `Picture Placeholder ${phIdx}`
475
+ updatedSp = updatedSp.replace(/(<p:cNvPr\b[^>]*?\bname=")[^"]*(")/, `$1${escapeXmlAttr(restoredName)}$2`)
476
+ }
477
+
478
+ if (el.type === 'shape' && Array.isArray(el.keypoints) && typeof el.keypoints[0] === 'number') {
479
+ const adjVal = Math.round(Math.max(0, Math.min(0.5, el.keypoints[0])) * 100000)
480
+ updatedSp = updatedSp.replace(
481
+ /(<a:prstGeom\s+prst="(?:roundRect|snip1Rect|round1Rect)">)<a:avLst\s*(?:\/>|><\/a:avLst>)(<\/a:prstGeom>)/,
482
+ `$1<a:avLst><a:gd name="adj" fmla="val ${adjVal}"/></a:avLst>$2`
483
+ )
484
+ }
485
+
486
+ return updatedSp
487
+ })
488
+ }
489
+
437
490
  export interface ThemeInjectionOptions {
438
491
  schemeFillMap?: Record<string, string>
439
492
  fullThemeColors?: Record<string, string>
@@ -707,7 +760,12 @@ export async function injectAnimationToPptxBlob(
707
760
  slideXml = processGroupNodesInSlideXml(slideXml, slide.elements || [], logicalWidth, logicalHeight)
708
761
 
709
762
  // 2. 映射原生方案色 schemeClr
710
- slideXml = applyThemeMappingToXml(slideXml)
763
+ // 2. 映射原生方案色 schemeClr(保护非纯白自定义幻灯片背景 <p:bg> 不被误替换)
764
+ const savedSlideBg = !isWhiteBg ? (slideXml.match(/<p:bg>[\s\S]*?<\/p:bg>/) || [])[0] : ''
765
+ slideXml = applyThemeMappingToXml(slideXml)
766
+ if (savedSlideBg) {
767
+ slideXml = slideXml.replace(/<p:bg>[\s\S]*?<\/p:bg>/, savedSlideBg)
768
+ }
711
769
 
712
770
  // 3. 注入动画 XML
713
771
  if (slide.animations && slide.animations.length) {
@@ -736,6 +794,7 @@ export async function injectAnimationToPptxBlob(
736
794
  }
737
795
  }
738
796
 
797
+ slideXml = injectPlaceholderAndShapeMetaInSlideXml(slideXml, slide.elements || [])
739
798
  loadedZip.file(slidePath, slideXml)
740
799
  }
741
800