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.
- package/README.md +152 -0
- package/dist/lib/jvs-ppt-ui.es.js +39270 -34665
- package/dist/lib/jvs-ppt-ui.umd.js +141 -114
- package/dist/lib/style.css +1 -1
- package/package.json +2 -1
- package/src/components/CanvasArea.vue +9 -1
- package/src/components/ChartTypeSelector.vue +69 -29
- package/src/components/Header.vue +228 -29
- package/src/components/PitchImportDialog.vue +482 -0
- package/src/components/PptEditor.vue +53 -1
- package/src/components/SidebarLeft.vue +367 -41
- package/src/components/SidebarRight.vue +75 -35
- package/src/components/StyleBuilderDialog.vue +276 -105
- package/src/components/SvgChart.vue +1242 -833
- package/src/components/canvas/elements/CanvasGroupElement.vue +16 -2
- package/src/components/canvas/elements/CanvasMediaElement.vue +5 -3
- package/src/components/canvas/elements/CanvasShapeElement.vue +6 -4
- package/src/components/sidebar/dialogs/ChartDataEditorDialog.vue +1040 -0
- package/src/components/sidebar/panels/LayoutThumbSvg.vue +9 -6
- package/src/components/sidebar/panels/SidebarChartFormatPanel.vue +1479 -641
- package/src/components/sidebar/panels/SidebarDesignPanel.vue +32 -0
- package/src/composables/presetThemes.ts +49 -1
- package/src/composables/sidebar/useSidebarChart.ts +357 -194
- package/src/composables/useSlides.ts +110 -22
- package/src/configs/slideTemplates.ts +1001 -0
- package/src/style.css +267 -4
- package/src/types/index.ts +37 -1
- package/src/utils/canvas/elementStyles.ts +55 -20
- package/src/utils/muxHlsToMp4.ts +569 -0
- package/src/utils/pitchConverter.ts +1725 -0
- package/dist/lib/templates/index.json +0 -5
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, computed, watch } from 'vue'
|
|
3
|
+
import { saveAs } from 'file-saver'
|
|
4
|
+
import { useSlides } from '../composables/useSlides'
|
|
5
|
+
import {
|
|
6
|
+
fetchAndConvertPitchTemplate,
|
|
7
|
+
normalizePitchTemplateUrl,
|
|
8
|
+
stringifyDeckToBlob,
|
|
9
|
+
PITCH_LAYOUT_CATEGORIES
|
|
10
|
+
} from '../utils/pitchConverter'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
visible: boolean
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
const emit = defineEmits<{
|
|
17
|
+
(e: 'update:visible', val: boolean): void
|
|
18
|
+
}>()
|
|
19
|
+
|
|
20
|
+
const { importSlides, presentationTitle, notify } = useSlides()
|
|
21
|
+
|
|
22
|
+
const DEFAULT_DEMO_URL = 'https://cdn.backend.services.pitch.com/templates/2017ca60-c167-4153-893b-c8bd5b63c914'
|
|
23
|
+
const KEY_LAYOUTS_URL = 'https://app.pitch.com/static/app/13d22ab9-f7ac-4219-9a2b-241061a72fb4/key-layouts.transit'
|
|
24
|
+
|
|
25
|
+
const inputMode = ref<'url' | 'json'>('url')
|
|
26
|
+
const templateUrl = ref(DEFAULT_DEMO_URL)
|
|
27
|
+
const rawJsonText = ref('')
|
|
28
|
+
const selectedCategory = ref('all')
|
|
29
|
+
const isLoading = ref(false)
|
|
30
|
+
const progressText = ref('')
|
|
31
|
+
const errorMsg = ref('')
|
|
32
|
+
|
|
33
|
+
const isLayoutLibraryUrl = computed(() => {
|
|
34
|
+
if (inputMode.value === 'url') {
|
|
35
|
+
return templateUrl.value.includes('key-layouts') || templateUrl.value.endsWith('.transit')
|
|
36
|
+
}
|
|
37
|
+
return rawJsonText.value.includes('key-layout-data')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
watch(
|
|
41
|
+
() => props.visible,
|
|
42
|
+
(val) => {
|
|
43
|
+
if (val) {
|
|
44
|
+
errorMsg.value = ''
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
function handleClose() {
|
|
50
|
+
if (isLoading.value) return
|
|
51
|
+
emit('update:visible', false)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function fillDemoUrl() {
|
|
55
|
+
inputMode.value = 'url'
|
|
56
|
+
templateUrl.value = DEFAULT_DEMO_URL
|
|
57
|
+
errorMsg.value = ''
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function fillKeyLayoutsUrl() {
|
|
61
|
+
inputMode.value = 'url'
|
|
62
|
+
templateUrl.value = KEY_LAYOUTS_URL
|
|
63
|
+
errorMsg.value = ''
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function runConvert(action: 'import' | 'download') {
|
|
67
|
+
errorMsg.value = ''
|
|
68
|
+
const source = inputMode.value === 'url' ? templateUrl.value.trim() : rawJsonText.value.trim()
|
|
69
|
+
if (!source) {
|
|
70
|
+
errorMsg.value = inputMode.value === 'url' ? '请输入 Pitch 模板/版式库地址或 UUID' : '请粘贴 Pitch Transit-JSON 数据'
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
isLoading.value = true
|
|
75
|
+
progressText.value = '正在拉取并解析模板...'
|
|
76
|
+
try {
|
|
77
|
+
const deck = await fetchAndConvertPitchTemplate(source, {
|
|
78
|
+
categoryFilter: isLayoutLibraryUrl.value ? selectedCategory.value : 'all',
|
|
79
|
+
convertMediaToBase64: true,
|
|
80
|
+
onProgress: (done, total) => {
|
|
81
|
+
progressText.value = `正在转换图片/音视频为 Base64 (${done}/${total})...`
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
if (action === 'download') {
|
|
85
|
+
const blob = stringifyDeckToBlob(deck)
|
|
86
|
+
saveAs(blob, `${deck.title || 'pitch-template'}.json`)
|
|
87
|
+
notify(`已转换并下载 "${deck.title}"(共 ${deck.slides.length} 页,${deck.styleRecipes.length} 套主题,媒体已转 Base64)`)
|
|
88
|
+
} else {
|
|
89
|
+
importSlides(deck)
|
|
90
|
+
if (deck.title) {
|
|
91
|
+
presentationTitle.value = deck.title
|
|
92
|
+
}
|
|
93
|
+
notify(`成功导入 "${deck.title}"(共 ${deck.slides.length} 页,${deck.styleRecipes.length} 套主题,媒体已转 Base64)`)
|
|
94
|
+
emit('update:visible', false)
|
|
95
|
+
}
|
|
96
|
+
} catch (err: any) {
|
|
97
|
+
errorMsg.value = err?.message || '转换失败,请检查模板地址或数据格式'
|
|
98
|
+
} finally {
|
|
99
|
+
isLoading.value = false
|
|
100
|
+
progressText.value = ''
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<template>
|
|
106
|
+
<el-dialog
|
|
107
|
+
:model-value="visible"
|
|
108
|
+
@update:model-value="emit('update:visible', $event)"
|
|
109
|
+
title="Pitch 模板拉取与转换器 (仅本地开发可见)"
|
|
110
|
+
width="640px"
|
|
111
|
+
:close-on-click-modal="!isLoading"
|
|
112
|
+
append-to-body
|
|
113
|
+
class="pitch-import-dialog"
|
|
114
|
+
>
|
|
115
|
+
<div class="pitch-dialog-body">
|
|
116
|
+
<div class="mode-tabs">
|
|
117
|
+
<button
|
|
118
|
+
type="button"
|
|
119
|
+
class="mode-tab-btn"
|
|
120
|
+
:class="{ active: inputMode === 'url' }"
|
|
121
|
+
@click="inputMode = 'url'; errorMsg = ''"
|
|
122
|
+
>
|
|
123
|
+
通过模板地址 / UUID 拉取
|
|
124
|
+
</button>
|
|
125
|
+
<button
|
|
126
|
+
type="button"
|
|
127
|
+
class="mode-tab-btn"
|
|
128
|
+
:class="{ active: inputMode === 'json' }"
|
|
129
|
+
@click="inputMode = 'json'; errorMsg = ''"
|
|
130
|
+
>
|
|
131
|
+
直接粘贴 Transit-JSON
|
|
132
|
+
</button>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
<div v-if="inputMode === 'url'" class="input-section">
|
|
136
|
+
<div class="field-header">
|
|
137
|
+
<label class="field-label">Pitch 模板 / 版式库地址或 UUID</label>
|
|
138
|
+
<div class="demo-links">
|
|
139
|
+
<button type="button" class="demo-link-btn" @click="fillDemoUrl">
|
|
140
|
+
示例模板 (Pride)
|
|
141
|
+
</button>
|
|
142
|
+
<span class="demo-divider">|</span>
|
|
143
|
+
<button type="button" class="demo-link-btn" @click="fillKeyLayoutsUrl">
|
|
144
|
+
官方版式库 (key-layouts.transit)
|
|
145
|
+
</button>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
<input
|
|
149
|
+
v-model="templateUrl"
|
|
150
|
+
type="text"
|
|
151
|
+
class="url-input"
|
|
152
|
+
placeholder="例如:https://cdn.backend.services.pitch.com/templates/2017ca60-... 或 .../key-layouts.transit"
|
|
153
|
+
:disabled="isLoading"
|
|
154
|
+
@keyup.enter="runConvert('import')"
|
|
155
|
+
/>
|
|
156
|
+
<div v-if="templateUrl.trim()" class="resolved-url-hint">
|
|
157
|
+
解析请求地址:<code>{{ normalizePitchTemplateUrl(templateUrl) }}</code>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<div v-if="isLayoutLibraryUrl" class="category-filter-row">
|
|
161
|
+
<label class="field-label">版式分类筛选:</label>
|
|
162
|
+
<select v-model="selectedCategory" class="category-select" :disabled="isLoading">
|
|
163
|
+
<option v-for="cat in PITCH_LAYOUT_CATEGORIES" :key="cat.key" :value="cat.key">
|
|
164
|
+
{{ cat.label }}
|
|
165
|
+
</option>
|
|
166
|
+
</select>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
<div class="feature-tips">
|
|
170
|
+
<div class="tip-title">支持自动转换的内容:</div>
|
|
171
|
+
<ul>
|
|
172
|
+
<li>单模板 (<code>templates/<uuid></code>) 与全量官方版式库 (<code>key-layouts.transit</code> 共 9 大类 149 套版式)</li>
|
|
173
|
+
<li>图片、视频、音频及背景图资源自动并发拉取并内联为 <code>Base64 DataURL</code>,便于离线下载与服务端持久化</li>
|
|
174
|
+
<li>Cognitect Transit-JSON 缓存表解码(<code>["^ ", ...]</code> 与 <code>^xx</code> 字典还原)及 <code>group</code> 组合容器</li>
|
|
175
|
+
<li>内嵌主题配方(<code>StyleRecipe</code> 字体、字号比例、色板、表格与图表配色)</li>
|
|
176
|
+
<li>归一化坐标映射到 <code>1280 × 720</code> 画布、背景图去重、人像裁切对焦与线性渐变形状</li>
|
|
177
|
+
</ul>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<div v-else class="input-section">
|
|
182
|
+
<div class="field-header">
|
|
183
|
+
<label class="field-label">Pitch 原始 Transit-JSON 内容</label>
|
|
184
|
+
<button v-if="rawJsonText" type="button" class="demo-link-btn" @click="rawJsonText = ''">
|
|
185
|
+
清空
|
|
186
|
+
</button>
|
|
187
|
+
</div>
|
|
188
|
+
<textarea
|
|
189
|
+
v-model="rawJsonText"
|
|
190
|
+
class="json-textarea"
|
|
191
|
+
rows="9"
|
|
192
|
+
placeholder='粘贴以 ["^ ", "~:page", ...] 开头的 Pitch 模板数据...'
|
|
193
|
+
:disabled="isLoading"
|
|
194
|
+
></textarea>
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<div v-if="isLoading && progressText" class="progress-banner">
|
|
198
|
+
{{ progressText }}
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<div v-if="errorMsg" class="error-banner">
|
|
202
|
+
{{ errorMsg }}
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
<template #footer>
|
|
207
|
+
<div class="dialog-footer">
|
|
208
|
+
<button type="button" class="btn-cancel" :disabled="isLoading" @click="handleClose">
|
|
209
|
+
取消
|
|
210
|
+
</button>
|
|
211
|
+
<div class="footer-right-actions">
|
|
212
|
+
<button
|
|
213
|
+
type="button"
|
|
214
|
+
class="btn-secondary"
|
|
215
|
+
:disabled="isLoading"
|
|
216
|
+
@click="runConvert('download')"
|
|
217
|
+
>
|
|
218
|
+
{{ isLoading ? (progressText || '处理中...') : '转换并下载 JSON' }}
|
|
219
|
+
</button>
|
|
220
|
+
<button
|
|
221
|
+
type="button"
|
|
222
|
+
class="btn-primary"
|
|
223
|
+
:disabled="isLoading"
|
|
224
|
+
@click="runConvert('import')"
|
|
225
|
+
>
|
|
226
|
+
{{ isLoading ? (progressText || '正在拉取并转换...') : '拉取并转换导入' }}
|
|
227
|
+
</button>
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
</template>
|
|
231
|
+
</el-dialog>
|
|
232
|
+
</template>
|
|
233
|
+
|
|
234
|
+
<style scoped>
|
|
235
|
+
.pitch-dialog-body {
|
|
236
|
+
display: flex;
|
|
237
|
+
flex-direction: column;
|
|
238
|
+
gap: 14px;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.mode-tabs {
|
|
242
|
+
display: flex;
|
|
243
|
+
gap: 8px;
|
|
244
|
+
background: #f1f5f9;
|
|
245
|
+
padding: 4px;
|
|
246
|
+
border-radius: 8px;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.mode-tab-btn {
|
|
250
|
+
flex: 1;
|
|
251
|
+
height: 32px;
|
|
252
|
+
border: none;
|
|
253
|
+
border-radius: 6px;
|
|
254
|
+
background: transparent;
|
|
255
|
+
color: #475569;
|
|
256
|
+
font-size: 13px;
|
|
257
|
+
font-weight: 600;
|
|
258
|
+
cursor: pointer;
|
|
259
|
+
transition: all 0.15s ease;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.mode-tab-btn.active {
|
|
263
|
+
background: #ffffff;
|
|
264
|
+
color: #2563eb;
|
|
265
|
+
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.input-section {
|
|
269
|
+
display: flex;
|
|
270
|
+
flex-direction: column;
|
|
271
|
+
gap: 8px;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.field-header {
|
|
275
|
+
display: flex;
|
|
276
|
+
align-items: center;
|
|
277
|
+
justify-content: space-between;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.field-label {
|
|
281
|
+
font-size: 13px;
|
|
282
|
+
font-weight: 600;
|
|
283
|
+
color: #1e293b;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.demo-links {
|
|
287
|
+
display: flex;
|
|
288
|
+
align-items: center;
|
|
289
|
+
gap: 6px;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.demo-divider {
|
|
293
|
+
color: #cbd5e1;
|
|
294
|
+
font-size: 12px;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.demo-link-btn {
|
|
298
|
+
border: none;
|
|
299
|
+
background: transparent;
|
|
300
|
+
color: #2563eb;
|
|
301
|
+
font-size: 12px;
|
|
302
|
+
font-weight: 500;
|
|
303
|
+
cursor: pointer;
|
|
304
|
+
padding: 0;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.demo-link-btn:hover {
|
|
308
|
+
text-decoration: underline;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.category-filter-row {
|
|
312
|
+
display: flex;
|
|
313
|
+
align-items: center;
|
|
314
|
+
gap: 10px;
|
|
315
|
+
margin-top: 2px;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.category-select {
|
|
319
|
+
flex: 1;
|
|
320
|
+
height: 34px;
|
|
321
|
+
padding: 0 10px;
|
|
322
|
+
border: 1px solid #cbd5e1;
|
|
323
|
+
border-radius: 6px;
|
|
324
|
+
font-size: 13px;
|
|
325
|
+
color: #0f172a;
|
|
326
|
+
background: #ffffff;
|
|
327
|
+
outline: none;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.category-select:focus {
|
|
331
|
+
border-color: #3b82f6;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.url-input {
|
|
335
|
+
width: 100%;
|
|
336
|
+
height: 38px;
|
|
337
|
+
padding: 0 12px;
|
|
338
|
+
border: 1px solid #cbd5e1;
|
|
339
|
+
border-radius: 8px;
|
|
340
|
+
font-size: 13px;
|
|
341
|
+
color: #0f172a;
|
|
342
|
+
box-sizing: border-box;
|
|
343
|
+
outline: none;
|
|
344
|
+
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.url-input:focus,
|
|
348
|
+
.json-textarea:focus {
|
|
349
|
+
border-color: #3b82f6;
|
|
350
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.json-textarea {
|
|
354
|
+
width: 100%;
|
|
355
|
+
padding: 10px 12px;
|
|
356
|
+
border: 1px solid #cbd5e1;
|
|
357
|
+
border-radius: 8px;
|
|
358
|
+
font-size: 12px;
|
|
359
|
+
font-family: Consolas, Monaco, monospace;
|
|
360
|
+
color: #0f172a;
|
|
361
|
+
box-sizing: border-box;
|
|
362
|
+
outline: none;
|
|
363
|
+
resize: vertical;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.resolved-url-hint {
|
|
367
|
+
font-size: 12px;
|
|
368
|
+
color: #64748b;
|
|
369
|
+
word-break: break-all;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.resolved-url-hint code {
|
|
373
|
+
background: #f1f5f9;
|
|
374
|
+
padding: 2px 6px;
|
|
375
|
+
border-radius: 4px;
|
|
376
|
+
color: #334155;
|
|
377
|
+
font-family: Consolas, Monaco, monospace;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.feature-tips {
|
|
381
|
+
margin-top: 4px;
|
|
382
|
+
padding: 10px 12px;
|
|
383
|
+
background: #f8fafc;
|
|
384
|
+
border: 1px solid #e2e8f0;
|
|
385
|
+
border-radius: 8px;
|
|
386
|
+
font-size: 12px;
|
|
387
|
+
color: #475569;
|
|
388
|
+
line-height: 1.6;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.tip-title {
|
|
392
|
+
font-weight: 600;
|
|
393
|
+
color: #334155;
|
|
394
|
+
margin-bottom: 4px;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
.feature-tips ul {
|
|
398
|
+
margin: 0;
|
|
399
|
+
padding-left: 18px;
|
|
400
|
+
}
|
|
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
|
+
|
|
412
|
+
.error-banner {
|
|
413
|
+
padding: 8px 12px;
|
|
414
|
+
background: #fef2f2;
|
|
415
|
+
border: 1px solid #fecaca;
|
|
416
|
+
border-radius: 6px;
|
|
417
|
+
color: #dc2626;
|
|
418
|
+
font-size: 12px;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.dialog-footer {
|
|
422
|
+
display: flex;
|
|
423
|
+
align-items: center;
|
|
424
|
+
justify-content: space-between;
|
|
425
|
+
width: 100%;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.footer-right-actions {
|
|
429
|
+
display: flex;
|
|
430
|
+
align-items: center;
|
|
431
|
+
gap: 8px;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
.btn-cancel,
|
|
435
|
+
.btn-secondary,
|
|
436
|
+
.btn-primary {
|
|
437
|
+
height: 34px;
|
|
438
|
+
padding: 0 14px;
|
|
439
|
+
border-radius: 6px;
|
|
440
|
+
font-size: 13px;
|
|
441
|
+
font-weight: 500;
|
|
442
|
+
cursor: pointer;
|
|
443
|
+
transition: all 0.15s ease;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.btn-cancel {
|
|
447
|
+
border: 1px solid #cbd5e1;
|
|
448
|
+
background: #ffffff;
|
|
449
|
+
color: #475569;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
.btn-cancel:hover:not(:disabled) {
|
|
453
|
+
background: #f8fafc;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.btn-secondary {
|
|
457
|
+
border: 1px solid #bfdbfe;
|
|
458
|
+
background: #eff6ff;
|
|
459
|
+
color: #1d4ed8;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.btn-secondary:hover:not(:disabled) {
|
|
463
|
+
background: #dbeafe;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.btn-primary {
|
|
467
|
+
border: none;
|
|
468
|
+
background: #2563eb;
|
|
469
|
+
color: #ffffff;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.btn-primary:hover:not(:disabled) {
|
|
473
|
+
background: #1d4ed8;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.btn-cancel:disabled,
|
|
477
|
+
.btn-secondary:disabled,
|
|
478
|
+
.btn-primary:disabled {
|
|
479
|
+
opacity: 0.6;
|
|
480
|
+
cursor: not-allowed;
|
|
481
|
+
}
|
|
482
|
+
</style>
|
|
@@ -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
|
|
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
|
|