jvs-ppt-ui 0.0.32 → 0.0.34

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 (32) hide show
  1. package/README.md +152 -0
  2. package/dist/lib/jvs-ppt-ui.es.js +23678 -21439
  3. package/dist/lib/jvs-ppt-ui.umd.js +136 -100
  4. package/dist/lib/style.css +1 -1
  5. package/package.json +2 -1
  6. package/src/components/CanvasArea.vue +77 -35
  7. package/src/components/Header.vue +184 -26
  8. package/src/components/PitchImportDialog.vue +29 -6
  9. package/src/components/PptEditor.vue +53 -1
  10. package/src/components/QuickColorPopover.vue +2 -1
  11. package/src/components/SidebarLeft.vue +367 -41
  12. package/src/components/SidebarRight.vue +183 -134
  13. package/src/components/canvas/CanvasTransformHandles.vue +27 -36
  14. package/src/components/canvas/elements/CanvasMediaElement.vue +4 -3
  15. package/src/components/canvas/elements/CanvasShapeElement.vue +9 -6
  16. package/src/components/sidebar/panels/LayoutThumbSvg.vue +9 -6
  17. package/src/components/sidebar/panels/SidebarShapeFormatPanel.vue +1 -1
  18. package/src/components/sidebar/panels/SidebarTextFormatPanel.vue +1 -1
  19. package/src/composables/canvas/useCanvasFormatting.ts +20 -13
  20. package/src/composables/canvas/useCanvasText.ts +4 -3
  21. package/src/composables/canvas/useCanvasTransform.ts +37 -10
  22. package/src/composables/sidebar/useSidebarElementTransform.ts +86 -57
  23. package/src/composables/sidebar/useSidebarTextFormat.ts +242 -19
  24. package/src/composables/useSlides.ts +93 -28
  25. package/src/configs/slideTemplates.ts +1001 -0
  26. package/src/style.css +265 -2
  27. package/src/types/index.ts +37 -1
  28. package/src/utils/canvas/elementStyles.ts +55 -20
  29. package/src/utils/canvas/formatPainter.ts +177 -30
  30. package/src/utils/muxHlsToMp4.ts +569 -0
  31. package/src/utils/pitchConverter.ts +512 -13
  32. package/dist/lib/templates/index.json +0 -5
@@ -5,6 +5,7 @@ import { useSlides } from '../composables/useSlides'
5
5
  import {
6
6
  fetchAndConvertPitchTemplate,
7
7
  normalizePitchTemplateUrl,
8
+ stringifyDeckToBlob,
8
9
  PITCH_LAYOUT_CATEGORIES
9
10
  } from '../utils/pitchConverter'
10
11
 
@@ -26,6 +27,7 @@ const templateUrl = ref(DEFAULT_DEMO_URL)
26
27
  const rawJsonText = ref('')
27
28
  const selectedCategory = ref('all')
28
29
  const isLoading = ref(false)
30
+ const progressText = ref('')
29
31
  const errorMsg = ref('')
30
32
 
