jvs-ppt-ui 0.0.34 → 0.0.36

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jvs-ppt-ui",
3
3
  "private": false,
4
- "version": "0.0.34",
4
+ "version": "0.0.36",
5
5
  "type": "module",
6
6
  "main": "./dist/lib/jvs-ppt-ui.umd.js",
7
7
  "module": "./dist/lib/jvs-ppt-ui.es.js",
@@ -69,7 +69,7 @@ const {
69
69
  showSearchPanel, showSelectionPanel, activeSearchTab, searchText, replaceText, isCaseSensitive, searchResults, currentResultIndex,
70
70
  nextSearchMatch, prevSearchMatch, replaceCurrent, replaceAll, formulaDialogVisible, currentEditingFormulaEl, renderLatexToSvg,
71
71
  editingElementId, symbolPanelVisible, addElement, isPresenting, startPresentation, clipboard, slideClipboard, pasteSlideData, pasteElementsData, copySelectedElements, handleUnifiedPaste, shapeFormatPainter,
72
- activeTab: activeTabRaw, isOpenedFromFloatToolbar, formatedAnimations, logicalWidth, logicalHeight, pauseHistory, isCanvasDragging, activeSlideVersion, addHistorySnapshot, normalizeHtmlFontFamily,
72
+ activeTab: activeTabRaw, isOpenedFromFloatToolbar, formatedAnimations, logicalWidth, logicalHeight, isUndoingRedoing, pauseHistory, isCanvasDragging, activeSlideVersion, addHistorySnapshot, normalizeHtmlFontFamily,
73
73
  globalThemeColor, globalFontColor, globalFontFamily, globalBgColor, getActiveSlideThemeRecipe, croppingElementId,
74
74
  isMasterEditingView, slideMasters, activeMasterId, activeLayoutId, activeLayout, sortSlideElements,
75
75
  selectedSlideIndexes, isMouseOverSlideList, selectAllSlides, deleteSelectedSlides, copySelectedSlides, cutSelectedSlides, duplicateSelectedSlides, duplicateSelectedElements,
@@ -1294,14 +1294,17 @@ watch(
1294
1294
  selectedElement.value?.autoFit?.type
1295
1295
  ],
1296
1296
  () => {
1297
+ if (isUndoingRedoing.value) return
1297
1298
  const el = selectedElement.value
1298
1299
  if (!el) return
1299
1300
  if ((el.type === 'text' || el.type === 'shape') && el.autoFit?.type === 'text') {
1300
1301
  nextTick(() => {
1302
+ if (isUndoingRedoing.value) return
1301
1303
  updateTextFontScale(el)
1302
1304
  })
1303
1305
  } else if (el.type === 'shape' && el.autoFit?.type === 'shape') {
1304
1306
  nextTick(() => {
1307
+ if (isUndoingRedoing.value) return
1305
1308
  syncShapeAutoFitHeight(el)
1306
1309
  })
1307
1310
  }
@@ -1602,11 +1605,17 @@ watch([selectedElementId, isEditingText], () => {
1602
1605
  })
1603
1606
 
1604
1607
  watch(selectedElementId, (newId, oldId) => {
1608
+ if (isUndoingRedoing.value) {
1609
+ isEditingText.value = false
1610
+ quickToolbarOffset.value = { x: 0, y: 0 }
1611
+ return
1612
+ }
1605
1613
  if (oldId && newId !== oldId) {
1606
1614
  const oldContainer = document.getElementById(`editable-${oldId}`)
1607
1615
  if (oldContainer && activeSlide.value) {
1616
+ const wasEditing = isEditingText.value || Boolean(oldContainer.querySelector('td[contenteditable="true"]'))
1608
1617
  const oldEl = activeSlide.value.elements.find((x: any) => x.id === oldId)
1609
- if (oldEl) {
1618
+ if (oldEl && wasEditing) {
1610
1619
  let htmlVal = oldContainer.innerHTML
1611
1620
  if (oldEl.style) {
1612
1621
  if (oldEl.style.fontWeight === 'bold') htmlVal = htmlVal.replace(/font-weight:\s*normal/gi, '')
@@ -1997,6 +2006,9 @@ function handleWindowMouseDown(e: MouseEvent) {
1997
2006
  }
1998
2007
 
1999
2008
  // Deselect active elements
2009
+ if (isEditingText.value) {
2010
+ checkAndExitEditText(undefined, true)
2011
+ }
2000
2012
  isEditingText.value = false
2001
2013
  activePlaceholderMenuElId.value = null
2002
2014
  selectedElementId.value = null
@@ -2081,6 +2093,9 @@ function handleDeselect(e?: MouseEvent) {
2081
2093
  activeTool.value = null
2082
2094
  return
2083
2095
  }
2096
+ if (isEditingText.value) {
2097
+ checkAndExitEditText(undefined, true)
2098
+ }
2084
2099
  isEditingText.value = false
2085
2100
  selectedElementId.value = null
2086
2101
  selectedElementIds.value = []
@@ -3250,6 +3265,12 @@ function stopCreationDrag() {
3250
3265
  createdElement.__isTemporaryNew = true
3251
3266
  }
3252
3267
 
3268
+ const maxOrder = (activeSlide.value.elements || []).reduce((max: number, el: any) => {
3269
+ const o = el?.order !== undefined ? el.order : 0
3270
+ return Math.max(max, o)
3271
+ }, 0)
3272
+ createdElement.order = maxOrder + 1
3273
+
3253
3274
  activeSlide.value.elements.push(createdElement)
3254
3275
  if (createdElement.type === 'line' && (createdElement.startConnection || createdElement.endConnection)) {
3255
3276
  syncSlideConnections(activeSlide.value, logicalWidth.value, logicalHeight.value, [createdElement.id])
@@ -4520,9 +4541,6 @@ function getElementWidthHeight(el: any): { width: number; height: number } {
4520
4541
  const tableEl = dom?.querySelector('table')
4521
4542
  if (tableEl && tableEl.offsetHeight > 0) {
4522
4543
  height = Math.max(height, tableEl.offsetHeight)
4523
- if (el.height && height > el.height) {
4524
- el.height = height
4525
- }
4526
4544
  }
4527
4545
  }
4528
4546
 
@@ -6962,22 +6980,23 @@ function cleanupEmptyTextboxes() {
6962
6980
  if (!activeSlide.value || !activeSlide.value.elements) return
6963
6981
  const toRemove: string[] = []
6964
6982
  activeSlide.value.elements.forEach((el: any) => {
6965
- // 检查 DOM 容器是否有真实内容并同步
6983
+ // 核心保护:只有新建且从未输入过的临时文本框,才检查并清理,绝不覆写或删除历史已有元素!
6984
+ if (!el.__isTemporaryNew) return
6985
+ // Skip element if currently being edited by user
6986
+ if (isEditingText.value && (el.id === selectedElementId.value || el.id === editingElementId.value)) {
6987
+ return
6988
+ }
6966
6989
  const container = document.getElementById(`editable-${el.id}`)
6967
6990
  if (container) {
6968
6991
  const domText = (container.innerText || container.textContent || '').replace(/\u200B/g, '').trim()
6969
- if (domText.length > 0) {
6992
+ if (domText.length > 0 && !isTextEmptyOrPlaceholderPrompt(domText)) {
6970
6993
  if (el.type === 'shape') el.text = container.innerHTML
6971
6994
  else el.content = container.innerHTML
6995
+ delete el.__isTemporaryNew
6972
6996
  return
6973
6997
  }
6974
6998
  }
6975
- // Skip element if currently being edited by user
6976
- if (isEditingText.value && (el.id === selectedElementId.value || el.id === editingElementId.value)) {
6977
- return
6978
- }
6979
- // 核心保护:只有新建且从未输入过的临时文本框,才在内容为空时自动清理,绝不删除历史已有文本框!
6980
- if (el.__isTemporaryNew && el.type === 'text' && !isMasterOrPlaceholder(el) && !el.content?.includes('<table') && !el.latex) {
6999
+ if (el.type === 'text' && !isMasterOrPlaceholder(el) && !el.content?.includes('<table') && !el.latex) {
6981
7000
  if (isTextEmptyOrPlaceholderPrompt(el.content || '')) {
6982
7001
  toRemove.push(el.id)
6983
7002
  }
@@ -8210,7 +8229,7 @@ async function handleGlobalPaste(e: ClipboardEvent) {
8210
8229
  <!-- Master Background Elements Layer (Z-Index 1: Read-only background elements) -->
8211
8230
  <div v-for="el in effectiveMasterElements" :key="`master-el-${el.id}`"
8212
8231
  class="canvas-element master-element-item"
8213
- v-memo="[el.id, isDragging ? 'drag' : `${el.style?.left}_${el.style?.top}_${el.style?.width}_${el.style?.height}`]"
8232
+ v-memo="[el.id, isDragging ? 'drag' : `${el.style?.left}_${el.style?.top}_${el.style?.width}_${el.style?.height}_${el.fill}_${el.color}_${el.style?.fill}_${el.style?.color}_${el.style?.fontFamily}_${activeSlide?.themeId}_${activeSlideVersion}`]"
8214
8233
  :style="{
8215
8234
  position: 'absolute',
8216
8235
  top: el.style?.top || (el.top !== undefined ? `${el.top}px` : '0px'),
@@ -8268,7 +8287,7 @@ async function handleGlobalPaste(e: ClipboardEvent) {
8268
8287
 
8269
8288
  <!-- Layout Placeholders Layer (Z-Index 2: Master layout placeholder boxes) -->
8270
8289
  <div v-for="ph in effectiveLayoutPlaceholders" :key="`ph-${ph.id}`" class="canvas-placeholder-item"
8271
- v-memo="[ph.id, isDragging ? 'drag' : `${ph.style?.left}_${ph.style?.top}_${ph.style?.width}_${ph.style?.height}_${isMasterEditingView}`]"
8290
+ v-memo="[ph.id, isDragging ? 'drag' : `${ph.style?.left}_${ph.style?.top}_${ph.style?.width}_${ph.style?.height}_${isMasterEditingView}_${activeSlideVersion}`]"
8272
8291
  :style="{
8273
8292
  position: 'absolute',
8274
8293
  top: ph.style.top,
@@ -190,7 +190,17 @@ function getElementPattern(el: any): string | undefined {
190
190
  if (!pattern || typeof pattern !== 'string') return undefined
191
191
  const str = pattern.trim()
192
192
  if (!str) return undefined
193
- if (str.startsWith('data:') || str.startsWith('http:') || str.startsWith('https:') || str.startsWith('blob:') || str.startsWith('url(')) {
193
+ if (
194
+ str.startsWith('data:') ||
195
+ str.startsWith('http:') ||
196
+ str.startsWith('https:') ||
197
+ str.startsWith('blob:') ||
198
+ str.startsWith('url(') ||
199
+ str.startsWith('/') ||
200
+ str.startsWith('./') ||
201
+ str.startsWith('../') ||
202
+ /\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)([?#].*)?$/i.test(str)
203
+ ) {
194
204
  return str
195
205
  }
196
206
  return `data:image/png;base64,${str}`
@@ -586,7 +586,16 @@ function getElementPattern(el: any): string | undefined {
586
586
  str = str.replace(/^url\(['"]?/, '').replace(/['"]?\)$/, '').trim()
587
587
  }
588
588
  if (!str) return undefined
589
- if (str.startsWith('data:') || str.startsWith('http:') || str.startsWith('https:') || str.startsWith('blob:')) {
589
+ if (
590
+ str.startsWith('data:') ||
591
+ str.startsWith('http:') ||
592
+ str.startsWith('https:') ||
593
+ str.startsWith('blob:') ||
594
+ str.startsWith('/') ||
595
+ str.startsWith('./') ||
596
+ str.startsWith('../') ||
597
+ /\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)([?#].*)?$/i.test(str)
598
+ ) {
590
599
  return str
591
600
  }
592
601
  return `data:image/png;base64,${str}`