jvs-ppt-ui 0.0.32 → 0.0.34

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.
Files changed (32) hide show
  1. package/README.md +152 -0
  2. package/dist/lib/jvs-ppt-ui.es.js +23678 -21439
  3. package/dist/lib/jvs-ppt-ui.umd.js +136 -100
  4. package/dist/lib/style.css +1 -1
  5. package/package.json +2 -1
  6. package/src/components/CanvasArea.vue +77 -35
  7. package/src/components/Header.vue +184 -26
  8. package/src/components/PitchImportDialog.vue +29 -6
  9. package/src/components/PptEditor.vue +53 -1
  10. package/src/components/QuickColorPopover.vue +2 -1
  11. package/src/components/SidebarLeft.vue +367 -41
  12. package/src/components/SidebarRight.vue +183 -134
  13. package/src/components/canvas/CanvasTransformHandles.vue +27 -36
  14. package/src/components/canvas/elements/CanvasMediaElement.vue +4 -3
  15. package/src/components/canvas/elements/CanvasShapeElement.vue +9 -6
  16. package/src/components/sidebar/panels/LayoutThumbSvg.vue +9 -6
  17. package/src/components/sidebar/panels/SidebarShapeFormatPanel.vue +1 -1
  18. package/src/components/sidebar/panels/SidebarTextFormatPanel.vue +1 -1
  19. package/src/composables/canvas/useCanvasFormatting.ts +20 -13
  20. package/src/composables/canvas/useCanvasText.ts +4 -3
  21. package/src/composables/canvas/useCanvasTransform.ts +37 -10
  22. package/src/composables/sidebar/useSidebarElementTransform.ts +86 -57
  23. package/src/composables/sidebar/useSidebarTextFormat.ts +242 -19
  24. package/src/composables/useSlides.ts +93 -28
  25. package/src/configs/slideTemplates.ts +1001 -0
  26. package/src/style.css +265 -2
  27. package/src/types/index.ts +37 -1
  28. package/src/utils/canvas/elementStyles.ts +55 -20
  29. package/src/utils/canvas/formatPainter.ts +177 -30
  30. package/src/utils/muxHlsToMp4.ts +569 -0
  31. package/src/utils/pitchConverter.ts +512 -13
  32. package/dist/lib/templates/index.json +0 -5
@@ -375,63 +375,93 @@ function getStyleVal(prop: string, fallback: any = ''): any {
375
375
  return val !== undefined ? val : fallback
376
376
  }
377
377
 
