jvs-ppt-ui 0.0.30 → 0.0.33

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 (31) hide show
  1. package/README.md +152 -0
  2. package/dist/lib/jvs-ppt-ui.es.js +39270 -34665
  3. package/dist/lib/jvs-ppt-ui.umd.js +141 -114
  4. package/dist/lib/style.css +1 -1
  5. package/package.json +2 -1
  6. package/src/components/CanvasArea.vue +9 -1
  7. package/src/components/ChartTypeSelector.vue +69 -29
  8. package/src/components/Header.vue +228 -29
  9. package/src/components/PitchImportDialog.vue +482 -0
  10. package/src/components/PptEditor.vue +53 -1
  11. package/src/components/SidebarLeft.vue +367 -41
  12. package/src/components/SidebarRight.vue +75 -35
  13. package/src/components/StyleBuilderDialog.vue +276 -105
  14. package/src/components/SvgChart.vue +1242 -833
  15. package/src/components/canvas/elements/CanvasGroupElement.vue +16 -2
  16. package/src/components/canvas/elements/CanvasMediaElement.vue +5 -3
  17. package/src/components/canvas/elements/CanvasShapeElement.vue +6 -4
  18. package/src/components/sidebar/dialogs/ChartDataEditorDialog.vue +1040 -0
  19. package/src/components/sidebar/panels/LayoutThumbSvg.vue +9 -6
  20. package/src/components/sidebar/panels/SidebarChartFormatPanel.vue +1479 -641
  21. package/src/components/sidebar/panels/SidebarDesignPanel.vue +32 -0
  22. package/src/composables/presetThemes.ts +49 -1
  23. package/src/composables/sidebar/useSidebarChart.ts +357 -194
  24. package/src/composables/useSlides.ts +110 -22
  25. package/src/configs/slideTemplates.ts +1001 -0
  26. package/src/style.css +267 -4
  27. package/src/types/index.ts +37 -1
  28. package/src/utils/canvas/elementStyles.ts +55 -20
  29. package/src/utils/muxHlsToMp4.ts +569 -0
  30. package/src/utils/pitchConverter.ts +1725 -0
  31. package/dist/lib/templates/index.json +0 -5
@@ -14,6 +14,7 @@ import {
14
14
  } from '../utils/textTypes'
15
15
  import { applyGroupGeometryFlip } from '../utils/groupFlip'
16
16
  import { getFontVariants, getFontVariantStyle } from '../configs/fonts'
17
+ import { setCustomTemplates, customTemplateBaseUrl, type SlideTemplateInput } from '../configs/slideTemplates'
17
18
  import type { CustomUploadHandler, UploadResourceContext, UploadResourceType } from '../types'
18
19
 
19
20
  export type { SlideTextType }
