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
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: #0f172a;
3977
+ color: #4f46e5;
3978
3978
  font-weight: 600;
3979
3979
  }
3980
3980
 
@@ -3985,10 +3985,273 @@ td.selected-cell.focused-cell,
3985
3985
  right: 0;
3986
3986
  bottom: 0;
3987
3987
  height: 2px;
3988
- background: #0f172a;
3988
+ background: #4f46e5;
3989
3989
  border-radius: 1px;
3990
3990
  }
3991
3991
 
3992
+ .preset-template-upload-btn {
3993
+ display: inline-flex;
3994
+ align-items: center;
3995
+ gap: 5px;
3996
+ padding: 5px 10px;
3997
+ border-radius: 6px;
3998
+ border: 1px solid #e2e8f0;
3999
+ background: #f8fafc;
4000
+ color: #475569;
4001
+ font-size: 12px;
4002
+ font-weight: 500;
4003
+ cursor: pointer;
4004
+ transition: all 0.15s ease;
4005
+ }
4006
+
4007
+ .preset-template-upload-btn:hover {
4008
+ background: #eef2ff;
4009
+ border-color: #c7d2fe;
4010
+ color: #4f46e5;
4011
+ }
4012
+
4013
+ .preset-template-search-box {
4014
+ position: relative;
4015
+ display: flex;
4016
+ align-items: center;
4017
+ width: 100%;
4018
+ height: 36px;
4019
+ padding: 0 12px;
4020
+ margin-bottom: 14px;
4021
+ border: 1px solid #e2e8f0;
4022
+ border-radius: 8px;
4023
+ background: #ffffff;
4024
+ box-sizing: border-box;
4025
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
4026
+ }
4027
+
4028
+ .preset-template-search-box:focus-within {
4029
+ border-color: #6366f1;
4030
+ box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
4031
+ }
4032
+
4033
+ .preset-template-search-icon {
4034
+ color: #64748b;
4035
+ flex-shrink: 0;
4036
+ margin-right: 8px;
4037
+ }
4038
+
4039
+ .preset-template-search-input {
4040
+ flex: 1;
4041
+ width: 100%;
4042
+ border: none;
4043
+ outline: none;
4044
+ background: transparent;
4045
+ font-size: 13px;
4046
+ color: #1e293b;
4047
+ }
4048
+
4049
+ .preset-template-search-input::placeholder {
4050
+ color: #94a3b8;
4051
+ }
4052
+
4053
+ .preset-template-search-clear {
4054
+ border: none;
4055
+ background: transparent;
4056
+ color: #94a3b8;
4057
+ font-size: 16px;
4058
+ line-height: 1;
4059
+ cursor: pointer;
4060
+ padding: 0 2px;
4061
+ }
4062
+
4063
+ .preset-template-search-clear:hover {
4064
+ color: #475569;
4065
+ }
4066
+
4067
+ .preset-template-section-header {
4068
+ display: flex;
4069
+ align-items: center;
4070
+ justify-content: space-between;
4071
+ font-size: 13px;
4072
+ font-weight: 600;
4073
+ color: #1e293b;
4074
+ margin-bottom: 12px;
4075
+ }
4076
+
4077
+ .preset-template-count-text {
4078
+ font-size: 12px;
4079
+ font-weight: 500;
4080
+ color: #94a3b8;
4081
+ }
4082
+
4083
+ .preset-template-thumb,
4084
+ .preset-template-slide-thumb {
4085
+ position: relative;
4086
+ }
4087
+
4088
+ .preset-template-card:hover .preset-template-thumb,
4089
+ .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);
4092
+ }
4093
+
4094
+ .preset-template-name {
4095
+ color: #64748b;
4096
+ font-weight: 500;
4097
+ }
4098
+
4099
+ .preset-template-card:hover .preset-template-name,
4100
+ .preset-template-slide-item:hover .preset-layout-name {
4101
+ color: #1e293b;
4102
+ }
4103
+
4104
+ .preset-template-page-pill {
4105
+ position: absolute;
4106
+ right: 6px;
4107
+ bottom: 6px;
4108
+ padding: 2px 7px;
4109
+ border-radius: 10px;
4110
+ background: rgba(15, 23, 42, 0.68);
4111
+ backdrop-filter: blur(4px);
4112
+ color: #ffffff;
4113
+ font-size: 10px;
4114
+ font-weight: 600;
4115
+ line-height: 1.4;
4116
+ pointer-events: none;
4117
+ }
4118
+
4119
+ .preset-template-loading-mask {
4120
+ position: absolute;
4121
+ inset: 0;
4122
+ display: flex;
4123
+ align-items: center;
4124
+ justify-content: center;
4125
+ background: rgba(255, 255, 255, 0.82);
4126
+ color: #4f46e5;
4127
+ font-size: 12px;
4128
+ font-weight: 600;
4129
+ }
4130
+
4131
+ .preset-template-empty {
4132
+ padding: 36px 0;
4133
+ text-align: center;
4134
+ color: #94a3b8;
4135
+ font-size: 13px;
4136
+ }
4137
+
4138
+ .preset-template-detail-header {
4139
+ position: sticky;
4140
+ top: -16px;
4141
+ z-index: 5;
4142
+ display: flex;
4143
+ align-items: center;
4144
+ justify-content: space-between;
4145
+ gap: 8px;
4146
+ margin: -16px -20px 14px -20px;
4147
+ padding: 10px 20px;
4148
+ background: rgba(255, 255, 255, 0.96);
4149
+ backdrop-filter: blur(6px);
4150
+ border-bottom: 1px solid #f1f5f9;
4151
+ }
4152
+
4153
+ .preset-template-back-btn {
4154
+ display: inline-flex;
4155
+ align-items: center;
4156
+ gap: 3px;
4157
+ padding: 4px 8px 4px 4px;
4158
+ border-radius: 6px;
4159
+ border: none;
4160
+ background: transparent;
4161
+ color: #475569;
4162
+ font-size: 12.5px;
4163
+ font-weight: 500;
4164
+ cursor: pointer;
4165
+ flex-shrink: 0;
4166
+ transition: background-color 0.15s ease, color 0.15s ease;
4167
+ }
4168
+
4169
+ .preset-template-back-btn:hover {
4170
+ background: #f1f5f9;
4171
+ color: #0f172a;
4172
+ }
4173
+
4174
+ .preset-template-detail-title {
4175
+ display: flex;
4176
+ align-items: center;
4177
+ gap: 6px;
4178
+ min-width: 0;
4179
+ flex: 1;
4180
+ }
4181
+
4182
+ .preset-template-detail-title .detail-name-text {
4183
+ font-size: 13px;
4184
+ font-weight: 600;
4185
+ color: #0f172a;
4186
+ white-space: nowrap;
4187
+ overflow: hidden;
4188
+ text-overflow: ellipsis;
4189
+ }
4190
+
4191
+ .preset-template-detail-title .detail-count-badge {
4192
+ font-size: 11px;
4193
+ font-weight: 500;
4194
+ color: #6366f1;
4195
+ background: #eef2ff;
4196
+ padding: 1px 7px;
4197
+ border-radius: 10px;
4198
+ flex-shrink: 0;
4199
+ }
4200
+
4201
+ .preset-template-insert-all-btn {
4202
+ padding: 5px 11px;
4203
+ border-radius: 6px;
4204
+ border: none;
4205
+ background: #4f46e5;
4206
+ color: #ffffff;
4207
+ font-size: 12px;
4208
+ font-weight: 500;
4209
+ cursor: pointer;
4210
+ flex-shrink: 0;
4211
+ transition: background-color 0.15s ease;
4212
+ }
4213
+
4214
+ .preset-template-insert-all-btn:hover {
4215
+ background: #4338ca;
4216
+ }
4217
+
4218
+ .preset-template-slide-index {
4219
+ position: absolute;
4220
+ top: 6px;
4221
+ left: 6px;
4222
+ z-index: 2;
4223
+ padding: 2px 6px;
4224
+ border-radius: 4px;
4225
+ background: rgba(15, 23, 42, 0.52);
4226
+ color: #ffffff;
4227
+ font-size: 10px;
4228
+ font-weight: 600;
4229
+ line-height: 1.2;
4230
+ pointer-events: none;
4231
+ }
4232
+
4233
+ .preset-template-slide-hover-badge {
4234
+ position: absolute;
4235
+ right: 6px;
4236
+ bottom: 6px;
4237
+ z-index: 2;
4238
+ padding: 2px 8px;
4239
+ border-radius: 6px;
4240
+ background: #4f46e5;
4241
+ color: #ffffff;
4242
+ font-size: 10.5px;
4243
+ font-weight: 500;
4244
+ opacity: 0;
4245
+ transform: translateY(2px);
4246
+ transition: opacity 0.15s ease, transform 0.15s ease;
4247
+ pointer-events: none;
4248
+ }
4249
+
4250
+ .preset-template-slide-item:hover .preset-template-slide-hover-badge {
4251
+ opacity: 1;
4252
+ transform: translateY(0);
4253
+ }
4254
+
3992
4255
  .preset-layout-body {
3993
4256
  padding: 16px 20px 20px 20px;
3994
4257
  max-height: min(640px, calc(100vh - 140px));
@@ -1,5 +1,6 @@
1
1
  import type { Ref } from 'vue'
2
2
  import type { Slide, SlideElement, SlideMaster, PresetTheme } from '../composables/useSlides'
3
+ import type { SlideTemplateItem, SlideTemplateInput } from '../configs/slideTemplates'
3
4
  import {
4
5
  type SlideTextType,
5
6
  type TextTypeConfig,
@@ -9,7 +10,7 @@ import {
9
10
  normalizeTextType
10
11
  } from '../utils/textTypes'
11
12
 
12
- export type { Slide, SlideElement, SlideMaster, PresetTheme, SlideTextType, TextTypeConfig }
13
+ export type { Slide, SlideElement, SlideMaster, PresetTheme, SlideTextType, TextTypeConfig, SlideTemplateItem, SlideTemplateInput }
13
14
  export { TEXT_TYPE_CONFIGS, TEXT_TYPE_LIST, inferElementTextType, normalizeTextType }
14
15
 
15
16
  /**
@@ -128,6 +129,16 @@ export interface PptEditorConfig {
128
129
  customUpload?: CustomUploadHandler
129
130
  /** 自定义资源上传函数的别名(等价于 customUpload) */
130
131
  uploadHandler?: CustomUploadHandler
132
+ /** 是否启用左侧“更多布局”中的“模板”库功能,默认为 true(设为 false 时隐藏模板 Tab 及加载本地模板按钮) */
133
+ enableTemplate?: boolean
134
+ /** enableTemplate 的别名 */
135
+ enableTemplates?: boolean
136
+ /** 外部自定义传入的模板列表(支持传入完整 Deck JSON 对象、按需加载索引项或 SlideTemplateItem) */
137
+ templates?: SlideTemplateInput[]
138
+ /** 模板静态资源的自定义基础路径(如 'https://cdn.example.com/templates'),用于按需请求 templates-first-page.json 与模板文件 */
139
+ templateBaseUrl?: string
140
+ /** 传入自定义 templates 时是否替换默认内置模板,默认为 true(设为 false 则与默认内置模板合并) */
141
+ replaceBuiltinTemplates?: boolean
131
142
  /** 其它扩展配置 */
132
143
  [key: string]: any
133
144
  }
@@ -178,6 +189,16 @@ export interface PptEditorProps {
178
189
  customUpload?: CustomUploadHandler
179
190
  /** 自定义资源上传函数的别名(等价于 customUpload) */
180
191
  uploadHandler?: CustomUploadHandler
192
+ /** 是否启用左侧“更多布局”中的“模板”库功能,默认为 true(设为 false 时隐藏模板 Tab 及加载本地模板按钮) */
193
+ enableTemplate?: boolean
194
+ /** enableTemplate 的别名 */
195
+ enableTemplates?: boolean
196
+ /** 外部自定义传入的模板列表(支持传入完整 Deck JSON 对象、按需加载索引项或 SlideTemplateItem) */
197
+ templates?: SlideTemplateInput[]
198
+ /** 模板静态资源的自定义基础路径(如 'https://cdn.example.com/templates'),用于按需请求 templates-first-page.json 与模板文件 */
199
+ templateBaseUrl?: string
200
+ /** 传入自定义 templates 时是否替换默认内置模板,默认为 true(设为 false 则与默认内置模板合并) */
201
+ replaceBuiltinTemplates?: boolean
181
202
  /** 编辑器扩展配置 */
182
203
  config?: PptEditorConfig
183
204
  }
@@ -279,6 +300,21 @@ export interface PptEditorApi {
279
300
  setCustomUploadHandler: (handler: CustomUploadHandler | null) => void
280
301
  /** 获取当前已配载的自定义资源上传处理器 */
281
302
  getCustomUploadHandler: () => CustomUploadHandler | null
303
+ /** 设置或更新模板库开关、自定义模板列表及基础路径配置 */
304
+ setTemplateConfig: (config?: {
305
+ enable?: boolean
306
+ templates?: SlideTemplateInput[]
307
+ baseUrl?: string
308
+ replaceBuiltin?: boolean
309
+ }) => void
310
+ /** 直接设置/替换模板库列表 */
311
+ setTemplates: (templates: SlideTemplateInput[], options?: { replaceBuiltin?: boolean; baseUrl?: string }) => void
312
+ /** 动态追加单个自定义模板到模板库 */
313
+ addTemplate: (template: SlideTemplateInput) => SlideTemplateItem
314
+ /** 获取当前模板库列表 */
315
+ getTemplates: () => SlideTemplateItem[]
316
+ /** 当前模板库功能是否启用 */
317
+ isTemplateEnabled: Ref<boolean>
282
318
  /** 底层 useSlides composable 完整实例(供深度扩展) */
283
319
  slidesComposable: any
284
320
  }
@@ -18,6 +18,34 @@ export function parseColorString(fill: any, fallback = 'none'): string {
18
18
  return fallback
19
19
  }
20
20
 
21
+ export function resolveLocalMediaPath(raw: string): string {
22
+ if (!raw || typeof raw !== 'string') return ''
23
+ const trimmed = raw.trim()
24
+ // 若路径包含 (image|mp4|mp3)/xxx,优先映射为前端 public/templates 静态路径,兼容部署态与插件态
25
+ const tplMatch = trimmed.match(/(?:[A-Za-z]:[\\/].*?[\\/]|^\/?templates[\\/])(image|mp4|mp3)[\\/]([^"'\\/?#\s]+)$/i)
26
+ if (tplMatch) {
27
+ return `/templates/${tplMatch[1].toLowerCase()}/${tplMatch[2]}`
28
+ }
29
+ if (/^[A-Za-z]:[\\/]/.test(trimmed)) {
30
+ return `/__ppt_template_media?path=${encodeURIComponent(trimmed)}`
31
+ }
32
+ if (/^file:\/\/\/[A-Za-z]:/i.test(trimmed)) {
33
+ const localPath = decodeURIComponent(trimmed.replace(/^file:\/\/\//i, '')).replace(/\//g, '\\')
34
+ return `/__ppt_template_media?path=${encodeURIComponent(localPath)}`
35
+ }
36
+ return trimmed
37
+ }
38
+
39
+ function normalizeCssUrlLocalPaths(cssUrlExpr: string): string {
40
+ return cssUrlExpr.replace(/url\(['"]?([^)'"]+)['"]?\)/gi, (full, inner) => {
41
+ const trimmedInner = (inner || '').trim()
42
+ if (/^[A-Za-z]:[\\/]/.test(trimmedInner) || /^file:\/\/\/[A-Za-z]:/i.test(trimmedInner)) {
43
+ return `url("${resolveLocalMediaPath(trimmedInner)}")`
44
+ }
45
+ return full
46
+ })
47
+ }
48
+
21
49
  export function getSlideBackgroundCss(bg: any): string {
22
50
  if (!bg) return '#ffffff'
23
51
  if (typeof bg === 'string') {
@@ -26,15 +54,16 @@ export function getSlideBackgroundCss(bg: any): string {
26
54
  return '#ffffff'
27
55
  }
28
56
  if (trimmed.startsWith('url(')) {
29
- const closeParenIdx = trimmed.lastIndexOf(')')
30
- const afterUrl = closeParenIdx >= 0 ? trimmed.slice(closeParenIdx + 1).trim() : ''
57
+ const normalizedUrl = normalizeCssUrlLocalPaths(trimmed)
58
+ const closeParenIdx = normalizedUrl.lastIndexOf(')')
59
+ const afterUrl = closeParenIdx >= 0 ? normalizedUrl.slice(closeParenIdx + 1).trim() : ''
31
60
  if (!afterUrl) {
32
- if (trimmed.includes('data:image/svg+xml')) {
33
- return `#ffffff ${trimmed} left top / auto repeat`
61
+ if (normalizedUrl.includes('data:image/svg+xml') || normalizedUrl.toLowerCase().includes('.svg')) {
62
+ return `#ffffff ${normalizedUrl} left top / auto repeat`
34
63
  }
35
- return `#ffffff ${trimmed} center center / 100% 100% no-repeat`
64
+ return `#ffffff ${normalizedUrl} center center / 100% 100% no-repeat`
36
65
  }
37
- return `#ffffff ${trimmed}`
66
+ return `#ffffff ${normalizedUrl}`
38
67
  }
39
68
  return trimmed
40
69
  }
@@ -143,6 +172,9 @@ export function getElementImageSrc(el: any): string {
143
172
  }
144
173
  if (typeof src === 'string' && src.length > 0) {
145
174
  const raw = src.trim()
175
+ if (/^[A-Za-z]:[\\/]/.test(raw) || /^file:\/\/\/[A-Za-z]:/i.test(raw)) {
176
+ return resolveLocalMediaPath(raw)
177
+ }
146
178
  if (raw.startsWith('data:') || raw.startsWith('http:') || raw.startsWith('https:') || raw.startsWith('/') || raw.startsWith('./') || raw.startsWith('blob:')) {
147
179
  return raw
148
180
  }
@@ -351,20 +383,23 @@ export function normalizeGradientConfig(raw: any): GradientConfig | undefined {
351
383
  }
352
384
 
353
385
  const rawColors = Array.isArray(raw.colors) ? raw.colors : []
354
- const colors: GradientColorStop[] = rawColors.length > 0 ? rawColors.map((c: any) => {
355
- let p = c.pos
356
- if (typeof p === 'string') {
357
- p = p.endsWith('%') ? p : `${p}%`
358
- } else if (typeof p === 'number') {
359
- p = `${Math.round(p)}%`
360
- } else {
361
- p = '0%'
362
- }
363
- return {
364
- pos: p,
365
- color: c.color || c.value || '#3b82f6'
366
- }
367
- }) : [
386
+ const colors: GradientColorStop[] = rawColors.length > 0 ? rawColors
387
+ .map((c: any, idx: number) => {
388
+ let numPos = 0
389
+ if (typeof c.pos === 'number') {
390
+ numPos = Math.round(c.pos)
391
+ } else if (typeof c.pos === 'string') {
392
+ numPos = parseFloat(c.pos) || 0
393
+ }
394
+ return {
395
+ numPos,
396
+ idx,
397
+ pos: `${Math.round(numPos)}%`,
398
+ color: c.color || c.value || '#3b82f6'
399
+ }
400
+ })
401
+ .sort((a: { numPos: number; idx: number }, b: { numPos: number; idx: number }) => a.numPos - b.numPos || a.idx - b.idx)
402
+ .map(({ pos, color }: { pos: string; color: string }) => ({ pos, color })) : [
368
403
  { pos: '0%', color: '#3b82f6' },
369
404
  { pos: '100%', color: '#60a5fa' }
370
405
  ]