dsh-ppt 0.32.1 → 0.33.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.
- package/CHANGELOG.md +13 -0
- package/README.en.md +1 -0
- package/README.md +1 -0
- package/docs/USAGE.en.md +1 -0
- package/docs/USAGE.md +1 -0
- package/docs/VALIDATION.md +4 -0
- package/lib/client.js +1 -1
- package/lib/tools.js +25 -2
- package/lib/types.d.ts +10 -1
- package/package.json +2 -2
- package/skills/dsh-ppt/SKILL.md +1 -1
- package/skills/dsh-ppt/package.json +1 -1
- package/skills/dsh-ppt/references/syntax.md +3 -1
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +23 -6
- package/skills/dsh-ppt/scripts/deck-chrome.mjs +2 -1
- package/skills/dsh-ppt/scripts/deck-core.mjs +7 -4
- package/skills/dsh-ppt/scripts/deck-covers.mjs +89 -3
- package/skills/dsh-ppt/scripts/deck-delivery.mjs +1 -0
- package/skills/dsh-ppt/scripts/deck-evidence.mjs +19 -1
- package/skills/dsh-ppt/scripts/deck-infographics.mjs +1214 -0
- package/skills/dsh-ppt/scripts/deck-layouts.mjs +44 -0
- package/skills/dsh-ppt/scripts/deck-media.mjs +41 -8
|
@@ -124,6 +124,16 @@ import {
|
|
|
124
124
|
renderProChartSlideBodyHtml,
|
|
125
125
|
PRO_CHARTS_CSS,
|
|
126
126
|
} from './deck-charts-pro.mjs'
|
|
127
|
+
import {
|
|
128
|
+
INFOGRAPHIC_LAYOUTS,
|
|
129
|
+
computeMapModel,
|
|
130
|
+
computeIsometricModel,
|
|
131
|
+
generateVisualBrief,
|
|
132
|
+
normalizeImageBrief,
|
|
133
|
+
renderInfographicSlideBodyPptx,
|
|
134
|
+
renderInfographicSlideBodyHtml,
|
|
135
|
+
INFOGRAPHICS_CSS,
|
|
136
|
+
} from './deck-infographics.mjs'
|
|
127
137
|
|
|
128
138
|
export {
|
|
129
139
|
CANVAS_IN,
|
|
@@ -190,6 +200,12 @@ export {
|
|
|
190
200
|
computeHeatmapModel,
|
|
191
201
|
SHOWCASE_CSS,
|
|
192
202
|
PRO_CHARTS_CSS,
|
|
203
|
+
INFOGRAPHIC_LAYOUTS,
|
|
204
|
+
computeMapModel,
|
|
205
|
+
computeIsometricModel,
|
|
206
|
+
generateVisualBrief,
|
|
207
|
+
normalizeImageBrief,
|
|
208
|
+
INFOGRAPHICS_CSS,
|
|
193
209
|
}
|
|
194
210
|
|
|
195
211
|
export const CORE_LAYOUTS = new Set([
|
|
@@ -221,6 +237,8 @@ export const CORE_LAYOUTS = new Set([
|
|
|
221
237
|
'radar',
|
|
222
238
|
'dumbbell',
|
|
223
239
|
'heatmap',
|
|
240
|
+
'map',
|
|
241
|
+
'isometric',
|
|
224
242
|
'table',
|
|
225
243
|
'closing',
|
|
226
244
|
])
|
|
@@ -235,6 +253,13 @@ export const LAYOUT_ALIASES = Object.freeze({
|
|
|
235
253
|
spider: { layout: 'radar' },
|
|
236
254
|
slope: { layout: 'dumbbell' },
|
|
237
255
|
'heat-matrix': { layout: 'heatmap' },
|
|
256
|
+
'world-map': { layout: 'map', variant: 'world' },
|
|
257
|
+
'china-map': { layout: 'map', variant: 'china' },
|
|
258
|
+
'geo-map': { layout: 'map' },
|
|
259
|
+
'iso-stack': { layout: 'isometric', variant: 'stack' },
|
|
260
|
+
'iso-layers': { layout: 'isometric', variant: 'stack' },
|
|
261
|
+
'3d-stack': { layout: 'isometric', variant: 'stack' },
|
|
262
|
+
'iso-pillars': { layout: 'isometric', variant: 'pillars' },
|
|
238
263
|
'kpi-grid': { layout: 'kpi', variant: 'grid' },
|
|
239
264
|
scorecard: { layout: 'kpi', variant: 'grid' },
|
|
240
265
|
bento: { layout: 'cards', variant: 'bento' },
|
|
@@ -910,6 +935,21 @@ export function renderCoreSlidePptx(slide, index, total, theme, langAttr, manife
|
|
|
910
935
|
return shapes.join('')
|
|
911
936
|
}
|
|
912
937
|
|
|
938
|
+
const infographicShapes = renderInfographicSlideBodyPptx(slide, {
|
|
939
|
+
theme,
|
|
940
|
+
langAttr,
|
|
941
|
+
chromeCfg,
|
|
942
|
+
nextId,
|
|
943
|
+
bodyTopY,
|
|
944
|
+
bodyBottomY,
|
|
945
|
+
bodyH,
|
|
946
|
+
})
|
|
947
|
+
if (infographicShapes !== null) {
|
|
948
|
+
shapes.push(infographicShapes)
|
|
949
|
+
shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
|
|
950
|
+
return shapes.join('')
|
|
951
|
+
}
|
|
952
|
+
|
|
913
953
|
const diagramShapes = renderDiagramSlideBodyPptx(slide, {
|
|
914
954
|
theme,
|
|
915
955
|
langAttr,
|
|
@@ -2095,6 +2135,7 @@ export function renderCoreSlideHtml(slide, index, total, ui, langId, manifest =
|
|
|
2095
2135
|
let inner = ''
|
|
2096
2136
|
const showcaseHtml = renderShowcaseSlideBodyHtml(slide, { theme, langId, manifest })
|
|
2097
2137
|
const proChartHtml = renderProChartSlideBodyHtml(slide, { theme, langId, manifest })
|
|
2138
|
+
const infographicHtml = renderInfographicSlideBodyHtml(slide, { theme, langId, manifest })
|
|
2098
2139
|
const diagramHtml = renderDiagramSlideBodyHtml(slide, { theme, langId, chromeStyle })
|
|
2099
2140
|
|
|
2100
2141
|
if (layout === 'cover') {
|
|
@@ -2181,6 +2222,8 @@ export function renderCoreSlideHtml(slide, index, total, ui, langId, manifest =
|
|
|
2181
2222
|
inner = renderHeader() + showcaseHtml
|
|
2182
2223
|
} else if (proChartHtml !== null) {
|
|
2183
2224
|
inner = renderHeader() + proChartHtml
|
|
2225
|
+
} else if (infographicHtml !== null) {
|
|
2226
|
+
inner = renderHeader() + infographicHtml
|
|
2184
2227
|
} else if (diagramHtml !== null) {
|
|
2185
2228
|
inner = renderHeader(layout === 'harvey' ? ui.tableKicker : '') + diagramHtml
|
|
2186
2229
|
} else if (layout === 'table' && (slide.tableStyle || slide.visual?.tableStyle) === 'harvey') {
|
|
@@ -2542,6 +2585,7 @@ math.deck-math.is-inline{font-size:1.06em;vertical-align:middle}
|
|
|
2542
2585
|
${AESTHETIC_STUDIO_CSS}
|
|
2543
2586
|
${SHOWCASE_CSS}
|
|
2544
2587
|
${PRO_CHARTS_CSS}
|
|
2588
|
+
${INFOGRAPHICS_CSS}
|
|
2545
2589
|
${DIAGRAMS_CSS}
|
|
2546
2590
|
${CHROME_CSS}
|
|
2547
2591
|
${MERMAID_CSS}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { resolveChromeStyle } from './deck-themes.mjs'
|
|
3
3
|
import { getChromeConfig, computeBadgePillWidth, roundRectAdj } from './deck-layouts.mjs'
|
|
4
4
|
import { resolveActiveTaste } from './deck-taste.mjs'
|
|
5
|
+
import { renderImageBriefPlaceholderPptx, renderImageBriefPlaceholderHtml } from './deck-infographics.mjs'
|
|
5
6
|
|
|
6
7
|
export const MEDIA_LAYOUTS = new Set(['image', 'image-left', 'image-right', 'chart', 'chart-split'])
|
|
7
8
|
export const CHART_KINDS = Object.freeze([
|
|
@@ -253,6 +254,8 @@ export function normalizeChart(input, page = 1) {
|
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
256
|
|
|
257
|
+
const FOCAL_POINTS = new Set(['center', 'top', 'bottom', 'left', 'right'])
|
|
258
|
+
|
|
256
259
|
function normalizeSingleImage(raw, fallbackAlt, page, defaultFit = 'contain') {
|
|
257
260
|
const image = typeof raw === 'string' ? { src: raw } : raw
|
|
258
261
|
if (!image || typeof image !== 'object' || (!image.src && !image.assetId)) {
|
|
@@ -262,11 +265,16 @@ function normalizeSingleImage(raw, fallbackAlt, page, defaultFit = 'contain') {
|
|
|
262
265
|
if (!['contain', 'cover'].includes(fit)) {
|
|
263
266
|
throw new Error(`dsh-ppt:第 ${page} 页 image.fit 仅支持 contain / cover`)
|
|
264
267
|
}
|
|
268
|
+
const rawFocal = image.focalPoint !== undefined ? String(image.focalPoint).trim().toLowerCase() : ''
|
|
269
|
+
if (rawFocal && !FOCAL_POINTS.has(rawFocal)) {
|
|
270
|
+
throw new Error(`dsh-ppt:第 ${page} 页 image.focalPoint 仅支持 center / top / bottom / left / right`)
|
|
271
|
+
}
|
|
265
272
|
return {
|
|
266
273
|
...(image.src ? { src: String(image.src) } : {}),
|
|
267
274
|
...(image.assetId ? { assetId: String(image.assetId) } : {}),
|
|
268
275
|
alt: String(image.alt ?? fallbackAlt ?? ''),
|
|
269
276
|
fit,
|
|
277
|
+
...(rawFocal ? { focalPoint: rawFocal } : {}),
|
|
270
278
|
...(image.caption ? { caption: String(image.caption) } : {}),
|
|
271
279
|
}
|
|
272
280
|
}
|
|
@@ -323,6 +331,13 @@ export function normalizeMediaSlide(source, normalized, index) {
|
|
|
323
331
|
}
|
|
324
332
|
}
|
|
325
333
|
|
|
334
|
+
if (!source.image && normalized.imageBrief) {
|
|
335
|
+
return {
|
|
336
|
+
...normalized,
|
|
337
|
+
...extras,
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
326
341
|
return {
|
|
327
342
|
...normalized,
|
|
328
343
|
...extras,
|
|
@@ -898,12 +913,19 @@ export function renderMediaHtml(slide, manifest, theme) {
|
|
|
898
913
|
boxes.gallery.forEach((gBox, idx) => {
|
|
899
914
|
const img = slide.images[idx]
|
|
900
915
|
const asset = manifest.assets?.[img?.assetId]
|
|
901
|
-
|
|
916
|
+
const posCss = img?.focalPoint && img.focalPoint !== 'center' ? `;object-position:${img.focalPoint === 'top' ? 'center top' : img.focalPoint === 'bottom' ? 'center bottom' : img.focalPoint === 'left' ? 'left center' : 'right center'}` : ''
|
|
917
|
+
body += `<figure class="media-image media-image--framed" style="${position(gBox)}"><img src="${esc(asset?.data ?? '')}" alt="${esc(img?.alt)}" style="object-fit:${img?.fit || 'cover'}${posCss}"/>${img?.caption ? `<figcaption>${esc(img.caption)}</figcaption>` : ''}</figure>`
|
|
902
918
|
})
|
|
919
|
+
} else if (!slide.image && slide.imageBrief) {
|
|
920
|
+
body += `<div class="media-image media-image--brief" style="${position(boxes.image)}">${renderImageBriefPlaceholderHtml(slide, theme, langEn)}</div>`
|
|
903
921
|
} else {
|
|
904
922
|
const image = slide.image, asset = manifest.assets?.[image?.assetId]
|
|
905
923
|
const frameClass = variant === 'split-bleed' || variant === 'full-bleed' ? 'media-image--bleed' : 'media-image--framed'
|
|
906
|
-
|
|
924
|
+
const posCss = image?.focalPoint && image.focalPoint !== 'center' ? `;object-position:${image.focalPoint === 'top' ? 'center top' : image.focalPoint === 'bottom' ? 'center bottom' : image.focalPoint === 'left' ? 'left center' : 'right center'}` : ''
|
|
925
|
+
body += `<figure class="media-image ${frameClass}" style="${position(boxes.image)}"><img src="${esc(asset?.data ?? '')}" alt="${esc(image?.alt)}" style="object-fit:${image?.fit || 'contain'}${posCss}"/></figure>`
|
|
926
|
+
if (variant === 'full-bleed') {
|
|
927
|
+
body += `<div class="media-bleed-scrim" aria-hidden="true"></div>`
|
|
928
|
+
}
|
|
907
929
|
}
|
|
908
930
|
if (boxes.body) {
|
|
909
931
|
const lead = slide.subtitle ? `<p class="media-lead">${formatInlineHtml(slide.subtitle)}</p>` : ''
|
|
@@ -1342,17 +1364,26 @@ export function renderMediaPptxShapes(slide, index, theme, langId = 'zh-CN', fon
|
|
|
1342
1364
|
shapes.push(spText('Kicker', boxes.kicker, [paraRich(slide.kicker.toUpperCase(), { size: 1100, color: accentText, bold: true, spc: 140 })], { ins: [0, 0, 0, 0] }))
|
|
1343
1365
|
}
|
|
1344
1366
|
if (variant === 'full-bleed') {
|
|
1345
|
-
const scrim = boxEmu({ x: 0
|
|
1346
|
-
shapes.push(
|
|
1367
|
+
const scrim = boxEmu({ x: 0, y: 3.9, w: CANVAS.w, h: 3.6 })
|
|
1368
|
+
shapes.push(
|
|
1369
|
+
`<p:sp><p:nvSpPr><p:cNvPr id="${allocId()}" name="Title Scrim"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>` +
|
|
1370
|
+
`<p:spPr><a:xfrm><a:off x="${scrim.x}" y="${scrim.y}"/><a:ext cx="${scrim.w}" cy="${scrim.h}"/></a:xfrm>` +
|
|
1371
|
+
`<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>` +
|
|
1372
|
+
`<a:gradFill><a:gsLst><a:gs pos="0"><a:srgbClr val="060B16"><a:alpha val="0"/></a:srgbClr></a:gs><a:gs pos="48000"><a:srgbClr val="060B16"><a:alpha val="62000"/></a:srgbClr></a:gs><a:gs pos="100000"><a:srgbClr val="060B16"><a:alpha val="88000"/></a:srgbClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="1"/></a:gradFill>` +
|
|
1373
|
+
`<a:ln><a:noFill/></a:ln></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p/></p:txBody></p:sp>`
|
|
1374
|
+
)
|
|
1347
1375
|
}
|
|
1348
|
-
|
|
1376
|
+
const titleColor = variant === 'full-bleed' ? '#F8FAFC' : fg
|
|
1377
|
+
shapes.push(spText('Title', boxes.title, [paraRich(slide.title || '', { size: titlePt * 100, color: titleColor, bold: true, latin: headingFont, ea: headingEa, linePct: 118000 })], { anchor: 'ctr', ins: [0, 0, 0, 0] }))
|
|
1349
1378
|
if (!isBleed) {
|
|
1350
1379
|
shapes.push(spLine('Header rule', toEmu(0.65), toEmu(1.56), toEmu(12.68), toEmu(1.56), hairline, 9525, 'solid'))
|
|
1351
1380
|
}
|
|
1352
1381
|
}
|
|
1353
1382
|
|
|
1354
|
-
// Framed matte container behind non-bleed images
|
|
1355
|
-
if (['image', 'image-left', 'image-right'].includes(slide.layout) && !
|
|
1383
|
+
// Framed matte container behind non-bleed images (or editorial Visual Brief slot when awaiting an image)
|
|
1384
|
+
if (['image', 'image-left', 'image-right'].includes(slide.layout) && !slide.image && slide.imageBrief) {
|
|
1385
|
+
shapes.push(renderImageBriefPlaceholderPptx(slide, boxes.image, theme, langId, allocId))
|
|
1386
|
+
} else if (['image', 'image-left', 'image-right'].includes(slide.layout) && !isBleed) {
|
|
1356
1387
|
if (Array.isArray(boxes.gallery) && Array.isArray(slide.images) && slide.images.length > 1) {
|
|
1357
1388
|
boxes.gallery.forEach((gBox, gIdx) => {
|
|
1358
1389
|
const pad = 0.06
|
|
@@ -1573,7 +1604,9 @@ export const MEDIA_CSS = `
|
|
|
1573
1604
|
.media-kicker,.media-title,.media-image,.media-body,.media-chart,.media-caption,.media-takeaway{position:absolute;margin:0;max-width:none;box-sizing:border-box}
|
|
1574
1605
|
.media-kicker{font-size:1.05cqw;line-height:1.2;margin:0}
|
|
1575
1606
|
.media-title{font-size:2.95cqw;font-weight:750;line-height:1.18;letter-spacing:-.015em;display:flex;align-items:center;overflow-wrap:anywhere}
|
|
1576
|
-
.media-title--bleed{
|
|
1607
|
+
.media-title--bleed{color:#F8FAFC;text-shadow:0 2px 14px rgba(0,0,0,.45);padding:.4cqw 0;z-index:3}
|
|
1608
|
+
.media-bleed-scrim{position:absolute;left:0;right:0;bottom:0;height:48%;background:linear-gradient(180deg,rgba(6,11,22,0) 0%,rgba(6,11,22,.62) 48%,rgba(6,11,22,.88) 100%);pointer-events:none;z-index:2}
|
|
1609
|
+
.media-image--brief{overflow:visible;padding:0;border:0;background:transparent}
|
|
1577
1610
|
.media-image{overflow:hidden}
|
|
1578
1611
|
.media-image--framed{border-radius:12px;background:var(--surface1,var(--panel));border:1px solid var(--hairline,color-mix(in srgb, var(--muted) 28%, transparent));padding:.45cqw}
|
|
1579
1612
|
.media-image--framed img{border-radius:8px}
|