378
- function applyTextStyleToHtml(html: string, styles: any) {
379
- if (!html) return html
380
- const div = document.createElement('div')
381
- div.innerHTML = html
382
-
383
- // 1. 保证所有块级元素(p, div, li 等)背景色透明,绝不被整行涂满
384
- div.querySelectorAll('p, div, li, h1, h2, h3, h4, h5, h6').forEach((block: any) => {
385
- block.style.backgroundColor = ''
386
- block.style.removeProperty('background-color')
387
- })
388
-
389
- // 2. 如果处理文字高亮背景色 textBackground
390
- if (styles.textBackground !== undefined) {
391
- const isClear = styles.textBackground === 'transparent' || !styles.textBackground
392
- const bgVal = isClear ? '' : styles.textBackground
393
-
394
- const existingSpans = div.querySelectorAll('span')
395
- if (isClear) {
396
- existingSpans.forEach((s: HTMLElement) => {
397
- s.style.backgroundColor = ''
398
- s.style.removeProperty('background-color')
399
- })
400
- } else {
401
- // 需要高亮文字
402
- const blocks = div.querySelectorAll('p, div, li')
403
- if (blocks.length > 0) {
404
- blocks.forEach((block: any) => {
405
- const spansInBlock = block.querySelectorAll('span')
406
- if (spansInBlock.length > 0) {
407
- spansInBlock.forEach((s: HTMLElement) => {
408
- s.style.backgroundColor = bgVal
409
- })
410
- } else if (block.childNodes.length > 0) {
411
- // 没有 span 时,将段落内所有子节点包裹进一个 span 中
412
- const span = document.createElement('span')
413
- span.style.backgroundColor = bgVal
414
- while (block.firstChild) {
415
- span.appendChild(block.firstChild)
416
- }
417
- block.appendChild(span)
418
- }
419
- })
420
- } else {
421
- if (existingSpans.length > 0) {
422
- existingSpans.forEach((s: HTMLElement) => {
423
- s.style.backgroundColor = bgVal
424
- })
425
- } else if (div.childNodes.length > 0) {
426
- const span = document.createElement('span')
427
- span.style.backgroundColor = bgVal
428
- while (div.firstChild) {
429
- span.appendChild(div.firstChild)
430
- }
431
- div.appendChild(span)
432
- }
433
- }
434
- }
378
+ function isTransparentColorVal(val: any): boolean {
379
+ if (!val || typeof val !== 'string') return true
380
+ const s = val.trim().toLowerCase()
381
+ if (s === 'transparent' || s === 'none' || s === 'initial' || s === 'inherit') return true
382
+ if (/^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*0(?:\.0+)?\s*\)$/.test(s)) return true
383
+ if (/^#[0-9a-f]{6}00$/.test(s) || /^#[0-9a-f]{3}0$/.test(s)) return true
384
+ return false
385
+ }
386
+
387
+ function applyTextStyleToHtml(html: string, styles: any) {
388
+ if (!html) return html
389
+ const div = document.createElement('div')
390
+ div.innerHTML = html
391
+
392
+ // 1. 保证所有块级元素(p, div, li 等)背景色透明,绝不被整行涂满
393
+ div.querySelectorAll('p, div, li, h1, h2, h3, h4, h5, h6, ul, ol').forEach((block: any) => {
394
+ block.style.backgroundColor = ''
395
+ block.style.removeProperty('background-color')
396
+ block.style.background = ''
397
+ block.style.removeProperty('background')
398
+ })
399
+
400
+ // 2. 如果处理文字高亮背景色 textBackground
401
+ if (styles.textBackground !== undefined) {
402
+ const isClear = isTransparentColorVal(styles.textBackground)
403
+ const bgVal = isClear ? '' : styles.textBackground
404
+
405
+ if (isClear) {
406
+ const tableCellTags = new Set(['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR', 'TD', 'TH', 'COL', 'COLGROUP'])
407
+ div.querySelectorAll('*').forEach((elem: any) => {
408
+ if (elem.style && !tableCellTags.has(elem.tagName)) {
409
+ elem.style.backgroundColor = ''
410
+ elem.style.removeProperty('background-color')
411
+ elem.style.background = ''
412
+ elem.style.removeProperty('background')
413
+ }
414
+ if (elem.tagName === 'MARK' && elem.parentNode) {
415
+ while (elem.firstChild) {
416
+ elem.parentNode.insertBefore(elem.firstChild, elem)
417
+ }
418
+ elem.parentNode.removeChild(elem)
419
+ }
420
+ })
421
+ } else {
422
+ // 需要高亮文字
423
+ const leafBlocks = Array.from(
424
+ div.querySelectorAll('p, div, li, h1, h2, h3, h4, h5, h6, td, th')
425
+ ).filter((b: Element) => !b.querySelector('p, div, li, h1, h2, h3, h4, h5, h6, ul, ol, table')) as HTMLElement[]
426
+
427
+ const applyBgToBlock = (block: HTMLElement) => {
428
+ const textContent = (block.textContent || '').replace(/\u200B/g, '').trim()
429
+ if (!textContent) return
430
+
431
+ block.querySelectorAll('*').forEach((child: any) => {
432
+ if (child.style) {
433
+ child.style.backgroundColor = ''
434
+ child.style.removeProperty('background-color')
435
+ child.style.background = ''
436
+ child.style.removeProperty('background')
437
+ }
438
+ })
439
+
440
+ const nonEmptyNodes = Array.from(block.childNodes).filter(
441
+ n => !(n.nodeType === Node.TEXT_NODE && !(n.textContent || '').trim())
442
+ )
443
+ if (
444
+ nonEmptyNodes.length === 1 &&
445
+ nonEmptyNodes[0].nodeType === Node.ELEMENT_NODE &&
446
+ (nonEmptyNodes[0] as HTMLElement).tagName === 'SPAN'
447
+ ) {
448
+ ;(nonEmptyNodes[0] as HTMLElement).style.backgroundColor = bgVal
449
+ } else if (block.childNodes.length > 0) {
450
+ const span = document.createElement('span')
451
+ span.style.backgroundColor = bgVal
452
+ while (block.firstChild) {
453
+ span.appendChild(block.firstChild)
454
+ }
455
+ block.appendChild(span)
456
+ }
457
+ }
458
+
459
+ if (leafBlocks.length > 0) {
460
+ leafBlocks.forEach(applyBgToBlock)
461
+ } else {
462
+ applyBgToBlock(div)
463
+ }
464
+ }
435
465
  }
436
466
 
437
467
  // 3. 处理字号、字体、颜色、加粗等其他文字样式
@@ -525,9 +555,10 @@ function applyTextStyleToHtml(html: string, styles: any) {
525
555
 
526
556
  function setStyleVal(prop: string, val: any) {
527
557
  if (!selectedElement.value) return
528
- if (selectedElementIds.value.length > 1 && activeSlide.value) {
529
- activeSlide.value.elements.forEach((el: any) => {
530
- if (selectedElementIds.value.includes(el.id)) {
558
+ if (selectedElementIds.value.length > 1 && activeSlide.value) {
559
+ selectedElementIds.value.forEach((id: string) => {
560
+ const el = findElementInSlide(id)
561
+ if (el) {
531
562
  if (!el.style) el.style = {}
532
563
  if (el.type === 'line') {
533
564
  if (prop === 'borderColor') {
@@ -616,36 +647,39 @@ function setStyleVal(prop: string, val: any) {
616
647
  }
617
648
  }
618
649
 
619
- if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'fontWeight' || prop === 'fontStyle' || prop === 'textAlign') {
620
- const container = document.getElementById(`editable-${el.id}`)
621
- if (container && (!el.content || !el.content.includes('<table')) && !el.latex) {
622
- if (prop === 'fontFamily') {
623
- container.style.fontFamily = val
624
- container.style.setProperty('--ppt-font-family', val)
625
- container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontFamily: val })
626
- } else if (prop === 'fontSize') {
627
- container.style.fontSize = val
628
- container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontSize: val })
629
- } else if (prop === 'fontWeight') {
630
- container.style.fontWeight = val
631
- container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontWeight: val })
632
- } else if (prop === 'fontStyle') {
633
- container.style.fontStyle = val
634
- container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontStyle: val })
635
- } else if (prop === 'textAlign') {
636
- container.style.textAlign = val
637
- container.innerHTML = updateTextAlignInHtml(container.innerHTML, val)
638
- }
639
- if (el.type === 'shape') {
640
- if (el.text && typeof el.text === 'object') {
641
- el.text.content = container.innerHTML
642
- } else {
643
- el.text = container.innerHTML
644
- }
645
- } else {
646
- el.content = container.innerHTML
647
- }
648
- }
650
+ if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'fontWeight' || prop === 'fontStyle' || prop === 'textAlign' || prop === 'textBackground') {
651
+ const container = document.getElementById(`editable-${el.id}`)
652
+ if (container && (!el.content || !el.content.includes('<table')) && !el.latex) {
653
+ if (prop === 'fontFamily') {
654
+ container.style.fontFamily = val
655
+ container.style.setProperty('--ppt-font-family', val)
656
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontFamily: val })
657
+ } else if (prop === 'fontSize') {
658
+ container.style.fontSize = val
659
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontSize: val })
660
+ } else if (prop === 'fontWeight') {
661
+ container.style.fontWeight = val
662
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontWeight: val })
663
+ } else if (prop === 'fontStyle') {
664
+ container.style.fontStyle = val
665
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontStyle: val })
666
+ } else if (prop === 'textAlign') {
667
+ container.style.textAlign = val
668
+ container.innerHTML = updateTextAlignInHtml(container.innerHTML, val)
669
+ } else if (prop === 'textBackground') {
670
+ container.style.backgroundColor = el.type === 'text' ? (el.style?.fill || 'transparent') : ''
671
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { textBackground: val })
672
+ }
673
+ if (el.type === 'shape') {
674
+ if (el.text && typeof el.text === 'object') {
675
+ el.text.content = container.innerHTML
676
+ } else {
677
+ el.text = container.innerHTML
678
+ }
679
+ } else {
680
+ el.content = container.innerHTML
681
+ }
682
+ }
649
683
  }
