jvs-ppt-ui 0.0.35 → 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 (61) 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 +81545 -23219
  26. package/dist/lib/jvs-ppt-ui.umd.js +113 -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/CanvasArea.vue +26 -13
  49. package/src/components/ChartTypeSelector.vue +15 -67
  50. package/src/components/Header.vue +10 -7
  51. package/src/components/SidebarLeft.vue +382 -30
  52. package/src/components/SidebarRight.vue +39 -1
  53. package/src/components/sidebar/panels/LayoutThumbSvg.vue +82 -14
  54. package/src/components/sidebar/panels/SidebarChartFormatPanel.vue +676 -3
  55. package/src/composables/sidebar/useSidebarChart.ts +88 -39
  56. package/src/composables/useSlides.ts +245 -25
  57. package/src/configs/layoutLibrary.ts +113 -0
  58. package/src/style.css +107 -17
  59. package/src/utils/pptxAnimationInjector.ts +36 -4
  60. package/src/assets/chart/baseMap.png +0 -0
  61. package/src/assets/chart/boxplot.png +0 -0
@@ -37,7 +37,7 @@ import { SHAPE_LIST, type ShapePoolItem } from '../utils/shapes'
37
37
  const flatShapePoolItems: ShapePoolItem[] = SHAPE_LIST.flatMap(c => c.children)
38
38
 
