jvs-ppt-ui 0.0.38 → 0.0.39
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 +20611 -20292
- package/dist/lib/jvs-ppt-ui.umd.js +112 -112
- package/dist/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/App.vue +7 -5
- package/src/components/CanvasArea.vue +263 -45
- package/src/components/Header.vue +2 -4
- package/src/components/PptEditor.vue +97 -5
- package/src/components/canvas/elements/CanvasGroupElement.vue +3 -0
- package/src/components/canvas/elements/CanvasTextElement.vue +1 -1
- package/src/composables/canvas/useCanvasText.ts +27 -8
- package/src/composables/useSlides.ts +6 -4
- package/src/index.ts +8 -1
- package/src/style.css +1 -1
- package/src/types/index.ts +14 -0
- package/src/utils/canvas/formatPainter.ts +91 -32
- package/src/utils/localDraftStorage.ts +340 -0
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref } from 'vue'
|
|
3
3
|
import PptEditor from './components/PptEditor.vue'
|
|
4
|
+
import { saveMediaBlobToIndexedDB } from './utils/localDraftStorage'
|
|
4
5
|
import type { DeckData, PptEditorApi, UploadResourceContext } from './types'
|
|
5
6
|
|
|
6
7
|
const editorRef = ref<PptEditorApi | null>(null)
|
|
7
8
|
|
|
8
9
|
function handleSave(deck: DeckData) {
|
|
9
10
|
console.log('[JVS-PPT 独立运行模式] 保存幻灯片:', deck)
|
|
11
|
+
editorRef.value?.saveLocalDraft?.()
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
function handleReady(api: PptEditorApi) {
|
|
@@ -27,7 +29,7 @@ async function handleCustomUpload(fileOrBlob: File | Blob, context: UploadResour
|
|
|
27
29
|
})
|
|
28
30
|
|
|
29
31
|
// 1. 模拟网络上传请求耗时
|
|
30
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
32
|
+
await new Promise(resolve => setTimeout(resolve, 100))
|
|
31
33
|
|
|
32
34
|
// 2. 实际业务生产代码范例:
|
|
33
35
|
// const formData = new FormData()
|
|
@@ -36,16 +38,16 @@ async function handleCustomUpload(fileOrBlob: File | Blob, context: UploadResour
|
|
|
36
38
|
// const res = await fetch('/api/oss/upload', { method: 'POST', body: formData }).then(r => r.json())
|
|
37
39
|
// return res.data.url
|
|
38
40
|
|
|
39
|
-
// 3.
|
|
40
|
-
const mockServerUrl =
|
|
41
|
-
console.log(`[模拟上传成功]
|
|
41
|
+
// 3. 独立运行环境:将二进制存入浏览器 IndexedDB 并生成可持久化还原的 URL
|
|
42
|
+
const mockServerUrl = await saveMediaBlobToIndexedDB(fileOrBlob)
|
|
43
|
+
console.log(`[模拟上传成功] 已缓存到 IndexedDB 并返回文件地址:`, mockServerUrl)
|
|
42
44
|
return mockServerUrl
|
|
43
45
|
}
|
|
44
46
|
</script>
|
|
45
47
|
|
|
46
48
|
<template>
|
|
47
49
|
<!-- :custom-upload="handleCustomUpload" -->
|
|
48
|
-
<PptEditor ref="editorRef" :custom-upload="handleCustomUpload" :enable-mcp="true" :enable-ai="
|
|
50
|
+
<PptEditor ref="editorRef" :local-storage-cache="true" :custom-upload="handleCustomUpload" :enable-mcp="true" :enable-ai="false"
|
|
49
51
|
ai-api-url="/jvs-dam/api/ppt/ai-replace" :enable-material="true"
|
|
50
52
|
material-api-url="/jvs-dam/stock/search" material-page-api-url="/jvs-dam/stock/search"
|
|
51
53
|
material-save-api-url="/jvs-dam/api/dam/material/save"
|
|
@@ -1630,7 +1630,9 @@ watch(editingElementId, (newId) => {
|
|
|
1630
1630
|
|
|
1631
1631
|
watch([selectedElementId, isEditingText], () => {
|
|
1632
1632
|
if (!isEditingText.value || !selectedElementId.value) {
|
|
1633
|
-
|
|
1633
|
+
if (!(shapeFormatPainter.value && shapeFormatPainter.value.mode === 'text-range')) {
|
|
1634
|
+
window.getSelection()?.removeAllRanges()
|
|
1635
|
+
}
|
|
1634
1636
|
savedSelectionRange = null
|
|
1635
1637
|
}
|
|
1636
1638
|
selectionVersion.value++
|
|
@@ -1878,6 +1880,56 @@ function restoreSelection() {
|
|
|
1878
1880
|
}
|
|
1879
1881
|
|
|
1880
1882
|
let copyFormatTime = 0
|
|
1883
|
+
let justAppliedFormatPainter = false
|
|
1884
|
+
|
|
1885
|
+
function syncFormattedElementDom(targetEl: any) {
|
|
1886
|
+
if (!targetEl || !targetEl.id || typeof document === 'undefined') return
|
|
1887
|
+
const container = document.getElementById(`editable-${targetEl.id}`)
|
|
1888
|
+
if (container && targetEl.type === 'text' && !targetEl.latex && !targetEl.content?.includes('<table')) {
|
|
1889
|
+
container.innerHTML = getRenderedContent(targetEl)
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
function findFormatPainterTargetNearPoint(clientX: number, clientY: number): any | null {
|
|
1894
|
+
if (!activeSlide.value || !Array.isArray(activeSlide.value.elements) || typeof document === 'undefined') return null
|
|
1895
|
+
const candidates: any[] = []
|
|
1896
|
+
const collectElements = (els: any[]) => {
|
|
1897
|
+
for (let i = els.length - 1; i >= 0; i--) {
|
|
1898
|
+
const item = els[i]
|
|
1899
|
+
if (!item || item.visible === false || item.locked || isLockedMasterElement(item)) continue
|
|
1900
|
+
if (item.type === 'group' && Array.isArray(item.elements)) {
|
|
1901
|
+
collectElements(item.elements)
|
|
1902
|
+
} else {
|
|
1903
|
+
candidates.push(item)
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
collectElements(renderElements.value || activeSlide.value.elements)
|
|
1908
|
+
|
|
1909
|
+
const tolerance = 14
|
|
1910
|
+
let bestEl: any = null
|
|
1911
|
+
let bestDist = Infinity
|
|
1912
|
+
|
|
1913
|
+
for (const item of candidates) {
|
|
1914
|
+
const dom = document.getElementById(`editable-${item.id}`) || document.getElementById(`canvas-el-${item.id}`)
|
|
1915
|
+
if (!dom) continue
|
|
1916
|
+
const rect = dom.getBoundingClientRect()
|
|
1917
|
+
if (rect.width <= 0 || rect.height <= 0) continue
|
|
1918
|
+
|
|
1919
|
+
const dx = clientX < rect.left ? (rect.left - clientX) : (clientX > rect.right ? (clientX - rect.right) : 0)
|
|
1920
|
+
const dy = clientY < rect.top ? (rect.top - clientY) : (clientY > rect.bottom ? (clientY - rect.bottom) : 0)
|
|
1921
|
+
if (dx <= tolerance && dy <= tolerance) {
|
|
1922
|
+
const dist = Math.hypot(dx, dy)
|
|
1923
|
+
if (dist < bestDist) {
|
|
1924
|
+
bestDist = dist
|
|
1925
|
+
bestEl = item
|
|
1926
|
+
if (dist === 0) break
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
return bestEl
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1881
1933
|
function handleGlobalMouseUp(e: MouseEvent) {
|
|
1882
1934
|
if (shapeFormatPainter.value && shapeFormatPainter.value.mode === 'text-range') {
|
|
1883
1935
|
if (Date.now() - copyFormatTime < 250) {
|
|
@@ -1901,16 +1953,45 @@ function handleGlobalMouseUp(e: MouseEvent) {
|
|
|
1901
1953
|
const applied = applyFormatToTextRange(range, shapeFormatPainter.value, container, targetEl)
|
|
1902
1954
|
if (applied) {
|
|
1903
1955
|
sel.removeAllRanges()
|
|
1956
|
+
container.blur()
|
|
1957
|
+
justSelectedElement = true
|
|
1958
|
+
justAppliedFormatPainter = true
|
|
1959
|
+
setTimeout(() => { justAppliedFormatPainter = false }, 50)
|
|
1904
1960
|
if (!shapeFormatPainter.value.__continuous) {
|
|
1905
1961
|
shapeFormatPainter.value = null
|
|
1906
1962
|
}
|
|
1907
1963
|
addHistorySnapshot()
|
|
1908
1964
|
notify('已应用文本格式')
|
|
1965
|
+
return
|
|
1909
1966
|
}
|
|
1910
1967
|
}
|
|
1911
1968
|
}
|
|
1912
1969
|
}
|
|
1913
1970
|
}
|
|
1971
|
+
|
|
1972
|
+
// Fallback: user single-clicked a target element without dragging a range selection
|
|
1973
|
+
const targetNode = e.target as HTMLElement | null
|
|
1974
|
+
if (targetNode && !targetNode.closest?.('.floating-quick-toolbar') && !targetNode.closest?.('.app-toolbar')) {
|
|
1975
|
+
const hitDom = targetNode.closest?.('[id^="canvas-el-"]') as HTMLElement | null
|
|
1976
|
+
const elId = hitDom ? hitDom.id.replace('canvas-el-', '') : ''
|
|
1977
|
+
const targetEl = (elId ? (findElementInSlide(elId) || activeSlide.value?.elements.find((x: any) => x.id === elId)) : null) ||
|
|
1978
|
+
findFormatPainterTargetNearPoint(e.clientX, e.clientY)
|
|
1979
|
+
if (targetEl && !isLockedMasterElement(targetEl) && !targetEl.locked) {
|
|
1980
|
+
applyFormatToElement(targetEl, shapeFormatPainter.value)
|
|
1981
|
+
syncFormattedElementDom(targetEl)
|
|
1982
|
+
sel?.removeAllRanges()
|
|
1983
|
+
const container = document.getElementById(`editable-${targetEl.id}`)
|
|
1984
|
+
if (container) container.blur()
|
|
1985
|
+
justSelectedElement = true
|
|
1986
|
+
justAppliedFormatPainter = true
|
|
1987
|
+
setTimeout(() => { justAppliedFormatPainter = false }, 50)
|
|
1988
|
+
if (!shapeFormatPainter.value.__continuous) {
|
|
1989
|
+
shapeFormatPainter.value = null
|
|
1990
|
+
}
|
|
1991
|
+
addHistorySnapshot()
|
|
1992
|
+
notify('已应用格式')
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1914
1995
|
}
|
|
1915
1996
|
}
|
|
1916
1997
|
|
|
@@ -2106,11 +2187,25 @@ function handleDeselect(e?: MouseEvent) {
|
|
|
2106
2187
|
justSelectedElement = false
|
|
2107
2188
|
return
|
|
2108
2189
|
}
|
|
2190
|
+
const downTarget = lastMouseDownTarget.value
|
|
2191
|
+
if (downTarget) {
|
|
2192
|
+
if (
|
|
2193
|
+
downTarget.closest?.('.canvas-element') ||
|
|
2194
|
+
downTarget.closest?.('.group-child-item') ||
|
|
2195
|
+
downTarget.closest?.('[id^="editable-"]') ||
|
|
2196
|
+
downTarget.closest?.('.global-selection-overlay') ||
|
|
2197
|
+
downTarget.closest?.('.floating-quick-toolbar') ||
|
|
2198
|
+
downTarget.closest?.('.el-popover') ||
|
|
2199
|
+
downTarget.closest?.('.el-popper')
|
|
2200
|
+
) return
|
|
2201
|
+
if (downTarget !== document.documentElement && !document.body.contains(downTarget)) return
|
|
2202
|
+
}
|
|
2109
2203
|
if (e) {
|
|
2110
2204
|
const target = e.target as HTMLElement
|
|
2111
2205
|
if (target) {
|
|
2112
2206
|
if (
|
|
2113
2207
|
target.closest('.canvas-element') ||
|
|
2208
|
+
target.closest('.group-child-item') ||
|
|
2114
2209
|
target.closest('.global-selection-overlay') ||
|
|
2115
2210
|
target.closest('.floating-quick-toolbar') ||
|
|
2116
2211
|
target.closest('.el-popover') ||
|
|
@@ -2718,6 +2813,27 @@ function handleCanvasMouseDown(e: MouseEvent) {
|
|
|
2718
2813
|
}
|
|
2719
2814
|
|
|
2720
2815
|
if (shapeFormatPainter.value) {
|
|
2816
|
+
const nearbyTargetEl = findFormatPainterTargetNearPoint(e.clientX, e.clientY)
|
|
2817
|
+
if (nearbyTargetEl) {
|
|
2818
|
+
if (shapeFormatPainter.value.mode === 'text-range') {
|
|
2819
|
+
justSelectedElement = true
|
|
2820
|
+
return
|
|
2821
|
+
}
|
|
2822
|
+
if (isEditingText.value) {
|
|
2823
|
+
checkAndExitEditText(undefined, true)
|
|
2824
|
+
}
|
|
2825
|
+
applyFormatToElement(nearbyTargetEl, shapeFormatPainter.value)
|
|
2826
|
+
syncFormattedElementDom(nearbyTargetEl)
|
|
2827
|
+
justSelectedElement = true
|
|
2828
|
+
justAppliedFormatPainter = true
|
|
2829
|
+
setTimeout(() => { justAppliedFormatPainter = false }, 50)
|
|
2830
|
+
if (!shapeFormatPainter.value.__continuous) {
|
|
2831
|
+
shapeFormatPainter.value = null
|
|
2832
|
+
}
|
|
2833
|
+
addHistorySnapshot()
|
|
2834
|
+
notify('已应用格式')
|
|
2835
|
+
return
|
|
2836
|
+
}
|
|
2721
2837
|
shapeFormatPainter.value = null
|
|
2722
2838
|
return
|
|
2723
2839
|
}
|
|
@@ -2734,6 +2850,7 @@ function handleCanvasMouseDown(e: MouseEvent) {
|
|
|
2734
2850
|
const isClickInsideEditing = (container && (container === e.target || container.contains(e.target as Node))) ||
|
|
2735
2851
|
(canvasElDom && (canvasElDom === e.target || canvasElDom.contains(e.target as Node)))
|
|
2736
2852
|
if (isClickInsideEditing) {
|
|
2853
|
+
justSelectedElement = true
|
|
2737
2854
|
return
|
|
2738
2855
|
}
|
|
2739
2856
|
}
|
|
@@ -3771,14 +3888,41 @@ function handleElementMouseDown(e: MouseEvent, el: any) {
|
|
|
3771
3888
|
return
|
|
3772
3889
|
}
|
|
3773
3890
|
|
|
3774
|
-
|
|
3891
|
+
if (shapeFormatPainter.value) {
|
|
3892
|
+
e.stopPropagation()
|
|
3893
|
+
if (shapeFormatPainter.value.mode === 'text-range') {
|
|
3894
|
+
justSelectedElement = true
|
|
3895
|
+
return
|
|
3896
|
+
}
|
|
3897
|
+
if (isEditingText.value) {
|
|
3898
|
+
checkAndExitEditText(undefined, true)
|
|
3899
|
+
}
|
|
3900
|
+
applyFormatToElement(el, shapeFormatPainter.value)
|
|
3901
|
+
syncFormattedElementDom(el)
|
|
3902
|
+
justSelectedElement = true
|
|
3903
|
+
justAppliedFormatPainter = true
|
|
3904
|
+
setTimeout(() => { justAppliedFormatPainter = false }, 50)
|
|
3905
|
+
if (!shapeFormatPainter.value.__continuous) {
|
|
3906
|
+
shapeFormatPainter.value = null
|
|
3907
|
+
}
|
|
3908
|
+
addHistorySnapshot()
|
|
3909
|
+
notify('已应用格式')
|
|
3910
|
+
return
|
|
3911
|
+
}
|
|
3912
|
+
|
|
3913
|
+
// 核心保护:若当前元素正在进行文字编辑,且鼠标按在编辑文本区域内(或实际文字字符/形状编辑区域内),放行浏览器原生光标定位与拖动划词选择;同时标记 justSelectedElement 并阻止冒泡,防止拖动划词移出元素后抬起鼠标触发画布 click 退出编辑态
|
|
3775
3914
|
if (isEditingText.value && (selectedElementId.value === el.id || editingElementId.value === el.id)) {
|
|
3776
3915
|
const target = e.target as HTMLElement
|
|
3777
3916
|
if (el.type === 'text' && !el.latex && !el.content?.includes('<table')) {
|
|
3778
|
-
|
|
3917
|
+
const isInsideEditable = Boolean(target && target.closest(`[id^="editable-${el.id}"]`) && !target.closest('.text-edit-drag-helper'))
|
|
3918
|
+
if (isInsideEditable || isClickOnTextCharacters(e, `editable-${el.id}`)) {
|
|
3919
|
+
justSelectedElement = true
|
|
3920
|
+
e.stopPropagation()
|
|
3779
3921
|
return
|
|
3780
3922
|
}
|
|
3781
3923
|
} else if (target && (target.closest(`[id^="editable-${el.id}"]`) || target.closest('.shape-text-overlay-wrapper') || el.type === 'shape')) {
|
|
3924
|
+
justSelectedElement = true
|
|
3925
|
+
e.stopPropagation()
|
|
3782
3926
|
return
|
|
3783
3927
|
}
|
|
3784
3928
|
}
|
|
@@ -3789,19 +3933,6 @@ function handleElementMouseDown(e: MouseEvent, el: any) {
|
|
|
3789
3933
|
return
|
|
3790
3934
|
}
|
|
3791
3935
|
|
|
3792
|
-
if (shapeFormatPainter.value) {
|
|
3793
|
-
if (shapeFormatPainter.value.mode === 'text-range') {
|
|
3794
|
-
return
|
|
3795
|
-
}
|
|
3796
|
-
applyFormatToElement(el, shapeFormatPainter.value)
|
|
3797
|
-
if (!shapeFormatPainter.value.__continuous) {
|
|
3798
|
-
shapeFormatPainter.value = null
|
|
3799
|
-
}
|
|
3800
|
-
addHistorySnapshot()
|
|
3801
|
-
notify('已应用格式')
|
|
3802
|
-
return
|
|
3803
|
-
}
|
|
3804
|
-
|
|
3805
3936
|
// 重叠下层元素拖拽保护:若当前已有选中的下层元素,且光标落在该已选元素范围内,则将拖拽代理给已选元素,防止顶层元素抢焦
|
|
3806
3937
|
if (!e.ctrlKey && !e.shiftKey && selectedElementIds.value.length > 0 && !selectedElementIds.value.includes(el.id)) {
|
|
3807
3938
|
const activeSelectedEl = findSelectedElementUnderPoint(e.clientX, e.clientY)
|
|
@@ -3829,9 +3960,17 @@ function handleBorderMouseDown(e: MouseEvent, el: any) {
|
|
|
3829
3960
|
|
|
3830
3961
|
if (shapeFormatPainter.value) {
|
|
3831
3962
|
if (shapeFormatPainter.value.mode === 'text-range') {
|
|
3963
|
+
justSelectedElement = true
|
|
3832
3964
|
return
|
|
3833
3965
|
}
|
|
3966
|
+
if (isEditingText.value) {
|
|
3967
|
+
checkAndExitEditText(undefined, true)
|
|
3968
|
+
}
|
|
3834
3969
|
applyFormatToElement(el, shapeFormatPainter.value)
|
|
3970
|
+
syncFormattedElementDom(el)
|
|
3971
|
+
justSelectedElement = true
|
|
3972
|
+
justAppliedFormatPainter = true
|
|
3973
|
+
setTimeout(() => { justAppliedFormatPainter = false }, 50)
|
|
3835
3974
|
if (!shapeFormatPainter.value.__continuous) {
|
|
3836
3975
|
shapeFormatPainter.value = null
|
|
3837
3976
|
}
|
|
@@ -3846,6 +3985,7 @@ function handleBorderMouseDown(e: MouseEvent, el: any) {
|
|
|
3846
3985
|
(canvasElDom && (canvasElDom === e.target || canvasElDom.contains(e.target as Node)))
|
|
3847
3986
|
|
|
3848
3987
|
if (isEditingText.value && selectedElementId.value === el.id && isClickInsideEditable) {
|
|
3988
|
+
justSelectedElement = true
|
|
3849
3989
|
return
|
|
3850
3990
|
}
|
|
3851
3991
|
|
|
@@ -3979,14 +4119,19 @@ function handleChildDragKeyUp(e: KeyboardEvent) {
|
|
|
3979
4119
|
|
|
3980
4120
|
function startChildDrag(e: MouseEvent, child: any, parentGroup: any) {
|
|
3981
4121
|
if (isReadonly.value) return
|
|
4122
|
+
const target = e.target as HTMLElement
|
|
3982
4123
|
const childContainerEl = document.getElementById(`editable-${child.id}`)
|
|
3983
4124
|
const childCanvasElDom = document.getElementById(`canvas-el-${child.id}`)
|
|
4125
|
+
const isEditingThisChild = isEditingText.value && (selectedElementId.value === child.id || editingElementId?.value === child.id)
|
|
3984
4126
|
const isChildClickInside = child.type === 'text' && !child.latex && !child.content?.includes('<table')
|
|
3985
|
-
?
|
|
4127
|
+
? (isEditingThisChild
|
|
4128
|
+
? (Boolean(target && target.closest?.(`[id^="editable-${child.id}"]`) && !target.closest?.('.text-edit-drag-helper')) || isClickOnTextCharacters(e, `editable-${child.id}`))
|
|
4129
|
+
: isClickOnTextCharacters(e, `editable-${child.id}`))
|
|
3986
4130
|
: ((childContainerEl && (childContainerEl === e.target || childContainerEl.contains(e.target as Node))) ||
|
|
3987
4131
|
(childCanvasElDom && (childCanvasElDom === e.target || childCanvasElDom.contains(e.target as Node))))
|
|
3988
4132
|
|
|
3989
|
-
if (
|
|
4133
|
+
if (isEditingThisChild && isChildClickInside) {
|
|
4134
|
+
justSelectedElement = true
|
|
3990
4135
|
return
|
|
3991
4136
|
}
|
|
3992
4137
|
|
|
@@ -4190,14 +4335,41 @@ function handleChildMouseDown(e: MouseEvent, child: any, parentGroup: any) {
|
|
|
4190
4335
|
return
|
|
4191
4336
|
}
|
|
4192
4337
|
if (activeTool.value) return
|
|
4338
|
+
if (shapeFormatPainter.value) {
|
|
4339
|
+
e.stopPropagation()
|
|
4340
|
+
if (shapeFormatPainter.value.mode === 'text-range') {
|
|
4341
|
+
justSelectedElement = true
|
|
4342
|
+
return
|
|
4343
|
+
}
|
|
4344
|
+
if (isEditingText.value) {
|
|
4345
|
+
checkAndExitEditText(undefined, true)
|
|
4346
|
+
}
|
|
4347
|
+
applyFormatToElement(child, shapeFormatPainter.value)
|
|
4348
|
+
syncFormattedElementDom(child)
|
|
4349
|
+
justSelectedElement = true
|
|
4350
|
+
justAppliedFormatPainter = true
|
|
4351
|
+
setTimeout(() => { justAppliedFormatPainter = false }, 50)
|
|
4352
|
+
if (!shapeFormatPainter.value.__continuous) {
|
|
4353
|
+
shapeFormatPainter.value = null
|
|
4354
|
+
}
|
|
4355
|
+
addHistorySnapshot()
|
|
4356
|
+
notify('已应用格式')
|
|
4357
|
+
return
|
|
4358
|
+
}
|
|
4359
|
+
const target = e.target as HTMLElement
|
|
4193
4360
|
const childContainerEl = document.getElementById(`editable-${child.id}`)
|
|
4194
4361
|
const childCanvasElDom = document.getElementById(`canvas-el-${child.id}`)
|
|
4362
|
+
const isEditingThisChild = isEditingText.value && (selectedElementId.value === child.id || editingElementId?.value === child.id)
|
|
4195
4363
|
const isChildClickInside = child.type === 'text' && !child.latex && !child.content?.includes('<table')
|
|
4196
|
-
?
|
|
4364
|
+
? (isEditingThisChild
|
|
4365
|
+
? (Boolean(target && target.closest?.(`[id^="editable-${child.id}"]`) && !target.closest?.('.text-edit-drag-helper')) || isClickOnTextCharacters(e, `editable-${child.id}`))
|
|
4366
|
+
: isClickOnTextCharacters(e, `editable-${child.id}`))
|
|
4197
4367
|
: ((childContainerEl && (childContainerEl === e.target || childContainerEl.contains(e.target as Node))) ||
|
|
4198
4368
|
(childCanvasElDom && (childCanvasElDom === e.target || childCanvasElDom.contains(e.target as Node))))
|
|
4199
4369
|
|
|
4200
|
-
if (
|
|
4370
|
+
if (isEditingThisChild && isChildClickInside) {
|
|
4371
|
+
justSelectedElement = true
|
|
4372
|
+
e.stopPropagation()
|
|
4201
4373
|
return
|
|
4202
4374
|
}
|
|
4203
4375
|
|
|
@@ -4207,19 +4379,6 @@ function handleChildMouseDown(e: MouseEvent, child: any, parentGroup: any) {
|
|
|
4207
4379
|
e.stopPropagation()
|
|
4208
4380
|
if (isReadonly.value) return
|
|
4209
4381
|
|
|
4210
|
-
if (shapeFormatPainter.value) {
|
|
4211
|
-
if (shapeFormatPainter.value.mode === 'text-range') {
|
|
4212
|
-
return
|
|
4213
|
-
}
|
|
4214
|
-
applyFormatToElement(child, shapeFormatPainter.value)
|
|
4215
|
-
if (!shapeFormatPainter.value.__continuous) {
|
|
4216
|
-
shapeFormatPainter.value = null
|
|
4217
|
-
}
|
|
4218
|
-
addHistorySnapshot()
|
|
4219
|
-
notify('已应用格式')
|
|
4220
|
-
return
|
|
4221
|
-
}
|
|
4222
|
-
|
|
4223
4382
|
justSelectedElement = true
|
|
4224
4383
|
const childTarget = e.target as HTMLElement
|
|
4225
4384
|
mousedownOnPlaceholderIcon = Boolean(childTarget?.closest?.('.image-placeholder-icon-btn'))
|
|
@@ -4275,10 +4434,29 @@ function handleChildClick(e: MouseEvent, child: any, parentGroup: any) {
|
|
|
4275
4434
|
if (isReadonly.value || activeTool.value) return
|
|
4276
4435
|
if (isLockedMasterElement(child)) return
|
|
4277
4436
|
e.stopPropagation()
|
|
4437
|
+
if (justAppliedFormatPainter) {
|
|
4438
|
+
justAppliedFormatPainter = false
|
|
4439
|
+
return
|
|
4440
|
+
}
|
|
4278
4441
|
if (dragOccurred) {
|
|
4279
4442
|
dragOccurred = false
|
|
4280
4443
|
return
|
|
4281
4444
|
}
|
|
4445
|
+
const currentEditingId = editingElementId?.value || selectedElementId.value
|
|
4446
|
+
if (isEditingText.value && currentEditingId) {
|
|
4447
|
+
if (currentEditingId === child.id) return
|
|
4448
|
+
const downTarget = lastMouseDownTarget.value
|
|
4449
|
+
if (downTarget) {
|
|
4450
|
+
const editingContainer = document.getElementById(`editable-${currentEditingId}`)
|
|
4451
|
+
const editingCanvasEl = document.getElementById(`canvas-el-${currentEditingId}`)
|
|
4452
|
+
if (
|
|
4453
|
+
(editingContainer && (editingContainer === downTarget || editingContainer.contains(downTarget))) ||
|
|
4454
|
+
(editingCanvasEl && (editingCanvasEl === downTarget || editingCanvasEl.contains(downTarget)))
|
|
4455
|
+
) {
|
|
4456
|
+
return
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4459
|
+
}
|
|
4282
4460
|
if (shapeFormatPainter.value) {
|
|
4283
4461
|
if (shapeFormatPainter.value.mode === 'text-range') {
|
|
4284
4462
|
return
|
|
@@ -4358,12 +4536,28 @@ function handleElementClick(e: MouseEvent, elId: string) {
|
|
|
4358
4536
|
if (isLockedMasterElement(targetEl)) return
|
|
4359
4537
|
}
|
|
4360
4538
|
e.stopPropagation()
|
|
4539
|
+
if (justAppliedFormatPainter) {
|
|
4540
|
+
justAppliedFormatPainter = false
|
|
4541
|
+
return
|
|
4542
|
+
}
|
|
4361
4543
|
if (dragOccurred) {
|
|
4362
4544
|
dragOccurred = false
|
|
4363
4545
|
return
|
|
4364
4546
|
}
|
|
4365
|
-
|
|
4366
|
-
|
|
4547
|
+
const currentEditingId = editingElementId?.value || selectedElementId.value
|
|
4548
|
+
if (isEditingText.value && currentEditingId) {
|
|
4549
|
+
if (currentEditingId === elId) return
|
|
4550
|
+
const downTarget = lastMouseDownTarget.value
|
|
4551
|
+
if (downTarget) {
|
|
4552
|
+
const editingContainer = document.getElementById(`editable-${currentEditingId}`)
|
|
4553
|
+
const editingCanvasEl = document.getElementById(`canvas-el-${currentEditingId}`)
|
|
4554
|
+
if (
|
|
4555
|
+
(editingContainer && (editingContainer === downTarget || editingContainer.contains(downTarget))) ||
|
|
4556
|
+
(editingCanvasEl && (editingCanvasEl === downTarget || editingCanvasEl.contains(downTarget)))
|
|
4557
|
+
) {
|
|
4558
|
+
return
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4367
4561
|
}
|
|
4368
4562
|
if (shapeFormatPainter.value) {
|
|
4369
4563
|
if (shapeFormatPainter.value.mode === 'text-range') {
|
|
@@ -4771,11 +4965,15 @@ function handleTextMouseMove(e: MouseEvent, el: any) {
|
|
|
4771
4965
|
const canvasElDom = document.getElementById(`canvas-el-${el.id}`)
|
|
4772
4966
|
if (!container) return
|
|
4773
4967
|
|
|
4774
|
-
if (el.
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4968
|
+
if (isEditingText.value && (selectedElementId.value === el.id || editingElementId?.value === el.id)) {
|
|
4969
|
+
container.style.cursor = 'text'
|
|
4970
|
+
if (canvasElDom) {
|
|
4971
|
+
canvasElDom.style.cursor = 'text'
|
|
4778
4972
|
}
|
|
4973
|
+
return
|
|
4974
|
+
}
|
|
4975
|
+
|
|
4976
|
+
if (el.type === 'shape') {
|
|
4779
4977
|
const textVal = el.text ? String(el.text).replace(/<[^>]*>/g, '').trim() : ''
|
|
4780
4978
|
const isEmptyText = !textVal
|
|
4781
4979
|
const isPlaceholder = isPlaceholderElement(el)
|
|
@@ -4797,6 +4995,11 @@ function handleTextMouseLeave(_e: MouseEvent, el: any) {
|
|
|
4797
4995
|
if (isReadonly.value) return
|
|
4798
4996
|
const container = document.getElementById(`editable-${el.id}`)
|
|
4799
4997
|
const canvasElDom = document.getElementById(`canvas-el-${el.id}`)
|
|
4998
|
+
if (isEditingText.value && (selectedElementId.value === el.id || editingElementId?.value === el.id)) {
|
|
4999
|
+
if (container) container.style.cursor = 'text'
|
|
5000
|
+
if (canvasElDom) canvasElDom.style.cursor = 'text'
|
|
5001
|
+
return
|
|
5002
|
+
}
|
|
4800
5003
|
if (container) {
|
|
4801
5004
|
container.style.cursor = 'move'
|
|
4802
5005
|
}
|
|
@@ -4810,11 +5013,15 @@ function startDrag(e: MouseEvent, el: any) {
|
|
|
4810
5013
|
const target = e.target as HTMLElement
|
|
4811
5014
|
const container = document.getElementById(`editable-${el.id}`)
|
|
4812
5015
|
const canvasElDom = document.getElementById(`canvas-el-${el.id}`)
|
|
5016
|
+
const isEditingThisEl = isEditingText.value && (selectedElementId.value === el.id || editingElementId?.value === el.id)
|
|
4813
5017
|
const isInsideEditingContainer = el.type === 'text' && !el.latex && !el.content?.includes('<table')
|
|
4814
|
-
?
|
|
5018
|
+
? (isEditingThisEl
|
|
5019
|
+
? (Boolean(target && target.closest?.(`[id^="editable-${el.id}"]`) && !target.closest?.('.text-edit-drag-helper')) || isClickOnTextCharacters(e, `editable-${el.id}`))
|
|
5020
|
+
: isClickOnTextCharacters(e, `editable-${el.id}`))
|
|
4815
5021
|
: ((container && (container === target || container.contains(target))) ||
|
|
4816
5022
|
(canvasElDom && (canvasElDom === target || canvasElDom.contains(target))))
|
|
4817
|
-
if (
|
|
5023
|
+
if (isEditingThisEl && isInsideEditingContainer) {
|
|
5024
|
+
justSelectedElement = true
|
|
4818
5025
|
return
|
|
4819
5026
|
}
|
|
4820
5027
|
|
|
@@ -6702,13 +6909,21 @@ function toggleQuickFormatPainter(el: any, continuous = false) {
|
|
|
6702
6909
|
}
|
|
6703
6910
|
shapeFormatPainter.value = null
|
|
6704
6911
|
} else if (el) {
|
|
6705
|
-
// 1. Check if there is an active text selection
|
|
6706
|
-
const
|
|
6912
|
+
// 1. Check if there is an active text selection inside the currently editing element
|
|
6913
|
+
const container = document.getElementById(`editable-${el.id}`)
|
|
6914
|
+
const sel = typeof window !== 'undefined' ? window.getSelection() : null
|
|
6915
|
+
const liveRange = (sel && sel.rangeCount > 0 && !sel.isCollapsed) ? sel.getRangeAt(0) : null
|
|
6916
|
+
const candidateRange = liveRange || (isEditingText.value && savedSelectionRange && !savedSelectionRange.collapsed ? savedSelectionRange : null)
|
|
6917
|
+
const isRangeInEl = Boolean(candidateRange && container && container.contains(candidateRange.commonAncestorContainer))
|
|
6918
|
+
const textFmt = (isEditingText.value && isRangeInEl) ? getFormatFromSelection(candidateRange) : null
|
|
6707
6919
|
if (textFmt) {
|
|
6708
6920
|
if (continuous) textFmt.__continuous = true
|
|
6921
|
+
if (isEditingText.value) {
|
|
6922
|
+
checkAndExitEditText(undefined, true)
|
|
6923
|
+
}
|
|
6709
6924
|
shapeFormatPainter.value = textFmt
|
|
6710
6925
|
copyFormatTime = Date.now()
|
|
6711
|
-
notify(continuous ? '
|
|
6926
|
+
notify(continuous ? '已开启连续文本格式刷,划选或点击目标文本进行应用,按 Esc 退出' : '已复制文本格式,请划选或点击目标文本进行应用')
|
|
6712
6927
|
return
|
|
6713
6928
|
}
|
|
6714
6929
|
|
|
@@ -6717,6 +6932,9 @@ function toggleQuickFormatPainter(el: any, continuous = false) {
|
|
|
6717
6932
|
if (fmt) {
|
|
6718
6933
|
fmt.mode = 'element'
|
|
6719
6934
|
if (continuous) fmt.__continuous = true
|
|
6935
|
+
if (isEditingText.value) {
|
|
6936
|
+
checkAndExitEditText(undefined, true)
|
|
6937
|
+
}
|
|
6720
6938
|
shapeFormatPainter.value = fmt
|
|
6721
6939
|
copyFormatTime = Date.now()
|
|
6722
6940
|
notify(continuous ? '已开启连续格式刷,按 Esc 键或再次点击退出' : '已复制格式,点击其他元素进行应用')
|
|
@@ -8358,7 +8576,7 @@ async function handleGlobalPaste(e: ClipboardEvent) {
|
|
|
8358
8576
|
: (el.type === 'line'
|
|
8359
8577
|
? `${el.style?.left}_${el.style?.top}_${el.style?.width}_${el.style?.height}_${el.start?.join(',')}_${el.end?.join(',')}_${el.broken?.join(',')}_${el.broken2?.join(',')}_${el.curve?.join(',')}`
|
|
8360
8578
|
: 'frozen'))
|
|
8361
|
-
: `${el.id}_${el.type}_${el.content}_${typeof (el as any).text === 'string' ? (el as any).text : ((el as any).text?.content || '')}_${(el.style as any)?.textBackground || ''}_${(el as any).autoFit?.type || ''}_${(el as any).autoFit?.fontScale || ''}_${(el as any).src}_${el.isPlaceholderReplaced}_${el.style?.left}_${el.style?.top}_${el.style?.width}_${el.style?.height}_${el.style?.rotate}_${el.type === 'line' ? `${el.start?.join(',')}_${el.end?.join(',')}_${el.broken?.join(',')}_${el.broken2?.join(',')}_${el.curve?.join(',')}_` : ''}${selectedElementIds.includes(el.id)}_${selectedElementId === el.id}_${isEditingText}_${activeTab}_${activeSlideVersion}_${(el.style as any)?.reflection?.enabled}_${(el.style as any)?.reflection?.distance}_${(el.style as any)?.reflection?.size}_${(el.style as any)?.reflection?.blur}_${(el.style as any)?.reflection?.opacity}`
|
|
8579
|
+
: `${el.id}_${el.type}_${el.content}_${typeof (el as any).text === 'string' ? (el as any).text : ((el as any).text?.content || '')}_${el.style?.color || ''}_${(el.style as any)?.textColor || ''}_${el.style?.fontSize || ''}_${el.style?.fontFamily || ''}_${el.style?.fontWeight || ''}_${el.style?.fontStyle || ''}_${el.style?.textDecoration || ''}_${el.style?.textAlign || ''}_${el.style?.verticalAlign || ''}_${el.style?.lineHeight || ''}_${el.style?.letterSpacing || ''}_${el.style?.fill || ''}_${el.style?.borderColor || ''}_${el.style?.borderWidth || ''}_${el.style?.borderStyle || ''}_${el.style?.borderRadius || ''}_${(el.style as any)?.opacity ?? ''}_${(el.style as any)?.textBackground || ''}_${(el as any).autoFit?.type || ''}_${(el as any).autoFit?.fontScale || ''}_${(el as any).src}_${el.isPlaceholderReplaced}_${el.style?.left}_${el.style?.top}_${el.style?.width}_${el.style?.height}_${el.style?.rotate}_${el.type === 'line' ? `${el.start?.join(',')}_${el.end?.join(',')}_${el.broken?.join(',')}_${el.broken2?.join(',')}_${el.curve?.join(',')}_` : ''}${selectedElementIds.includes(el.id)}_${selectedElementId === el.id}_${isEditingText}_${Boolean(shapeFormatPainter)}_${shapeFormatPainter?.mode || ''}_${activeTab}_${activeSlideVersion}_${(el.style as any)?.reflection?.enabled}_${(el.style as any)?.reflection?.distance}_${(el.style as any)?.reflection?.size}_${(el.style as any)?.reflection?.blur}_${(el.style as any)?.reflection?.opacity}`
|
|
8362
8580
|
]"
|
|
8363
8581
|
:class="{
|
|
8364
8582
|
selected: selectedElementIds.includes(el.id),
|
|
@@ -7751,7 +7751,6 @@ defineExpose({
|
|
|
7751
7751
|
</svg>
|
|
7752
7752
|
</div>
|
|
7753
7753
|
<div class="import-label">PPTX</div>
|
|
7754
|
-
<div class="import-subtext">(仅供测试)</div>
|
|
7755
7754
|
</div>
|
|
7756
7755
|
|
|
7757
7756
|
<!-- JSON Import -->
|
|
@@ -7766,11 +7765,10 @@ defineExpose({
|
|
|
7766
7765
|
</svg>
|
|
7767
7766
|
</div>
|
|
7768
7767
|
<div class="import-label">JSON</div>
|
|
7769
|
-
<div class="import-subtext">(仅供测试)</div>
|
|
7770
7768
|
</div>
|
|
7771
7769
|
|
|
7772
7770
|
<!-- JVS-PPT Import -->
|
|
7773
|
-
<div class="import-card" @click="handleMenuAction(handleJVSPPTImport)">
|
|
7771
|
+
<div v-if="false" class="import-card" @click="handleMenuAction(handleJVSPPTImport)">
|
|
7774
7772
|
<div class="import-icon-box pptist-icon">
|
|
7775
7773
|
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7776
7774
|
<path
|
|
@@ -7840,7 +7838,7 @@ defineExpose({
|
|
|
7840
7838
|
</div>
|
|
7841
7839
|
|
|
7842
7840
|
<!-- Label -->
|
|
7843
|
-
<div class="menu-link-item" @click="handleMenuAction(handleLabelSlides)">
|
|
7841
|
+
<div v-if="false" class="menu-link-item" @click="handleMenuAction(handleLabelSlides)">
|
|
7844
7842
|
<svg class="link-icon" viewBox="0 0 24 24">
|
|
7845
7843
|
<path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6h-5.6z" fill="currentColor" />
|
|
7846
7844
|
</svg>
|