650
684
  }
651
685
  })
@@ -739,36 +773,39 @@ function setStyleVal(prop: string, val: any) {
739
773
  }
740
774
  }
741
775
 
742
- if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'fontWeight' || prop === 'fontStyle' || prop === 'textAlign') {
743
- const container = document.getElementById(`editable-${el.id}`)
744
- if (container && (!el.content || !el.content.includes('<table')) && !el.latex) {
745
- if (prop === 'fontFamily') {
746
- container.style.fontFamily = val
747
- container.style.setProperty('--ppt-font-family', val)
748
- container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontFamily: val })
749
- } else if (prop === 'fontSize') {
750
- container.style.fontSize = val
751
- container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontSize: val })
752
- } else if (prop === 'fontWeight') {
753
- container.style.fontWeight = val
754
- container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontWeight: val })
755
- } else if (prop === 'fontStyle') {
756
- container.style.fontStyle = val
757
- container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontStyle: val })
758
- } else if (prop === 'textAlign') {
759
- container.style.textAlign = val
760
- container.innerHTML = updateTextAlignInHtml(container.innerHTML, val)
761
- }
762
- if (el.type === 'shape') {
763
- if (el.text && typeof el.text === 'object') {
764
- el.text.content = container.innerHTML
765
- } else {
766
- el.text = container.innerHTML
767
- }
768
- } else {
769
- el.content = container.innerHTML
770
- }
771
- }
776
+ if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'fontWeight' || prop === 'fontStyle' || prop === 'textAlign' || prop === 'textBackground') {
777
+ const container = document.getElementById(`editable-${el.id}`)
778
+ if (container && (!el.content || !el.content.includes('<table')) && !el.latex) {
779
+ if (prop === 'fontFamily') {
780
+ container.style.fontFamily = val
781
+ container.style.setProperty('--ppt-font-family', val)
782
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontFamily: val })
783
+ } else if (prop === 'fontSize') {
784
+ container.style.fontSize = val
785
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontSize: val })
786
+ } else if (prop === 'fontWeight') {
787
+ container.style.fontWeight = val
788
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontWeight: val })
789
+ } else if (prop === 'fontStyle') {
790
+ container.style.fontStyle = val
791
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { fontStyle: val })
792
+ } else if (prop === 'textAlign') {
793
+ container.style.textAlign = val
794
+ container.innerHTML = updateTextAlignInHtml(container.innerHTML, val)
795
+ } else if (prop === 'textBackground') {
796
+ container.style.backgroundColor = el.type === 'text' ? (el.style?.fill || 'transparent') : ''
797
+ container.innerHTML = applyTextStyleToHtml(container.innerHTML, { textBackground: val })
798
+ }
799
+ if (el.type === 'shape') {
800
+ if (el.text && typeof el.text === 'object') {
801
+ el.text.content = container.innerHTML
802
+ } else {
803
+ el.text = container.innerHTML
804
+ }
805
+ } else {
806
+ el.content = container.innerHTML
807
+ }
808
+ }
772
809
  }
