jvs-ppt-ui 0.0.34 → 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.
@@ -1659,6 +1659,14 @@ export function recolorElementsWithRecipe(elements: any[], recipe: StyleRecipe)
1659
1659
  el.style.textColor = textColor
1660
1660
  if (el.text && typeof el.text === 'object') {
1661
1661
  el.text.defaultColor = textColor
1662
+ if (typeof el.text.content === 'string' && el.text.content.includes('<')) {
1663
+ const div = document.createElement('div')
1664
+ div.innerHTML = el.text.content
1665
+ div.querySelectorAll('span, p, font, td, th').forEach((child: any) => {
1666
+ child.style.color = textColor
1667
+ })
1668
+ el.text.content = div.innerHTML
1669
+ }
1662
1670
  }
1663
1671
  if (el.text && typeof el.text === 'string' && el.text.includes('<')) {
1664
1672
  const div = document.createElement('div')
@@ -2000,6 +2008,9 @@ function applyStyleRecipeToSlides(
2000
2008
  return
2001
2009
  }
2002
2010
 
2011
+ // 在修改幻灯片与母版前,先将此前尚未落盘的防抖编辑(如刚输入的文字、刚插入的幻灯片)独立落盘,保证本次主题切换是单一原子操作
2012
+ flushPendingHistorySnapshot()
2013
+
2003
2014
  let targetSlides: Slide[] = []
2004
2015
  if (effectiveMode === 'all') {
2005
2016
  targetSlides = slides.value
@@ -2094,9 +2105,11 @@ function applyStyleRecipeToSlides(
2094
2105
  globalThemeColor.value = [...recipe.styleColors]
2095
2106
  }
2096
2107
 
2097
- // 同 tick 多页变更 + 急切快照:非 single 模式涉及多页,显式全量标脏(字符串比对会自动去重)
2098
- if (effectiveMode !== 'single') markAllPagesDirty()
2099
- addHistorySnapshot()
2108
+ // 同 tick 多页与母版变更 + 急切快照:single 模式同样可能锁定其余幻灯片默认主题并同步当前母版,显式全量标脏(字符串比对会自动去重)
2109
+ markAllPagesDirty()
2110
+ for (let i = 0; i < slideMasters.value.length; i++) dirtyMasterIndexes.add(i)
2111
+ addHistorySnapshot(true)
2112
+ syncDOMWithRestoredSlides()
2100
2113
  if (effectiveMode === 'all') {
2101
2114
  notify(`已应用主题「${recipe.name}」到全部幻灯片与母版`)
2102
2115
  } else if (effectiveMode === 'single') {
@@ -2406,10 +2419,11 @@ watch(activeIndex, (newIdx) => {
2406
2419
  if (curSlide?.themeId && !isMasterEditingView.value) {
2407
2420
  const resolved = resolveSlideMasterAndLayout(curSlide)
2408
2421
  const master = slideMasters.value.find(m => m.id === resolved.masterId) || slideMasters.value[0]
2409
- if (master && !(master as any).isImported && (master as any).themeId !== curSlide.themeId) {
2410
- const targetRecipe = getActiveSlideThemeRecipe(curSlide)
2411
- if (targetRecipe) {
2412
- applyStyleRecipeToMaster(targetRecipe, 'single', master.id, true)
2422
+ const matchedRecipe = builtinStyleRecipes.find(r => r.id === curSlide.themeId)
2423
+ if (master && !(master as any).isImported && matchedRecipe && (master as any).themeId !== curSlide.themeId) {
2424
+ const hasOtherSlidesOnMaster = slides.value.some((s, idx) => idx !== newIdx && (s.masterId || 'master-default') === master.id && s.themeId !== curSlide.themeId)
2425
+ if (!hasOtherSlidesOnMaster) {
2426
+ applyStyleRecipeToMaster(matchedRecipe, 'single', master.id, true)
2413
2427
  }
2414
2428
  }
2415
2429
  }
@@ -3002,11 +3016,37 @@ function notify(msg: string) {
3002
3016
  }
3003
3017
 
3004
3018
  // 历史栈按页存 JSON 字符串:每条快照是 string[](每页一条),未变页的字符串引用跨快照共享,
3005
- // 编辑只序列化脏页、撤销只解析变更页;每条快照对应的激活页仍记在平行数组中,翻页只改一个数字
3019
+ // 编辑只序列化脏页、撤销只解析变更页;每条快照对应的激活页、母版快照与全局主题状态记在平行数组中
3020
+ interface HistoryGlobalThemeState {
3021
+ fontFamily: string
3022
+ fontColor: string
3023
+ bgColor: string
3024
+ themeColor: string[]
3025
+ }
3026
+
3006
3027
  const historyStack = ref<string[][]>([])
3007
3028
  const historyIndex = ref(-1)
3008
3029
  const isUndoingRedoing = ref(false)
3009
3030
  let historyActiveIndexes: number[] = []
3031
+ let historyMasterSnapshots: string[][] = []
3032
+ let historyGlobalStates: HistoryGlobalThemeState[] = []
3033
+
3034
+ function captureGlobalThemeState(): HistoryGlobalThemeState {
3035
+ return {
3036
+ fontFamily: globalFontFamily.value,
3037
+ fontColor: globalFontColor.value,
3038
+ bgColor: globalBgColor.value,
3039
+ themeColor: Array.isArray(globalThemeColor.value) ? [...globalThemeColor.value] : []
3040
+ }
3041
+ }
3042
+
3043
+ function restoreGlobalThemeState(state?: HistoryGlobalThemeState) {
3044
+ if (!state) return
3045
+ globalFontFamily.value = state.fontFamily
3046
+ globalFontColor.value = state.fontColor
3047
+ globalBgColor.value = state.bgColor
3048
+ globalThemeColor.value = [...state.themeColor]
3049
+ }
3010
3050
 
3011
3051
  const masterHistoryStack = ref<string[][]>([])
3012
3052
  const masterHistoryIndex = ref(-1)
@@ -3117,13 +3157,16 @@ function initHistory() {
3117
3157
 
3118
3158
  currentPageStrs = slides.value.map(serializePage)
3119
3159
  currentPageIds = slides.value.map(s => s && s.id)
3160
+ currentMasterStrs = slideMasters.value.map(serializePage)
3161
+ currentMasterIds = slideMasters.value.map(m => m && m.id)
3162
+
3120
3163
  historyStack.value = [currentPageStrs.slice()]
3121
3164
  historyActiveIndexes = [activeIndex.value]
3165
+ historyMasterSnapshots = [currentMasterStrs.slice()]
3166
+ historyGlobalStates = [captureGlobalThemeState()]
3122
3167
  historyIndex.value = 0
3123
3168
 
3124
3169
  // 母版历史独立初始化(导入/重置演示文稿时同样清空)
3125
- currentMasterStrs = slideMasters.value.map(serializePage)
3126
- currentMasterIds = slideMasters.value.map(m => m && m.id)
3127
3170
  masterHistoryStack.value = [currentMasterStrs.slice()]
3128
3171
  masterHistoryActiveMids = [activeMasterId.value || '']
3129
3172
  masterHistoryActiveLids = [activeLayoutId.value || '']
@@ -3135,27 +3178,41 @@ function syncActiveEditingTextToElement() {
3135
3178
  if (typeof document === 'undefined' || !slides.value) return
3136
3179
  const curSlide = slides.value[activeIndex.value]
3137
3180
  if (!curSlide || !curSlide.elements) return
3138
- curSlide.elements.forEach((el: any) => {
3139
- if (el && (el.type === 'text' || el.type === 'shape')) {
3140
- const container = document.getElementById(`editable-${el.id}`)
3141
- const isEditingContainer = Boolean(
3142
- container &&
3143
- (container.getAttribute('contenteditable') === 'true' ||
3144
- (document.activeElement && container.contains(document.activeElement)))
3145
- )
3146
- if (container && isEditingContainer && (!el.content || !el.content.includes('<table'))) {
3147
- const htmlVal = container.innerHTML
3148
- if (el.type === 'shape') {
3149
- // 空 DOM 抓到 '' 时不能给无文本 shape 制造 text:"" 新键:
3150
- // 语义等价但字符串不等,会被当作变更推入幽灵快照,导致 undo 永远撤不到底
3151
- const isEmptyNoop = htmlVal === '' && !el.text
3152
- if (!isEmptyNoop && el.text !== htmlVal) el.text = htmlVal
3153
- } else if (el.content !== htmlVal) {
3154
- el.content = htmlVal
3181
+ const syncList = (elements: any[]) => {
3182
+ elements.forEach((el: any) => {
3183
+ if (!el) return
3184
+ if (el.type === 'group' && Array.isArray(el.elements)) {
3185
+ syncList(el.elements)
3186
+ return
3187
+ }
3188
+ if (el.type === 'text' || el.type === 'shape') {
3189
+ const container = document.getElementById(`editable-${el.id}`)
3190
+ const isEditingContainer = Boolean(
3191
+ container &&
3192
+ (container.getAttribute('contenteditable') === 'true' ||
3193
+ (document.activeElement && container.contains(document.activeElement)))
3194
+ )
3195
+ if (container && isEditingContainer && (!el.content || !el.content.includes('<table'))) {
3196
+ const htmlVal = container.innerHTML
3197
+ if (el.type === 'shape') {
3198
+ // 空 DOM 抓到 '' 时不能给无文本 shape 制造 text:"" 新键:
3199
+ // 语义等价但字符串不等,会被当作变更推入幽灵快照,导致 undo 永远撤不到底
3200
+ const isEmptyNoop = htmlVal === '' && !el.text
3201
+ if (!isEmptyNoop) {
3202
+ if (el.text && typeof el.text === 'object') {
3203
+ if (el.text.content !== htmlVal) el.text.content = htmlVal
3204
+ } else if (el.text !== htmlVal) {
3205
+ el.text = htmlVal
3206
+ }
3207
+ }
3208
+ } else if (el.content !== htmlVal) {
3209
+ el.content = htmlVal
3210
+ }
3155
3211
  }
3156
3212
  }
3157
- }
3158
- })
3213
+ })
3214
+ }
3215
+ syncList(curSlide.elements)
3159
3216
  }
3160
3217
 
3161
3218
  function syncDOMWithRestoredSlides() {
@@ -3163,27 +3220,56 @@ function syncDOMWithRestoredSlides() {
3163
3220
  if (typeof document === 'undefined' || !slides.value) return
3164
3221
  const curSlide = slides.value[activeIndex.value]
3165
3222
  if (!curSlide || !curSlide.elements) return
3166
- curSlide.elements.forEach((el: any) => {
3167
- if (el && (el.type === 'text' || el.type === 'shape')) {
3168
- const container = document.getElementById(`editable-${el.id}`)
3169
- if (container && (!el.content || !el.content.includes('<table'))) {
3170
- const freshVal = el.type === 'shape' ? (el.text || '') : (el.content || '')
3171
- container.innerHTML = freshVal
3223
+ const syncList = (elements: any[]) => {
3224
+ elements.forEach((el: any) => {
3225
+ if (!el) return
3226
+ if (el.type === 'group' && Array.isArray(el.elements)) {
3227
+ syncList(el.elements)
3228
+ return
3172
3229
  }
3173
- }
3174
- })
3230
+ if (el.type === 'text' || el.type === 'shape' || el.type === 'table') {
3231
+ const container = document.getElementById(`editable-${el.id}`)
3232
+ if (!container || el.latex) return
3233
+ if (el.type === 'shape') {
3234
+ let rawText = ''
3235
+ if (typeof el.text === 'string') rawText = el.text
3236
+ else if (el.text && typeof el.text === 'object') rawText = el.text.content || el.text.text || ''
3237
+ if (rawText && (/^[Mm]\s*[-+]?\d/.test(rawText.trim()) || rawText === 'rect' || rawText === 'circle' || rawText === 'triangle')) {
3238
+ rawText = ''
3239
+ }
3240
+ const freshVal = normalizeHtmlFontFamily(rawText)
3241
+ if (container.innerHTML !== freshVal) container.innerHTML = freshVal
3242
+ } else {
3243
+ const freshVal = normalizeHtmlFontFamily(el.content || '')
3244
+ if (container.innerHTML !== freshVal) container.innerHTML = freshVal
3245
+ }
3246
+ }
3247
+ })
3248
+ }
3249
+ syncList(curSlide.elements)
3175
3250
  })
3176
3251
  }
3177
3252
 
3178
- function addHistorySnapshot() {
3253
+ function addHistorySnapshot(skipDomSync = false) {
3179
3254
  if (isUndoingRedoing.value || pauseHistory.value) return
3180
- syncActiveEditingTextToElement()
3255
+ if (historySnapshotTimer) {
3256
+ clearTimeout(historySnapshotTimer)
3257
+ historySnapshotTimer = null
3258
+ }
3259
+ if (historyIdleCallbackId && typeof window !== 'undefined' && 'cancelIdleCallback' in window) {
3260
+ window.cancelIdleCallback(historyIdleCallbackId)
3261
+ historyIdleCallbackId = null
3262
+ }
3263
+ if (!skipDomSync) {
3264
+ syncActiveEditingTextToElement()
3265
+ }
3181
3266
  // 连接线吸附是 flush:'post' 的深度 watcher,在手动快照之后才执行:若快照先落盘,
3182
3267
  // 吸附结果会被防抖 watcher 再推一条幽灵条目(同一操作两条历史,撤销第一步看似无效;
3183
3268
  // 还原旧条目还会让吸附反复重推导,undo 前的 flush 不断推新条目,撤销指针原地打转)。
3184
3269
  // 序列化前先就地收敛一次(拖拽 stopDrag 里显式调 syncSlideConnections 同理),幂等无副作用。
3185
3270
  settleActiveSlideConnections()
3186
3271
  ensurePageWatchers()
3272
+ ensureMasterWatchers()
3187
3273
 
3188
3274
  const __perfT0 = performance.now()
3189
3275
  const n = slides.value.length
@@ -3212,6 +3298,31 @@ function addHistorySnapshot() {
3212
3298
  currentPageStrs.length = n
3213
3299
  dirtyPageIndexes.clear()
3214
3300
 
3301
+ // 同步检测普通视图下关联的母版变更(例如单页/整册切换主题、插入带独立母版的模板页)
3302
+ const mn = slideMasters.value.length
3303
+ const masterStructural = mn !== currentMasterStrs.length || masterWatchers.length !== mn
3304
+ const masterCandidates: Set<number> = new Set(masterStructural ? undefined : dirtyMasterIndexes)
3305
+ if (!masterStructural) {
3306
+ for (let i = 0; i < mn; i++) {
3307
+ if (slideMasters.value[i]?.id !== currentMasterIds[i]) masterCandidates.add(i)
3308
+ }
3309
+ } else {
3310
+ for (let i = 0; i < mn; i++) masterCandidates.add(i)
3311
+ changed = true
3312
+ }
3313
+ for (const i of masterCandidates) {
3314
+ const ms = serializePage(slideMasters.value[i])
3315
+ if (ms !== currentMasterStrs[i]) {
3316
+ currentMasterStrs[i] = ms
3317
+ changed = true
3318
+ }
3319
+ }
3320
+ currentMasterStrs.length = mn
3321
+ currentMasterIds = slideMasters.value.map(m => m && m.id)
3322
+ if (!isMasterEditingView.value) {
3323
+ dirtyMasterIndexes.clear()
3324
+ }
3325
+
3215
3326
  if (!changed) {
3216
3327
  if (import.meta.env.DEV) console.debug(`[perf:addSnapshot-dedup] ${(performance.now() - __perfT0).toFixed(1)}ms pages=${slides.value.length} dirty=${candidates.size}`)
3217
3328
  return
@@ -3220,15 +3331,21 @@ function addHistorySnapshot() {
3220
3331
  if (historyIndex.value >= 0) {
3221
3332
  historyStack.value = historyStack.value.slice(0, historyIndex.value + 1)
3222
3333
  historyActiveIndexes = historyActiveIndexes.slice(0, historyIndex.value + 1)
3334
+ historyMasterSnapshots = historyMasterSnapshots.slice(0, historyIndex.value + 1)
3335
+ historyGlobalStates = historyGlobalStates.slice(0, historyIndex.value + 1)
3223
3336
  }
3224
3337
 
3225
- // 未变页的字符串引用跨快照共享(string 不可变,零拷贝)
3338
+ // 未变页/未变母版的字符串引用跨快照共享(string 不可变,零拷贝)
3226
3339
  historyStack.value.push(currentPageStrs.slice())
3227
3340
  historyActiveIndexes.push(activeIndex.value)
3341
+ historyMasterSnapshots.push(currentMasterStrs.slice())
3342
+ historyGlobalStates.push(captureGlobalThemeState())
3228
3343
 
3229
3344
  if (historyStack.value.length > 15) {
3230
3345
  historyStack.value.shift()
3231
3346
  historyActiveIndexes.shift()
3347
+ historyMasterSnapshots.shift()
3348
+ historyGlobalStates.shift()
3232
3349
  }
3233
3350
 
3234
3351
  historyIndex.value = historyStack.value.length - 1
@@ -3246,6 +3363,14 @@ function addHistorySnapshot() {
3246
3363
 
3247
3364
  function addMasterHistorySnapshot() {
3248
3365
  if (isUndoingRedoing.value || pauseHistory.value) return
3366
+ if (masterSnapshotTimer) {
3367
+ clearTimeout(masterSnapshotTimer)
3368
+ masterSnapshotTimer = null
3369
+ }
3370
+ if (masterIdleCallbackId && typeof window !== 'undefined' && 'cancelIdleCallback' in window) {
3371
+ window.cancelIdleCallback(masterIdleCallbackId)
3372
+ masterIdleCallbackId = null
3373
+ }
3249
3374
  ensureMasterWatchers()
3250
3375
 
3251
3376
  const n = slideMasters.value.length
@@ -3381,7 +3506,11 @@ function ensureMasterWatchers() {
3381
3506
  if (isUndoingRedoing.value) return
3382
3507
  dirtyMasterIndexes.add(i)
3383
3508
  slidesRevision.value++
3384
- scheduleMasterHistorySnapshot()
3509
+ if (isMasterEditingView.value) {
3510
+ scheduleMasterHistorySnapshot()
3511
+ } else {
3512
+ scheduleHistorySnapshot()
3513
+ }
3385
3514
  }, { deep: true }))
3386
3515
  }
3387
3516
  }
@@ -3389,7 +3518,11 @@ function ensureMasterWatchers() {
3389
3518
  watch(() => slideMasters.value.length, () => {
3390
3519
  ensureMasterWatchers()
3391
3520
  slidesRevision.value++
3392
- scheduleMasterHistorySnapshot()
3521
+ if (isMasterEditingView.value) {
3522
+ scheduleMasterHistorySnapshot()
3523
+ } else {
3524
+ scheduleHistorySnapshot()
3525
+ }
3393
3526
  })
3394
3527
 
3395
3528
  // 切换母版/版式只更新栈顶快照的激活状态(与 activeIndex 同理),不产生新历史记录
@@ -3490,6 +3623,13 @@ function undo() {
3490
3623
  slides.value = applyHistoryEntry<Slide>(entry, currentPageStrs, slides.value).list
3491
3624
  currentPageStrs = entry.slice()
3492
3625
  currentPageIds = slides.value.map(s => s && s.id)
3626
+ const masterEntry = historyMasterSnapshots[historyIndex.value]
3627
+ if (masterEntry) {
3628
+ slideMasters.value = applyHistoryEntry<SlideMaster>(masterEntry, currentMasterStrs, slideMasters.value).list
3629
+ currentMasterStrs = masterEntry.slice()
3630
+ currentMasterIds = slideMasters.value.map(m => m && m.id)
3631
+ }
3632
+ restoreGlobalThemeState(historyGlobalStates[historyIndex.value])
3493
3633
  activeIndex.value = historyActiveIndexes[historyIndex.value]
3494
3634
  selectedElementId.value = null
3495
3635
  selectedElementIds.value = []
@@ -3542,6 +3682,13 @@ function redo() {
3542
3682
  slides.value = applyHistoryEntry<Slide>(entry, currentPageStrs, slides.value).list
3543
3683
  currentPageStrs = entry.slice()
3544
3684
  currentPageIds = slides.value.map(s => s && s.id)
3685
+ const masterEntry = historyMasterSnapshots[historyIndex.value]
3686
+ if (masterEntry) {
3687
+ slideMasters.value = applyHistoryEntry<SlideMaster>(masterEntry, currentMasterStrs, slideMasters.value).list
3688
+ currentMasterStrs = masterEntry.slice()
3689
+ currentMasterIds = slideMasters.value.map(m => m && m.id)
3690
+ }
3691
+ restoreGlobalThemeState(historyGlobalStates[historyIndex.value])
3545
3692
  activeIndex.value = historyActiveIndexes[historyIndex.value]
3546
3693
  selectedElementId.value = null
3547
3694
  selectedElementIds.value = []
@@ -4061,6 +4208,12 @@ function pasteElementsData(elementsArray: any[], options?: { sourceWidth?: numbe
4061
4208
  updateGroupBounds(newEl)
4062
4209
  }
4063
4210
 
4211
+ const maxOrder = (activeSlide.value!.elements || []).reduce((max: number, item: any, idx: number) => {
4212
+ const o = typeof item?.order === 'number' ? item.order : (idx + 1)
4213
+ return o > max ? o : max
4214
+ }, 0)
4215
+ newEl.order = maxOrder + 1
4216
+
4064
4217
  activeSlide.value!.elements.push(newEl)
4065
4218
  pastedIds.push(newEl.id)
4066
4219
  })
@@ -6384,7 +6537,17 @@ function extractPatternFromFill(el: any): string | undefined {
6384
6537
  if (!pattern || typeof pattern !== 'string') return undefined
6385
6538
  const str = pattern.trim()
6386
6539
  if (!str) return undefined
6387
- if (str.startsWith('data:') || str.startsWith('http:') || str.startsWith('https:') || str.startsWith('blob:') || str.startsWith('url(')) {
6540
+ if (
6541
+ str.startsWith('data:') ||
6542
+ str.startsWith('http:') ||
6543
+ str.startsWith('https:') ||
6544
+ str.startsWith('blob:') ||
6545
+ str.startsWith('url(') ||
6546
+ str.startsWith('/') ||
6547
+ str.startsWith('./') ||
6548
+ str.startsWith('../') ||
6549
+ /\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)([?#].*)?$/i.test(str)
6550
+ ) {
6388
6551
  return str
6389
6552
  }
6390
6553
  return `data:image/png;base64,${str}`
@@ -7728,12 +7891,15 @@ function preprocessImportedSlides(slides: any[]) {
7728
7891
  slide.bgType = bgInfo.bgType
7729
7892
  if (!slide.elements) continue
7730
7893
 
7731
- // 导入时按 PPT 原始 order 排序一次并规范化,确保页面元素数组本身就是最权威的层级顺序
7732
- slide.elements.sort((a: any, b: any) => {
7733
- const orderA = a?.order !== undefined ? a.order : (parseFloat(a?.style?.zIndex) || 0)
7734
- const orderB = b?.order !== undefined ? b.order : (parseFloat(b?.style?.zIndex) || 0)
7735
- return orderA - orderB
7736
- })
7894
+ // 导入时仅对原始 PPTX 解析结构(尚无 style.left)按 order 排序,已由编辑器导出的页面元素数组本身即为权威层级顺序
7895
+ const isEditorExportedSlide = slide.elements.every((el: any) => el && el.style && el.style.left !== undefined)
7896
+ if (!isEditorExportedSlide) {
7897
+ slide.elements.sort((a: any, b: any) => {
7898
+ const orderA = a?.order !== undefined ? a.order : (parseFloat(a?.style?.zIndex) || 0)
7899
+ const orderB = b?.order !== undefined ? b.order : (parseFloat(b?.style?.zIndex) || 0)
7900
+ return orderA - orderB
7901
+ })
7902
+ }
7737
7903
  slide.elements.forEach((el: any, idx: number) => {
7738
7904
  if (el) el.order = idx + 1
7739
7905
  })
@@ -9420,12 +9586,12 @@ export function useSlides() {
9420
9586
  }
9421
9587
  }
9422
9588
 
9423
- const curRecipe = getActiveSlideThemeRecipe(curSlide)
9424
- if (curRecipe && activeMasterId.value && curMaster && curSlide.themeId && curSlide.themeId !== (curMaster as any).themeId) {
9425
- applyStyleRecipeToMaster(curRecipe, 'single', activeMasterId.value)
9426
- } else if (curMaster && curRecipe) {
9427
- ;(curMaster as any).themeId = curRecipe.id
9428
- ;(curMaster as any).themeName = curRecipe.name
9589
+ const matchedRecipe = curSlide.themeId ? builtinStyleRecipes.find(r => r.id === curSlide.themeId) : null
9590
+ if (matchedRecipe && activeMasterId.value && curMaster && !(curMaster as any).isImported && curSlide.themeId !== (curMaster as any).themeId) {
9591
+ applyStyleRecipeToMaster(matchedRecipe, 'single', activeMasterId.value)
9592
+ } else if (curMaster && matchedRecipe && !(curMaster as any).isImported) {
9593
+ ;(curMaster as any).themeId = matchedRecipe.id
9594
+ ;(curMaster as any).themeName = matchedRecipe.name
9429
9595
  }
9430
9596
  }
9431
9597
 
@@ -280,8 +280,8 @@ const asyncPitchDeckSlides = [
280
280
  showMasterElements: false,
281
281
  elements: [
282
282
  makeRectEl('a1-line', 96, 152, 168, 3, '#A78BFA'),
283
- makeTextEl('a1-comp', 'Company name', 96, 168, 360, 40, { fontSize: 24, color: '#18181B' }),
284
- makeTextEl('a1-title', 'Pitch\nDeck', 96, 360, 480, 240, { fontSize: 96, color: '#111827', fontWeight: 'bold', lineHeight: 1.05 }),
283
+ makeTextEl('a1-comp', '公司名称', 96, 168, 360, 40, { fontSize: 24, color: '#18181B' }),
284
+ makeTextEl('a1-title', '提案表', 96, 360, 480, 240, { fontSize: 96, color: '#111827', fontWeight: 'bold', lineHeight: 1.05 }),
285
285
  // Right phone mockup & floating purple card (matching user screenshot)
286
286
  makeRectEl('a1-phone-border', 780, 120, 360, 580, '#111827', { borderRadius: 44 }),
287
287
  makeRectEl('a1-phone-screen', 794, 134, 332, 552, '#FFFFFF', { borderRadius: 34 }),
@@ -686,7 +686,7 @@ const defaultBuiltinTemplateList: SlideTemplateItem[] = [
686
686
  name: 'Remote Learning Lesson Plan',
687
687
  fileName: 'Remote Learning Lesson Plan.json',
688
688
  category: 'Education',
689
- slidesCount: 30,
689
+ slidesCount: 29,
690
690
  jsonUrl: '/templates/' + encodeURIComponent('Remote Learning Lesson Plan.json'),
691
691
  slides: [remoteLearningSlides[0]],
692
692
  loaded: false
@@ -733,6 +733,10 @@ export function rewriteSlideTemplateAssetUrls(slide: any, baseUrl?: string): any
733
733
  el.content = replaceUrl(el.content)
734
734
  }
735
735
  if (typeof el.poster === 'string') el.poster = replaceUrl(el.poster)
736
+ if (typeof el.pattern === 'string') el.pattern = replaceUrl(el.pattern)
737
+ if (el.style && typeof el.style.pattern === 'string') {
738
+ el.style.pattern = replaceUrl(el.style.pattern)
739
+ }
736
740
  if (el.style && typeof el.style.backgroundImage === 'string') {
737
741
  el.style.backgroundImage = replaceUrl(el.style.backgroundImage)
738
742
  }
package/src/style.css CHANGED
@@ -133,8 +133,8 @@
133
133
  font-style: italic !important;
134
134
  }
135
135
 
136
- /* 强行重置外部宿主全局 button 样式侵入 */
137
- .jvs-ppt-editor-root button:not(.el-button) {
136
+ /* 强行重置外部宿主全局 button 样式侵入(使用 :where 将权重降至 (0,0,1),彻底避免压过任何单类名 (0,1,0) 或 scoped (0,2,0) 按钮样式) */
137
+ :where(.jvs-ppt-editor-root) button:where(:not(.el-button)) {
138
138
  font-family: inherit;
139
139
  font-size: inherit;
140
140
  line-height: normal;
@@ -161,7 +161,7 @@
161
161
  }
162
162
 
163
163
  /* 强行重置外部宿主全局 button 样式侵入(防 text-indent, line-height, text-transform, pseudo elements) */
164
- .jvs-ppt-editor-root button:not(.el-button) {
164
+ :where(.jvs-ppt-editor-root) button:where(:not(.el-button)) {
165
165
  box-sizing: border-box !important;
166
166
  text-transform: none !important;
167
167
  text-indent: 0 !important;
@@ -244,7 +244,17 @@ export function getElementPattern(el: any): string | undefined {
244
244
  if (!pattern || typeof pattern !== 'string') return undefined
245
245
  const str = pattern.trim()
246
246
  if (!str) return undefined
247
- if (str.startsWith('data:') || str.startsWith('http:') || str.startsWith('https:') || str.startsWith('blob:') || str.startsWith('url(')) {
247
+ if (
248
+ str.startsWith('data:') ||
249
+ str.startsWith('http:') ||
250
+ str.startsWith('https:') ||
251
+ str.startsWith('blob:') ||
252
+ str.startsWith('url(') ||
253
+ str.startsWith('/') ||
254
+ str.startsWith('./') ||
255
+ str.startsWith('../') ||
256
+ /\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)([?#].*)?$/i.test(str)
257
+ ) {
248
258
  return str
249
259
  }
250
260
  return `data:image/png;base64,${str}`