jvs-ppt-ui 0.0.36 → 0.0.37

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.
Files changed (57) hide show
  1. package/dist/lib/jvs-ppt-ui/iconfont/iconfont.css +7 -3
  2. package/dist/lib/jvs-ppt-ui/iconfont/iconfont.js +1 -1
  3. package/dist/lib/jvs-ppt-ui/iconfont/iconfont.json +7 -0
  4. package/dist/lib/jvs-ppt-ui/iconfont/iconfont.ttf +0 -0
  5. package/dist/lib/jvs-ppt-ui/iconfont/iconfont.woff +0 -0
  6. package/dist/lib/jvs-ppt-ui/iconfont/iconfont.woff2 +0 -0
  7. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_01de32e3d01df54a.svg +9 -0
  8. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_12935f21f0b1ae78.png +0 -0
  9. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_201146e666f28fff.png +0 -0
  10. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_32ef4f2c1d76ea32.svg +15 -0
  11. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_571054b13f220252.svg +10 -0
  12. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_5b14f99769a8894c.svg +10 -0
  13. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_62fc021bdae89b21.png +0 -0
  14. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_649d2b36f7fc251e.png +0 -0
  15. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_7e57de8ea8d46aba.png +0 -0
  16. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_9ad1284e63535689.svg +15 -0
  17. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_9ff268d3709d6454.png +0 -0
  18. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_b8f80ac591d69945.png +0 -0
  19. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_dce239981c2cd1aa.svg +15 -0
  20. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_e2ea31ca7735e5c0.png +0 -0
  21. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_e585ddb9ec5c408e.png +0 -0
  22. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_f3335fad3673d648.svg +10 -0
  23. package/dist/lib/jvs-ppt-ui/layout-library/layout-image/img_fb925327432cc7e7.svg +15 -0
  24. package/dist/lib/jvs-ppt-ui/layout-library/layout-library.json +1 -0
  25. package/dist/lib/jvs-ppt-ui.es.js +78530 -20156
  26. package/dist/lib/jvs-ppt-ui.umd.js +112 -112
  27. package/dist/lib/style.css +1 -1
  28. package/package.json +1 -1
  29. package/scripts/patch-pptxtojson.cjs +33 -0
  30. package/src/assets/chart/baseArea.png +0 -0
  31. package/src/assets/chart/baseBar.png +0 -0
  32. package/src/assets/chart/baseHistogram.png +0 -0
  33. package/src/assets/chart/basePie.png +0 -0
  34. package/src/assets/chart/bubbleChart.png +0 -0
  35. package/src/assets/chart/circyChart.png +0 -0
  36. package/src/assets/chart/compPolyline.png +0 -0
  37. package/src/assets/chart/lineChart.png +0 -0
  38. package/src/assets/chart/otherLine.png +0 -0
  39. package/src/assets/chart/otherLineChart.png +0 -0
  40. package/src/assets/chart/perHistogram.png +0 -0
  41. package/src/assets/chart/radarChart.png +0 -0
  42. package/src/assets/chart/roseChart.png +0 -0
  43. package/src/assets/chart/roseCircyChart.png +0 -0
  44. package/src/assets/chart/stackArea.png +0 -0
  45. package/src/assets/chart/stackBar.png +0 -0
  46. package/src/assets/chart/stackHistogram.png +0 -0
  47. package/src/assets/iconfont/iconfont.js +1 -1
  48. package/src/components/ChartTypeSelector.vue +15 -67
  49. package/src/components/Header.vue +10 -7
  50. package/src/components/SidebarLeft.vue +381 -29
  51. package/src/components/sidebar/panels/LayoutThumbSvg.vue +82 -14
  52. package/src/composables/useSlides.ts +141 -3
  53. package/src/configs/layoutLibrary.ts +113 -0
  54. package/src/style.css +107 -17
  55. package/src/utils/pptxAnimationInjector.ts +36 -4
  56. package/src/assets/chart/baseMap.png +0 -0
  57. package/src/assets/chart/boxplot.png +0 -0
