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/dist/lib/jvs-ppt-ui.es.js +36629 -34003
- package/dist/lib/jvs-ppt-ui.umd.js +105 -114
- package/dist/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/components/CanvasArea.vue +9 -1
- package/src/components/ChartTypeSelector.vue +69 -29
- package/src/components/Header.vue +44 -3
- package/src/components/PitchImportDialog.vue +459 -0
- 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 +2 -1
- package/src/components/sidebar/dialogs/ChartDataEditorDialog.vue +1040 -0
- 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 +25 -2
- package/src/style.css +2 -2
- package/src/utils/pitchConverter.ts +1226 -0
|
@@ -1,194 +1,357 @@
|
|
|
1
|
-
import { ref, computed, type ComputedRef } from 'vue'
|
|
2
|
-
import { generateMonoPalette } from '../../utils/palette'
|
|
3
|
-
|
|
4
|
-
export const CHART_PRESET_PALETTES = [
|
|
5
|
-
{ id: 'mono', name: 'Chart colors - Mono', isDynamic: true },
|
|
6
|
-
{ id: 'diverging', name: 'Diverging', colors: ['#2563eb', '#60a5fa', '#93c5fd', '#e2e8f0', '#fed7aa', '#fb923c', '#ea580c', '#c2410c'] },
|
|
7
|
-
{ id: 'saturated', name: 'Saturated', colors: ['#3b82f6', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6', '#ec4899', '#06b6d4', '#84cc16'] },
|
|
8
|
-
{ id: 'colorblind', name: 'Colorblind friendly', colors: ['#000000', '#E69F00', '#56B4E9', '#009E73', '#F0E442', '#0072B2', '#D55E00', '#CC79A7'] },
|
|
9
|
-
{ id: 'ocean', name: '静谧海洋', colors: ['#2563eb', '#3b82f6', '#60a5fa', '#93c5fd', '#bfdbfe', '#1d4ed8', '#1e3a8a', '#dbeafe'] },
|
|
10
|
-
{ id: 'emerald', name: '清新绿意', colors: ['#10b981', '#059669', '#34d399', '#6ee7b7', '#a7f3d0', '#047857', '#065f46', '#022c22'] },
|
|
11
|
-
{ id: 'warm', name: '温暖朝阳', colors: ['#f59e0b', '#ef4444', '#ec4899', '#f97316', '#fca5a5', '#b91c1c', '#7f1d1d', '#fda4af'] },
|
|
12
|
-
{ id: 'slate', name: '高级灰调', colors: ['#1e293b', '#334155', '#475569', '#64748b', '#94a3b8', '#cbd5e1', '#e2e8f0', '#f1f5f9'] },
|
|
13
|
-
{ id: 'pink', name: '浪漫粉黛', colors: ['#fbcfe8', '#f9a8d4', '#f472b6', '#ec4899', '#db2777', '#be185d', '#9d174d', '#831843'] }
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
selectedElement.value
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
selectedElement.value.style.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
1
|
+
import { ref, computed, type ComputedRef } from 'vue'
|
|
2
|
+
import { generateMonoPalette } from '../../utils/palette'
|
|
3
|
+
|
|
4
|
+
export const CHART_PRESET_PALETTES = [
|
|
5
|
+
{ id: 'mono', name: 'Chart colors - Mono', isDynamic: true },
|
|
6
|
+
{ id: 'diverging', name: 'Diverging', colors: ['#2563eb', '#60a5fa', '#93c5fd', '#e2e8f0', '#fed7aa', '#fb923c', '#ea580c', '#c2410c'] },
|
|
7
|
+
{ id: 'saturated', name: 'Saturated', colors: ['#3b82f6', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6', '#ec4899', '#06b6d4', '#84cc16'] },
|
|
8
|
+
{ id: 'colorblind', name: 'Colorblind friendly', colors: ['#000000', '#E69F00', '#56B4E9', '#009E73', '#F0E442', '#0072B2', '#D55E00', '#CC79A7'] },
|
|
9
|
+
{ id: 'ocean', name: '静谧海洋', colors: ['#2563eb', '#3b82f6', '#60a5fa', '#93c5fd', '#bfdbfe', '#1d4ed8', '#1e3a8a', '#dbeafe'] },
|
|
10
|
+
{ id: 'emerald', name: '清新绿意', colors: ['#10b981', '#059669', '#34d399', '#6ee7b7', '#a7f3d0', '#047857', '#065f46', '#022c22'] },
|
|
11
|
+
{ id: 'warm', name: '温暖朝阳', colors: ['#f59e0b', '#ef4444', '#ec4899', '#f97316', '#fca5a5', '#b91c1c', '#7f1d1d', '#fda4af'] },
|
|
12
|
+
{ id: 'slate', name: '高级灰调', colors: ['#1e293b', '#334155', '#475569', '#64748b', '#94a3b8', '#cbd5e1', '#e2e8f0', '#f1f5f9'] },
|
|
13
|
+
{ id: 'pink', name: '浪漫粉黛', colors: ['#fbcfe8', '#f9a8d4', '#f472b6', '#ec4899', '#db2777', '#be185d', '#9d174d', '#831843'] }
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
export interface ChartDatasetItem {
|
|
17
|
+
label: string
|
|
18
|
+
data: number[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function useSidebarChart(
|
|
22
|
+
selectedElement: ComputedRef<any>,
|
|
23
|
+
addHistorySnapshot: () => void
|
|
24
|
+
) {
|
|
25
|
+
const chartDataDialogVisible = ref(false)
|
|
26
|
+
const tempChartDataText = ref('')
|
|
27
|
+
const tempChartLabels = ref<string[]>([])
|
|
28
|
+
const tempChartDatasets = ref<ChartDatasetItem[]>([])
|
|
29
|
+
const chartEditMode = ref<'table' | 'csv'>('table')
|
|
30
|
+
const previewChartType = ref<string>('pie')
|
|
31
|
+
const chartTypePopoverVisible = ref(false)
|
|
32
|
+
|
|
33
|
+
const chartPrimaryColor = computed({
|
|
34
|
+
get() {
|
|
35
|
+
if (!selectedElement.value) return '#4f46e5'
|
|
36
|
+
return selectedElement.value.style?.chartPrimaryColor || selectedElement.value.style?.chartColors?.[0] || '#4f46e5'
|
|
37
|
+
},
|
|
38
|
+
set(val: string) {
|
|
39
|
+
if (!selectedElement.value || selectedElement.value.type !== 'chart') return
|
|
40
|
+
if (!selectedElement.value.style) selectedElement.value.style = {}
|
|
41
|
+
selectedElement.value.style.chartPrimaryColor = val
|
|
42
|
+
const monoColors = generateMonoPalette(val, 8)
|
|
43
|
+
selectedElement.value.style.chartColors = monoColors
|
|
44
|
+
selectedElement.value.style.chartPalette = 'mono'
|
|
45
|
+
addHistorySnapshot()
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const currentChartPaletteId = computed(() => {
|
|
50
|
+
return selectedElement.value?.style?.chartPalette || 'mono'
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const currentChartColors = computed(() => {
|
|
54
|
+
if (selectedElement.value?.style?.chartColors && Array.isArray(selectedElement.value.style.chartColors) && selectedElement.value.style.chartColors.length > 0) {
|
|
55
|
+
return selectedElement.value.style.chartColors
|
|
56
|
+
}
|
|
57
|
+
return generateMonoPalette(chartPrimaryColor.value, 8)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
function getPaletteColors(palette: any): string[] {
|
|
61
|
+
if (palette.id === 'mono') {
|
|
62
|
+
return generateMonoPalette(chartPrimaryColor.value, 8)
|
|
63
|
+
}
|
|
64
|
+
return palette.colors || []
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function selectChartPalette(palette: any) {
|
|
68
|
+
if (!selectedElement.value || selectedElement.value.type !== 'chart') return
|
|
69
|
+
if (!selectedElement.value.style) selectedElement.value.style = {}
|
|
70
|
+
selectedElement.value.style.chartPalette = palette.id
|
|
71
|
+
selectedElement.value.style.chartColors = getPaletteColors(palette)
|
|
72
|
+
addHistorySnapshot()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const chartTextColor = computed({
|
|
76
|
+
get() {
|
|
77
|
+
return selectedElement.value?.style?.textColor || selectedElement.value?.style?.color || '#64748b'
|
|
78
|
+
},
|
|
79
|
+
set(val: string) {
|
|
80
|
+
if (!selectedElement.value) return
|
|
81
|
+
if (!selectedElement.value.style) selectedElement.value.style = {}
|
|
82
|
+
selectedElement.value.style.textColor = val
|
|
83
|
+
selectedElement.value.style.color = val
|
|
84
|
+
addHistorySnapshot()
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const chartGridColor = computed({
|
|
89
|
+
get() {
|
|
90
|
+
return selectedElement.value?.style?.gridColor || '#e2e8f0'
|
|
91
|
+
},
|
|
92
|
+
set(val: string) {
|
|
93
|
+
if (!selectedElement.value) return
|
|
94
|
+
if (!selectedElement.value.style) selectedElement.value.style = {}
|
|
95
|
+
selectedElement.value.style.gridColor = val
|
|
96
|
+
addHistorySnapshot()
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
function updateChartColor(index: number, newColor: string) {
|
|
101
|
+
if (!selectedElement.value || selectedElement.value.type !== 'chart') return
|
|
102
|
+
if (!selectedElement.value.style) selectedElement.value.style = { top: '0px', left: '0px' }
|
|
103
|
+
if (!selectedElement.value.style.chartColors) {
|
|
104
|
+
selectedElement.value.style.chartColors = [...(CHART_PRESET_PALETTES[1].colors || [])]
|
|
105
|
+
}
|
|
106
|
+
const newColors = [...selectedElement.value.style.chartColors]
|
|
107
|
+
newColors[index] = newColor
|
|
108
|
+
selectedElement.value.style.chartColors = newColors
|
|
109
|
+
selectedElement.value.style.chartPalette = 'custom'
|
|
110
|
+
addHistorySnapshot()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function changeChartType(type: string) {
|
|
114
|
+
if (selectedElement.value && selectedElement.value.type === 'chart') {
|
|
115
|
+
selectedElement.value.chartType = type
|
|
116
|
+
addHistorySnapshot()
|
|
117
|
+
}
|
|
118
|
+
chartTypePopoverVisible.value = false
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function getDefaultStructuredData(el: any): { labels: string[]; datasets: ChartDatasetItem[] } {
|
|
122
|
+
const type = el?.chartType || 'bar'
|
|
123
|
+
if (['pie', 'donut', 'rose-pie', 'rose-donut', 'pieChart', 'doughnutChart'].includes(type)) {
|
|
124
|
+
return {
|
|
125
|
+
labels: ['分类A', '分类B', '分类C', '分类D'],
|
|
126
|
+
datasets: [{ label: '系列1', data: [35, 25, 20, 20] }]
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (type === 'radar') {
|
|
130
|
+
return {
|
|
131
|
+
labels: ['指标A', '指标B', '指标C', '指标D', '指标E'],
|
|
132
|
+
datasets: [
|
|
133
|
+
{ label: '系列1', data: [80, 70, 90, 60, 85] },
|
|
134
|
+
{ label: '系列2', data: [60, 80, 75, 80, 70] }
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
labels: ['一月', '二月', '三月', '四月', '五月'],
|
|
140
|
+
datasets: [
|
|
141
|
+
{ label: '系列1', data: [30, 45, 55, 60, 80] },
|
|
142
|
+
{ label: '系列2', data: [20, 30, 40, 45, 65] }
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function extractStructuredData(el: any): { labels: string[]; datasets: ChartDatasetItem[] } {
|
|
148
|
+
if (!el?.data) {
|
|
149
|
+
return getDefaultStructuredData(el)
|
|
150
|
+
}
|
|
151
|
+
const rawLabels = Array.isArray(el.data.labels) && el.data.labels.length > 0
|
|
152
|
+
? [...el.data.labels]
|
|
153
|
+
: getDefaultStructuredData(el).labels
|
|
154
|
+
|
|
155
|
+
if (Array.isArray(el.data.datasets) && el.data.datasets.length > 0) {
|
|
156
|
+
const datasets = el.data.datasets.map((ds: any, idx: number) => ({
|
|
157
|
+
label: ds.label || `系列${idx + 1}`,
|
|
158
|
+
data: rawLabels.map((_, rIdx) => {
|
|
159
|
+
const v = Number(ds.data?.[rIdx])
|
|
160
|
+
return isNaN(v) ? 0 : v
|
|
161
|
+
})
|
|
162
|
+
}))
|
|
163
|
+
return { labels: rawLabels, datasets }
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (Array.isArray(el.data.series) && el.data.series.length > 0) {
|
|
167
|
+
const legends = el.data.legends || []
|
|
168
|
+
const datasets = el.data.series.map((s: any, idx: number) => {
|
|
169
|
+
const arr = Array.isArray(s) ? s : [s]
|
|
170
|
+
return {
|
|
171
|
+
label: legends[idx] || `系列${idx + 1}`,
|
|
172
|
+
data: rawLabels.map((_, rIdx) => {
|
|
173
|
+
const v = Number(arr[rIdx])
|
|
174
|
+
return isNaN(v) ? 0 : v
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
|
+
return { labels: rawLabels, datasets }
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return getDefaultStructuredData(el)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function syncStructuredToText() {
|
|
185
|
+
const labels = tempChartLabels.value
|
|
186
|
+
const datasets = tempChartDatasets.value
|
|
187
|
+
if (!labels.length || !datasets.length) {
|
|
188
|
+
tempChartDataText.value = ''
|
|
189
|
+
return
|
|
190
|
+
}
|
|
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')
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function syncTextToStructured(text: string) {
|
|
200
|
+
const lines = text.split('\n').map(l => l.trim()).filter(Boolean)
|
|
201
|
+
const labels: string[] = []
|
|
202
|
+
const datasetValuesList: number[][] = []
|
|
203
|
+
|
|
204
|
+
for (const line of lines) {
|
|
205
|
+
const parts = line.split(/[,,\t]/)
|
|
206
|
+
if (parts.length >= 2) {
|
|
207
|
+
const label = parts[0].trim() || `分类${labels.length + 1}`
|
|
208
|
+
const vals = parts.slice(1).map(p => {
|
|
209
|
+
const parsed = parseFloat(p.trim())
|
|
210
|
+
return isNaN(parsed) ? 0 : parsed
|
|
211
|
+
})
|
|
212
|
+
if (vals.length > 0) {
|
|
213
|
+
labels.push(label)
|
|
214
|
+
vals.forEach((v, idx) => {
|
|
215
|
+
if (!datasetValuesList[idx]) datasetValuesList[idx] = []
|
|
216
|
+
datasetValuesList[idx].push(v)
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (labels.length > 0 && datasetValuesList.length > 0) {
|
|
223
|
+
tempChartLabels.value = labels
|
|
224
|
+
tempChartDatasets.value = datasetValuesList.map((vals, idx) => ({
|
|
225
|
+
label: tempChartDatasets.value[idx]?.label || `系列${idx + 1}`,
|
|
226
|
+
data: labels.map((_, rIdx) => vals[rIdx] ?? 0)
|
|
227
|
+
}))
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function addChartRow() {
|
|
232
|
+
const nextIdx = tempChartLabels.value.length
|
|
233
|
+
const suffix = nextIdx < 26 ? String.fromCharCode(65 + nextIdx) : `${nextIdx + 1}`
|
|
234
|
+
tempChartLabels.value.push(`分类${suffix}`)
|
|
235
|
+
tempChartDatasets.value.forEach(ds => {
|
|
236
|
+
ds.data.push(20)
|
|
237
|
+
})
|
|
238
|
+
syncStructuredToText()
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function removeChartRow(rowIndex: number) {
|
|
242
|
+
if (tempChartLabels.value.length <= 1) return
|
|
243
|
+
tempChartLabels.value.splice(rowIndex, 1)
|
|
244
|
+
tempChartDatasets.value.forEach(ds => {
|
|
245
|
+
ds.data.splice(rowIndex, 1)
|
|
246
|
+
})
|
|
247
|
+
syncStructuredToText()
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function addChartSeries() {
|
|
251
|
+
const nextIdx = tempChartDatasets.value.length + 1
|
|
252
|
+
tempChartDatasets.value.push({
|
|
253
|
+
label: `系列${nextIdx}`,
|
|
254
|
+
data: tempChartLabels.value.map(() => 25)
|
|
255
|
+
})
|
|
256
|
+
syncStructuredToText()
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function removeChartSeries(seriesIndex: number) {
|
|
260
|
+
if (tempChartDatasets.value.length <= 1) return
|
|
261
|
+
tempChartDatasets.value.splice(seriesIndex, 1)
|
|
262
|
+
syncStructuredToText()
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function transposeChartData() {
|
|
266
|
+
const oldLabels = [...tempChartLabels.value]
|
|
267
|
+
const oldDatasets = tempChartDatasets.value.map(ds => ({
|
|
268
|
+
label: ds.label,
|
|
269
|
+
data: [...ds.data]
|
|
270
|
+
}))
|
|
271
|
+
if (!oldLabels.length || !oldDatasets.length) return
|
|
272
|
+
|
|
273
|
+
tempChartLabels.value = oldDatasets.map(ds => ds.label)
|
|
274
|
+
tempChartDatasets.value = oldLabels.map((lbl, rIdx) => ({
|
|
275
|
+
label: lbl,
|
|
276
|
+
data: oldDatasets.map(ds => ds.data[rIdx] ?? 0)
|
|
277
|
+
}))
|
|
278
|
+
syncStructuredToText()
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function openChartDataDialog() {
|
|
282
|
+
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'
|
|
287
|
+
chartEditMode.value = 'table'
|
|
288
|
+
syncStructuredToText()
|
|
289
|
+
chartDataDialogVisible.value = true
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function saveChartData() {
|
|
294
|
+
if (selectedElement.value) {
|
|
295
|
+
if (chartEditMode.value === 'csv') {
|
|
296
|
+
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
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (previewChartType.value && selectedElement.value.chartType !== previewChartType.value) {
|
|
323
|
+
selectedElement.value.chartType = previewChartType.value
|
|
324
|
+
}
|
|
325
|
+
addHistorySnapshot()
|
|
326
|
+
chartDataDialogVisible.value = false
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return {
|
|
331
|
+
chartDataDialogVisible,
|
|
332
|
+
tempChartDataText,
|
|
333
|
+
tempChartLabels,
|
|
334
|
+
tempChartDatasets,
|
|
335
|
+
chartEditMode,
|
|
336
|
+
previewChartType,
|
|
337
|
+
chartTypePopoverVisible,
|
|
338
|
+
chartPrimaryColor,
|
|
339
|
+
currentChartPaletteId,
|
|
340
|
+
currentChartColors,
|
|
341
|
+
chartPresetPalettes: CHART_PRESET_PALETTES,
|
|
342
|
+
selectChartPalette,
|
|
343
|
+
chartTextColor,
|
|
344
|
+
chartGridColor,
|
|
345
|
+
updateChartColor,
|
|
346
|
+
changeChartType,
|
|
347
|
+
addChartRow,
|
|
348
|
+
removeChartRow,
|
|
349
|
+
addChartSeries,
|
|
350
|
+
removeChartSeries,
|
|
351
|
+
transposeChartData,
|
|
352
|
+
syncStructuredToText,
|
|
353
|
+
syncTextToStructured,
|
|
354
|
+
openChartDataDialog,
|
|
355
|
+
saveChartData
|
|
356
|
+
}
|
|
357
|
+
}
|
|
@@ -87,7 +87,7 @@ export interface SlideElement {
|
|
|
87
87
|
curve?: [number, number]
|
|
88
88
|
cubic?: [[number, number], [number, number]]
|
|
89
89
|
customControlPoints?: boolean
|
|
90
|
-
chartType?: 'bar' | 'horizontal-bar' | 'line' | 'area' | 'scatter' | 'pie' | 'donut' | 'radar'
|
|
90
|
+
chartType?: 'bar' | 'percent-bar' | 'stacked-bar' | 'horizontal-bar' | 'stacked-horizontal-bar' | 'line' | 'compare-line' | 'step-line' | 'area' | 'stacked-area' | 'scatter' | 'pie' | 'donut' | 'rose-pie' | 'rose-donut' | 'radar' | string
|
|
91
91
|
showAxes?: boolean
|
|
92
92
|
showAxisTitles?: boolean
|
|
93
93
|
showTitle?: boolean
|
|
@@ -302,6 +302,7 @@ export interface PresetTheme {
|
|
|
302
302
|
|
|
303
303
|
import { presetThemes, builtinStyleRecipes, type StyleRecipe } from './presetThemes'
|
|
304
304
|
import { generateMonoPalette } from '../utils/palette'
|
|
305
|
+
import { isPitchTemplateData, convertPitchTemplateToDeck } from '../utils/pitchConverter'
|
|
305
306
|
|
|
306
307
|
// Global reactive states
|
|
307
308
|
const presentationTitle = ref('未命名演示文稿')
|
|
@@ -1959,10 +1960,12 @@ function applyStyleRecipeToSlides(
|
|
|
1959
1960
|
effectiveMode = mode
|
|
1960
1961
|
}
|
|
1961
1962
|
|
|
1962
|
-
//
|
|
1963
|
+
// 同步更新内置配方库中的对应项(若为新增自定义主题则追加到配方库)
|
|
1963
1964
|
const recipeIdx = builtinStyleRecipes.findIndex(r => r.id === recipe.id)
|
|
1964
1965
|
if (recipeIdx >= 0) {
|
|
1965
1966
|
builtinStyleRecipes[recipeIdx] = JSON.parse(JSON.stringify(recipe))
|
|
1967
|
+
} else {
|
|
1968
|
+
builtinStyleRecipes.push(JSON.parse(JSON.stringify(recipe)))
|
|
1966
1969
|
}
|
|
1967
1970
|
|
|
1968
1971
|
// 🌟 母版编辑视图下直接应用到母版与版式
|
|
@@ -8443,6 +8446,26 @@ function importSlides(newSlides: any) {
|
|
|
8443
8446
|
revokeSlideBlobUrls(slides.value)
|
|
8444
8447
|
}
|
|
8445
8448
|
|
|
8449
|
+
// 智能识别 Pitch Transit-JSON 模板数据并自动转换为本地 DeckData
|
|
8450
|
+
if (isPitchTemplateData(newSlides)) {
|
|
8451
|
+
const convertedPitchDeck = convertPitchTemplateToDeck(newSlides)
|
|
8452
|
+
return importSlides(convertedPitchDeck)
|
|
8453
|
+
}
|
|
8454
|
+
|
|
8455
|
+
// 若包含 styleRecipes(如 Pitch 转换器生成的自定义多主题配方),注册到 builtinStyleRecipes
|
|
8456
|
+
if (newSlides && typeof newSlides === 'object' && Array.isArray(newSlides.styleRecipes) && newSlides.styleRecipes.length > 0) {
|
|
8457
|
+
for (let i = newSlides.styleRecipes.length - 1; i >= 0; i--) {
|
|
8458
|
+
const recipe = newSlides.styleRecipes[i]
|
|
8459
|
+
if (!recipe || !recipe.id) continue
|
|
8460
|
+
const existingIdx = builtinStyleRecipes.findIndex(r => r.id === recipe.id)
|
|
8461
|
+
if (existingIdx !== -1) {
|
|
8462
|
+
builtinStyleRecipes[existingIdx] = recipe
|
|
8463
|
+
} else {
|
|
8464
|
+
builtinStyleRecipes.unshift(recipe)
|
|
8465
|
+
}
|
|
8466
|
+
}
|
|
8467
|
+
}
|
|
8468
|
+
|
|
8446
8469
|
// 智能识别 raw PPTX JSON (如来自 jvs-pptxtojson 原生导出的 slides.json) 并代理给 PPT 解析器
|
|
8447
8470
|
if (pptParserFn && newSlides && typeof newSlides === 'object' && Array.isArray(newSlides.slides) && newSlides.size) {
|
|
8448
8471
|
const isRawPPTX = (() => {
|
package/src/style.css
CHANGED
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
/* 强行重置外部宿主全局 button 样式侵入 */
|
|
137
|
-
.jvs-ppt-editor-root button {
|
|
137
|
+
.jvs-ppt-editor-root button:not(.el-button) {
|
|
138
138
|
font-family: inherit;
|
|
139
139
|
font-size: inherit;
|
|
140
140
|
line-height: normal;
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
/* 强行重置外部宿主全局 button 样式侵入(防 text-indent, line-height, text-transform, pseudo elements) */
|
|
164
|
-
.jvs-ppt-editor-root button {
|
|
164
|
+
.jvs-ppt-editor-root button:not(.el-button) {
|
|
165
165
|
box-sizing: border-box !important;
|
|
166
166
|
text-transform: none !important;
|
|
167
167
|
text-indent: 0 !important;
|