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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jvs-ppt-ui",
3
3
  "private": false,
4
- "version": "0.0.30",
4
+ "version": "0.0.32",
5
5
  "type": "module",
6
6
  "main": "./dist/lib/jvs-ppt-ui.umd.js",
7
7
  "module": "./dist/lib/jvs-ppt-ui.es.js",
@@ -33,6 +33,10 @@ import {
33
33
  getSlideBackgroundCss,
34
34
  getLuminance,
35
35
  getImageObjectFitStyle,
36
+ getElementPattern,
37
+ isElementPatternTile,
38
+ getElementPatternTileSize,
39
+ getElementGradientCss,
36
40
  getElementFill,
37
41
  hasElementFill,
38
42
  hasElementBorder,
@@ -8409,7 +8413,11 @@ async function handleGlobalPaste(e: ClipboardEvent) {
8409
8413
  <!-- Chart element -->
8410
8414
  <template v-else-if="el.type === 'chart'">
8411
8415
  <div style="width: 100%; height: 100%; overflow: visible; box-sizing: border-box;" :style="{
8412
- backgroundColor: el.style.fill || 'transparent',
8416
+ backgroundColor: (getElementPattern(el) || getElementGradientCss(el)) ? 'transparent' : (el.style.fill || 'transparent'),
8417
+ backgroundImage: getElementPattern(el) ? `url('${getElementPattern(el)}')` : (getElementGradientCss(el) || 'none'),
8418
+ backgroundSize: getElementPattern(el) ? (isElementPatternTile(el) ? `${getElementPatternTileSize(el).w}px ${getElementPatternTileSize(el).h}px` : 'cover') : undefined,
8419
+ backgroundPosition: getElementPattern(el) ? (isElementPatternTile(el) ? '0 0' : 'center center') : undefined,
8420
+ backgroundRepeat: getElementPattern(el) ? (isElementPatternTile(el) ? 'repeat' : 'no-repeat') : undefined,
8413
8421
  borderWidth: el.style.borderWidth || '0px',
8414
8422
  borderStyle: el.style.borderStyle || 'solid',
8415
8423
  borderColor: el.style.borderColor || 'transparent',
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { ref } from 'vue'
2
+ import { ref, watch } from 'vue'
3
3
  import { useSlides } from '../composables/useSlides'
4
4
 
5
5
  import baseBarImg from '../assets/chart/baseBar.png'
@@ -13,6 +13,10 @@ import bubbleChartImg from '../assets/chart/bubbleChart.png'
13
13
  import radarChartImg from '../assets/chart/radarChart.png'
14
14
  import otherLineChartImg from '../assets/chart/otherLineChart.png'
15
15
 
16
+ const props = defineProps<{
17
+ currentType?: string
18
+ }>()
19
+
16
20
  const { notify } = useSlides()
17
21
  const emit = defineEmits(['select'])
18
22
 
@@ -30,10 +34,33 @@ const chartCategories = [
30
34
  { id: 'mini', name: '迷你图' }
31
35
  ]
32
36
 
37
+ function resolveCategoryByType(type?: string): string {
38
+ if (!type) return 'pie'
39
+ if (['pie', 'donut', 'rose-pie', 'rose-donut', 'pieChart', 'doughnutChart'].includes(type)) return 'pie'
40
+ if (['bar', 'percent-bar', 'stacked-bar', 'barChart'].includes(type)) return 'bar'
41
+ if (['line', 'compare-line', 'step-line', 'lineChart'].includes(type)) return 'line'
42
+ if (['horizontal-bar', 'stacked-horizontal-bar'].includes(type)) return 'horizontal-bar'
43
+ if (['area', 'stacked-area', 'areaChart'].includes(type)) return 'area'
44
+ if (type === 'scatter') return 'scatter'
45
+ if (type === 'radar') return 'radar'
46
+ return 'pie'
47
+ }
48
+
49
+ watch(
50
+ () => props.currentType,
51
+ (newType) => {
52
+ if (newType) {
53
+ activeChartCategory.value = resolveCategoryByType(newType)
54
+ }
55
+ },
56
+ { immediate: true }
57
+ )
58
+
33
59
  function scrollToCategory(catId: string) {
34
60
  activeChartCategory.value = catId
35
- const el = document.getElementById(`chart-sec-${catId}`)
36
- if (el && scrollContainerRef.value) {
61
+ if (!scrollContainerRef.value) return
62
+ const el = scrollContainerRef.value.querySelector(`[data-chart-sec="${catId}"]`) as HTMLElement | null
63
+ if (el) {
37
64
  const containerTop = scrollContainerRef.value.getBoundingClientRect().top
38
65
  const sectionTop = el.getBoundingClientRect().top
39
66
  const currentScroll = scrollContainerRef.value.scrollTop
@@ -48,7 +75,7 @@ function onScroll() {
48
75
  if (!scrollContainerRef.value) return
49
76
  const containerTop = scrollContainerRef.value.getBoundingClientRect().top
50
77
  for (const cat of chartCategories) {
51
- const el = document.getElementById(`chart-sec-${cat.id}`)
78
+ const el = scrollContainerRef.value.querySelector(`[data-chart-sec="${cat.id}"]`) as HTMLElement | null
52
79
  if (el) {
53
80
  const rect = el.getBoundingClientRect()
54
81
  if (rect.top - containerTop <= 60 && rect.bottom - containerTop > 20) {
@@ -85,11 +112,11 @@ function handleSelect(chartType: string, isMini = false) {
85
112
  <!-- Scrollable Content with Category Sections -->
86
113
  <div class="chart-scroll-content" ref="scrollContainerRef" @scroll="onScroll">
87
114
  <!-- 1. 饼图 Section -->
88
- <div class="chart-section" id="chart-sec-pie">
115
+ <div class="chart-section" data-chart-sec="pie">
89
116
  <div class="chart-section-title">饼图</div>
90
117
  <div class="chart-grid-4">
91
118
  <!-- 基础饼图 -->
92
- <div class="chart-card-item" @click="handleSelect('pie')">
119
+ <div class="chart-card-item" :class="{ active: currentType === 'pie' }" @click="handleSelect('pie')">
93
120
  <div class="chart-card-thumb">
94
121
  <div class="chart-thumb-box">
95
122
  <img :src="basePieImg" alt="基础饼图" />
@@ -99,7 +126,7 @@ function handleSelect(chartType: string, isMini = false) {
99
126
  </div>
100
127
 
101
128
  <!-- 环图 -->
102
- <div class="chart-card-item" @click="handleSelect('donut')">
129
+ <div class="chart-card-item" :class="{ active: currentType === 'donut' }" @click="handleSelect('donut')">
103
130
  <div class="chart-card-thumb">
104
131
  <div class="chart-thumb-box">
105
132
  <img :src="circyChartImg" alt="环图" />
@@ -109,7 +136,7 @@ function handleSelect(chartType: string, isMini = false) {
109
136
  </div>
110
137
 
111
138
  <!-- 玫瑰图 -->
112
- <div class="chart-card-item" @click="handleSelect('pie')">
139
+ <div class="chart-card-item" :class="{ active: currentType === 'rose-pie' }" @click="handleSelect('rose-pie')">
113
140
  <div class="chart-card-thumb">
114
141
  <div class="chart-thumb-box">
115
142
  <img :src="roseCircyChartImg" alt="玫瑰图" />
@@ -119,7 +146,7 @@ function handleSelect(chartType: string, isMini = false) {
119
146
  </div>
120
147
 
121
148
  <!-- 玫瑰环图 -->
122
- <div class="chart-card-item" @click="handleSelect('donut')">
149
+ <div class="chart-card-item" :class="{ active: currentType === 'rose-donut' }" @click="handleSelect('rose-donut')">
123
150
  <div class="chart-card-thumb">
124
151
  <div class="chart-thumb-box">
125
152
  <svg viewBox="0 0 36 36" width="72" height="72" fill="none">
@@ -136,11 +163,11 @@ function handleSelect(chartType: string, isMini = false) {
136
163
  </div>
137
164
 
138
165
  <!-- 2. 柱状图 Section -->
139
- <div class="chart-section" id="chart-sec-bar">
166
+ <div class="chart-section" data-chart-sec="bar">
140
167
  <div class="chart-section-title">柱状图</div>
141
168
  <div class="chart-grid-4">
142
169
  <!-- 基础柱状图 -->
143
- <div class="chart-card-item" @click="handleSelect('bar')">
170
+ <div class="chart-card-item" :class="{ active: currentType === 'bar' }" @click="handleSelect('bar')">
144
171
  <div class="chart-card-thumb">
145
172
  <div class="chart-thumb-box">
146
173
  <img :src="baseHistogramImg" alt="基础柱状图" />
@@ -150,7 +177,7 @@ function handleSelect(chartType: string, isMini = false) {
150
177
  </div>
151
178
 
152
179
  <!-- 百分比柱状图 -->
153
- <div class="chart-card-item" @click="handleSelect('bar')">
180
+ <div class="chart-card-item" :class="{ active: currentType === 'percent-bar' }" @click="handleSelect('percent-bar')">
154
181
  <div class="chart-card-thumb">
155
182
  <div class="chart-thumb-box">
156
183
  <svg viewBox="0 0 36 36" width="72" height="72" fill="none">
@@ -174,7 +201,7 @@ function handleSelect(chartType: string, isMini = false) {
174
201
  </div>
175
202
 
176
203
  <!-- 堆叠柱状图 -->
177
- <div class="chart-card-item" @click="handleSelect('bar')">
204
+ <div class="chart-card-item" :class="{ active: currentType === 'stacked-bar' }" @click="handleSelect('stacked-bar')">
178
205
  <div class="chart-card-thumb">
179
206
  <div class="chart-thumb-box">
180
207
  <svg viewBox="0 0 36 36" width="72" height="72" fill="none">
@@ -197,11 +224,11 @@ function handleSelect(chartType: string, isMini = false) {
197
224
  </div>
198
225
 
199
226
  <!-- 3. 折线图 Section -->
200
- <div class="chart-section" id="chart-sec-line">
227
+ <div class="chart-section" data-chart-sec="line">
201
228
  <div class="chart-section-title">折线图</div>
202
229
  <div class="chart-grid-4">
203
230
  <!-- 折线图 -->
204
- <div class="chart-card-item" @click="handleSelect('line')">
231
+ <div class="chart-card-item" :class="{ active: currentType === 'line' }" @click="handleSelect('line')">
205
232
  <div class="chart-card-thumb">
206
233
  <div class="chart-thumb-box">
207
234
  <img :src="lineChartImg" alt="折线图" />
@@ -211,7 +238,7 @@ function handleSelect(chartType: string, isMini = false) {
211
238
  </div>
212
239
 
213
240
  <!-- 对比折线图 -->
214
- <div class="chart-card-item" @click="handleSelect('line')">
241
+ <div class="chart-card-item" :class="{ active: currentType === 'compare-line' }" @click="handleSelect('compare-line')">
215
242
  <div class="chart-card-thumb">
216
243
  <div class="chart-thumb-box">
217
244
  <svg viewBox="0 0 36 36" width="72" height="72" fill="none">
@@ -225,7 +252,7 @@ function handleSelect(chartType: string, isMini = false) {
225
252
  </div>
226
253
 
227
254
  <!-- 其他折线图 -->
228
- <div class="chart-card-item" @click="handleSelect('line')">
255
+ <div class="chart-card-item" :class="{ active: currentType === 'step-line' }" @click="handleSelect('step-line')">
229
256
  <div class="chart-card-thumb">
230
257
  <div class="chart-thumb-box">
231
258
  <svg viewBox="0 0 36 36" width="72" height="72" fill="none">
@@ -238,7 +265,7 @@ function handleSelect(chartType: string, isMini = false) {
238
265
  </div>
239
266
 
240
267
  <!-- 基础面积图 -->
241
- <div class="chart-card-item" @click="handleSelect('area')">
268
+ <div class="chart-card-item" :class="{ active: currentType === 'area' }" @click="handleSelect('area')">
242
269
  <div class="chart-card-thumb">
243
270
  <div class="chart-thumb-box">
244
271
  <img :src="baseAreaImg" alt="基础面积图" />
@@ -250,10 +277,10 @@ function handleSelect(chartType: string, isMini = false) {
250
277
  </div>
251
278
 
252
279
  <!-- 4. 条形图 Section -->
253
- <div class="chart-section" id="chart-sec-horizontal-bar">
280
+ <div class="chart-section" data-chart-sec="horizontal-bar">
254
281
  <div class="chart-section-title">条形图</div>
255
282
  <div class="chart-grid-4">
256
- <div class="chart-card-item" @click="handleSelect('horizontal-bar')">
283
+ <div class="chart-card-item" :class="{ active: currentType === 'horizontal-bar' }" @click="handleSelect('horizontal-bar')">
257
284
  <div class="chart-card-thumb">
258
285
  <div class="chart-thumb-box">
259
286
  <img :src="baseBarImg" alt="基础条形图" />
@@ -261,7 +288,7 @@ function handleSelect(chartType: string, isMini = false) {
261
288
  </div>
262
289
  <span class="chart-card-name">基础条形图</span>
263
290
  </div>
264
- <div class="chart-card-item" @click="handleSelect('horizontal-bar')">
291
+ <div class="chart-card-item" :class="{ active: currentType === 'stacked-horizontal-bar' }" @click="handleSelect('stacked-horizontal-bar')">
265
292
  <div class="chart-card-thumb">
266
293
  <div class="chart-thumb-box">
267
294
  <svg viewBox="0 0 36 36" width="72" height="72" fill="none">
@@ -281,10 +308,10 @@ function handleSelect(chartType: string, isMini = false) {
281
308
  </div>
282
309
 
283
310
  <!-- 5. 面积图 Section -->
284
- <div class="chart-section" id="chart-sec-area">
311
+ <div class="chart-section" data-chart-sec="area">
285
312
  <div class="chart-section-title">面积图</div>
286
313
  <div class="chart-grid-4">
287
- <div class="chart-card-item" @click="handleSelect('area')">
314
+ <div class="chart-card-item" :class="{ active: currentType === 'area' }" @click="handleSelect('area')">
288
315
  <div class="chart-card-thumb">
289
316
  <div class="chart-thumb-box">
290
317
  <img :src="baseAreaImg" alt="基础面积图" />
@@ -292,7 +319,7 @@ function handleSelect(chartType: string, isMini = false) {
292
319
  </div>
293
320
  <span class="chart-card-name">基础面积图</span>
294
321
  </div>
295
- <div class="chart-card-item" @click="handleSelect('area')">
322
+ <div class="chart-card-item" :class="{ active: currentType === 'stacked-area' }" @click="handleSelect('stacked-area')">
296
323
  <div class="chart-card-thumb">
297
324
  <div class="chart-thumb-box">
298
325
  <svg viewBox="0 0 36 36" width="72" height="72" fill="none">
@@ -308,10 +335,10 @@ function handleSelect(chartType: string, isMini = false) {
308
335
  </div>
309
336
 
310
337
  <!-- 6. 散点图 Section -->
311
- <div class="chart-section" id="chart-sec-scatter">
338
+ <div class="chart-section" data-chart-sec="scatter">
312
339
  <div class="chart-section-title">散点图</div>
313
340
  <div class="chart-grid-4">
314
- <div class="chart-card-item" @click="handleSelect('scatter')">
341
+ <div class="chart-card-item" :class="{ active: currentType === 'scatter' }" @click="handleSelect('scatter')">
315
342
  <div class="chart-card-thumb">
316
343
  <div class="chart-thumb-box">
317
344
  <img :src="bubbleChartImg" alt="散点图" />
@@ -323,10 +350,10 @@ function handleSelect(chartType: string, isMini = false) {
323
350
  </div>
324
351
 
325
352
  <!-- 7. 雷达图 Section -->
326
- <div class="chart-section" id="chart-sec-radar">
353
+ <div class="chart-section" data-chart-sec="radar">
327
354
  <div class="chart-section-title">雷达图</div>
328
355
  <div class="chart-grid-4">
329
- <div class="chart-card-item" @click="handleSelect('radar')">
356
+ <div class="chart-card-item" :class="{ active: currentType === 'radar' }" @click="handleSelect('radar')">
330
357
  <div class="chart-card-thumb">
331
358
  <div class="chart-thumb-box">
332
359
  <img :src="radarChartImg" alt="雷达图" />
@@ -338,7 +365,7 @@ function handleSelect(chartType: string, isMini = false) {
338
365
  </div>
339
366
 
340
367
  <!-- 8. 迷你图 Section -->
341
- <div class="chart-section" id="chart-sec-mini">
368
+ <div class="chart-section" data-chart-sec="mini">
342
369
  <div class="chart-section-title">迷你图</div>
343
370
  <div class="chart-grid-4">
344
371
  <div class="chart-card-item" @click="handleSelect('mini', true)">
@@ -464,11 +491,24 @@ function handleSelect(chartType: string, isMini = false) {
464
491
  width: 120px;
465
492
  height: 88px;
466
493
  background: #f8fafc;
494
+ border: 1.5px solid transparent;
467
495
  border-radius: 6px;
468
496
  display: flex;
469
497
  align-items: center;
470
498
  justify-content: center;
471
499
  transition: all 0.15s ease;
500
+ box-sizing: border-box;
501
+ }
502
+
503
+ .chart-card-item.active .chart-card-thumb {
504
+ background: #eff6ff;
505
+ border-color: #2563eb;
506
+ box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
507
+ }
508
+
509
+ .chart-card-item.active .chart-card-name {
510
+ color: #2563eb;
511
+ font-weight: 600;
472
512
  }
473
513
 
474
514
  .chart-thumb-box {
@@ -16,6 +16,8 @@ import { inferElementTextType, type SlideTextType } from '../utils/textTypes'
16
16
  import { applyGroupGeometryFlip } from '../utils/groupFlip'
17
17
  // 快捷键弹层异步化;mock DSL 模板(~77KB)改为触发时动态加载
18
18
  const ShortcutsDialog = defineAsyncComponent(() => import('./ShortcutsDialog.vue'))
19
+ const PitchImportDialog = defineAsyncComponent(() => import('./PitchImportDialog.vue'))
20
+ const isLocalDev = import.meta.env.DEV
19
21
 
20
22
  const { presentationTitle, exportSlides, importSlides, currentZipMeta, startPresentation, activeIndex, slides, notify, renderLatexToSvg, globalFontFamily, globalFontColor, globalThemeColor, themeSchemeFillMap, themeClrScheme, logicalWidth, logicalHeight, dslInputDialogVisible, aiPptDialogVisible, shortcutsDialogVisible, registerPPTParser, isMasterEditingView, enterMasterView, exitMasterView, zoomRatio, resetZoom, normalizeSlideBackground, getEffectiveMasterElementsForSlide, getEffectiveSlideBackground, uploadMediaResourcesInSlides, getCustomUploadHandler, isReadonly } = useSlides()
21
23
  import { sanitizeNbspInHtml, checkIsVertical } from '../composables/useSlides'
@@ -24,6 +26,13 @@ import { sanitizeNbspInHtml, checkIsVertical } from '../composables/useSlides'
24
26
  const shortcutsOpened = ref(false)
25
27
  watch(shortcutsDialogVisible, v => { if (v) shortcutsOpened.value = true })
26
28
 
29
+ const pitchDialogVisible = ref(false)
30
+ const pitchDialogOpened = ref(false)
31
+ watch(pitchDialogVisible, v => { if (v) pitchDialogOpened.value = true })
32
+ const triggerPitchImport = () => {
33
+ pitchDialogVisible.value = true
34
+ }
35
+
27
36
  function handleZoomCommand(command: string | number) {
28
37
  if (command === 'reset') {
29
38
  resetZoom()
@@ -123,12 +132,15 @@ const onJSONFileChange = (e: Event) => {
123
132
  await ensurePptxShapes()
124
133
  const data = JSON.parse(event.target?.result as string)
125
134
  if (Array.isArray(data)) {
126
- if (uploadMediaResourcesInSlides) {
135
+ const isPitchTransit = data[0] === '^ '
136
+ if (!isPitchTransit && uploadMediaResourcesInSlides) {
127
137
  await uploadMediaResourcesInSlides(data)
128
138
  }
129
139
  importSlides(data)
130
- const nameWithoutExt = file.name.substring(0, file.name.lastIndexOf('.'))
131
- presentationTitle.value = nameWithoutExt
140
+ if (!isPitchTransit) {
141
+ const nameWithoutExt = file.name.substring(0, file.name.lastIndexOf('.'))
142
+ presentationTitle.value = nameWithoutExt
143
+ }
132
144
  } else if (data && typeof data === 'object' && Array.isArray(data.slides)) {
133
145
  const isRawPPTX = (() => {
134
146
  if (!data.size || !Array.isArray(data.slides)) return false
@@ -7614,6 +7626,21 @@ defineExpose({
7614
7626
  <div class="import-label">JVS-PPT</div>
7615
7627
  <div class="import-subtext">(专属格式)</div>
7616
7628
  </div>
7629
+
7630
+ <!-- Pitch Template Import (仅本地开发可见) -->
7631
+ <div v-if="isLocalDev" class="import-card" @click="handleMenuAction(triggerPitchImport)">
7632
+ <div class="import-icon-box pitch-icon">
7633
+ <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
7634
+ <path
7635
+ d="M4 4C4 2.89543 4.89543 2 6 2H14L20 8V20C20 21.1046 19.1046 22 18 22H6C4.89543 22 4 21.1046 4 20V4Z"
7636
+ fill="#7c3aed" />
7637
+ <path d="M14 2V8H20L14 2Z" fill="#5b21b6" />
7638
+ <text x="7" y="17" fill="#fff" font-size="9" font-weight="900" font-family="Arial">P</text>
7639
+ </svg>
7640
+ </div>
7641
+ <div class="import-label">Pitch 模板</div>
7642
+ <div class="import-subtext">(本地开发)</div>
7643
+ </div>
7617
7644
  </div>
7618
7645
 
7619
7646
  <!-- Divider -->
@@ -7774,6 +7801,18 @@ defineExpose({
7774
7801
  <span>退出母版</span>
7775
7802
  </button>
7776
7803
 
7804
+ <!-- Pitch Template Converter Button (仅本地开发模式显示) -->
7805
+ <button v-if="isLocalDev && !isReadonly" class="btn-master-toggle" @click="triggerPitchImport" title="Pitch 模板拉取转换 (仅本地开发可见)"
7806
+ style="background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe;">
7807
+ <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2"
7808
+ stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;">
7809
+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
7810
+ <polyline points="7 10 12 15 17 10" />
7811
+ <line x1="12" y1="15" x2="12" y2="3" />
7812
+ </svg>
7813
+ <span>Pitch 转换</span>
7814
+ </button>
7815
+
7777
7816
  <!-- Slide Master Mode Toggle Button -->
7778
7817
  <button v-if="!isMasterEditingView && !isReadonly" class="btn-master-toggle" @click="enterMasterView()" title="母版"
7779
7818
  data-tooltip="母版">
@@ -7837,6 +7876,8 @@ defineExpose({
7837
7876
 
7838
7877
  <!-- Shortcuts Dialog Modal -->
7839
7878
  <ShortcutsDialog v-if="shortcutsOpened" v-model:visible="shortcutsDialogVisible" />
7879
+ <!-- Pitch Import Dialog Modal (Dev Only) -->
7880
+ <PitchImportDialog v-if="isLocalDev && pitchDialogOpened" v-model:visible="pitchDialogVisible" />
7840
7881
  </header>
7841
7882
 
7842
7883
  <teleport to="body">