jvs-ppt-ui 0.0.28 → 0.0.30
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 +29823 -29669
- package/dist/lib/jvs-ppt-ui.umd.js +94 -94
- package/dist/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/components/AIPptDialog.vue +1 -1
- package/src/components/DslInputDialog.vue +1 -1
- package/src/components/FormulaDialog.vue +1 -1
- package/src/components/Header.vue +48 -16
- package/src/components/SidebarLeft.vue +1 -0
- package/src/components/StyleBuilderDialog.vue +9 -8
- package/src/components/sidebar/panels/SidebarDesignPanel.vue +1 -1
- package/src/composables/sidebar/useSidebarDesign.ts +2 -0
- package/src/composables/useSlides.ts +93 -21
- package/src/utils/pptxAnimationInjector.ts +60 -1
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@ interface PptApprovalPayload {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// 当打开弹窗时初始化表单
|
|
41
|
-
watch(() => props.visible, (newVal) => {
|
|
41
|
+
const watchVisibleImmediate = (cb: (newVal: boolean) => void) => { watch(() => props.visible, cb); queueMicrotask(() => { if (props.visible) cb(true) }) }; watchVisibleImmediate((newVal) => {
|
|
42
42
|
if (newVal) {
|
|
43
43
|
prompt.value = '2026年企业级大模型落地与数字化转型白皮书'
|
|
44
44
|
selectedTheme.value = '雅致青绿'
|
|
@@ -17,7 +17,7 @@ const dslText = ref('')
|
|
|
17
17
|
const jsonError = ref('')
|
|
18
18
|
const textareaRef = ref<HTMLTextAreaElement | null>(null)
|
|
19
19
|
|
|
20
|
-
watch(() => props.visible, (newVal) => {
|
|
20
|
+
const watchVisibleImmediate = (cb: (newVal: boolean) => void) => { watch(() => props.visible, cb); queueMicrotask(() => { if (props.visible) cb(true) }) }; watchVisibleImmediate((newVal) => {
|
|
21
21
|
if (newVal) {
|
|
22
22
|
jsonError.value = ''
|
|
23
23
|
nextTick(() => {
|
|
@@ -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,
|
|
@@ -686,6 +686,7 @@ const addSlideWithLayout = (layoutId: string) => {
|
|
|
686
686
|
newSlide.masterId = activeMasterId.value || 'master-default'
|
|
687
687
|
newSlide.layoutId = masterLayout.id
|
|
688
688
|
newSlide.showMasterElements = true
|
|
689
|
+
const parentMaster = (slideMasters.value || []).find((m: any) => (m.layouts || []).some((l: any) => l.id === masterLayout.id)) || slideMasters.value?.[0]; if ((parentMaster as any)?.themeId) { newSlide.themeId = (parentMaster as any).themeId; newSlide.themeName = (parentMaster as any).themeName }
|
|
689
690
|
if (masterLayout.background) {
|
|
690
691
|
newSlide.background = masterLayout.background
|
|
691
692
|
}
|
|
@@ -58,7 +58,7 @@ function selectThemePreset(preset: StyleRecipe) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
watch(() => props.visible, (newVal) => {
|
|
61
|
+
const watchVisibleImmediate = (cb: (newVal: boolean) => void) => { watch([() => props.visible, () => props.initialRecipeId, () => props.targetMode], ([v]) => cb(v)); queueMicrotask(() => { if (props.visible) cb(true) }) }; watchVisibleImmediate((newVal) => {
|
|
62
62
|
if (newVal) {
|
|
63
63
|
applyScope.value = props.targetMode || 'all'
|
|
64
64
|
Object.keys(draftCacheMap).forEach(key => delete draftCacheMap[key])
|
|
@@ -625,7 +625,7 @@ function handlePickerChange(val: any) {
|
|
|
625
625
|
</div>
|
|
626
626
|
<div class="header-theme-usage-info">
|
|
627
627
|
正在编辑:<strong style="color: #0f172a;">{{ localRecipe.name }}</strong>
|
|
628
|
-
<span class="header-usage-pill" :class="getThemeUsageLabel(localRecipe.id).type">
|
|
628
|
+
<span class="header-usage-pill" :class="getThemeUsageLabel(localRecipe.id).type" :title="getThemeUsageLabel(localRecipe.id).fullText || getThemeUsageLabel(localRecipe.id).text" style="white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis;">
|
|
629
629
|
{{ getThemeUsageLabel(localRecipe.id).text }}
|
|
630
630
|
</span>
|
|
631
631
|
</div>
|
|
@@ -995,11 +995,11 @@ function handlePickerChange(val: any) {
|
|
|
995
995
|
<div class="config-sidebar">
|
|
996
996
|
<div class="sidebar-header">
|
|
997
997
|
<div>
|
|
998
|
-
<h3>{{ localRecipe.name || '主题配置' }}</h3>
|
|
999
|
-
<div style="font-size: 11px; color: #64748b; margin-top: 2px;">编辑全局或单页样式配方</div>
|
|
998
|
+
<h3 style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">{{ localRecipe.name || '主题配置' }}</h3>
|
|
999
|
+
<div style="font-size: 11px; color: #64748b; margin-top: 2px; white-space: nowrap;">编辑全局或单页样式配方</div>
|
|
1000
1000
|
</div>
|
|
1001
|
-
<div class="theme-usage-badge-container">
|
|
1002
|
-
<span class="theme-usage-badge" :class="getThemeUsageLabel(localRecipe.id).type">
|
|
1001
|
+
<div class="theme-usage-badge-container" style="flex-shrink: 0; margin-left: 10px;">
|
|
1002
|
+
<span class="theme-usage-badge" :class="getThemeUsageLabel(localRecipe.id).type" :title="getThemeUsageLabel(localRecipe.id).fullText || getThemeUsageLabel(localRecipe.id).text" style="white-space: nowrap; max-width: 145px; overflow: hidden; text-overflow: ellipsis;">
|
|
1003
1003
|
{{ getThemeUsageLabel(localRecipe.id).text }}
|
|
1004
1004
|
</span>
|
|
1005
1005
|
</div>
|
|
@@ -1577,8 +1577,8 @@ function handlePickerChange(val: any) {
|
|
|
1577
1577
|
<!-- Usage Pill Badge -->
|
|
1578
1578
|
<div class="usage-pill" :class="getThemeUsageLabel(themeItem.id).type">
|
|
1579
1579
|
{{ getThemeUsageSlides(themeItem.id).length === slides.length && slides.length > 0 ? '全部' :
|
|
1580
|
-
(getThemeUsageSlides(themeItem.id).length > 0 ? `P${getThemeUsageSlides(themeItem.id).join(',')}` :
|
|
1581
|
-
'未用') }}
|
|
1580
|
+
(getThemeUsageSlides(themeItem.id).length > 2 ? `${getThemeUsageSlides(themeItem.id).length}页` : (getThemeUsageSlides(themeItem.id).length > 0 ? `P${getThemeUsageSlides(themeItem.id).join(',')}` :
|
|
1581
|
+
'未用')) }}
|
|
1582
1582
|
</div>
|
|
1583
1583
|
</div>
|
|
1584
1584
|
</el-tooltip>
|
|
@@ -1938,6 +1938,7 @@ function handlePickerChange(val: any) {
|
|
|
1938
1938
|
margin-bottom: 20px;
|
|
1939
1939
|
}
|
|
1940
1940
|
|
|
1941
|
+
.sidebar-header > div:first-child { min-width: 0; flex: 1; }
|
|
1941
1942
|
.sidebar-header h3 {
|
|
1942
1943
|
margin: 0;
|
|
1943
1944
|
font-size: 16px;
|
|
@@ -24,7 +24,7 @@ const props = defineProps<{
|
|
|
24
24
|
|
|
25
25
|
// 样式构建器挂载闩锁:首次打开后保持挂载,异步 chunk 只加载一次
|
|
26
26
|
const styleBuilderMounted = ref(false)
|
|
27
|
-
watch(() => props.styleBuilderVisible, v => { if (v) styleBuilderMounted.value = true })
|
|
27
|
+
watch(() => props.styleBuilderVisible, v => { if (v) styleBuilderMounted.value = true }, { immediate: true })
|
|
28
28
|
|
|
29
29
|
const emit = defineEmits<{
|
|
30
30
|
(e: 'update:designActiveTab', val: string): void
|
|
@@ -170,6 +170,8 @@ export function useSidebarDesign() {
|
|
|
170
170
|
|
|
171
171
|
slide.masterId = parentMaster?.id || slide.masterId || 'master-default'
|
|
172
172
|
slide.layoutId = masterLayout.id
|
|
173
|
+
if (masterLayout.background && (!slide.bgType || slide.bgType === 'color')) slide.background = masterLayout.background
|
|
174
|
+
if ((parentMaster as any)?.themeId && !slide.themeId) { slide.themeId = (parentMaster as any).themeId; slide.themeName = (parentMaster as any).themeName }
|
|
173
175
|
slide.showMasterElements = true
|
|
174
176
|
slide.elements = [...nonLayoutElements, ...newElements]
|
|
175
177
|
addHistorySnapshot()
|
|
@@ -1858,10 +1858,17 @@ export function getEffectiveSlideBackground(slide?: any): any {
|
|
|
1858
1858
|
}
|
|
1859
1859
|
}
|
|
1860
1860
|
|
|
1861
|
-
// 3.
|
|
1861
|
+
// 3. 向上继承匹配版式或母版的背景(非外部导入母版时,幻灯片自身的纯白背景即为该页独立背景,不随母版主题色变更被覆盖)
|
|
1862
1862
|
const { masterId, layoutId } = resolveSlideMasterAndLayout(slide)
|
|
1863
1863
|
const master = slideMasters.value.find(m => m && m.id === masterId) || slideMasters.value[0]
|
|
1864
1864
|
const layout = layoutId && master ? master.layouts?.find(l => l && l.id === layoutId) : null
|
|
1865
|
+
const isImportedMaster = Boolean((master as any)?.isImported)
|
|
1866
|
+
const masterThemeId = (master as any)?.themeId || (!isImportedMaster ? 'tech-blue' : '')
|
|
1867
|
+
if (directBg && typeof directBg === 'string' && !['transparent', 'none', ''].includes(directBg.trim().toLowerCase())) {
|
|
1868
|
+
if (!isImportedMaster || (slide.themeId && masterThemeId && slide.themeId !== masterThemeId)) {
|
|
1869
|
+
return formatBareUrlWithMode(directBg, slide.bgImageMode, slide.isPattern)
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1865
1872
|
|
|
1866
1873
|
if (layout?.background && layout.background !== '#ffffff' && layout.background !== 'none') {
|
|
1867
1874
|
return formatBareUrlWithMode(layout.background, (layout as any).bgImageMode, (layout as any).isPattern)
|
|
@@ -1876,7 +1883,8 @@ export function getEffectiveSlideBackground(slide?: any): any {
|
|
|
1876
1883
|
function applyStyleRecipeToMaster(
|
|
1877
1884
|
recipe: StyleRecipe,
|
|
1878
1885
|
mode: boolean | 'all' | 'single' = 'single',
|
|
1879
|
-
masterId?: string
|
|
1886
|
+
masterId?: string,
|
|
1887
|
+
silent = false
|
|
1880
1888
|
) {
|
|
1881
1889
|
const isAll = mode === true || mode === 'all'
|
|
1882
1890
|
const targetMasters = isAll
|
|
@@ -1930,12 +1938,14 @@ function applyStyleRecipeToMaster(
|
|
|
1930
1938
|
}
|
|
1931
1939
|
|
|
1932
1940
|
// 同 tick 多母版变更 + 急切快照:pre-flush watcher 尚未排空,显式标脏目标母版
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1941
|
+
if (!silent) {
|
|
1942
|
+
targetMasters.forEach(m => {
|
|
1943
|
+
const i = slideMasters.value.indexOf(m)
|
|
1944
|
+
if (i >= 0) dirtyMasterIndexes.add(i)
|
|
1945
|
+
})
|
|
1946
|
+
addMasterHistorySnapshot()
|
|
1947
|
+
notify(isAll ? `已应用主题「${recipe.name}」到全部母版` : `已应用主题「${recipe.name}」到当前母版`)
|
|
1948
|
+
}
|
|
1939
1949
|
}
|
|
1940
1950
|
|
|
1941
1951
|
function applyStyleRecipeToSlides(
|
|
@@ -1992,12 +2002,22 @@ function applyStyleRecipeToSlides(
|
|
|
1992
2002
|
}
|
|
1993
2003
|
})
|
|
1994
2004
|
|
|
1995
|
-
// 🌟
|
|
2005
|
+
// 🌟 单页应用时,先锁定其余已存在幻灯片自身的主题标识与背景,再同步关联母版与版式以当前选中主题渲染
|
|
1996
2006
|
if (effectiveMode === 'single' && targetSlides[0]) {
|
|
1997
2007
|
const curSlide = targetSlides[0]
|
|
1998
2008
|
const resolved = resolveSlideMasterAndLayout(curSlide)
|
|
2009
|
+
const curMaster = slideMasters.value.find(m => m.id === resolved.masterId) || slideMasters.value[0]
|
|
2010
|
+
const prevMasterThemeId = (curMaster as any)?.themeId || 'tech-blue'
|
|
2011
|
+
slides.value.forEach(s => {
|
|
2012
|
+
if (s !== curSlide) {
|
|
2013
|
+
if (!s.themeId) s.themeId = prevMasterThemeId
|
|
2014
|
+
if ((curMaster as any)?.isImported && (!s.background || s.background === '#ffffff')) {
|
|
2015
|
+
s.background = getEffectiveSlideBackground(s) || '#ffffff'
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
})
|
|
1999
2019
|
if (resolved.masterId) {
|
|
2000
|
-
applyStyleRecipeToMaster(recipe, 'single', resolved.masterId)
|
|
2020
|
+
applyStyleRecipeToMaster(recipe, 'single', resolved.masterId, true)
|
|
2001
2021
|
}
|
|
2002
2022
|
}
|
|
2003
2023
|
|
|
@@ -2051,7 +2071,7 @@ function applyStyleRecipeToSlides(
|
|
|
2051
2071
|
if (effectiveMode === 'all') {
|
|
2052
2072
|
notify(`已应用主题「${recipe.name}」到全部幻灯片与母版`)
|
|
2053
2073
|
} else if (effectiveMode === 'single') {
|
|
2054
|
-
notify(`已应用主题「${recipe.name}」到第 ${activeIndex.value + 1}
|
|
2074
|
+
notify(`已应用主题「${recipe.name}」到第 ${activeIndex.value + 1} 页`)
|
|
2055
2075
|
} else if (effectiveMode === 'used') {
|
|
2056
2076
|
notify(`已保存主题「${recipe.name}」并同步更新使用该主题的 ${targetSlides.length} 页幻灯片`)
|
|
2057
2077
|
}
|
|
@@ -2117,7 +2137,7 @@ function getEffectiveMasterElementsForSlide(slide: any, recolorWithTheme: boolea
|
|
|
2117
2137
|
// 🌟 核心判断:只有当前幻灯片显式指定了与母版不同的主题时,才需要进行母版元素主题重映射!
|
|
2118
2138
|
// 若幻灯片与母版同属一个主题(例如刚导入 PPT),母版本身的颜色就是最权威的原始效果,直接返回 combined
|
|
2119
2139
|
const slideThemeId = slide.themeId
|
|
2120
|
-
const masterThemeId = (master as any)?.themeId
|
|
2140
|
+
const masterThemeId = (master as any)?.themeId || (!(master as any)?.isImported ? 'tech-blue' : '')
|
|
2121
2141
|
const needRecolor = recolorWithTheme && slideThemeId && masterThemeId && slideThemeId !== masterThemeId
|
|
2122
2142
|
|
|
2123
2143
|
if (needRecolor) {
|
|
@@ -2230,16 +2250,39 @@ function getThemeUsageSlides(themeId: string): number[] {
|
|
|
2230
2250
|
return pages
|
|
2231
2251
|
}
|
|
2232
2252
|
|
|
2233
|
-
function
|
|
2253
|
+
function formatPageRanges(pages: number[]): string[] {
|
|
2254
|
+
const ranges: string[] = []
|
|
2255
|
+
let i = 0
|
|
2256
|
+
while (i < pages.length) {
|
|
2257
|
+
const start = pages[i]
|
|
2258
|
+
let end = start
|
|
2259
|
+
while (i + 1 < pages.length && pages[i + 1] === end + 1) {
|
|
2260
|
+
i++
|
|
2261
|
+
end = pages[i]
|
|
2262
|
+
}
|
|
2263
|
+
ranges.push(start === end ? `${start}` : (end === start + 1 ? `${start}, ${end}` : `${start}-${end}`))
|
|
2264
|
+
i++
|
|
2265
|
+
}
|
|
2266
|
+
return ranges
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
function getThemeUsageLabel(themeId: string): { type: 'all' | 'partial' | 'none'; text: string; fullText: string; pages: number[] } {
|
|
2234
2270
|
const pages = getThemeUsageSlides(themeId)
|
|
2235
2271
|
const total = slides.value ? slides.value.length : 0
|
|
2236
2272
|
if (total > 0 && pages.length === total) {
|
|
2237
|
-
|
|
2273
|
+
const text = `全部页面 (共 ${total} 页)`
|
|
2274
|
+
return { type: 'all', text, fullText: text, pages }
|
|
2238
2275
|
}
|
|
2239
2276
|
if (pages.length > 0) {
|
|
2240
|
-
|
|
2277
|
+
const ranges = formatPageRanges(pages)
|
|
2278
|
+
const fullRangeStr = ranges.join(', ')
|
|
2279
|
+
const fullText = `第 ${pages.join(', ')} 页 (共 ${pages.length} 页)`
|
|
2280
|
+
const text = (ranges.length <= 2 && fullRangeStr.length <= 12)
|
|
2281
|
+
? `第 ${fullRangeStr} 页`
|
|
2282
|
+
: `第 ${ranges.slice(0, 2).join(', ')} 等 ${pages.length} 页`
|
|
2283
|
+
return { type: 'partial', text, fullText, pages }
|
|
2241
2284
|
}
|
|
2242
|
-
return { type: 'none', text: '未被使用', pages: [] }
|
|
2285
|
+
return { type: 'none', text: '未被使用', fullText: '未被使用', pages: [] }
|
|
2243
2286
|
}
|
|
2244
2287
|
|
|
2245
2288
|
function getActiveSlideThemeRecipe(targetSlide?: any): StyleRecipe {
|
|
@@ -2330,6 +2373,17 @@ watch(activeIndex, (newIdx) => {
|
|
|
2330
2373
|
if (!selectedSlideIndexes.value.includes(newIdx)) {
|
|
2331
2374
|
selectedSlideIndexes.value = [newIdx]
|
|
2332
2375
|
}
|
|
2376
|
+
const curSlide = slides.value[newIdx]
|
|
2377
|
+
if (curSlide?.themeId && !isMasterEditingView.value) {
|
|
2378
|
+
const resolved = resolveSlideMasterAndLayout(curSlide)
|
|
2379
|
+
const master = slideMasters.value.find(m => m.id === resolved.masterId) || slideMasters.value[0]
|
|
2380
|
+
if (master && !(master as any).isImported && (master as any).themeId !== curSlide.themeId) {
|
|
2381
|
+
const targetRecipe = getActiveSlideThemeRecipe(curSlide)
|
|
2382
|
+
if (targetRecipe) {
|
|
2383
|
+
applyStyleRecipeToMaster(targetRecipe, 'single', master.id, true)
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2333
2387
|
})
|
|
2334
2388
|
|
|
2335
2389
|
const activeSlide = computed<Slide>({
|
|
@@ -7418,8 +7472,18 @@ function convertPPTistToLocalIfNeed(newSlides: any): Slide[] {
|
|
|
7418
7472
|
|
|
7419
7473
|
const isTopVertical = checkIsVertical(el)
|
|
7420
7474
|
|
|
7475
|
+
if (el.placeholderType === 'pic' && (el.outline?.width > 0 || el.borderWidth > 0)) {
|
|
7476
|
+
style.enableBorder = true
|
|
7477
|
+
}
|
|
7478
|
+
|
|
7421
7479
|
return {
|
|
7422
7480
|
id: el.id || Math.random().toString(36).substr(2, 9),
|
|
7481
|
+
name: el.name,
|
|
7482
|
+
phType: el.phType,
|
|
7483
|
+
phIdx: el.phIdx,
|
|
7484
|
+
isPlaceholder: el.isPlaceholder,
|
|
7485
|
+
placeholderType: el.placeholderType,
|
|
7486
|
+
placeholder: el.placeholder,
|
|
7423
7487
|
type: type,
|
|
7424
7488
|
vertical: isTopVertical,
|
|
7425
7489
|
isVertical: isTopVertical,
|
|
@@ -8115,7 +8179,8 @@ function extractAndApplyThemeFromImportedContent(newSlides: any, parsedSlides: a
|
|
|
8115
8179
|
const lumOffM = m[2].match(/<a:lumOff val="(\d+)"/)
|
|
8116
8180
|
const lumMod = lumModM ? parseInt(lumModM[1], 10) / 100000 : 1
|
|
8117
8181
|
const lumOff = lumOffM ? parseInt(lumOffM[1], 10) / 100000 : 0
|
|
8118
|
-
const
|
|
8182
|
+
const clrMap = newSlides?.zipMeta?.clrMap || {}
|
|
8183
|
+
const slot = clrMap[val] || (val === 'tx1' ? 'dk1' : val === 'bg1' ? 'lt1' : val === 'tx2' ? 'dk2' : val === 'bg2' ? 'lt2' : val)
|
|
8119
8184
|
const tc = newSlides.zipMeta.themeColors || {}
|
|
8120
8185
|
const baseHex = tc[slot] || tc[val] || (slot === 'dk1' || slot === 'tx1' ? '#000000' : '#FFFFFF')
|
|
8121
8186
|
masterTextColor = (lumMod !== 1 || lumOff !== 0) ? applyLumAdjust(baseHex, lumMod, lumOff) : baseHex
|
|
@@ -8132,10 +8197,17 @@ function extractAndApplyThemeFromImportedContent(newSlides: any, parsedSlides: a
|
|
|
8132
8197
|
? newSlides.masters[0].fullThemeColors
|
|
8133
8198
|
: {}
|
|
8134
8199
|
|
|
8135
|
-
// 1)
|
|
8136
|
-
const
|
|
8137
|
-
const
|
|
8138
|
-
const
|
|
8200
|
+
// 1) 页面背景色:优先从实际页面/母版主背景色 (dominantBgColor) 或 clrMap.bg1 提取,准确识别深色背景主题
|
|
8201
|
+
const clrMapBgSlot = newSlides?.zipMeta?.clrMap?.bg1 || 'lt1'
|
|
8202
|
+
const mappedBgColor = clrScheme[clrMapBgSlot] || ''
|
|
8203
|
+
const isDominantBgMajority = maxBgCount >= Math.max(1, Math.ceil((parsedSlides?.length || 1) / 2))
|
|
8204
|
+
const effectiveBgCandidate = (dominantBgColor && dominantBgColor !== '#FFFFFF' && (isDominantBgMajority || !mappedBgColor))
|
|
8205
|
+
? dominantBgColor
|
|
8206
|
+
: (mappedBgColor || dominantBgColor || clrScheme.lt1 || '#FFFFFF')
|
|
8207
|
+
const isDarkBg = getHsl(effectiveBgCandidate).l < 30
|
|
8208
|
+
const bgColor = isDarkBg
|
|
8209
|
+
? (effectiveBgCandidate || clrScheme.dk1 || '#0F172A')
|
|
8210
|
+
: (mappedBgColor || clrScheme.lt1 || dominantBgColor || '#FFFFFF')
|
|
8139
8211
|
|
|
8140
8212
|
// 2) 主品牌强调色 (Primary Accent)
|
|
8141
8213
|
// 核心规范: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
|
|