@@ -160,7 +160,7 @@ function getLayoutSvgElements(elements: any[]) {
160
160
 
161
161
  const fontSize = parseFloat(el.style?.fontSize || el.fontSize || (isPlaceholder ? (el.placeholder?.type === 'title' ? '28' : '16') : '16')) || 16
162
162
 
163
- const defaultWidthFallback = isVertical ? ((60 / baseW) * 100) : 0
163
+ const defaultWidthFallback = isVertical ? (((fontSize + 24) / baseW) * 100) : 0
164
164
  const defaultHeightFallback = ((fontSize * 1.25) / baseH) * 100
165
165
  const rawWVal = (el.style?.width && el.style.width !== 'auto') ? el.style.width : el.width
166
166
  const rawHVal = (el.style?.height && el.style.height !== 'auto') ? el.style.height : (el.height && el.height !== 'auto' ? el.height : undefined)
@@ -194,7 +194,7 @@ function getLayoutSvgElements(elements: any[]) {
194
194
  const baseRatio = 100 / baseW
195
195
  const rawSvgSize = fontSize * baseRatio
196
196
  const svgFontSize = isPlaceholder
197
- ? +(Math.max(1.8, Math.min(4.5, rawSvgSize * 1.15))).toFixed(2)
197
+ ? +(Math.max(1.5, Math.min(7.5, rawSvgSize * 1.05))).toFixed(2)
198
198
  : +(Math.max(1.4, Math.min(14, rawSvgSize))).toFixed(2)
199
199
 
200
200
  const rawSegments: { text: string; indent: number }[] = []
@@ -260,7 +260,8 @@ function getLayoutSvgElements(elements: any[]) {
260
260
  const lineHeight = +(svgFontSize * (fontSize >= 72 ? 1.05 : 1.25)).toFixed(2)
261
261
  const lineCount = Math.min(parsedTextLines.length, 6)
262
262
  const totalTextH = lineCount * lineHeight
263
- const vAlign = el.verticalAlign || el.style?.verticalAlign || 'top'
263
+ const defaultVAlign = (!isVertical && isPlaceholder && h > svgFontSize * 3.8 && fontSize < 32) ? 'top' : 'middle'
264
+ const vAlign = el.verticalAlign || el.style?.verticalAlign || defaultVAlign
264
265
  let textStartY = +(y + svgFontSize * 0.95).toFixed(2)
265
266
  if (h > totalTextH) {
266
267
  if (vAlign === 'bottom' || vAlign === 'down') {
@@ -273,6 +274,11 @@ function getLayoutSvgElements(elements: any[]) {
273
274
 
274
275
  const isTitle = el.type === 'text' && (el.name?.includes('标题') || el.placeholder?.type === 'title' || fontSize >= 24)
275
276
  const isText = el.type === 'text'
277
+ const fontFamily = (el.style?.fontFamily && el.style.fontFamily !== '默认字体' && el.style.fontFamily !== 'inherit')
278
+ ? el.style.fontFamily
279
+ : ((el.fontFamily && el.fontFamily !== '默认字体' && el.fontFamily !== 'inherit')
280
+ ? el.fontFamily
281
+ : 'sans-serif')
276
282
 
277
283
  const color = parseColorString(el.style?.color || el.color, isPlaceholder ? (isTitle ? '#0f172a' : '#64748b') : (isTitle ? '#0f172a' : '#334155'))
278
284
  const rawFillVal = (el.style && el.style.fill !== undefined) ? el.style.fill : el.fill
@@ -297,7 +303,7 @@ function getLayoutSvgElements(elements: any[]) {
297
303
  const rawOpacity = el.style?.opacity !== undefined ? parseFloat(el.style.opacity) : (el.opacity !== undefined ? parseFloat(el.opacity) : 1)
298
304
  const opacity = isNaN(rawOpacity) ? 1 : rawOpacity
299
305
  const inlineAlignMatch = rawContentStr ? rawContentStr.match(/text-align:\s*(left|center|right)/i) : null
300
- const textAlign = el.style?.textAlign || el.textAlign || (inlineAlignMatch ? inlineAlignMatch[1].toLowerCase() : (el.type === 'shape' ? 'center' : (isTitle && !isVertical && isPlaceholder ? 'center' : 'left')))
306
+ const textAlign = el.style?.textAlign || el.textAlign || (inlineAlignMatch ? inlineAlignMatch[1].toLowerCase() : (el.type === 'shape' ? 'center' : 'left'))
301
307
  const pattern = getElementPattern(el)
302
308
  const rawBr = parseFloat(el.style?.borderRadius || el.borderRadius || 0) || 0
303
309
  const rx = rawBr > 0 ? +((rawBr / baseW) * 100).toFixed(2) : (el.type === 'shape' ? 0.8 : 0)
@@ -379,6 +385,13 @@ function getLayoutSvgElements(elements: any[]) {
379
385
  }
380
386
  }
381
387
 
388
+ const chartColors: string[] = Array.isArray(el.style?.chartColors) && el.style.chartColors.length > 0
389
+ ? el.style.chartColors
390
+ : (Array.isArray(el.themeColors) && el.themeColors.length > 0
391
+ ? el.themeColors
392
+ : ['#2563eb', '#3b82f6', '#60a5fa', '#93c5fd'])
393
+ const chartType = String(el.chartType || 'bar').toLowerCase()
394
+
382
395
  return {
383
396
  id: el.id,
384
397
  rawEl: el,
@@ -389,6 +402,8 @@ function getLayoutSvgElements(elements: any[]) {
389
402
  isCircle,
390
403
  isImagePlaceholder,
391
404
  type: el.type || 'text',
405
+ chartType,
406
+ chartColors,
392
407
  isImage: el.type === 'image' || Boolean(el.src || el.imageSrc || el.picBase64 || el.base64 || getElementImageSrc(el)),
393
408
  imageSrc: getElementImageSrc(el),
394
409
  clipViewBox,
@@ -413,6 +428,7 @@ function getLayoutSvgElements(elements: any[]) {
413
428
  isPlaceholder,
414
429
  textAlign,
415
430
  svgFontSize,
431
+ fontFamily,
416
432
  isTitle,
417
433
  isText,
418
434
  cleanText,
@@ -564,7 +580,7 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
564
580
  text-anchor="middle"
565
581
  :fill="item.color || '#ffffff'"
566
582
  :font-size="item.svgFontSize"
567
- font-family="sans-serif"
583
+ :font-family="item.fontFamily"
568
584
  font-weight="bold"
569
585
  style="pointer-events: none; user-select: none;"
570
586
  >{{ item.cleanText.length > 20 ? item.cleanText.substring(0, 20) + '...' : item.cleanText }}</text>
@@ -588,7 +604,7 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
588
604
  text-anchor="middle"
589
605
  :fill="item.color || '#ffffff'"
590
606
  :font-size="item.svgFontSize"
591
- font-family="sans-serif"
607
+ :font-family="item.fontFamily"
592
608
  font-weight="bold"
593
609
  style="pointer-events: none; user-select: none;"
594
610
  >{{ item.cleanText.length > 20 ? item.cleanText.substring(0, 20) + '...' : item.cleanText }}</text>
@@ -602,7 +618,7 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
602
618
  text-anchor="middle"
603
619
  :fill="item.color || '#ffffff'"
604
620
  :font-size="item.svgFontSize"
605
- font-family="sans-serif"
621
+ :font-family="item.fontFamily"
606
622
  font-weight="bold"
607
623
  style="pointer-events: none; user-select: none;"
608
624
  >{{ item.cleanText.length > 20 ? item.cleanText.substring(0, 20) + '...' : item.cleanText }}</text>
@@ -625,17 +641,22 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
625
641
  v-for="(lineObj, lIdx) in item.parsedTextLines.slice(0, 6)"
626
642
  :key="lIdx"
627
643
  :x="item.isVertical
628
- ? (item.x + item.w * 0.5)
644
+ ? (item.x + item.w * 0.5 - (lIdx - (Math.min(item.parsedTextLines.length, 6) - 1) / 2) * item.lineHeight)
629
645
  : (item.textAlign === 'center' || (item.isPlaceholder && item.w < 15)
630
646
  ? (item.x + item.w * 0.5)
631
647
  : (item.textAlign === 'right'
632
648
  ? (item.x + item.w - (item.isPlaceholder ? 1 : 0))
633
649
  : (item.x + (lineObj.indent || 0) * 2.5 + (item.isPlaceholder ? 1 : 0))))"
634
- :y="item.textStartY + lIdx * item.lineHeight"
635
- :text-anchor="item.isVertical ? 'middle' : (item.textAlign === 'center' || (item.isPlaceholder && item.w < 15) ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
650
+ :y="item.isVertical
651
+ ? (item.textAlign === 'center' ? item.yCenter : (item.textAlign === 'right' ? (item.y + item.h - 1.2) : (item.y + 1.2)))
652
+ : (item.textStartY + lIdx * item.lineHeight)"
653
+ :text-anchor="item.isVertical
654
+ ? (item.textAlign === 'center' ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))
655
+ : (item.textAlign === 'center' || (item.isPlaceholder && item.w < 15) ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
656
+ :dominant-baseline="item.isVertical ? 'central' : undefined"
636
657
  :fill="item.color || (item.isTitle ? '#0f172a' : '#64748b')"
637
658
  :font-size="item.svgFontSize"
638
- font-family="sans-serif"
659
+ :font-family="item.fontFamily"
639
660
  :font-weight="item.isTitle ? 'bold' : 'normal'"
640
661
  :style="{ writingMode: item.isVertical ? 'vertical-rl' : 'horizontal-tb', pointerEvents: 'none', userSelect: 'none' }"
641
662
  >{{ lineObj.text.length > 20 ? lineObj.text.substring(0, 20) + '...' : lineObj.text }}</text>
@@ -650,12 +671,15 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
650
671
  ? item.x + item.w - (item.isPlaceholder ? 1 : 0)
651
672
  : item.x + (item.isPlaceholder ? 1 : 0)))"
652
673
  :y="item.isVertical
653
- ? item.y + item.svgFontSize * 1.2
674
+ ? (item.textAlign === 'center' ? item.yCenter : (item.textAlign === 'right' ? (item.y + item.h - 1.2) : (item.y + 1.2)))
654
675
  : (item.textStartY || Math.min(thumbSvgHeight - 1, item.y + item.h * 0.5 + item.svgFontSize * 0.35))"
655
- :text-anchor="item.isVertical ? 'middle' : (item.textAlign === 'center' || (item.isPlaceholder && item.w < 15) ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
676
+ :text-anchor="item.isVertical
677
+ ? (item.textAlign === 'center' ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))
678
+ : (item.textAlign === 'center' || (item.isPlaceholder && item.w < 15) ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
679
+ :dominant-baseline="item.isVertical ? 'central' : undefined"
656
680
  :fill="item.color || (item.isTitle ? '#0f172a' : '#64748b')"
657
681
  :font-size="item.svgFontSize"
658
- font-family="sans-serif"
682
+ :font-family="item.fontFamily"
659
683
  :font-weight="item.isTitle ? 'bold' : 'normal'"
660
684
  :style="{ writingMode: item.isVertical ? 'vertical-rl' : 'horizontal-tb', pointerEvents: 'none', userSelect: 'none' }"
661
685
  >{{ item.cleanText.length > 20 ? item.cleanText.substring(0, 20) + '...' : item.cleanText }}</text>
@@ -677,6 +701,50 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
677
701
  />
678
702
  </g>
679
703
  </g>
704
+ <g v-else-if="item.type === 'chart'" :transform="item.transform" :opacity="item.opacity !== undefined && item.opacity < 1 ? item.opacity : undefined">
705
+ <template v-if="item.chartType === 'donut' || item.chartType === 'ring' || item.chartType === 'pie'">
706
+ <circle
707
+ :cx="item.cx"
708
+ :cy="item.cy"
709
+ :r="Math.max(1.5, Math.min(item.w, item.h) * 0.36)"
710
+ :fill="item.chartType === 'pie' ? (item.chartColors[0] || '#2563eb') : 'none'"
711
+ :stroke="item.chartColors[0] || '#2563eb'"
712
+ :stroke-width="item.chartType === 'pie' ? 0.4 : Math.max(1.2, Math.min(item.w, item.h) * 0.14)"
713
+ />
714
+ <circle
715
+ v-if="item.chartType !== 'pie'"
716
+ :cx="item.cx"
717
+ :cy="item.cy"
718
+ :r="Math.max(1.5, Math.min(item.w, item.h) * 0.36)"
719
+ fill="none"
720
+ :stroke="item.chartColors[2] || item.chartColors[1] || '#93c5fd'"
721
+ :stroke-width="Math.max(1.2, Math.min(item.w, item.h) * 0.14)"
722
+ :stroke-dasharray="`${Math.max(2, Math.min(item.w, item.h) * 0.8)} ${Math.max(4, Math.min(item.w, item.h) * 2)}`"
723
+ />
724
+ </template>
725
+ <template v-else-if="item.chartType === 'line' || item.chartType === 'area'">
726
+ <polyline
727
+ :points="`${item.x + item.w * 0.08},${item.y + item.h * 0.82} ${item.x + item.w * 0.35},${item.y + item.h * 0.58} ${item.x + item.w * 0.65},${item.y + item.h * 0.38} ${item.x + item.w * 0.92},${item.y + item.h * 0.16}`"
728
+ fill="none"
729
+ :stroke="item.chartColors[0] || '#2563eb'"
730
+ stroke-width="1.1"
731
+ stroke-linecap="round"
732
+ stroke-linejoin="round"
733
+ />
734
+ <line :x1="item.x + item.w * 0.06" :y1="item.y + item.h * 0.88" :x2="item.x + item.w * 0.94" :y2="item.y + item.h * 0.88" :stroke="item.chartColors[3] || '#cbd5e1'" stroke-width="0.4" />
735
+ </template>
736
+ <template v-else-if="item.chartType === 'horizontal-bar'">
737
+ <rect :x="item.x + item.w * 0.08" :y="item.y + item.h * 0.15" :width="item.w * 0.78" :height="item.h * 0.16" rx="0.5" :fill="item.chartColors[0] || '#2563eb'" />
738
+ <rect :x="item.x + item.w * 0.08" :y="item.y + item.h * 0.42" :width="item.w * 0.56" :height="item.h * 0.16" rx="0.5" :fill="item.chartColors[1] || item.chartColors[0] || '#3b82f6'" />
739
+ <rect :x="item.x + item.w * 0.08" :y="item.y + item.h * 0.69" :width="item.w * 0.38" :height="item.h * 0.16" rx="0.5" :fill="item.chartColors[2] || item.chartColors[0] || '#60a5fa'" />
740
+ </template>
741
+ <template v-else>
742
+ <rect :x="item.x + item.w * 0.1" :y="item.y + item.h * 0.45" :width="item.w * 0.14" :height="item.h * 0.45" rx="0.5" :fill="item.chartColors[0] || '#2563eb'" />
743
+ <rect :x="item.x + item.w * 0.31" :y="item.y + item.h * 0.25" :width="item.w * 0.14" :height="item.h * 0.65" rx="0.5" :fill="item.chartColors[1] || item.chartColors[0] || '#3b82f6'" />
744
+ <rect :x="item.x + item.w * 0.52" :y="item.y + item.h * 0.35" :width="item.w * 0.14" :height="item.h * 0.55" rx="0.5" :fill="item.chartColors[2] || item.chartColors[0] || '#60a5fa'" />
745
+ <rect :x="item.x + item.w * 0.73" :y="item.y + item.h * 0.15" :width="item.w * 0.14" :height="item.h * 0.75" rx="0.5" :fill="item.chartColors[3] || item.chartColors[0] || '#93c5fd'" />
746
+ </template>
747
+ </g>
680
748
  <rect v-else :x="item.x" :y="item.y" :width="item.w" :height="item.h" rx="1" fill="none" stroke="#e2e8f0" stroke-width="0.8" />
681
749
  </template>
682
750
  </template>
@@ -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
- const themeId = effSlide?.themeId || (isMasterEditingView.value ? ((slideMasters.value.find(m => m.id === activeMasterId.value) as any)?.themeId || 'tech-blue') : 'tech-blue')
2356
- const recipe = builtinStyleRecipes.find(r => r.id === themeId || (themeId === 'default-recipe' && r.id === 'tech-blue')) || defaultStyleRecipe
2357
- return recipe
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: #4f46e5;
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: #4f46e5;
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: #eef2ff;
4009
- border-color: #c7d2fe;
4010
- color: #4f46e5;
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: #6366f1;
4030
- box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
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: #6366f1;
4091
- box-shadow: 0 0 0 1px #6366f1, 0 6px 14px rgba(79, 70, 229, 0.12);
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: #4f46e5;
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: #6366f1;
4195
- background: #eef2ff;
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: #4f46e5;
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: #4338ca;
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: #4f46e5;
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;