jvs-ppt-ui 0.0.34 → 0.0.36

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.
@@ -290,11 +290,11 @@ function ensureBgImageSizeLoaded(url: string) {
290
290
  ...bgImageNaturalSizes.value,
291
291
  [url]: { w, h }
292
292
  }
293
- // 若当前幻灯片正在使用该图片且处于居中或平铺模式,按真实尺寸比例刷新背景 CSS
293
+ // 仅当用户显式在面板上选择了居中/平铺模式 (bgImageMode 已写入 slide) 时,才在图片尺寸加载后回写精确百分比
294
294
  const curUrl = extractUrlFromBgCss(activeSlide.value?.background)
295
- const curMode = bgImageMode.value
296
- if (activeSlide.value && curUrl === url && (curMode === 'cover' || curMode === 'tile')) {
297
- const formatted = formatSlideBgImageCss(url, curMode)
295
+ const explicitMode = (activeSlide.value as any)?.bgImageMode
296
+ if (activeSlide.value && curUrl === url && (explicitMode === 'cover' || explicitMode === 'tile')) {
297
+ const formatted = formatSlideBgImageCss(url, explicitMode)
298
298
  if (activeSlide.value.background !== formatted) {
299
299
  activeSlide.value.background = formatted
300
300
  }
@@ -687,15 +687,8 @@ watch(
687
687
  const effectiveType = activeSlide.value?.bgType || (bg ? normalizeSlideBackground(bg).bgType : 'color')
688
688
  if (effectiveType === 'image' || (typeof bg === 'string' && bg.includes('url('))) {
689
689
  const url = extractUrlFromBgCss(bg)
690
- if (url && !url.startsWith('data:image/svg+xml') && activeSlide.value) {
691
- ; (activeSlide.value as any)._lastBgImageUrl = url
690
+ if (url && !url.startsWith('data:image/svg+xml')) {
692
691
  ensureBgImageSizeLoaded(url)
693
- if (!(activeSlide.value as any)?.isPattern) {
694
- const formatted = formatSlideBgImageCss(url, bgImageMode.value)
695
- if (typeof bg === 'string' && bg !== formatted) {
696
- activeSlide.value.background = formatted
697
- }
698
- }
699
692
  }
700
693
  if ((typeof bg === 'string' && bg.includes('data:image/svg+xml')) || (activeSlide.value as any)?.isPattern) {
701
694
  activeBgTab.value = 'pattern'
@@ -1304,8 +1297,8 @@ watch(extractTab, () => {
1304
1297
  <!-- Card Header: Title + More Actions Menu -->
1305
1298
  <div class="theme-card-header">
1306
1299
  <span class="theme-name-text">{{ recipe.name }}</span>
1307
- <el-popover trigger="click" placement="left-start" popper-class="theme-actions-popper" :width="156"
1308
- :offset="175" :show-arrow="false" :teleported="true">
1300
+ <el-popover trigger="click" placement="bottom-end" popper-class="theme-actions-popper" :width="156"
1301
+ :offset="4" :show-arrow="false" :teleported="true">
1309
1302
  <template #reference>
1310
1303
  <button class="theme-more-btn" @click.stop title="更多选项">
1311
1304
  <svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor">
@@ -475,7 +475,7 @@ export function useCanvasContextMenu(options: ContextMenuOptions) {
475
475
  }
476
476
  }
477
477
 
478
- elements.forEach((el: any, idx: number) => {
478
+ activeSlide.value.elements.forEach((el: any, idx: number) => {
479
479
  if (el) el.order = idx + 1
480
480
  })
481
481
 
@@ -1,4 +1,4 @@
1
- import { ref, computed, type ComputedRef } from 'vue'
1
+ import { ref, computed, watch, type ComputedRef } from 'vue'
2
2
  import { generateMonoPalette } from '../../utils/palette'
3
3
 
4
4
  export const CHART_PRESET_PALETTES = [
@@ -22,6 +22,7 @@ export function useSidebarChart(
22
22
  selectedElement: ComputedRef<any>,
23
23
  addHistorySnapshot: () => void
24
24
  ) {
25
+ const chartActiveTab = ref<'chart' | 'data'>('chart')
25
26
  const chartDataDialogVisible = ref(false)
26
27
  const tempChartDataText = ref('')
27
28
  const tempChartLabels = ref<string[]>([])
@@ -181,19 +182,92 @@ export function useSidebarChart(
181
182
  return getDefaultStructuredData(el)
182
183
  }
183
184
 
185
+ let isApplyingChartData = false
186
+
187
+ function applyChartDataToElement() {
188
+ if (!selectedElement.value || selectedElement.value.type !== 'chart') return
189
+ isApplyingChartData = true
190
+ try {
191
+ const cleanLabels: string[] = []
192
+ const cleanDatasets: ChartDatasetItem[] = tempChartDatasets.value.map((ds, idx) => ({
193
+ label: (ds.label || '').trim() || `系列${idx + 1}`,
194
+ data: []
195
+ }))
196
+
197
+ tempChartLabels.value.forEach((lbl, rIdx) => {
198
+ const trimmed = (lbl || '').trim()
199
+ const hasAnyValue = tempChartDatasets.value.some(ds => ds.data[rIdx] !== undefined && !isNaN(Number(ds.data[rIdx])))
200
+ if (trimmed || hasAnyValue) {
201
+ cleanLabels.push(trimmed || `分类${cleanLabels.length + 1}`)
202
+ tempChartDatasets.value.forEach((ds, sIdx) => {
203
+ const num = Number(ds.data[rIdx])
204
+ cleanDatasets[sIdx].data.push(isNaN(num) ? 0 : num)
205
+ })
206
+ }
207
+ })
208
+
209
+ if (cleanLabels.length > 0 && cleanDatasets.length > 0) {
210
+ selectedElement.value.data = {
211
+ labels: cleanLabels,
212
+ datasets: cleanDatasets
213
+ }
214
+ }
215
+ addHistorySnapshot()
216
+ } finally {
217
+ isApplyingChartData = false
218
+ }
219
+ }
220
+
221
+ function loadChartDataFromElement(el: any) {
222
+ if (!el || el.type !== 'chart' || isApplyingChartData) return
223
+ const { labels, datasets } = extractStructuredData(el)
224
+ tempChartLabels.value = labels
225
+ tempChartDatasets.value = datasets
226
+ previewChartType.value = el.chartType || 'bar'
227
+ const labelsVal = tempChartLabels.value
228
+ const datasetsVal = tempChartDatasets.value
229
+ if (!labelsVal.length || !datasetsVal.length) {
230
+ tempChartDataText.value = ''
231
+ } else {
232
+ tempChartDataText.value = labelsVal
233
+ .map((l, rIdx) => {
234
+ const vals = datasetsVal.map(ds => (ds.data[rIdx] !== undefined ? ds.data[rIdx] : 0))
235
+ return [l, ...vals].join(', ')
236
+ })
237
+ .join('\n')
238
+ }
239
+ }
240
+
241
+ watch(
242
+ [() => selectedElement.value?.id, () => selectedElement.value?.chartType],
243
+ () => {
244
+ if (selectedElement.value?.type === 'chart') {
245
+ loadChartDataFromElement(selectedElement.value)
246
+ }
247
+ },
248
+ { immediate: true }
249
+ )
250
+
251
+ watch(chartActiveTab, (tab) => {
252
+ if (tab === 'data' && selectedElement.value?.type === 'chart') {
253
+ loadChartDataFromElement(selectedElement.value)
254
+ }
255
+ })
256
+
184
257
  function syncStructuredToText() {
185
258
  const labels = tempChartLabels.value
186
259
  const datasets = tempChartDatasets.value
187
260
  if (!labels.length || !datasets.length) {
188
261
  tempChartDataText.value = ''
189
- return
262
+ } else {
263
+ tempChartDataText.value = labels
264
+ .map((l, rIdx) => {
265
+ const vals = datasets.map(ds => (ds.data[rIdx] !== undefined ? ds.data[rIdx] : 0))
266
+ return [l, ...vals].join(', ')
267
+ })
268
+ .join('\n')
190
269
  }
191
- tempChartDataText.value = labels
192
- .map((l, rIdx) => {
193
- const vals = datasets.map(ds => (ds.data[rIdx] !== undefined ? ds.data[rIdx] : 0))
194
- return [l, ...vals].join(', ')
195
- })
196
- .join('\n')
270
+ applyChartDataToElement()
197
271
  }
198
272
 
199
273
  function syncTextToStructured(text: string) {
@@ -225,6 +299,7 @@ export function useSidebarChart(
225
299
  label: tempChartDatasets.value[idx]?.label || `系列${idx + 1}`,
226
300
  data: labels.map((_, rIdx) => vals[rIdx] ?? 0)
227
301
  }))
302
+ applyChartDataToElement()
228
303
  }
229
304
  }
230
305
 
@@ -280,13 +355,9 @@ export function useSidebarChart(
280
355
 
281
356
  function openChartDataDialog() {
282
357
  if (selectedElement.value) {
283
- const { labels, datasets } = extractStructuredData(selectedElement.value)
284
- tempChartLabels.value = labels
285
- tempChartDatasets.value = datasets
286
- previewChartType.value = selectedElement.value.chartType || 'bar'
358
+ loadChartDataFromElement(selectedElement.value)
287
359
  chartEditMode.value = 'table'
288
- syncStructuredToText()
289
- chartDataDialogVisible.value = true
360
+ chartActiveTab.value = 'data'
290
361
  }
291
362
  }
292
363
 
@@ -294,40 +365,18 @@ export function useSidebarChart(
294
365
  if (selectedElement.value) {
295
366
  if (chartEditMode.value === 'csv') {
296
367
  syncTextToStructured(tempChartDataText.value)
297
- }
298
- const cleanLabels: string[] = []
299
- const cleanDatasets: ChartDatasetItem[] = tempChartDatasets.value.map((ds, idx) => ({
300
- label: (ds.label || '').trim() || `系列${idx + 1}`,
301
- data: []
302
- }))
303
-
304
- tempChartLabels.value.forEach((lbl, rIdx) => {
305
- const trimmed = (lbl || '').trim()
306
- const hasAnyValue = tempChartDatasets.value.some(ds => ds.data[rIdx] !== undefined && !isNaN(Number(ds.data[rIdx])))
307
- if (trimmed || hasAnyValue) {
308
- cleanLabels.push(trimmed || `分类${cleanLabels.length + 1}`)
309
- tempChartDatasets.value.forEach((ds, sIdx) => {
310
- const num = Number(ds.data[rIdx])
311
- cleanDatasets[sIdx].data.push(isNaN(num) ? 0 : num)
312
- })
313
- }
314
- })
315
-
316
- if (cleanLabels.length > 0 && cleanDatasets.length > 0) {
317
- selectedElement.value.data = {
318
- labels: cleanLabels,
319
- datasets: cleanDatasets
320
- }
368
+ } else {
369
+ applyChartDataToElement()
321
370
  }
322
371
  if (previewChartType.value && selectedElement.value.chartType !== previewChartType.value) {
323
372
  selectedElement.value.chartType = previewChartType.value
324
373
  }
325
- addHistorySnapshot()
326
374
  chartDataDialogVisible.value = false
327
375
  }
328
376
  }
329
377
 
330
378
  return {
379
+ chartActiveTab,
331
380
  chartDataDialogVisible,
332
381
  tempChartDataText,
333
382
  tempChartLabels,
@@ -21,7 +21,8 @@ export function useSidebarDesign() {
21
21
  const extraPlaceholders = (layout.type === 'custom' && Array.isArray(layout.elements) && layout.elements.length > 0)
22
22
  ? []
23
23
  : (layout.placeholders || [])
24
- const rawList = [...(master.elements || []), ...(layout.elements || []), ...extraPlaceholders]
24
+ const masterStaticEls = (master.elements || []).filter((el: any) => !(el && (el.isPlaceholder || el.placeholder || el.placeholderType || (typeof el.id === 'string' && (el.id.startsWith('ph-') || el.id.startsWith('ph_'))) || (typeof el.name === 'string' && el.name.includes('占位符')))))
25
+ const rawList = [...masterStaticEls, ...(layout.elements || []), ...extraPlaceholders]
25
26
  const seenIds = new Set<string>()
26
27
  const deduped = rawList.filter((el: any) => {
27
28
  if (!el) return false
@@ -56,7 +56,7 @@ export function useSidebarElementTransform(
56
56
  }
57
57
  }
58
58
  }
59
- elements.forEach((el: any, idx: number) => {
59
+ activeSlide.value.elements.forEach((el: any, idx: number) => {
60
60
  if (el) el.order = idx + 1
61
61
  })
62
62
  addHistorySnapshot()