Skip to content

Commit 8e6fb40

Browse files
committed
fix: copy markdown copies actual markdown, not YAML fallback
- Remove output.value fallback from Copy as Markdown button - Combine service overview + volume comparison in single copy - Add markdown preview textarea on Table tab for visibility - Rename Volumes tab to Table - All external links already have noopener noreferrer
1 parent 2ec899d commit 8e6fb40

1 file changed

Lines changed: 37 additions & 26 deletions

File tree

src/main.ts

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ function init(): void {
199199
cardsTab.textContent = 'Cards'
200200
tabBar.appendChild(cardsTab)
201201
const volumesTab = el('button', { className: 'tab-btn' })
202-
volumesTab.textContent = 'Volumes'
202+
volumesTab.textContent = 'Table'
203203
tabBar.appendChild(volumesTab)
204204
app.appendChild(tabBar)
205205

@@ -260,35 +260,29 @@ function init(): void {
260260
actions.appendChild(copyBtn)
261261

262262
const mdBtn = el('button', { className: 'btn btn-secondary' })
263-
mdBtn.textContent = 'Copy as Markdown Table'
263+
mdBtn.textContent = 'Copy as Markdown'
264264
mdBtn.addEventListener('click', async () => {
265-
if (currentParsed) {
266-
const services = parseServices(currentParsed)
267-
const md = generateMarkdownTable(services)
268-
const ok = await copyToClipboard(md || output.value)
269-
mdBtn.textContent = ok ? 'Copied!' : 'Copy failed'
270-
} else {
271-
const ok = await copyToClipboard(output.value)
272-
mdBtn.textContent = ok ? 'Copied!' : 'Copy failed'
265+
if (!currentParsed) {
266+
mdBtn.textContent = 'No data'
267+
setTimeout(() => { mdBtn.textContent = 'Copy as Markdown' }, 1500)
268+
return
273269
}
274-
setTimeout(() => { mdBtn.textContent = 'Copy as Markdown Table' }, 1500)
275-
})
276-
actions.appendChild(mdBtn)
277-
278-
const volMdBtn = el('button', { className: 'btn btn-secondary' })
279-
volMdBtn.textContent = 'Copy Volume Table'
280-
volMdBtn.addEventListener('click', async () => {
281-
if (currentParsed) {
282-
const services = parseServices(currentParsed)
283-
const md = generateVolumeComparisonMarkdown(services)
284-
const ok = await copyToClipboard(md || 'No volumes found')
285-
volMdBtn.textContent = ok ? 'Copied!' : 'Copy failed'
286-
} else {
287-
volMdBtn.textContent = 'No data'
270+
const services = parseServices(currentParsed)
271+
const parts: string[] = []
272+
const serviceTable = generateMarkdownTable(services)
273+
if (serviceTable) {
274+
parts.push('### Services\n\n' + serviceTable)
288275
}
289-
setTimeout(() => { volMdBtn.textContent = 'Copy Volume Table' }, 1500)
276+
const volTable = generateVolumeComparisonMarkdown(services)
277+
if (volTable) {
278+
parts.push('### Volume Comparison\n\n' + volTable)
279+
}
280+
const md = parts.join('\n\n')
281+
const ok = await copyToClipboard(md || 'No services found')
282+
mdBtn.textContent = ok ? 'Copied!' : 'Copy failed'
283+
setTimeout(() => { mdBtn.textContent = 'Copy as Markdown' }, 1500)
290284
})
291-
actions.appendChild(volMdBtn)
285+
actions.appendChild(mdBtn)
292286

293287
const pbBtn = el('button', { className: 'btn btn-secondary' })
294288
pbBtn.textContent = 'Open PrivateBin'
@@ -387,6 +381,23 @@ function init(): void {
387381
// Render volume comparison table
388382
const volTable = renderVolumeTable(services)
389383
volumesContainer.appendChild(volTable)
384+
385+
// Markdown preview textarea
386+
const volMd = generateVolumeComparisonMarkdown(services)
387+
if (volMd) {
388+
const mdLabel = el('label')
389+
mdLabel.textContent = 'Markdown (for pasting into Discord / GitHub):'
390+
mdLabel.style.marginTop = '0.75rem'
391+
volumesContainer.appendChild(mdLabel)
392+
const mdPreview = el('textarea', {
393+
className: 'code-textarea',
394+
rows: String(Math.min(volMd.split('\n').length + 1, 12)),
395+
readonly: 'true',
396+
spellcheck: 'false',
397+
})
398+
mdPreview.value = volMd
399+
volumesContainer.appendChild(mdPreview)
400+
}
390401
}
391402
}
392403

0 commit comments

Comments
 (0)