31
33
  const isLayoutLibraryUrl = computed(() => {
@@ -70,26 +72,32 @@ async function runConvert(action: 'import' | 'download') {
70
72
  }
71
73
 
72
74
  isLoading.value = true
75
+ progressText.value = '正在拉取并解析模板...'
73
76
  try {
74
77
  const deck = await fetchAndConvertPitchTemplate(source, {
75
- categoryFilter: isLayoutLibraryUrl.value ? selectedCategory.value : 'all'
78
+ categoryFilter: isLayoutLibraryUrl.value ? selectedCategory.value : 'all',
79
+ convertMediaToBase64: true,
80
+ onProgress: (done, total) => {
81
+ progressText.value = `正在转换图片/音视频为 Base64 (${done}/${total})...`
82
+ }
76
83
  })
77
84
  if (action === 'download') {
78
- const blob = new Blob([JSON.stringify(deck, null, 2)], { type: 'application/json;charset=utf-8' })
85
+ const blob = stringifyDeckToBlob(deck)
79
86
  saveAs(blob, `${deck.title || 'pitch-template'}.json`)
80
- notify(`已转换并下载 "${deck.title}"(共 ${deck.slides.length} 页,${deck.styleRecipes.length} 套主题)`)
87
+ notify(`已转换并下载 "${deck.title}"(共 ${deck.slides.length} 页,${deck.styleRecipes.length} 套主题,媒体已转 Base64)`)
81
88
  } else {
82
89
  importSlides(deck)
83
90
  if (deck.title) {
84
91
  presentationTitle.value = deck.title
85
92
  }
86
- notify(`成功导入 "${deck.title}"(共 ${deck.slides.length} 页,${deck.styleRecipes.length} 套主题)`)
93
+ notify(`成功导入 "${deck.title}"(共 ${deck.slides.length} 页,${deck.styleRecipes.length} 套主题,媒体已转 Base64)`)
87
94
  emit('update:visible', false)
88
95
  }
89
96
  } catch (err: any) {
90
97
  errorMsg.value = err?.message || '转换失败,请检查模板地址或数据格式'
91
98
  } finally {
92
99
  isLoading.value = false
100
+ progressText.value = ''
93
101
  }
94
102
  }
95
103
  </script>
@@ -162,6 +170,7 @@ async function runConvert(action: 'import' | 'download') {
162
170
  <div class="tip-title">支持自动转换的内容:</div>
163
171
  <ul>
164
172
  <li>单模板 (<code>templates/&lt;uuid&gt;</code>) 与全量官方版式库 (<code>key-layouts.transit</code> 共 9 大类 149 套版式)</li>
173
+ <li>图片、视频、音频及背景图资源自动并发拉取并内联为 <code>Base64 DataURL</code>,便于离线下载与服务端持久化</li>
165
174
  <li>Cognitect Transit-JSON 缓存表解码(<code>["^ ", ...]</code> 与 <code>^xx</code> 字典还原)及 <code>group</code> 组合容器</li>
166
175
  <li>内嵌主题配方(<code>StyleRecipe</code> 字体、字号比例、色板、表格与图表配色)</li>
167
176
  <li>归一化坐标映射到 <code>1280 × 720</code> 画布、背景图去重、人像裁切对焦与线性渐变形状</li>
@@ -185,6 +194,10 @@ async function runConvert(action: 'import' | 'download') {
185
194
  ></textarea>
186
195
  </div>
187
196
 
197
+ <div v-if="isLoading && progressText" class="progress-banner">
198
+ {{ progressText }}
199
+ </div>
200
+
188
201
  <div v-if="errorMsg" class="error-banner">
189
202
  {{ errorMsg }}
190
203
  </div>
@@ -202,7 +215,7 @@ async function runConvert(action: 'import' | 'download') {
202
215
  :disabled="isLoading"
203
216
  @click="runConvert('download')"
204
217
  >
205
- {{ isLoading ? '处理中...' : '转换并下载 JSON' }}
218
+ {{ isLoading ? (progressText || '处理中...') : '转换并下载 JSON' }}
206
219
  </button>
207
220
  <button
208
221
  type="button"
@@ -210,7 +223,7 @@ async function runConvert(action: 'import' | 'download') {
210
223
  :disabled="isLoading"
211
224
  @click="runConvert('import')"
212
225
  >
213
- {{ isLoading ? '正在拉取并转换...' : '拉取并转换导入' }}
226
+ {{ isLoading ? (progressText || '正在拉取并转换...') : '拉取并转换导入' }}
214
227
  </button>
215
228
  </div>
216
229
  </div>
@@ -386,6 +399,16 @@ async function runConvert(action: 'import' | 'download') {
386
399
  padding-left: 18px;
387
400
  }
388
401
 
402
+ .progress-banner {
403
+ padding: 8px 12px;
404
+ background: #eff6ff;
405
+ border: 1px solid #bfdbfe;
406
+ border-radius: 6px;
407
+ color: #1d4ed8;
408
+ font-size: 12px;
409
+ font-weight: 500;
410
+ }
411
+
389
412
  .error-banner {
390
413
  padding: 8px 12px;
391
414
  background: #fef2f2;
@@ -4,6 +4,7 @@ import jvsPickerColorV3 from 'jvs-picker-color-v3'
4
4
  import '../assets/iconfont/iconfont.js'
5
5
  import '../../public/jvs-ppt-ui/fonts/fonts.css'
6
6
  import { saveAs } from 'file-saver'
7
+ import { stringifyDeckToBlob } from '../utils/pitchConverter'
7
8
  import Header from './Header.vue'
8
9
  import Toolbar from './Toolbar.vue'
9
10
  import SidebarLeft from './SidebarLeft.vue'
@@ -28,6 +29,7 @@ if (currentApp) {
28
29
  }
29
30
 
30
31
  import { useSlides } from '../composables/useSlides'
32
+ import { builtinSlideTemplates, setCustomTemplates, addCustomTemplate } from '../configs/slideTemplates'
31
33
  import type { Slide, SlideMaster, DeckData, PptEditorProps, PptEditorApi, SaveOptions, LoadSourceOptions, LoadSourceResult } from '../types'
32
34
 
33
35
  const props = withDefaults(defineProps<PptEditorProps>(), {
@@ -50,6 +52,11 @@ const props = withDefaults(defineProps<PptEditorProps>(), {
50
52
  materialTypeApiUrl: '',
51
53
  materialSaveApiUrl: '',
52
54
  materialHeaders: () => ({}),
55
+ enableTemplate: undefined,
56
+ enableTemplates: undefined,
57
+ templates: undefined,
58
+ templateBaseUrl: '',
59
+ replaceBuiltinTemplates: undefined,
53
60
  config: () => ({})
54
61
  })
55
62
 
@@ -104,6 +111,8 @@ const {
104
111
  isAiBeautifyEnabled,
105
112
  setMaterialConfig,
106
113
  isMaterialEnabled,
114
+ setTemplateConfig,
115
+ isTemplateEnabled,
107
116
  saveCurrentSlideToMaterial,
108
117
  isCanvasDragging,
109
118
  pauseHistory,
@@ -211,6 +220,44 @@ watch(
211
220
  { immediate: true }
212
221
  )
213
222
 
223
+ // 监听外部传入的模板库相关配置(优先 props,次选 config 对象)
224
+ watch(
225
+ [
226
+ () => props.enableTemplate,
227
+ () => props.enableTemplates,
228
+ () => props.config?.enableTemplate,
229
+ () => props.config?.enableTemplates,
230
+ () => props.templates,
231
+ () => props.config?.templates,
232
+ () => props.templateBaseUrl,
233
+ () => props.config?.templateBaseUrl,
234
+ () => props.replaceBuiltinTemplates,
235
+ () => props.config?.replaceBuiltinTemplates
236
+ ],
237
+ () => {
238
+ const rawEnable = props.enableTemplate !== undefined
239
+ ? props.enableTemplate
240
+ : (props.enableTemplates !== undefined
241
+ ? props.enableTemplates
242
+ : (props.config?.enableTemplate !== undefined
243
+ ? props.config.enableTemplate
244
+ : props.config?.enableTemplates))
245
+ const templates = props.templates !== undefined ? props.templates : props.config?.templates
246
+ const baseUrl = props.templateBaseUrl || props.config?.templateBaseUrl || ''
247
+ const replaceBuiltin = props.replaceBuiltinTemplates !== undefined
248
+ ? props.replaceBuiltinTemplates
249
+ : props.config?.replaceBuiltinTemplates
250
+
251
+ setTemplateConfig({
252
+ enable: rawEnable !== undefined ? Boolean(rawEnable) : true,
253
+ templates,
254
+ baseUrl,
255
+ replaceBuiltin
256
+ })
257
+ },
258
+ { immediate: true, deep: true }
259
+ )
260
+
214
261
  // 初始化标题
215
262
  if (props.config?.title) {
216
263
  presentationTitle.value = props.config.title
@@ -276,7 +323,7 @@ const headerRef = ref<any>(null)
276
323
  */
277
324
  function getSaveJsonBlob(): Blob {
278
325
  const deck = getDeck()
279
- return new Blob([JSON.stringify(deck, null, 2)], { type: 'application/json' })
326
+ return stringifyDeckToBlob(deck as any)
280
327
  }
281
328
 
282
329
  /**
@@ -877,6 +924,11 @@ const editorApi: PptEditorApi = {
877
924
  saveMaterial: (meta) => saveCurrentSlideToMaterial(meta),
878
925
  setCustomUploadHandler,
879
926
  getCustomUploadHandler,
927
+ setTemplateConfig,
928
+ setTemplates: (templates, options) => setCustomTemplates(templates, options),
929
+ addTemplate: (template) => addCustomTemplate(template),
930
+ getTemplates: () => [...builtinSlideTemplates],
931
+ isTemplateEnabled,
880
932
  slidesComposable: slidesState
881
933
  }
882
934
 
@@ -36,6 +36,7 @@ const isCustomColorPickerShow = ref(false)
36
36
  const referenceWrapperRef = ref<HTMLElement>()
37
37
 
38
38
  const handleBodyBubble = (e: MouseEvent) => {
39
+ if (!popoverVisible.value && !isCustomColorPickerShow.value) return
39
40
  const target = e.target as HTMLElement
40
41
  if (!target) return
41
42
  const isInsidePopover = target.closest('.quick-color-popover') ||
@@ -147,7 +148,7 @@ function getCurrentColor(): string {
147
148
  col = props.color || '#000000'
148
149
  }
149
150
  if (!col || col === 'transparent' || col === 'none') {
150
- return 'rgba(0, 0, 0, 0)'
151
+ return '#FFFFFF'
151
152
  }
152
153
  if (props.alpha !== undefined && props.alpha >= 0 && props.alpha <= 100) {
153
154
  const cleanHex = col.trim().replace('#', '')