773
810
  if (el.type === 'group' && Array.isArray(el.elements)) {
774
811
  const allowedInheritProps = [
@@ -841,20 +878,32 @@ function setStyleVal(prop: string, val: any) {
841
878
  child.text = updateTextAlignInHtml(child.text, val)
842
879
  }
843
880
  }
844
- if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'textAlign') {
845
- const childContainer = document.getElementById(`editable-${child.id}`)
846
- if (childContainer && (!child.content || !child.content.includes('<table')) && !child.latex) {
847
- if (prop === 'fontFamily') {
848
- childContainer.style.fontFamily = val
849
- childContainer.innerHTML = applyTextStyleToHtml(childContainer.innerHTML, { fontFamily: val })
850
- } else if (prop === 'fontSize') {
851
- childContainer.style.fontSize = val
852
- childContainer.innerHTML = applyTextStyleToHtml(childContainer.innerHTML, { fontSize: val })
853
- } else if (prop === 'textAlign') {
854
- childContainer.style.textAlign = val
855
- childContainer.innerHTML = updateTextAlignInHtml(childContainer.innerHTML, val)
856
- }
857
- }
881
+ if (prop === 'fontFamily' || prop === 'fontSize' || prop === 'textAlign' || prop === 'textBackground') {
882
+ const childContainer = document.getElementById(`editable-${child.id}`)
883
+ if (childContainer && (!child.content || !child.content.includes('<table')) && !child.latex) {
884
+ if (prop === 'fontFamily') {
885
+ childContainer.style.fontFamily = val
886
+ childContainer.innerHTML = applyTextStyleToHtml(childContainer.innerHTML, { fontFamily: val })
887
+ } else if (prop === 'fontSize') {
888
+ childContainer.style.fontSize = val
889
+ childContainer.innerHTML = applyTextStyleToHtml(childContainer.innerHTML, { fontSize: val })
890
+ } else if (prop === 'textAlign') {
891
+ childContainer.style.textAlign = val
892
+ childContainer.innerHTML = updateTextAlignInHtml(childContainer.innerHTML, val)
893
+ } else if (prop === 'textBackground') {
894
+ childContainer.style.backgroundColor = child.type === 'text' ? (child.style?.fill || 'transparent') : ''
895
+ childContainer.innerHTML = applyTextStyleToHtml(childContainer.innerHTML, { textBackground: val })
896
+ }
897
+ if (child.type === 'shape') {
898
+ if (child.text && typeof child.text === 'object') {
899
+ child.text.content = childContainer.innerHTML
900
+ } else {
901
+ child.text = childContainer.innerHTML
902
+ }
903
+ } else {
904
+ child.content = childContainer.innerHTML
905
+ }
906
+ }
858
907
  }
859
908
  if (child.type === 'group' && Array.isArray(child.elements)) {
860
909
  child.elements.forEach(applyToGroupChild)
@@ -151,44 +151,35 @@ const isNearTopEdge = computed(() => {
151
151
 
152
152
  <!-- Standard Selection Handles -->
153
153
  <template v-else-if="selectedElementIds && selectedElementIds.includes(element.id)">
154
- <!-- 4 Corner resize handles (Non-text elements, Tables, LaTeX formulas) -->
155
- <template
156
- v-if="element.type !== 'text' || (element.content && element.content.includes('<table')) || element.latex">
157
- <div class="resize-handle handle-tl"
158
- :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('tl', element) : 'nwse-resize' }"
159
- @mousedown.stop="emit('resizeStart', $event, element, 'tl')"></div>
160
- <div class="resize-handle handle-tr"
161
- :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('tr', element) : 'nesw-resize' }"
162
- @mousedown.stop="emit('resizeStart', $event, element, 'tr')"></div>
163
- <div class="resize-handle handle-bl"
164
- :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('bl', element) : 'nesw-resize' }"
165
- @mousedown.stop="emit('resizeStart', $event, element, 'bl')"></div>
166
- <div class="resize-handle handle-br"
167
- :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('br', element) : 'nwse-resize' }"
168
- @mousedown.stop="emit('resizeStart', $event, element, 'br')"></div>
169
- </template>
154
+ <!-- 4 Corner resize handles -->
155
+ <div class="resize-handle handle-tl"
156
+ :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('tl', element) : 'nwse-resize' }"
157
+ @mousedown.stop="emit('resizeStart', $event, element, 'tl')"></div>
158
+ <div class="resize-handle handle-tr"
159
+ :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('tr', element) : 'nesw-resize' }"
160
+ @mousedown.stop="emit('resizeStart', $event, element, 'tr')"></div>
161
+ <div class="resize-handle handle-bl"
162
+ :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('bl', element) : 'nesw-resize' }"
163
+ @mousedown.stop="emit('resizeStart', $event, element, 'bl')"></div>
164
+ <div class="resize-handle handle-br"
165
+ :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('br', element) : 'nwse-resize' }"
166
+ @mousedown.stop="emit('resizeStart', $event, element, 'br')"></div>
170
167
 
