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
@@ -1,5 +1,6 @@
1
1
  import { ref, computed, nextTick, type Ref } from 'vue'
2
2
  import { shapeFormulas } from '../../utils/pptxShapesLazy'
3
+ import { isTransparentTextBg, applyOrClearRangeHighlight } from '../../utils/canvas/formatPainter'
3
4
 
4
5
  export interface FormattingOptions {
5
6
  activeSlide: Ref<any>
@@ -426,19 +427,24 @@ export function useCanvasFormatting(options: FormattingOptions) {
426
427
  const isCollapsed = !rangeToUse || rangeToUse.collapsed
427
428
 
428
429
  if (!isCollapsed && rangeToUse) {
430
+ let targetEl: any = null
429
431
  els.forEach((el: any) => {
430
432
  const container = document.getElementById(`editable-${el.id}`)
431
433
  if (container && container.contains(rangeToUse.commonAncestorContainer)) {
432
434
  targetContainer = container
435
+ targetEl = el
433
436
  offsets = getSelectionCharacterOffsetWithin(container, rangeToUse)
434
437
  }
435
438
  })
436
439
 
437
- restoreSelection()
438
440
  if (type === 'color') {
441
+ restoreSelection()
439
442
  document.execCommand('foreColor', false, color)
440
443
  activeSelectionTextColor.value = color
444
+ } else if (targetContainer) {
445
+ applyOrClearRangeHighlight(targetContainer, rangeToUse, color, targetEl)
441
446
  } else {
447
+ restoreSelection()
442
448
  const hiliteCmd = document.queryCommandSupported('hiliteColor') ? 'hiliteColor' : 'backColor'
443
449
  const executed = document.execCommand(hiliteCmd, false, color)
444
450
  if (!executed && hiliteCmd !== 'backColor') {
@@ -553,43 +559,44 @@ export function useCanvasFormatting(options: FormattingOptions) {
553
559
  })
554
560
  addHistorySnapshot()
555
561
  } else {
562
+ const normalizedBg = isTransparentTextBg(color) ? 'transparent' : color
556
563
  els.forEach((el: any) => {
557
564
  if (!el) return
558
565
  if (!el.style) el.style = {}
559
- el.style.textBackground = color
566
+ el.style.textBackground = normalizedBg
560
567
 
568
+ const container = document.getElementById(`editable-${el.id}`)
561
569
  if (el.type === 'shape') {
562
- const raw = typeof el.text === 'string' ? el.text : (el.text?.content || '')
563
- const formatted = applyTextStyleToHtml(raw, { textBackground: color })
570
+ const raw = (container && container.innerHTML) ? container.innerHTML : (typeof el.text === 'string' ? el.text : (el.text?.content || ''))
571
+ const formatted = applyTextStyleToHtml(raw, { textBackground: normalizedBg })
564
572
  if (typeof el.text === 'string') {
565
573
  el.text = formatted
566
- } else if (el.text) {
574
+ } else if (el.text && typeof el.text === 'object') {
567
575
  el.text.content = formatted
568
576
  } else {
569
577
  el.text = formatted
570
578
  }
571
- const container = document.getElementById(`editable-${el.id}`)
572
579
  if (container) {
573
580
  container.style.backgroundColor = ''
574
581
  container.innerHTML = formatted
575
582
  }
576
- } else if (el.content) {
577
- if (el.content.includes('<table')) {
583
+ } else if (el.content || container) {
584
+ const rawHtml = (container && (!el.content || !el.content.includes('<table')) && container.innerHTML) ? container.innerHTML : (el.content || '')
585
+ if (rawHtml.includes('<table')) {
578
586
  const div = document.createElement('div')
579
- div.innerHTML = el.content
587
+ div.innerHTML = rawHtml
580
588
  const table = div.querySelector('table')
581
589
  if (table) {
582
590
  table.querySelectorAll('td, th').forEach((cell: any) => {
583
- cell.style.backgroundColor = color === 'transparent' ? '' : color
591
+ cell.style.backgroundColor = normalizedBg === 'transparent' ? '' : normalizedBg
584
592
  })
585
593
  el.content = div.innerHTML
586
594
  }
587
595
  } else {
588
- el.content = applyTextStyleToHtml(el.content, { textBackground: color })
596
+ el.content = applyTextStyleToHtml(rawHtml, { textBackground: normalizedBg })
589
597
  }
590
- const container = document.getElementById(`editable-${el.id}`)
591
598
  if (container) {
592
- container.style.backgroundColor = ''
599
+ container.style.backgroundColor = el.style?.fill || 'transparent'
593
600
  container.innerHTML = el.content
594
601
  }
595
602
  }
@@ -376,7 +376,8 @@ export function useCanvasText(options: TextOptions) {
376
376
  prevEl.text = htmlVal
377
377
  } else if (prevEl.type === 'text') {
378
378
  prevEl.content = htmlVal
379
- if (!isMasterEl && container.offsetHeight > 0) {
379
+ const fitType = prevEl.autoFit?.type || 'none'
380
+ if (!isMasterEl && fitType === 'shape' && container.offsetHeight > 0) {
380
381
  prevEl.height = container.offsetHeight
381
382
  }
382
383
  }
@@ -587,7 +588,7 @@ export function useCanvasText(options: TextOptions) {
587
588
  selectedElementWidth.value = el.style?.width || (el.width ? `${el.width}px` : 'auto')
588
589
  selectedElementHeight.value = el.style?.height || (el.height ? `${el.height}px` : 'auto')
589
590
  } else {
590
- const fitType = el.autoFit?.type || 'shape'
591
+ const fitType = el.autoFit?.type || 'none'
591
592
  const isVertical = el.style?.writingMode === 'vertical-rl' || el.style?.writingMode === 'vertical-lr'
592
593
  if (fitType === 'shape') {
593
594
  if (isVertical) {
@@ -690,7 +691,7 @@ export function useCanvasText(options: TextOptions) {
690
691
 
691
692
  if (el.style && el.style.textBackground && el.style.textBackground !== 'transparent') {
692
693
  if (!content.includes('background-color')) {
693
- content = `<span style="background-color: ${el.style.textBackground}; display: inline;">${content}</span>`
694
+ content = applyTextStyleToHtml(content, { textBackground: el.style.textBackground })
694
695
  }
695
696
  }
696
697
  return content
@@ -281,8 +281,8 @@ export function useCanvasTransform(options: CanvasTransformOptions) {
281
281
  const isText = item.type === 'text' && !item.content?.includes('<table')
282
282
  const fontSize = parseFloat(item.style?.fontSize) || 18
283
283
  const isVerticalText = isText && (item.style?.writingMode === 'vertical-rl' || item.style?.writingMode === 'vertical-lr')
284
- const textMinWidth = isText ? Math.max(40, fontSize + 20) : 10
285
- const textMinHeight = isVerticalText ? Math.max(40, fontSize + 20) : 10
284
+ const textMinWidth = isText ? (isVerticalText ? 24 : Math.max(40, fontSize + 20)) : 10
285
+ const textMinHeight = isText ? (isVerticalText ? Math.max(40, fontSize + 20) : 20) : 10
286
286
 
287
287
  let minWidth = (item.type === 'text' && item.content && item.content.includes('<table'))
288
288
  ? (state.minTableWidth || 50)
@@ -303,8 +303,25 @@ export function useCanvasTransform(options: CanvasTransformOptions) {
303
303
  if (handle.includes('l')) newLeft = state.startLeft - actualDw
304
304
  if (handle.includes('t')) newTop = state.startTop - actualDh
305
305
 
306
- const isAutoHeightText = item.type === 'text' && !item.content?.includes('<table') && !item.latex && !(item.style?.writingMode === 'vertical-rl' || item.style?.writingMode === 'vertical-lr')
307
- const isAutoWidthText = item.type === 'text' && !item.content?.includes('<table') && !item.latex && (item.style?.writingMode === 'vertical-rl' || item.style?.writingMode === 'vertical-lr')
306
+ const isResizingHeight = handle.includes('t') || handle.includes('b')
307
+ const isResizingWidth = handle.includes('l') || handle.includes('r')
308
+ if (isText && !item.latex && item.autoFit?.type === 'shape') {
309
+ if (!isVerticalText && isResizingHeight) {
310
+ item.autoFit = {
311
+ ...item.autoFit,
312
+ type: 'none'
313
+ }
314
+ } else if (isVerticalText && isResizingWidth) {
315
+ item.autoFit = {
316
+ ...item.autoFit,
317
+ type: 'none'
318
+ }
319
+ }
320
+ }
321
+
322
+ const isShapeAutoFit = item.autoFit?.type === 'shape'
323
+ const isAutoHeightText = item.type === 'text' && isShapeAutoFit && !item.content?.includes('<table') && !item.latex && !(item.style?.writingMode === 'vertical-rl' || item.style?.writingMode === 'vertical-lr')
324
+ const isAutoWidthText = item.type === 'text' && isShapeAutoFit && !item.content?.includes('<table') && !item.latex && (item.style?.writingMode === 'vertical-rl' || item.style?.writingMode === 'vertical-lr')
308
325
 
309
326
  const parentGroup = findParentGroup(item.id)
310
327
  if (parentGroup) {
@@ -344,10 +361,10 @@ export function useCanvasTransform(options: CanvasTransformOptions) {
344
361
  if (typeof item.left === 'number') item.left = newLeft
345
362
  if (typeof item.top === 'number') item.top = newTop
346
363
  if (!isAutoWidthText) {
347
- if (typeof item.width === 'number') item.width = newW
364
+ item.width = newW
348
365
  }
349
366
  if (!isAutoHeightText) {
350
- if (typeof item.height === 'number') item.height = newH
367
+ item.height = newH
351
368
  }
352
369
 
353
370
  if (item.type === 'shape' && item.pathFormula === 'roundRect') {
@@ -367,11 +384,21 @@ export function useCanvasTransform(options: CanvasTransformOptions) {
367
384
  updateTextFontScale(item)
368
385
 
369
386
  if (selectedElementId.value === item.id) {
370
- if (options.selectedElementWidth && !isAutoWidthText) {
371
- options.selectedElementWidth.value = `${newW.toFixed(1)}px`
387
+ if (options.selectedElementWidth) {
388
+ if (!isAutoWidthText) {
389
+ options.selectedElementWidth.value = `${newW.toFixed(1)}px`
390
+ } else {
391
+ const dom = document.getElementById(`canvas-el-${item.id}`)
392
+ if (dom && dom.offsetWidth > 0) options.selectedElementWidth.value = `${dom.offsetWidth}px`
393
+ }
372
394
  }
373
- if (options.selectedElementHeight && !isAutoHeightText) {
374
- options.selectedElementHeight.value = `${newH.toFixed(1)}px`
395
+ if (options.selectedElementHeight) {
396
+ if (!isAutoHeightText) {
397
+ options.selectedElementHeight.value = `${newH.toFixed(1)}px`
398
+ } else {
399
+ const dom = document.getElementById(`canvas-el-${item.id}`)
400
+ if (dom && dom.offsetHeight > 0) options.selectedElementHeight.value = `${dom.offsetHeight}px`
401
+ }
375
402
  }
376
403
  }
377
404
 
@@ -253,8 +253,19 @@ export function useSidebarElementTransform(
253
253
  const elementW = computed({
254
254
  get() {
255
255
  if (!selectedElement.value) return 0
256
- const wStr = selectedElement.value.style?.width || '100px'
257
- if (wStr === 'auto') return 200
256
+ const isVerticalText = selectedElement.value.type === 'text' && !selectedElement.value.latex && (selectedElement.value.style?.writingMode === 'vertical-rl' || selectedElement.value.style?.writingMode === 'vertical-lr')
257
+ const wStr = selectedElement.value.style?.width || ''
258
+ if (isVerticalText && (selectedElement.value.autoFit?.type === 'shape' || !wStr || wStr === 'auto')) {
259
+ const editableDom = document.getElementById(`editable-${selectedElement.value.id}`)
260
+ const dom = document.getElementById(`canvas-el-${selectedElement.value.id}`)
261
+ const actualW = Math.max(editableDom?.scrollWidth || 0, dom?.offsetWidth || 0)
262
+ if (actualW > 0) return parseFloat(actualW.toFixed(1))
263
+ }
264
+ if (!wStr || wStr === 'auto') {
265
+ const dom = document.getElementById(`canvas-el-${selectedElement.value.id}`)
266
+ if (dom && dom.offsetWidth > 0) return parseFloat(dom.offsetWidth.toFixed(1))
267
+ return selectedElement.value.width || 200
268
+ }
258
269
  if (wStr.endsWith('%')) {
259
270
  const refW = getParentDimensions(selectedElement.value).width
260
271
  return parseFloat(((parseFloat(wStr) / 100) * refW).toFixed(1))
@@ -267,6 +278,10 @@ export function useSidebarElementTransform(
267
278
  activeSlide.value.elements.forEach((el: any) => {
268
279
  if (selectedElementIds.value.includes(el.id)) {
269
280
  if (!el.style) el.style = {}
281
+ const isVert = el.type === 'text' && !el.latex && (el.style?.writingMode === 'vertical-rl' || el.style?.writingMode === 'vertical-lr')
282
+ if (isVert && el.autoFit?.type === 'shape') {
283
+ el.autoFit = { ...el.autoFit, type: 'none' }
284
+ }
270
285
  const wStr = el.style.width || '100px'
271
286
  const refDims = getParentDimensions(el)
272
287
  let elOldW = 0
@@ -277,7 +292,7 @@ export function useSidebarElementTransform(
277
292
  elOldW = parseFloat(wStr) || 0
278
293
  el.style.width = `${val}px`
279
294
  }
280
- if (typeof el.width === 'number') el.width = val
295
+ el.width = val
281
296
  if (el.fixedRatio && elOldW > 0) {
282
297
  const hStr = el.style.height || '100px'
283
298
  let elOldH = 0
@@ -293,7 +308,7 @@ export function useSidebarElementTransform(
293
308
  } else {
294
309
  el.style.height = `${newH}px`
295
310
  }
296
- if (typeof el.height === 'number') el.height = newH
311
+ el.height = newH
297
312
  }
298
313
  if (el.type === 'shape' && el.pathFormula) {
299
314
  const formulaObj = shapeFormulas()[el.pathFormula]
@@ -308,31 +323,36 @@ export function useSidebarElementTransform(
308
323
  }
309
324
  })
310
325
  } else {
326
+ const el = selectedElement.value
327
+ const isVert = el.type === 'text' && !el.latex && (el.style?.writingMode === 'vertical-rl' || el.style?.writingMode === 'vertical-lr')
328
+ if (isVert && el.autoFit?.type === 'shape') {
329
+ el.autoFit = { ...el.autoFit, type: 'none' }
330
+ }
311
331
  const oldW = elementW.value
312
- const refDims = getParentDimensions(selectedElement.value)
313
- const wStr = selectedElement.value.style?.width || '100px'
332
+ const refDims = getParentDimensions(el)
333
+ const wStr = el.style?.width || '100px'
314
334
  if (wStr.endsWith('%')) {
315
- selectedElement.value.style.width = `${((val / refDims.width) * 100).toFixed(4)}%`
335
+ el.style.width = `${((val / refDims.width) * 100).toFixed(4)}%`
316
336
  } else {
317
- selectedElement.value.style.width = `${val}px`
337
+ el.style.width = `${val}px`
318
338
  }
319
- if (typeof selectedElement.value.width === 'number') selectedElement.value.width = val
339
+ el.width = val
320
340
  let newH = elementH.value
321
- if ((selectedElement.value as any).fixedRatio && oldW > 0) {
341
+ if ((el as any).fixedRatio && oldW > 0) {
322
342
  const ratio = elementH.value / oldW
323
343
  newH = parseFloat((val * ratio).toFixed(1))
324
- const hStr = selectedElement.value.style?.height || '100px'
344
+ const hStr = el.style?.height || '100px'
325
345
  if (hStr.endsWith('%')) {
326
- selectedElement.value.style.height = `${((newH / refDims.height) * 100).toFixed(4)}%`
346
+ el.style.height = `${((newH / refDims.height) * 100).toFixed(4)}%`
327
347
  } else {
328
- selectedElement.value.style.height = `${newH}px`
348
+ el.style.height = `${newH}px`
329
349
  }
330
- if (typeof selectedElement.value.height === 'number') selectedElement.value.height = newH
350
+ el.height = newH
331
351
  }
332
- if (selectedElement.value.type === 'group' && Array.isArray(selectedElement.value.elements) && oldW > 0) {
352
+ if (el.type === 'group' && Array.isArray(el.elements) && oldW > 0) {
333
353
  const scaleX = val / oldW
334
- const scaleY = (selectedElement.value as any).fixedRatio && elementH.value > 0 ? newH / elementH.value : 1
335
- selectedElement.value.elements.forEach((child: any) => {
354
+ const scaleY = (el as any).fixedRatio && elementH.value > 0 ? newH / elementH.value : 1
355
+ el.elements.forEach((child: any) => {
336
356
  if (child.style) {
337
357
  if (typeof child.style.left === 'string' && child.style.left.endsWith('px')) {
338
358
  child.style.left = `${(parseFloat(child.style.left) * scaleX).toFixed(1)}px`
@@ -351,14 +371,14 @@ export function useSidebarElementTransform(
351
371
  }
352
372
  })
353
373
  }
354
- if (selectedElement.value.type === 'shape' && selectedElement.value.pathFormula) {
355
- const formulaObj = shapeFormulas()[selectedElement.value.pathFormula]
374
+ if (el.type === 'shape' && el.pathFormula) {
375
+ const formulaObj = shapeFormulas()[el.pathFormula]
356
376
  if (formulaObj) {
357
- const logicalW = parseFloat(selectedElement.value.style.width) || val
358
- const logicalH = parseFloat(selectedElement.value.style.height) || 120
359
- selectedElement.value.viewBox = [logicalW, logicalH]
360
- selectedElement.value.content = formulaObj.formula(logicalW, logicalH, selectedElement.value.keypoints)
361
- selectedElement.value.path = selectedElement.value.content
377
+ const logicalW = parseFloat(el.style.width) || val
378
+ const logicalH = parseFloat(el.style.height) || 120
379
+ el.viewBox = [logicalW, logicalH]
380
+ el.content = formulaObj.formula(logicalW, logicalH, el.keypoints)
381
+ el.path = el.content
362
382
  }
363
383
  }
364
384
  }
@@ -370,35 +390,39 @@ export function useSidebarElementTransform(
370
390
  const elementH = computed({
371
391
  get() {
372
392
  if (!selectedElement.value) return 0
373
- if (selectedElement.value.type === 'text' && !selectedElement.value.latex && selectedElement.value.style?.writingMode !== 'vertical-rl' && selectedElement.value.style?.writingMode !== 'vertical-lr') {
374
- const editableDom = document.getElementById(`editable-${selectedElement.value.id}`) || document.getElementById(`canvas-el-${selectedElement.value.id}`)
393
+ const el = selectedElement.value
394
+ if (el.type === 'text' && el.content?.includes('<table')) {
395
+ const editableDom = document.getElementById(`editable-${el.id}`) || document.getElementById(`canvas-el-${el.id}`)
375
396
  const tableEl = editableDom?.querySelector('table')
376
397
  if (tableEl && tableEl.offsetHeight > 0) {
377
398
  return parseFloat(tableEl.offsetHeight.toFixed(1))
378
399
  }
379
- const dom = document.getElementById(`canvas-el-${selectedElement.value.id}`)
400
+ }
401
+ const hStr = el.style?.height || ''
402
+ const isHorizText = el.type === 'text' && !el.latex && !el.content?.includes('<table') && el.style?.writingMode !== 'vertical-rl' && el.style?.writingMode !== 'vertical-lr'
403
+ if ((isHorizText && el.autoFit?.type === 'shape') || !hStr || hStr === 'auto') {
404
+ const dom = document.getElementById(`canvas-el-${el.id}`)
380
405
  if (dom && dom.offsetHeight > 0) {
381
406
  return parseFloat(dom.offsetHeight.toFixed(1))
382
407
  }
408
+ return el.height || 60
383
409
  }
384
- const hStr = selectedElement.value.style?.height || '100px'
385
- if (hStr === 'auto') return 60
386
410
  if (hStr.endsWith('%')) {
387
- const refH = getParentDimensions(selectedElement.value).height
411
+ const refH = getParentDimensions(el).height
388
412
  return parseFloat(((parseFloat(hStr) / 100) * refH).toFixed(1))
389
413
  }
390
- return parseFloat(parseFloat(hStr).toFixed(1)) || (selectedElement.value.height || 0)
414
+ return parseFloat(parseFloat(hStr).toFixed(1)) || (el.height || 0)
391
415
  },
392
416
  set(val: number) {
393
417
  if (!selectedElement.value) return
394
- // If single text element is selected, height is auto-computed by text content, do not allow manual change
395
- if (selectedElementIds.value.length <= 1 && selectedElement.value.type === 'text' && !selectedElement.value.content?.includes('<table') && !selectedElement.value.latex) {
396
- return
397
- }
398
418
  if (selectedElementIds.value.length > 1 && activeSlide.value) {
399
419
  activeSlide.value.elements.forEach((el: any) => {
400
420
  if (selectedElementIds.value.includes(el.id)) {
401
421
  if (!el.style) el.style = {}
422
+ const isHoriz = el.type === 'text' && !el.latex && !el.content?.includes('<table') && el.style?.writingMode !== 'vertical-rl' && el.style?.writingMode !== 'vertical-lr'
423
+ if (isHoriz && el.autoFit?.type === 'shape') {
424
+ el.autoFit = { ...el.autoFit, type: 'none' }
425
+ }
402
426
  const hStr = el.style.height || '100px'
403
427
  const refDims = getParentDimensions(el)
404
428
  let elOldH = 0
@@ -409,7 +433,7 @@ export function useSidebarElementTransform(
409
433
  elOldH = parseFloat(hStr) || 0
410
434
  el.style.height = `${val}px`
411
435
  }
412
- if (typeof el.height === 'number') el.height = val
436
+ el.height = val
413
437
  if (el.fixedRatio && elOldH > 0) {
414
438
  const wStr = el.style.width || '100px'
415
439
  let elOldW = 0
@@ -425,7 +449,7 @@ export function useSidebarElementTransform(
425
449
  } else {
426
450
  el.style.width = `${newW}px`
427
451
  }
428
- if (typeof el.width === 'number') el.width = newW
452
+ el.width = newW
429
453
  }
430
454
  if (el.type === 'shape' && el.pathFormula) {
431
455
  const formulaObj = shapeFormulas()[el.pathFormula]
@@ -440,31 +464,36 @@ export function useSidebarElementTransform(
440
464
  }
441
465
  })
442
466
  } else {
467
+ const el = selectedElement.value
468
+ const isHoriz = el.type === 'text' && !el.latex && !el.content?.includes('<table') && el.style?.writingMode !== 'vertical-rl' && el.style?.writingMode !== 'vertical-lr'
469
+ if (isHoriz && el.autoFit?.type === 'shape') {
470
+ el.autoFit = { ...el.autoFit, type: 'none' }
471
+ }
443
472
  const oldH = elementH.value
444
- const refDims = getParentDimensions(selectedElement.value)
445
- const hStr = selectedElement.value.style?.height || '100px'
473
+ const refDims = getParentDimensions(el)
474
+ const hStr = el.style?.height || '100px'
446
475
  if (hStr.endsWith('%')) {
447
- selectedElement.value.style.height = `${((val / refDims.height) * 100).toFixed(4)}%`
476
+ el.style.height = `${((val / refDims.height) * 100).toFixed(4)}%`
448
477
  } else {
449
- selectedElement.value.style.height = `${val}px`
478
+ el.style.height = `${val}px`
450
479
  }
451
- if (typeof selectedElement.value.height === 'number') selectedElement.value.height = val
480
+ el.height = val
452
481
  let newW = elementW.value
453
- if ((selectedElement.value as any).fixedRatio && oldH > 0) {
482
+ if ((el as any).fixedRatio && oldH > 0) {
454
483
  const ratio = elementW.value / oldH
455
484
  newW = parseFloat((val * ratio).toFixed(1))
456
- const wStr = selectedElement.value.style?.width || '100px'
485
+ const wStr = el.style?.width || '100px'
457
486
  if (wStr.endsWith('%')) {
458
- selectedElement.value.style.width = `${((newW / refDims.width) * 100).toFixed(4)}%`
487
+ el.style.width = `${((newW / refDims.width) * 100).toFixed(4)}%`
459
488
  } else {
460
- selectedElement.value.style.width = `${newW}px`
489
+ el.style.width = `${newW}px`
461
490
  }
462
- if (typeof selectedElement.value.width === 'number') selectedElement.value.width = newW
491
+ el.width = newW
463
492
  }
464
- if (selectedElement.value.type === 'group' && Array.isArray(selectedElement.value.elements) && oldH > 0) {
493
+ if (el.type === 'group' && Array.isArray(el.elements) && oldH > 0) {
465
494
  const scaleY = val / oldH
466
- const scaleX = (selectedElement.value as any).fixedRatio && elementW.value > 0 ? newW / elementW.value : 1
467
- selectedElement.value.elements.forEach((child: any) => {
495
+ const scaleX = (el as any).fixedRatio && elementW.value > 0 ? newW / elementW.value : 1
496
+ el.elements.forEach((child: any) => {
468
497
  if (child.style) {
469
498
  if (typeof child.style.top === 'string' && child.style.top.endsWith('px')) {
470
499
  child.style.top = `${(parseFloat(child.style.top) * scaleY).toFixed(1)}px`
@@ -483,14 +512,14 @@ export function useSidebarElementTransform(
483
512
  }
484
513
  })
485
514
  }
486
- if (selectedElement.value.type === 'shape' && selectedElement.value.pathFormula) {
487
- const formulaObj = shapeFormulas()[selectedElement.value.pathFormula]
515
+ if (el.type === 'shape' && el.pathFormula) {
516
+ const formulaObj = shapeFormulas()[el.pathFormula]
488
517
  if (formulaObj) {
489
- const logicalW = parseFloat(selectedElement.value.style.width) || 120
490
- const logicalH = parseFloat(selectedElement.value.style.height) || val
491
- selectedElement.value.viewBox = [logicalW, logicalH]
492
- selectedElement.value.content = formulaObj.formula(logicalW, logicalH, selectedElement.value.keypoints)
493
- selectedElement.value.path = selectedElement.value.content
518
+ const logicalW = parseFloat(el.style.width) || 120
519
+ const logicalH = parseFloat(el.style.height) || val
520
+ el.viewBox = [logicalW, logicalH]
521
+ el.content = formulaObj.formula(logicalW, logicalH, el.keypoints)
522
+ el.path = el.content
494
523
  }
495
524
  }
496
525
  }