Designer (web editor)
The designer is a browser-based editor for Liuska templates. It ships inside the liuska binary. Its live preview is rendered by the real engine through /api/preview, so what you see is exactly what liuska render produces.
Running it
liuska serve --templates ./templates
Then open http://127.0.0.1:8080.
- With
--templates dir, the designer lists the templates in that folder and opens and saves them directly throughGET/PUT /api/templates/{name}. Images, fonts and snippets referenced by those templates resolve relative to that folder. - Without
--templates, you can still open a template file from disk and save (download) it again. - To try it out, run
liuska serve --templates examples/invoice(or point it at another example folder) and opentemplate.
Working with templates
The screen has a canvas showing the page, an element palette, a properties panel for the selected element, and a data panel.
- Page setup: choose the size, orientation and margins. The header and footer bands are shown on the canvas, and their heights are set in the page properties.
- Add elements from the palette (text, rect, line, image, table, chart, group), then drag to move and use the handles to resize. Header and footer elements are placed inside their band.
- Properties: position and size (in pt, or a unit string such as
10mmor50%), style properties, a named style,visibleIf, and type-specific options such as textoverflowor imagefit. - Bindings: type
{{customer.name}}into text content. Filters work as in the format:{{ total | currency:"EUR" }}. See templates.md. - Tables: set the
datapath, then choose fixedcolumns(edit key, header, width, align and format per column),columnsFrom(a data path), orautoColumns. Header, row and alt-row styles, borders and totals are set in the panel. - Charts: pick the kind (bar, line, area, pie, donut, scatter) and set the
datapath and the category key. Then choose fixedseries(key, label, color, format, and per series the kind and left/right axis for combo charts),seriesFrom(a data path) orautoSeries. Stacking, horizontal bars, title, legend position, axis labels, ranges, tick formats and label rotation, data labels and palette are set in the panel. The chart is drawn by the engine in the preview, so it looks exactly as in the PDF. See templates.md. - Anchors: to make an element follow a growing table (totals, notes, signature), anchor its top edge to the table's bottom edge with an offset. Charts anchor the same way, and a table can be anchored under a chart.
- Sample data: paste or load JSON in the data panel. The canvas, preview and validation use it, but it is not part of the template: loading or pasting data does not mark the template as changed. The designer keeps it per template in the browser (localStorage), so it is there again next time you open the template. Embed in template writes it into the template as
sampleData(saved with it; Remove from template takes it out again). A template'ssampleDataFileis loaded automatically through the server, relative to its--templatesdirectory (GET /api/sample-data); when the server can't provide it (no--templates, file elsewhere), use Pick file…. When a template is opened, the browser copy wins over embeddedsampleData, which wins oversampleDataFile; Use embedded / Clear drop the browser copy. - Pages: the canvas shows every page of the document, stacked vertically, laid out by the engine (
POST /api/layout) with the current sample data. Tables continue onto the following pages (each part shows its rows and a2/5badge), elements anchored under a table appear where the table ends, repeated elements are drawn on each page they repeat on, the header and footer are on every page (with that page's{{page}}), and elements after apageBreakare on their own pages. Everything is editable on any page: click, drag, resize or nudge an element wherever it appears. A drag moves the element immediately and the page layout catches up a moment later. Header, footer and repeated elements get their handles on the page you clicked. The pager and thumbnails at the top right jump between pages. The dot next to the pager is green when the layout is current, amber while it updates, and grey when the server is not running. In that case pages come from page breaks only, and tables show their first page. - Preview: the preview re-renders as you edit and pages through multi-page output (page N of M). The server renders the page as a one-page PDF (
/api/preview?format=pdf) and the designer draws it with pdf.js, loaded the first time the preview runs. If pdf.js cannot run in the browser, the preview falls back to PNGs rendered by the server. Validation issues from/api/validate, such as unknown bindings or bad formats, are listed with the element they refer to. - Save: this writes template v1 JSON. The file works with
liuska render,batchand the HTTP API, and can be edited by hand, with schema validation in VS Code via$schema.
Developing the designer
liuska serve # API on :8080 (or from source: go -C generator run . serve)
cd editor-web
npm install
npm run dev # http://localhost:5173, proxies /api -> http://127.0.0.1:8080
Other scripts:
npm run typecheck
npm test
npm run build # -> editor-web/dist
To check a production build without rebuilding the Go binary, run liuska serve --editor-dir editor-web/dist. Release builds embed editor-web/dist into liuska (see .github/workflows/release.yml).