171
- <!-- Top/Bottom midpoint resize handles (Non-text elements, Vertical text, Tables, LaTeX formulas) -->
172
- <template
173
- v-if="element.type !== 'text' || (element.style?.writingMode === 'vertical-rl' || element.style?.writingMode === 'vertical-lr') || (element.content && element.content.includes('<table')) || element.latex">
174
- <div class="resize-handle handle-tc"
175
- :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('tc', element) : 'ns-resize' }"
176
- @mousedown.stop="emit('resizeStart', $event, element, 'tc')"></div>
177
- <div class="resize-handle handle-bc"
178
- :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('bc', element) : 'ns-resize' }"
179
- @mousedown.stop="emit('resizeStart', $event, element, 'bc')"></div>
180
- </template>
168
+ <!-- Top/Bottom midpoint resize handles -->
169
+ <div class="resize-handle handle-tc"
170
+ :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('tc', element) : 'ns-resize' }"
171
+ @mousedown.stop="emit('resizeStart', $event, element, 'tc')"></div>
172
+ <div class="resize-handle handle-bc"
173
+ :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('bc', element) : 'ns-resize' }"
174
+ @mousedown.stop="emit('resizeStart', $event, element, 'bc')"></div>
181
175
 
182
- <!-- Left/Right midpoint resize handles (Non-text elements, Horizontal text, Tables, LaTeX formulas) -->
183
- <template
184
- v-if="element.type !== 'text' || (element.style?.writingMode !== 'vertical-rl' && element.style?.writingMode !== 'vertical-lr')">
185
- <div class="resize-handle handle-ml"
186
- :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('ml', element) : 'ew-resize' }"
187
- @mousedown.stop="emit('resizeStart', $event, element, 'ml')"></div>
188
- <div class="resize-handle handle-mr"
189
- :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('mr', element) : 'ew-resize' }"
190
- @mousedown.stop="emit('resizeStart', $event, element, 'mr')"></div>
191
- </template>
176
+ <!-- Left/Right midpoint resize handles -->
177
+ <div class="resize-handle handle-ml"
178
+ :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('ml', element) : 'ew-resize' }"
179
+ @mousedown.stop="emit('resizeStart', $event, element, 'ml')"></div>
180
+ <div class="resize-handle handle-mr"
181
+ :style="{ pointerEvents: 'auto', cursor: getResizeCursor ? getResizeCursor('mr', element) : 'ew-resize' }"
182
+ @mousedown.stop="emit('resizeStart', $event, element, 'mr')"></div>
192
183
 
193
184
  <!-- Rotation handle (始终保持在元素正上方,符合主流 PPT/设计软件标准规范) -->
194
185
  <div v-if="element.type !== 'chart' && !(element.content && element.content.includes('<table'))"
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { ref } from 'vue'
3
+ import { resolveLocalMediaPath } from '../../../utils/canvas/elementStyles'
3
4
 
