dsh-ppt 0.27.2 → 0.29.0

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.en.md +23 -22
  3. package/README.md +23 -22
  4. package/docs/USAGE.en.md +2 -0
  5. package/docs/USAGE.md +2 -0
  6. package/docs/VALIDATION.md +8 -0
  7. package/docs/assets/intro/workflow-en-dark.svg +1 -1
  8. package/docs/assets/intro/workflow-en-light.svg +1 -1
  9. package/docs/assets/intro/workflow-en-mobile-dark.svg +1 -1
  10. package/docs/assets/intro/workflow-en-mobile-light.svg +1 -1
  11. package/docs/assets/intro/workflow-zh-dark.svg +1 -1
  12. package/docs/assets/intro/workflow-zh-light.svg +1 -1
  13. package/docs/assets/intro/workflow-zh-mobile-dark.svg +1 -1
  14. package/docs/assets/intro/workflow-zh-mobile-light.svg +1 -1
  15. package/lib/client.js +283 -33
  16. package/lib/execution.d.ts +7 -0
  17. package/lib/execution.js +47 -6
  18. package/lib/tools.js +62 -12
  19. package/lib/types.d.ts +51 -4
  20. package/lib/workbench.js +185 -9
  21. package/package.json +1 -1
  22. package/skills/dsh-ppt/SKILL.md +4 -2
  23. package/skills/dsh-ppt/package.json +1 -1
  24. package/skills/dsh-ppt/references/exemplars.md +116 -0
  25. package/skills/dsh-ppt/scripts/build-deck.mjs +20 -1
  26. package/skills/dsh-ppt/scripts/deck-absorb.mjs +27 -3
  27. package/skills/dsh-ppt/scripts/deck-advanced.mjs +107 -24
  28. package/skills/dsh-ppt/scripts/deck-charts-pro.mjs +1004 -0
  29. package/skills/dsh-ppt/scripts/deck-chrome.mjs +27 -6
  30. package/skills/dsh-ppt/scripts/deck-core.mjs +96 -3
  31. package/skills/dsh-ppt/scripts/deck-covers.mjs +157 -3
  32. package/skills/dsh-ppt/scripts/deck-exemplars.mjs +548 -0
  33. package/skills/dsh-ppt/scripts/deck-layouts.mjs +90 -2
  34. package/skills/dsh-ppt/scripts/deck-showcase.mjs +729 -0
  35. package/skills/dsh-ppt/scripts/deck-upgrader.mjs +618 -0
@@ -479,7 +479,7 @@ function parseBulletToItem(rawBullet, index, layout) {
479
479
  }
480
480
  }
481
481
 
482
- const EXTENDED_ITEM_LAYOUTS = new Set(['sankey', 'value-chain', 'marimekko', 'swot'])
482
+ const EXTENDED_ITEM_LAYOUTS = new Set(['sankey', 'value-chain', 'marimekko', 'swot', 'quadrant', 'radar', 'dumbbell', 'heatmap'])
483
483
 
