jvs-ppt-ui 0.0.29 → 0.0.32

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.
@@ -87,7 +87,7 @@ export interface SlideElement {
87
87
  curve?: [number, number]
88
88
  cubic?: [[number, number], [number, number]]
89
89
  customControlPoints?: boolean
90
- chartType?: 'bar' | 'horizontal-bar' | 'line' | 'area' | 'scatter' | 'pie' | 'donut' | 'radar'
90
+ chartType?: 'bar' | 'percent-bar' | 'stacked-bar' | 'horizontal-bar' | 'stacked-horizontal-bar' | 'line' | 'compare-line' | 'step-line' | 'area' | 'stacked-area' | 'scatter' | 'pie' | 'donut' | 'rose-pie' | 'rose-donut' | 'radar' | string
91
91
  showAxes?: boolean
92
92
  showAxisTitles?: boolean
93
93
  showTitle?: boolean
@@ -302,6 +302,7 @@ export interface PresetTheme {
302
302
 
303
303
  import { presetThemes, builtinStyleRecipes, type StyleRecipe } from './presetThemes'
304
304
  import { generateMonoPalette } from '../utils/palette'
305
+ import { isPitchTemplateData, convertPitchTemplateToDeck } from '../utils/pitchConverter'
305
306
 
306
307
  // Global reactive states
307
308
  const presentationTitle = ref('未命名演示文稿')
@@ -1858,10 +1859,17 @@ export function getEffectiveSlideBackground(slide?: any): any {
1858
1859
  }
1859
1860
  }
1860
1861
 
1861
- // 3. 向上继承匹配版式或母版的背景
1862
+ // 3. 向上继承匹配版式或母版的背景(非外部导入母版时,幻灯片自身的纯白背景即为该页独立背景,不随母版主题色变更被覆盖)
1862
1863
  const { masterId, layoutId } = resolveSlideMasterAndLayout(slide)
1863
1864
  const master = slideMasters.value.find(m => m && m.id === masterId) || slideMasters.value[0]
1864
1865
  const layout = layoutId && master ? master.layouts?.find(l => l && l.id === layoutId) : null
1866
+ const isImportedMaster = Boolean((master as any)?.isImported)
1867
+ const masterThemeId = (master as any)?.themeId || (!isImportedMaster ? 'tech-blue' : '')
1868
+ if (directBg && typeof directBg === 'string' && !['transparent', 'none', ''].includes(directBg.trim().toLowerCase())) {
1869
+ if (!isImportedMaster || (slide.themeId && masterThemeId && slide.themeId !== masterThemeId)) {
1870
+ return formatBareUrlWithMode(directBg, slide.bgImageMode, slide.isPattern)
1871
+ }
1872
+ }
1865
1873
 
1866
1874
  if (layout?.background && layout.background !== '#ffffff' && layout.background !== 'none') {
1867
1875
  return formatBareUrlWithMode(layout.background, (layout as any).bgImageMode, (layout as any).isPattern)
@@ -1876,7 +1884,8 @@ export function getEffectiveSlideBackground(slide?: any): any {
1876
1884
  function applyStyleRecipeToMaster(
1877
1885
  recipe: StyleRecipe,
1878
1886
  mode: boolean | 'all' | 'single' = 'single',
1879
- masterId?: string
1887
+ masterId?: string,
1888
+ silent = false
1880
1889
  ) {
1881
1890
  const isAll = mode === true || mode === 'all'
1882
1891
  const targetMasters = isAll
@@ -1930,12 +1939,14 @@ function applyStyleRecipeToMaster(
1930
1939
  }
1931
1940
 
1932
1941
  // 同 tick 多母版变更 + 急切快照:pre-flush watcher 尚未排空,显式标脏目标母版
1933
- targetMasters.forEach(m => {
1934
- const i = slideMasters.value.indexOf(m)
1935
- if (i >= 0) dirtyMasterIndexes.add(i)
1936
- })
1937
- addMasterHistorySnapshot()
1938
- notify(isAll ? `已应用主题「${recipe.name}」到全部母版` : `已应用主题「${recipe.name}」到当前母版`)
1942
+ if (!silent) {
1943
+ targetMasters.forEach(m => {
1944
+ const i = slideMasters.value.indexOf(m)
1945
+ if (i >= 0) dirtyMasterIndexes.add(i)
1946
+ })
1947
+ addMasterHistorySnapshot()
1948
+ notify(isAll ? `已应用主题「${recipe.name}」到全部母版` : `已应用主题「${recipe.name}」到当前母版`)
1949
+ }
1939
1950
  }
1940
1951
 
1941
1952
  function applyStyleRecipeToSlides(
@@ -1949,10 +1960,12 @@ function applyStyleRecipeToSlides(
1949
1960
  effectiveMode = mode
1950
1961
  }
1951
1962
 
1952
- // 同步更新内置配方库中的对应项
1963
+ // 同步更新内置配方库中的对应项(若为新增自定义主题则追加到配方库)
1953
1964
  const recipeIdx = builtinStyleRecipes.findIndex(r => r.id === recipe.id)
1954
1965
  if (recipeIdx >= 0) {
1955
1966
  builtinStyleRecipes[recipeIdx] = JSON.parse(JSON.stringify(recipe))
1967
+ } else {
1968
+ builtinStyleRecipes.push(JSON.parse(JSON.stringify(recipe)))
1956
1969
  }
1957
1970
 
1958
1971
  // 🌟 母版编辑视图下直接应用到母版与版式
@@ -1992,12 +2005,22 @@ function applyStyleRecipeToSlides(
1992
2005
  }
1993
2006
  })
1994
2007
 
1995
- // 🌟 单页应用时,同时以当前页的主题来设置关联母版的主题色与内容
2008
+ // 🌟 单页应用时,先锁定其余已存在幻灯片自身的主题标识与背景,再同步关联母版与版式以当前选中主题渲染
1996
2009
  if (effectiveMode === 'single' && targetSlides[0]) {
1997
2010
  const curSlide = targetSlides[0]
1998
2011
  const resolved = resolveSlideMasterAndLayout(curSlide)
2012
+ const curMaster = slideMasters.value.find(m => m.id === resolved.masterId) || slideMasters.value[0]
2013
+ const prevMasterThemeId = (curMaster as any)?.themeId || 'tech-blue'
2014
+ slides.value.forEach(s => {
2015
+ if (s !== curSlide) {
2016
+ if (!s.themeId) s.themeId = prevMasterThemeId
2017
+ if ((curMaster as any)?.isImported && (!s.background || s.background === '#ffffff')) {
2018
+ s.background = getEffectiveSlideBackground(s) || '#ffffff'
2019
+ }
2020
+ }
2021
+ })
1999
2022
  if (resolved.masterId) {
2000
- applyStyleRecipeToMaster(recipe, 'single', resolved.masterId)
2023
+ applyStyleRecipeToMaster(recipe, 'single', resolved.masterId, true)
2001
2024
  }
2002
2025
  }
2003
2026
 
@@ -2051,7 +2074,7 @@ function applyStyleRecipeToSlides(
2051
2074
  if (effectiveMode === 'all') {
2052
2075
  notify(`已应用主题「${recipe.name}」到全部幻灯片与母版`)
2053
2076
  } else if (effectiveMode === 'single') {
2054
- notify(`已应用主题「${recipe.name}」到第 ${activeIndex.value + 1} 页及当前母版`)
2077
+ notify(`已应用主题「${recipe.name}」到第 ${activeIndex.value + 1} 页`)
2055
2078
  } else if (effectiveMode === 'used') {
2056
2079
  notify(`已保存主题「${recipe.name}」并同步更新使用该主题的 ${targetSlides.length} 页幻灯片`)
2057
2080
  }
@@ -2117,7 +2140,7 @@ function getEffectiveMasterElementsForSlide(slide: any, recolorWithTheme: boolea
2117
2140
  // 🌟 核心判断:只有当前幻灯片显式指定了与母版不同的主题时,才需要进行母版元素主题重映射!
2118
2141
  // 若幻灯片与母版同属一个主题(例如刚导入 PPT),母版本身的颜色就是最权威的原始效果,直接返回 combined
2119
2142
  const slideThemeId = slide.themeId
2120
- const masterThemeId = (master as any)?.themeId
2143
+ const masterThemeId = (master as any)?.themeId || (!(master as any)?.isImported ? 'tech-blue' : '')
2121
2144
  const needRecolor = recolorWithTheme && slideThemeId && masterThemeId && slideThemeId !== masterThemeId
2122
2145
 
2123
2146
  if (needRecolor) {
@@ -2230,16 +2253,39 @@ function getThemeUsageSlides(themeId: string): number[] {
2230
2253
  return pages
2231
2254
  }
2232
2255
 
2233
- function getThemeUsageLabel(themeId: string): { type: 'all' | 'partial' | 'none'; text: string; pages: number[] } {
2256
+ function formatPageRanges(pages: number[]): string[] {
2257
+ const ranges: string[] = []
2258
+ let i = 0
2259
+ while (i < pages.length) {
2260
+ const start = pages[i]
2261
+ let end = start
2262
+ while (i + 1 < pages.length && pages[i + 1] === end + 1) {
2263
+ i++
2264
+ end = pages[i]
2265
+ }
2266
+ ranges.push(start === end ? `${start}` : (end === start + 1 ? `${start}, ${end}` : `${start}-${end}`))
2267
+ i++
2268
+ }
2269
+ return ranges
2270
+ }
2271
+
2272
+ function getThemeUsageLabel(themeId: string): { type: 'all' | 'partial' | 'none'; text: string; fullText: string; pages: number[] } {
2234
2273
  const pages = getThemeUsageSlides(themeId)
2235
2274
  const total = slides.value ? slides.value.length : 0
2236
2275
  if (total > 0 && pages.length === total) {
2237
- return { type: 'all', text: `全部页面 (共 ${total} 页)`, pages }
2276
+ const text = `全部页面 (共 ${total} 页)`
2277
+ return { type: 'all', text, fullText: text, pages }
2238
2278
  }
2239
2279
  if (pages.length > 0) {
2240
- return { type: 'partial', text: `第 ${pages.join(', ')} 页`, pages }
2280
+ const ranges = formatPageRanges(pages)
2281
+ const fullRangeStr = ranges.join(', ')
2282
+ const fullText = `第 ${pages.join(', ')} 页 (共 ${pages.length} 页)`
2283
+ const text = (ranges.length <= 2 && fullRangeStr.length <= 12)
2284
+ ? `第 ${fullRangeStr} 页`
2285
+ : `第 ${ranges.slice(0, 2).join(', ')} 等 ${pages.length} 页`
2286
+ return { type: 'partial', text, fullText, pages }
2241
2287
  }
2242
- return { type: 'none', text: '未被使用', pages: [] }
2288
+ return { type: 'none', text: '未被使用', fullText: '未被使用', pages: [] }
2243
2289
  }
2244
2290
 
2245
2291
  function getActiveSlideThemeRecipe(targetSlide?: any): StyleRecipe {
@@ -2330,6 +2376,17 @@ watch(activeIndex, (newIdx) => {
2330
2376
  if (!selectedSlideIndexes.value.includes(newIdx)) {
2331
2377
  selectedSlideIndexes.value = [newIdx]
2332
2378
  }
2379
+ const curSlide = slides.value[newIdx]
2380
+ if (curSlide?.themeId && !isMasterEditingView.value) {
2381
+ const resolved = resolveSlideMasterAndLayout(curSlide)
2382
+ const master = slideMasters.value.find(m => m.id === resolved.masterId) || slideMasters.value[0]
2383
+ if (master && !(master as any).isImported && (master as any).themeId !== curSlide.themeId) {
2384
+ const targetRecipe = getActiveSlideThemeRecipe(curSlide)
2385
+ if (targetRecipe) {
2386
+ applyStyleRecipeToMaster(targetRecipe, 'single', master.id, true)
2387
+ }
2388
+ }
2389
+ }
2333
2390
  })
2334
2391
 
2335
2392
  const activeSlide = computed<Slide>({
@@ -8389,6 +8446,26 @@ function importSlides(newSlides: any) {
8389
8446
  revokeSlideBlobUrls(slides.value)
8390
8447
  }
8391
8448
 
8449
+ // 智能识别 Pitch Transit-JSON 模板数据并自动转换为本地 DeckData
8450
+ if (isPitchTemplateData(newSlides)) {
8451
+ const convertedPitchDeck = convertPitchTemplateToDeck(newSlides)
8452
+ return importSlides(convertedPitchDeck)
8453
+ }
8454
+
8455
+ // 若包含 styleRecipes(如 Pitch 转换器生成的自定义多主题配方),注册到 builtinStyleRecipes
8456
+ if (newSlides && typeof newSlides === 'object' && Array.isArray(newSlides.styleRecipes) && newSlides.styleRecipes.length > 0) {
8457
+ for (let i = newSlides.styleRecipes.length - 1; i >= 0; i--) {
8458
+ const recipe = newSlides.styleRecipes[i]
8459
+ if (!recipe || !recipe.id) continue
8460
+ const existingIdx = builtinStyleRecipes.findIndex(r => r.id === recipe.id)
8461
+ if (existingIdx !== -1) {
8462
+ builtinStyleRecipes[existingIdx] = recipe
8463
+ } else {
8464
+ builtinStyleRecipes.unshift(recipe)
8465
+ }
8466
+ }
8467
+ }
8468
+
8392
8469
  // 智能识别 raw PPTX JSON (如来自 jvs-pptxtojson 原生导出的 slides.json) 并代理给 PPT 解析器
8393
8470
  if (pptParserFn && newSlides && typeof newSlides === 'object' && Array.isArray(newSlides.slides) && newSlides.size) {
8394
8471
  const isRawPPTX = (() => {
package/src/style.css CHANGED
@@ -134,7 +134,7 @@
134
134
  }
135
135
 
136
136
  /* 强行重置外部宿主全局 button 样式侵入 */
137
- .jvs-ppt-editor-root button {
137
+ .jvs-ppt-editor-root button: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 {
164
+ .jvs-ppt-editor-root button:not(.el-button) {
165
165
  box-sizing: border-box !important;
166
166
  text-transform: none !important;
167
167
  text-indent: 0 !important;