jvs-ppt-ui 0.0.37 → 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.
@@ -290,6 +290,7 @@ const {
290
290
 
291
291
  // Crop Composable
292
292
  const {
293
+ isCropping,
293
294
  startInteractiveCrop,
294
295
  handleCropDrag,
295
296
  stopCropDrag,
@@ -299,7 +300,10 @@ const {
299
300
  pauseHistory,
300
301
  getElementPixels: (el: any) => getElementPixels(el),
301
302
  findParentGroup: (id: any) => findParentGroup(id),
302
- addHistorySnapshot: () => addHistorySnapshot()
303
+ addHistorySnapshot: () => addHistorySnapshot(),
304
+ onCropStop: () => {
305
+ justSelectedElement = true
306
+ }
303
307
  })
304
308
 
305
309
  // Element Map and Group helpers
@@ -836,6 +840,7 @@ const isInteracting = computed(() => {
836
840
  isDraggingChild.value ||
837
841
  isResizing.value ||
838
842
  isRotating.value ||
843
+ isCropping.value ||
839
844
  isDraggingLine.value ||
840
845
  isDraggingLineControlPoint.value ||
841
846
  isPanningCanvas.value
@@ -1160,21 +1165,48 @@ const getQuickToolbarAnchor = (el: any) => {
1160
1165
  return { box, extraTableOffset }
1161
1166
  }
1162
1167
 
1163
- // 将工具栏物理坐标(left/top)钳制在幻灯片区域内,防止拖出画布后无法再次拖回
1168
+ // 将工具栏物理坐标(left/top)钳制在幻灯片及画布可视区域内,防止超出可视区顶部被裁剪或拖出画布无法拖回
1164
1169
  const clampQuickToolbarPhysical = (left: number, top: number) => {
1165
1170
  const scale = (zoomRatio.value || 100) / 100
1166
1171
  const slideW = (logicalWidth.value || 0) * scale
1167
1172
  const slideH = (logicalHeight.value || 0) * scale
1168
1173
  const toolbarEl = document.querySelector('.floating-quick-toolbar') as HTMLElement | null
1169
- const halfW = (toolbarEl?.offsetWidth || 0) / 2 // translateX(-50%),left 为中心点
1170
- const toolbarH = toolbarEl?.offsetHeight || 0
1174
+ const halfW = (toolbarEl?.offsetWidth || 220) / 2 // translateX(-50%),left 为中心点
1175
+ const toolbarH = toolbarEl?.offsetHeight || 42
1176
+
1177
+ let minLeft = halfW
1178
+ let maxLeft = Math.max(halfW, slideW - halfW)
1179
+ let minTop = -56
1180
+ let maxTop = Math.max(0, slideH - toolbarH)
1181
+
1182
+ const wrapperEl = document.querySelector('.canvas-slide-wrapper') as HTMLElement | null
1183
+ const zoomContainerEl = document.querySelector('.slide-zoom-container') as HTMLElement | null
1184
+ if (wrapperEl && zoomContainerEl) {
1185
+ const wrapperRect = wrapperEl.getBoundingClientRect()
1186
+ const zoomRect = zoomContainerEl.getBoundingClientRect()
1187
+ // 距离 .canvas-slide-wrapper 可视边界保留至少 8px 安全间距,防止顶部/四周溢出被裁剪
1188
+ const visibleMinTop = (wrapperRect.top - zoomRect.top) + 8
1189
+ const visibleMaxTop = (wrapperRect.bottom - zoomRect.top) - toolbarH - 8
1190
+ const visibleMinLeft = (wrapperRect.left - zoomRect.left) + halfW + 8
1191
+ const visibleMaxLeft = (wrapperRect.right - zoomRect.left) - halfW - 8
1192
+
1193
+ minTop = Math.max(minTop, visibleMinTop)
1194
+ if (visibleMaxTop >= minTop) {
1195
+ maxTop = Math.min(maxTop, visibleMaxTop)
1196
+ }
1197
+ minLeft = Math.max(minLeft, visibleMinLeft)
1198
+ if (visibleMaxLeft >= minLeft) {
1199
+ maxLeft = Math.min(maxLeft, visibleMaxLeft)
1200
+ }
1201
+ }
1171
1202
 
1172
- const clampedLeft = Math.min(Math.max(left, halfW), Math.max(halfW, slideW - halfW))
1173
- const clampedTop = Math.min(Math.max(top, -56), Math.max(0, slideH - toolbarH))
1174
- return { left: clampedLeft, top: clampedTop }
1203
+ const clampedLeft = Math.min(Math.max(left, minLeft), Math.max(minLeft, maxLeft))
1204
+ const clampedTop = Math.min(Math.max(top, minTop), Math.max(minTop, maxTop))
1205
+ return { left: Math.round(clampedLeft), top: Math.round(clampedTop) }
1175
1206
  }
1176
1207
 
1177
1208
  const getFloatingQuickToolbarStyle = (el: any) => {
1209
+ void selectionVersion.value
1178
1210
  if (isDragging.value || isCanvasDragging.value) {
1179
1211
  return { display: 'none' } as any
1180
1212
  }
@@ -1598,10 +1630,15 @@ watch(editingElementId, (newId) => {
1598
1630
 
1599
1631
  watch([selectedElementId, isEditingText], () => {
1600
1632
  if (!isEditingText.value || !selectedElementId.value) {
1601
- window.getSelection()?.removeAllRanges()
1633
+ if (!(shapeFormatPainter.value && shapeFormatPainter.value.mode === 'text-range')) {
1634
+ window.getSelection()?.removeAllRanges()
1635
+ }
1602
1636
  savedSelectionRange = null
1603
1637
  }
1604
1638
  selectionVersion.value++
1639
+ nextTick(() => {
1640
+ selectionVersion.value++
1641
+ })
1605
1642
  })
1606
1643
 
1607
1644
  watch(selectedElementId, (newId, oldId) => {
@@ -1843,6 +1880,56 @@ function restoreSelection() {
1843
1880
  }
1844
1881
 
1845
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
+
1846
1933
  function handleGlobalMouseUp(e: MouseEvent) {
1847
1934
  if (shapeFormatPainter.value && shapeFormatPainter.value.mode === 'text-range') {
1848
1935
  if (Date.now() - copyFormatTime < 250) {
@@ -1866,16 +1953,45 @@ function handleGlobalMouseUp(e: MouseEvent) {
1866
1953
  const applied = applyFormatToTextRange(range, shapeFormatPainter.value, container, targetEl)
1867
1954
  if (applied) {
1868
1955
  sel.removeAllRanges()
1956
+ container.blur()
1957
+ justSelectedElement = true
1958
+ justAppliedFormatPainter = true
1959
+ setTimeout(() => { justAppliedFormatPainter = false }, 50)
1869
1960
  if (!shapeFormatPainter.value.__continuous) {
1870
1961
  shapeFormatPainter.value = null
1871
1962
  }
1872
1963
  addHistorySnapshot()
1873
1964
  notify('已应用文本格式')
1965
+ return
1874
1966
  }
1875
1967
  }
1876
1968
  }
1877
1969
  }
1878
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
+ }
1879
1995
  }
1880
1996
  }
1881
1997
 
@@ -1964,6 +2080,7 @@ function handleWindowMouseDown(e: MouseEvent) {
1964
2080
  if (
1965
2081
  target.closest('.resize-handle') ||
1966
2082
  target.closest('.rotate-handle') ||
2083
+ target.closest('.crop-handle') ||
1967
2084
  target.closest('.line-point-handle') ||
1968
2085
  target.closest('.line-control-handle') ||
1969
2086
  target.closest('.table-edit-mask') ||
@@ -2005,7 +2122,10 @@ function handleWindowMouseDown(e: MouseEvent) {
2005
2122
  return
2006
2123
  }
2007
2124
 
2008
- // Deselect active elements
2125
+ // Deselect active elements (blur any active right-sidebar input first so its @blur commits while selectedElement is still active)
2126
+ if (typeof document !== 'undefined' && document.activeElement instanceof HTMLElement && document.activeElement.closest('.sidebar-right')) {
2127
+ document.activeElement.blur()
2128
+ }
2009
2129
  if (isEditingText.value) {
2010
2130
  checkAndExitEditText(undefined, true)
2011
2131
  }
@@ -2067,11 +2187,25 @@ function handleDeselect(e?: MouseEvent) {
2067
2187
  justSelectedElement = false
2068
2188
  return
2069
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
+ }
2070
2203
  if (e) {
2071
2204
  const target = e.target as HTMLElement
2072
2205
  if (target) {
2073
2206
  if (
2074
2207
  target.closest('.canvas-element') ||
2208
+ target.closest('.group-child-item') ||
2075
2209
  target.closest('.global-selection-overlay') ||
2076
2210
  target.closest('.floating-quick-toolbar') ||
2077
2211
  target.closest('.el-popover') ||
@@ -2679,6 +2813,27 @@ function handleCanvasMouseDown(e: MouseEvent) {
2679
2813
  }
2680
2814
 
2681
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
+ }
2682
2837
  shapeFormatPainter.value = null
2683
2838
  return
2684
2839
  }
@@ -2695,6 +2850,7 @@ function handleCanvasMouseDown(e: MouseEvent) {
2695
2850
  const isClickInsideEditing = (container && (container === e.target || container.contains(e.target as Node))) ||
2696
2851
  (canvasElDom && (canvasElDom === e.target || canvasElDom.contains(e.target as Node)))
2697
2852
  if (isClickInsideEditing) {
2853
+ justSelectedElement = true
2698
2854
  return
2699
2855
  }
2700
2856
  }
@@ -3732,14 +3888,41 @@ function handleElementMouseDown(e: MouseEvent, el: any) {
3732
3888
  return
3733
3889
  }
3734
3890
 
3735
- // 核心保护:若当前元素正在进行文字编辑,且鼠标按在实际文字字符上(或形状编辑区域内),放行浏览器原生光标定位与拖动划词选择;若按在文本框空白区域则允许拖动文本框
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 退出编辑态
3736
3914
  if (isEditingText.value && (selectedElementId.value === el.id || editingElementId.value === el.id)) {
3737
3915
  const target = e.target as HTMLElement
3738
3916
  if (el.type === 'text' && !el.latex && !el.content?.includes('<table')) {
3739
- if (isClickOnTextCharacters(e, `editable-${el.id}`)) {
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()
3740
3921
  return
3741
3922
  }
3742
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()
3743
3926
  return
3744
3927
  }
3745
3928
  }
@@ -3750,19 +3933,6 @@ function handleElementMouseDown(e: MouseEvent, el: any) {
3750
3933
  return
3751
3934
  }
3752
3935
 
3753
- if (shapeFormatPainter.value) {
3754
- if (shapeFormatPainter.value.mode === 'text-range') {
3755
- return
3756
- }
3757
- applyFormatToElement(el, shapeFormatPainter.value)
3758
- if (!shapeFormatPainter.value.__continuous) {
3759
- shapeFormatPainter.value = null
3760
- }
3761
- addHistorySnapshot()
3762
- notify('已应用格式')
3763
- return
3764
- }
3765
-
3766
3936
  // 重叠下层元素拖拽保护:若当前已有选中的下层元素,且光标落在该已选元素范围内,则将拖拽代理给已选元素,防止顶层元素抢焦
3767
3937
  if (!e.ctrlKey && !e.shiftKey && selectedElementIds.value.length > 0 && !selectedElementIds.value.includes(el.id)) {
3768
3938
  const activeSelectedEl = findSelectedElementUnderPoint(e.clientX, e.clientY)
@@ -3790,9 +3960,17 @@ function handleBorderMouseDown(e: MouseEvent, el: any) {
3790
3960
 
3791
3961
  if (shapeFormatPainter.value) {
3792
3962
  if (shapeFormatPainter.value.mode === 'text-range') {
3963
+ justSelectedElement = true
3793
3964
  return
3794
3965
  }
3966
+ if (isEditingText.value) {
3967
+ checkAndExitEditText(undefined, true)
3968
+ }
3795
3969
  applyFormatToElement(el, shapeFormatPainter.value)
3970
+ syncFormattedElementDom(el)
3971
+ justSelectedElement = true
3972
+ justAppliedFormatPainter = true
3973
+ setTimeout(() => { justAppliedFormatPainter = false }, 50)
3796
3974
  if (!shapeFormatPainter.value.__continuous) {
3797
3975
  shapeFormatPainter.value = null
3798
3976
  }
@@ -3807,6 +3985,7 @@ function handleBorderMouseDown(e: MouseEvent, el: any) {
3807
3985
  (canvasElDom && (canvasElDom === e.target || canvasElDom.contains(e.target as Node)))
3808
3986
 
3809
3987
  if (isEditingText.value && selectedElementId.value === el.id && isClickInsideEditable) {
3988
+ justSelectedElement = true
3810
3989
  return
3811
3990
  }
3812
3991
 
@@ -3940,14 +4119,19 @@ function handleChildDragKeyUp(e: KeyboardEvent) {
3940
4119
 
3941
4120
  function startChildDrag(e: MouseEvent, child: any, parentGroup: any) {
3942
4121
  if (isReadonly.value) return
4122
+ const target = e.target as HTMLElement
3943
4123
  const childContainerEl = document.getElementById(`editable-${child.id}`)
3944
4124
  const childCanvasElDom = document.getElementById(`canvas-el-${child.id}`)
4125
+ const isEditingThisChild = isEditingText.value && (selectedElementId.value === child.id || editingElementId?.value === child.id)
3945
4126
  const isChildClickInside = child.type === 'text' && !child.latex && !child.content?.includes('<table')
3946
- ? isClickOnTextCharacters(e, `editable-${child.id}`)
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}`))
3947
4130
  : ((childContainerEl && (childContainerEl === e.target || childContainerEl.contains(e.target as Node))) ||
3948
4131
  (childCanvasElDom && (childCanvasElDom === e.target || childCanvasElDom.contains(e.target as Node))))
3949
4132
 
3950
- if (isEditingText.value && selectedElementId.value === child.id && isChildClickInside) {
4133
+ if (isEditingThisChild && isChildClickInside) {
4134
+ justSelectedElement = true
3951
4135
  return
3952
4136
  }
3953
4137
 
@@ -4151,14 +4335,41 @@ function handleChildMouseDown(e: MouseEvent, child: any, parentGroup: any) {
4151
4335
  return
4152
4336
  }
4153
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
4154
4360
  const childContainerEl = document.getElementById(`editable-${child.id}`)
4155
4361
  const childCanvasElDom = document.getElementById(`canvas-el-${child.id}`)
4362
+ const isEditingThisChild = isEditingText.value && (selectedElementId.value === child.id || editingElementId?.value === child.id)
4156
4363
  const isChildClickInside = child.type === 'text' && !child.latex && !child.content?.includes('<table')
4157
- ? isClickOnTextCharacters(e, `editable-${child.id}`)
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}`))
4158
4367
  : ((childContainerEl && (childContainerEl === e.target || childContainerEl.contains(e.target as Node))) ||
4159
4368
  (childCanvasElDom && (childCanvasElDom === e.target || childCanvasElDom.contains(e.target as Node))))
4160
4369
 
4161
- if (isEditingText.value && selectedElementId.value === child.id && isChildClickInside) {
4370
+ if (isEditingThisChild && isChildClickInside) {
4371
+ justSelectedElement = true
4372
+ e.stopPropagation()
4162
4373
  return
4163
4374
  }
4164
4375
 
@@ -4168,19 +4379,6 @@ function handleChildMouseDown(e: MouseEvent, child: any, parentGroup: any) {
4168
4379
  e.stopPropagation()
4169
4380
  if (isReadonly.value) return
4170
4381
 
4171
- if (shapeFormatPainter.value) {
4172
- if (shapeFormatPainter.value.mode === 'text-range') {
4173
- return
4174
- }
4175
- applyFormatToElement(child, shapeFormatPainter.value)
4176
- if (!shapeFormatPainter.value.__continuous) {
4177
- shapeFormatPainter.value = null
4178
- }
4179
- addHistorySnapshot()
4180
- notify('已应用格式')
4181
- return
4182
- }
4183
-
4184
4382
  justSelectedElement = true
4185
4383
  const childTarget = e.target as HTMLElement
4186
4384
  mousedownOnPlaceholderIcon = Boolean(childTarget?.closest?.('.image-placeholder-icon-btn'))
@@ -4236,10 +4434,29 @@ function handleChildClick(e: MouseEvent, child: any, parentGroup: any) {
4236
4434
  if (isReadonly.value || activeTool.value) return
4237
4435
  if (isLockedMasterElement(child)) return
4238
4436
  e.stopPropagation()
4437
+ if (justAppliedFormatPainter) {
4438
+ justAppliedFormatPainter = false
4439
+ return
4440
+ }
4239
4441
  if (dragOccurred) {
4240
4442
  dragOccurred = false
4241
4443
  return
4242
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
+ }
4243
4460
  if (shapeFormatPainter.value) {
4244
4461
  if (shapeFormatPainter.value.mode === 'text-range') {
4245
4462
  return
@@ -4319,12 +4536,28 @@ function handleElementClick(e: MouseEvent, elId: string) {
4319
4536
  if (isLockedMasterElement(targetEl)) return
4320
4537
  }
4321
4538
  e.stopPropagation()
4539
+ if (justAppliedFormatPainter) {
4540
+ justAppliedFormatPainter = false
4541
+ return
4542
+ }
4322
4543
  if (dragOccurred) {
4323
4544
  dragOccurred = false
4324
4545
  return
4325
4546
  }
4326
- if (isEditingText.value && (selectedElementId.value === elId || editingElementId?.value === elId)) {
4327
- return
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
+ }
4328
4561
  }
4329
4562
  if (shapeFormatPainter.value) {
4330
4563
  if (shapeFormatPainter.value.mode === 'text-range') {
@@ -4732,11 +4965,15 @@ function handleTextMouseMove(e: MouseEvent, el: any) {
4732
4965
  const canvasElDom = document.getElementById(`canvas-el-${el.id}`)
4733
4966
  if (!container) return
4734
4967
 
4735
- if (el.type === 'shape') {
4736
- if (isEditingText.value && (selectedElementId.value === el.id || editingElementId?.value === el.id)) {
4737
- container.style.cursor = 'text'
4738
- return
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'
4739
4972
  }
4973
+ return
4974
+ }
4975
+
4976
+ if (el.type === 'shape') {
4740
4977
  const textVal = el.text ? String(el.text).replace(/<[^>]*>/g, '').trim() : ''
4741
4978
  const isEmptyText = !textVal
4742
4979
  const isPlaceholder = isPlaceholderElement(el)
@@ -4758,6 +4995,11 @@ function handleTextMouseLeave(_e: MouseEvent, el: any) {
4758
4995
  if (isReadonly.value) return
4759
4996
  const container = document.getElementById(`editable-${el.id}`)
4760
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
+ }
4761
5003
  if (container) {
4762
5004
  container.style.cursor = 'move'
4763
5005
  }
@@ -4771,11 +5013,15 @@ function startDrag(e: MouseEvent, el: any) {
4771
5013
  const target = e.target as HTMLElement
4772
5014
  const container = document.getElementById(`editable-${el.id}`)
4773
5015
  const canvasElDom = document.getElementById(`canvas-el-${el.id}`)
5016
+ const isEditingThisEl = isEditingText.value && (selectedElementId.value === el.id || editingElementId?.value === el.id)
4774
5017
  const isInsideEditingContainer = el.type === 'text' && !el.latex && !el.content?.includes('<table')
4775
- ? isClickOnTextCharacters(e, `editable-${el.id}`)
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}`))
4776
5021
  : ((container && (container === target || container.contains(target))) ||
4777
5022
  (canvasElDom && (canvasElDom === target || canvasElDom.contains(target))))
4778
- if (isEditingText.value && selectedElementId.value === el.id && isInsideEditingContainer) {
5023
+ if (isEditingThisEl && isInsideEditingContainer) {
5024
+ justSelectedElement = true
4779
5025
  return
4780
5026
  }
4781
5027
 
@@ -6663,13 +6909,21 @@ function toggleQuickFormatPainter(el: any, continuous = false) {
6663
6909
  }
6664
6910
  shapeFormatPainter.value = null
6665
6911
  } else if (el) {
6666
- // 1. Check if there is an active text selection
6667
- const textFmt = getFormatFromSelection(savedSelectionRange)
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
6668
6919
  if (textFmt) {
6669
6920
  if (continuous) textFmt.__continuous = true
6921
+ if (isEditingText.value) {
6922
+ checkAndExitEditText(undefined, true)
6923
+ }
6670
6924
  shapeFormatPainter.value = textFmt
6671
6925
  copyFormatTime = Date.now()
6672
- notify(continuous ? '已开启连续文本格式刷,划选目标文本进行应用,按 Esc 退出' : '已复制文本格式,请划选目标文本进行应用')
6926
+ notify(continuous ? '已开启连续文本格式刷,划选或点击目标文本进行应用,按 Esc 退出' : '已复制文本格式,请划选或点击目标文本进行应用')
6673
6927
  return
6674
6928
  }
6675
6929
 
@@ -6678,6 +6932,9 @@ function toggleQuickFormatPainter(el: any, continuous = false) {
6678
6932
  if (fmt) {
6679
6933
  fmt.mode = 'element'
6680
6934
  if (continuous) fmt.__continuous = true
6935
+ if (isEditingText.value) {
6936
+ checkAndExitEditText(undefined, true)
6937
+ }
6681
6938
  shapeFormatPainter.value = fmt
6682
6939
  copyFormatTime = Date.now()
6683
6940
  notify(continuous ? '已开启连续格式刷,按 Esc 键或再次点击退出' : '已复制格式,点击其他元素进行应用')
@@ -8319,7 +8576,7 @@ async function handleGlobalPaste(e: ClipboardEvent) {
8319
8576
  : (el.type === 'line'
8320
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(',')}`
8321
8578
  : 'frozen'))
8322
- : `${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}`
8323
8580
  ]"
8324
8581
  :class="{
8325
8582
  selected: selectedElementIds.includes(el.id),
@@ -8923,12 +9180,12 @@ async function handleGlobalPaste(e: ClipboardEvent) {
8923
9180
  :selected-element-keypoints="selectedElementKeypoints"
8924
9181
  :get-resize-cursor="getResizeCursor"
8925
9182
  :zoom-ratio="zoomRatio"
8926
- @resize-start="(ev, el, handle) => startResize(ev, el, handle)"
8927
- @rotate-start="(ev, el) => startRotate(ev, el)"
8928
- @keypoint-drag-start="(ev, el, idx) => startDragKeypoint(ev, el, idx)"
8929
- @line-point-drag-start="(ev, el, pt) => startDragLinePoint(ev, el, pt)"
8930
- @line-control-point-drag-start="(ev, el, t) => startDragLineControlPoint(ev, el, t)"
8931
- @crop-start="(ev, el, handle) => startInteractiveCrop(ev, el, handle)"
9183
+ @resize-start="(ev, el, handle) => { justSelectedElement = true; startResize(ev, el, handle) }"
9184
+ @rotate-start="(ev, el) => { justSelectedElement = true; startRotate(ev, el) }"
9185
+ @keypoint-drag-start="(ev, el, idx) => { justSelectedElement = true; startDragKeypoint(ev, el, idx) }"
9186
+ @line-point-drag-start="(ev, el, pt) => { justSelectedElement = true; startDragLinePoint(ev, el, pt) }"
9187
+ @line-control-point-drag-start="(ev, el, t) => { justSelectedElement = true; startDragLineControlPoint(ev, el, t) }"
9188
+ @crop-start="(ev, el, handle) => { justSelectedElement = true; startInteractiveCrop(ev, el, handle) }"
8932
9189
  />
8933
9190
  </div>
8934
9191
 
@@ -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>