* docs(playground): plan file workspace * docs(playground): refine file workspace plan * feat(playground): add mounted file workspace * fix(playground): address file workspace review * chore(playground): remove stale workspace scaffolding * fix(cli): read per-template example metadata * fix(playground): add form link after designer save * feat(playground): standardize template metadata * feat(playground): manage mounted workspace metadata * feat(playground): rename mounted folders from metadata title * fix(playground): harden mounted workspace refresh
This repository is a playground and development environment for the https://github.com/pdfme/pdfme library. It can be started with the following command.
root directory
$ npm install
$ npm run build
playground directory
$ npm install
$ npm run dev
If you are developing a pdfme library, please refer to the following document. https://github.com/pdfme/pdfme/blob/main/DEVELOPMENT.md
How to Add Sample Templates
The playground/public/template-assets directory is the source of the sample template gallery used by the playground.
Each gallery item is a directory under playground/public/template-assets/<template-name>/.
Designer templates
Use this flow for normal pdfme templates:
- Create a kebab-case directory in
playground/public/template-assets.- Example:
playground/public/template-assets/invoice-blue.
- Example:
- Put
template.jsonin that directory.- You can create it with the playground Designer and download the Template JSON.
- Add gallery metadata in
playground/public/template-assets/<template-name>/metadata.json.
Example:
{
"order": 200,
"description": "A blue invoice variant for a more branded business document.",
"tags": ["Invoice", "Business", "Table"]
}
Supported metadata fields:
title: optional display title. If omitted, the directory name is converted from kebab-case.order: optional gallery sort order. Lower numbers appear first; leave gaps such as10,20, and30so new templates can be inserted later. Templates withoutorderappear after ordered templates and are sorted by title/name.description: short card description shown in the template gallery.tags: filter tags shown on the card and in the gallery filter.sourceKind: optional generation kind. Use"designer","jsx", or"md2pdf". Normaltemplate.jsonsamples can omit this; they default to"designer".
Template metadata is validated during asset generation. Every template directory with a
template.json must have metadata, and metadata entries without a matching template directory fail
the build.
JSX and md2pdf starters
JSX and md2pdf starters live in the same template-assets gallery. Their source is stored beside
the generated template so the source, metadata, thumbnail, and generated template.json move
together.
- JSX starters use
playground/public/template-assets/<starter-name>/source.tsx. - md2pdf starters use
playground/public/template-assets/<starter-name>/source.md. - Add
metadata.jsonin the same directory withsourceKind: "jsx"orsourceKind: "md2pdf". - Use names such as
jsx-invoiceormd2pdf-overviewso the gallery type can also be inferred. - Give generated starters a human-readable
title; otherwise the gallery falls back to the directory name. - Use
orderwhen a starter should appear in the first screen of the gallery.
Example:
{
"title": "Invoice layout",
"description": "A two-page invoice generated from JSX authoring source.",
"sourceKind": "jsx",
"tags": ["Invoice", "Business", "Table"]
}
Regenerate assets
After changing templates or metadata, run this from the playground directory:
npm run generate-template-assets
This command:
- generates JSX/md2pdf starter
template.jsonfiles, - regenerates
index.jsonandmanifest.json, - creates or updates
thumbnail.pngfor each template, - keeps only the current versioned manifest under
template-assets/manifests/.
npm run dev and npm run build also run this command automatically.
Before committing, include the updated template directory, metadata files, generated
manifest.json, and versioned manifest. The generated index.json, thumbnail PNGs, and hash-map
cache files are intentionally ignored.