jvs-ppt-ui 0.0.33 → 0.0.35
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 +20752 -20255
- package/dist/lib/jvs-ppt-ui.umd.js +115 -116
- package/dist/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/components/CanvasArea.vue +85 -37
- package/src/components/PresentationGroupChild.vue +11 -1
- package/src/components/PresentationMode.vue +10 -1
- package/src/components/QuickColorPopover.vue +2 -1
- package/src/components/SidebarLeft.vue +3354 -3212
- 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/canvas/elements/CanvasTextElement.vue +4 -0
- package/src/components/sidebar/panels/LayoutThumbSvg.vue +130 -57
- package/src/components/sidebar/panels/SidebarDesignPanel.vue +7 -14
- package/src/components/sidebar/panels/SidebarShapeFormatPanel.vue +1 -1
- package/src/components/sidebar/panels/SidebarTextFormatPanel.vue +1 -1
- package/src/composables/canvas/useCanvasContextMenu.ts +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/useSidebarDesign.ts +2 -1
- package/src/composables/sidebar/useSidebarElementTransform.ts +87 -58
- package/src/composables/sidebar/useSidebarTextFormat.ts +242 -19
- package/src/composables/useSlides.ts +228 -62
- package/src/configs/slideTemplates.ts +7 -3
- package/src/style.css +3 -3
- package/src/utils/canvas/elementStyles.ts +11 -1
- package/src/utils/canvas/formatPainter.ts +177 -30
|
@@ -3,6 +3,7 @@ import { computed } from 'vue'
|
|
|
3
3
|
import { useSlides } from '../../../composables/useSlides'
|
|
4
4
|
import { SHAPE_LIST, type ShapePoolItem } from '../../../utils/shapes'
|
|
5
5
|
import {
|
|
6
|
+
getElementPattern,
|
|
6
7
|
getElementGradientConfig,
|
|
7
8
|
getElementBorderGradientConfig,
|
|
8
9
|
hasElementBorderGradient,
|
|
@@ -21,6 +22,7 @@ const props = defineProps<{
|
|
|
21
22
|
}>()
|
|
22
23
|
|
|
23
24
|
const { logicalWidth, logicalHeight } = useSlides()
|
|
25
|
+
const instanceUid = Math.random().toString(36).slice(2, 8)
|
|
24
26
|
|
|
25
27
|
const flatShapePoolItems: ShapePoolItem[] = SHAPE_LIST.flatMap(c => c.children)
|
|
26
28
|
|
|
@@ -131,8 +133,12 @@ function getLayoutSvgElements(elements: any[]) {
|
|
|
131
133
|
(typeof el.id === 'string' && (el.id.startsWith('ph_title') || el.id.startsWith('ph_body') || el.id.startsWith('ph_subtitle') || el.id.startsWith('ph_0_') || el.id.startsWith('ph_1_') || el.id.startsWith('ph-')))
|
|
132
134
|
)
|
|
133
135
|
)
|
|
134
|
-
const cleanContent = (
|
|
135
|
-
|
|
136
|
+
const cleanContent = (el.type !== 'shape' && typeof el.content === 'string')
|
|
137
|
+
? el.content.replace(/<[^>]*>/g, '').replace(/ /gi, ' ').trim()
|
|
138
|
+
: ''
|
|
139
|
+
const cleanTextProp = (typeof el.text === 'string')
|
|
140
|
+
? el.text.replace(/<[^>]*>/g, '').replace(/ /gi, ' ').trim()
|
|
141
|
+
: (el.text?.content ? String(el.text.content).replace(/<[^>]*>/g, '').replace(/ /gi, ' ').trim() : '')
|
|
136
142
|
const phPrompt = el.placeholder?.prompt || (el.placeholder?.type === 'title' ? '单击此处编辑母版标题样式' : (el.placeholder?.type === 'subtitle' ? '单击此处编辑母版副标题样式' : (el.placeholder?.type === 'image' ? '单击图标添加图片' : '单击此处添加文本描述')))
|
|
137
143
|
|
|
138
144
|
// 如果 content 含有真实有效文字,使用 content;如果是占位符且无自定义文字,使用占位符 prompt 提示
|
|
@@ -142,7 +148,7 @@ function getLayoutSvgElements(elements: any[]) {
|
|
|
142
148
|
? (typeof el.text === 'string' ? el.text : el.text.content)
|
|
143
149
|
: (isPlaceholder
|
|
144
150
|
? phPrompt
|
|
145
|
-
: (typeof el.content === 'string' ? el.content : '')))
|
|
151
|
+
: (el.type !== 'shape' && typeof el.content === 'string' ? el.content : '')))
|
|
146
152
|
|
|
147
153
|
const writingMode = el.style?.writingMode || el.writingMode || ''
|
|
148
154
|
const isVertical = Boolean(
|
|
@@ -152,11 +158,16 @@ function getLayoutSvgElements(elements: any[]) {
|
|
|
152
158
|
rawContentStr.includes('writing-mode:vertical')
|
|
153
159
|
)
|
|
154
160
|
|
|
161
|
+
const fontSize = parseFloat(el.style?.fontSize || el.fontSize || (isPlaceholder ? (el.placeholder?.type === 'title' ? '28' : '16') : '16')) || 16
|
|
162
|
+
|
|
155
163
|
const defaultWidthFallback = isVertical ? ((60 / baseW) * 100) : 0
|
|
164
|
+
const defaultHeightFallback = ((fontSize * 1.25) / baseH) * 100
|
|
165
|
+
const rawWVal = (el.style?.width && el.style.width !== 'auto') ? el.style.width : el.width
|
|
166
|
+
const rawHVal = (el.style?.height && el.style.height !== 'auto') ? el.style.height : (el.height && el.height !== 'auto' ? el.height : undefined)
|
|
156
167
|
const rawLeft = parseDimValue(el.style?.left ?? el.left, baseW)
|
|
157
168
|
const rawTop = parseDimValue(el.style?.top ?? el.top, baseH)
|
|
158
|
-
const rawWidth = parseDimValue(
|
|
159
|
-
const rawHeight = parseDimValue(
|
|
169
|
+
const rawWidth = parseDimValue(rawWVal, baseW, defaultWidthFallback)
|
|
170
|
+
const rawHeight = parseDimValue(rawHVal, baseH, defaultHeightFallback)
|
|
160
171
|
|
|
161
172
|
const leftPct = parentLeftPct + (rawLeft * parentWidthPct / 100)
|
|
162
173
|
const topPct = parentTopPct + (rawTop * parentHeightPct / 100)
|
|
@@ -179,12 +190,12 @@ function getLayoutSvgElements(elements: any[]) {
|
|
|
179
190
|
? `translate(${cx}, ${cy}) rotate(${rotate}) scale(${flipH ? -1 : 1}, ${flipV ? -1 : 1}) translate(${-cx}, ${-cy})`
|
|
180
191
|
: undefined
|
|
181
192
|
|
|
182
|
-
const fontSize = parseFloat(el.style?.fontSize || el.fontSize || (isPlaceholder ? (el.placeholder?.type === 'title' ? '28' : '16') : '16')) || 16
|
|
183
|
-
|
|
184
193
|
// 缩略图字体按画布宽高真实几何比例计算,配合微缩优化保持和谐可辨识
|
|
185
194
|
const baseRatio = 100 / baseW
|
|
186
195
|
const rawSvgSize = fontSize * baseRatio
|
|
187
|
-
const svgFontSize =
|
|
196
|
+
const svgFontSize = isPlaceholder
|
|
197
|
+
? +(Math.max(1.8, Math.min(4.5, rawSvgSize * 1.15))).toFixed(2)
|
|
198
|
+
: +(Math.max(1.4, Math.min(14, rawSvgSize))).toFixed(2)
|
|
188
199
|
|
|
189
200
|
const rawSegments: { text: string; indent: number }[] = []
|
|
190
201
|
if (rawContentStr) {
|
|
@@ -217,19 +228,19 @@ function getLayoutSvgElements(elements: any[]) {
|
|
|
217
228
|
const availableW = Math.max(0.5, w - (isPlaceholder ? 0.6 : 0.4))
|
|
218
229
|
const maxWeight = Math.max(1, availableW / (svgFontSize * 0.9))
|
|
219
230
|
const canMultiLine = h >= svgFontSize * 1.6
|
|
220
|
-
const maxLines = Math.
|
|
231
|
+
const maxLines = Math.min(6, Math.max(rawSegments.length || 1, Math.floor(h / (svgFontSize * 1.1))))
|
|
221
232
|
|
|
222
|
-
rawSegments.forEach(({ text, indent }) => {
|
|
223
|
-
if (!isVertical && canMultiLine && text.length > maxWeight) {
|
|
233
|
+
rawSegments.forEach(({ text, indent }, segIdx) => {
|
|
234
|
+
if (!isVertical && canMultiLine && text.length > maxWeight && parsedTextLines.length + (rawSegments.length - segIdx) < maxLines) {
|
|
224
235
|
let curLine = ''
|
|
225
236
|
let curW = 0
|
|
226
237
|
for (let i = 0; i < text.length; i++) {
|
|
227
238
|
const ch = text[i]
|
|
228
239
|
const isFull = /[\u4e00-\u9fa5\u3000-\u303f\uff01-\uff5e]/.test(ch)
|
|
229
240
|
const weight = isFull ? 1.0 : 0.55
|
|
230
|
-
|
|
241
|
+
const canWrapMore = parsedTextLines.length + (rawSegments.length - segIdx) < maxLines
|
|
242
|
+
if (canWrapMore && curW + weight > maxWeight && curLine.length > 0) {
|
|
231
243
|
parsedTextLines.push({ text: curLine, indent })
|
|
232
|
-
if (parsedTextLines.length >= maxLines) break
|
|
233
244
|
curLine = ch
|
|
234
245
|
curW = weight
|
|
235
246
|
} else {
|
|
@@ -240,27 +251,30 @@ function getLayoutSvgElements(elements: any[]) {
|
|
|
240
251
|
if (curLine && parsedTextLines.length < maxLines) {
|
|
241
252
|
parsedTextLines.push({ text: curLine, indent })
|
|
242
253
|
}
|
|
243
|
-
} else {
|
|
254
|
+
} else if (parsedTextLines.length < maxLines) {
|
|
244
255
|
parsedTextLines.push({ text, indent })
|
|
245
256
|
}
|
|
246
257
|
})
|
|
247
258
|
|
|
248
259
|
const cleanText = parsedTextLines.length > 0 ? parsedTextLines[0].text : ''
|
|
249
|
-
const lineHeight = +(svgFontSize * 1.25).toFixed(2)
|
|
260
|
+
const lineHeight = +(svgFontSize * (fontSize >= 72 ? 1.05 : 1.25)).toFixed(2)
|
|
250
261
|
const lineCount = Math.min(parsedTextLines.length, 6)
|
|
251
262
|
const totalTextH = lineCount * lineHeight
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
263
|
+
const vAlign = el.verticalAlign || el.style?.verticalAlign || 'top'
|
|
264
|
+
let textStartY = +(y + svgFontSize * 0.95).toFixed(2)
|
|
265
|
+
if (h > totalTextH) {
|
|
266
|
+
if (vAlign === 'bottom' || vAlign === 'down') {
|
|
267
|
+
textStartY = +(y + h - totalTextH + svgFontSize * 0.85).toFixed(2)
|
|
268
|
+
} else if (vAlign !== 'top' && vAlign !== 'up') {
|
|
269
|
+
// 垂直居中起始 y 坐标
|
|
270
|
+
textStartY = +(y + (h - totalTextH) / 2 + svgFontSize * 0.85).toFixed(2)
|
|
271
|
+
}
|
|
256
272
|
}
|
|
257
273
|
|
|
258
274
|
const isTitle = el.type === 'text' && (el.name?.includes('标题') || el.placeholder?.type === 'title' || fontSize >= 24)
|
|
259
275
|
const isText = el.type === 'text'
|
|
260
276
|
|
|
261
|
-
const color = isPlaceholder
|
|
262
|
-
? (isTitle ? '#0f172a' : '#64748b')
|
|
263
|
-
: parseColorString(el.style?.color || el.color, isTitle ? '#0f172a' : '#334155')
|
|
277
|
+
const color = parseColorString(el.style?.color || el.color, isPlaceholder ? (isTitle ? '#0f172a' : '#64748b') : (isTitle ? '#0f172a' : '#334155'))
|
|
264
278
|
const rawFillVal = (el.style && el.style.fill !== undefined) ? el.style.fill : el.fill
|
|
265
279
|
let fill = 'none'
|
|
266
280
|
if (rawFillVal !== undefined && rawFillVal !== null) {
|
|
@@ -277,10 +291,16 @@ function getLayoutSvgElements(elements: any[]) {
|
|
|
277
291
|
}
|
|
278
292
|
|
|
279
293
|
const borderStyle = el.style?.borderStyle || el.borderStyle || 'none'
|
|
280
|
-
const borderWidth =
|
|
281
|
-
const hasBorderGrad = hasElementBorderGradient(el)
|
|
294
|
+
const borderWidth = el.style?.enableBorder === false ? 0 : getElementBorderWidth(el)
|
|
295
|
+
const hasBorderGrad = el.style?.enableBorder === false ? false : hasElementBorderGradient(el)
|
|
282
296
|
const borderColor = (!hasBorderGrad && borderWidth <= 0) ? 'none' : (getElementBorderColor(el) || parseColorString(el.style?.borderColor || el.borderColor, 'none'))
|
|
283
|
-
const
|
|
297
|
+
const rawOpacity = el.style?.opacity !== undefined ? parseFloat(el.style.opacity) : (el.opacity !== undefined ? parseFloat(el.opacity) : 1)
|
|
298
|
+
const opacity = isNaN(rawOpacity) ? 1 : rawOpacity
|
|
299
|
+
const inlineAlignMatch = rawContentStr ? rawContentStr.match(/text-align:\s*(left|center|right)/i) : null
|
|
300
|
+
const textAlign = el.style?.textAlign || el.textAlign || (inlineAlignMatch ? inlineAlignMatch[1].toLowerCase() : (el.type === 'shape' ? 'center' : (isTitle && !isVertical && isPlaceholder ? 'center' : 'left')))
|
|
301
|
+
const pattern = getElementPattern(el)
|
|
302
|
+
const rawBr = parseFloat(el.style?.borderRadius || el.borderRadius || 0) || 0
|
|
303
|
+
const rx = rawBr > 0 ? +((rawBr / baseW) * 100).toFixed(2) : (el.type === 'shape' ? 0.8 : 0)
|
|
284
304
|
|
|
285
305
|
let shapePath = ''
|
|
286
306
|
let shapeViewBox: [number, number] = [200, 200]
|
|
@@ -326,8 +346,11 @@ function getLayoutSvgElements(elements: any[]) {
|
|
|
326
346
|
|
|
327
347
|
let linePath = ''
|
|
328
348
|
let lineColor = '#475569'
|
|
329
|
-
let strokeWidth =
|
|
349
|
+
let strokeWidth = +(1.5 * baseRatio).toFixed(2)
|
|
330
350
|
let strokeDashArray: string | undefined = undefined
|
|
351
|
+
const svgBorderWidth = (hasBorderGrad || borderWidth > 0)
|
|
352
|
+
? Math.max(0.12, +((borderWidth || 1) * baseRatio).toFixed(2))
|
|
353
|
+
: 0
|
|
331
354
|
|
|
332
355
|
if (el.type === 'line') {
|
|
333
356
|
lineColor = parseColorString(
|
|
@@ -335,11 +358,11 @@ function getLayoutSvgElements(elements: any[]) {
|
|
|
335
358
|
'#334155'
|
|
336
359
|
)
|
|
337
360
|
const rawStrokeWidth = parseFloat(el.style?.strokeWidth || el.strokeWidth || el.style?.borderWidth || el.borderWidth || 1) || 1
|
|
338
|
-
strokeWidth = Math.
|
|
361
|
+
strokeWidth = Math.max(0.12, +(rawStrokeWidth * baseRatio).toFixed(2))
|
|
339
362
|
if (el.lineStyle === 'dashed' || el.style?.borderStyle === 'dashed' || (el as any).borderType === 'dashed') {
|
|
340
|
-
strokeDashArray =
|
|
363
|
+
strokeDashArray = `${+(strokeWidth * 4).toFixed(2)} ${+(strokeWidth * 3).toFixed(2)}`
|
|
341
364
|
} else if (el.lineStyle === 'dotted' || el.style?.borderStyle === 'dotted' || (el as any).borderType === 'dotted') {
|
|
342
|
-
strokeDashArray =
|
|
365
|
+
strokeDashArray = `${strokeWidth} ${+(strokeWidth * 2).toFixed(2)}`
|
|
343
366
|
}
|
|
344
367
|
|
|
345
368
|
const rawPath = getLineElementRenderPath(el) || getLineElementPath(el) || ''
|
|
@@ -359,6 +382,8 @@ function getLayoutSvgElements(elements: any[]) {
|
|
|
359
382
|
return {
|
|
360
383
|
id: el.id,
|
|
361
384
|
rawEl: el,
|
|
385
|
+
pattern,
|
|
386
|
+
rx,
|
|
362
387
|
gradient,
|
|
363
388
|
borderGradient,
|
|
364
389
|
isCircle,
|
|
@@ -380,9 +405,11 @@ function getLayoutSvgElements(elements: any[]) {
|
|
|
380
405
|
yCenter: +(y + h * 0.5).toFixed(2),
|
|
381
406
|
color,
|
|
382
407
|
fill,
|
|
408
|
+
opacity,
|
|
383
409
|
borderColor,
|
|
384
410
|
borderStyle,
|
|
385
411
|
borderWidth,
|
|
412
|
+
svgBorderWidth,
|
|
386
413
|
isPlaceholder,
|
|
387
414
|
textAlign,
|
|
388
415
|
svgFontSize,
|
|
@@ -425,11 +452,24 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
|
|
|
425
452
|
<template>
|
|
426
453
|
<svg :viewBox="`0 0 100 ${thumbSvgHeight}`" preserveAspectRatio="none" class="layout-svg" :style="{ width: '100%', height: '100%', display: 'block', background: getSlideBackgroundCss(background || '#ffffff') }">
|
|
427
454
|
<defs>
|
|
428
|
-
<template v-for="item in svgItems" :key="`layout-
|
|
455
|
+
<template v-for="item in svgItems" :key="`layout-defs-${item.id}`">
|
|
456
|
+
<pattern
|
|
457
|
+
v-if="item.pattern"
|
|
458
|
+
:id="`layout-pat-${instanceUid}-${item.id}`"
|
|
459
|
+
width="100%"
|
|
460
|
+
height="100%"
|
|
461
|
+
patternUnits="objectBoundingBox"
|
|
462
|
+
patternContentUnits="objectBoundingBox"
|
|
463
|
+
>
|
|
464
|
+
<image :href="item.pattern" width="1" height="1" preserveAspectRatio="none" />
|
|
465
|
+
</pattern>
|
|
466
|
+
<clipPath v-if="item.isImage && item.imageSrc && item.rx > 0" :id="`layout-img-clip-${instanceUid}-${item.id}`">
|
|
467
|
+
<rect :x="item.x" :y="item.y" :width="item.w" :height="item.h" :rx="item.rx" />
|
|
468
|
+
</clipPath>
|
|
429
469
|
<template v-if="item.gradient">
|
|
430
470
|
<radialGradient
|
|
431
471
|
v-if="item.gradient.path && item.gradient.path !== 'line'"
|
|
432
|
-
:id="`layout-grad-${item.id}`"
|
|
472
|
+
:id="`layout-grad-${instanceUid}-${item.id}`"
|
|
433
473
|
:cx="`${item.gradient.center ? Math.round(item.gradient.center.x * 100) : 50}%`"
|
|
434
474
|
:cy="`${item.gradient.center ? Math.round(item.gradient.center.y * 100) : 50}%`"
|
|
435
475
|
:r="item.gradient.path === 'rect' ? '60%' : (item.gradient.path === 'shape' || item.gradient.path === 'path' ? '70%' : '50%')"
|
|
@@ -446,7 +486,7 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
|
|
|
446
486
|
</radialGradient>
|
|
447
487
|
<linearGradient
|
|
448
488
|
v-else
|
|
449
|
-
:id="`layout-grad-${item.id}`"
|
|
489
|
+
:id="`layout-grad-${instanceUid}-${item.id}`"
|
|
450
490
|
:x1="getSvgGradientCoords(item.rawEl).x1"
|
|
451
491
|
:y1="getSvgGradientCoords(item.rawEl).y1"
|
|
452
492
|
:x2="getSvgGradientCoords(item.rawEl).x2"
|
|
@@ -464,7 +504,7 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
|
|
|
464
504
|
<template v-if="item.borderGradient">
|
|
465
505
|
<radialGradient
|
|
466
506
|
v-if="item.borderGradient.path && item.borderGradient.path !== 'line'"
|
|
467
|
-
:id="`layout-bgrad-${item.id}`"
|
|
507
|
+
:id="`layout-bgrad-${instanceUid}-${item.id}`"
|
|
468
508
|
:cx="`${item.borderGradient.center ? Math.round(item.borderGradient.center.x * 100) : 50}%`"
|
|
469
509
|
:cy="`${item.borderGradient.center ? Math.round(item.borderGradient.center.y * 100) : 50}%`"
|
|
470
510
|
:r="item.borderGradient.path === 'rect' ? '60%' : (item.borderGradient.path === 'shape' || item.borderGradient.path === 'path' ? '70%' : '50%')"
|
|
@@ -481,7 +521,7 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
|
|
|
481
521
|
</radialGradient>
|
|
482
522
|
<linearGradient
|
|
483
523
|
v-else
|
|
484
|
-
:id="`layout-bgrad-${item.id}`"
|
|
524
|
+
:id="`layout-bgrad-${instanceUid}-${item.id}`"
|
|
485
525
|
:x1="getSvgGradientCoords(item.borderGradient).x1"
|
|
486
526
|
:y1="getSvgGradientCoords(item.borderGradient).y1"
|
|
487
527
|
:x2="getSvgGradientCoords(item.borderGradient).x2"
|
|
@@ -500,12 +540,12 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
|
|
|
500
540
|
</defs>
|
|
501
541
|
<template v-if="svgItems && svgItems.length > 0">
|
|
502
542
|
<template v-for="item in svgItems" :key="item.id">
|
|
503
|
-
<g v-if="item.isImage && item.imageSrc" :transform="item.transform">
|
|
543
|
+
<g v-if="item.isImage && item.imageSrc" :transform="item.transform" :opacity="item.opacity !== undefined && item.opacity < 1 ? item.opacity : undefined" :clip-path="item.rx > 0 ? `url(#layout-img-clip-${instanceUid}-${item.id})` : undefined">
|
|
504
544
|
<svg :x="item.x" :y="item.y" :width="item.w" :height="item.h" :viewBox="item.clipViewBox || '0 0 100 100'" preserveAspectRatio="none" style="overflow: hidden;">
|
|
505
545
|
<image :href="item.imageSrc" x="0" y="0" width="100" height="100" preserveAspectRatio="none" />
|
|
506
546
|
</svg>
|
|
507
547
|
</g>
|
|
508
|
-
<g v-else-if="item.isImagePlaceholder" :transform="item.transform">
|
|
548
|
+
<g v-else-if="item.isImagePlaceholder" :transform="item.transform" :opacity="item.opacity !== undefined && item.opacity < 1 ? item.opacity : undefined">
|
|
509
549
|
<rect :x="item.x" :y="item.y" :width="item.w" :height="item.h" fill="#d9dde3" rx="1.2" />
|
|
510
550
|
<svg :x="item.cx - 2.2" :y="item.cy - 2.2" width="4.4" height="4.4" viewBox="0 0 24 24" fill="none">
|
|
511
551
|
<rect x="3" y="3" width="18" height="18" rx="2" stroke="#475569" stroke-width="2" />
|
|
@@ -513,28 +553,61 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
|
|
|
513
553
|
<path d="M21 15l-5-5L5 21" stroke="#475569" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
|
514
554
|
</svg>
|
|
515
555
|
</g>
|
|
516
|
-
<g v-else-if="item.type === 'shape' && item.shapePath" :transform="item.transform">
|
|
556
|
+
<g v-else-if="item.type === 'shape' && item.shapePath" :transform="item.transform" :opacity="item.opacity !== undefined && item.opacity < 1 ? item.opacity : undefined">
|
|
517
557
|
<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;">
|
|
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.
|
|
558
|
+
<path :d="item.shapePath" :fill="item.pattern ? `url(#layout-pat-${instanceUid}-${item.id})` : (item.gradient ? `url(#layout-grad-${instanceUid}-${item.id})` : (item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getHexColorWithoutAlpha(item.fill) : 'none'))" :fill-opacity="!item.pattern && !item.gradient && item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getAlphaFromColor(item.fill) : undefined" :stroke="item.borderGradient ? `url(#layout-bgrad-${instanceUid}-${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.max(0.5, +((item.borderWidth || 1) * 0.25).toFixed(2)) : 0" :stroke-linecap="item.lineCap" vector-effect="non-scaling-stroke" />
|
|
519
559
|
</svg>
|
|
560
|
+
<text
|
|
561
|
+
v-if="item.cleanText"
|
|
562
|
+
:x="item.x + item.w * 0.5"
|
|
563
|
+
:y="item.y + item.h * 0.5 + item.svgFontSize * 0.35"
|
|
564
|
+
text-anchor="middle"
|
|
565
|
+
:fill="item.color || '#ffffff'"
|
|
566
|
+
:font-size="item.svgFontSize"
|
|
567
|
+
font-family="sans-serif"
|
|
568
|
+
font-weight="bold"
|
|
569
|
+
style="pointer-events: none; user-select: none;"
|
|
570
|
+
>{{ item.cleanText.length > 20 ? item.cleanText.substring(0, 20) + '...' : item.cleanText }}</text>
|
|
520
571
|
</g>
|
|
521
|
-
<g v-else-if="item.type === 'shape' && item.isCircle" :transform="item.transform">
|
|
572
|
+
<g v-else-if="item.type === 'shape' && item.isCircle" :transform="item.transform" :opacity="item.opacity !== undefined && item.opacity < 1 ? item.opacity : undefined">
|
|
522
573
|
<ellipse
|
|
523
574
|
:cx="item.x + item.w / 2"
|
|
524
575
|
:cy="item.y + item.h / 2"
|
|
525
576
|
:rx="item.w / 2"
|
|
526
577
|
:ry="item.h / 2"
|
|
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')"
|
|
578
|
+
:fill="item.pattern ? `url(#layout-pat-${instanceUid}-${item.id})` : (item.gradient ? `url(#layout-grad-${instanceUid}-${item.id})` : (item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getHexColorWithoutAlpha(item.fill) : 'none'))"
|
|
579
|
+
:fill-opacity="!item.pattern && !item.gradient && item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getAlphaFromColor(item.fill) : undefined"
|
|
580
|
+
:stroke="item.borderGradient ? `url(#layout-bgrad-${instanceUid}-${item.id})` : (item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getHexColorWithoutAlpha(item.borderColor) : 'none')"
|
|
530
581
|
:stroke-opacity="!item.borderGradient && item.borderWidth > 0 && item.borderColor && item.borderColor !== 'transparent' && item.borderColor !== 'none' ? getAlphaFromColor(item.borderColor) : undefined"
|
|
531
|
-
:stroke-width="
|
|
582
|
+
:stroke-width="item.svgBorderWidth"
|
|
532
583
|
/>
|
|
584
|
+
<text
|
|
585
|
+
v-if="item.cleanText"
|
|
586
|
+
:x="item.x + item.w * 0.5"
|
|
587
|
+
:y="item.y + item.h * 0.5 + item.svgFontSize * 0.35"
|
|
588
|
+
text-anchor="middle"
|
|
589
|
+
:fill="item.color || '#ffffff'"
|
|
590
|
+
:font-size="item.svgFontSize"
|
|
591
|
+
font-family="sans-serif"
|
|
592
|
+
font-weight="bold"
|
|
593
|
+
style="pointer-events: none; user-select: none;"
|
|
594
|
+
>{{ item.cleanText.length > 20 ? item.cleanText.substring(0, 20) + '...' : item.cleanText }}</text>
|
|
533
595
|
</g>
|
|
534
|
-
<g v-else-if="item.type === 'shape'" :transform="item.transform">
|
|
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="
|
|
596
|
+
<g v-else-if="item.type === 'shape'" :transform="item.transform" :opacity="item.opacity !== undefined && item.opacity < 1 ? item.opacity : undefined">
|
|
597
|
+
<rect :x="item.x" :y="item.y" :width="item.w" :height="item.h" :fill="item.pattern ? `url(#layout-pat-${instanceUid}-${item.id})` : (item.gradient ? `url(#layout-grad-${instanceUid}-${item.id})` : (item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getHexColorWithoutAlpha(item.fill) : 'none'))" :fill-opacity="!item.pattern && !item.gradient && item.fill && item.fill !== 'transparent' && item.fill !== 'none' ? getAlphaFromColor(item.fill) : undefined" :stroke="item.borderGradient ? `url(#layout-bgrad-${instanceUid}-${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.svgBorderWidth" :rx="item.rx" />
|
|
598
|
+
<text
|
|
599
|
+
v-if="item.cleanText"
|
|
600
|
+
:x="item.x + item.w * 0.5"
|
|
601
|
+
:y="item.y + item.h * 0.5 + item.svgFontSize * 0.35"
|
|
602
|
+
text-anchor="middle"
|
|
603
|
+
:fill="item.color || '#ffffff'"
|
|
604
|
+
:font-size="item.svgFontSize"
|
|
605
|
+
font-family="sans-serif"
|
|
606
|
+
font-weight="bold"
|
|
607
|
+
style="pointer-events: none; user-select: none;"
|
|
608
|
+
>{{ item.cleanText.length > 20 ? item.cleanText.substring(0, 20) + '...' : item.cleanText }}</text>
|
|
536
609
|
</g>
|
|
537
|
-
<g v-else-if="item.type === 'title' || item.type === 'text'" :transform="item.transform">
|
|
610
|
+
<g v-else-if="item.type === 'title' || item.type === 'text'" :transform="item.transform" :opacity="item.opacity !== undefined && item.opacity < 1 ? item.opacity : undefined">
|
|
538
611
|
<rect
|
|
539
612
|
v-if="item.isPlaceholder || (item.fill && item.fill !== 'none' && item.fill !== 'transparent') || (!item.isPlaceholder && item.borderColor && item.borderColor !== 'none' && item.borderColor !== 'transparent' && item.borderWidth && Number(item.borderWidth) > 0)"
|
|
540
613
|
:x="item.x"
|
|
@@ -542,8 +615,8 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
|
|
|
542
615
|
:width="item.w"
|
|
543
616
|
:height="item.h"
|
|
544
617
|
:fill="item.fill && item.fill !== 'none' && item.fill !== 'transparent' ? item.fill : 'none'"
|
|
545
|
-
:stroke="item.isPlaceholder ? '#
|
|
546
|
-
:stroke-dasharray="
|
|
618
|
+
:stroke="item.isPlaceholder ? (item.borderColor && item.borderColor !== 'none' ? item.borderColor : '#cbd5e1') : (item.borderColor && item.borderColor !== 'none' ? item.borderColor : 'none')"
|
|
619
|
+
:stroke-dasharray="item.isPlaceholder || item.borderStyle === 'dashed' ? '1.2 1.2' : undefined"
|
|
547
620
|
:stroke-width="item.isPlaceholder ? '0.4' : '0.8'"
|
|
548
621
|
rx="0.8"
|
|
549
622
|
/>
|
|
@@ -553,13 +626,13 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
|
|
|
553
626
|
:key="lIdx"
|
|
554
627
|
:x="item.isVertical
|
|
555
628
|
? (item.x + item.w * 0.5)
|
|
556
|
-
: (item.textAlign === 'center' || item.w < 15
|
|
629
|
+
: (item.textAlign === 'center' || (item.isPlaceholder && item.w < 15)
|
|
557
630
|
? (item.x + item.w * 0.5)
|
|
558
631
|
: (item.textAlign === 'right'
|
|
559
|
-
? (item.x + item.w - 1)
|
|
560
|
-
: (item.x + (lineObj.indent || 0) * 2.5 + 1)))"
|
|
632
|
+
? (item.x + item.w - (item.isPlaceholder ? 1 : 0))
|
|
633
|
+
: (item.x + (lineObj.indent || 0) * 2.5 + (item.isPlaceholder ? 1 : 0))))"
|
|
561
634
|
:y="item.textStartY + lIdx * item.lineHeight"
|
|
562
|
-
:text-anchor="item.isVertical ? 'middle' : (item.textAlign === 'center' || item.w < 15 ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
|
|
635
|
+
:text-anchor="item.isVertical ? 'middle' : (item.textAlign === 'center' || (item.isPlaceholder && item.w < 15) ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
|
|
563
636
|
:fill="item.color || (item.isTitle ? '#0f172a' : '#64748b')"
|
|
564
637
|
:font-size="item.svgFontSize"
|
|
565
638
|
font-family="sans-serif"
|
|
@@ -571,15 +644,15 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
|
|
|
571
644
|
<text
|
|
572
645
|
:x="item.isVertical
|
|
573
646
|
? item.x + item.w * 0.5
|
|
574
|
-
: (item.textAlign === 'center' || item.w < 15
|
|
647
|
+
: (item.textAlign === 'center' || (item.isPlaceholder && item.w < 15)
|
|
575
648
|
? item.x + item.w * 0.5
|
|
576
649
|
: (item.textAlign === 'right'
|
|
577
|
-
? item.x + item.w - 1
|
|
578
|
-
: item.x + 1))"
|
|
650
|
+
? item.x + item.w - (item.isPlaceholder ? 1 : 0)
|
|
651
|
+
: item.x + (item.isPlaceholder ? 1 : 0)))"
|
|
579
652
|
:y="item.isVertical
|
|
580
653
|
? item.y + item.svgFontSize * 1.2
|
|
581
654
|
: (item.textStartY || Math.min(thumbSvgHeight - 1, item.y + item.h * 0.5 + item.svgFontSize * 0.35))"
|
|
582
|
-
:text-anchor="item.isVertical ? 'middle' : (item.textAlign === 'center' || item.w < 15 ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
|
|
655
|
+
:text-anchor="item.isVertical ? 'middle' : (item.textAlign === 'center' || (item.isPlaceholder && item.w < 15) ? 'middle' : (item.textAlign === 'right' ? 'end' : 'start'))"
|
|
583
656
|
:fill="item.color || (item.isTitle ? '#0f172a' : '#64748b')"
|
|
584
657
|
:font-size="item.svgFontSize"
|
|
585
658
|
font-family="sans-serif"
|
|
@@ -591,7 +664,7 @@ const svgItems = computed(() => getLayoutSvgElements(deduplicateElements(props.e
|
|
|
591
664
|
<line v-else-if="!item.isPlaceholder && item.type === 'title'" :x1="item.textAlign === 'center' ? (item.x + item.w * 0.15) : item.x" :y1="item.yCenter" :x2="item.textAlign === 'center' ? (item.x + item.w * 0.85) : (item.x + item.w * 0.8)" :y2="item.yCenter" :stroke="item.color || '#3b82f6'" stroke-width="2" stroke-linecap="round" />
|
|
592
665
|
<line v-else-if="!item.isPlaceholder" :x1="item.x" :y1="item.yCenter" :x2="item.x + item.w" :y2="item.yCenter" :stroke="item.color || '#64748b'" stroke-width="1.2" stroke-linecap="round" />
|
|
593
666
|
</g>
|
|
594
|
-
<g v-else-if="item.type === 'line'" :transform="item.transform">
|
|
667
|
+
<g v-else-if="item.type === 'line'" :transform="item.transform" :opacity="item.opacity !== undefined && item.opacity < 1 ? item.opacity : undefined">
|
|
595
668
|
<g :transform="`translate(${item.x}, ${item.y})`">
|
|
596
669
|
<path
|
|
597
670
|
:d="item.linePath"
|
|
@@ -290,11 +290,11 @@ function ensureBgImageSizeLoaded(url: string) {
|
|
|
290
290
|
...bgImageNaturalSizes.value,
|
|
291
291
|
[url]: { w, h }
|
|
292
292
|
}
|
|
293
|
-
//
|
|
293
|
+
// 仅当用户显式在面板上选择了居中/平铺模式 (bgImageMode 已写入 slide) 时,才在图片尺寸加载后回写精确百分比
|
|
294
294
|
const curUrl = extractUrlFromBgCss(activeSlide.value?.background)
|
|
295
|
-
const
|
|
296
|
-
if (activeSlide.value && curUrl === url && (
|
|
297
|
-
const formatted = formatSlideBgImageCss(url,
|
|
295
|
+
const explicitMode = (activeSlide.value as any)?.bgImageMode
|
|
296
|
+
if (activeSlide.value && curUrl === url && (explicitMode === 'cover' || explicitMode === 'tile')) {
|
|
297
|
+
const formatted = formatSlideBgImageCss(url, explicitMode)
|
|
298
298
|
if (activeSlide.value.background !== formatted) {
|
|
299
299
|
activeSlide.value.background = formatted
|
|
300
300
|
}
|
|
@@ -687,15 +687,8 @@ watch(
|
|
|
687
687
|
const effectiveType = activeSlide.value?.bgType || (bg ? normalizeSlideBackground(bg).bgType : 'color')
|
|
688
688
|
if (effectiveType === 'image' || (typeof bg === 'string' && bg.includes('url('))) {
|
|
689
689
|
const url = extractUrlFromBgCss(bg)
|
|
690
|
-
if (url && !url.startsWith('data:image/svg+xml')
|
|
691
|
-
; (activeSlide.value as any)._lastBgImageUrl = url
|
|
690
|
+
if (url && !url.startsWith('data:image/svg+xml')) {
|
|
692
691
|
ensureBgImageSizeLoaded(url)
|
|
693
|
-
if (!(activeSlide.value as any)?.isPattern) {
|
|
694
|
-
const formatted = formatSlideBgImageCss(url, bgImageMode.value)
|
|
695
|
-
if (typeof bg === 'string' && bg !== formatted) {
|
|
696
|
-
activeSlide.value.background = formatted
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
692
|
}
|
|
700
693
|
if ((typeof bg === 'string' && bg.includes('data:image/svg+xml')) || (activeSlide.value as any)?.isPattern) {
|
|
701
694
|
activeBgTab.value = 'pattern'
|
|
@@ -1304,8 +1297,8 @@ watch(extractTab, () => {
|
|
|
1304
1297
|
<!-- Card Header: Title + More Actions Menu -->
|
|
1305
1298
|
<div class="theme-card-header">
|
|
1306
1299
|
<span class="theme-name-text">{{ recipe.name }}</span>
|
|
1307
|
-
<el-popover trigger="click" placement="
|
|
1308
|
-
:offset="
|
|
1300
|
+
<el-popover trigger="click" placement="bottom-end" popper-class="theme-actions-popper" :width="156"
|
|
1301
|
+
:offset="4" :show-arrow="false" :teleported="true">
|
|
1309
1302
|
<template #reference>
|
|
1310
1303
|
<button class="theme-more-btn" @click.stop title="更多选项">
|
|
1311
1304
|
<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor">
|
|
@@ -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
|