dsh-ppt 0.23.1 → 0.24.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 +10 -0
- package/README.en.md +7 -7
- package/README.md +7 -7
- package/docs/REFERENCE.en.md +3 -2
- package/docs/REFERENCE.zh.md +3 -2
- package/docs/USAGE.en.md +3 -2
- package/docs/USAGE.md +3 -2
- package/docs/VALIDATION.md +4 -0
- package/docs/WORKBENCH.md +4 -3
- package/lib/client.js +949 -38
- package/lib/execution.d.ts +6 -5
- package/lib/execution.js +56 -1
- package/lib/tools.js +26 -1
- package/lib/types.d.ts +18 -1
- package/lib/workbench-language.js +1 -0
- package/lib/workbench.js +157 -6
- package/package.json +1 -1
- package/skills/dsh-ppt/SKILL.md +3 -3
- package/skills/dsh-ppt/package.json +1 -1
- package/skills/dsh-ppt/references/advanced.md +19 -5
- package/skills/dsh-ppt/references/data.md +1 -1
- package/skills/dsh-ppt/references/syntax.md +6 -2
- package/skills/dsh-ppt/scripts/build-deck.mjs +45 -6
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +258 -14
- package/skills/dsh-ppt/scripts/deck-core.mjs +135 -14
- package/skills/dsh-ppt/scripts/deck-data.mjs +10 -1
- package/skills/dsh-ppt/scripts/deck-delivery.mjs +529 -6
- package/skills/dsh-ppt/scripts/deck-director.mjs +31 -1
- package/skills/dsh-ppt/scripts/deck-import.mjs +1193 -0
- package/skills/dsh-ppt/scripts/deck-layouts.mjs +2273 -119
- package/skills/dsh-ppt/scripts/deck-math.mjs +1735 -0
|
@@ -2,31 +2,242 @@ import { basename } from 'node:path'
|
|
|
2
2
|
|
|
3
3
|
const escape = value => String(value ?? '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c])
|
|
4
4
|
|
|
5
|
+
function cleanLine(value) {
|
|
6
|
+
return String(value ?? '').replace(/\s+/g, ' ').trim()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function slideCueLines(slide) {
|
|
10
|
+
const cues = []
|
|
11
|
+
if (typeof slide?.takeaway === 'string' && slide.takeaway.trim()) {
|
|
12
|
+
cues.push(cleanLine(slide.takeaway))
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(slide?.bullets)) {
|
|
15
|
+
for (const b of slide.bullets.slice(0, 5)) {
|
|
16
|
+
const t = cleanLine(b)
|
|
17
|
+
if (t) cues.push('• ' + t)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (cues.length === 0 && Array.isArray(slide?.items)) {
|
|
21
|
+
for (const it of slide.items.slice(0, 5)) {
|
|
22
|
+
if (!it || typeof it !== 'object') continue
|
|
23
|
+
const parts = [it.tag, it.title, it.value, it.text].map(cleanLine).filter(Boolean)
|
|
24
|
+
if (parts.length) cues.push('• ' + parts.join(' — '))
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (cues.length === 0 && typeof slide?.subtitle === 'string' && slide.subtitle.trim()) {
|
|
28
|
+
cues.push(cleanLine(slide.subtitle))
|
|
29
|
+
}
|
|
30
|
+
return cues.join('\n')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function estimateSlideMinutes(slide) {
|
|
34
|
+
const words = [
|
|
35
|
+
slide?.title,
|
|
36
|
+
slide?.subtitle,
|
|
37
|
+
slide?.takeaway,
|
|
38
|
+
slide?.notes,
|
|
39
|
+
...(Array.isArray(slide?.bullets) ? slide.bullets : []),
|
|
40
|
+
]
|
|
41
|
+
.filter(Boolean)
|
|
42
|
+
.join(' ')
|
|
43
|
+
const cjk = (words.match(/[\u3400-\u9fff]/g) || []).length
|
|
44
|
+
const latin = (words.replace(/[\u3400-\u9fff]/g, ' ').match(/[A-Za-z0-9]+/g) || []).length
|
|
45
|
+
const spoken = cjk + latin
|
|
46
|
+
if (slide?.layout === 'cover' || slide?.layout === 'closing' || slide?.layout === 'section') return 0.5
|
|
47
|
+
if (spoken > 160) return 2
|
|
48
|
+
if (spoken > 70) return 1.5
|
|
49
|
+
return 1
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Render a complete structured Speaker Handout & Verbatim Teleprompter Markdown document.
|
|
54
|
+
* @param {object} manifest
|
|
55
|
+
* @param {string} [language]
|
|
56
|
+
*/
|
|
57
|
+
export function renderHandoutMarkdown(manifest, language) {
|
|
58
|
+
const lang = language || manifest?.language || 'zh'
|
|
59
|
+
const en = lang === 'en'
|
|
60
|
+
const slides = Array.isArray(manifest?.slides) ? manifest.slides : []
|
|
61
|
+
const totalMinutes = Math.max(1, Math.round(slides.reduce((sum, s) => sum + estimateSlideMinutes(s), 0)))
|
|
62
|
+
const title = cleanLine(manifest?.title) || (en ? 'Presentation Handout' : '演示文稿讲义')
|
|
63
|
+
|
|
64
|
+
const lines = [
|
|
65
|
+
`# ${title} — ${en ? 'Speaker Handout & Script' : '演讲者讲义与逐页手稿'}`,
|
|
66
|
+
'',
|
|
67
|
+
`## ${en ? 'Executive Overview' : '演示概览'}`,
|
|
68
|
+
`- **${en ? 'Theme' : '视觉主题'}**: \`${cleanLine(manifest?.theme || 'consulting')}\``,
|
|
69
|
+
`- **${en ? 'Slides' : '总页数'}**: ${slides.length}`,
|
|
70
|
+
`- **${en ? 'Estimated Speaking Time' : '预计演讲时长'}**: ~${totalMinutes} ${en ? 'min' : '分钟'}`,
|
|
71
|
+
'',
|
|
72
|
+
'---',
|
|
73
|
+
'',
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
slides.forEach((slide, idx) => {
|
|
77
|
+
const slideTitle = cleanLine(slide?.title) || (en ? `Slide ${idx + 1}` : `第 ${idx + 1} 页`)
|
|
78
|
+
const mins = estimateSlideMinutes(slide)
|
|
79
|
+
lines.push(`## ${en ? `Slide ${idx + 1}` : `第 ${idx + 1} 页`} · ${slideTitle}`)
|
|
80
|
+
const cleanKicker = cleanLine(slide?.kicker)
|
|
81
|
+
const meta = [
|
|
82
|
+
`**${en ? 'Layout' : '版式'}**: \`${slide?.layout || 'bullets'}${slide?.variant ? `[${slide.variant}]` : ''}\``,
|
|
83
|
+
(cleanKicker && cleanKicker !== slideTitle) ? `**${en ? 'Section' : '章节'}**: ${cleanKicker}` : '',
|
|
84
|
+
`**${en ? 'Pace' : '建议时长'}**: ~${mins} ${en ? 'min' : '分钟'}`,
|
|
85
|
+
].filter(Boolean)
|
|
86
|
+
lines.push(meta.join(' · '))
|
|
87
|
+
lines.push('')
|
|
88
|
+
|
|
89
|
+
if (slide?.subtitle) {
|
|
90
|
+
lines.push(`_${cleanLine(slide.subtitle)}_`)
|
|
91
|
+
lines.push('')
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (slide?.formula) {
|
|
95
|
+
lines.push(`$$${String(slide.formula).trim()}$$`)
|
|
96
|
+
lines.push('')
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (Array.isArray(slide?.items) && slide.items.length > 0) {
|
|
100
|
+
lines.push(`### ${en ? 'Key Metrics & Structured Items' : '核心指标与结构要素'}`)
|
|
101
|
+
for (const it of slide.items) {
|
|
102
|
+
if (!it || typeof it !== 'object') continue
|
|
103
|
+
const head = [it.tag, it.title].map(cleanLine).filter(Boolean).join(' · ')
|
|
104
|
+
const val = it.value !== undefined && it.value !== '' ? ` **${cleanLine(it.value)}${it.unit ? cleanLine(it.unit) : ''}**` : ''
|
|
105
|
+
const delta = it.delta ? ` (${cleanLine(it.delta)})` : ''
|
|
106
|
+
const body = it.text ? ` — ${cleanLine(it.text)}` : ''
|
|
107
|
+
lines.push(`- ${head || (en ? 'Item' : '条目')}${val}${delta}${body}`)
|
|
108
|
+
if (Array.isArray(it.bullets)) {
|
|
109
|
+
for (const sub of it.bullets) lines.push(` - ${cleanLine(sub)}`)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
lines.push('')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (Array.isArray(slide?.rows) && slide.rows.length > 0) {
|
|
116
|
+
lines.push(`### ${en ? 'Data Table' : '核心数据表'}`)
|
|
117
|
+
const header = slide.rows[0].map((c) => cleanLine(c).replace(/\|/g, '\\|'))
|
|
118
|
+
lines.push(`| ${header.join(' | ')} |`)
|
|
119
|
+
lines.push(`| ${header.map(() => '---').join(' | ')} |`)
|
|
120
|
+
for (const r of slide.rows.slice(1)) {
|
|
121
|
+
const cells = header.map((_, ci) => cleanLine(r?.[ci] ?? '').replace(/\|/g, '\\|'))
|
|
122
|
+
lines.push(`| ${cells.join(' | ')} |`)
|
|
123
|
+
}
|
|
124
|
+
lines.push('')
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (slide?.chart && Array.isArray(slide.chart.series) && slide.chart.series.length > 0) {
|
|
128
|
+
lines.push(`### ${en ? 'Chart Data' : '图表数据'} (${slide.chart.kind || 'column'})`)
|
|
129
|
+
const cats = Array.isArray(slide.chart.categories) ? slide.chart.categories : []
|
|
130
|
+
for (const s of slide.chart.series) {
|
|
131
|
+
const pairs = (s.values || []).map((v, i) => `${cats[i] ?? i + 1}: ${v}`).join(', ')
|
|
132
|
+
lines.push(`- **${cleanLine(s.name || 'Series')}**: ${pairs}`)
|
|
133
|
+
}
|
|
134
|
+
lines.push('')
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (Array.isArray(slide?.bullets) && slide.bullets.length > 0) {
|
|
138
|
+
lines.push(`### ${en ? 'Slide Points' : '页面要点'}`)
|
|
139
|
+
for (const b of slide.bullets) {
|
|
140
|
+
const t = cleanLine(b)
|
|
141
|
+
if (t) lines.push(`- ${t}`)
|
|
142
|
+
}
|
|
143
|
+
lines.push('')
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (slide?.takeaway) {
|
|
147
|
+
lines.push(`> **${en ? 'Takeaway' : '核心结论'}**: ${cleanLine(slide.takeaway)}`)
|
|
148
|
+
lines.push('')
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (slide?.source) {
|
|
152
|
+
lines.push(`_${en ? 'Source' : '数据来源'}: ${cleanLine(slide.source)}_`)
|
|
153
|
+
lines.push('')
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const script = cleanLine(slide?.notes)
|
|
157
|
+
? String(slide.notes).trim()
|
|
158
|
+
: slideCueLines(slide) || (en ? '(Opening / transition slide — pause 2s and introduce next section.)' : '(过渡页 — 停顿 2 秒,引导进入下一章节。)')
|
|
159
|
+
lines.push(`### ${en ? 'Speaker Script' : '演讲逐字稿 / 提词参考'}`)
|
|
160
|
+
lines.push(script)
|
|
161
|
+
lines.push('')
|
|
162
|
+
lines.push('---')
|
|
163
|
+
lines.push('')
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
return lines.join('\n')
|
|
167
|
+
}
|
|
168
|
+
|
|
5
169
|
/** Offline, sibling-file links only. No credentials or application server needed. */
|
|
6
|
-
export function renderDelivery(manifest, files, language) {
|
|
170
|
+
export function renderDelivery(manifest, files = {}, language) {
|
|
7
171
|
const label = (zh, en) => language === 'en' ? en : language === 'bilingual' ? zh + ' · ' + en : zh
|
|
8
172
|
const issues = manifest.quality?.issues ?? []
|
|
9
173
|
const draft = issues.some(issue => issue.code === 'template-unfilled')
|
|
10
174
|
const href = path => './' + encodeURIComponent(basename(path))
|
|
11
175
|
const download = (kind, text, id) => files[kind] ? `<a id="${id}" href="${escape(href(files[kind]))}" download>${escape(text)}</a>` : ''
|
|
12
176
|
const pptxLabel = label('下载 PPTX', 'Download PPTX')
|
|
177
|
+
const handoutLabel = label('下载讲义 (.md)', 'Download handout (.md)')
|
|
13
178
|
const reviewLabel = label('检查与导出', 'Review and export')
|
|
14
179
|
const outline = manifest.slides.map((slide, i) => `<li><button type="button" data-review-slide="${i + 1}"><span>${i + 1}</span>${escape(slide.title || label('无标题', 'Untitled'))}</button></li>`).join('')
|
|
15
180
|
const rows = issues.map(issue => `<li><button type="button" data-review-slide="${issue.slide}"><strong>${escape(label('第 ' + issue.slide + ' 页', 'Slide ' + issue.slide))} · ${escape(issue.message)}</strong><span>${escape(issue.suggestion)}</span></button></li>`).join('')
|
|
16
181
|
const summary = draft ? label('草稿中还有待填写内容,请补齐事实后再交付。', 'This draft still contains placeholders. Complete the facts before delivery.')
|
|
17
182
|
: manifest.quality ? label('静态检查发现 ' + issues.length + ' 项提示;请核对实际显示。', 'Static checks found ' + issues.length + ' item(s); review the actual slides.')
|
|
18
183
|
: label('此项目没有静态质量报告,请逐页检查。', 'No static quality report is available; review every slide.')
|
|
184
|
+
|
|
185
|
+
const handoutMarkdown = renderHandoutMarkdown(manifest, language)
|
|
186
|
+
const handoutFileName = files.handout
|
|
187
|
+
? basename(files.handout)
|
|
188
|
+
: (files.json ? basename(files.json, '.json') : (manifest.title || 'presentation').replace(/[^\p{L}\p{N}._-]+/gu, '-').replace(/^-+|-+$/g, '') || 'presentation') + '.handout.md'
|
|
189
|
+
const handoutLink = files.handout
|
|
190
|
+
? `<a id="download-handout" href="${escape(href(files.handout))}" download>${escape(handoutLabel)}</a>`
|
|
191
|
+
: `<a id="download-handout" href="#handout" download="${escape(handoutFileName)}">${escape(handoutLabel)}</a>`
|
|
192
|
+
|
|
193
|
+
const slideCues = (manifest.slides || []).map((s) => slideCueLines(s))
|
|
194
|
+
const targetMinutes = Math.max(1, Math.round((manifest.slides || []).reduce((sum, s) => sum + estimateSlideMinutes(s), 0)))
|
|
195
|
+
const deliveryConfig = {
|
|
196
|
+
lang: language || 'zh',
|
|
197
|
+
title: String(manifest.title || 'Presentation'),
|
|
198
|
+
channelId: String(manifest.deckId || manifest.title || 'dsh-ppt').slice(0, 64),
|
|
199
|
+
slideCues,
|
|
200
|
+
targetMinutes,
|
|
201
|
+
handoutMarkdown,
|
|
202
|
+
handoutFileName,
|
|
203
|
+
hasSiblingHandout: Boolean(files.handout),
|
|
204
|
+
labels: {
|
|
205
|
+
presenterTitle: label('演讲者提词台', 'Presenter Console'),
|
|
206
|
+
currentSlide: label('当前画面', 'CURRENT SLIDE'),
|
|
207
|
+
nextSlide: label('下一页预览', 'NEXT SLIDE'),
|
|
208
|
+
teleprompter: label('演讲提词器', 'TELEPROMPTER'),
|
|
209
|
+
autoCueBadge: label('自动提纲提示(无手写备注)', 'Auto cue (no speaker notes)'),
|
|
210
|
+
noNotes: label('本页暂无演讲备注与要点提示', 'No notes or cues for this slide'),
|
|
211
|
+
elapsed: label('已用时间', 'Elapsed'),
|
|
212
|
+
remaining: label('目标倒计时', 'Remaining'),
|
|
213
|
+
pause: label('暂停', 'Pause'),
|
|
214
|
+
resume: label('继续', 'Resume'),
|
|
215
|
+
reset: label('重置计时', 'Reset'),
|
|
216
|
+
black: label('黑屏', 'Black'),
|
|
217
|
+
unblack: label('取消黑屏', 'Unblack'),
|
|
218
|
+
white: label('白屏', 'White'),
|
|
219
|
+
unwhite: label('取消白屏', 'Unwhite'),
|
|
220
|
+
laser: label('激光笔 (L)', 'Laser (L)'),
|
|
221
|
+
endShow: label('结束放映', 'End'),
|
|
222
|
+
popupBlocked: label('浏览器拦截了演讲者窗口,请允许弹窗后按 P 重试。', 'Presenter popup was blocked. Allow popups and press P to retry.'),
|
|
223
|
+
laserOn: label('虚拟激光笔已开启(移动鼠标指示,按 L 关闭)', 'Laser pointer ON (move pointer, press L to off)'),
|
|
224
|
+
laserOff: label('虚拟激光笔已关闭', 'Laser pointer OFF'),
|
|
225
|
+
hint: label('← → 翻页 · P/空格 暂停 · T 重置 · A+/A- 字号 · L 激光笔 · B/W 黑白屏 · Esc 结束', '← → Navigate · T Reset · A+/A- Zoom · L Laser · B/W Blank · Esc End'),
|
|
226
|
+
},
|
|
227
|
+
}
|
|
228
|
+
|
|
19
229
|
return {
|
|
20
230
|
body: `<div id="delivery-bar">
|
|
21
231
|
<span id="delivery-status">${escape(draft ? label('待补全草稿', 'Draft: content needed') : label('演示文稿 · 请检查后交付', 'Presentation · review before delivery'))}</span>
|
|
22
232
|
${download('pptx', pptxLabel, 'download-pptx')}
|
|
23
233
|
<button id="review-toggle" type="button" aria-haspopup="dialog">${escape(reviewLabel)}</button>
|
|
24
234
|
</div>
|
|
235
|
+
<div id="dsh-laser-dot" aria-hidden="true"></div>
|
|
25
236
|
<dialog id="review-panel" aria-labelledby="review-title">
|
|
26
237
|
<div class="review-head"><h2 id="review-title">${escape(reviewLabel)}</h2><button id="review-close" type="button">${escape(label('关闭', 'Close'))}</button></div>
|
|
27
238
|
<p id="review-summary">${escape(summary)}</p>
|
|
28
|
-
<div class="review-exports">${download('pptx', pptxLabel, 'review-download-pptx')}${download('json', label('保存可编辑项目', 'Save project'), 'download-project')}</div>
|
|
29
|
-
<p>${escape(label('用 PowerPoint / WPS 打开 PPTX 可直接修改文字、图片和图表。让 Agent
|
|
239
|
+
<div class="review-exports">${download('pptx', pptxLabel, 'review-download-pptx')}${download('json', label('保存可编辑项目', 'Save project'), 'download-project')}${handoutLink}</div>
|
|
240
|
+
<p>${escape(label('用 PowerPoint / WPS 打开 PPTX 可直接修改文字、图片和图表。让 Agent 继续修改时,使用保存的项目文件;按 P 打开双屏演讲者提词台,按 L 开启虚拟激光笔。', 'Open the PPTX in PowerPoint / WPS to edit text, images and charts. Use the saved project when asking your Agent to revise it; press P for Dual-Screen Presenter Console and L for Virtual Laser Pointer.'))}</p>
|
|
30
241
|
<h3>${escape(label('检查提示 · 点击定位页面', 'Review items · click to open slide'))}</h3>
|
|
31
242
|
${issues.length ? `<ul id="review-issues">${rows}</ul>` : `<p>${escape(manifest.quality ? label('静态检查未发现问题;仍需核对实际排版和事实。', 'No static issues found; check the actual layout and facts.') : label('暂无报告。', 'No report available.'))}</p>`}
|
|
32
243
|
<p>${escape(label('文字尺寸是静态估算;这里不能证明 PowerPoint / WPS 排版已通过验收。', 'Text fit is estimated; this does not verify the rendered PowerPoint / WPS layout.'))}</p>
|
|
@@ -34,17 +245,20 @@ export function renderDelivery(manifest, files, language) {
|
|
|
34
245
|
</dialog>`,
|
|
35
246
|
navigation: `<button id="previous-slide" type="button" aria-label="${escape(label('上一页', 'Previous slide'))}">←</button><input id="page-number" type="number" min="1" max="${manifest.slides.length}" value="1" aria-label="${escape(label('跳到第几页', 'Go to slide'))}"><button id="next-slide" type="button" aria-label="${escape(label('下一页', 'Next slide'))}">→</button>`,
|
|
36
247
|
css: DELIVERY_CSS,
|
|
37
|
-
script: `syncDelivery = (${initDelivery.toString()})(go, setOverview, () => index, total);`,
|
|
248
|
+
script: `syncDelivery = (${initDelivery.toString()})(go, setOverview, () => index, total, ${JSON.stringify(deliveryConfig).replace(/</g, '\\u003c')});`,
|
|
38
249
|
}
|
|
39
250
|
}
|
|
40
251
|
|
|
41
252
|
/** This function is embedded in the standalone HTML, with no module dependencies. */
|
|
42
|
-
function initDelivery(go, setOverview, current, total) {
|
|
253
|
+
function initDelivery(go, setOverview, current, total, cfg) {
|
|
43
254
|
const previous = document.getElementById('previous-slide')
|
|
44
255
|
const next = document.getElementById('next-slide')
|
|
45
256
|
const number = document.getElementById('page-number')
|
|
46
257
|
const panel = document.getElementById('review-panel')
|
|
47
258
|
const toggle = document.getElementById('review-toggle')
|
|
259
|
+
const handoutBtn = document.getElementById('download-handout')
|
|
260
|
+
const laserDot = document.getElementById('dsh-laser-dot')
|
|
261
|
+
|
|
48
262
|
previous.addEventListener('click', () => go(Math.max(0, current() - 1)))
|
|
49
263
|
next.addEventListener('click', () => go(Math.min(total - 1, current() + 1)))
|
|
50
264
|
const jump = () => {
|
|
@@ -60,10 +274,317 @@ function initDelivery(go, setOverview, current, total) {
|
|
|
60
274
|
const slide = Number(button.dataset.reviewSlide)
|
|
61
275
|
if (Number.isInteger(slide) && slide >= 1 && slide <= total) { go(slide - 1); setOverview(false); panel.close() }
|
|
62
276
|
}))
|
|
277
|
+
|
|
278
|
+
if (handoutBtn && cfg && !cfg.hasSiblingHandout) {
|
|
279
|
+
handoutBtn.addEventListener('click', (event) => {
|
|
280
|
+
event.preventDefault()
|
|
281
|
+
try {
|
|
282
|
+
const blob = new Blob([cfg.handoutMarkdown || ''], { type: 'text/markdown;charset=utf-8' })
|
|
283
|
+
const url = URL.createObjectURL(blob)
|
|
284
|
+
const a = document.createElement('a')
|
|
285
|
+
a.href = url
|
|
286
|
+
a.download = cfg.handoutFileName || 'handout.md'
|
|
287
|
+
document.body.appendChild(a)
|
|
288
|
+
a.click()
|
|
289
|
+
a.remove()
|
|
290
|
+
setTimeout(() => { try { URL.revokeObjectURL(url) } catch (_) {} }, 2500)
|
|
291
|
+
} catch (_) {}
|
|
292
|
+
})
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Phase 4 Dual-Screen Presenter Console (BroadcastChannel + window.opener.postMessage + Laser Pointer)
|
|
296
|
+
let consoleWin = null
|
|
297
|
+
let consoleInitSent = false
|
|
298
|
+
let laserActive = false
|
|
299
|
+
let bc = null
|
|
300
|
+
try {
|
|
301
|
+
if (typeof BroadcastChannel === 'function' && cfg?.channelId) {
|
|
302
|
+
bc = new BroadcastChannel('dsh-ppt-presenter-' + cfg.channelId)
|
|
303
|
+
}
|
|
304
|
+
} catch (_) { bc = null }
|
|
305
|
+
|
|
306
|
+
const slidesList = Array.from(document.querySelectorAll('.slide'))
|
|
307
|
+
const notesOf = i => (slidesList[i] && slidesList[i].dataset ? (slidesList[i].dataset.notes || '') : '')
|
|
308
|
+
const cueOf = i => (cfg?.slideCues?.[i] || '')
|
|
309
|
+
const titleOf = i => {
|
|
310
|
+
const el = slidesList[i] ? slidesList[i].querySelector('h1,h2,.statement-title,.quote-text') : null
|
|
311
|
+
return el ? el.textContent.trim() : ''
|
|
312
|
+
}
|
|
313
|
+
const consoleOpen = () => { try { return !!(consoleWin && !consoleWin.closed) } catch (_) { return false } }
|
|
314
|
+
|
|
315
|
+
function broadcast(payload) {
|
|
316
|
+
if (bc) { try { bc.postMessage(payload) } catch (_) {} }
|
|
317
|
+
if (consoleOpen()) { try { consoleWin.postMessage(payload, '*') } catch (_) {} }
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function applyLaser(active, nx, ny) {
|
|
321
|
+
laserActive = Boolean(active)
|
|
322
|
+
if (!laserDot) return
|
|
323
|
+
if (!laserActive || typeof nx !== 'number' || typeof ny !== 'number') {
|
|
324
|
+
laserDot.style.display = 'none'
|
|
325
|
+
return
|
|
326
|
+
}
|
|
327
|
+
laserDot.style.display = 'block'
|
|
328
|
+
laserDot.style.left = (Math.max(0, Math.min(1, nx)) * 100) + '%'
|
|
329
|
+
laserDot.style.top = (Math.max(0, Math.min(1, ny)) * 100) + '%'
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function sendConsoleInit() {
|
|
333
|
+
if (!consoleOpen()) return
|
|
334
|
+
const styleEl = document.querySelector('style')
|
|
335
|
+
broadcast({
|
|
336
|
+
__dshPpt: 'init',
|
|
337
|
+
title: cfg?.title || document.title,
|
|
338
|
+
css: styleEl ? styleEl.textContent : '',
|
|
339
|
+
total,
|
|
340
|
+
slides: slidesList.map(s => s.outerHTML),
|
|
341
|
+
cues: cfg?.slideCues || [],
|
|
342
|
+
})
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function sendConsoleState(idx) {
|
|
346
|
+
const i = typeof idx === 'number' ? idx : current()
|
|
347
|
+
const nxt = (i + 1) % total
|
|
348
|
+
const rawNotes = notesOf(i)
|
|
349
|
+
const fallbackCue = cueOf(i)
|
|
350
|
+
broadcast({
|
|
351
|
+
__dshPpt: 'state',
|
|
352
|
+
index: i,
|
|
353
|
+
total,
|
|
354
|
+
title: titleOf(i),
|
|
355
|
+
nextTitle: titleOf(nxt),
|
|
356
|
+
notes: rawNotes,
|
|
357
|
+
cue: fallbackCue,
|
|
358
|
+
blank: document.body.classList.contains('blank-black') ? 'black' : (document.body.classList.contains('blank-white') ? 'white' : null),
|
|
359
|
+
laser: laserActive,
|
|
360
|
+
})
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function presenterConsoleHtml() {
|
|
364
|
+
const L = cfg?.labels || {}
|
|
365
|
+
const channelName = cfg?.channelId ? ('dsh-ppt-presenter-' + cfg.channelId) : ''
|
|
366
|
+
const targetSecs = (cfg?.targetMinutes || total || 5) * 60
|
|
367
|
+
const cs = getComputedStyle(document.documentElement)
|
|
368
|
+
const val = (name, fb) => { const v = cs.getPropertyValue(name).trim(); return v || fb }
|
|
369
|
+
const css = [
|
|
370
|
+
`:root{--bg:${val('--bg', '#0B1120')};--panel:${val('--panel', '#131C31')};--fg:${val('--fg', '#F1F5F9')};--muted:${val('--muted', '#94A3B8')};--accent:${val('--accent', '#3B82F6')};--accent2:${val('--accent2', '#10B981')};--font-heading:${val('--font-heading', 'sans-serif')};--font-body:${val('--font-body', 'sans-serif')}}`,
|
|
371
|
+
'*{box-sizing:border-box}',
|
|
372
|
+
'body{margin:0;background:var(--bg);color:var(--fg);font-family:var(--font-body);height:100vh;display:flex;flex-direction:column;overflow:hidden}',
|
|
373
|
+
'header{display:flex;align-items:center;gap:14px;padding:10px 18px;border-bottom:1px solid color-mix(in srgb,var(--muted) 35%,transparent);font-size:13px;color:var(--muted)}',
|
|
374
|
+
'header #ptitle{color:var(--fg);font-weight:700;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
375
|
+
'main{flex:1;display:grid;grid-template-columns:1.18fr .82fr;gap:12px;padding:12px 16px;min-height:0}',
|
|
376
|
+
'.col{display:flex;flex-direction:column;gap:10px;min-height:0}',
|
|
377
|
+
'.card{background:var(--panel);border:1px solid color-mix(in srgb,var(--muted) 28%,transparent);border-radius:12px;padding:10px 12px;min-height:0;display:flex;flex-direction:column;gap:6px}',
|
|
378
|
+
'.card-notes{flex:1}',
|
|
379
|
+
'.lbl-row{display:flex;align-items:center;justify-content:space-between;gap:8px}',
|
|
380
|
+
'.lbl{color:var(--accent);font-size:11px;font-weight:700;letter-spacing:.12em;text-transform:uppercase}',
|
|
381
|
+
'.cue-badge{font-size:11px;color:var(--muted);padding:2px 8px;border-radius:99px;border:1px solid color-mix(in srgb,var(--muted) 35%,transparent)}',
|
|
382
|
+
'.pv{position:relative;width:100%;aspect-ratio:16/9;overflow:hidden;border-radius:8px;background:var(--bg);border:1px solid color-mix(in srgb,var(--muted) 25%,transparent);--pv-scale:.3}',
|
|
383
|
+
'.pv.laser-on{cursor:crosshair}',
|
|
384
|
+
'.pv-slide{position:absolute;left:0;top:0;transform:translate(var(--pv-x,0px),var(--pv-y,0px)) scale(var(--pv-scale,.25));transform-origin:top left;pointer-events:none}',
|
|
385
|
+
'.pv-slide .slide{display:flex !important;position:absolute;left:0;top:0;width:100vw;height:100vh;animation:none !important}',
|
|
386
|
+
'.pv-slide .bullets li{opacity:1 !important;animation:none !important}',
|
|
387
|
+
'#pv-laser-preview{position:absolute;width:12px;height:12px;border-radius:99px;background:#EF4444;box-shadow:0 0 10px 4px rgba(239,68,68,.65);transform:translate(-50%,-50%);pointer-events:none;display:none;z-index:20}',
|
|
388
|
+
'#thumbs{display:flex;gap:8px;overflow-x:auto;padding-bottom:4px}',
|
|
389
|
+
'#thumbs .thumb{position:relative;flex:0 0 128px;aspect-ratio:16/9;border-radius:8px;overflow:hidden;border:1px solid color-mix(in srgb,var(--muted) 35%,transparent);cursor:pointer;background:var(--bg);--pv-scale:.09}',
|
|
390
|
+
'#thumbs .thumb.is-current{outline:2px solid var(--accent);outline-offset:1px}',
|
|
391
|
+
'#pnotes{font-size:var(--notes-size,20px);line-height:1.65;white-space:pre-wrap;overflow:auto;flex:1}',
|
|
392
|
+
'.timers{display:flex;align-items:center;gap:14px;font-variant-numeric:tabular-nums}',
|
|
393
|
+
'.timer-box{display:flex;flex-direction:column;line-height:1.15}',
|
|
394
|
+
'.timer-lbl{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}',
|
|
395
|
+
'#ptimer{font-size:20px;font-weight:700;color:var(--accent)}',
|
|
396
|
+
'#ppace{font-size:18px;font-weight:700;color:var(--accent2)}',
|
|
397
|
+
'#ppace.is-warn{color:#F59E0B}#ppace.is-over{color:#EF4444}',
|
|
398
|
+
'footer{display:flex;align-items:center;gap:8px;padding:9px 16px;border-top:1px solid color-mix(in srgb,var(--muted) 35%,transparent);flex-wrap:wrap}',
|
|
399
|
+
'button{background:color-mix(in srgb,var(--panel) 90%,transparent);color:var(--fg);border:1px solid color-mix(in srgb,var(--muted) 45%,transparent);border-radius:99px;padding:6px 12px;min-height:34px;font:inherit;font-size:13px;cursor:pointer}',
|
|
400
|
+
'button:hover{border-color:var(--accent);color:var(--accent)}',
|
|
401
|
+
'button[aria-pressed="true"]{background:var(--accent);color:var(--bg);border-color:var(--accent)}',
|
|
402
|
+
'.bar{flex:1;min-width:90px;height:8px;background:color-mix(in srgb,var(--muted) 28%,transparent);border-radius:99px;overflow:hidden}',
|
|
403
|
+
'#pprog{height:100%;width:0;background:var(--accent);transition:width .2s}',
|
|
404
|
+
'.hint{color:var(--muted);font-size:11px;width:100%}',
|
|
405
|
+
].join('')
|
|
406
|
+
const js = [
|
|
407
|
+
`var total=0,index=0,elapsed=0,started=Date.now(),paused=false,notesSize=20,slides=[],cues=[],targetSecs=${targetSecs},curBlank=null,laserOn=false,initialized=false,readyTries=0;`,
|
|
408
|
+
`var bc=null;try{if(typeof BroadcastChannel==="function"&&${JSON.stringify(channelName)})bc=new BroadcastChannel(${JSON.stringify(channelName)});}catch(_){bc=null;}`,
|
|
409
|
+
'function q(id){return document.getElementById(id)}',
|
|
410
|
+
'function post(m){try{if(bc)bc.postMessage(m)}catch(_){}try{if(window.opener)window.opener.postMessage(m,"*")}catch(_){}}',
|
|
411
|
+
'function fmt(ms,signed){var neg=ms<0;var s=Math.floor(Math.abs(ms)/1000),m=Math.floor(s/60);s=s%60;var h=Math.floor(m/60);m=m%60;return (neg&&signed?"-":"")+(h>0?(h<10?"0":"")+h+":":"")+(m<10?"0":"")+m+":"+(s<10?"0":"")+s}',
|
|
412
|
+
'function clock(){var d=new Date();return ("0"+d.getHours()).slice(-2)+":"+("0"+d.getMinutes()).slice(-2)+":"+("0"+d.getSeconds()).slice(-2)}',
|
|
413
|
+
'function tick(){if(!paused)elapsed=Date.now()-started;q("ptimer").textContent=fmt(elapsed,false);var rem=targetSecs*1000-elapsed;var pe=q("ppace");pe.textContent=fmt(rem,true);pe.classList.toggle("is-warn",rem>0&&rem<60000);pe.classList.toggle("is-over",rem<=0);q("pclock").textContent=clock();if(window.requestAnimationFrame)requestAnimationFrame(tick);else setTimeout(tick,250)}',
|
|
414
|
+
'function fitBox(box){var rw=box.clientWidth||320,rh=box.clientHeight||180;var vw=window.innerWidth||1280,vh=window.innerHeight||720;var s=Math.min(rw/vw,rh/vh);var ox=(rw-vw*s)/2,oy=(rh-vh*s)/2;box.style.setProperty("--pv-scale",String(s));box.style.setProperty("--pv-x",ox+"px");box.style.setProperty("--pv-y",oy+"px")}',
|
|
415
|
+
'function fit(){fitBox(q("pv-cur"));fitBox(q("pv-next"));var th=q("thumbs").children;for(var i=0;i<th.length;i++){fitBox(th[i])}}',
|
|
416
|
+
'function setSlide(box,html){var dot=box.id==="pv-cur"?q("pv-laser-preview"):null;box.innerHTML="";var f=document.createElement("div");f.className="pv-slide";f.innerHTML=html;box.appendChild(f);if(dot)box.appendChild(dot)}',
|
|
417
|
+
'function buildThumbs(){var box=q("thumbs");box.innerHTML="";slides.forEach(function(html,i){var t=document.createElement("div");t.className="thumb";var f=document.createElement("div");f.className="pv-slide";f.innerHTML=html;t.appendChild(f);t.addEventListener("click",function(){post({__dshPpt:"cmd",kind:"go",index:i})});box.appendChild(t)});fit()}',
|
|
418
|
+
'function renderState(st){index=st.index;total=st.total||total;q("pcounter").textContent=(index+1)+" / "+total;setSlide(q("pv-cur"),slides[index]||"");setSlide(q("pv-next"),slides[(index+1)%total]||"");var hasNotes=Boolean(st.notes&&st.notes.trim());var cue=st.cue||cues[index]||"";q("pcue-badge").style.display=(!hasNotes&&cue)?"inline-block":"none";q("pnotes").textContent=hasNotes?st.notes:(cue||' + JSON.stringify(L.noNotes || 'No notes') + ');q("pprog").style.width=((index+1)/Math.max(1,total)*100)+"%";curBlank=st.blank||null;q("pv-black").setAttribute("aria-pressed",curBlank==="black"?"true":"false");q("pv-white").setAttribute("aria-pressed",curBlank==="white"?"true":"false");q("pv-black").textContent=curBlank==="black"?' + JSON.stringify(L.unblack || 'Unblack') + ':' + JSON.stringify(L.black || 'Black') + ';q("pv-white").textContent=curBlank==="white"?' + JSON.stringify(L.unwhite || 'Unwhite') + ':' + JSON.stringify(L.white || 'White') + ';if(typeof st.laser==="boolean"){laserOn=st.laser;syncLaserUi()}var th=q("thumbs").children;for(var i=0;i<th.length;i++){th[i].classList.toggle("is-current",i===index)}fit()}',
|
|
419
|
+
'function syncLaserUi(){q("laser-btn").setAttribute("aria-pressed",laserOn?"true":"false");q("pv-cur").classList.toggle("laser-on",laserOn);if(!laserOn)q("pv-laser-preview").style.display="none"}',
|
|
420
|
+
'function toggleLaser(){laserOn=!laserOn;syncLaserUi();post({__dshPpt:"cmd",kind:"laser",active:laserOn,x:0.5,y:0.5})}',
|
|
421
|
+
'function togglePause(){paused=!paused;if(!paused)started=Date.now()-elapsed;var b=q("pause");b.setAttribute("aria-pressed",paused?"true":"false");b.textContent=paused?' + JSON.stringify(L.resume || 'Resume') + ':' + JSON.stringify(L.pause || 'Pause') + '}',
|
|
422
|
+
'function resetTimer(){started=Date.now();elapsed=0}',
|
|
423
|
+
'function applyNotesSize(){document.documentElement.style.setProperty("--notes-size",notesSize+"px")}',
|
|
424
|
+
'function handleMsg(d){if(!d)return;if(d.__dshPpt==="init"&&!initialized){initialized=true;slides=d.slides||[];cues=d.cues||[];total=d.total||slides.length;var st=document.createElement("style");st.textContent=d.css||"";document.head.appendChild(st);q("ptitle").textContent=d.title||"";buildThumbs()}else if(d.__dshPpt==="state"){renderState(d)}else if(d.__dshPpt==="close"){window.close()}}',
|
|
425
|
+
'window.addEventListener("message",function(e){handleMsg(e.data)});if(bc){bc.onmessage=function(e){handleMsg(e.data)}}',
|
|
426
|
+
'window.addEventListener("resize",fit);',
|
|
427
|
+
'window.addEventListener("beforeunload",function(){post({__dshPpt:"cmd",kind:"closed"})});',
|
|
428
|
+
'q("pv-cur").addEventListener("mousemove",function(e){if(!laserOn)return;var r=this.getBoundingClientRect();var nx=(e.clientX-r.left)/Math.max(1,r.width),ny=(e.clientY-r.top)/Math.max(1,r.height);var dot=q("pv-laser-preview");dot.style.display="block";dot.style.left=(nx*100)+"%";dot.style.top=(ny*100)+"%";post({__dshPpt:"cmd",kind:"laser",active:true,x:nx,y:ny})});',
|
|
429
|
+
'document.addEventListener("keydown",function(e){var k=e.key;if(k==="ArrowRight"||k===" "){e.preventDefault();post({__dshPpt:"cmd",kind:"go",delta:1})}else if(k==="ArrowLeft"){e.preventDefault();post({__dshPpt:"cmd",kind:"go",delta:-1})}else if(k==="Escape"){post({__dshPpt:"cmd",kind:"end"});window.close()}else if(k.toLowerCase()==="p"){togglePause()}else if(k.toLowerCase()==="t"){resetTimer()}else if(k.toLowerCase()==="l"){toggleLaser()}else if(k==="+"||k==="="){notesSize=Math.min(38,notesSize+2);applyNotesSize()}else if(k==="-"){notesSize=Math.max(12,notesSize-2);applyNotesSize()}else if(k.toLowerCase()==="b"){post({__dshPpt:"cmd",kind:"blank",color:curBlank==="black"?null:"black"})}else if(k.toLowerCase()==="w"){post({__dshPpt:"cmd",kind:"blank",color:curBlank==="white"?null:"white"})}});',
|
|
430
|
+
'q("prev").addEventListener("click",function(){post({__dshPpt:"cmd",kind:"go",delta:-1})});',
|
|
431
|
+
'q("next").addEventListener("click",function(){post({__dshPpt:"cmd",kind:"go",delta:1})});',
|
|
432
|
+
'q("pause").addEventListener("click",togglePause);',
|
|
433
|
+
'q("reset").addEventListener("click",resetTimer);',
|
|
434
|
+
'q("font-plus").addEventListener("click",function(){notesSize=Math.min(38,notesSize+2);applyNotesSize()});',
|
|
435
|
+
'q("font-minus").addEventListener("click",function(){notesSize=Math.max(12,notesSize-2);applyNotesSize()});',
|
|
436
|
+
'q("laser-btn").addEventListener("click",toggleLaser);',
|
|
437
|
+
'q("pv-black").addEventListener("click",function(){post({__dshPpt:"cmd",kind:"blank",color:curBlank==="black"?null:"black"})});',
|
|
438
|
+
'q("pv-white").addEventListener("click",function(){post({__dshPpt:"cmd",kind:"blank",color:curBlank==="white"?null:"white"})});',
|
|
439
|
+
'q("end").addEventListener("click",function(){post({__dshPpt:"cmd",kind:"end"});window.close()});',
|
|
440
|
+
'applyNotesSize();tick();function ready(){if(initialized)return;post({__dshPpt:"ready"});readyTries++;if(readyTries<6)setTimeout(ready,400)}setTimeout(ready,80);',
|
|
441
|
+
].join('')
|
|
442
|
+
return '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>' + escape(cfg?.title || '') + ' · ' + escape(L.presenterTitle || 'Presenter Console') + '</title><style>' + css + '</style></head><body>'
|
|
443
|
+
+ '<header><div id="ptitle"></div><div id="pcounter"></div><div id="pclock"></div></header>'
|
|
444
|
+
+ '<main><div class="col">'
|
|
445
|
+
+ '<div class="card"><div class="lbl-row"><span class="lbl">' + escape(L.currentSlide || 'CURRENT') + '</span></div><div class="pv" id="pv-cur"><div id="pv-laser-preview"></div></div></div>'
|
|
446
|
+
+ '<div class="card"><div class="lbl">' + escape(L.nextSlide || 'NEXT') + '</div><div class="pv" id="pv-next"></div></div>'
|
|
447
|
+
+ '<div class="card"><div class="lbl">SLIDES</div><div id="thumbs"></div></div>'
|
|
448
|
+
+ '</div><div class="col"><div class="card card-notes"><div class="lbl-row"><span class="lbl">' + escape(L.teleprompter || 'TELEPROMPTER') + '</span><span id="pcue-badge" class="cue-badge" style="display:none">' + escape(L.autoCueBadge || 'Auto cue') + '</span></div><div id="pnotes"></div></div></div></main>'
|
|
449
|
+
+ '<footer>'
|
|
450
|
+
+ '<button id="prev">◀</button><button id="next">▶</button>'
|
|
451
|
+
+ '<button id="pause" aria-pressed="false">' + escape(L.pause || 'Pause') + '</button>'
|
|
452
|
+
+ '<button id="reset">' + escape(L.reset || 'Reset') + '</button>'
|
|
453
|
+
+ '<button id="font-minus">A−</button><button id="font-plus">A+</button>'
|
|
454
|
+
+ '<button id="laser-btn" aria-pressed="false">' + escape(L.laser || 'Laser (L)') + '</button>'
|
|
455
|
+
+ '<button id="pv-black">' + escape(L.black || 'Black') + '</button>'
|
|
456
|
+
+ '<button id="pv-white">' + escape(L.white || 'White') + '</button>'
|
|
457
|
+
+ '<button id="end">' + escape(L.endShow || 'End') + '</button>'
|
|
458
|
+
+ '<div class="timers"><div class="timer-box"><span class="timer-lbl">' + escape(L.elapsed || 'Elapsed') + '</span><span id="ptimer">00:00</span></div>'
|
|
459
|
+
+ '<div class="timer-box"><span class="timer-lbl">' + escape(L.remaining || 'Remaining') + '</span><span id="ppace">05:00</span></div></div>'
|
|
460
|
+
+ '<div class="bar"><div id="pprog"></div></div>'
|
|
461
|
+
+ '<div class="hint">' + escape(L.hint || '') + '</div></footer>'
|
|
462
|
+
+ '<scr' + 'ipt>' + js + '</scr' + 'ipt></body></html>'
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function closeConsole() {
|
|
466
|
+
if (consoleOpen()) {
|
|
467
|
+
try { consoleWin.postMessage({ __dshPpt: 'close' }, '*'); consoleWin.close() } catch (_) {}
|
|
468
|
+
}
|
|
469
|
+
broadcast({ __dshPpt: 'close' })
|
|
470
|
+
document.body.classList.remove('presenting', 'blank-black', 'blank-white')
|
|
471
|
+
consoleInitSent = false
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function openConsole() {
|
|
475
|
+
if (consoleOpen()) { try { consoleWin.focus() } catch (_) {} return }
|
|
476
|
+
consoleInitSent = false
|
|
477
|
+
const html = presenterConsoleHtml()
|
|
478
|
+
consoleWin = window.open('', 'dsh-ppt-presenter', 'width=1120,height=760')
|
|
479
|
+
if (!consoleWin) {
|
|
480
|
+
try {
|
|
481
|
+
const url = URL.createObjectURL(new Blob([html], { type: 'text/html' }))
|
|
482
|
+
consoleWin = window.open(url, 'dsh-ppt-presenter', 'width=1120,height=760')
|
|
483
|
+
} catch (_) {}
|
|
484
|
+
} else {
|
|
485
|
+
try {
|
|
486
|
+
consoleWin.document.open()
|
|
487
|
+
consoleWin.document.write(html)
|
|
488
|
+
consoleWin.document.close()
|
|
489
|
+
} catch (_) {}
|
|
490
|
+
}
|
|
491
|
+
if (!consoleWin) {
|
|
492
|
+
const toastEl = document.getElementById('toast')
|
|
493
|
+
if (toastEl && cfg?.labels?.popupBlocked) {
|
|
494
|
+
toastEl.textContent = cfg.labels.popupBlocked
|
|
495
|
+
toastEl.hidden = false
|
|
496
|
+
setTimeout(() => { toastEl.hidden = true }, 2600)
|
|
497
|
+
}
|
|
498
|
+
return
|
|
499
|
+
}
|
|
500
|
+
document.body.classList.add('presenting')
|
|
501
|
+
setTimeout(() => {
|
|
502
|
+
if (!consoleInitSent) {
|
|
503
|
+
consoleInitSent = true
|
|
504
|
+
sendConsoleInit()
|
|
505
|
+
sendConsoleState()
|
|
506
|
+
}
|
|
507
|
+
}, 120)
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function handleConsoleCommand(data) {
|
|
511
|
+
if (!data || typeof data !== 'object') return
|
|
512
|
+
if (data.__dshPpt === 'ready') {
|
|
513
|
+
if (!consoleInitSent) { consoleInitSent = true; sendConsoleInit() }
|
|
514
|
+
sendConsoleState()
|
|
515
|
+
return
|
|
516
|
+
}
|
|
517
|
+
if (data.__dshPpt !== 'cmd') return
|
|
518
|
+
if (data.kind === 'end' || data.kind === 'closed') {
|
|
519
|
+
closeConsole()
|
|
520
|
+
return
|
|
521
|
+
}
|
|
522
|
+
if (data.kind === 'go') {
|
|
523
|
+
document.body.classList.remove('blank-black', 'blank-white')
|
|
524
|
+
if (typeof data.index === 'number') go(data.index)
|
|
525
|
+
else go(current() + (data.delta || 0))
|
|
526
|
+
sendConsoleState()
|
|
527
|
+
} else if (data.kind === 'blank') {
|
|
528
|
+
document.body.classList.remove('blank-black', 'blank-white')
|
|
529
|
+
if (data.color === 'black') document.body.classList.add('blank-black')
|
|
530
|
+
else if (data.color === 'white') document.body.classList.add('blank-white')
|
|
531
|
+
sendConsoleState()
|
|
532
|
+
} else if (data.kind === 'laser') {
|
|
533
|
+
applyLaser(data.active, data.x, data.y)
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
window.addEventListener('message', event => {
|
|
538
|
+
if (consoleWin && event.source === consoleWin) handleConsoleCommand(event.data)
|
|
539
|
+
})
|
|
540
|
+
if (bc) {
|
|
541
|
+
bc.onmessage = event => handleConsoleCommand(event.data)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// Register unified toggle hook for deck-core.mjs (#presenter-toggle / P / V)
|
|
545
|
+
window.__dshTogglePresenter = () => {
|
|
546
|
+
if (consoleOpen()) closeConsole()
|
|
547
|
+
else openConsole()
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// Laser pointer toggle ('L') + local stage tracking + fallback 'P' capture handler
|
|
551
|
+
document.addEventListener('keydown', event => {
|
|
552
|
+
const targetEl = event.target
|
|
553
|
+
if (event.ctrlKey || event.metaKey || event.altKey) return
|
|
554
|
+
if (targetEl && (['INPUT', 'SELECT', 'TEXTAREA'].includes(targetEl.tagName) || targetEl.isContentEditable === true)) return
|
|
555
|
+
if (panel.open) return
|
|
556
|
+
const lower = String(event.key || '').toLowerCase()
|
|
557
|
+
if (lower === 'l') {
|
|
558
|
+
event.preventDefault()
|
|
559
|
+
laserActive = !laserActive
|
|
560
|
+
applyLaser(laserActive, 0.5, 0.5)
|
|
561
|
+
document.body.classList.toggle('laser-active', laserActive)
|
|
562
|
+
sendConsoleState()
|
|
563
|
+
const toastEl = document.getElementById('toast')
|
|
564
|
+
if (toastEl && cfg?.labels) {
|
|
565
|
+
toastEl.textContent = laserActive ? cfg.labels.laserOn : cfg.labels.laserOff
|
|
566
|
+
toastEl.hidden = false
|
|
567
|
+
setTimeout(() => { toastEl.hidden = true }, 2000)
|
|
568
|
+
}
|
|
569
|
+
} else if (lower === 'escape' && laserActive) {
|
|
570
|
+
applyLaser(false)
|
|
571
|
+
document.body.classList.remove('laser-active')
|
|
572
|
+
sendConsoleState()
|
|
573
|
+
}
|
|
574
|
+
})
|
|
575
|
+
|
|
576
|
+
document.addEventListener('mousemove', event => {
|
|
577
|
+
if (!laserActive) return
|
|
578
|
+
const nx = event.clientX / Math.max(1, window.innerWidth)
|
|
579
|
+
const ny = event.clientY / Math.max(1, window.innerHeight)
|
|
580
|
+
applyLaser(true, nx, ny)
|
|
581
|
+
})
|
|
582
|
+
|
|
63
583
|
return index => {
|
|
64
584
|
number.value = String(index + 1)
|
|
65
585
|
previous.disabled = index === 0
|
|
66
586
|
next.disabled = index === total - 1
|
|
587
|
+
if (consoleOpen()) sendConsoleState(index)
|
|
67
588
|
}
|
|
68
589
|
}
|
|
69
590
|
|
|
@@ -75,6 +596,8 @@ const DELIVERY_CSS = `
|
|
|
75
596
|
#delivery-bar a,#delivery-bar button,.review-exports a{display:inline-block;text-decoration:none;border:1px solid var(--muted);border-radius:99px;padding:9px 14px;background:var(--panel);color:var(--fg);font:inherit;cursor:pointer}
|
|
76
597
|
#delivery-bar a:hover,#delivery-bar button:hover,.review-exports a:hover{border-color:var(--accent);color:var(--accent)}
|
|
77
598
|
#delivery-bar #download-pptx{background:var(--accent);color:var(--bg);border-color:var(--accent)}
|
|
599
|
+
#dsh-laser-dot{position:fixed;z-index:95;width:16px;height:16px;border-radius:99px;background:#EF4444;box-shadow:0 0 14px 6px rgba(239,68,68,.75);pointer-events:none;transform:translate(-50%,-50%);display:none}
|
|
600
|
+
body.laser-active{cursor:crosshair}
|
|
78
601
|
#review-panel{background:var(--panel);color:var(--fg);border:1px solid var(--muted);border-radius:18px;width:min(620px,calc(100vw - 24px));max-height:85vh;padding:24px;overflow:auto}
|
|
79
602
|
#review-panel::backdrop{background:rgba(0,0,0,.65)}
|
|
80
603
|
.review-head{display:flex;justify-content:space-between;align-items:center;gap:16px}
|
|
@@ -100,5 +623,5 @@ button:focus-visible,a:focus-visible,input:focus-visible{outline:2px solid var(-
|
|
|
100
623
|
#notes-panel,#help-panel{bottom:160px}
|
|
101
624
|
#review-panel{padding:18px}
|
|
102
625
|
}
|
|
103
|
-
@media print{#delivery-bar,#review-panel{display:none!important}}
|
|
626
|
+
@media print{#delivery-bar,#review-panel,#dsh-laser-dot{display:none!important}}
|
|
104
627
|
`
|