39
39
  const {
40
- slides, activeIndex, selectSlide, selectAllSlides, deleteSelectedSlides,
40
+ slides, activeIndex, activeSlide, selectSlide, selectAllSlides, deleteSelectedSlides,
41
41
  copySelectedSlides, cutSelectedSlides, duplicateSelectedSlides,
42
42
  selectedSlideIndexes, isMouseOverSlideList, renderLatexToSvg, deleteSlide,
43
43
  selectedElementIds, selectedElementId, notify, startPresentation,
@@ -46,7 +46,8 @@ const {
46
46
  enterMasterView, addMaster, deleteMaster, addLayout, deleteLayout, duplicateLayout,
47
47
  clipboard, slideClipboard, handleUnifiedPaste, sortSlideElements, getEffectiveMasterElementsForSlide,
48
48
  getEffectiveSlideBackground, isCanvasDragging, activeSlideVersion, pauseHistory,
49
- activeSidebarTab, isReadonly, isTemplateEnabled
49
+ activeSidebarTab, isReadonly, isTemplateEnabled, addHistorySnapshot,
50
+ getActiveSlideThemeRecipe, recolorElementsWithRecipe
50
51
  } = useSlides()
51
52
 
52
53
  const displaySlides = shallowRef<any[]>([...slides.value])
@@ -225,24 +226,232 @@ import {
225
226
  parseTemplateJsonToDeck,
226
227
  type SlideTemplateItem
227
228
  } from '../configs/slideTemplates'
229
+ import {
230
+ DEFAULT_LAYOUT_LIBRARY_CATEGORIES,
231
+ loadBuiltinLayoutLibrary
232
+ } from '../configs/layoutLibrary'
228
233
 
229
234
  const presetPopoverVisible = ref(false)
230
- const presetActiveTab = ref<'templates' | 'layouts'>(isTemplateEnabled.value ? 'templates' : 'layouts')
235
+ const presetActiveTab = ref<'templates' | 'layout-library' | 'layouts'>(isTemplateEnabled.value ? 'templates' : 'layout-library')
231
236
  const templateSearchQuery = ref('')
232
237
  const selectedTemplateDeck = ref<SlideTemplateItem | null>(null)
233
238
  const loadingTemplateId = ref<string | null>(null)
234
239
  const templateJsonInputRef = ref<HTMLInputElement | null>(null)
240
+ const templateBodyRef = ref<HTMLElement | null>(null)
241
+
242
+ function resetTemplateBodyScroll() {
243
+ if (templateBodyRef.value) {
244
+ templateBodyRef.value.scrollTop = 0
245
+ }
246
+ nextTick(() => {
247
+ if (templateBodyRef.value) {
248
+ templateBodyRef.value.scrollTop = 0
249
+ }
250
+ })
251
+ }
252
+
253
+ watch(selectedTemplateDeck, () => {
254
+ resetTemplateBodyScroll()
255
+ })
256
+
257
+ // 版式库 (Layout Library) 状态与内置开箱即用加载
258
+ const layoutLibraryDeck = shallowRef<SlideTemplateItem | null>(null)
259
+ const layoutLibrarySlides = shallowRef<any[]>([])
260
+ const layoutLibraryCategories = ref<string[]>([...DEFAULT_LAYOUT_LIBRARY_CATEGORIES])
261
+ const activeLayoutLibraryCategory = ref<string>('all')
262
+ const layoutLibraryLoading = ref(false)
263
+ const layoutLibraryLoaded = ref(false)
264
+ const layoutLibraryVisibleCount = ref(24)
265
+ const layoutCategoryBarRef = ref<HTMLElement | null>(null)
266
+ const canScrollLayoutCatLeft = ref(false)
267
+ const canScrollLayoutCatRight = ref(true)
268
+ const layoutLibraryBodyRef = ref<HTMLElement | null>(null)
269
+
270
+ function updateLayoutCategoryScrollState() {
271
+ const el = layoutCategoryBarRef.value
272
+ if (!el) return
273
+ canScrollLayoutCatLeft.value = el.scrollLeft > 4
274
+ canScrollLayoutCatRight.value = el.scrollLeft + el.clientWidth < el.scrollWidth - 4
275
+ }
276
+
277
+ function scrollLayoutCategoryBar(delta: number) {
278
+ const el = layoutCategoryBarRef.value
279
+ if (!el) return
280
+ el.scrollBy({ left: delta, behavior: 'smooth' })
281
+ setTimeout(updateLayoutCategoryScrollState, 220)
282
+ }
283
+
284
+ function selectLayoutLibraryCategory(cat: string) {
285
+ activeLayoutLibraryCategory.value = cat
286
+ layoutLibraryVisibleCount.value = 24
287
+ if (layoutLibraryBodyRef.value) {
288
+ layoutLibraryBodyRef.value.scrollTop = 0
289
+ }
290
+ }
291
+
292
+ function handleLayoutLibraryScroll(e: Event) {
293
+ const el = e.target as HTMLElement
294
+ if (!el) return
295
+ if (el.scrollTop + el.clientHeight >= el.scrollHeight - 240) {
296
+ if (layoutLibraryVisibleCount.value < filteredLayoutLibrarySlides.value.length) {
297
+ layoutLibraryVisibleCount.value = Math.min(
298
+ filteredLayoutLibrarySlides.value.length,
299
+ layoutLibraryVisibleCount.value + 24
300
+ )
301
+ }
302
+ }
303
+ }
304
+
305
+ async function ensureLayoutLibraryLoaded() {
306
+ if (layoutLibraryLoaded.value || layoutLibraryLoading.value) return
307
+ layoutLibraryLoading.value = true
308
+ try {
309
+ const { deck, slides, categories } = await loadBuiltinLayoutLibrary()
310
+ layoutLibraryCategories.value = categories
311
+ layoutLibraryDeck.value = deck
312
+ layoutLibrarySlides.value = slides
313
+ layoutLibraryLoaded.value = true
314
+ nextTick(updateLayoutCategoryScrollState)
315
+ } catch (err: any) {
316
+ console.warn('[layoutLibrary] 加载内置版式库失败:', err)
317
+ } finally {
318
+ layoutLibraryLoading.value = false
319
+ }
320
+ }
321
+
322
+ const filteredLayoutLibrarySlides = computed(() => {
323
+ const cat = activeLayoutLibraryCategory.value
324
+ if (!cat || cat === 'all') return layoutLibrarySlides.value
325
+ return layoutLibrarySlides.value.filter((s: any) => s.category === cat)
326
+ })
327
+
328
+ const activeLayoutLibraryRecipe = computed(() => {
329
+ // 订阅当前选中幻灯片、母版与版本变化,确保切换页面或切换主题时版式库实时重着色
330
+ void activeIndex.value
331
+ void activeSlideVersion.value
332
+ void isMasterEditingView.value
333
+ void activeMasterId.value
334
+ return getActiveSlideThemeRecipe(activeSlide.value)
335
+ })
336
+
337
+ const themedLayoutLibraryCache = new Map<string, any>()
338
+
339
+ function applyThemeRecipeToLayoutSlide(rawSlide: any, recipe: any): any {
340
+ const cloned = cloneSlideForInsertion(rawSlide)
341
+ cloned.id = rawSlide.id
342
+ cloned.name = rawSlide.name
343
+ cloned.category = rawSlide.category
344
+ cloned.title = rawSlide.title
345
+
346
+ if (!recipe) return cloned
347
+
348
+ if (recipe.backgroundColor) {
349
+ cloned.background = recipe.backgroundColor
350
+ cloned.bgType = 'color'
351
+ }
352
+ cloned.themeId = recipe.id
353
+ cloned.themeName = recipe.name
354
+ if (Array.isArray(recipe.styleColors)) {
355
+ cloned.themeColors = [...recipe.styleColors]
356
+ }
357
+
358
+ if (Array.isArray(cloned.elements)) {
359
+ recolorElementsWithRecipe(cloned.elements, recipe)
360
+
361
+ // 保障位于实心色块(如流程卡片、按钮背景)之上的独立文本元素具备高对比度可读性
362
+ const solidShapes = cloned.elements.filter((el: any) => {
363
+ if (el?.type !== 'shape') return false
364
+ const f = el.style?.fill || el.fill
365
+ return typeof f === 'string' && f !== 'none' && f !== 'transparent'
366
+ })
367
+ if (solidShapes.length > 0) {
368
+ for (const el of cloned.elements) {
369
+ if (el?.type !== 'text') continue
370
+ const cx = (parseFloat(el.style?.left ?? el.left) || 0) + (parseFloat(el.style?.width ?? el.width) || 0) / 2
371
+ const cy = (parseFloat(el.style?.top ?? el.top) || 0) + (parseFloat(el.style?.height ?? el.height) || 0) / 2
372
+ const hostShape = solidShapes.find((sh: any) => {
373
+ const sx = parseFloat(sh.style?.left ?? sh.left) || 0
374
+ const sy = parseFloat(sh.style?.top ?? sh.top) || 0
375
+ const sw = parseFloat(sh.style?.width ?? sh.width) || 0
376
+ const shH = parseFloat(sh.style?.height ?? sh.height) || 0
377
+ return cx >= sx && cx <= sx + sw && cy >= sy && cy <= sy + shH
378
+ })
379
+ if (hostShape) {
380
+ const shFill = hostShape.style?.fill || hostShape.fill
381
+ const txtColor = el.style?.color || el.color
382
+ if (typeof shFill === 'string' && typeof txtColor === 'string') {
383
+ if (isColorDarkForMaster(shFill) === isColorDarkForMaster(txtColor)) {
384
+ const contrastColor = recipe.shape?.textColor || (isColorDarkForMaster(shFill) ? '#ffffff' : '#0f172a')
385
+ el.color = contrastColor
386
+ el.textColor = contrastColor
387
+ if (el.style) {
388
+ el.style.color = contrastColor
389
+ el.style.textColor = contrastColor
390
+ }
391
+ }
392
+ }
393
+ }
394
+ }
395
+ }
396
+ }
397
+
398
+ return cloned
399
+ }
400
+
401
+ const visibleLayoutLibrarySlides = computed(() => {
402
+ const recipe = activeLayoutLibraryRecipe.value
403
+ const recipeKey = recipe
404
+ ? `${recipe.id}_${recipe.backgroundColor}_${recipe.textStyles?.title?.color}_${recipe.textStyles?.headline?.color}_${recipe.textStyles?.normalText?.color}_${recipe.shape?.fillColor}`
405
+ : 'default'
406
+ if (themedLayoutLibraryCache.size > 400) {
407
+ themedLayoutLibraryCache.clear()
408
+ }
409
+ const slice = filteredLayoutLibrarySlides.value.slice(0, layoutLibraryVisibleCount.value)
410
+ return slice.map((rawSlide: any, idx: number) => {
411
+ const cacheKey = `${recipeKey}__${rawSlide.id || idx}`
412
+ const hit = themedLayoutLibraryCache.get(cacheKey)
413
+ if (hit) return hit
414
+ const themed = applyThemeRecipeToLayoutSlide(rawSlide, recipe)
415
+ themedLayoutLibraryCache.set(cacheKey, themed)
416
+ return themed
417
+ })
418
+ })
419
+
420
+ function insertLayoutLibrarySlide(slide: any, slideIdx: number) {
421
+ if (!slide) return
422
+ addHistorySnapshot()
423
+ const recipe = activeLayoutLibraryRecipe.value
424
+ const themedSlide = applyThemeRecipeToLayoutSlide(slide, recipe)
425
+ const cloned = cloneSlideForInsertion(themedSlide)
426
+ const curSlide = activeSlide.value
427
+ cloned.masterId = curSlide?.masterId || activeMasterId.value || slideMasters.value?.[0]?.id || 'master-default'
428
+ cloned.title = slide.name || (slide.title || '').replace(/^\[[^\]]+\]\s*/, '') || `版式 ${slideIdx + 1}`
429
+ const insertPos = Math.min(slides.value.length, Math.max(0, activeIndex.value + 1))
430
+ slides.value.splice(insertPos, 0, cloned)
431
+ activeIndex.value = insertPos
432
+ activeSlideVersion.value++
433
+ displaySlides.value = [...slides.value]
434
+ addHistorySnapshot()
435
+ presetPopoverVisible.value = false
436
+ notify(`已插入版式 "${cloned.title}"`)
437
+ }
235
438
 
