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.
- package/README.md +152 -0
- package/dist/lib/jvs-ppt-ui.es.js +23678 -21439
- package/dist/lib/jvs-ppt-ui.umd.js +136 -100
- package/dist/lib/style.css +1 -1
- package/package.json +2 -1
- package/src/components/CanvasArea.vue +77 -35
- package/src/components/Header.vue +184 -26
- package/src/components/PitchImportDialog.vue +29 -6
- package/src/components/PptEditor.vue +53 -1
- package/src/components/QuickColorPopover.vue +2 -1
- package/src/components/SidebarLeft.vue +367 -41
- package/src/components/SidebarRight.vue +183 -134
- package/src/components/canvas/CanvasTransformHandles.vue +27 -36
- package/src/components/canvas/elements/CanvasMediaElement.vue +4 -3
- package/src/components/canvas/elements/CanvasShapeElement.vue +9 -6
- package/src/components/sidebar/panels/LayoutThumbSvg.vue +9 -6
- 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 +93 -28
- package/src/configs/slideTemplates.ts +1001 -0
- package/src/style.css +265 -2
- package/src/types/index.ts +37 -1
- package/src/utils/canvas/elementStyles.ts +55 -20
- package/src/utils/canvas/formatPainter.ts +177 -30
- package/src/utils/muxHlsToMp4.ts +569 -0
- package/src/utils/pitchConverter.ts +512 -13
- package/dist/lib/templates/index.json +0 -5
|
@@ -145,6 +145,129 @@ export function getFormatFromElement(el: any): ElementFormat | null {
|
|
|
145
145
|
return cleaned
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
export function isTransparentTextBg(val: any): boolean {
|
|
149
|
+
if (!val || typeof val !== 'string') return true
|
|
150
|
+
const s = val.trim().toLowerCase()
|
|
151
|
+
if (s === 'transparent' || s === 'none' || s === 'initial' || s === 'inherit') return true
|
|
152
|
+
if (/^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*0(?:\.0+)?\s*\)$/.test(s)) return true
|
|
153
|
+
if (/^#[0-9a-f]{6}00$/.test(s) || /^#[0-9a-f]{3}0$/.test(s)) return true
|
|
154
|
+
return false
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Apply or clear text highlight color on a specific DOM Range inside an editable container.
|
|
159
|
+
* Returns the updated Range (if still valid) so callers can preserve selection.
|
|
160
|
+
*/
|
|
161
|
+
export function applyOrClearRangeHighlight(
|
|
162
|
+
container: HTMLElement,
|
|
163
|
+
range: Range,
|
|
164
|
+
color: string,
|
|
165
|
+
el?: any
|
|
166
|
+
): Range | null {
|
|
167
|
+
const isClear = isTransparentTextBg(color)
|
|
168
|
+
const prevEditable = container.getAttribute('contenteditable')
|
|
169
|
+
if (prevEditable !== 'true') {
|
|
170
|
+
container.setAttribute('contenteditable', 'true')
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
// If element had a whole-box style.textBackground that wasn't materialized into inline spans yet,
|
|
175
|
+
// materialize it first before clearing a partial selection, then clear style.textBackground.
|
|
176
|
+
if (isClear && el?.style?.textBackground && !isTransparentTextBg(el.style.textBackground)) {
|
|
177
|
+
if (!container.innerHTML.includes('background-color')) {
|
|
178
|
+
container.innerHTML = applyTextStyleToHtml(container.innerHTML, { textBackground: el.style.textBackground })
|
|
179
|
+
}
|
|
180
|
+
el.style.textBackground = 'transparent'
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const selectedTxt = (range.toString() || '').replace(/\s+/g, '')
|
|
184
|
+
const totalTxt = (container.textContent || '').replace(/\s+/g, '')
|
|
185
|
+
|
|
186
|
+
// If clearing and the selection covers all text in the container, strip all inline text background-color cleanly
|
|
187
|
+
const tableCellTags = new Set(['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR', 'TD', 'TH', 'COL', 'COLGROUP'])
|
|
188
|
+
if (isClear && selectedTxt.length > 0 && selectedTxt.length >= totalTxt.length) {
|
|
189
|
+
container.querySelectorAll('*').forEach((node: any) => {
|
|
190
|
+
if (node.style && !tableCellTags.has(node.tagName)) {
|
|
191
|
+
node.style.backgroundColor = ''
|
|
192
|
+
node.style.removeProperty('background-color')
|
|
193
|
+
node.style.background = ''
|
|
194
|
+
node.style.removeProperty('background')
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
if (el?.style) {
|
|
198
|
+
el.style.textBackground = 'transparent'
|
|
199
|
+
}
|
|
200
|
+
const sel = window.getSelection()
|
|
201
|
+
if (sel && container.contains(range.commonAncestorContainer)) {
|
|
202
|
+
sel.removeAllRanges()
|
|
203
|
+
sel.addRange(range)
|
|
204
|
+
return sel.rangeCount > 0 ? sel.getRangeAt(0).cloneRange() : null
|
|
205
|
+
}
|
|
206
|
+
return null
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const sel = window.getSelection()
|
|
210
|
+
if (!sel) return null
|
|
211
|
+
|
|
212
|
+
if (document.activeElement !== container && !container.contains(document.activeElement)) {
|
|
213
|
+
container.focus({ preventScroll: true })
|
|
214
|
+
}
|
|
215
|
+
sel.removeAllRanges()
|
|
216
|
+
sel.addRange(range)
|
|
217
|
+
|
|
218
|
+
const hiliteCmd = document.queryCommandSupported('hiliteColor') ? 'hiliteColor' : 'backColor'
|
|
219
|
+
if (isClear) {
|
|
220
|
+
// Use a sentinel opaque color first so Blink splits any parent <span style="background-color: ...">
|
|
221
|
+
const sentinelHex = '#010203'
|
|
222
|
+
const executed = document.execCommand(hiliteCmd, false, sentinelHex)
|
|
223
|
+
if (!executed && hiliteCmd !== 'backColor') {
|
|
224
|
+
document.execCommand('backColor', false, sentinelHex)
|
|
225
|
+
}
|
|
226
|
+
container.querySelectorAll('*').forEach((node: any) => {
|
|
227
|
+
if (node.style) {
|
|
228
|
+
const bg = (node.style.backgroundColor || '').toLowerCase().replace(/\s+/g, '')
|
|
229
|
+
if (bg === 'rgb(1,2,3)' || bg === '#010203' || bg === 'transparent' || bg === 'rgba(0,0,0,0)') {
|
|
230
|
+
node.style.backgroundColor = ''
|
|
231
|
+
node.style.removeProperty('background-color')
|
|
232
|
+
node.style.background = ''
|
|
233
|
+
node.style.removeProperty('background')
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
} else {
|
|
238
|
+
const executed = document.execCommand(hiliteCmd, false, color)
|
|
239
|
+
if (!executed && hiliteCmd !== 'backColor') {
|
|
240
|
+
document.execCommand('backColor', false, color)
|
|
241
|
+
}
|
|
242
|
+
if (sel.rangeCount > 0) {
|
|
243
|
+
const newRange = sel.getRangeAt(0)
|
|
244
|
+
container.querySelectorAll('span, font, mark, b, strong, i, em, u, s, a').forEach((node: any) => {
|
|
245
|
+
if (newRange.intersectsNode(node) && newRange.isPointInRange(node, 0) && node.style?.backgroundColor) {
|
|
246
|
+
node.style.backgroundColor = color
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Ensure block elements inside container never keep a full-line background color
|
|
253
|
+
container.querySelectorAll('p, div, li, h1, h2, h3, h4, h5, h6, ul, ol').forEach((block: any) => {
|
|
254
|
+
if (block.style) {
|
|
255
|
+
block.style.backgroundColor = ''
|
|
256
|
+
block.style.removeProperty('background-color')
|
|
257
|
+
block.style.background = ''
|
|
258
|
+
block.style.removeProperty('background')
|
|
259
|
+
}
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
return sel.rangeCount > 0 ? sel.getRangeAt(0).cloneRange() : null
|
|
263
|
+
} finally {
|
|
264
|
+
if (prevEditable !== 'true') {
|
|
265
|
+
if (prevEditable === null) container.removeAttribute('contenteditable')
|
|
266
|
+
else container.setAttribute('contenteditable', prevEditable)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
148
271
|
/**
|
|
149
272
|
* Apply typography styles directly to an HTML string.
|
|
150
273
|
*/
|
|
@@ -154,54 +277,78 @@ export function applyTextStyleToHtml(html: string, styles: ElementFormat): strin
|
|
|
154
277
|
div.innerHTML = html
|
|
155
278
|
|
|
156
279
|
// 1. 保证所有块级元素(p, div, li 等)背景色透明,绝不被整行涂满
|
|
157
|
-
div.querySelectorAll('p, div, li, h1, h2, h3, h4, h5, h6').forEach((block: any) => {
|
|
280
|
+
div.querySelectorAll('p, div, li, h1, h2, h3, h4, h5, h6, ul, ol').forEach((block: any) => {
|
|
158
281
|
block.style.backgroundColor = ''
|
|
159
282
|
block.style.removeProperty('background-color')
|
|
283
|
+
block.style.background = ''
|
|
284
|
+
block.style.removeProperty('background')
|
|
160
285
|
})
|
|
161
286
|
|
|
162
287
|
// 2. 处理文字高亮背景色 textBackground
|
|
163
288
|
if (styles.textBackground !== undefined) {
|
|
164
|
-
const isClear = styles.textBackground
|
|
289
|
+
const isClear = isTransparentTextBg(styles.textBackground)
|
|
165
290
|
const bgVal = isClear ? '' : styles.textBackground
|
|
166
291
|
|
|
167
|
-
const existingSpans = div.querySelectorAll('span')
|
|
168
292
|
if (isClear) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
293
|
+
const tableCellTags = new Set(['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR', 'TD', 'TH', 'COL', 'COLGROUP'])
|
|
294
|
+
div.querySelectorAll('*').forEach((elem: any) => {
|
|
295
|
+
if (elem.style && !tableCellTags.has(elem.tagName)) {
|
|
296
|
+
elem.style.backgroundColor = ''
|
|
297
|
+
elem.style.removeProperty('background-color')
|
|
298
|
+
elem.style.background = ''
|
|
299
|
+
elem.style.removeProperty('background')
|
|
300
|
+
}
|
|
301
|
+
if (elem.tagName === 'MARK' && elem.parentNode) {
|
|
302
|
+
while (elem.firstChild) {
|
|
303
|
+
elem.parentNode.insertBefore(elem.firstChild, elem)
|
|
304
|
+
}
|
|
305
|
+
elem.parentNode.removeChild(elem)
|
|
306
|
+
}
|
|
172
307
|
})
|
|
173
308
|
} else {
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
309
|
+
const leafBlocks = Array.from(
|
|
310
|
+
div.querySelectorAll('p, div, li, h1, h2, h3, h4, h5, h6, td, th')
|
|
311
|
+
).filter((b: Element) => !b.querySelector('p, div, li, h1, h2, h3, h4, h5, h6, ul, ol, table')) as HTMLElement[]
|
|
312
|
+
|
|
313
|
+
const applyBgToBlock = (block: HTMLElement) => {
|
|
314
|
+
const textContent = (block.textContent || '').replace(/\u200B/g, '').trim()
|
|
315
|
+
if (!textContent) return
|
|
316
|
+
|
|
317
|
+
// Clear any inner background overrides first so we have a clean uniform highlight
|
|
318
|
+
block.querySelectorAll('*').forEach((child: any) => {
|
|
319
|
+
if (child.style) {
|
|
320
|
+
child.style.backgroundColor = ''
|
|
321
|
+
child.style.removeProperty('background-color')
|
|
322
|
+
child.style.background = ''
|
|
323
|
+
child.style.removeProperty('background')
|
|
189
324
|
}
|
|
190
325
|
})
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
326
|
+
|
|
327
|
+
// If block already has a single SPAN element covering all non-empty children, apply to it directly
|
|
328
|
+
const nonEmptyNodes = Array.from(block.childNodes).filter(
|
|
329
|
+
n => !(n.nodeType === Node.TEXT_NODE && !(n.textContent || '').trim())
|
|
330
|
+
)
|
|
331
|
+
if (
|
|
332
|
+
nonEmptyNodes.length === 1 &&
|
|
333
|
+
nonEmptyNodes[0].nodeType === Node.ELEMENT_NODE &&
|
|
334
|
+
(nonEmptyNodes[0] as HTMLElement).tagName === 'SPAN'
|
|
335
|
+
) {
|
|
336
|
+
;(nonEmptyNodes[0] as HTMLElement).style.backgroundColor = bgVal
|
|
337
|
+
} else if (block.childNodes.length > 0) {
|
|
197
338
|
const span = document.createElement('span')
|
|
198
339
|
span.style.backgroundColor = bgVal
|
|
199
|
-
while (
|
|
200
|
-
span.appendChild(
|
|
340
|
+
while (block.firstChild) {
|
|
341
|
+
span.appendChild(block.firstChild)
|
|
201
342
|
}
|
|
202
|
-
|
|
343
|
+
block.appendChild(span)
|
|
203
344
|
}
|
|
204
345
|
}
|
|
346
|
+
|
|
347
|
+
if (leafBlocks.length > 0) {
|
|
348
|
+
leafBlocks.forEach(applyBgToBlock)
|
|
349
|
+
} else {
|
|
350
|
+
applyBgToBlock(div)
|
|
351
|
+
}
|
|
205
352
|
}
|
|
206
353
|
}
|
|
207
354
|
|