jvs-ppt-ui 0.0.33 → 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.
- package/dist/lib/jvs-ppt-ui.es.js +19275 -19015
- package/dist/lib/jvs-ppt-ui.umd.js +112 -112
- package/dist/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/components/CanvasArea.vue +77 -35
- package/src/components/QuickColorPopover.vue +2 -1
- package/src/components/SidebarRight.vue +183 -134
- package/src/components/canvas/CanvasTransformHandles.vue +27 -36
- package/src/components/canvas/elements/CanvasShapeElement.vue +3 -2
- package/src/components/sidebar/panels/SidebarShapeFormatPanel.vue +1 -1
- package/src/components/sidebar/panels/SidebarTextFormatPanel.vue +1 -1
- package/src/composables/canvas/useCanvasFormatting.ts +20 -13
- package/src/composables/canvas/useCanvasText.ts +4 -3
- package/src/composables/canvas/useCanvasTransform.ts +37 -10
- package/src/composables/sidebar/useSidebarElementTransform.ts +86 -57
- package/src/composables/sidebar/useSidebarTextFormat.ts +242 -19
- package/src/composables/useSlides.ts +7 -7
- package/src/utils/canvas/formatPainter.ts +177 -30
|
@@ -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
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
|
172
|
-
<
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
|
183
|
-
<
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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'))"
|
|
@@ -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
|
|
357
|
+
if (el.style?.textBackground && !isTransparentTextBg(el.style.textBackground)) {
|
|
357
358
|
if (!norm.includes('background-color')) {
|
|
358
|
-
return
|
|
359
|
+
return applyTextStyleToHtml(norm, { textBackground: el.style.textBackground })
|
|
359
360
|
}
|
|
360
361
|
}
|
|
361
362
|
return norm
|
|
@@ -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'"
|
|
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: '
|
|
81
|
+
styleAutoFitType: 'none',
|
|
82
82
|
styleWordWrap: true,
|
|
83
83
|
paddingTop: 4.8,
|
|
84
84
|
paddingRight: 9.6,
|
|
@@ -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 =
|
|
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:
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
591
|
+
cell.style.backgroundColor = normalizedBg === 'transparent' ? '' : normalizedBg
|
|
584
592
|
})
|
|
585
593
|
el.content = div.innerHTML
|
|
586
594
|
}
|
|
587
595
|
} else {
|
|
588
|
-
el.content = applyTextStyleToHtml(
|
|
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
|
-
|
|
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 || '
|
|
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 =
|
|
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
|
|
307
|
-
const
|
|
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
|
-
|
|
364
|
+
item.width = newW
|
|
348
365
|
}
|
|
349
366
|
if (!isAutoHeightText) {
|
|
350
|
-
|
|
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
|
|
371
|
-
|
|
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
|
|
374
|
-
|
|
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
|
|
257
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
313
|
-
const wStr =
|
|
332
|
+
const refDims = getParentDimensions(el)
|
|
333
|
+
const wStr = el.style?.width || '100px'
|
|
314
334
|
if (wStr.endsWith('%')) {
|
|
315
|
-
|
|
335
|
+
el.style.width = `${((val / refDims.width) * 100).toFixed(4)}%`
|
|
316
336
|
} else {
|
|
317
|
-
|
|
337
|
+
el.style.width = `${val}px`
|
|
318
338
|
}
|
|
319
|
-
|
|
339
|
+
el.width = val
|
|
320
340
|
let newH = elementH.value
|
|
321
|
-
if ((
|
|
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 =
|
|
344
|
+
const hStr = el.style?.height || '100px'
|
|
325
345
|
if (hStr.endsWith('%')) {
|
|
326
|
-
|
|
346
|
+
el.style.height = `${((newH / refDims.height) * 100).toFixed(4)}%`
|
|
327
347
|
} else {
|
|
328
|
-
|
|
348
|
+
el.style.height = `${newH}px`
|
|
329
349
|
}
|
|
330
|
-
|
|
350
|
+
el.height = newH
|
|
331
351
|
}
|
|
332
|
-
if (
|
|
352
|
+
if (el.type === 'group' && Array.isArray(el.elements) && oldW > 0) {
|
|
333
353
|
const scaleX = val / oldW
|
|
334
|
-
const scaleY = (
|
|
335
|
-
|
|
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 (
|
|
355
|
-
const formulaObj = shapeFormulas()[
|
|
374
|
+
if (el.type === 'shape' && el.pathFormula) {
|
|
375
|
+
const formulaObj = shapeFormulas()[el.pathFormula]
|
|
356
376
|
if (formulaObj) {
|
|
357
|
-
const logicalW = parseFloat(
|
|
358
|
-
const logicalH = parseFloat(
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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
|
-
|
|
374
|
-
|
|
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
|
-
|
|
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(
|
|
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)) || (
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
445
|
-
const hStr =
|
|
473
|
+
const refDims = getParentDimensions(el)
|
|
474
|
+
const hStr = el.style?.height || '100px'
|
|
446
475
|
if (hStr.endsWith('%')) {
|
|
447
|
-
|
|
476
|
+
el.style.height = `${((val / refDims.height) * 100).toFixed(4)}%`
|
|
448
477
|
} else {
|
|
449
|
-
|
|
478
|
+
el.style.height = `${val}px`
|
|
450
479
|
}
|
|
451
|
-
|
|
480
|
+
el.height = val
|
|
452
481
|
let newW = elementW.value
|
|
453
|
-
if ((
|
|
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 =
|
|
485
|
+
const wStr = el.style?.width || '100px'
|
|
457
486
|
if (wStr.endsWith('%')) {
|
|
458
|
-
|
|
487
|
+
el.style.width = `${((newW / refDims.width) * 100).toFixed(4)}%`
|
|
459
488
|
} else {
|
|
460
|
-
|
|
489
|
+
el.style.width = `${newW}px`
|
|
461
490
|
}
|
|
462
|
-
|
|
491
|
+
el.width = newW
|
|
463
492
|
}
|
|
464
|
-
if (
|
|
493
|
+
if (el.type === 'group' && Array.isArray(el.elements) && oldH > 0) {
|
|
465
494
|
const scaleY = val / oldH
|
|
466
|
-
const scaleX = (
|
|
467
|
-
|
|
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 (
|
|
487
|
-
const formulaObj = shapeFormulas()[
|
|
515
|
+
if (el.type === 'shape' && el.pathFormula) {
|
|
516
|
+
const formulaObj = shapeFormulas()[el.pathFormula]
|
|
488
517
|
if (formulaObj) {
|
|
489
|
-
const logicalW = parseFloat(
|
|
490
|
-
const logicalH = parseFloat(
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
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
|
}
|