jvs-ppt-ui 0.0.30 → 0.0.32

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.
@@ -0,0 +1,459 @@
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
+ PITCH_LAYOUT_CATEGORIES
9
+ } from '../utils/pitchConverter'
10
+
11
+ const props = defineProps<{
12
+ visible: boolean
13
+ }>()
14
+
15
+ const emit = defineEmits<{
16
+ (e: 'update:visible', val: boolean): void
17
+ }>()
18
+
19
+ const { importSlides, presentationTitle, notify } = useSlides()
20
+
21
+ const DEFAULT_DEMO_URL = 'https://cdn.backend.services.pitch.com/templates/2017ca60-c167-4153-893b-c8bd5b63c914'
22
+ const KEY_LAYOUTS_URL = 'https://app.pitch.com/static/app/13d22ab9-f7ac-4219-9a2b-241061a72fb4/key-layouts.transit'
23
+
24
+ const inputMode = ref<'url' | 'json'>('url')
25
+ const templateUrl = ref(DEFAULT_DEMO_URL)
26
+ const rawJsonText = ref('')
27
+ const selectedCategory = ref('all')
28
+ const isLoading = ref(false)
29
+ const errorMsg = ref('')
30
+
31
+ const isLayoutLibraryUrl = computed(() => {
32
+ if (inputMode.value === 'url') {
33
+ return templateUrl.value.includes('key-layouts') || templateUrl.value.endsWith('.transit')
34
+ }
35
+ return rawJsonText.value.includes('key-layout-data')
36
+ })
37
+
38
+ watch(
39
+ () => props.visible,
40
+ (val) => {
41
+ if (val) {
42
+ errorMsg.value = ''
43
+ }
44
+ }
45
+ )
46
+
47
+ function handleClose() {
48
+ if (isLoading.value) return
49
+ emit('update:visible', false)
50
+ }
51
+
52
+ function fillDemoUrl() {
53
+ inputMode.value = 'url'
54
+ templateUrl.value = DEFAULT_DEMO_URL
55
+ errorMsg.value = ''
56
+ }
57
+
58
+ function fillKeyLayoutsUrl() {
59
+ inputMode.value = 'url'
60
+ templateUrl.value = KEY_LAYOUTS_URL
61
+ errorMsg.value = ''
62
+ }
63
+
64
+ async function runConvert(action: 'import' | 'download') {
65
+ errorMsg.value = ''
66
+ const source = inputMode.value === 'url' ? templateUrl.value.trim() : rawJsonText.value.trim()
67
+ if (!source) {
68
+ errorMsg.value = inputMode.value === 'url' ? '请输入 Pitch 模板/版式库地址或 UUID' : '请粘贴 Pitch Transit-JSON 数据'
69
+ return
70
+ }
71
+
72
+ isLoading.value = true
73
+ try {
74
+ const deck = await fetchAndConvertPitchTemplate(source, {
75
+ categoryFilter: isLayoutLibraryUrl.value ? selectedCategory.value : 'all'
76
+ })
77
+ if (action === 'download') {
78
+ const blob = new Blob([JSON.stringify(deck, null, 2)], { type: 'application/json;charset=utf-8' })
79
+ saveAs(blob, `${deck.title || 'pitch-template'}.json`)
80
+ notify(`已转换并下载 "${deck.title}"(共 ${deck.slides.length} 页,${deck.styleRecipes.length} 套主题)`)
81
+ } else {
82
+ importSlides(deck)
83
+ if (deck.title) {
84
+ presentationTitle.value = deck.title
85
+ }
86
+ notify(`成功导入 "${deck.title}"(共 ${deck.slides.length} 页,${deck.styleRecipes.length} 套主题)`)
87
+ emit('update:visible', false)
88
+ }
89
+ } catch (err: any) {
90
+ errorMsg.value = err?.message || '转换失败,请检查模板地址或数据格式'
91
+ } finally {
92
+ isLoading.value = false
93
+ }
94
+ }
95
+ </script>
96
+
97
+ <template>
98
+ <el-dialog
99
+ :model-value="visible"
100
+ @update:model-value="emit('update:visible', $event)"
101
+ title="Pitch 模板拉取与转换器 (仅本地开发可见)"
102
+ width="640px"
103
+ :close-on-click-modal="!isLoading"
104
+ append-to-body
105
+ class="pitch-import-dialog"
106
+ >
107
+ <div class="pitch-dialog-body">
108
+ <div class="mode-tabs">
109
+ <button
110
+ type="button"
111
+ class="mode-tab-btn"
112
+ :class="{ active: inputMode === 'url' }"
113
+ @click="inputMode = 'url'; errorMsg = ''"
114
+ >
115
+ 通过模板地址 / UUID 拉取
116
+ </button>
117
+ <button
118
+ type="button"
119
+ class="mode-tab-btn"
120
+ :class="{ active: inputMode === 'json' }"
121
+ @click="inputMode = 'json'; errorMsg = ''"
122
+ >
123
+ 直接粘贴 Transit-JSON
124
+ </button>
125
+ </div>
126
+
127
+ <div v-if="inputMode === 'url'" class="input-section">
128
+ <div class="field-header">
129
+ <label class="field-label">Pitch 模板 / 版式库地址或 UUID</label>
130
+ <div class="demo-links">
131
+ <button type="button" class="demo-link-btn" @click="fillDemoUrl">
132
+ 示例模板 (Pride)
133
+ </button>
134
+ <span class="demo-divider">|</span>
135
+ <button type="button" class="demo-link-btn" @click="fillKeyLayoutsUrl">
136
+ 官方版式库 (key-layouts.transit)
137
+ </button>
138
+ </div>
139
+ </div>
140
+ <input
141
+ v-model="templateUrl"
142
+ type="text"
143
+ class="url-input"
144
+ placeholder="例如:https://cdn.backend.services.pitch.com/templates/2017ca60-... 或 .../key-layouts.transit"
145
+ :disabled="isLoading"
146
+ @keyup.enter="runConvert('import')"
147
+ />
148
+ <div v-if="templateUrl.trim()" class="resolved-url-hint">
149
+ 解析请求地址:<code>{{ normalizePitchTemplateUrl(templateUrl) }}</code>
150
+ </div>
151
+
152
+ <div v-if="isLayoutLibraryUrl" class="category-filter-row">
153
+ <label class="field-label">版式分类筛选:</label>
154
+ <select v-model="selectedCategory" class="category-select" :disabled="isLoading">
155
+ <option v-for="cat in PITCH_LAYOUT_CATEGORIES" :key="cat.key" :value="cat.key">
156
+ {{ cat.label }}
157
+ </option>
158
+ </select>
159
+ </div>
160
+
161
+ <div class="feature-tips">
162
+ <div class="tip-title">支持自动转换的内容:</div>
163
+ <ul>
164
+ <li>单模板 (<code>templates/&lt;uuid&gt;</code>) 与全量官方版式库 (<code>key-layouts.transit</code> 共 9 大类 149 套版式)</li>
165
+ <li>Cognitect Transit-JSON 缓存表解码(<code>["^ ", ...]</code> 与 <code>^xx</code> 字典还原)及 <code>group</code> 组合容器</li>
166
+ <li>内嵌主题配方(<code>StyleRecipe</code> 字体、字号比例、色板、表格与图表配色)</li>
167
+ <li>归一化坐标映射到 <code>1280 × 720</code> 画布、背景图去重、人像裁切对焦与线性渐变形状</li>
168
+ </ul>
169
+ </div>
170
+ </div>
171
+
172
+ <div v-else class="input-section">
173
+ <div class="field-header">
174
+ <label class="field-label">Pitch 原始 Transit-JSON 内容</label>
175
+ <button v-if="rawJsonText" type="button" class="demo-link-btn" @click="rawJsonText = ''">
176
+ 清空
177
+ </button>
178
+ </div>
179
+ <textarea
180
+ v-model="rawJsonText"
181
+ class="json-textarea"
182
+ rows="9"
183
+ placeholder='粘贴以 ["^ ", "~:page", ...] 开头的 Pitch 模板数据...'
184
+ :disabled="isLoading"
185
+ ></textarea>
186
+ </div>
187
+
188
+ <div v-if="errorMsg" class="error-banner">
189
+ {{ errorMsg }}
190
+ </div>
191
+ </div>
192
+
193
+ <template #footer>
194
+ <div class="dialog-footer">
195
+ <button type="button" class="btn-cancel" :disabled="isLoading" @click="handleClose">
196
+ 取消
197
+ </button>
198
+ <div class="footer-right-actions">
199
+ <button
200
+ type="button"
201
+ class="btn-secondary"
202
+ :disabled="isLoading"
203
+ @click="runConvert('download')"
204
+ >
205
+ {{ isLoading ? '处理中...' : '转换并下载 JSON' }}
206
+ </button>
207
+ <button
208
+ type="button"
209
+ class="btn-primary"
210
+ :disabled="isLoading"
211
+ @click="runConvert('import')"
212
+ >
213
+ {{ isLoading ? '正在拉取并转换...' : '拉取并转换导入' }}
214
+ </button>
215
+ </div>
216
+ </div>
217
+ </template>
218
+ </el-dialog>
219
+ </template>
220
+
221
+ <style scoped>
222
+ .pitch-dialog-body {
223
+ display: flex;
224
+ flex-direction: column;
225
+ gap: 14px;
226
+ }
227
+
228
+ .mode-tabs {
229
+ display: flex;
230
+ gap: 8px;
231
+ background: #f1f5f9;
232
+ padding: 4px;
233
+ border-radius: 8px;
234
+ }
235
+
236
+ .mode-tab-btn {
237
+ flex: 1;
238
+ height: 32px;
239
+ border: none;
240
+ border-radius: 6px;
241
+ background: transparent;
242
+ color: #475569;
243
+ font-size: 13px;
244
+ font-weight: 600;
245
+ cursor: pointer;
246
+ transition: all 0.15s ease;
247
+ }
248
+
249
+ .mode-tab-btn.active {
250
+ background: #ffffff;
251
+ color: #2563eb;
252
+ box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
253
+ }
254
+
255
+ .input-section {
256
+ display: flex;
257
+ flex-direction: column;
258
+ gap: 8px;
259
+ }
260
+
261
+ .field-header {
262
+ display: flex;
263
+ align-items: center;
264
+ justify-content: space-between;
265
+ }
266
+
267
+ .field-label {
268
+ font-size: 13px;
269
+ font-weight: 600;
270
+ color: #1e293b;
271
+ }
272
+
273
+ .demo-links {
274
+ display: flex;
275
+ align-items: center;
276
+ gap: 6px;
277
+ }
278
+
279
+ .demo-divider {
280
+ color: #cbd5e1;
281
+ font-size: 12px;
282
+ }
283
+
284
+ .demo-link-btn {
285
+ border: none;
286
+ background: transparent;
287
+ color: #2563eb;
288
+ font-size: 12px;
289
+ font-weight: 500;
290
+ cursor: pointer;
291
+ padding: 0;
292
+ }
293
+
294
+ .demo-link-btn:hover {
295
+ text-decoration: underline;
296
+ }
297
+
298
+ .category-filter-row {
299
+ display: flex;
300
+ align-items: center;
301
+ gap: 10px;
302
+ margin-top: 2px;
303
+ }
304
+
305
+ .category-select {
306
+ flex: 1;
307
+ height: 34px;
308
+ padding: 0 10px;
309
+ border: 1px solid #cbd5e1;
310
+ border-radius: 6px;
311
+ font-size: 13px;
312
+ color: #0f172a;
313
+ background: #ffffff;
314
+ outline: none;
315
+ }
316
+
317
+ .category-select:focus {
318
+ border-color: #3b82f6;
319
+ }
320
+
321
+ .url-input {
322
+ width: 100%;
323
+ height: 38px;
324
+ padding: 0 12px;
325
+ border: 1px solid #cbd5e1;
326
+ border-radius: 8px;
327
+ font-size: 13px;
328
+ color: #0f172a;
329
+ box-sizing: border-box;
330
+ outline: none;
331
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
332
+ }
333
+
334
+ .url-input:focus,
335
+ .json-textarea:focus {
336
+ border-color: #3b82f6;
337
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
338
+ }
339
+
340
+ .json-textarea {
341
+ width: 100%;
342
+ padding: 10px 12px;
343
+ border: 1px solid #cbd5e1;
344
+ border-radius: 8px;
345
+ font-size: 12px;
346
+ font-family: Consolas, Monaco, monospace;
347
+ color: #0f172a;
348
+ box-sizing: border-box;
349
+ outline: none;
350
+ resize: vertical;
351
+ }
352
+
353
+ .resolved-url-hint {
354
+ font-size: 12px;
355
+ color: #64748b;
356
+ word-break: break-all;
357
+ }
358
+
359
+ .resolved-url-hint code {
360
+ background: #f1f5f9;
361
+ padding: 2px 6px;
362
+ border-radius: 4px;
363
+ color: #334155;
364
+ font-family: Consolas, Monaco, monospace;
365
+ }
366
+
367
+ .feature-tips {
368
+ margin-top: 4px;
369
+ padding: 10px 12px;
370
+ background: #f8fafc;
371
+ border: 1px solid #e2e8f0;
372
+ border-radius: 8px;
373
+ font-size: 12px;
374
+ color: #475569;
375
+ line-height: 1.6;
376
+ }
377
+
378
+ .tip-title {
379
+ font-weight: 600;
380
+ color: #334155;
381
+ margin-bottom: 4px;
382
+ }
383
+
384
+ .feature-tips ul {
385
+ margin: 0;
386
+ padding-left: 18px;
387
+ }
388
+
389
+ .error-banner {
390
+ padding: 8px 12px;
391
+ background: #fef2f2;
392
+ border: 1px solid #fecaca;
393
+ border-radius: 6px;
394
+ color: #dc2626;
395
+ font-size: 12px;
396
+ }
397
+
398
+ .dialog-footer {
399
+ display: flex;
400
+ align-items: center;
401
+ justify-content: space-between;
402
+ width: 100%;
403
+ }
404
+
405
+ .footer-right-actions {
406
+ display: flex;
407
+ align-items: center;
408
+ gap: 8px;
409
+ }
410
+
411
+ .btn-cancel,
412
+ .btn-secondary,
413
+ .btn-primary {
414
+ height: 34px;
415
+ padding: 0 14px;
416
+ border-radius: 6px;
417
+ font-size: 13px;
418
+ font-weight: 500;
419
+ cursor: pointer;
420
+ transition: all 0.15s ease;
421
+ }
422
+
423
+ .btn-cancel {
424
+ border: 1px solid #cbd5e1;
425
+ background: #ffffff;
426
+ color: #475569;
427
+ }
428
+
429
+ .btn-cancel:hover:not(:disabled) {
430
+ background: #f8fafc;
431
+ }
432
+
433
+ .btn-secondary {
434
+ border: 1px solid #bfdbfe;
435
+ background: #eff6ff;
436
+ color: #1d4ed8;
437
+ }
438
+
439
+ .btn-secondary:hover:not(:disabled) {
440
+ background: #dbeafe;
441
+ }
442
+
443
+ .btn-primary {
444
+ border: none;
445
+ background: #2563eb;
446
+ color: #ffffff;
447
+ }
448
+
449
+ .btn-primary:hover:not(:disabled) {
450
+ background: #1d4ed8;
451
+ }
452
+
453
+ .btn-cancel:disabled,
454
+ .btn-secondary:disabled,
455
+ .btn-primary:disabled {
456
+ opacity: 0.6;
457
+ cursor: not-allowed;
458
+ }
459
+ </style>
@@ -15,6 +15,7 @@ import SidebarDesignPanel from './sidebar/panels/SidebarDesignPanel.vue'
15
15
  import SidebarAnimationPanel from './sidebar/panels/SidebarAnimationPanel.vue'