236
439
  watch(isTemplateEnabled, (enabled) => {
237
- if (!enabled) {
238
- presetActiveTab.value = 'layouts'
440
+ if (!enabled && presetActiveTab.value === 'templates') {
441
+ presetActiveTab.value = 'layout-library'
239
442
  selectedTemplateDeck.value = null
240
443
  }
241
444
  }, { immediate: true })
242
445
 
243
446
  watch(presetPopoverVisible, (visible) => {
244
- if (visible && isTemplateEnabled.value) {
245
- ensureTemplatesFirstPageLoaded()
447
+ if (visible) {
448
+ if (isTemplateEnabled.value) {
449
+ ensureTemplatesFirstPageLoaded()
450
+ }
451
+ if (presetActiveTab.value === 'layout-library') {
452
+ ensureLayoutLibraryLoaded()
453
+ nextTick(updateLayoutCategoryScrollState)
454
+ }
246
455
  }
247
456
  })
248
457
 
@@ -255,10 +464,13 @@ const filteredSlideTemplates = computed(() => {
255
464
  )
256
465
  })
257
466
 
258
- function switchPresetTab(tab: 'templates' | 'layouts') {
467
+ function switchPresetTab(tab: 'templates' | 'layout-library' | 'layouts') {
259
468
  presetActiveTab.value = tab
260
469
  if (tab === 'templates') {
261
470
  selectedTemplateDeck.value = null
471
+ } else if (tab === 'layout-library') {
472
+ ensureLayoutLibraryLoaded()
473
+ nextTick(updateLayoutCategoryScrollState)
262
474
  }
263
475
  }
264
476
 
@@ -366,9 +578,10 @@ function ensureTemplateMasterForSlide(tpl: SlideTemplateItem, slide: any): strin
366
578
  const uid = Date.now().toString(36) + Math.random().toString(36).slice(2, 6)
367
579
  const newMasterId = `master-tpl-${uid}`
368
580
  const baseDefault = createDefaultSlideMasters(logicalWidth.value, logicalHeight.value)[0]
581
+ const slideRecipe = getActiveSlideThemeRecipe(slide)
369
582
  const dark = isSlideThemeDarkForMaster(slide)
370
- const titleColor = dark ? '#ffffff' : '#0f172a'
371
- const bodyColor = dark ? 'rgba(255, 255, 255, 0.85)' : '#64748b'
583
+ const titleColor = slideRecipe?.textStyles?.title?.color || (dark ? '#ffffff' : '#0f172a')
584
+ const bodyColor = slideRecipe?.textStyles?.normalText?.color || (dark ? 'rgba(255, 255, 255, 0.85)' : '#64748b')
372
585
  const borderColor = dark ? 'rgba(255, 255, 255, 0.45)' : '#cbd5e1'
373
586
 
374
587
  const clonedBg = typeof rawBg === 'object' && rawBg !== null ? JSON.parse(JSON.stringify(rawBg)) : rawBg
@@ -647,7 +860,9 @@ function getLayoutSvgElements(elements: any[]) {
647
860
  rawContentStr.includes('writing-mode:vertical')
648
861
  )
649
862
 
650
- const defaultWidthFallback = isVertical ? ((60 / baseW) * 100) : 0
863
+ const fontSize = parseFloat(el.style?.fontSize || el.fontSize || (isPlaceholder ? (el.placeholder?.type === 'title' ? '28' : '16') : '16')) || 16
864
+
865
+ const defaultWidthFallback = isVertical ? (((fontSize + 24) / baseW) * 100) : 0
651
866
  const rawLeft = parseDimValue(el.style?.left ?? el.left, baseW)
652
867
  const rawTop = parseDimValue(el.style?.top ?? el.top, baseH)
653
868
  const rawWidth = parseDimValue(el.style?.width ?? el.width, baseW, defaultWidthFallback)
@@ -674,12 +889,10 @@ function getLayoutSvgElements(elements: any[]) {
674
889
  ? `translate(${cx}, ${cy}) rotate(${rotate}) scale(${flipH ? -1 : 1}, ${flipV ? -1 : 1}) translate(${-cx}, ${-cy})`
675
890
  : undefined
676
891
 
677
- const fontSize = parseFloat(el.style?.fontSize || el.fontSize || (isPlaceholder ? (el.placeholder?.type === 'title' ? '28' : '16') : '16')) || 16
678
-
679
892
  // 缩略图字体按画布宽高真实几何比例计算,配合微缩优化保持和谐可辨识
680
893
  const baseRatio = 100 / baseW
681
894
  const rawSvgSize = fontSize * baseRatio
682
- const svgFontSize = +(Math.max(1.8, Math.min(4.5, rawSvgSize * 1.15))).toFixed(2)
895
+ const svgFontSize = +(Math.max(1.5, Math.min(7.5, rawSvgSize * 1.05))).toFixed(2)
683
896
 
684
897
  const rawSegments: { text: string; indent: number }[] = []
685
898
  if (rawContentStr) {
@@ -744,8 +957,10 @@ function getLayoutSvgElements(elements: any[]) {
744
957
  const lineHeight = +(svgFontSize * 1.25).toFixed(2)
745
958
  const lineCount = Math.min(parsedTextLines.length, 6)
746
959
  const totalTextH = lineCount * lineHeight
747
- let textStartY = +(y + svgFontSize * 1.05).toFixed(2)
748
- if (h > totalTextH && (el.style?.verticalAlign !== 'top' && el.style?.verticalAlign !== 'up')) {
960
+ const defaultVAlign = (!isVertical && isPlaceholder && h > svgFontSize * 3.8 && fontSize < 32) ? 'top' : 'middle'
961
+ const vAlign = el.verticalAlign || el.style?.verticalAlign || defaultVAlign
962
+ let textStartY = +(y + svgFontSize * 0.95).toFixed(2)
963
+ if (h > totalTextH && (vAlign !== 'top' && vAlign !== 'up')) {
749
964
  // 垂直居中起始 y 坐标
750
965
  textStartY = +(y + (h - totalTextH) / 2 + svgFontSize * 0.85).toFixed(2)
751
966
  }
@@ -773,7 +988,7 @@ function getLayoutSvgElements(elements: any[]) {
773
988
  const borderWidth = isPlaceholder ? 1 : (getElementBorderWidth(el) || (el.style?.borderWidth ? parseFloat(el.style.borderWidth) : (el.borderWidth ? parseFloat(el.borderWidth) : 0)))
774
989
  const hasBorderGrad = hasElementBorderGradient(el)
775
990
  const borderColor = isPlaceholder ? '#cbd5e1' : ((!hasBorderGrad && borderWidth <= 0) ? 'none' : (getElementBorderColor(el) || parseColorString(el.style?.borderColor || el.borderColor, 'none')))
776
- const textAlign = el.style?.textAlign || el.textAlign || (isTitle && !isVertical ? 'center' : 'left')
991
+ const textAlign = el.style?.textAlign || el.textAlign || 'left'
777
992
 
778
993
  let shapePath = ''
779
994
  let shapeViewBox: [number, number] = [200, 200]
@@ -1065,6 +1280,14 @@ const addSlideWithLayout = (layoutId: string) => {
1065
1280
  if (isPh) {
1066
1281
  if (cloned.content) cloned.content = convertPrompt(cloned.content)
1067
1282
  if (cloned.text && typeof cloned.text === 'string') cloned.text = convertPrompt(cloned.text)
1283
+ if (cloned.type === 'text' && cloned.style) {
1284
+ const isVert = cloned.style.writingMode === 'vertical-rl' || cloned.style.writingMode === 'vertical-lr'
1285
+ const hPx = parseFloat(cloned.style.height || cloned.height || '0') || 0
1286
+ const fsPx = parseFloat(cloned.style.fontSize || cloned.fontSize || '16') || 16
1287
+ if (!isVert && !cloned.style.verticalAlign && hPx > 150 && fsPx < 34) {
1288
+ cloned.style.verticalAlign = 'top'
1289
+ }
1290
+ }
1068
1291
  return {
1069
1292
  ...cloned,
1070
1293
  id: 'el_' + Date.now().toString(36) + Math.random().toString(36).substring(2, 6),
@@ -1447,7 +1670,7 @@ const thumbMasterCache = new WeakMap<object, { masterKey: string; result: any[]
1447
1670
 
1448
1671
  function getEffectiveMasterElements(slide: any) {
1449
1672
  if (!slide) return []
1450
- const curKey = `${slide.masterId || ''}_${slide.layoutId || ''}_${slide.showMasterElements !== false}_${slideMasters.value?.length || 0}`
1673
+ const curKey = `${slide.masterId || ''}_${slide.layoutId || ''}_${slide.themeId || ''}_${slide.showMasterElements !== false}_${slideMasters.value?.length || 0}_${activeSlideVersion.value}`
1451
1674
  const cached = thumbMasterCache.get(slide)
1452
1675
  if (cached && cached.masterKey === curKey) {
1453
1676
  return cached.result
@@ -2005,6 +2228,16 @@ onUnmounted(() => {
2005
2228
  })
2006
2229
  const masterGroupedLayouts = computed(() => {
2007
2230
  const masters = slideMasters.value || []
2231
+ const normalizePreviewPrompt = (content: string) => {
2232
+ if (typeof content !== 'string') return content
2233
+ return content
2234
+ .replace(/单击此处编辑母版标题样式/g, '单击此处添加标题')
2235
+ .replace(/单击此处编辑母版副标题样式/g, '单击此处添加副标题')
2236
+ .replace(/•\s*编辑母版文本样式 第一级/g, '• 单击此处添加文本')
2237
+ .replace(/•\s*编辑母版文本样式 第二级/g, '')
2238
+ .replace(/<br\s*\/?>&nbsp;&nbsp;/g, '')
2239
+ .replace(/单击此处编辑节标题样式/g, '单击此处添加节标题')
2240
+ }
2008
2241
  return masters.map(master => ({
2009
2242
  id: master.id,
2010
2243
  name: master.name || '默认母版',
@@ -2021,6 +2254,14 @@ const masterGroupedLayouts = computed(() => {
2021
2254
  if (el.id && seenIds.has(el.id)) return false
2022
2255
  if (el.id) seenIds.add(el.id)
2023
2256
  return true
2257
+ }).map((el: any) => {
2258
+ if (el.type === 'text' && typeof el.content === 'string') {
2259
+ return {
2260
+ ...el,
2261
+ content: normalizePreviewPrompt(el.content)
2262
+ }
2263
+ }
2264
+ return el
2024
2265
  })
2025
2266
  return {
2026
2267
  id: layout.id,
@@ -2204,14 +2445,19 @@ const masterGroupedLayouts = computed(() => {
2204
2445
  v-for="(lineObj, lIdx) in item.parsedTextLines.slice(0, 6)"
2205
2446
  :key="lIdx"
2206
2447
  :x="item.isVertical
2207
- ? (item.x + item.w * 0.5)
2448
+ ? (item.x + item.w * 0.5 - (lIdx - (Math.min(item.parsedTextLines.length, 6) - 1) / 2) * item.lineHeight)
2208
2449
  : (item.textAlign === 'center' || item.w < 15
2209
2450
  ? (item.x + item.w * 0.5)
2210
2451
  : (item.textAlign === 'right'
2211
2452
  ? (item.x + item.w - 1)
2212
2453
  : (item.x + (lineObj.indent || 0) * 2.5 + 1)))"
2213
- :y="item.textStartY + lIdx * item.lineHeight"
2214
- :text-anchor="item.isVertical ? 'middle' : (item.textAlign === 'center' || item.w < 15 ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
2454
+ :y="item.isVertical
2455
+ ? (item.textAlign === 'center' ? item.yCenter : (item.textAlign === 'right' ? (item.y + item.h - 1.2) : (item.y + 1.2)))
2456
+ : (item.textStartY + lIdx * item.lineHeight)"
2457
+ :text-anchor="item.isVertical
2458
+ ? (item.textAlign === 'center' ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))
2459
+ : (item.textAlign === 'center' || item.w < 15 ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
2460
+ :dominant-baseline="item.isVertical ? 'central' : undefined"
2215
2461
  :fill="item.isPlaceholder ? '#94a3b8' : (item.color || '#334155')"
2216
2462
  :font-size="item.svgFontSize"
2217
2463
  font-family="sans-serif"
@@ -2229,9 +2475,12 @@ const masterGroupedLayouts = computed(() => {
2229
2475
  ? item.x + item.w - 1
2230
2476
  : item.x + 1))"
2231
2477
  :y="item.isVertical
2232
- ? item.y + item.svgFontSize * 1.2
2478
+ ? (item.textAlign === 'center' ? item.yCenter : (item.textAlign === 'right' ? (item.y + item.h - 1.2) : (item.y + 1.2)))
2233
2479
  : (item.textStartY || Math.min(thumbSvgHeight - 1, item.y + item.h * 0.5 + item.svgFontSize * 0.35))"
2234
- :text-anchor="item.isVertical ? 'middle' : (item.textAlign === 'center' || item.w < 15 ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
2480
+ :text-anchor="item.isVertical
2481
+ ? (item.textAlign === 'center' ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))
2482
+ : (item.textAlign === 'center' || item.w < 15 ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
2483
+ :dominant-baseline="item.isVertical ? 'central' : undefined"
2235
2484
  :fill="item.isPlaceholder ? '#94a3b8' : (item.color || '#334155')"
2236
2485
  :font-size="item.svgFontSize"
2237
2486
  font-family="sans-serif"
@@ -2426,14 +2675,19 @@ const masterGroupedLayouts = computed(() => {
2426
2675
  v-for="(lineObj, lIdx) in item.parsedTextLines.slice(0, 6)"
2427
2676
  :key="lIdx"
2428
2677
  :x="item.isVertical
2429
- ? (item.x + item.w * 0.5)
2678
+ ? (item.x + item.w * 0.5 - (lIdx - (Math.min(item.parsedTextLines.length, 6) - 1) / 2) * item.lineHeight)
2430
2679
  : (item.textAlign === 'center' || item.w < 15
2431
2680
  ? (item.x + item.w * 0.5)
2432
2681
  : (item.textAlign === 'right'
2433
2682
  ? (item.x + item.w - 1)
2434
2683
  : (item.x + (lineObj.indent || 0) * 2.5 + 1)))"
2435
- :y="item.textStartY + lIdx * item.lineHeight"
2436
- :text-anchor="item.isVertical ? 'middle' : (item.textAlign === 'center' || item.w < 15 ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
2684
+ :y="item.isVertical
2685
+ ? (item.textAlign === 'center' ? item.yCenter : (item.textAlign === 'right' ? (item.y + item.h - 1.2) : (item.y + 1.2)))
2686
+ : (item.textStartY + lIdx * item.lineHeight)"
2687
+ :text-anchor="item.isVertical
2688
+ ? (item.textAlign === 'center' ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))
2689
+ : (item.textAlign === 'center' || item.w < 15 ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
2690
+ :dominant-baseline="item.isVertical ? 'central' : undefined"
2437
2691
  :fill="item.isPlaceholder ? '#94a3b8' : (item.color || '#334155')"
2438
2692
  :font-size="item.svgFontSize"
2439
2693
  font-family="sans-serif"
@@ -2451,9 +2705,12 @@ const masterGroupedLayouts = computed(() => {
2451
2705
  ? item.x + item.w - 1
2452
2706
  : item.x + 1))"
2453
2707
  :y="item.isVertical
2454
- ? item.y + item.svgFontSize * 1.2
2708
+ ? (item.textAlign === 'center' ? item.yCenter : (item.textAlign === 'right' ? (item.y + item.h - 1.2) : (item.y + 1.2)))
2455
2709
  : (item.textStartY || Math.min(thumbSvgHeight - 1, item.y + item.h * 0.5 + item.svgFontSize * 0.35))"
2456
- :text-anchor="item.isVertical ? 'middle' : (item.textAlign === 'center' || item.w < 15 ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
2710
+ :text-anchor="item.isVertical
2711
+ ? (item.textAlign === 'center' ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))
2712
+ : (item.textAlign === 'center' || item.w < 15 ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
2713
+ :dominant-baseline="item.isVertical ? 'central' : undefined"
2457
2714
  :fill="item.isPlaceholder ? '#94a3b8' : (item.color || '#334155')"
2458
2715
  :font-size="item.svgFontSize"
2459
2716
  font-family="sans-serif"
@@ -2546,6 +2803,13 @@ const masterGroupedLayouts = computed(() => {
2546
2803
  >
2547
2804
  <span>模板</span>
2548
2805
  </div>
2806
+ <div
2807
+ class="preset-layout-tab"
2808
+ :class="{ 'is-active': presetActiveTab === 'layout-library' }"
2809
+ @click="switchPresetTab('layout-library')"
2810
+ >
2811
+ <span>版式库</span>
2812
+ </div>
2549
2813
  <div
2550
2814
  class="preset-layout-tab"
2551
2815
  :class="{ 'is-active': presetActiveTab === 'layouts' }"
@@ -2571,8 +2835,60 @@ const masterGroupedLayouts = computed(() => {
2571
2835
  </button>
2572
2836
  </div>
2573
2837
 
2838
+ <!-- 版式库分类过滤栏 (参考 Pitch Layouts 顶部分类条) -->
2839
+ <div v-if="presetActiveTab === 'layout-library'" class="preset-layout-category-bar-wrap">
2840
+ <button
2841
+ v-show="canScrollLayoutCatLeft"
2842
+ type="button"
2843
+ class="preset-cat-scroll-btn is-left"
2844
+ title="向左滚动分类"
2845
+ @click.stop="scrollLayoutCategoryBar(-180)"
2846
+ >
2847
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2848
+ <polyline points="15 18 9 12 15 6" />
2849
+ </svg>
2850
+ </button>
2851
+
2852
+ <div
2853
+ ref="layoutCategoryBarRef"
2854
+ class="preset-layout-category-bar"
2855
+ @scroll="updateLayoutCategoryScrollState"
2856
+ >
2857
+ <button
2858
+ type="button"
2859
+ class="preset-layout-category-item"
2860
+ :class="{ 'is-active': activeLayoutLibraryCategory === 'all' }"
2861
+ @click="selectLayoutLibraryCategory('all')"
2862
+ >
2863
+ 全部
2864
+ </button>
2865
+ <button
2866
+ v-for="cat in layoutLibraryCategories"
2867
+ :key="cat"
2868
+ type="button"
2869
+ class="preset-layout-category-item"
2870
+ :class="{ 'is-active': activeLayoutLibraryCategory === cat }"
2871
+ @click="selectLayoutLibraryCategory(cat)"
2872
+ >
2873
+ {{ cat }}
2874
+ </button>
2875
+ </div>
2876
+
2877
+ <button
2878
+ v-show="canScrollLayoutCatRight"
2879
+ type="button"
2880
+ class="preset-cat-scroll-btn is-right"
2881
+ title="向右滚动分类"
2882
+ @click.stop="scrollLayoutCategoryBar(180)"
2883
+ >
2884
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2885
+ <polyline points="9 18 15 12 9 6" />
2886
+ </svg>
2887
+ </button>
2888
+ </div>
2889
+
2574
2890
  <!-- TAB 1: 模板 (Templates) -->
2575
- <div v-if="presetActiveTab === 'templates'" class="preset-layout-body preset-template-body">
2891
+ <div v-if="presetActiveTab === 'templates'" ref="templateBodyRef" class="preset-layout-body preset-template-body">
2576
2892
  <!-- 第一级:模板列表视图 (显示模板封面与名称) -->
2577
2893
  <template v-if="!selectedTemplateDeck">
2578
2894
  <div class="preset-template-search-box">
@@ -2684,7 +3000,43 @@ const masterGroupedLayouts = computed(() => {
2684
3000
  </template>
2685
3001
  </div>
2686
3002
 
2687
- <!-- TAB 2: 版式 (Layouts) -->
3003
+ <!-- TAB 2: 版式库 (Layout Library) -->
3004
+ <div
3005
+ v-else-if="presetActiveTab === 'layout-library'"
3006
+ ref="layoutLibraryBodyRef"
3007
+ class="preset-layout-body preset-layout-library-body"
3008
+ @scroll="handleLayoutLibraryScroll"
3009
+ >
3010
+ <div v-if="layoutLibraryLoading" class="preset-template-empty">
3011
+ 正在加载版式库...
3012
+ </div>
3013
+ <div v-else-if="visibleLayoutLibrarySlides.length > 0" class="preset-layout-grid">
3014
+ <div
3015
+ v-for="(lSlide, lIdx) in visibleLayoutLibrarySlides"
3016
+ :key="lSlide.id || lIdx"
3017
+ class="preset-layout-item preset-template-slide-item"
3018
+ @click="insertLayoutLibrarySlide(lSlide, lIdx)"
3019
+ >
3020
+ <div
3021
+ class="preset-layout-thumb preset-template-slide-thumb"
3022
+ :style="{ background: getSlideBackgroundCss(lSlide.background || '#ffffff') }"
3023
+ >
3024
+ <LayoutThumbSvg
3025
+ :elements="lSlide.elements || []"
3026
+ :background="lSlide.background || '#ffffff'"
3027
+ />
3028
+ </div>
3029
+ <span class="preset-layout-name" :title="lSlide.name || lSlide.title">
3030
+ {{ lSlide.name || lSlide.title }}
3031
+ </span>
3032
+ </div>
3033
+ </div>
3034
+ <div v-else class="preset-template-empty">
3035
+ 暂无该分类下的版式
3036
+ </div>
3037
+ </div>
3038
+
3039
+ <!-- TAB 3: 版式 (Layouts) -->
2688
3040
  <div v-else class="preset-layout-body">
2689
3041
  <div v-for="masterGroup in masterGroupedLayouts" :key="masterGroup.id" class="preset-layout-master-group">
2690
3042
  <div v-if="masterGroupedLayouts.length > 1" class="preset-layout-section-name" :title="masterGroup.name">{{ masterGroup.name }}</div>
@@ -292,6 +292,7 @@ watch(selectedElementId, (newId) => {
292
292
 
293
293
 
294
294
  const {
295
+ chartActiveTab,
295
296
  chartDataDialogVisible,
296
297
  tempChartDataText,
297
298
  tempChartLabels,
@@ -1400,6 +1401,30 @@ function handleUndockToPopover() {
1400
1401
  </div>
1401
1402
  </div>
1402
1403
 
1404
+ <!-- Sub tabs for Chart: 图表 vs 数据 -->
1405
+ <div
1406
+ v-if="activeTab === 'format' && selectedElement && selectedElementIds.length <= 1 && selectedElement.type === 'chart'"
1407
+ style="display: flex; height: 38px; border-bottom: 1px solid #edf0f3; padding: 0 16px; align-items: center; gap: 24px; background: #ffffff;">
1408
+ <div
1409
+ style="font-size: 13px; font-weight: 600; cursor: pointer; height: 100%; display: flex; align-items: center; position: relative; transition: color 0.15s ease;"
1410
+ :style="chartActiveTab === 'chart' ? { color: '#2563eb' } : { color: '#64748b' }"
1411
+ @click="chartActiveTab = 'chart'">
1412
+ 图表
1413
+ <div v-if="chartActiveTab === 'chart'"
1414
+ style="position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: #2563eb; border-radius: 2px 2px 0 0;">
1415
+ </div>
1416
+ </div>
1417
+ <div
1418
+ style="font-size: 13px; font-weight: 600; cursor: pointer; height: 100%; display: flex; align-items: center; position: relative; transition: color 0.15s ease;"
1419
+ :style="chartActiveTab === 'data' ? { color: '#2563eb' } : { color: '#64748b' }"
1420
+ @click="chartActiveTab = 'data'">
1421
+ 数据
1422
+ <div v-if="chartActiveTab === 'data'"
1423
+ style="position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: #2563eb; border-radius: 2px 2px 0 0;">
1424
+ </div>
1425
+ </div>
1426
+ </div>
1427
+
1403
1428
  <!-- Sub tabs for Slide Design/Format: Global vs Theme vs Layout -->
1404
1429
  <div v-if="activeTab === 'design' && !isMasterEditingView"
1405
1430
  style="display: flex; height: 38px; border-bottom: 1px solid var(--border-color); padding: 0 16px; align-items: center; gap: 20px; background: var(--bg-surface);">
@@ -1774,6 +1799,18 @@ function handleUndockToPopover() {
1774
1799
  @update:shape-pattern-bg="shapePatternBg = $event"
1775
1800
  @handle-shape-pattern-upload="handleShapePatternUpload"
1776
1801
  @clear-shape-pattern-fill="clearShapePatternFill"
1802
+ :chart-active-tab="chartActiveTab"
1803
+ v-model:labels="tempChartLabels"
1804
+ v-model:datasets="tempChartDatasets"
1805
+ v-model:csv-text="tempChartDataText"
1806
+ v-model:edit-mode="chartEditMode"
1807
+ @add-row="addChartRow"
1808
+ @remove-row="removeChartRow"
1809
+ @add-series="addChartSeries"
1810
+ @remove-series="removeChartSeries"
1811
+ @transpose="transposeChartData"
1812
+ @sync-from-table="syncStructuredToText"
1813
+ @sync-from-csv="syncTextToStructured"
1777
1814
  @update:border-alpha="borderAlpha = $event"
1778
1815
  @update:shadow-alpha="shadowAlpha = $event"
1779
1816
  @update:is-border-enabled="enableBorder = $event"
@@ -2219,8 +2256,9 @@ function handleUndockToPopover() {
2219
2256
 
2220
2257
 
2221
2258
 
2222
- <!-- Chart Data Editor Dialog (方案二:左表右图双栏实时预览版) -->
2259
+ <!-- Chart Data Editor Dialog (已抽离为右侧栏「编辑数据」独立 Tab,此处弹窗隐藏保留不调用) -->
2223
2260
  <ChartDataEditorDialog
2261
+ v-if="false"
2224
2262
  v-model:visible="chartDataDialogVisible"
2225
2263
  v-model:labels="tempChartLabels"
2226
2264
  v-model:datasets="tempChartDatasets"