jvs-ppt-ui 0.0.36 → 0.0.38
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/iconfont/iconfont.css +7 -3
- package/dist/lib/jvs-ppt-ui/iconfont/iconfont.js +1 -1
- package/dist/lib/jvs-ppt-ui/iconfont/iconfont.json +7 -0
- package/dist/lib/jvs-ppt-ui/iconfont/iconfont.ttf +0 -0
- package/dist/lib/jvs-ppt-ui/iconfont/iconfont.woff +0 -0
- package/dist/lib/jvs-ppt-ui/iconfont/iconfont.woff2 +0 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_01de32e3d01df54a.svg +9 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_12935f21f0b1ae78.png +0 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_201146e666f28fff.png +0 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_32ef4f2c1d76ea32.svg +15 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_571054b13f220252.svg +10 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_5b14f99769a8894c.svg +10 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_62fc021bdae89b21.png +0 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_649d2b36f7fc251e.png +0 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_7e57de8ea8d46aba.png +0 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_9ad1284e63535689.svg +15 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_9ff268d3709d6454.png +0 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_b8f80ac591d69945.png +0 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_dce239981c2cd1aa.svg +15 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_e2ea31ca7735e5c0.png +0 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_e585ddb9ec5c408e.png +0 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_f3335fad3673d648.svg +10 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_fb925327432cc7e7.svg +15 -0
- package/dist/lib/jvs-ppt-ui/layout-library/layout-library.json +1 -0
- package/dist/lib/jvs-ppt-ui.es.js +80182 -21671
- package/dist/lib/jvs-ppt-ui.umd.js +112 -112
- package/dist/lib/style.css +1 -1
- package/package.json +1 -1
- package/scripts/patch-pptxtojson.cjs +33 -0
- package/src/assets/chart/baseArea.png +0 -0
- package/src/assets/chart/baseBar.png +0 -0
- package/src/assets/chart/baseHistogram.png +0 -0
- package/src/assets/chart/basePie.png +0 -0
- package/src/assets/chart/bubbleChart.png +0 -0
- package/src/assets/chart/circyChart.png +0 -0
- package/src/assets/chart/compPolyline.png +0 -0
- package/src/assets/chart/lineChart.png +0 -0
- package/src/assets/chart/otherLine.png +0 -0
- package/src/assets/chart/otherLineChart.png +0 -0
- package/src/assets/chart/perHistogram.png +0 -0
- package/src/assets/chart/radarChart.png +0 -0
- package/src/assets/chart/roseChart.png +0 -0
- package/src/assets/chart/roseCircyChart.png +0 -0
- package/src/assets/chart/stackArea.png +0 -0
- package/src/assets/chart/stackBar.png +0 -0
- package/src/assets/chart/stackHistogram.png +0 -0
- package/src/assets/iconfont/iconfont.js +1 -1
- package/src/components/CanvasArea.vue +53 -14
- package/src/components/ChartTypeSelector.vue +15 -67
- package/src/components/Header.vue +10 -7
- package/src/components/SidebarLeft.vue +411 -35
- package/src/components/sidebar/common/SidebarPositionGroup.vue +199 -33
- package/src/components/sidebar/panels/LayoutThumbSvg.vue +82 -14
- package/src/components/sidebar/panels/SidebarImageFormatPanel.vue +37 -33
- package/src/composables/canvas/useCanvasCrop.ts +25 -2
- package/src/composables/sidebar/useSidebarElementTransform.ts +13 -7
- package/src/composables/useSlides.ts +141 -3
- package/src/configs/layoutLibrary.ts +113 -0
- package/src/style.css +107 -17
- package/src/utils/pptxAnimationInjector.ts +36 -4
- package/src/assets/chart/baseMap.png +0 -0
- package/src/assets/chart/boxplot.png +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Ref } from 'vue'
|
|
1
|
+
import { ref, type Ref } from 'vue'
|
|
2
2
|
|
|
3
3
|
export interface CropOptions {
|
|
4
4
|
zoomRatio: Ref<number>
|
|
@@ -6,6 +6,7 @@ export interface CropOptions {
|
|
|
6
6
|
getElementPixels: (el: any) => { left: number; top: number; width: number; height: number; rotate: number }
|
|
7
7
|
findParentGroup: (id: any) => any
|
|
8
8
|
addHistorySnapshot: () => void
|
|
9
|
+
onCropStop?: () => void
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export function useCanvasCrop(options: CropOptions) {
|
|
@@ -14,9 +15,11 @@ export function useCanvasCrop(options: CropOptions) {
|
|
|
14
15
|
pauseHistory,
|
|
15
16
|
getElementPixels,
|
|
16
17
|
findParentGroup,
|
|
17
|
-
addHistorySnapshot
|
|
18
|
+
addHistorySnapshot,
|
|
19
|
+
onCropStop
|
|
18
20
|
} = options
|
|
19
21
|
|
|
22
|
+
const isCropping = ref(false)
|
|
20
23
|
let isCroppingDrag = false
|
|
21
24
|
let cropHandle = ''
|
|
22
25
|
let cropStartX = 0
|
|
@@ -121,11 +124,29 @@ export function useCanvasCrop(options: CropOptions) {
|
|
|
121
124
|
cancelAnimationFrame(cropAnimationFrameId)
|
|
122
125
|
cropAnimationFrameId = null
|
|
123
126
|
}
|
|
127
|
+
if (lastCropEvent && isCroppingDrag && cropCurrentEl) {
|
|
128
|
+
updateCropDimensions(lastCropEvent)
|
|
129
|
+
lastCropEvent = null
|
|
130
|
+
}
|
|
124
131
|
window.removeEventListener('mousemove', handleCropDrag)
|
|
125
132
|
window.removeEventListener('mouseup', stopCropDrag)
|
|
126
133
|
isCroppingDrag = false
|
|
134
|
+
isCropping.value = false
|
|
127
135
|
cropCurrentEl = null
|
|
128
136
|
pauseHistory.value = false
|
|
137
|
+
if (onCropStop) onCropStop()
|
|
138
|
+
|
|
139
|
+
// 拦截因拖拽手柄移出图片范围后 mouseup 与 mousedown 节点不一致而由浏览器合成在父容器上的 click 事件,防止误触发 handleDeselect 退出裁剪模式
|
|
140
|
+
const suppressSyntheticClick = (ev: MouseEvent) => {
|
|
141
|
+
ev.stopPropagation()
|
|
142
|
+
ev.preventDefault()
|
|
143
|
+
window.removeEventListener('click', suppressSyntheticClick, true)
|
|
144
|
+
}
|
|
145
|
+
window.addEventListener('click', suppressSyntheticClick, true)
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
window.removeEventListener('click', suppressSyntheticClick, true)
|
|
148
|
+
}, 50)
|
|
149
|
+
|
|
129
150
|
addHistorySnapshot()
|
|
130
151
|
}
|
|
131
152
|
|
|
@@ -136,6 +157,7 @@ export function useCanvasCrop(options: CropOptions) {
|
|
|
136
157
|
|
|
137
158
|
pauseHistory.value = true
|
|
138
159
|
isCroppingDrag = true
|
|
160
|
+
isCropping.value = true
|
|
139
161
|
cropHandle = handle
|
|
140
162
|
cropCurrentEl = el
|
|
141
163
|
|
|
@@ -165,6 +187,7 @@ export function useCanvasCrop(options: CropOptions) {
|
|
|
165
187
|
}
|
|
166
188
|
|
|
167
189
|
return {
|
|
190
|
+
isCropping,
|
|
168
191
|
startInteractiveCrop,
|
|
169
192
|
handleCropDrag,
|
|
170
193
|
stopCropDrag,
|
|
@@ -132,7 +132,7 @@ export function useSidebarElementTransform(
|
|
|
132
132
|
return { width: logicalWidth.value, height: logicalHeight.value }
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
const { isCanvasDragging, activeSlideVersion } = useSlides()
|
|
135
|
+
const { isCanvasDragging, activeSlideVersion, selectedElementWidth, selectedElementHeight } = useSlides()
|
|
136
136
|
let cachedX = 0
|
|
137
137
|
let cachedY = 0
|
|
138
138
|
|
|
@@ -272,8 +272,9 @@ export function useSidebarElementTransform(
|
|
|
272
272
|
}
|
|
273
273
|
return parseFloat(parseFloat(wStr).toFixed(1)) || (selectedElement.value.width || 0)
|
|
274
274
|
},
|
|
275
|
-
set(
|
|
275
|
+
set(rawVal: number) {
|
|
276
276
|
if (!selectedElement.value) return
|
|
277
|
+
const val = Math.max(10, Number(rawVal) || 10)
|
|
277
278
|
if (selectedElementIds.value.length > 1 && activeSlide.value) {
|
|
278
279
|
activeSlide.value.elements.forEach((el: any) => {
|
|
279
280
|
if (selectedElementIds.value.includes(el.id)) {
|
|
@@ -302,7 +303,7 @@ export function useSidebarElementTransform(
|
|
|
302
303
|
elOldH = parseFloat(hStr) || 0
|
|
303
304
|
}
|
|
304
305
|
const ratio = elOldH / elOldW
|
|
305
|
-
const newH = parseFloat((val * ratio).toFixed(1))
|
|
306
|
+
const newH = Math.max(10, parseFloat((val * ratio).toFixed(1)))
|
|
306
307
|
if (hStr.endsWith('%')) {
|
|
307
308
|
el.style.height = `${((newH / refDims.height) * 100).toFixed(4)}%`
|
|
308
309
|
} else {
|
|
@@ -337,10 +338,11 @@ export function useSidebarElementTransform(
|
|
|
337
338
|
el.style.width = `${val}px`
|
|
338
339
|
}
|
|
339
340
|
el.width = val
|
|
341
|
+
if (selectedElementWidth) selectedElementWidth.value = `${val}px`
|
|
340
342
|
let newH = elementH.value
|
|
341
343
|
if ((el as any).fixedRatio && oldW > 0) {
|
|
342
344
|
const ratio = elementH.value / oldW
|
|
343
|
-
newH = parseFloat((val * ratio).toFixed(1))
|
|
345
|
+
newH = Math.max(10, parseFloat((val * ratio).toFixed(1)))
|
|
344
346
|
const hStr = el.style?.height || '100px'
|
|
345
347
|
if (hStr.endsWith('%')) {
|
|
346
348
|
el.style.height = `${((newH / refDims.height) * 100).toFixed(4)}%`
|
|
@@ -348,6 +350,7 @@ export function useSidebarElementTransform(
|
|
|
348
350
|
el.style.height = `${newH}px`
|
|
349
351
|
}
|
|
350
352
|
el.height = newH
|
|
353
|
+
if (selectedElementHeight) selectedElementHeight.value = `${newH}px`
|
|
351
354
|
}
|
|
352
355
|
if (el.type === 'group' && Array.isArray(el.elements) && oldW > 0) {
|
|
353
356
|
const scaleX = val / oldW
|
|
@@ -413,8 +416,9 @@ export function useSidebarElementTransform(
|
|
|
413
416
|
}
|
|
414
417
|
return parseFloat(parseFloat(hStr).toFixed(1)) || (el.height || 0)
|
|
415
418
|
},
|
|
416
|
-
set(
|
|
419
|
+
set(rawVal: number) {
|
|
417
420
|
if (!selectedElement.value) return
|
|
421
|
+
const val = Math.max(10, Number(rawVal) || 10)
|
|
418
422
|
if (selectedElementIds.value.length > 1 && activeSlide.value) {
|
|
419
423
|
activeSlide.value.elements.forEach((el: any) => {
|
|
420
424
|
if (selectedElementIds.value.includes(el.id)) {
|
|
@@ -443,7 +447,7 @@ export function useSidebarElementTransform(
|
|
|
443
447
|
elOldW = parseFloat(wStr) || 0
|
|
444
448
|
}
|
|
445
449
|
const ratio = elOldW / elOldH
|
|
446
|
-
const newW = parseFloat((val * ratio).toFixed(1))
|
|
450
|
+
const newW = Math.max(10, parseFloat((val * ratio).toFixed(1)))
|
|
447
451
|
if (wStr.endsWith('%')) {
|
|
448
452
|
el.style.width = `${((newW / refDims.width) * 100).toFixed(4)}%`
|
|
449
453
|
} else {
|
|
@@ -478,10 +482,11 @@ export function useSidebarElementTransform(
|
|
|
478
482
|
el.style.height = `${val}px`
|
|
479
483
|
}
|
|
480
484
|
el.height = val
|
|
485
|
+
if (selectedElementHeight) selectedElementHeight.value = `${val}px`
|
|
481
486
|
let newW = elementW.value
|
|
482
487
|
if ((el as any).fixedRatio && oldH > 0) {
|
|
483
488
|
const ratio = elementW.value / oldH
|
|
484
|
-
newW = parseFloat((val * ratio).toFixed(1))
|
|
489
|
+
newW = Math.max(10, parseFloat((val * ratio).toFixed(1)))
|
|
485
490
|
const wStr = el.style?.width || '100px'
|
|
486
491
|
if (wStr.endsWith('%')) {
|
|
487
492
|
el.style.width = `${((newW / refDims.width) * 100).toFixed(4)}%`
|
|
@@ -489,6 +494,7 @@ export function useSidebarElementTransform(
|
|
|
489
494
|
el.style.width = `${newW}px`
|
|
490
495
|
}
|
|
491
496
|
el.width = newW
|
|
497
|
+
if (selectedElementWidth) selectedElementWidth.value = `${newW}px`
|
|
492
498
|
}
|
|
493
499
|
if (el.type === 'group' && Array.isArray(el.elements) && oldH > 0) {
|
|
494
500
|
const scaleY = val / oldH
|
|
@@ -2343,6 +2343,28 @@ function getThemeUsageLabel(themeId: string): { type: 'all' | 'partial' | 'none'
|
|
|
2343
2343
|
return { type: 'none', text: '未被使用', fullText: '未被使用', pages: [] }
|
|
2344
2344
|
}
|
|
2345
2345
|
|
|
2346
|
+
function isHexOrRgbDark(colorStr?: string): boolean {
|
|
2347
|
+
if (!colorStr || typeof colorStr !== 'string') return false
|
|
2348
|
+
const s = colorStr.trim().toLowerCase()
|
|
2349
|
+
const hexMatch = s.match(/#([0-9a-f]{3,8})\b/i)
|
|
2350
|
+
if (hexMatch) {
|
|
2351
|
+
let hex = hexMatch[1]
|
|
2352
|
+
if (hex.length === 3) hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]
|
|
2353
|
+
const r = parseInt(hex.slice(0, 2), 16)
|
|
2354
|
+
const g = parseInt(hex.slice(2, 4), 16)
|
|
2355
|
+
const b = parseInt(hex.slice(4, 6), 16)
|
|
2356
|
+
return ((0.299 * r + 0.587 * g + 0.114 * b) / 255) < 0.58
|
|
2357
|
+
}
|
|
2358
|
+
const rgbMatch = s.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i)
|
|
2359
|
+
if (rgbMatch) {
|
|
2360
|
+
const r = parseInt(rgbMatch[1], 10)
|
|
2361
|
+
const g = parseInt(rgbMatch[2], 10)
|
|
2362
|
+
const b = parseInt(rgbMatch[3], 10)
|
|
2363
|
+
return ((0.299 * r + 0.587 * g + 0.114 * b) / 255) < 0.58
|
|
2364
|
+
}
|
|
2365
|
+
return false
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2346
2368
|
function getActiveSlideThemeRecipe(targetSlide?: any): StyleRecipe {
|
|
2347
2369
|
let effSlide: Slide | null = null
|
|
2348
2370
|
if (targetSlide && targetSlide.elements) {
|
|
@@ -2352,9 +2374,125 @@ function getActiveSlideThemeRecipe(targetSlide?: any): StyleRecipe {
|
|
|
2352
2374
|
} else if (activeSlide.value) {
|
|
2353
2375
|
effSlide = activeSlide.value
|
|
2354
2376
|
}
|
|
2355
|
-
|
|
2356
|
-
const
|
|
2357
|
-
|
|
2377
|
+
|
|
2378
|
+
const resolved = effSlide ? resolveSlideMasterAndLayout(effSlide) : { masterId: activeMasterId.value, layoutId: '' }
|
|
2379
|
+
const master = slideMasters.value.find(m => m && m.id === (isMasterEditingView.value ? activeMasterId.value : resolved.masterId)) || slideMasters.value[0]
|
|
2380
|
+
const rawThemeId = isMasterEditingView.value
|
|
2381
|
+
? ((master as any)?.themeId || effSlide?.themeId || 'tech-blue')
|
|
2382
|
+
: (effSlide?.themeId || (master as any)?.themeId || 'tech-blue')
|
|
2383
|
+
|
|
2384
|
+
const matched = builtinStyleRecipes.find(
|
|
2385
|
+
r => r.id === rawThemeId || (rawThemeId === 'default-recipe' && r.id === 'tech-blue')
|
|
2386
|
+
)
|
|
2387
|
+
if (matched) {
|
|
2388
|
+
return matched
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
// 若当前幻灯片来自外部模板/导入页面且其 themeId 未注册在 builtinStyleRecipes 中,
|
|
2392
|
+
// 动态从当前幻灯片(及同主题/同母版页面)提取真实主题色生成 StyleRecipe,保证版式库与母版版式实时跟随当前幻灯片配色
|
|
2393
|
+
if (effSlide) {
|
|
2394
|
+
const rawBg = effSlide.background || master?.background || '#ffffff'
|
|
2395
|
+
const bgStr = (typeof rawBg === 'string' && !rawBg.includes('url(') && !rawBg.includes('gradient('))
|
|
2396
|
+
? rawBg
|
|
2397
|
+
: (typeof (rawBg as any)?.color === 'string' ? (rawBg as any).color : '#ffffff')
|
|
2398
|
+
const isDark = isHexOrRgbDark(bgStr)
|
|
2399
|
+
|
|
2400
|
+
const textColors: Partial<Record<SlideTextType, string>> = {}
|
|
2401
|
+
let detectedShapeFill = ''
|
|
2402
|
+
let detectedFont = master?.fontFamily ? master.fontFamily.replace(/['"]/g, '').split(',')[0].trim() : 'SourceHanSansCN'
|
|
2403
|
+
|
|
2404
|
+
const peerSlides = [
|
|
2405
|
+
effSlide,
|
|
2406
|
+
...(slides.value || []).filter(s => s && s !== effSlide && (
|
|
2407
|
+
(effSlide.themeId && s.themeId === effSlide.themeId) ||
|
|
2408
|
+
(effSlide.masterId && s.masterId === effSlide.masterId)
|
|
2409
|
+
))
|
|
2410
|
+
]
|
|
2411
|
+
|
|
2412
|
+
const inspectElements = (els: any[]) => {
|
|
2413
|
+
for (const el of els || []) {
|
|
2414
|
+
if (!el || typeof el !== 'object') continue
|
|
2415
|
+
if (el.type === 'text') {
|
|
2416
|
+
const c = el.style?.color || el.color || el.style?.textColor
|
|
2417
|
+
if (typeof c === 'string' && c !== 'transparent' && c !== 'none') {
|
|
2418
|
+
const tType: SlideTextType = el.textType ? normalizeTextType(el.textType) : inferElementTextType(el)
|
|
2419
|
+
if (!textColors[tType]) textColors[tType] = c
|
|
2420
|
+
}
|
|
2421
|
+
const f = el.style?.fontFamily || el.fontFamily
|
|
2422
|
+
if (typeof f === 'string' && f && detectedFont === 'SourceHanSansCN') {
|
|
2423
|
+
detectedFont = f.replace(/['"]/g, '').split(',')[0].trim() || 'SourceHanSansCN'
|
|
2424
|
+
}
|
|
2425
|
+
} else if (el.type === 'shape' && !detectedShapeFill) {
|
|
2426
|
+
const fill = el.style?.fill || el.fill
|
|
2427
|
+
if (typeof fill === 'string' && fill !== 'none' && fill !== 'transparent' && fill.toLowerCase() !== bgStr.toLowerCase()) {
|
|
2428
|
+
detectedShapeFill = fill
|
|
2429
|
+
}
|
|
2430
|
+
} else if (el.type === 'group' && Array.isArray(el.elements)) {
|
|
2431
|
+
inspectElements(el.elements)
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
for (const s of peerSlides) {
|
|
2437
|
+
if (Array.isArray(s?.elements)) inspectElements(s.elements)
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
const titleColor = textColors.title || textColors.headline || (isDark ? '#ffffff' : '#0f172a')
|
|
2441
|
+
const headlineColor = textColors.headline || titleColor
|
|
2442
|
+
const normalColor = textColors.normalText || textColors.smallText || textColors.subheadline || (isDark ? '#e2e8f0' : '#334155')
|
|
2443
|
+
const subheadlineColor = textColors.subheadline || headlineColor || normalColor
|
|
2444
|
+
const smallColor = textColors.smallText || normalColor
|
|
2445
|
+
const accentColor = (titleColor.toLowerCase() !== normalColor.toLowerCase() && titleColor.toLowerCase() !== bgStr.toLowerCase())
|
|
2446
|
+
? titleColor
|
|
2447
|
+
: (detectedShapeFill || master?.themeColors?.[0] || '#2563eb')
|
|
2448
|
+
const shapeFill = detectedShapeFill || accentColor
|
|
2449
|
+
const shapeText = isHexOrRgbDark(shapeFill) ? '#ffffff' : '#0f172a'
|
|
2450
|
+
const palette = Array.isArray(master?.themeColors) && master.themeColors.length > 0
|
|
2451
|
+
? [...master.themeColors]
|
|
2452
|
+
: [accentColor, titleColor, subheadlineColor, normalColor, smallColor, bgStr]
|
|
2453
|
+
|
|
2454
|
+
return {
|
|
2455
|
+
...defaultStyleRecipe,
|
|
2456
|
+
id: rawThemeId || `slide-derived-${effSlide.id}`,
|
|
2457
|
+
name: (effSlide as any).themeName || (master as any)?.themeName || '当前页面主题',
|
|
2458
|
+
styleColors: palette,
|
|
2459
|
+
styleFonts: {
|
|
2460
|
+
titleFont: detectedFont,
|
|
2461
|
+
bodyFont: detectedFont
|
|
2462
|
+
},
|
|
2463
|
+
backgroundColor: bgStr,
|
|
2464
|
+
bulletPointsColor: accentColor,
|
|
2465
|
+
linkColor: accentColor,
|
|
2466
|
+
textStyles: {
|
|
2467
|
+
title: { ...defaultStyleRecipe.textStyles.title, color: titleColor, fontFamily: detectedFont },
|
|
2468
|
+
headline: { ...defaultStyleRecipe.textStyles.headline, color: headlineColor, fontFamily: detectedFont },
|
|
2469
|
+
subheadline: { ...defaultStyleRecipe.textStyles.subheadline, color: subheadlineColor, fontFamily: detectedFont },
|
|
2470
|
+
normalText: { ...defaultStyleRecipe.textStyles.normalText, color: normalColor, fontFamily: detectedFont },
|
|
2471
|
+
smallText: { ...defaultStyleRecipe.textStyles.smallText, color: smallColor, fontFamily: detectedFont }
|
|
2472
|
+
},
|
|
2473
|
+
table: {
|
|
2474
|
+
headerBg: accentColor,
|
|
2475
|
+
headerTextColor: isHexOrRgbDark(accentColor) ? '#ffffff' : '#0f172a',
|
|
2476
|
+
borderColor: isDark ? '#334155' : '#cbd5e1',
|
|
2477
|
+
alternateRowBg: isDark ? 'rgba(255,255,255,0.06)' : '#f8fafc',
|
|
2478
|
+
textColor: normalColor
|
|
2479
|
+
},
|
|
2480
|
+
chart: {
|
|
2481
|
+
...defaultStyleRecipe.chart,
|
|
2482
|
+
chartColor: accentColor,
|
|
2483
|
+
palette: palette.length >= 4 ? palette : defaultStyleRecipe.chart.palette,
|
|
2484
|
+
labelColor: normalColor,
|
|
2485
|
+
gridColor: isDark ? '#334155' : '#e2e8f0'
|
|
2486
|
+
},
|
|
2487
|
+
shape: {
|
|
2488
|
+
fillColor: shapeFill,
|
|
2489
|
+
borderColor: accentColor,
|
|
2490
|
+
textColor: shapeText
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
return defaultStyleRecipe
|
|
2358
2496
|
}
|
|
2359
2497
|
|
|
2360
2498
|
function initMathJax() {
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { parseTemplateJsonToDeck, type SlideTemplateItem } from './slideTemplates'
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_LAYOUT_LIBRARY_CATEGORIES = [
|
|
4
|
+
'基础版式',
|
|
5
|
+
'网格布局',
|
|
6
|
+
'图表与数据',
|
|
7
|
+
'时间轴与计划',
|
|
8
|
+
'价格方案',
|
|
9
|
+
'目录与议程',
|
|
10
|
+
'人物与团队',
|
|
11
|
+
'金句与证言',
|
|
12
|
+
'设备样机'
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
// 将 public/jvs-ppt-ui/layout-library/layout-image 下的 17 个轻量资源通过 Vite 内联映射,
|
|
16
|
+
// 确保作为 NPM 插件在任何宿主项目中使用时无需额外部署静态目录即可 100% 开箱即用
|
|
17
|
+
const inlineImageModules = import.meta.glob<string>(
|
|
18
|
+
'../../public/jvs-ppt-ui/layout-library/layout-image/*',
|
|
19
|
+
{ eager: true, query: '?inline', import: 'default' }
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
const layoutImageMap: Record<string, string> = {}
|
|
23
|
+
for (const [modPath, dataUrl] of Object.entries(inlineImageModules)) {
|
|
24
|
+
const fileName = modPath.split('/').pop()
|
|
25
|
+
if (fileName && typeof dataUrl === 'string') {
|
|
26
|
+
layoutImageMap[fileName] = dataUrl
|
|
27
|
+
layoutImageMap[`/jvs-ppt-ui/layout-library/layout-image/${fileName}`] = dataUrl
|
|
28
|
+
layoutImageMap[`/templates/layout-image/${fileName}`] = dataUrl
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function resolveLayoutSlideAssets(slide: any): any {
|
|
33
|
+
if (!slide || typeof slide !== 'object') return slide
|
|
34
|
+
const walkElements = (elements: any[]) => {
|
|
35
|
+
for (const el of elements) {
|
|
36
|
+
if (!el || typeof el !== 'object') continue
|
|
37
|
+
for (const key of ['content', 'src'] as const) {
|
|
38
|
+
const val = el[key]
|
|
39
|
+
if (typeof val === 'string') {
|
|
40
|
+
if (layoutImageMap[val]) {
|
|
41
|
+
el[key] = layoutImageMap[val]
|
|
42
|
+
} else {
|
|
43
|
+
const fileName = val.split('/').pop() || ''
|
|
44
|
+
if (fileName && layoutImageMap[fileName] && (val.includes('/layout-image/') || val.startsWith('layout-image/'))) {
|
|
45
|
+
el[key] = layoutImageMap[fileName]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (Array.isArray(el.elements)) {
|
|
51
|
+
walkElements(el.elements)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(slide.elements)) {
|
|
56
|
+
walkElements(slide.elements)
|
|
57
|
+
}
|
|
58
|
+
return slide
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let cachedResult: {
|
|
62
|
+
deck: SlideTemplateItem
|
|
63
|
+
slides: any[]
|
|
64
|
+
categories: string[]
|
|
65
|
+
} | null = null
|
|
66
|
+
|
|
67
|
+
export async function loadBuiltinLayoutLibrary(): Promise<{
|
|
68
|
+
deck: SlideTemplateItem
|
|
69
|
+
slides: any[]
|
|
70
|
+
categories: string[]
|
|
71
|
+
}> {
|
|
72
|
+
if (cachedResult) return cachedResult
|
|
73
|
+
|
|
74
|
+
const mod = await import('../../public/jvs-ppt-ui/layout-library/layout-library.json')
|
|
75
|
+
const rawJson: any = mod.default || mod
|
|
76
|
+
|
|
77
|
+
const parsed = parseTemplateJsonToDeck(rawJson, 'Pitch 官方版式库')
|
|
78
|
+
const normalizedSlides = (parsed.slides || []).map((s: any, idx: number) => {
|
|
79
|
+
const rawTitle = (s.title || `版式 ${idx + 1}`).trim()
|
|
80
|
+
const m = rawTitle.match(/^\[([^\]]+)\]\s*(.*)$/)
|
|
81
|
+
const category = s.category || (m ? m[1].trim() : '基础版式')
|
|
82
|
+
const cleanName = s.name || (m ? m[2].trim() : rawTitle) || rawTitle
|
|
83
|
+
const slideCopy = {
|
|
84
|
+
...s,
|
|
85
|
+
category,
|
|
86
|
+
name: cleanName
|
|
87
|
+
}
|
|
88
|
+
return resolveLayoutSlideAssets(slideCopy)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
let categories = [...DEFAULT_LAYOUT_LIBRARY_CATEGORIES]
|
|
92
|
+
if (Array.isArray(rawJson?.categories) && rawJson.categories.length > 0) {
|
|
93
|
+
const catNames = rawJson.categories
|
|
94
|
+
.map((c: any) => (typeof c === 'string' ? c : c?.name))
|
|
95
|
+
.filter(Boolean)
|
|
96
|
+
if (catNames.length > 0) {
|
|
97
|
+
categories = catNames
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const deck: SlideTemplateItem = {
|
|
102
|
+
...parsed,
|
|
103
|
+
name: 'Pitch 官方版式库',
|
|
104
|
+
slides: normalizedSlides
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
cachedResult = {
|
|
108
|
+
deck,
|
|
109
|
+
slides: normalizedSlides,
|
|
110
|
+
categories
|
|
111
|
+
}
|
|
112
|
+
return cachedResult
|
|
113
|
+
}
|
package/src/style.css
CHANGED
|
@@ -3974,7 +3974,7 @@ td.selected-cell.focused-cell,
|
|
|
3974
3974
|
}
|
|
3975
3975
|
|
|
3976
3976
|
.preset-layout-tab.is-active {
|
|
3977
|
-
color: #
|
|
3977
|
+
color: #1677ff !important;
|
|
3978
3978
|
font-weight: 600;
|
|
3979
3979
|
}
|
|
3980
3980
|
|
|
@@ -3985,10 +3985,100 @@ td.selected-cell.focused-cell,
|
|
|
3985
3985
|
right: 0;
|
|
3986
3986
|
bottom: 0;
|
|
3987
3987
|
height: 2px;
|
|
3988
|
-
background: #
|
|
3988
|
+
background: #1677ff !important;
|
|
3989
3989
|
border-radius: 1px;
|
|
3990
3990
|
}
|
|
3991
3991
|
|
|
3992
|
+
.preset-layout-category-bar-wrap {
|
|
3993
|
+
position: relative;
|
|
3994
|
+
display: flex;
|
|
3995
|
+
align-items: center;
|
|
3996
|
+
height: 40px;
|
|
3997
|
+
border-bottom: 1px solid #f1f5f9;
|
|
3998
|
+
background: #ffffff;
|
|
3999
|
+
overflow: hidden;
|
|
4000
|
+
flex-shrink: 0;
|
|
4001
|
+
}
|
|
4002
|
+
|
|
4003
|
+
.preset-layout-category-bar {
|
|
4004
|
+
display: flex;
|
|
4005
|
+
align-items: center;
|
|
4006
|
+
gap: 18px;
|
|
4007
|
+
padding: 0 20px;
|
|
4008
|
+
width: 100%;
|
|
4009
|
+
height: 100%;
|
|
4010
|
+
overflow-x: auto;
|
|
4011
|
+
overflow-y: hidden;
|
|
4012
|
+
scrollbar-width: none;
|
|
4013
|
+
-ms-overflow-style: none;
|
|
4014
|
+
scroll-behavior: smooth;
|
|
4015
|
+
}
|
|
4016
|
+
|
|
4017
|
+
.preset-layout-category-bar::-webkit-scrollbar {
|
|
4018
|
+
display: none;
|
|
4019
|
+
}
|
|
4020
|
+
|
|
4021
|
+
.preset-layout-category-item {
|
|
4022
|
+
position: relative;
|
|
4023
|
+
display: inline-flex;
|
|
4024
|
+
align-items: center;
|
|
4025
|
+
height: 100%;
|
|
4026
|
+
padding: 0;
|
|
4027
|
+
border: none;
|
|
4028
|
+
background: transparent;
|
|
4029
|
+
font-size: 13px;
|
|
4030
|
+
font-weight: 400;
|
|
4031
|
+
color: #64748b;
|
|
4032
|
+
white-space: nowrap;
|
|
4033
|
+
cursor: pointer;
|
|
4034
|
+
flex-shrink: 0;
|
|
4035
|
+
transition: color 0.15s ease;
|
|
4036
|
+
}
|
|
4037
|
+
|
|
4038
|
+
.preset-layout-category-item:hover {
|
|
4039
|
+
color: #1e293b;
|
|
4040
|
+
}
|
|
4041
|
+
|
|
4042
|
+
.preset-layout-category-item.is-active {
|
|
4043
|
+
color: #0f172a;
|
|
4044
|
+
font-weight: 600;
|
|
4045
|
+
}
|
|
4046
|
+
|
|
4047
|
+
.preset-cat-scroll-btn {
|
|
4048
|
+
position: absolute;
|
|
4049
|
+
top: 0;
|
|
4050
|
+
bottom: 0;
|
|
4051
|
+
z-index: 3;
|
|
4052
|
+
display: inline-flex;
|
|
4053
|
+
align-items: center;
|
|
4054
|
+
justify-content: center;
|
|
4055
|
+
width: 32px;
|
|
4056
|
+
border: none;
|
|
4057
|
+
color: #475569;
|
|
4058
|
+
cursor: pointer;
|
|
4059
|
+
transition: color 0.15s ease;
|
|
4060
|
+
}
|
|
4061
|
+
|
|
4062
|
+
.preset-cat-scroll-btn:hover {
|
|
4063
|
+
color: #0f172a;
|
|
4064
|
+
}
|
|
4065
|
+
|
|
4066
|
+
.preset-cat-scroll-btn.is-left {
|
|
4067
|
+
left: 0;
|
|
4068
|
+
padding-right: 6px;
|
|
4069
|
+
background: linear-gradient(90deg, #ffffff 65%, rgba(255, 255, 255, 0));
|
|
4070
|
+
}
|
|
4071
|
+
|
|
4072
|
+
.preset-cat-scroll-btn.is-right {
|
|
4073
|
+
right: 0;
|
|
4074
|
+
padding-left: 6px;
|
|
4075
|
+
background: linear-gradient(270deg, #ffffff 65%, rgba(255, 255, 255, 0));
|
|
4076
|
+
}
|
|
4077
|
+
|
|
4078
|
+
.preset-layout-library-body {
|
|
4079
|
+
max-height: min(600px, calc(100vh - 180px));
|
|
4080
|
+
}
|
|
4081
|
+
|
|
3992
4082
|
.preset-template-upload-btn {
|
|
3993
4083
|
display: inline-flex;
|
|
3994
4084
|
align-items: center;
|
|
@@ -4005,9 +4095,9 @@ td.selected-cell.focused-cell,
|
|
|
4005
4095
|
}
|
|
4006
4096
|
|
|
4007
4097
|
.preset-template-upload-btn:hover {
|
|
4008
|
-
background: #
|
|
4009
|
-
border-color: #
|
|
4010
|
-
color: #
|
|
4098
|
+
background: #e6f4ff;
|
|
4099
|
+
border-color: #91caff;
|
|
4100
|
+
color: #1677ff !important;
|
|
4011
4101
|
}
|
|
4012
4102
|
|
|
4013
4103
|
.preset-template-search-box {
|
|
@@ -4026,8 +4116,8 @@ td.selected-cell.focused-cell,
|
|
|
4026
4116
|
}
|
|
4027
4117
|
|
|
4028
4118
|
.preset-template-search-box:focus-within {
|
|
4029
|
-
border-color: #
|
|
4030
|
-
box-shadow: 0 0 0 2px rgba(
|
|
4119
|
+
border-color: #1677ff;
|
|
4120
|
+
box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
|
|
4031
4121
|
}
|
|
4032
4122
|
|
|
4033
4123
|
.preset-template-search-icon {
|
|
@@ -4087,8 +4177,8 @@ td.selected-cell.focused-cell,
|
|
|
4087
4177
|
|
|
4088
4178
|
.preset-template-card:hover .preset-template-thumb,
|
|
4089
4179
|
.preset-template-slide-item:hover .preset-template-slide-thumb {
|
|
4090
|
-
border-color: #
|
|
4091
|
-
box-shadow: 0 0 0 1px #
|
|
4180
|
+
border-color: #1677ff !important;
|
|
4181
|
+
box-shadow: 0 0 0 1px #1677ff, 0 6px 14px rgba(22, 119, 255, 0.12);
|
|
4092
4182
|
}
|
|
4093
4183
|
|
|
4094
4184
|
.preset-template-name {
|
|
@@ -4123,7 +4213,7 @@ td.selected-cell.focused-cell,
|
|
|
4123
4213
|
align-items: center;
|
|
4124
4214
|
justify-content: center;
|
|
4125
4215
|
background: rgba(255, 255, 255, 0.82);
|
|
4126
|
-
color: #
|
|
4216
|
+
color: #1677ff !important;
|
|
4127
4217
|
font-size: 12px;
|
|
4128
4218
|
font-weight: 600;
|
|
4129
4219
|
}
|
|
@@ -4191,8 +4281,8 @@ td.selected-cell.focused-cell,
|
|
|
4191
4281
|
.preset-template-detail-title .detail-count-badge {
|
|
4192
4282
|
font-size: 11px;
|
|
4193
4283
|
font-weight: 500;
|
|
4194
|
-
color: #
|
|
4195
|
-
background: #
|
|
4284
|
+
color: #1677ff !important;
|
|
4285
|
+
background: #e6f4ff !important;
|
|
4196
4286
|
padding: 1px 7px;
|
|
4197
4287
|
border-radius: 10px;
|
|
4198
4288
|
flex-shrink: 0;
|
|
@@ -4202,8 +4292,8 @@ td.selected-cell.focused-cell,
|
|
|
4202
4292
|
padding: 5px 11px;
|
|
4203
4293
|
border-radius: 6px;
|
|
4204
4294
|
border: none;
|
|
4205
|
-
background: #
|
|
4206
|
-
color: #ffffff;
|
|
4295
|
+
background: #1677ff !important;
|
|
4296
|
+
color: #ffffff !important;
|
|
4207
4297
|
font-size: 12px;
|
|
4208
4298
|
font-weight: 500;
|
|
4209
4299
|
cursor: pointer;
|
|
@@ -4212,7 +4302,7 @@ td.selected-cell.focused-cell,
|
|
|
4212
4302
|
}
|
|
4213
4303
|
|
|
4214
4304
|
.preset-template-insert-all-btn:hover {
|
|
4215
|
-
background: #
|
|
4305
|
+
background: #4096ff !important;
|
|
4216
4306
|
}
|
|
4217
4307
|
|
|
4218
4308
|
.preset-template-slide-index {
|
|
@@ -4237,8 +4327,8 @@ td.selected-cell.focused-cell,
|
|
|
4237
4327
|
z-index: 2;
|
|
4238
4328
|
padding: 2px 8px;
|
|
4239
4329
|
border-radius: 6px;
|
|
4240
|
-
background: #
|
|
4241
|
-
color: #ffffff;
|
|
4330
|
+
background: #1677ff !important;
|
|
4331
|
+
color: #ffffff !important;
|
|
4242
4332
|
font-size: 10.5px;
|
|
4243
4333
|
font-weight: 500;
|
|
4244
4334
|
opacity: 0;
|
|
@@ -501,10 +501,27 @@ async function injectMasterAndLayouts(loadedZip: JSZip, zipMeta: any, slides: Sl
|
|
|
501
501
|
return false
|
|
502
502
|
}
|
|
503
503
|
|
|
504
|
-
// 1. 覆盖写入所有 slideMasters 及其 _rels
|
|
504
|
+
// 1. 覆盖写入所有 slideMasters 及其 _rels
|
|
505
|
+
const injectedMasterXmlFiles = Object.keys(zipMeta.masterFilesMap).filter(k => k.endsWith('.xml') && !k.includes('_rels'))
|
|
506
|
+
if (injectedMasterXmlFiles.length > 0 && !zipMeta.masterFilesMap['ppt/slideMasters/slideMaster1.xml']) {
|
|
507
|
+
loadedZip.remove('ppt/slideMasters/slideMaster1.xml')
|
|
508
|
+
loadedZip.remove('ppt/slideMasters/_rels/slideMaster1.xml.rels')
|
|
509
|
+
const primaryMasterRelTarget = injectedMasterXmlFiles[0].replace(/^ppt\//, '')
|
|
510
|
+
const presRelsPath = 'ppt/_rels/presentation.xml.rels'
|
|
511
|
+
const presRelsXml = await loadedZip.file(presRelsPath)?.async('text')
|
|
512
|
+
if (presRelsXml) {
|
|
513
|
+
loadedZip.file(presRelsPath, presRelsXml.replace(/Target="slideMasters\/slideMaster1\.xml"/g, `Target="${primaryMasterRelTarget}"`))
|
|
514
|
+
}
|
|
515
|
+
}
|
|
505
516
|
for (const [filePath, content] of Object.entries(zipMeta.masterFilesMap)) {
|
|
506
517
|
if (content) {
|
|
507
|
-
|
|
518
|
+
let strContent = content as string
|
|
519
|
+
if (filePath.endsWith('.rels')) {
|
|
520
|
+
strContent = strContent.replace(/Target="\.\.\/theme\/(theme\d+\.xml)"/g, (full, themeFile) => {
|
|
521
|
+
return loadedZip.file(`ppt/theme/${themeFile}`) ? full : 'Target="../theme/theme1.xml"'
|
|
522
|
+
})
|
|
523
|
+
}
|
|
524
|
+
loadedZip.file(filePath, strContent)
|
|
508
525
|
}
|
|
509
526
|
}
|
|
510
527
|
|
|
@@ -512,7 +529,13 @@ async function injectMasterAndLayouts(loadedZip: JSZip, zipMeta: any, slides: Sl
|
|
|
512
529
|
if (zipMeta.layoutFilesMap) {
|
|
513
530
|
for (const [filePath, content] of Object.entries(zipMeta.layoutFilesMap)) {
|
|
514
531
|
if (content) {
|
|
515
|
-
|
|
532
|
+
let strContent = content as string
|
|
533
|
+
if (filePath.endsWith('.rels')) {
|
|
534
|
+
strContent = strContent.replace(/Target="\.\.\/theme\/(theme\d+\.xml)"/g, (full, themeFile) => {
|
|
535
|
+
return loadedZip.file(`ppt/theme/${themeFile}`) ? full : 'Target="../theme/theme1.xml"'
|
|
536
|
+
})
|
|
537
|
+
}
|
|
538
|
+
loadedZip.file(filePath, strContent)
|
|
516
539
|
}
|
|
517
540
|
}
|
|
518
541
|
}
|
|
@@ -537,7 +560,16 @@ async function injectMasterAndLayouts(loadedZip: JSZip, zipMeta: any, slides: Sl
|
|
|
537
560
|
|
|
538
561
|
// 4. 更新 [Content_Types].xml,确保所有 slideLayout 及 tags 均已注册,并清理不存在的幽灵 slideMaster
|
|
539
562
|
let ctXml = await loadedZip.file('[Content_Types].xml')?.async('text')
|
|
540
|
-
if (ctXml) {
|
|
563
|
+
if (ctXml) {
|
|
564
|
+
for (const mf of Object.keys(zipMeta.masterFilesMap)) {
|
|
565
|
+
if (mf.endsWith('.xml') && !mf.includes('_rels')) {
|
|
566
|
+
const partName = '/' + mf
|
|
567
|
+
if (!ctXml.includes(partName)) {
|
|
568
|
+
const override = `<Override PartName="${partName}" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"/>`
|
|
569
|
+
ctXml = ctXml.replace('</Types>', override + '</Types>')
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
541
573
|
if (zipMeta.layoutFilesMap) {
|
|
542
574
|
for (const lf of Object.keys(zipMeta.layoutFilesMap)) {
|
|
543
575
|
if (lf.endsWith('.xml') && !lf.includes('_rels')) {
|
|
Binary file
|