jvs-ppt-ui 0.0.27 → 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/dist/lib/jvs-ppt-ui.es.js +29063 -28441
- package/dist/lib/jvs-ppt-ui.umd.js +80 -80
- package/dist/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/components/Header.vue +48 -16
- package/src/components/material/CreateMaterialPanel.vue +835 -27
- package/src/composables/useSlides.ts +23 -5
- package/src/utils/pptxAnimationInjector.ts +60 -1
|
@@ -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
|
|
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)
|
|
8136
|
-
const
|
|
8137
|
-
const
|
|
8138
|
-
const
|
|
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, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>')
|
|
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
|
-
|
|
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
|
|