@@ -87,7 +88,7 @@ export interface SlideElement {
87
88
  curve?: [number, number]
88
89
  cubic?: [[number, number], [number, number]]
89
90
  customControlPoints?: boolean
90
- chartType?: 'bar' | 'horizontal-bar' | 'line' | 'area' | 'scatter' | 'pie' | 'donut' | 'radar'
91
+ chartType?: 'bar' | 'percent-bar' | 'stacked-bar' | 'horizontal-bar' | 'stacked-horizontal-bar' | 'line' | 'compare-line' | 'step-line' | 'area' | 'stacked-area' | 'scatter' | 'pie' | 'donut' | 'rose-pie' | 'rose-donut' | 'radar' | string
91
92
  showAxes?: boolean
92
93
  showAxisTitles?: boolean
93
94
  showTitle?: boolean
@@ -302,6 +303,7 @@ export interface PresetTheme {
302
303
 
303
304
  import { presetThemes, builtinStyleRecipes, type StyleRecipe } from './presetThemes'
304
305
  import { generateMonoPalette } from '../utils/palette'
306
+ import { isPitchTemplateData, convertPitchTemplateToDeck, stringifyDeckToBlob } from '../utils/pitchConverter'
305
307
 
306
308
  // Global reactive states
307
309
  const presentationTitle = ref('未命名演示文稿')
@@ -414,6 +416,31 @@ function setMaterialConfig(config?: {
414
416
  }
415
417
  }
416
418
 
419
+ // 模板库配置状态(控制左侧“更多布局”中是否启用“模板”库及传入自定义模板)
420
+ const enableTemplate = ref<boolean>(true)
421
+ const isTemplateEnabled = computed(() => enableTemplate.value !== false)
422
+
423
+ function setTemplateConfig(config?: {
424
+ enable?: boolean
425
+ templates?: SlideTemplateInput[]
426
+ baseUrl?: string
427
+ replaceBuiltin?: boolean
428
+ }) {
429
+ if (!config) return
430
+ if (config.enable !== undefined) {
431
+ enableTemplate.value = Boolean(config.enable)
432
+ }
433
+ if (config.baseUrl !== undefined) {
434
+ customTemplateBaseUrl.value = (config.baseUrl || '').trim()
435
+ }
436
+ if (config.templates !== undefined && Array.isArray(config.templates)) {
437
+ setCustomTemplates(config.templates, {
438
+ replaceBuiltin: config.replaceBuiltin !== undefined ? config.replaceBuiltin : true,
439
+ baseUrl: config.baseUrl
440
+ })
441
+ }
442
+ }
443
+
417
444
  /**
418
445
  * 保存幻灯片到素材库 API
419
446
  */
@@ -1959,10 +1986,12 @@ function applyStyleRecipeToSlides(
1959
1986
  effectiveMode = mode
1960
1987
  }
1961
1988
 
1962
- // 同步更新内置配方库中的对应项
1989
+ // 同步更新内置配方库中的对应项(若为新增自定义主题则追加到配方库)
1963
1990
  const recipeIdx = builtinStyleRecipes.findIndex(r => r.id === recipe.id)
1964
1991
  if (recipeIdx >= 0) {
1965
1992
  builtinStyleRecipes[recipeIdx] = JSON.parse(JSON.stringify(recipe))
1993
+ } else {
1994
+ builtinStyleRecipes.push(JSON.parse(JSON.stringify(recipe)))
1966
1995
  }
1967
1996
 
1968
1997
  // 🌟 母版编辑视图下直接应用到母版与版式
@@ -5734,10 +5763,10 @@ function exportSlides(options?: { excludeImages?: boolean; clearContent?: boolea
5734
5763
  const { excludeImages = false, clearContent = false } = options || {}
5735
5764
  notify(excludeImages || clearContent ? '正在导出纯版式 JSON 模板...' : '正在导出幻灯片 JSON 配置...')
5736
5765
 
5737
- const rawSlides = JSON.parse(JSON.stringify(slides.value))
5766
+ const rawSlides = slides.value || []
5738
5767
 
5739
5768
  const processedSlides = rawSlides.map((slide: any) => {
5740
- let elements = slide.elements || []
5769
+ let elements = Array.isArray(slide.elements) ? [...slide.elements] : []
5741
5770
 
5742
5771
  if (excludeImages) {
5743
5772
  elements = elements.filter((el: any) => el.type !== 'image' && el.type !== 'audio' && el.type !== 'video')
@@ -5773,8 +5802,12 @@ function exportSlides(options?: { excludeImages?: boolean; clearContent?: boolea
5773
5802
  }
5774
5803
 
5775
5804
  let background = slide.background
5776
- if (excludeImages && background && background.type === 'image') {
5777
- background = { type: 'solid', color: '#ffffff' }
5805
+ if (excludeImages && background) {
5806
+ if (typeof background === 'object' && background.type === 'image') {
5807
+ background = { type: 'solid', color: '#ffffff' }
5808
+ } else if (typeof background === 'string' && background.includes('url(')) {
5809
+ background = '#ffffff'
5810
+ }
5778
5811
  }
5779
5812
 
5780
5813
  return {
@@ -5785,24 +5818,32 @@ function exportSlides(options?: { excludeImages?: boolean; clearContent?: boolea
5785
5818
  })
5786
5819
 
5787
5820
  // 🌟 导出母版内容:确保导出的完整 JSON 包含母版与其全部版式定义
5788
- const rawMasters = JSON.parse(JSON.stringify(slideMasters.value || []))
5821
+ const rawMasters = slideMasters.value || []
5789
5822
  const processedMasters = rawMasters.map((master: any) => {
5790
- let elements = master.elements || []
5823
+ let elements = Array.isArray(master.elements) ? [...master.elements] : []
5791
5824
  if (excludeImages) {
5792
5825
  elements = elements.filter((el: any) => el.type !== 'image' && el.type !== 'audio' && el.type !== 'video')
5793
5826
  }
5794
5827
  let background = master.background
5795
- if (excludeImages && background && background.type === 'image') {
5796
- background = { type: 'solid', color: '#ffffff' }
5828
+ if (excludeImages && background) {
5829
+ if (typeof background === 'object' && background.type === 'image') {
5830
+ background = { type: 'solid', color: '#ffffff' }
5831
+ } else if (typeof background === 'string' && background.includes('url(')) {
5832
+ background = '#ffffff'
5833
+ }
5797
5834
  }
5798
5835
  const layouts = (master.layouts || []).map((layout: any) => {
5799
- let lElements = layout.elements || []
5836
+ let lElements = Array.isArray(layout.elements) ? [...layout.elements] : []
5800
5837
  if (excludeImages) {
5801
5838
  lElements = lElements.filter((el: any) => el.type !== 'image' && el.type !== 'audio' && el.type !== 'video')
5802
5839
  }
5803
5840
  let lBg = layout.background
5804
- if (excludeImages && lBg && lBg.type === 'image') {
5805
- lBg = { type: 'solid', color: '#ffffff' }
5841
+ if (excludeImages && lBg) {
5842
+ if (typeof lBg === 'object' && lBg.type === 'image') {
5843
+ lBg = { type: 'solid', color: '#ffffff' }
5844
+ } else if (typeof lBg === 'string' && lBg.includes('url(')) {
5845
+ lBg = '#ffffff'
5846
+ }
5806
5847
  }
5807
5848
  return {
5808
5849
  ...layout,
@@ -5838,13 +5879,21 @@ function exportSlides(options?: { excludeImages?: boolean; clearContent?: boolea
5838
5879
  }
5839
5880
 
5840
5881
  const filenameSuffix = excludeImages || clearContent ? '-template' : ''
5841
- const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(json, null, 2))
5882
+ const blob = stringifyDeckToBlob(json)
5883
+ const blobUrl = URL.createObjectURL(blob)
5842
5884
  const downloadAnchor = document.createElement('a')
5843
- downloadAnchor.setAttribute("href", dataStr)
5844
- downloadAnchor.setAttribute("download", `${presentationTitle.value}${filenameSuffix}-${Date.now()}.json`)
5885
+ downloadAnchor.setAttribute('href', blobUrl)
5886
+ downloadAnchor.setAttribute('download', `${presentationTitle.value}${filenameSuffix}-${Date.now()}.json`)
5845
5887
  document.body.appendChild(downloadAnchor)
5846
5888
  downloadAnchor.click()
5847
5889
  downloadAnchor.remove()
5890
+ setTimeout(() => {
5891
+ try {
5892
+ URL.revokeObjectURL(blobUrl)
5893
+ } catch {
5894
+ // ignore
5895
+ }
5896
+ }, 60000)
5848
5897
  }
5849
5898
 
5850
5899
  function extractTextStyleFromHtml(html: string, defaultColor: string, defaultFont: string) {
@@ -8443,6 +8492,26 @@ function importSlides(newSlides: any) {
8443
8492
  revokeSlideBlobUrls(slides.value)
8444
8493
  }
8445
8494
 
8495
+ // 智能识别 Pitch Transit-JSON 模板数据并自动转换为本地 DeckData
8496
+ if (isPitchTemplateData(newSlides)) {
8497
+ const convertedPitchDeck = convertPitchTemplateToDeck(newSlides)
8498
+ return importSlides(convertedPitchDeck)
8499
+ }
8500
+
8501
+ // 若包含 styleRecipes(如 Pitch 转换器生成的自定义多主题配方),注册到 builtinStyleRecipes
8502
+ if (newSlides && typeof newSlides === 'object' && Array.isArray(newSlides.styleRecipes) && newSlides.styleRecipes.length > 0) {
8503
+ for (let i = newSlides.styleRecipes.length - 1; i >= 0; i--) {
8504
+ const recipe = newSlides.styleRecipes[i]
8505
+ if (!recipe || !recipe.id) continue
8506
+ const existingIdx = builtinStyleRecipes.findIndex(r => r.id === recipe.id)
8507
+ if (existingIdx !== -1) {
8508
+ builtinStyleRecipes[existingIdx] = recipe
8509
+ } else {
8510
+ builtinStyleRecipes.unshift(recipe)
8511
+ }
8512
+ }
8513
+ }
8514
+
8446
8515
  // 智能识别 raw PPTX JSON (如来自 jvs-pptxtojson 原生导出的 slides.json) 并代理给 PPT 解析器
8447
8516
  if (pptParserFn && newSlides && typeof newSlides === 'object' && Array.isArray(newSlides.slides) && newSlides.size) {
8448
8517
  const isRawPPTX = (() => {
@@ -9133,14 +9202,21 @@ async function uploadMediaResourcesInSlides(deckOrSlides: any): Promise<void> {
9133
9202
  el.content = remote
9134
9203
  }
9135
9204
  } else if (el.type === 'video') {
9136
- if (shouldUpload(el.src)) {
9137
- const remote = await uploadMediaUrl(el.src, 'video', 'mp4')
9205
+ const targetSrc = el.src || el.content
9206
+ if (shouldUpload(targetSrc)) {
9207
+ const remote = await uploadMediaUrl(targetSrc, 'video', 'mp4')
9138
9208
  el.src = remote
9209
+ el.content = remote
9210
+ }
9211
+ if (el.poster && shouldUpload(el.poster)) {
9212
+ el.poster = await uploadMediaUrl(el.poster, 'image', 'jpg')
9139
9213
  }
9140
9214
  } else if (el.type === 'audio') {
9141
- if (shouldUpload(el.src)) {
9142
- const remote = await uploadMediaUrl(el.src, 'audio', 'mp3')
9215
+ const targetSrc = el.src || el.content
9216
+ if (shouldUpload(targetSrc)) {
9217
+ const remote = await uploadMediaUrl(targetSrc, 'audio', 'mp3')
9143
9218
  el.src = remote
9219
+ el.content = remote
9144
9220
  }
9145
9221
  } else if (el.type === 'math') {
9146
9222
  const targetSrc = el.src || el.picBlob || el.picBase64
@@ -9156,6 +9232,11 @@ async function uploadMediaResourcesInSlides(deckOrSlides: any): Promise<void> {
9156
9232
  if (el.style) el.style.pattern = remote
9157
9233
  }
9158
9234
  }
9235
+ if (Array.isArray(el.elements)) {
9236
+ for (const child of el.elements) {
9237
+ await processElement(child)
9238
+ }
9239
+ }
9159
9240
  }
9160
9241
 
9161
9242
  const processBackground = async (item: any) => {
@@ -9171,9 +9252,13 @@ async function uploadMediaResourcesInSlides(deckOrSlides: any): Promise<void> {
9171
9252
  item.background = remote
9172
9253
  }
9173
9254
  } else if (item.background && typeof item.background === 'object') {
9174
- if (item.background.type === 'image' && shouldUpload(item.background.value)) {
9175
- const remote = await uploadMediaUrl(item.background.value, 'image', 'jpg')
9255
+ const bgTarget = item.background.image?.src || item.background.value
9256
+ if (item.background.type === 'image' && shouldUpload(bgTarget)) {
9257
+ const remote = await uploadMediaUrl(bgTarget, 'image', 'jpg')
9176
9258
  item.background.value = remote
9259
+ if (item.background.image && typeof item.background.image === 'object') {
9260
+ item.background.image.src = remote
9261
+ }
9177
9262
  }
9178
9263
  }
9179
9264
  }
@@ -9883,6 +9968,9 @@ export function useSlides() {
9883
9968
  enableMaterial,
9884
9969
  isMaterialEnabled,
9885
9970
  setMaterialConfig,
9971
+ enableTemplate,
9972
+ isTemplateEnabled,
9973
+ setTemplateConfig,
9886
9974
  saveCurrentSlideToMaterial,
9887
9975
  placeholderMaterialTargetId,
9888
9976
  setPlaceholderMaterialTargetId,