16
16
  import SidebarShapeFormatPanel from './sidebar/panels/SidebarShapeFormatPanel.vue'
17
17
  import SidebarTransitionPanel from './sidebar/panels/SidebarTransitionPanel.vue'
18
+ import ChartDataEditorDialog from './sidebar/dialogs/ChartDataEditorDialog.vue'
18
19
  import { useSidebarDesign } from '../composables/sidebar/useSidebarDesign'
19
20
  import { useSidebarAnimation } from '../composables/sidebar/useSidebarAnimation'
20
21
  import { useSidebarTable } from '../composables/sidebar/useSidebarTable'
@@ -290,19 +291,30 @@ watch(selectedElementId, (newId) => {
290
291
  })
291
292
 
292
293
 
293
- const {
294
- chartDataDialogVisible,
295
- tempChartDataText,
296
- chartPrimaryColor,
297
- currentChartPaletteId,
298
- currentChartColors,
299
- chartPresetPalettes,
300
- selectChartPalette,
301
- chartTextColor,
302
- chartGridColor,
303
- changeChartType,
304
- openChartDataDialog,
305
- saveChartData
294
+ const {
295
+ chartDataDialogVisible,
296
+ tempChartDataText,
297
+ tempChartLabels,
298
+ tempChartDatasets,
299
+ chartEditMode,
300
+ previewChartType,
301
+ chartPrimaryColor,
302
+ currentChartPaletteId,
303
+ currentChartColors,
304
+ chartPresetPalettes,
305
+ selectChartPalette,
306
+ chartTextColor,
307
+ chartGridColor,
308
+ changeChartType,
309
+ addChartRow,
310
+ removeChartRow,
311
+ addChartSeries,
312
+ removeChartSeries,
313
+ transposeChartData,
314
+ syncStructuredToText,
315
+ syncTextToStructured,
316
+ openChartDataDialog,
317
+ saveChartData
306
318
  } = useSidebarChart(selectedElement, addHistorySnapshot)
307
319
 
308
320
  watch(() => selectedElementIds.value.length, (newLength) => {
@@ -1643,7 +1655,20 @@ function handleUndockToPopover() {
1643
1655
  :recent-colors="quickRecentColors"
1644
1656
  :is-fill-enabled="isFillEnabled"
1645
1657
  :is-fill-expanded="isFillExpanded"
1646
- :fill-hex="fillHex"
1658
+ :fill-hex="fillHex"
1659
+ :shape-fill-type="shapeFillType"
1660
+ :fill-opacity="fillAlpha"
1661
+ :gradient-path-type="gradientPathType"
1662
+ :gradient-direction="gradientDirection"
1663
+ :gradient-start-hex="gradientStartHex"
1664
+ :gradient-end-hex="gradientEndHex"
1665
+ :gradient-angle="gradientAngle"
1666
+ :shape-pattern-fill="shapePatternFill"
1667
+ :shape-pattern-type="shapePatternType"
1668
+ :shape-pattern-fg="shapePatternFg"
1669
+ :shape-pattern-bg="shapePatternBg"
1670
+ :border-alpha="borderAlpha"
1671
+ :shadow-alpha="shadowAlpha"
1647
1672
  :is-border-enabled="enableBorder"
1648
1673
  :is-border-expanded="isBorderExpanded"
1649
1674
  :border-hex="borderHex"
@@ -1685,7 +1710,23 @@ function handleUndockToPopover() {
1685
1710
  @select-chart-palette="selectChartPalette"
1686
1711
  @update:is-fill-enabled="isFillEnabled = $event"
1687
1712
  @update:is-fill-expanded="isFillExpanded = $event"
1688
- @update:fill-hex="fillHex = $event"
1713
+ @update:fill-hex="fillHex = $event"
1714
+ @update:shape-fill-type="shapeFillType = $event"
1715
+ @update:fill-opacity="fillAlpha = $event"
1716
+ @update:gradient-path-type="gradientPathType = $event"
1717
+ @update:gradient-direction="gradientDirection = $event"
1718
+ @update:gradient-start-hex="gradientStartHex = $event"
1719
+ @update:gradient-end-hex="gradientEndHex = $event"
1720
+ @update:gradient-angle="gradientAngle = $event"
1721
+ @update:element-gradient="updateElementGradient"
1722
+ @update:shape-pattern-fill="shapePatternFill = $event"
1723
+ @update:shape-pattern-type="shapePatternType = $event"
1724
+ @update:shape-pattern-fg="shapePatternFg = $event"
1725
+ @update:shape-pattern-bg="shapePatternBg = $event"
1726
+ @handle-shape-pattern-upload="handleShapePatternUpload"
1727
+ @clear-shape-pattern-fill="clearShapePatternFill"
1728
+ @update:border-alpha="borderAlpha = $event"
1729
+ @update:shadow-alpha="shadowAlpha = $event"
1689
1730
  @update:is-border-enabled="enableBorder = $event"
1690
1731
  @update:is-border-expanded="isBorderExpanded = $event"
1691
1732
  @update:border-hex="borderHex = $event"
@@ -2129,26 +2170,25 @@ function handleUndockToPopover() {
2129
2170
 
2130
2171
 
2131
2172
 
2132
- <!-- Chart Data Editor Dialog -->
2133
- <el-dialog v-model="chartDataDialogVisible" title="编辑图表数据" width="480px" destroy-on-close align-center>
2134
- <div style="display: flex; flex-direction: column; gap: 12px; padding: 10px 0;">
2135
- <div style="font-size: 12px; color: var(--text-muted); line-height: 1.5;">
2136
- 格式: 标签, 系列1数据, 系列2数据...<br />
2137
- 例如:<br />
2138
- 一月,30,20<br />
2139
- 二月,45,30<br />
2140
- 三月,55,40
2141
- </div>
2142
- <el-input type="textarea" v-model="tempChartDataText" :rows="10" placeholder="请输入图表数据..."
2143
- style="font-family: monospace; font-size: 12px;" />
2144
- </div>
2145
- <template #footer>
2146
- <div style="display: flex; justify-content: flex-end; gap: 8px;">
2147
- <el-button size="small" @click="chartDataDialogVisible = false">取消</el-button>
2148
- <el-button type="primary" size="small" @click="saveChartData">保存</el-button>
2149
- </div>
2150
- </template>
2151
- </el-dialog>
2173
+ <!-- Chart Data Editor Dialog (方案二:左表右图双栏实时预览版) -->
2174
+ <ChartDataEditorDialog
2175
+ v-model:visible="chartDataDialogVisible"
2176
+ v-model:labels="tempChartLabels"
2177
+ v-model:datasets="tempChartDatasets"
2178
+ v-model:csv-text="tempChartDataText"
2179
+ v-model:edit-mode="chartEditMode"
2180
+ v-model:preview-chart-type="previewChartType"
2181
+ :element="selectedElement"
2182
+ :chart-colors="currentChartColors"
2183
+ @add-row="addChartRow"
2184
+ @remove-row="removeChartRow"
2185
+ @add-series="addChartSeries"
2186
+ @remove-series="removeChartSeries"
2187
+ @transpose="transposeChartData"
2188
+ @sync-from-table="syncStructuredToText"
2189
+ @sync-from-csv="syncTextToStructured"
2190
+ @save="saveChartData"
2191
+ />
2152
2192
  </aside>
2153
2193
  </template>
2154
2194