jvs-ppt-ui 0.0.37 → 0.0.39
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 +22348 -21892
- package/dist/lib/jvs-ppt-ui.umd.js +111 -111
- package/dist/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/App.vue +7 -5
- package/src/components/CanvasArea.vue +316 -59
- package/src/components/Header.vue +2 -4
- package/src/components/PptEditor.vue +97 -5
- package/src/components/SidebarLeft.vue +30 -6
- package/src/components/canvas/elements/CanvasGroupElement.vue +3 -0
- package/src/components/canvas/elements/CanvasTextElement.vue +1 -1
- package/src/components/sidebar/common/SidebarPositionGroup.vue +199 -33
- package/src/components/sidebar/panels/SidebarImageFormatPanel.vue +37 -33
- package/src/composables/canvas/useCanvasCrop.ts +25 -2
- package/src/composables/canvas/useCanvasText.ts +27 -8
- package/src/composables/sidebar/useSidebarElementTransform.ts +13 -7
- package/src/composables/useSlides.ts +6 -4
- package/src/index.ts +8 -1
- package/src/style.css +1 -1
- package/src/types/index.ts +14 -0
- package/src/utils/canvas/formatPainter.ts +91 -32
- package/src/utils/localDraftStorage.ts +340 -0
|
@@ -301,7 +301,7 @@ function applyPresetFilter(values: Record<string, string>) {
|
|
|
301
301
|
|
|
302
302
|
<!-- Image Actions (Crop, Replace, Reset, Set Background) -->
|
|
303
303
|
<div class="control-group"
|
|
304
|
-
style="padding: 0 16px; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; border-bottom: 1px solid #
|
|
304
|
+
style="padding: 0 16px; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; border-bottom: 1px solid #f1f5f9; padding-bottom: 12px; margin-bottom: 12px;">
|
|
305
305
|
<!-- Row 1 -->
|
|
306
306
|
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px;">
|
|
307
307
|
<!-- 剪裁 split dropdown group -->
|
|
@@ -389,12 +389,16 @@ function applyPresetFilter(values: Record<string, string>) {
|
|
|
389
389
|
</div>
|
|
390
390
|
|
|
391
391
|
<!-- 1. 蒙版 Accordion -->
|
|
392
|
-
<div class="control-group shape-accordion-group"
|
|
393
|
-
|
|
394
|
-
<div class="shape-accordion-header" @click="toggleMaskHeader" style="padding: 0 16px;">
|
|
392
|
+
<div class="control-group shape-accordion-group">
|
|
393
|
+
<div class="shape-accordion-header" @click="toggleMaskHeader">
|
|
395
394
|
<span class="control-label shape-accordion-header-label">
|
|
396
|
-
<span
|
|
397
|
-
|
|
395
|
+
<span>蒙版</span>
|
|
396
|
+
<span class="accordion-arrow">
|
|
397
|
+
<svg class="icon" style="width: 14px; height: 14px;">
|
|
398
|
+
<use :href="(enableColorMask && isMaskExpanded) ? '#icon-ppt-xiala-zhankai' : '#icon-ppt-xiala-shouqi'"
|
|
399
|
+
:xlink:href="(enableColorMask && isMaskExpanded) ? '#icon-ppt-xiala-zhankai' : '#icon-ppt-xiala-shouqi'"></use>
|
|
400
|
+
</svg>
|
|
401
|
+
</span>
|
|
398
402
|
</span>
|
|
399
403
|
<el-switch v-model="enableColorMask" size="small" @click.stop />
|
|
400
404
|
</div>
|
|
@@ -435,12 +439,16 @@ function applyPresetFilter(values: Record<string, string>) {
|
|
|
435
439
|
</div>
|
|
436
440
|
|
|
437
441
|
<!-- 2. 滤镜 Accordion -->
|
|
438
|
-
<div class="control-group shape-accordion-group"
|
|
439
|
-
|
|
440
|
-
<div class="shape-accordion-header" @click="toggleFiltersHeader" style="padding: 0 16px;">
|
|
442
|
+
<div class="control-group shape-accordion-group">
|
|
443
|
+
<div class="shape-accordion-header" @click="toggleFiltersHeader">
|
|
441
444
|
<span class="control-label shape-accordion-header-label">
|
|
442
|
-
<span
|
|
443
|
-
|
|
445
|
+
<span>滤镜</span>
|
|
446
|
+
<span class="accordion-arrow">
|
|
447
|
+
<svg class="icon" style="width: 14px; height: 14px;">
|
|
448
|
+
<use :href="(enableFilters && isFiltersExpanded) ? '#icon-ppt-xiala-zhankai' : '#icon-ppt-xiala-shouqi'"
|
|
449
|
+
:xlink:href="(enableFilters && isFiltersExpanded) ? '#icon-ppt-xiala-zhankai' : '#icon-ppt-xiala-shouqi'"></use>
|
|
450
|
+
</svg>
|
|
451
|
+
</span>
|
|
444
452
|
</span>
|
|
445
453
|
<el-switch v-model="enableFilters" size="small" @click.stop />
|
|
446
454
|
</div>
|
|
@@ -661,37 +669,41 @@ function applyPresetFilter(values: Record<string, string>) {
|
|
|
661
669
|
}
|
|
662
670
|
|
|
663
671
|
.shape-accordion-group {
|
|
664
|
-
|
|
672
|
+
border-bottom: 1px solid #f1f5f9;
|
|
673
|
+
padding-bottom: 12px;
|
|
674
|
+
margin-bottom: 12px;
|
|
665
675
|
}
|
|
666
676
|
|
|
667
677
|
.shape-accordion-header {
|
|
668
|
-
height: 34px;
|
|
669
|
-
padding: 0 16px;
|
|
670
678
|
display: flex;
|
|
671
679
|
align-items: center;
|
|
672
|
-
|
|
680
|
+
justify-content: space-between;
|
|
681
|
+
padding: 0 16px;
|
|
682
|
+
height: 34px;
|
|
673
683
|
cursor: pointer;
|
|
674
684
|
user-select: none;
|
|
675
685
|
}
|
|
676
686
|
|
|
677
687
|
.shape-accordion-header-label {
|
|
678
|
-
font-size:
|
|
679
|
-
font-weight:
|
|
680
|
-
color:
|
|
688
|
+
font-size: 14px;
|
|
689
|
+
font-weight: 400;
|
|
690
|
+
color: #1e293b;
|
|
681
691
|
display: flex;
|
|
682
692
|
align-items: center;
|
|
683
693
|
gap: 6px;
|
|
684
|
-
width: 80px;
|
|
685
694
|
flex-shrink: 0;
|
|
686
|
-
text-align: left;
|
|
687
695
|
}
|
|
688
696
|
|
|
689
697
|
.accordion-arrow {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
color: #
|
|
694
|
-
|
|
698
|
+
display: flex;
|
|
699
|
+
align-items: center;
|
|
700
|
+
justify-content: center;
|
|
701
|
+
color: #64748b;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
:deep(.el-switch) {
|
|
705
|
+
--el-switch-on-color: #2563eb;
|
|
706
|
+
--el-switch-off-color: #cbd5e1;
|
|
695
707
|
}
|
|
696
708
|
|
|
697
709
|
.shape-accordion-content {
|
|
@@ -788,12 +800,4 @@ function applyPresetFilter(values: Record<string, string>) {
|
|
|
788
800
|
color: var(--text-primary, #1e293b) !important;
|
|
789
801
|
}
|
|
790
802
|
}
|
|
791
|
-
|
|
792
|
-
:deep(.el-switch__core) {
|
|
793
|
-
border-radius: 4px !important;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
:deep(.el-switch__action) {
|
|
797
|
-
border-radius: 3px !important;
|
|
798
|
-
}
|
|
799
803
|
</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Ref } from 'vue'
|
|
1
|
+
import { ref, type Ref } from 'vue'
|
|
2
2
|
|
|
3
3
|
export interface CropOptions {
|
|
4
4
|
zoomRatio: Ref<number>
|
|
@@ -6,6 +6,7 @@ export interface CropOptions {
|
|
|
6
6
|
getElementPixels: (el: any) => { left: number; top: number; width: number; height: number; rotate: number }
|
|
7
7
|
findParentGroup: (id: any) => any
|
|
8
8
|
addHistorySnapshot: () => void
|
|
9
|
+
onCropStop?: () => void
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export function useCanvasCrop(options: CropOptions) {
|
|
@@ -14,9 +15,11 @@ export function useCanvasCrop(options: CropOptions) {
|
|
|
14
15
|
pauseHistory,
|
|
15
16
|
getElementPixels,
|
|
16
17
|
findParentGroup,
|
|
17
|
-
addHistorySnapshot
|
|
18
|
+
addHistorySnapshot,
|
|
19
|
+
onCropStop
|
|
18
20
|
} = options
|
|
19
21
|
|
|
22
|
+
const isCropping = ref(false)
|
|
20
23
|
let isCroppingDrag = false
|
|
21
24
|
let cropHandle = ''
|
|
22
25
|
let cropStartX = 0
|
|
@@ -121,11 +124,29 @@ export function useCanvasCrop(options: CropOptions) {
|
|
|
121
124
|
cancelAnimationFrame(cropAnimationFrameId)
|
|
122
125
|
cropAnimationFrameId = null
|
|
123
126
|
}
|
|
127
|
+
if (lastCropEvent && isCroppingDrag && cropCurrentEl) {
|
|
128
|
+
updateCropDimensions(lastCropEvent)
|
|
129
|
+
lastCropEvent = null
|
|
130
|
+
}
|
|
124
131
|
window.removeEventListener('mousemove', handleCropDrag)
|
|
125
132
|
window.removeEventListener('mouseup', stopCropDrag)
|
|
126
133
|
isCroppingDrag = false
|
|
134
|
+
isCropping.value = false
|
|
127
135
|
cropCurrentEl = null
|
|
128
136
|
pauseHistory.value = false
|
|
137
|
+
if (onCropStop) onCropStop()
|
|
138
|
+
|
|
139
|
+
// 拦截因拖拽手柄移出图片范围后 mouseup 与 mousedown 节点不一致而由浏览器合成在父容器上的 click 事件,防止误触发 handleDeselect 退出裁剪模式
|
|
140
|
+
const suppressSyntheticClick = (ev: MouseEvent) => {
|
|
141
|
+
ev.stopPropagation()
|
|
142
|
+
ev.preventDefault()
|
|
143
|
+
window.removeEventListener('click', suppressSyntheticClick, true)
|
|
144
|
+
}
|
|
145
|
+
window.addEventListener('click', suppressSyntheticClick, true)
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
window.removeEventListener('click', suppressSyntheticClick, true)
|
|
148
|
+
}, 50)
|
|
149
|
+
|
|
129
150
|
addHistorySnapshot()
|
|
130
151
|
}
|
|
131
152
|
|
|
@@ -136,6 +157,7 @@ export function useCanvasCrop(options: CropOptions) {
|
|
|
136
157
|
|
|
137
158
|
pauseHistory.value = true
|
|
138
159
|
isCroppingDrag = true
|
|
160
|
+
isCropping.value = true
|
|
139
161
|
cropHandle = handle
|
|
140
162
|
cropCurrentEl = el
|
|
141
163
|
|
|
@@ -165,6 +187,7 @@ export function useCanvasCrop(options: CropOptions) {
|
|
|
165
187
|
}
|
|
166
188
|
|
|
167
189
|
return {
|
|
190
|
+
isCropping,
|
|
168
191
|
startInteractiveCrop,
|
|
169
192
|
handleCropDrag,
|
|
170
193
|
stopCropDrag,
|
|
@@ -238,27 +238,36 @@ export function useCanvasText(options: TextOptions) {
|
|
|
238
238
|
selectedElementIds.value = [elId]
|
|
239
239
|
}
|
|
240
240
|
isEditingText.value = true
|
|
241
|
+
const isClearingPlaceholder = Boolean(el && isPlaceholderElement(el))
|
|
241
242
|
if (el) {
|
|
242
243
|
const currentVal = el.text || ''
|
|
243
244
|
if (currentVal && currentVal !== '<div><br></div>') {
|
|
244
245
|
initialTextContent.value[elId] = currentVal
|
|
245
246
|
}
|
|
246
|
-
if (
|
|
247
|
+
if (isClearingPlaceholder) {
|
|
247
248
|
if (!editingPlaceholderOriginalValue.value[elId]) {
|
|
248
249
|
editingPlaceholderOriginalValue.value[elId] = currentVal
|
|
249
250
|
}
|
|
250
251
|
el.text = '<div><br></div>'
|
|
251
252
|
}
|
|
252
253
|
}
|
|
254
|
+
const syncContainer = document.getElementById(`editable-${elId}`)
|
|
255
|
+
if (syncContainer && !isClearingPlaceholder) {
|
|
256
|
+
syncContainer.setAttribute('contenteditable', 'true')
|
|
257
|
+
syncContainer.style.userSelect = 'text'
|
|
258
|
+
;(syncContainer.style as any).webkitUserSelect = 'text'
|
|
259
|
+
syncContainer.style.pointerEvents = 'auto'
|
|
260
|
+
}
|
|
253
261
|
nextTick(() => {
|
|
254
262
|
const container = document.getElementById(`editable-${elId}`)
|
|
255
263
|
if (container) {
|
|
256
|
-
if (
|
|
264
|
+
if (isClearingPlaceholder) {
|
|
257
265
|
container.innerHTML = '<div><br></div>'
|
|
258
266
|
}
|
|
259
267
|
const existingSel = window.getSelection()
|
|
260
|
-
const hasActiveSelection = existingSel && existingSel.rangeCount > 0 &&
|
|
261
|
-
existingSel.anchorNode && container.contains(existingSel.anchorNode)
|
|
268
|
+
const hasActiveSelection = !isClearingPlaceholder && existingSel && existingSel.rangeCount > 0 &&
|
|
269
|
+
existingSel.anchorNode && container.contains(existingSel.anchorNode) &&
|
|
270
|
+
(!existingSel.isCollapsed || mouseEvent?.type === 'mousedown')
|
|
262
271
|
if (!hasActiveSelection) {
|
|
263
272
|
setCaretAtPointOrEnd(container, mouseEvent)
|
|
264
273
|
requestAnimationFrame(() => {
|
|
@@ -289,27 +298,37 @@ export function useCanvasText(options: TextOptions) {
|
|
|
289
298
|
selectedElementIds.value = [elId]
|
|
290
299
|
isEditingText.value = true
|
|
291
300
|
const el = findElementInSlide(elId) || activeSlide.value?.elements.find((x: any) => x.id === elId)
|
|
301
|
+
const isClearingPlaceholder = Boolean(!isMasterEditingView?.value && el && isPlaceholderElement(el))
|
|
292
302
|
if (el) {
|
|
293
303
|
const currentVal = el.content || ''
|
|
294
304
|
if (currentVal && currentVal !== '<div><br></div>') {
|
|
295
305
|
initialTextContent.value[el.id] = currentVal
|
|
296
306
|
}
|
|
297
|
-
if (
|
|
307
|
+
if (isClearingPlaceholder) {
|
|
298
308
|
if (!editingPlaceholderOriginalValue.value[el.id]) {
|
|
299
309
|
editingPlaceholderOriginalValue.value[el.id] = currentVal
|
|
300
310
|
}
|
|
301
311
|
el.content = '<div><br></div>'
|
|
302
312
|
}
|
|
303
313
|
}
|
|
314
|
+
const isTableOrLatex = Boolean(el && (el.latex || (typeof el.content === 'string' && el.content.includes('<table'))))
|
|
315
|
+
const syncContainer = document.getElementById(`editable-${elId}`)
|
|
316
|
+
if (syncContainer && !isClearingPlaceholder && !isTableOrLatex) {
|
|
317
|
+
syncContainer.setAttribute('contenteditable', 'true')
|
|
318
|
+
syncContainer.style.userSelect = 'text'
|
|
319
|
+
;(syncContainer.style as any).webkitUserSelect = 'text'
|
|
320
|
+
syncContainer.style.pointerEvents = 'auto'
|
|
321
|
+
}
|
|
304
322
|
nextTick(() => {
|
|
305
323
|
const container = document.getElementById(`editable-${elId}`)
|
|
306
324
|
if (container) {
|
|
307
|
-
if (
|
|
325
|
+
if (isClearingPlaceholder) {
|
|
308
326
|
container.innerHTML = '<div><br></div>'
|
|
309
327
|
}
|
|
310
328
|
const existingSel = window.getSelection()
|
|
311
|
-
const hasActiveSelection = existingSel && existingSel.rangeCount > 0 &&
|
|
312
|
-
existingSel.anchorNode && container.contains(existingSel.anchorNode)
|
|
329
|
+
const hasActiveSelection = !isClearingPlaceholder && existingSel && existingSel.rangeCount > 0 &&
|
|
330
|
+
existingSel.anchorNode && container.contains(existingSel.anchorNode) &&
|
|
331
|
+
(!existingSel.isCollapsed || mouseEvent?.type === 'mousedown')
|
|
313
332
|
if (!hasActiveSelection) {
|
|
314
333
|
setCaretAtPointOrEnd(container, mouseEvent)
|
|
315
334
|
requestAnimationFrame(() => {
|
|
@@ -132,7 +132,7 @@ export function useSidebarElementTransform(
|
|
|
132
132
|
return { width: logicalWidth.value, height: logicalHeight.value }
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
const { isCanvasDragging, activeSlideVersion } = useSlides()
|
|
135
|
+
const { isCanvasDragging, activeSlideVersion, selectedElementWidth, selectedElementHeight } = useSlides()
|
|
136
136
|
let cachedX = 0
|
|
137
137
|
let cachedY = 0
|
|
138
138
|
|
|
@@ -272,8 +272,9 @@ export function useSidebarElementTransform(
|
|
|
272
272
|
}
|
|
273
273
|
return parseFloat(parseFloat(wStr).toFixed(1)) || (selectedElement.value.width || 0)
|
|
274
274
|
},
|
|
275
|
-
set(
|
|
275
|
+
set(rawVal: number) {
|
|
276
276
|
if (!selectedElement.value) return
|
|
277
|
+
const val = Math.max(10, Number(rawVal) || 10)
|
|
277
278
|
if (selectedElementIds.value.length > 1 && activeSlide.value) {
|
|
278
279
|
activeSlide.value.elements.forEach((el: any) => {
|
|
279
280
|
if (selectedElementIds.value.includes(el.id)) {
|
|
@@ -302,7 +303,7 @@ export function useSidebarElementTransform(
|
|
|
302
303
|
elOldH = parseFloat(hStr) || 0
|
|
303
304
|
}
|
|
304
305
|
const ratio = elOldH / elOldW
|
|
305
|
-
const newH = parseFloat((val * ratio).toFixed(1))
|
|
306
|
+
const newH = Math.max(10, parseFloat((val * ratio).toFixed(1)))
|
|
306
307
|
if (hStr.endsWith('%')) {
|
|
307
308
|
el.style.height = `${((newH / refDims.height) * 100).toFixed(4)}%`
|
|
308
309
|
} else {
|
|
@@ -337,10 +338,11 @@ export function useSidebarElementTransform(
|
|
|
337
338
|
el.style.width = `${val}px`
|
|
338
339
|
}
|
|
339
340
|
el.width = val
|
|
341
|
+
if (selectedElementWidth) selectedElementWidth.value = `${val}px`
|
|
340
342
|
let newH = elementH.value
|
|
341
343
|
if ((el as any).fixedRatio && oldW > 0) {
|
|
342
344
|
const ratio = elementH.value / oldW
|
|
343
|
-
newH = parseFloat((val * ratio).toFixed(1))
|
|
345
|
+
newH = Math.max(10, parseFloat((val * ratio).toFixed(1)))
|
|
344
346
|
const hStr = el.style?.height || '100px'
|
|
345
347
|
if (hStr.endsWith('%')) {
|
|
346
348
|
el.style.height = `${((newH / refDims.height) * 100).toFixed(4)}%`
|
|
@@ -348,6 +350,7 @@ export function useSidebarElementTransform(
|
|
|
348
350
|
el.style.height = `${newH}px`
|
|
349
351
|
}
|
|
350
352
|
el.height = newH
|
|
353
|
+
if (selectedElementHeight) selectedElementHeight.value = `${newH}px`
|
|
351
354
|
}
|
|
352
355
|
if (el.type === 'group' && Array.isArray(el.elements) && oldW > 0) {
|
|
353
356
|
const scaleX = val / oldW
|
|
@@ -413,8 +416,9 @@ export function useSidebarElementTransform(
|
|
|
413
416
|
}
|
|
414
417
|
return parseFloat(parseFloat(hStr).toFixed(1)) || (el.height || 0)
|
|
415
418
|
},
|
|
416
|
-
set(
|
|
419
|
+
set(rawVal: number) {
|
|
417
420
|
if (!selectedElement.value) return
|
|
421
|
+
const val = Math.max(10, Number(rawVal) || 10)
|
|
418
422
|
if (selectedElementIds.value.length > 1 && activeSlide.value) {
|
|
419
423
|
activeSlide.value.elements.forEach((el: any) => {
|
|
420
424
|
if (selectedElementIds.value.includes(el.id)) {
|
|
@@ -443,7 +447,7 @@ export function useSidebarElementTransform(
|
|
|
443
447
|
elOldW = parseFloat(wStr) || 0
|
|
444
448
|
}
|
|
445
449
|
const ratio = elOldW / elOldH
|
|
446
|
-
const newW = parseFloat((val * ratio).toFixed(1))
|
|
450
|
+
const newW = Math.max(10, parseFloat((val * ratio).toFixed(1)))
|
|
447
451
|
if (wStr.endsWith('%')) {
|
|
448
452
|
el.style.width = `${((newW / refDims.width) * 100).toFixed(4)}%`
|
|
449
453
|
} else {
|
|
@@ -478,10 +482,11 @@ export function useSidebarElementTransform(
|
|
|
478
482
|
el.style.height = `${val}px`
|
|
479
483
|
}
|
|
480
484
|
el.height = val
|
|
485
|
+
if (selectedElementHeight) selectedElementHeight.value = `${val}px`
|
|
481
486
|
let newW = elementW.value
|
|
482
487
|
if ((el as any).fixedRatio && oldH > 0) {
|
|
483
488
|
const ratio = elementW.value / oldH
|
|
484
|
-
newW = parseFloat((val * ratio).toFixed(1))
|
|
489
|
+
newW = Math.max(10, parseFloat((val * ratio).toFixed(1)))
|
|
485
490
|
const wStr = el.style?.width || '100px'
|
|
486
491
|
if (wStr.endsWith('%')) {
|
|
487
492
|
el.style.width = `${((newW / refDims.width) * 100).toFixed(4)}%`
|
|
@@ -489,6 +494,7 @@ export function useSidebarElementTransform(
|
|
|
489
494
|
el.style.width = `${newW}px`
|
|
490
495
|
}
|
|
491
496
|
el.width = newW
|
|
497
|
+
if (selectedElementWidth) selectedElementWidth.value = `${newW}px`
|
|
492
498
|
}
|
|
493
499
|
if (el.type === 'group' && Array.isArray(el.elements) && oldH > 0) {
|
|
494
500
|
const scaleY = val / oldH
|
|
@@ -8872,7 +8872,7 @@ function extractAndApplyThemeFromImportedContent(newSlides: any, parsedSlides: a
|
|
|
8872
8872
|
console.log('✅ 已成功从导入内容解析颜色并设置主题:', importedRecipe)
|
|
8873
8873
|
}
|
|
8874
8874
|
|
|
8875
|
-
function importSlides(newSlides: any) {
|
|
8875
|
+
function importSlides(newSlides: any, options?: { silent?: boolean }) {
|
|
8876
8876
|
if (slides.value && slides.value.length > 0) {
|
|
8877
8877
|
revokeSlideBlobUrls(slides.value)
|
|
8878
8878
|
}
|
|
@@ -8880,7 +8880,7 @@ function importSlides(newSlides: any) {
|
|
|
8880
8880
|
// 智能识别 Pitch Transit-JSON 模板数据并自动转换为本地 DeckData
|
|
8881
8881
|
if (isPitchTemplateData(newSlides)) {
|
|
8882
8882
|
const convertedPitchDeck = convertPitchTemplateToDeck(newSlides)
|
|
8883
|
-
return importSlides(convertedPitchDeck)
|
|
8883
|
+
return importSlides(convertedPitchDeck, options)
|
|
8884
8884
|
}
|
|
8885
8885
|
|
|
8886
8886
|
// 若包含 styleRecipes(如 Pitch 转换器生成的自定义多主题配方),注册到 builtinStyleRecipes
|
|
@@ -8909,7 +8909,7 @@ function importSlides(newSlides: any) {
|
|
|
8909
8909
|
})()
|
|
8910
8910
|
if (isRawPPTX) {
|
|
8911
8911
|
const parsedData = pptParserFn(newSlides)
|
|
8912
|
-
return importSlides(parsedData)
|
|
8912
|
+
return importSlides(parsedData, options)
|
|
8913
8913
|
}
|
|
8914
8914
|
}
|
|
8915
8915
|
|
|
@@ -8995,7 +8995,9 @@ function importSlides(newSlides: any) {
|
|
|
8995
8995
|
|
|
8996
8996
|
initHistory()
|
|
8997
8997
|
fitTrigger.value++
|
|
8998
|
-
|
|
8998
|
+
if (!options?.silent) {
|
|
8999
|
+
notify('导入幻灯片成功')
|
|
9000
|
+
}
|
|
8999
9001
|
}
|
|
9000
9002
|
|
|
9001
9003
|
function startPresentation() {
|
package/src/index.ts
CHANGED
|
@@ -23,8 +23,15 @@ import './style.css'
|
|
|
23
23
|
// 导出核心组件
|
|
24
24
|
export { PptEditor, PptEditor as JvsPptEditor }
|
|
25
25
|
|
|
26
|
-
// 导出 composables
|
|
26
|
+
// 导出 composables 与本地 IndexedDB 持久化工具
|
|
27
27
|
export { useSlides }
|
|
28
|
+
export {
|
|
29
|
+
saveDraftToIndexedDB,
|
|
30
|
+
loadDraftFromIndexedDB,
|
|
31
|
+
clearDraftFromIndexedDB,
|
|
32
|
+
saveMediaBlobToIndexedDB,
|
|
33
|
+
type LocalDraftRecord
|
|
34
|
+
} from './utils/localDraftStorage'
|
|
28
35
|
|
|
29
36
|
// 导出所有类型
|
|
30
37
|
export * from './types'
|
package/src/style.css
CHANGED
|
@@ -4800,7 +4800,7 @@ td.selected-cell.focused-cell,
|
|
|
4800
4800
|
/* Custom cursor for format painter mode */
|
|
4801
4801
|
.main-slide.format-painting-mode,
|
|
4802
4802
|
.main-slide.format-painting-mode * {
|
|
4803
|
-
cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 1024 1024" fill="%231E6FFF" stroke="white" stroke-width="40"><path d="M730.624 102.7072q20.736 20.7872 20.736 50.176V228.352h134.2464q33.9456 0 58.0096 24.1664 24.064 24.1152 24.064 58.2144v235.4688q0 66.56-64.9728 80.4864l-465.92 100.096v191.488q0 18.3296-12.9024 31.3344-12.9536 12.9536-31.232 12.9536-18.3296 0-31.232-12.9536-12.9536-13.0048-12.9536-31.3344v-196.5568q0-66.5088 64.9728-80.4864l465.92-100.096V317.0304h-128v79.7184q0 29.3888-20.6848 50.176-20.736 20.736-50.0224 20.736H127.0272q-29.2864 0-49.9712-20.736-20.736-20.7872-20.736-50.176V152.8832q0-29.3888 20.736-50.176 20.6848-20.7872 49.9712-20.7872h553.6256q29.2864 0 50.0224 20.7872zM150.6816 373.0432q5.9392 5.9904 14.336 5.9904h477.7984q8.3968 0 14.336-5.9392 5.9392-5.9392 5.9392-14.336V190.8224q0-8.3968-5.9392-14.336-5.9904-5.9904-14.336-5.9904H164.9664q-8.3968 0-14.336 5.9904-5.9392 5.9392-5.9392 14.336v167.8336q0 8.448 5.9392 14.336z"/></svg>')
|
|
4803
|
+
cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 1024 1024" fill="%231E6FFF" stroke="white" stroke-width="40"><path d="M730.624 102.7072q20.736 20.7872 20.736 50.176V228.352h134.2464q33.9456 0 58.0096 24.1664 24.064 24.1152 24.064 58.2144v235.4688q0 66.56-64.9728 80.4864l-465.92 100.096v191.488q0 18.3296-12.9024 31.3344-12.9536 12.9536-31.232 12.9536-18.3296 0-31.232-12.9536-12.9536-13.0048-12.9536-31.3344v-196.5568q0-66.5088 64.9728-80.4864l465.92-100.096V317.0304h-128v79.7184q0 29.3888-20.6848 50.176-20.736 20.736-50.0224 20.736H127.0272q-29.2864 0-49.9712-20.736-20.736-20.7872-20.736-50.176V152.8832q0-29.3888 20.736-50.176 20.6848-20.7872 49.9712-20.7872h553.6256q29.2864 0 50.0224 20.7872zM150.6816 373.0432q5.9392 5.9904 14.336 5.9904h477.7984q8.3968 0 14.336-5.9392 5.9392-5.9392 5.9392-14.336V190.8224q0-8.3968-5.9392-14.336-5.9904-5.9904-14.336-5.9904H164.9664q-8.3968 0-14.336 5.9904-5.9392 5.9392-5.9392 14.336v167.8336q0 8.448 5.9392 14.336z"/></svg>') 12 9, copy !important;
|
|
4804
4804
|
}
|
|
4805
4805
|
|
|
4806
4806
|
/* ==========================================================================
|
package/src/types/index.ts
CHANGED
|
@@ -139,6 +139,10 @@ export interface PptEditorConfig {
|
|
|
139
139
|
templateBaseUrl?: string
|
|
140
140
|
/** 传入自定义 templates 时是否替换默认内置模板,默认为 true(设为 false 则与默认内置模板合并) */
|
|
141
141
|
replaceBuiltinTemplates?: boolean
|
|
142
|
+
/** 是否开启浏览器本地 IndexedDB 自动缓存与刷新恢复(独立运行模式可开启,作为受控插件时默认 false) */
|
|
143
|
+
localStorageCache?: boolean
|
|
144
|
+
/** 浏览器本地 IndexedDB 缓存的自定义键名,默认为 'default_workspace_draft' */
|
|
145
|
+
localStorageKey?: string
|
|
142
146
|
/** 其它扩展配置 */
|
|
143
147
|
[key: string]: any
|
|
144
148
|
}
|
|
@@ -199,6 +203,10 @@ export interface PptEditorProps {
|
|
|
199
203
|
templateBaseUrl?: string
|
|
200
204
|
/** 传入自定义 templates 时是否替换默认内置模板,默认为 true(设为 false 则与默认内置模板合并) */
|
|
201
205
|
replaceBuiltinTemplates?: boolean
|
|
206
|
+
/** 是否开启浏览器本地 IndexedDB 自动缓存与刷新恢复(独立运行模式可开启,作为受控插件时默认 false) */
|
|
207
|
+
localStorageCache?: boolean
|
|
208
|
+
/** 浏览器本地 IndexedDB 缓存的自定义键名,默认为 'default_workspace_draft' */
|
|
209
|
+
localStorageKey?: string
|
|
202
210
|
/** 编辑器扩展配置 */
|
|
203
211
|
config?: PptEditorConfig
|
|
204
212
|
}
|
|
@@ -315,6 +323,12 @@ export interface PptEditorApi {
|
|
|
315
323
|
getTemplates: () => SlideTemplateItem[]
|
|
316
324
|
/** 当前模板库功能是否启用 */
|
|
317
325
|
isTemplateEnabled: Ref<boolean>
|
|
326
|
+
/** 立即将当前工程草稿保存到浏览器 IndexedDB */
|
|
327
|
+
saveLocalDraft?: () => Promise<boolean>
|
|
328
|
+
/** 从浏览器 IndexedDB 恢复上次保存的工程草稿 */
|
|
329
|
+
restoreLocalDraft?: () => Promise<boolean>
|
|
330
|
+
/** 清空浏览器 IndexedDB 中保存的工程草稿 */
|
|
331
|
+
clearLocalDraft?: () => Promise<boolean>
|
|
318
332
|
/** 底层 useSlides composable 完整实例(供深度扩展) */
|
|
319
333
|
slidesComposable: any
|
|
320
334
|
}
|