484
484
  export function normalizeSlideItems(rawItems, layout) {
485
485
  if (!Array.isArray(rawItems) || rawItems.length === 0) return undefined
@@ -505,10 +505,21 @@ export function normalizeSlideItems(rawItems, layout) {
505
505
  const role = stripInlineMarkdown(entry.role ?? '')
506
506
  const conversion = stripInlineMarkdown(entry.conversion ?? '')
507
507
  const icon = stripInlineMarkdown(entry.icon ?? '')
508
+ const avatar = stripInlineMarkdown(entry.avatar ?? '')
509
+ const xNum = entry.x !== undefined && entry.x !== null && entry.x !== '' ? Number(entry.x) : NaN
510
+ const x = Number.isFinite(xNum) ? xNum : undefined
511
+ const yNum = entry.y !== undefined && entry.y !== null && entry.y !== '' ? Number(entry.y) : NaN
512
+ const y = Number.isFinite(yNum) ? yNum : undefined
513
+ const sizeNum = entry.size !== undefined && entry.size !== null && entry.size !== '' ? Number(entry.size) : NaN
514
+ const size = Number.isFinite(sizeNum) ? Math.max(1, sizeNum) : undefined
515
+ const beforeNum = entry.before !== undefined && entry.before !== null && entry.before !== '' ? Number(entry.before) : NaN
516
+ const before = Number.isFinite(beforeNum) ? beforeNum : undefined
517
+ const afterNum = entry.after !== undefined && entry.after !== null && entry.after !== '' ? Number(entry.after) : NaN
518
+ const after = Number.isFinite(afterNum) ? afterNum : undefined
508
519
  const bullets = Array.isArray(entry.bullets ?? entry.items)
509
520
  ? (entry.bullets ?? entry.items).map((b) => cleanRichText(String(b))).filter(Boolean).slice(0, 8)
510
521
  : undefined
511
- if (!title && !text && !value && (!bullets || bullets.length === 0)) return null
522
+ if (!title && !text && !value && x === undefined && before === undefined && (!bullets || bullets.length === 0)) return null
512
523
  return {
513
524
  ...(tag ? { tag } : {}),
514
525
  ...(title ? { title } : {}),
@@ -522,6 +533,12 @@ export function normalizeSlideItems(rawItems, layout) {
522
533
  ...(role ? { role } : {}),
523
534
  ...(conversion ? { conversion } : {}),
524
535
  ...(icon ? { icon } : {}),
536
+ ...(avatar ? { avatar } : {}),
537
+ ...(x !== undefined ? { x } : {}),
538
+ ...(y !== undefined ? { y } : {}),
539
+ ...(size !== undefined ? { size } : {}),
540
+ ...(before !== undefined ? { before } : {}),
541
+ ...(after !== undefined ? { after } : {}),
525
542
  ...(status ? { status } : {}),
526
543
  ...(bullets?.length ? { bullets } : {}),
527
544
  }
@@ -695,6 +712,8 @@ export function ooxmlShape(id, name, boxIn, options = {}) {
695
712
  marginsIn = { l: 0.08, r: 0.08, t: 0.05, b: 0.05 },
696
713
  fontScale = 100000,
697
714
  autofit = true,
715
+ rot = 0,
716
+ vert = '',
698
717
  paragraphs = [],
699
718
  } = options
700
719
 
@@ -731,10 +750,10 @@ export function ooxmlShape(id, name, boxIn, options = {}) {
731
750
  '<p:sp>' +
732
751
  '<p:nvSpPr><p:cNvPr id="' + id + '" name="' + escapeXml(name) + '"/>' +
733
752
  '<p:cNvSpPr' + (txBox ? ' txBox="1"' : '') + '/><p:nvPr/></p:nvSpPr>' +
734
- '<p:spPr><a:xfrm><a:off x="' + b.x + '" y="' + b.y + '"/><a:ext cx="' + b.w + '" cy="' + b.h + '"/></a:xfrm>' +
753
+ '<p:spPr><a:xfrm' + (rot ? ' rot="' + Math.round(rot) + '"' : '') + '><a:off x="' + b.x + '" y="' + b.y + '"/><a:ext cx="' + b.w + '" cy="' + b.h + '"/></a:xfrm>' +
735
754
  '<a:prstGeom prst="' + preset + '">' + avLst + '</a:prstGeom>' +
736
755
  fillXml + lnXml + effectXml + '</p:spPr>' +
737
- '<p:txBody><a:bodyPr wrap="square" rtlCol="0" lIns="' + lIns + '" tIns="' + tIns + '" rIns="' + rIns + '" bIns="' + bIns + '" anchor="' + anchor + '">' +
756
+ '<p:txBody><a:bodyPr wrap="' + (vert ? 'none' : 'square') + '" rtlCol="0"' + (vert ? ' vert="' + escapeXml(vert) + '"' : '') + ' lIns="' + lIns + '" tIns="' + tIns + '" rIns="' + rIns + '" bIns="' + bIns + '" anchor="' + anchor + '">' +
738
757
  fitXml + '</a:bodyPr><a:lstStyle/>' + bodyContent + '</p:txBody>' +
739
758
  '</p:sp>'
740
759
  )
@@ -1172,8 +1191,10 @@ export function renderSurfaceCardPptx(name, box, opts, nextIdFn, chromeCfg, them
1172
1191
  }),
1173
1192
  ]
1174
1193
  if (chromeCfg.cardTopBar) {
1175
- out.push(ooxmlShape(nextIdFn(), name + ' top bar', { x: box.x, y: box.y, w: box.w, h: 0.05 }, {
1176
- preset: 'rect',
1194
+ const barInset = radius > 0 ? Math.min(0.12, (radius / 96) * 0.85) : 0
1195
+ out.push(ooxmlShape(nextIdFn(), name + ' top bar', { x: box.x + barInset, y: box.y, w: Math.max(0.2, box.w - barInset * 2), h: 0.045 }, {
1196
+ preset: radius > 0 ? 'roundRect' : 'rect',
1197
+ adj: radius > 0 ? 50000 : undefined,
1177
1198
  fill: focal ? accentBarColor : tk.hairline,
1178
1199
  }))
1179
1200
  }
@@ -412,6 +412,8 @@ function createSection(heading = '', level = 0, coverOnly = false) {
412
412
  directive: null,
413
413
  formula: '',
414
414
  mermaid: '',
415
+ code: '',
416
+ codeLang: '',
415
417
  takeaway: '',
416
418
  source: '',
417
419
  }
@@ -569,6 +571,10 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
569
571
  let inMermaidFence = false
570
572
  let mermaidFenceMarker = ''
571
573
  let mermaidFenceLines = []
574
+ let inCodeFence = false
575
+ let codeFenceMarker = ''
576
+ let codeFenceLang = ''
577
+ let codeFenceLines = []
572
578
 
573
579
  const flush = () => {
574
580
  if (inMermaidFence && mermaidFenceLines.length > 0) {
@@ -578,6 +584,14 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
578
584
  current.mermaid = current.mermaid ? current.mermaid + '\n' + pendingMermaid : pendingMermaid
579
585
  }
580
586
  }
587
+ if (inCodeFence && codeFenceLines.length > 0) {
588
+ if (current === null) current = createSection()
589
+ const pendingCode = codeFenceLines.join('\n').trimEnd()
590
+ if (pendingCode.trim() !== '') {
591
+ current.code = current.code ? current.code + '\n\n' + pendingCode : pendingCode
592
+ if (!current.codeLang && codeFenceLang) current.codeLang = codeFenceLang
593
+ }
594
+ }
581
595
  if (
582
596
  current !== null &&
583
597
  (current.heading !== '' ||
@@ -585,6 +599,7 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
585
599
  current.paragraphs.length > 0 ||
586
600
  current.formula !== '' ||
587
601
  current.mermaid !== '' ||
602
+ current.code !== '' ||
588
603
  current.table !== null ||
589
604
  current.quote.length > 0 ||
590
605
  current.directive !== null)
@@ -599,6 +614,10 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
599
614
  inMermaidFence = false
600
615
  mermaidFenceMarker = ''
601
616
  mermaidFenceLines = []
617
+ inCodeFence = false
618
+ codeFenceMarker = ''
619
+ codeFenceLang = ''
620
+ codeFenceLines = []
602
621
  }
603
622
 
604
623
  for (const rawLine of body.split('\n')) {
@@ -619,6 +638,24 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
619
638
  continue
620
639
  }
621
640
 
641
+ if (inCodeFence) {
642
+ if (line.startsWith(codeFenceMarker) && new RegExp('^' + codeFenceMarker + '\\s*$').test(line)) {
643
+ if (current === null) current = createSection()
644
+ const joinedCode = codeFenceLines.join('\n').trimEnd()
645
+ if (joinedCode.trim() !== '') {
646
+ current.code = current.code ? current.code + '\n\n' + joinedCode : joinedCode
647
+ if (!current.codeLang && codeFenceLang) current.codeLang = codeFenceLang
648
+ }
649
+ inCodeFence = false
650
+ codeFenceMarker = ''
651
+ codeFenceLang = ''
652
+ codeFenceLines = []
653
+ } else {
654
+ codeFenceLines.push(rawLine)
655
+ }
656
+ continue
657
+ }
658
+
622
659
  const mermaidOpen = /^(`{3,}|~{3,})\s*mermaid\b.*$/i.exec(line)
623
660
  if (mermaidOpen !== null) {
624
661
  if (current === null) current = createSection()
@@ -628,6 +665,16 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
628
665
  continue
629
666
  }
630
667
 
668
+ const codeOpen = /^(`{3,}|~{3,})\s*([a-zA-Z][\w.+-]*)\s*$/.exec(line)
669
+ if (codeOpen !== null) {
670
+ if (current === null) current = createSection()
671
+ inCodeFence = true
672
+ codeFenceMarker = codeOpen[1]
673
+ codeFenceLang = codeOpen[2]
674
+ codeFenceLines = []
675
+ continue
676
+ }
677
+
631
678
  if (inMathBlock) {
632
679
  if (line === '$$') {
633
680
  if (current === null) current = createSection()
@@ -911,6 +958,24 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
911
958
  continue
912
959
  }
913
960
 
961
+ if (section.code !== '') {
962
+ const label = section.heading || (ui.pointKicker + ' ' + (++pointRef.count))
963
+ const rawPoints = [...section.bullets, ...section.paragraphs]
964
+ const slide = {
965
+ layout: 'code',
966
+ kicker: label,
967
+ title: label,
968
+ code: section.code,
969
+ ...(section.codeLang ? { language: section.codeLang } : {}),
970
+ ...(rawPoints.length > 0 ? { bullets: rawPoints } : {}),
971
+ ...(section.takeaway ? { takeaway: section.takeaway } : {}),
972
+ ...(section.source ? { source: section.source } : {}),
973
+ }
974
+ if (specials.length === 0 && notes !== '') slide.notes = notes
975
+ slides.push(slide)
976
+ continue
977
+ }
978
+
914
979
  if (section.formula !== '') {
915
980
  const label = section.heading || (ui.pointKicker + ' ' + (++pointRef.count))
916
981
  const rawPoints = [...section.bullets, ...section.paragraphs]
@@ -1060,12 +1125,28 @@ function normalizeSlideContent(raw, index) {
1060
1125
  ? source.columns.map((c) => stripInlineMarkdown(c)).filter(Boolean)
1061
1126
  : undefined
1062
1127
 
1128
+ const fencedTextMatch = (!source.code && typeof source.text === 'string')
1129
+ ? /```([a-zA-Z0-9_-]*)\r?\n([\s\S]+?)\r?\n```/.exec(source.text)
1130
+ : null
1131
+ const rawCode = typeof source.code === 'string'
1132
+ ? source.code.replace(/\r\n?/g, '\n').replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, '').trimEnd()
1133
+ : (fencedTextMatch ? fencedTextMatch[2].replace(/\r\n?/g, '\n').replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, '').trimEnd() : '')
1134
+ const codeLanguage = stripInlineMarkdown(source.language ?? (fencedTextMatch?.[1] || ''))
1135
+ const filename = stripInlineMarkdown(source.filename ?? '')
1136
+ const url = stripInlineMarkdown(source.url ?? '')
1137
+ const rawCoverPattern = String(source.coverPattern ?? '').trim().toLowerCase()
1138
+ const coverPattern = ['dots', 'grid', 'rings'].includes(rawCoverPattern) ? rawCoverPattern : ''
1139
+ const xLabel = stripInlineMarkdown(source.xLabel ?? '')
1140
+ const yLabel = stripInlineMarkdown(source.yLabel ?? '')
1141
+ const hasStringQuadrants = Array.isArray(source.quadrants) && source.quadrants.length === 4 && source.quadrants.every((q) => typeof q === 'string')
1142
+ const quadrantLabels = hasStringQuadrants ? source.quadrants.map((q) => stripInlineMarkdown(q)) : undefined
1143
+
1063
1144
  const rawItemsInput = source.items
1064
1145
  ?? source.cards
1065
1146
  ?? source.metrics
1066
1147
  ?? (!hasStringColumns ? source.columns : undefined)
1067
1148
  ?? source.steps
1068
- ?? source.quadrants
1149
+ ?? (!hasStringQuadrants && layout !== 'quadrant' ? source.quadrants : undefined)
1069
1150
  ?? (layout === 'sankey' && bullets.length > 0 ? bullets : undefined)
1070
1151
  const items = normalizeSlideItems(rawItemsInput, layout)
1071
1152
 
@@ -1076,6 +1157,14 @@ function normalizeSlideContent(raw, index) {
1076
1157
  ...(iconMode ? { iconMode } : {}),
1077
1158
  ...(formula !== '' ? { formula } : {}),
1078
1159
  ...(mermaid !== '' ? { mermaid } : {}),
1160
+ ...(rawCode !== '' ? { code: rawCode } : {}),
1161
+ ...(codeLanguage !== '' ? { language: codeLanguage } : {}),
1162
+ ...(filename !== '' ? { filename } : {}),
1163
+ ...(url !== '' ? { url } : {}),
1164
+ ...(coverPattern !== '' ? { coverPattern } : {}),
1165
+ ...(xLabel !== '' ? { xLabel } : {}),
1166
+ ...(yLabel !== '' ? { yLabel } : {}),
1167
+ ...(quadrantLabels ? { quadrants: quadrantLabels } : {}),
1079
1168
  ...(takeaway !== '' ? { takeaway } : {}),
1080
1169
  ...(slideSource !== '' ? { source: slideSource } : {}),
1081
1170
  ...(activeIndex !== undefined ? { activeIndex } : {}),
@@ -1109,7 +1198,7 @@ function normalizeSlideContent(raw, index) {
1109
1198
  return { layout, kicker, title: truncate(quoteText, 220), subtitle, ...commonExtras }
1110
1199
  }
1111
1200
 
1112
- if (layout === 'harvey' || layout === 'marimekko' || layout === 'sankey') {
1201
+ if (layout === 'harvey' || layout === 'marimekko' || layout === 'sankey' || layout === 'quadrant' || layout === 'radar' || layout === 'dumbbell' || layout === 'heatmap') {
1113
1202
  let rows = []
1114
1203
  if (Array.isArray(source.rows)) {
1115
1204
  rows = source.rows
@@ -1125,6 +1214,7 @@ function normalizeSlideContent(raw, index) {
1125
1214
  bullets,
1126
1215
  ...(rows.length ? { rows } : {}),
1127
1216
  ...(tableStyle ? { tableStyle } : {}),
1217
+ ...(layout === 'radar' && source.chart ? { chart: deckMedia.normalizeChart(source.chart, index + 1) } : {}),
1128
1218
  ...commonExtras,
1129
1219
  }
1130
1220
  }
@@ -1149,7 +1239,10 @@ function normalizeSlideContent(raw, index) {
1149
1239
  }
1150
1240
  }
1151
1241
 
1152
- return { layout, kicker, title, subtitle, text, bullets, ...commonExtras }
1242
+ const preservedImage = (layout === 'cover' || layout === 'mockup') && source.image && typeof source.image === 'object'
1243
+ ? { image: source.image }
1244
+ : {}
1245
+ return { layout, kicker, title, subtitle, text, bullets, ...preservedImage, ...commonExtras }
1153
1246
  }
1154
1247
 
1155
1248
  function checkSlideLimit(slides, limit) {
@@ -30,11 +30,127 @@ export const POSTER_COVER_VARIANTS = new Set([
30
30
  'split-bleed',
31
31
  ])
32
32
 
33
+ export const COVER_PATTERNS = new Set(['dots', 'grid', 'rings'])
34
+
35
+ /**
36
+ * 封面轻量矢量几何底纹(dots / grid / rings)—— 零外部依赖,低透明度克制点缀。
37
+ */
38
+ export function renderCoverPatternPptx(pattern, theme, nextId) {
39
+ const p = String(pattern || '').trim().toLowerCase()
40
+ if (!COVER_PATTERNS.has(p)) return ''
41
+ const tk = theme.tokens
42
+ const col = theme.dark ? '#FFFFFF' : tk.accentPrimary
43
+ const out = []
44
+ if (p === 'grid') {
45
+ for (let gx = 0.8; gx <= 12.6; gx += 1.18) {
46
+ out.push(ooxmlLine(nextId(), 'Cover Pattern V', { x: gx, y: 0 }, { x: gx, y: CANVAS_IN.h }, { color: tk.hairline, widthPt: 0.4 }))
47
+ }
48
+ for (let gy = 0.75; gy <= 6.8; gy += 1.15) {
49
+ out.push(ooxmlLine(nextId(), 'Cover Pattern H', { x: 0, y: gy }, { x: CANVAS_IN.w, y: gy }, { color: tk.hairline, widthPt: 0.4 }))
50
+ }
51
+ } else if (p === 'rings') {
52
+ ;[3.6, 5.4, 7.2].forEach((d, ri) => {
53
+ out.push(ooxmlShape(nextId(), `Cover Pattern Ring ${ri + 1}`, { x: 10.6 - d / 2, y: 3.75 - d / 2, w: d, h: d }, {
54
+ preset: 'ellipse',
55
+ fill: '',
56
+ stroke: col,
57
+ strokeAlpha: theme.dark ? 0.10 : 0.12,
58
+ strokePt: 0.75,
59
+ }))
60
+ })
61
+ } else if (p === 'dots') {
62
+ for (let r = 0; r < 5; r += 1) {
63
+ for (let c = 0; c < 6; c += 1) {
64
+ out.push(ooxmlShape(nextId(), `Cover Dot ${r}-${c}`, { x: 9.8 + c * 0.54, y: 0.9 + r * 0.54, w: 0.06, h: 0.06 }, {
65
+ preset: 'ellipse',
66
+ fill: col,
67
+ fillAlpha: theme.dark ? 0.16 : 0.18,
68
+ }))
69
+ }
70
+ }
71
+ }
72
+ return out.join('')
73
+ }
74
+
33
75
  export function renderPosterCoverPptx(slide, ctx) {
34
76
  const { coverVariant, title, subtitle, kicker, metaText, total, theme, langAttr, manifest, idBase, nextId } = ctx
35
- if (!POSTER_COVER_VARIANTS.has(coverVariant)) return null
36
77
  const tk = theme.tokens
78
+ const hasHeroPhoto = Boolean(slide?.image?.assetId || slide?.image?.src)
79
+
80
+ // Poster Cover 0:封面真图混排(左侧深邃渐变排版区 + 右侧全出血高清视觉图,0 遮挡 + WCAG AAA 对比)
81
+ if (hasHeroPhoto) {
82
+ const shapes = []
83
+ const panelW = 6.65
84
+ const darkBase = tk.coverBg && relativeLuminance(tk.coverBg) < 0.25
85
+ ? tk.coverBg
86
+ : mixHex(tk.accentPrimary, '#070B14', 0.62)
87
+ const darkEnd = mixHex(darkBase, tk.accentSecondary, 0.22)
88
+ shapes.push(ooxmlShape(nextId(), 'Photo Cover Left Panel', { x: 0, y: 0, w: panelW, h: CANVAS_IN.h }, {
89
+ preset: 'rect',
90
+ gradientStops: [
91
+ { offset: 0, color: darkBase },
92
+ { offset: 1, color: darkEnd },
93
+ ],
94
+ gradientAngle: 145,
95
+ }))
96
+ shapes.push(ooxmlShape(nextId(), 'Photo Cover Top Accent', { x: 0, y: 0, w: panelW, h: 0.08 }, {
97
+ preset: 'rect',
98
+ fill: tk.accentPrimary,
99
+ }))
100
+ if (kicker !== '') {
101
+ shapes.push(ooxmlShape(idBase + 4, 'Kicker', { x: 0.76, y: 1.38, w: panelW - 1.32, h: 0.36 }, {
102
+ txBox: true,
103
+ anchor: 'ctr',
104
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
105
+ paragraphs: [
106
+ ooxmlRichParagraph(kicker.toUpperCase(), { sizePt: 11, color: '#FDE68A', bold: true, lang: langAttr, font: theme.fonts.body, spc: 180 }),
107
+ ],
108
+ }))
109
+ }
110
+ const titleBox = { x: 0.76, y: 1.88, w: panelW - 1.32, h: 2.38 }
111
+ const titleFit = computeTextFit(title, titleBox, 'coverTitle', { maxPt: 38, minPt: 24, padXPt: 2, padYPt: 4 })
112
+ shapes.push(ooxmlShape(idBase + 2, 'Title', titleBox, {
113
+ txBox: true,
114
+ anchor: 'ctr',
115
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
116
+ fontScale: titleFit.fontScale,
117
+ paragraphs: [
118
+ ooxmlRichParagraph(title, { sizePt: titleFit.fontPt, color: '#F8FAFC', bold: true, lang: langAttr, font: theme.fonts.heading, lineHeight: titleFit.lineHeight }),
119
+ ],
120
+ }))
121
+ shapes.push(ooxmlShape(nextId(), 'Photo Cover Rule', { x: 0.76, y: 4.38, w: 1.10, h: 0.055 }, {
122
+ preset: 'rect',
123
+ fill: tk.accentPrimary,
124
+ }))
125
+ if (subtitle !== '') {
126
+ const subBox = { x: 0.76, y: 4.62, w: panelW - 1.32, h: 1.35 }
127
+ const subFit = computeTextFit(subtitle, subBox, 'body', { maxPt: 16.5, minPt: 13, padXPt: 2, padYPt: 2 })
128
+ shapes.push(ooxmlShape(idBase + 3, 'Subtitle', subBox, {
129
+ txBox: true,
130
+ anchor: 't',
131
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
132
+ fontScale: subFit.fontScale,
133
+ paragraphs: [
134
+ ooxmlRichParagraph(subtitle, { sizePt: subFit.fontPt, color: '#CBD5E1', lang: langAttr, font: theme.fonts.body, lineHeight: 1.44 }),
135
+ ],
136
+ }))
137
+ }
138
+ if (metaText) {
139
+ shapes.push(ooxmlShape(nextId(), 'Cover meta', { x: 0.76, y: 6.46, w: panelW - 1.32, h: 0.42 }, {
140
+ txBox: true,
141
+ anchor: 'ctr',
142
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
143
+ paragraphs: [
144
+ ooxmlRichParagraph(metaText, { sizePt: 10.5, color: '#94A3B8', lang: langAttr, font: theme.fonts.body }),
145
+ ],
146
+ }))
147
+ }
148
+ return shapes.join('')
149
+ }
150
+
151
+ if (!POSTER_COVER_VARIANTS.has(coverVariant)) return null
37
152
  const shapes = []
153
+ const patXml = renderCoverPatternPptx(slide?.coverPattern, theme, nextId)
38
154
 
39
155
  // Poster Cover 1:Apple / Linear Keynote 光晕剧场封面
40
156
  if (coverVariant === 'keynote-glow') {
@@ -55,6 +171,7 @@ export function renderPosterCoverPptx(slide, ctx) {
55
171
  gradientStops: gradStops,
56
172
  gradientAngle: 135,
57
173
  }))
174
+ if (patXml) shapes.push(patXml)
58
175
  // 右上主氛围径向光斑 + 左下辅氛围径向光斑(4段柔滑过渡避免 LibreOffice 椭圆边界断层)
59
176
  shapes.push(ooxmlShape(nextId(), 'Ambient Glow Primary', { x: 6.7, y: -2.2, w: 8.8, h: 8.8 }, {
60
177
  preset: 'ellipse',
@@ -169,6 +286,7 @@ export function renderPosterCoverPptx(slide, ctx) {
169
286
 
170
287
  // Poster Cover 2:瑞士杂志网格封面(Monocle / FT / Nature)
171
288
  if (coverVariant === 'editorial-grid') {
289
+ if (patXml) shapes.push(patXml)
172
290
  shapes.push(ooxmlShape(nextId(), 'Editorial Top Rule', { x: 0.62, y: 0.42, w: 12.09, h: 0.04 }, {
173
291
  preset: 'rect',
174
292
  fill: tk.inkPrimary,
@@ -305,6 +423,7 @@ export function renderPosterCoverPptx(slide, ctx) {
305
423
  }
306
424
 
307
425
  // Poster Cover 3 & 4:建筑感非对称封面(architectural / split-bleed —— 麦肯锡/东方极简)
426
+ if (patXml) shapes.push(patXml)
308
427
  const isSplitBleed = coverVariant === 'split-bleed'
309
428
  const wingW = isSplitBleed ? 5.25 : 4.25
310
429
  const wingX = CANVAS_IN.w - wingW
@@ -443,11 +562,39 @@ export function renderPosterCoverPptx(slide, ctx) {
443
562
 
444
563
  export function renderPosterCoverHtml(slide, ctx) {
445
564
  const { coverVariant, title, subtitle, kicker, meta, total, langId, manifest, theme } = ctx
565
+ const rawAsset = slide?.image?.assetId && manifest?.assets?.[slide.image.assetId]
566
+ const photoData = rawAsset
567
+ ? (String(rawAsset.data || '').startsWith('data:') ? rawAsset.data : `data:${rawAsset.mime};base64,${rawAsset.data}`)
568
+ : (typeof slide?.image?.src === 'string' && slide.image.src.startsWith('data:image/') ? slide.image.src : '')
569
+
570
+ if (photoData) {
571
+ const tk = theme?.tokens
572
+ const darkBase = tk?.coverBg && relativeLuminance(tk.coverBg) < 0.25
573
+ ? tk.coverBg
574
+ : mixHex(tk?.accentPrimary || '#0057B8', '#070B14', 0.62)
575
+ const darkEnd = mixHex(darkBase, tk?.accentSecondary || '#0E7490', 0.22)
576
+ return (
577
+ '<div class="cover-shell is-photo-split">' +
578
+ `<div class="photo-cover-left" style="background:linear-gradient(145deg,${darkBase},${darkEnd})">` +
579
+ (kicker !== '' ? '<div class="kicker">' + escapeHtml(kicker) + '</div>' : '') +
580
+ '<h1>' + renderInlineHtml(title) + '</h1>' +
581
+ '<div class="arch-rule"></div>' +
582
+ (subtitle !== '' ? '<div class="subtitle">' + renderInlineHtml(subtitle) + '</div>' : '') +
583
+ (meta !== '' ? '<div class="meta">' + escapeHtml(meta) + '</div>' : '') +
584
+ '</div>' +
585
+ `<div class="photo-cover-right"><img src="${photoData}" alt="${escapeHtml(slide.image?.alt || title)}"/></div>` +
586
+ '</div>'
587
+ )
588
+ }
589
+
446
590
  if (!POSTER_COVER_VARIANTS.has(coverVariant)) return null
591
+ const patClass = COVER_PATTERNS.has(String(slide?.coverPattern || '').toLowerCase())
592
+ ? ' cover-pat-' + String(slide.coverPattern).toLowerCase()
593
+ : ''
447
594
 
448
595
  if (coverVariant === 'keynote-glow') {
449
596
  return (
450
- '<div class="cover-shell is-keynote-glow">' +
597
+ '<div class="cover-shell is-keynote-glow' + patClass + '">' +
451
598
  '<div class="cover-glow-orb orb-a" aria-hidden="true"></div>' +
452
599
  '<div class="cover-glow-orb orb-b" aria-hidden="true"></div>' +
453
600
  '<div class="cover-center-stack">' +
@@ -790,7 +937,7 @@ export const AESTHETIC_STUDIO_CSS = `
790
937
  .bento-hero-grid.bento-hero-2 > :first-child{grid-row:1}
791
938
  .bento-hero-grid.bento-hero-3 > :first-child{grid-row:1 / span 2}
792
939
  .bento-hero-grid.bento-hero-4 > :first-child{grid-row:1 / span 3}
793
- .surface-card.is-inverted-hero{background:linear-gradient(140deg,var(--cover-bg),color-mix(in srgb,var(--cover-bg) 65%,var(--accent2))) !important;border:0 !important;color:#F8FAFC !important}
940
+ .surface-card.is-inverted-hero{background:linear-gradient(140deg,color-mix(in srgb,var(--accent) 82%,#0F172A),color-mix(in srgb,var(--accent) 55%,#0B1120)) !important;border:0 !important;color:#F8FAFC !important}
794
941
  .surface-card.is-inverted-hero .card-title{color:#F8FAFC}
795
942
  .surface-card.is-inverted-hero .card-body,.surface-card.is-inverted-hero .card-bullets{color:#E2E8F0}
796
943
  .surface-card.is-inverted-hero .card-stat{color:#FDE68A}
@@ -801,4 +948,11 @@ export const AESTHETIC_STUDIO_CSS = `
801
948
  .deck-icon-badge--ring{border:1.25px solid var(--accent);background:transparent}
802
949
  .deck-icon-badge--solid{background:var(--accent);color:var(--ink-on-accent)}
803
950
  .deck-icon-badge--bare{width:auto;height:auto;padding:2px;background:transparent}
951
+ .cover-shell.is-photo-split{display:grid;grid-template-columns:1fr 1fr;height:100%;border-radius:calc(var(--radius) * 1.2);overflow:hidden}
952
+ .photo-cover-left{padding:clamp(32px,4.2vw,58px);display:flex;flex-direction:column;justify-content:center;gap:16px;color:#F8FAFC;border-top:5px solid var(--accent)}
953
+ .photo-cover-left .kicker{color:#FDE68A}.photo-cover-left h1{color:#F8FAFC}.photo-cover-left .subtitle{color:#CBD5E1}.photo-cover-left .meta{color:#94A3B8;margin-top:auto;border-top:1px solid rgba(255,255,255,.15);padding-top:12px}
954
+ .photo-cover-right{position:relative;overflow:hidden;background:#0F172A}
955
+ .photo-cover-right img{width:100%;height:100%;object-fit:cover;display:block}
956
+ .cover-pat-grid{background-image:linear-gradient(to right,color-mix(in srgb,var(--hairline) 42%,transparent) 1px,transparent 1px),linear-gradient(to bottom,color-mix(in srgb,var(--hairline) 42%,transparent) 1px,transparent 1px);background-size:48px 48px}
957
+ .cover-pat-dots{background-image:radial-gradient(color-mix(in srgb,var(--accent) 26%,transparent) 1.5px,transparent 1.5px);background-size:24px 24px}
804
958
  `