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
package/package.json
CHANGED
|
@@ -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
|
|
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(/ /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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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]
|
|
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,
|