diff --git a/docs/app/components/prose/ReleaseImage.vue b/docs/app/components/prose/ReleaseImage.vue new file mode 100644 index 000000000..749f851e5 --- /dev/null +++ b/docs/app/components/prose/ReleaseImage.vue @@ -0,0 +1,264 @@ + + + + + + + + + + + + + + + + + + + {{ nameText }} + + + {{ labelText }} + + + + + + {{ versionLabel }}. + + + + + + + + + + + {{ urlText }} + + {{ dateText }} + + + + + + + {{ headingText }} + + + + + + + + + + + + + + + + diff --git a/docs/app/composables/useImageExport.ts b/docs/app/composables/useImageExport.ts new file mode 100644 index 000000000..159f6068f --- /dev/null +++ b/docs/app/composables/useImageExport.ts @@ -0,0 +1,77 @@ +import type { Ref } from 'vue' +import { useResizeObserver } from '@vueuse/core' + +/** + * Renders a fixed-size card scaled to fit its container, and exports it as a 2x PNG. + * Bind `viewport` to the sized wrapper and `card` to the element to capture. + */ +export function useImageExport(options: { + width: number + height: number + viewport: Ref + card: Ref + fileName: () => string +}) { + const { width, height, viewport, card } = options + const scale = ref(1) + const busy = ref(false) + const toast = useToast() + + useResizeObserver(viewport, ([entry]) => { + if (entry) scale.value = Math.min(1, entry.contentRect.width / width) + }) + + async function capture(): Promise { + if (!card.value) return null + const { domToBlob } = await import('modern-screenshot') + await document.fonts?.ready + return domToBlob(card.value, { + width, + height, + scale: 2, + type: 'image/png', + // The card is scaled through its wrapper; reset any inherited transform on the clone. + style: { transform: 'none', margin: '0' }, + }) + } + + async function run(action: (blob: Blob) => Promise | void, success: string) { + if (busy.value) return + busy.value = true + try { + const blob = await capture() + if (!blob) throw new Error('Nothing to capture') + await action(blob) + toast.add({ title: success, icon: 'i-lucide-check', color: 'success' }) + } catch (error) { + toast.add({ + title: 'Could not export the image', + description: error instanceof Error ? error.message : String(error), + icon: 'i-lucide-circle-alert', + color: 'error', + }) + } finally { + busy.value = false + } + } + + function download() { + const name = options.fileName() + return run((blob) => { + const href = URL.createObjectURL(blob) + const link = document.createElement('a') + link.href = href + link.download = name + link.click() + URL.revokeObjectURL(href) + }, `Downloaded ${name}`) + } + + function copy() { + return run(async (blob) => { + await navigator.clipboard.write([new ClipboardItem({ 'image/png': blob })]) + }, 'Image copied to clipboard') + } + + return { scale, busy, download, copy } +} diff --git a/docs/app/constants/index.ts b/docs/app/constants/index.ts index 736a74bcd..9543f3de2 100644 --- a/docs/app/constants/index.ts +++ b/docs/app/constants/index.ts @@ -435,6 +435,30 @@ Free for up to 5 services. No credit card. Deploys in under a minute. :: ` +export const releaseImageMarkdown = `::release-image +\`\`\`yaml [props] +name: Comark +version: 0.9.0 +date: November 2026 +label: Release +url: comark.dev +heading: What's new +color: '#facc15' +\`\`\` +- \`transformNode\`: change any node at render time, in every renderer +- \`comark/core\`: a smaller parser with no default plugins +- New \`heading-links\` plugin + + 15+ fixes across parsing, Markdown round-trips, and renderers. + +#title +Round-trip safe rendering + +#description +Fixes across Shiki, auto-close and \`renderMarkdown\`. +:: +` + export type AiMode = 'showcase' | 'nuxt-ui' export type PlaygroundExample = { @@ -474,6 +498,11 @@ export const playgroundExamples: PlaygroundExample[] = [ mode: 'nuxt-ui', prompt: 'Landing page for a mountain bike rental in the Alps.', }, + { + label: 'Release image', + value: 'release-image', + content: releaseImageMarkdown, + }, ] export const defaultMarkdown = bookingMarkdown diff --git a/docs/app/utils/components-manifest.ts b/docs/app/utils/components-manifest.ts index 961a00f11..96cc306c8 100644 --- a/docs/app/utils/components-manifest.ts +++ b/docs/app/utils/components-manifest.ts @@ -55,6 +55,7 @@ const components: Record Promise> = { TwoColumn: () => import('@/components/playground/TwoColumn.vue'), BookingCard: () => import('@/components/playground/BookingCard.vue'), Ingredients: () => import('@/components/playground/Ingredients.vue'), + ReleaseImage: () => import('@/components/prose/ReleaseImage.vue'), } export default function resolveComponent(name: string) { diff --git a/docs/package.json b/docs/package.json index 286cf8ce6..3f9186da1 100644 --- a/docs/package.json +++ b/docs/package.json @@ -26,6 +26,7 @@ "comark": "workspace:*", "comark-docs": "github:comarkdown/comark-docs#96c1546e33286e6ce4329e46f2b8a57d8f162891", "katex": "catalog:", + "modern-screenshot": "catalog:", "nuxt": "catalog:", "splitpanes": "catalog:", "ufo": "catalog:", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d01257a0d..814a2dc78 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -347,6 +347,9 @@ catalogs: mitata: specifier: ^1.0.34 version: 1.0.34 + modern-screenshot: + specifier: ^4.7.0 + version: 4.7.0 next: specifier: ^16.4.3 version: 16.4.3 @@ -591,6 +594,9 @@ importers: katex: specifier: 'catalog:' version: 0.19.1 + modern-screenshot: + specifier: 'catalog:' + version: 4.7.0 nuxt: specifier: 'catalog:' version: 4.6.4(@babel/plugin-syntax-jsx@7.29.7(@babel/core@7.29.7(supports-color@10.2.2)))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.7(supports-color@10.2.2)))(@oxc-project/types@0.150.0)(@parcel/watcher@2.6.0)(@types/node@26.6.6)(@vercel/functions@3.10.3(ws@8.22.0))(@vue/compiler-sfc@3.5.44)(acorn@8.18.0)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1(supports-color@10.2.2))(lightningcss@1.33.0)(mlly@1.8.2)(oxc-parser@0.153.0)(oxlint@1.90.0)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.67.4))(rollup@4.67.4)(sass-embedded@1.104.1)(sass@1.104.1)(srvx@1.0.5)(supports-color@10.2.2)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.104.1)(sass@1.104.1)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue-tsc@3.3.14(typescript@6.0.3))(yaml@2.9.1) @@ -8143,6 +8149,9 @@ packages: mocked-exports@0.1.1: resolution: {integrity: sha512-aF7yRQr/Q0O2/4pIXm6PZ5G+jAd7QS4Yu8m+WEeEHGnbo+7mE36CbLSDQiXYV8bVL3NfmdeqPJct0tUlnjVSnA==} + modern-screenshot@4.7.0: + resolution: {integrity: sha512-9YxN+ddPSMMlhylOv25VHzXrl9u67QRxoh7+SEewGtgUw7t6hHTrjptSDJUSne9oG4Xk/h2cwG15nIt4Hc9ujg==} + module-details-from-path@1.0.4: resolution: {integrity: sha512-EGWKgxALGMgzvxYF1UyGTy0HXX/2vHLkw6+NvDKW2jypWbHpjQuj4UMcqQWXHERJhVGKikolT06G3bcKe4fi7w==} @@ -17113,6 +17122,8 @@ snapshots: mocked-exports@0.1.1: {} + modern-screenshot@4.7.0: {} + module-details-from-path@1.0.4: {} motion-dom@14.3.1: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 606dffe58..7568f3a1a 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -28,6 +28,7 @@ catalog: # Misc "@json-render/core": ^0.21.3 "@monaco-editor/loader": ^1.7.0 + modern-screenshot: ^4.7.0 "@nuxt/devtools-kit": 4.0.0 # Keep kit on the same minor line as `nuxt` so `@nuxt/schema` stays singular # (dual schema breaks `defineNuxtModule` setup typing + declaration emit).
+ {{ versionLabel }}. +
+ {{ headingText }} +