4
5
  const props = defineProps<{
5
6
  element: any
@@ -98,8 +99,8 @@ function seekAudio(e: MouseEvent, id: string) {
98
99
  <template v-if="element.type === 'video'">
99
100
  <video
100
101
  :id="`video-player-${element.id}`"
101
- :src="element.content"
102
- :poster="(element as any).poster"
102
+ :src="resolveLocalMediaPath(element.content || element.src)"
103
+ :poster="resolveLocalMediaPath((element as any).poster)"
103
104
  controls
104
105
  :autoplay="element.autoplay"
105
106
  :style="{
@@ -139,7 +140,7 @@ function seekAudio(e: MouseEvent, id: string) {
139
140
 
140
141
  <audio
141
142
  :id="`audio-player-${element.id}`"
142
- :src="element.content"
143
+ :src="resolveLocalMediaPath(element.content || element.src)"
143
144
  style="position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none;"
144
145
  @play="onAudioPlay(element.id)"
145
146
  @pause="onAudioPause(element.id)"
@@ -22,6 +22,7 @@ import {
22
22
  import { isEllipseShape } from '../../../utils/line'
23
23
  import { getFontVariantStyle } from '../../../configs/fonts'
24
24
  import { useSlides } from '../../../composables/useSlides'
25
+ import { applyTextStyleToHtml, isTransparentTextBg } from '../../../utils/canvas/formatPainter'
25
26
  import { createTextSelectionOverlay, type TextSelectionOverlayHandle } from '../textSelectionOverlay'
26
27
 
27
28
  const { shapeFormatPainter, isReadonly } = useSlides()
@@ -353,9 +354,9 @@ function formatShapeHtml(el: any): string {
353
354
  }
354
355
  const raw = getRawText(el)
355
356
  const norm = props.normalizeHtmlFontFamily ? props.normalizeHtmlFontFamily(raw) : raw
356
- if (el.style?.textBackground && el.style.textBackground !== 'transparent') {
357
+ if (el.style?.textBackground && !isTransparentTextBg(el.style.textBackground)) {
357
358
  if (!norm.includes('background-color')) {
358
- return `<span style='background-color: ${el.style.textBackground}; display: inline;'>${norm}</span>`
359
+ return applyTextStyleToHtml(norm, { textBackground: el.style.textBackground })
359
360
  }
360
361
  }
361
362
  return norm
@@ -668,8 +669,9 @@ function formatShapeHtml(el: any): string {
668
669
  :rx="getRectRadiusInVb(element).rx"
669
670
  :ry="getRectRadiusInVb(element).ry"
670
671
  vector-effect="non-scaling-stroke"
671
- :fill="hasElementFill(element) ? (getElementPattern(element) ? `url(#shape-pattern-${svgIdKey})` : (getElementGradientConfig(element) ? `url(#shape-gradient-${svgIdKey})` : (getElementFill(element) !== undefined ? getElementFill(element) : '#3b82f6'))) : ((isImagePlaceholder && isImagePlaceholder(element)) ? getImagePlaceholderFill(element) : 'none')"
672
- :stroke="(isImagePlaceholder && isImagePlaceholder(element) && element.style?.enableBorder !== true) ? 'none' : (element.style?.enableBorder === false ? 'none' : getEffectiveBorderColor(element, 'none'))"
672
+ :fill="hasElementFill(element) ? (getElementPattern(element) ? `url(#shape-pattern-${svgIdKey})` : (getElementGradientConfig(element) ? `url(#shape-gradient-${svgIdKey})` : getHexColorWithoutAlpha(getElementFill(element) !== undefined ? getElementFill(element) : '#3b82f6'))) : ((isImagePlaceholder && isImagePlaceholder(element)) ? getImagePlaceholderFill(element) : 'none')"
673
+ :fill-opacity="(hasElementFill(element) && !getElementPattern(element) && !getElementGradientConfig(element)) ? getAlphaFromColor(getElementFill(element) !== undefined ? getElementFill(element) : '#3b82f6') : undefined"
674
+ :stroke="(isImagePlaceholder && isImagePlaceholder(element) && element.style?.enableBorder !== true) ? 'none' : (element.style?.enableBorder === false || (!hasElementBorderGradient(element) && getElementBorderWidth(element) <= 0) ? 'none' : getEffectiveBorderColor(element, 'none'))"
673
675
  :stroke-width="(isImagePlaceholder && isImagePlaceholder(element) && element.style?.enableBorder !== true) ? 0 : (element.style?.enableBorder === false ? 0 : getElementBorderWidth(element))"
674
676
  :stroke-linecap="element.style?.strokeLinecap || element.borderLineCap || element.lineCap || (element.shapType === 'arc' ? 'round' : (isOpenLineShape(element) ? 'butt' : undefined))"
675
677
  :stroke-dasharray="element.style?.borderStyle === 'dashed' || element.borderType === 'dashed' ? '5 5' : ''"
@@ -678,8 +680,9 @@ function formatShapeHtml(el: any): string {
678
680
  v-else
679
681
  vector-effect="non-scaling-stroke"
680
682
  :d="element.path || element.content"
681
- :fill="hasElementFill(element) ? (getElementPattern(element) ? `url(#shape-pattern-${svgIdKey})` : (getElementGradientConfig(element) ? `url(#shape-gradient-${svgIdKey})` : (getElementFill(element) !== undefined ? getElementFill(element) : '#3b82f6'))) : ((isImagePlaceholder && isImagePlaceholder(element)) ? getImagePlaceholderFill(element) : 'none')"
682
- :stroke="(isImagePlaceholder && isImagePlaceholder(element) && element.style?.enableBorder !== true) ? 'none' : (element.style?.enableBorder === false ? 'none' : getEffectiveBorderColor(element, 'none'))"
683
+ :fill="hasElementFill(element) ? (getElementPattern(element) ? `url(#shape-pattern-${svgIdKey})` : (getElementGradientConfig(element) ? `url(#shape-gradient-${svgIdKey})` : getHexColorWithoutAlpha(getElementFill(element) !== undefined ? getElementFill(element) : '#3b82f6'))) : ((isImagePlaceholder && isImagePlaceholder(element)) ? getImagePlaceholderFill(element) : 'none')"
684
+ :fill-opacity="(hasElementFill(element) && !getElementPattern(element) && !getElementGradientConfig(element)) ? getAlphaFromColor(getElementFill(element) !== undefined ? getElementFill(element) : '#3b82f6') : undefined"
685
+ :stroke="(isImagePlaceholder && isImagePlaceholder(element) && element.style?.enableBorder !== true) ? 'none' : (element.style?.enableBorder === false || (!hasElementBorderGradient(element) && getElementBorderWidth(element) <= 0) ? 'none' : getEffectiveBorderColor(element, 'none'))"
683
686
  :stroke-width="(isImagePlaceholder && isImagePlaceholder(element) && element.style?.enableBorder !== true) ? 0 : (element.style?.enableBorder === false ? 0 : getElementBorderWidth(element))"
684
687
  :stroke-linecap="element.style?.strokeLinecap || element.borderLineCap || element.lineCap || (element.shapType === 'arc' ? 'round' : (isOpenLineShape(element) ? 'butt' : undefined))"
685
688
  :stroke-dasharray="element.style?.borderStyle === 'dashed' || element.borderType === 'dashed' ? '5 5' : ''"
@@ -277,8 +277,9 @@ function getLayoutSvgElements(elements: any[]) {
277
277
  }
278
278
 
279
279
  const borderStyle = el.style?.borderStyle || el.borderStyle || 'none'
280
- const borderColor = getElementBorderColor(el) || parseColorString(el.style?.borderColor || el.borderColor, 'none')
281
280
  const borderWidth = getElementBorderWidth(el) || (el.style?.borderWidth ? parseFloat(el.style.borderWidth) : (el.borderWidth ? parseFloat(el.borderWidth) : 0))
281
+ const hasBorderGrad = hasElementBorderGradient(el)
282
+ const borderColor = (!hasBorderGrad && borderWidth <= 0) ? 'none' : (getElementBorderColor(el) || parseColorString(el.style?.borderColor || el.borderColor, 'none'))
282
283
  const textAlign = el.style?.textAlign || el.textAlign || (isTitle && !isVertical ? 'center' : 'left')
283
284
 
284
285
  let shapePath = ''
@@ -514,7 +515,7 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
514
515
  </g>
515
516
  <g v-else-if="item.type === 'shape' && item.shapePath" :transform="item.transform">
516
517
  <svg :x="item.x" :y="item.y" :width="item.w" :height="item.h" :viewBox="`0 0 ${item.shapeViewBox ? item.shapeViewBox[0] : 200} ${item.shapeViewBox ? item.shapeViewBox[1] : 200}`" preserveAspectRatio="none" style="overflow: visible;">
517
- <path :d="item.shapePath" :fill="item.gradient ? `url(#layout-grad-${item.id})` : (item.fill && item.fill !== 'transparent' ? item.fill : 'none')" :stroke="item.borderGradient ? `url(#layout-bgrad-${item.id})` : (item.borderColor && item.borderColor !== 'transparent' ? item.borderColor : 'none')" :stroke-width="item.borderWidth ? Math.min(1.5, Math.max(0.6, item.borderWidth * 0.8)) : 0.8" :stroke-linecap="item.lineCap" vector-effect="non-scaling-stroke" />
518
+ <path :d="item.shapePath" :fill="item.gradient ? `url(#layout-grad-${item.id})` : (item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getHexColorWithoutAlpha(item.fill) : 'none')" :fill-opacity="!item.gradient && item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getAlphaFromColor(item.fill) : undefined" :stroke="item.borderGradient ? `url(#layout-bgrad-${item.id})` : (item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getHexColorWithoutAlpha(item.borderColor) : 'none')" :stroke-opacity="!item.borderGradient && item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getAlphaFromColor(item.borderColor) : undefined" :stroke-width="(item.borderGradient || item.borderWidth > 0) ? Math.min(1.5, Math.max(0.6, (item.borderWidth || 1) * 0.8)) : 0" :stroke-linecap="item.lineCap" vector-effect="non-scaling-stroke" />
518
519
  </svg>
519
520
  </g>
520
521
  <g v-else-if="item.type === 'shape' && item.isCircle" :transform="item.transform">
@@ -523,13 +524,15 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
523
524
  :cy="item.y + item.h / 2"
524
525
  :rx="item.w / 2"
525
526
  :ry="item.h / 2"
526
- :fill="item.gradient ? `url(#layout-grad-${item.id})` : (item.fill && item.fill !== 'transparent' ? item.fill : 'none')"
527
- :stroke="item.borderGradient ? `url(#layout-bgrad-${item.id})` : (item.borderColor && item.borderColor !== 'transparent' ? item.borderColor : 'none')"
528
- :stroke-width="item.borderWidth ? Math.min(1.5, Math.max(0.6, item.borderWidth * 0.8)) : 0.8"
527
+ :fill="item.gradient ? `url(#layout-grad-${item.id})` : (item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getHexColorWithoutAlpha(item.fill) : 'none')"
528
+ :fill-opacity="!item.gradient && item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getAlphaFromColor(item.fill) : undefined"
529
+ :stroke="item.borderGradient ? `url(#layout-bgrad-${item.id})` : (item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getHexColorWithoutAlpha(item.borderColor) : 'none')"
530
+ :stroke-opacity="!item.borderGradient && item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getAlphaFromColor(item.borderColor) : undefined"
531
+ :stroke-width="(item.borderGradient || item.borderWidth > 0) ? Math.min(1.5, Math.max(0.6, (item.borderWidth || 1) * 0.8)) : 0"
529
532
  />
530
533
  </g>
531
534
  <g v-else-if="item.type === 'shape'" :transform="item.transform">
532
- <rect :x="item.x" :y="item.y" :width="item.w" :height="item.h" :fill="item.gradient ? `url(#layout-grad-${item.id})` : (item.fill && item.fill !== 'transparent' ? item.fill : 'none')" :stroke="item.borderGradient ? `url(#layout-bgrad-${item.id})` : (item.borderColor && item.borderColor !== 'transparent' ? item.borderColor : 'none')" :stroke-width="item.borderWidth ? Math.min(1.5, Math.max(0.6, item.borderWidth * 0.8)) : 0.8" rx="1" />
535
+ <rect :x="item.x" :y="item.y" :width="item.w" :height="item.h" :fill="item.gradient ? `url(#layout-grad-${item.id})` : (item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getHexColorWithoutAlpha(item.fill) : 'none')" :fill-opacity="!item.gradient && item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getAlphaFromColor(item.fill) : undefined" :stroke="item.borderGradient ? `url(#layout-bgrad-${item.id})` : (item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getHexColorWithoutAlpha(item.borderColor) : 'none')" :stroke-opacity="!item.borderGradient && item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getAlphaFromColor(item.borderColor) : undefined" :stroke-width="(item.borderGradient || item.borderWidth > 0) ? Math.min(1.5, Math.max(0.6, (item.borderWidth || 1) * 0.8)) : 0" rx="1" />
533
536
  </g>
534
537
  <g v-else-if="item.type === 'title' || item.type === 'text'" :transform="item.transform">
535
538
  <rect
@@ -498,7 +498,7 @@ function onSelectFillColor(color: string) {
498
498
  <SidebarPositionGroup :element-x="elementX" :element-y="elementY" :element-w="elementW" :element-h="elementH"
499
499
  :element-rotate="elementRotate" :is-fixed-ratio="isFixedRatio" :is-flip-h="isFlipH" :is-flip-v="isFlipV"
500
500
  :hide-position="isMultiSelect" :hide-dimensions="isMultiSelect" :show-rotate="element?.type !== 'table'"
501
- :show-flips="element?.type !== 'table'" :disable-height="element?.type === 'text'"
501
+ :show-flips="element?.type !== 'table'"
502
502
  @update:element-x="emit('update:elementX', $event)"
503
503
  @update:element-y="emit('update:elementY', $event)" @update:element-w="emit('update:elementW', $event)"
504
504
  @update:element-h="emit('update:elementH', $event)" @update:element-rotate="emit('update:elementRotate', $event)"
@@ -78,7 +78,7 @@ const props = withDefaults(defineProps<{
78
78
  styleTextAlign: 'center',
79
79
  styleVerticalAlign: 'middle',
80
80
  styleWritingMode: 'horizontal-tb',
81
- styleAutoFitType: 'shape',
81
+ styleAutoFitType: 'none',
82
82
  styleWordWrap: true,
83
83
  paddingTop: 4.8,
84
84
  paddingRight: 9.6,