diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..3f0c38a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,79 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +- Focusing on what is best not just for us as individuals, but for the overall community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or advances of any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [contact@deityhub.com](mailto:contact@deityhub.com). All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of actions. + +**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at . + +Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). + +For answers to common questions about this code of conduct, see the FAQ at . Translations are available at . + +[homepage]: https://www.contributor-covenant.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..06a8a1a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,77 @@ +# Contributing to Lienzo + +Thanks for helping. Bug reports, ideas, documentation fixes and code are all welcome. By taking part you agree to follow the [Code of Conduct](CODE_OF_CONDUCT.md). For a security problem, please follow [SECURITY.md](SECURITY.md) instead of opening an issue. + +## Ways to help + +- **Report a bug or suggest something:** open a [GitHub issue](https://github.com/Deityhub/lienzo/issues). For a bug, say what you did, what you expected, what happened, and your browser. A screenshot or a `.lienzo.json` file that shows it helps. +- **Ask a question or share an idea:** use [GitHub Discussions](https://github.com/Deityhub/lienzo/discussions). +- **Send a change:** see below. For anything bigger than a small fix, please open an issue first so we can agree on the approach before you spend time on it. + +## Set up + +You need Node.js 22 (see `.nvmrc`) and Yarn 4 (`corepack enable` picks the pinned version). + +```bash +git clone https://github.com//lienzo.git +cd lienzo +yarn install +yarn dev # http://localhost:5173 +``` + +## Make a change + +1. Fork the repository and create a branch from `develop`, for example `feat/text-alignment` or `fix/resize-offset`. +2. Make the change, and add or update tests for it. +3. Run the same checks CI runs: + + ```bash + yarn lint # Prettier and ESLint + yarn check # types + yarn test:unit:run # unit and browser-component tests + yarn test:e2e # builds the app and runs the Playwright tests (Chromium) + ``` + + `yarn format` fixes formatting. The first time, run `yarn playwright install chromium`. + +4. Open a pull request into `develop` and fill in the template. + +### Pull request titles and commits + +Pull requests are squash-merged, and the PR title becomes the commit message, so it must follow [Conventional Commits](https://www.conventionalcommits.org/) (CI checks this): `feat: add text alignment`, `fix: resize handle offset`, `docs: explain backups`. `feat`, `fix`, `perf`, `refactor` and `docs` appear in the changelog; `chore`, `ci`, `test` and similar do not. + +### Code style + +- TypeScript and Svelte 5 with runes (`$state`, `$derived`, `$effect`). State shared between components lives in `.svelte.ts` files. +- Keep pure logic (geometry, sorting, file formats) in `src/lib/utils` as plain functions with unit tests, apart from the components. +- Colours, spacing and radii come from the theme tokens in `src/app.css`, so both the light and the dark theme work. Please check a change in both. +- Interfaces must work with the keyboard and a screen reader: real buttons, labels for icon-only controls, visible focus, and touch targets of at least 44px on phones. + +### Tests + +- **Unit tests** (`*.spec.ts`) run in Node. Tests that need a browser (`*.browser.spec.ts`) run in Chromium. +- **End-to-end tests** (`e2e/`) run against a production build on port 4173. To keep them reliable on any machine: + - wait for hydration (`waitForLoadState('networkidle')`) before the first click; + - assert on the saved data (read from IndexedDB, in page units) rather than on screen pixels; + - use `dragTo` for drags, and `hasTouch: true` for tap tests. + +## Documentation and generated files + +- Update the README and other docs when behaviour changes. +- If you add or remove a runtime dependency or a font, run `yarn notices` to refresh [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). +- If you add a font, also regenerate the PDF export fonts with `python3 scripts/generate-pdf-fonts.py` (needs `fonttools` and `brotli`). +- The icons and the social image are generated by `yarn brand:assets`; the screenshots in the README by `yarn docs:screenshots`. + +## Releases + +Lienzo follows [Semantic Versioning](https://semver.org/) and keeps a [CHANGELOG](CHANGELOG.md) generated from the commit titles. + +1. In GitHub, go to Actions, then **Prepare Release**, and run it on `develop` with `patch`, `minor` or `major`. It opens a `chore(release): vX.Y.Z` pull request that bumps `package.json` and the changelog. +2. Merge that pull request into `develop`. +3. Open a pull request from `develop` into `main` and merge it with a merge commit. The **Release** workflow tags the version and creates the GitHub release; the Docker image is published to GHCR and Docker Hub. + +To run CI on the release pull request, add a personal access token as the repository secret `RELEASE_TOKEN`. + +## License + +Lienzo is licensed under the [GNU GPLv3](LICENSE). By contributing you agree that your contribution is licensed under the same terms. diff --git a/README.md b/README.md index 540f28d..3bd69b3 100644 --- a/README.md +++ b/README.md @@ -1,327 +1,67 @@ # Lienzo -A modern, open-source document builder built with Svelte 5, TypeScript, and Tailwind CSS. Create professional documents (resumes, invoices, letters, and more) with an intuitive drag-and-drop canvas interface, featuring advanced ruler boundaries and real-time editing capabilities. +A free document builder for A4 pages. Place text, shapes and images, start from a template, and export a PDF that keeps real, selectable text and carries your editable document inside it. No account, and nothing leaves your browser. -![CI](https://github.com/Deityhub/lienzo/workflows/CI/badge.svg) -![PR Checks](https://github.com/Deityhub/lienzo/workflows/PR%20Checks/badge.svg) +[![CI](https://github.com/Deityhub/lienzo/actions/workflows/ci.yml/badge.svg)](https://github.com/Deityhub/lienzo/actions/workflows/ci.yml) +[![License: GPL v3](https://img.shields.io/badge/license-GPLv3-blue.svg)](LICENSE) -## ๐Ÿš€ Features +**Try it: ** -### Core Features + + + The Lienzo editor with an invoice template open + -- **Drag-and-Drop Interface**: Intuitive canvas-based document creation with real-time preview -- **Multiple Element Types**: Text, shapes, and images with full customization -- **Real-time Editing**: Live preview with instant updates and inline text editing -- **Multi-page Support**: Create documents with unlimited pages -- **Nested Elements**: Elements can contain other elements (hierarchical structure) -- **UUID-based IDs**: Cryptographically secure unique identifiers for all elements -- **Backup & Transfer**: Export documents to a `.lienzo.json` file and import them back (see below) -- **Versatile Use Cases**: Perfect for resumes, invoices, letters, certificates, and more +## What you can do -### Advanced Canvas Tools +- **Design on a canvas.** Add text, shapes (rectangles, circles, triangles, lines, arrows and more) and images, then move, resize, layer and style them. Rulers set the margins of each page, and elements stay inside them. +- **Start from a template.** 22 ready-made layouts: resumes, letters, invoices, flyers, certificates, menus, planners and more. Each is a normal document, so you can change anything. +- **Work with several elements.** Select many at once, group them, copy, cut, paste and duplicate (also between documents and tabs), and move them to another page. Pictures can be pasted straight in. +- **Never lose work.** Documents save automatically in your browser a moment after each change. +- **Export a real PDF.** Text stays text and shapes stay vector, with fonts embedded. The editable document is stored inside the PDF, so importing that PDF later brings your design back. +- **Back up and move.** Export one document or all of them as `.lienzo.json` files, and import them in another browser or on another device. +- **Light, dark or system theme,** and a layout that works on a phone. The page you design is always white, so a document looks the same in every theme. +- **14 font families,** loaded only when a document uses them. -- **Professional Ruler System**: - - Horizontal and vertical rulers with tick marks (major, minor, tiny) - - Draggable triangle markers for boundary adjustment - - Real-time boundary visualization -- **Smart Element Positioning**: - - Snap-to-grid with 10px threshold - - Boundary enforcement (elements stay within defined areas) - - Dynamic sizing based on drop position - - Automatic element reparenting on drag + + + The template gallery + -- **Advanced Resize Tool**: - - 4 edge handles for width/height adjustment - - 4 corner handles for proportional resize - - Minimum size enforcement (20px) - - Visual feedback with hover states +## Run it yourself -### Element Management - -- **Text Elements**: - - Inline contenteditable text - - Font family, size, weight, and style customization - - Color picker - - Full typography control - -- **Shape Elements**: - - **Basic Shapes**: Rectangle, Circle, Ellipse, Triangle, Diamond, Hexagon, Pentagon - - **Lines & Arrows**: Horizontal, Vertical, and Directional Arrows (up, down, left, right) - - **Styling Options**: - - Custom stroke color and width - - Fill color with opacity control - - Stroke styles: solid, dashed, or dotted - - Corner radius for rectangles - - Rotation support - - **Use Cases**: - - Visual dividers and section breaks - - Decorative elements and icons - - Flow charts and diagrams - - Highlighting important content - -- **Image Elements**: - - URL-based image loading - - Alt text support - - Responsive sizing - -### Visual Feedback System - -- **Element Highlighting**: - - Blue ring: Selected element - - Yellow ring: Elements underneath (overlapping) - - Green ring: Element being hovered during drag - - Purple dashed outline: Drag preview -- **Drag Operations**: - - Real-time drag preview - - ESC key to cancel drag - - Automatic cleanup on drag leave - - Parent detection and highlighting - -### Property Panel - -- **Position & Size**: Precise X, Y, width, height controls -- **Typography**: Font family, size, weight, style, color -- **Shape Properties**: Type, stroke color, stroke width -- **Image Properties**: URL, alt text -- **Element Actions**: Delete button with confirmation - -## ๐Ÿ› ๏ธ Technology Stack - -- **Framework**: Svelte 5 (SvelteKit) -- **Language**: TypeScript -- **Styling**: Tailwind CSS -- **Build Tool**: Vite -- **Testing**: Vitest + Playwright -- **Code Quality**: ESLint + Prettier -- **Deployment**: Vercel, or Docker (GHCR and Docker Hub) - -## ๐Ÿ“‹ Prerequisites - -- **Node.js** 22 (see `.nvmrc`) -- **Yarn** 4 (run `corepack enable`; the version is pinned via `packageManager`) -- **Git** - -## ๐Ÿš€ Quick Start - -### Installation - -1. **Clone the repository** - - ```bash - git clone https://github.com/your-username/lienzo.git - cd lienzo - ``` - -2. **Install dependencies** - - ```bash - yarn install - ``` - -3. **Start development server** - - ```bash - yarn dev - ``` - -4. **Open your browser** - Navigate to `http://localhost:5173` - -### Build for Production - -```bash -# Build the application -yarn build - -# Preview production build -yarn preview -``` - -## ๐ŸŽจ Key Components - -### Canvas - -The main canvas component that handles: - -- Element rendering with zIndex sorting -- Drag-and-drop with real-time preview -- Boundary enforcement and snapping -- Ruler integration and visualization -- Element reparenting on drag -- Nested element flattening for display - -### Ruler System - -Professional boundary controls featuring: - -- Horizontal and vertical rulers (Google Docs style) -- Draggable triangle markers (blue for start, red for end) -- Three-tier tick marks: - - Major ticks (12px) every 100px - - Minor ticks (8px) every 50px - - Tiny ticks (4px) every 10px -- Real-time boundary updates with reactive effects -- Coordinate scaling for accurate positioning - -### Property Panel - -Comprehensive styling interface for: - -- Position and dimensions (X, Y, width, height) -- Typography (7 font families, 12 font sizes) -- Font weight (normal, bold) and style (normal, italic) -- Color picker for text and shapes -- Element-specific properties -- Delete functionality - -### Resize Tool - -Advanced resize system with: - -- **4 Edge Handles**: 60px ร— 4px bars for width/height -- **4 Corner Handles**: 12px circles for proportional resize -- **8 Resize Directions**: n, s, e, w, nw, ne, sw, se -- Visual feedback with hover states -- Boundary-aware resizing - -## ๐Ÿ”ง Development - -### Available Scripts - -```bash -# Development -yarn dev # Start development server -yarn dev -- --open # Open browser automatically - -# Building -yarn build # Production build -yarn preview # Preview production build - -# Code Quality -yarn lint # Run ESLint -yarn format # Format code with Prettier -yarn check # Type checking - -# Testing -yarn test # Run all tests -yarn test:unit # Unit tests only -yarn test:e2e # End-to-end tests -``` - -### Code Style - -This project follows: - -- **Prettier** for code formatting -- **ESLint** for linting -- **TypeScript** for type safety -- **Svelte 5** syntax and patterns - -### Key Development Patterns - -1. **State Management**: Uses Svelte 5 runes (`$state`, `$derived`) -2. **Component Architecture**: Functional components with clear props -3. **TypeScript**: Full type safety across the application -4. **Responsive Design**: Mobile-first approach with Tailwind CSS - -## ๐ŸŽฏ Usage Guide - -### Creating a Document - -1. **Navigate to Builder**: Click "Start Building" from the homepage -2. **Add Elements**: Drag text, shapes, or images from the toolbar -3. **Customize Elements**: Select elements to edit properties in the panel -4. **Adjust Boundaries**: Drag ruler markers to set canvas boundaries -5. **Multi-page Support**: Add additional pages as needed -6. **Save & Export**: Your work is saved automatically in your browser a moment after each change (a new document is called "Untitled document" until you name it with **Save**). Export it as a PDF when you are done -7. **Light or dark**: The switch in the header changes the theme. It starts from your system setting and remembers your choice. The page you design is always white, so a document looks the same in both. - -### Element Manipulation - -- **Move**: Click and drag elements on the canvas -- **Resize**: Use corner handles on selected elements -- **Edit**: Select elements to modify properties in the panel -- **Delete**: Use the delete button in the property panel - -### Boundary System - -- **Set Boundaries**: Drag triangle markers on rulers -- **Snap-to-Grid**: Elements automatically align to boundaries -- **Boundary Enforcement**: Elements cannot move outside defined areas -- **Auto-constrain**: Elements automatically adjust when boundaries change - -## ๐Ÿงช Testing - -This project has comprehensive test coverage for most features. - -### Unit Tests +You need Node.js 22 (see `.nvmrc`) and Yarn 4 (`corepack enable` picks the pinned version). ```bash -yarn test:unit +git clone https://github.com/Deityhub/lienzo.git +cd lienzo +yarn install +yarn dev # http://localhost:5173 ``` -**Test Coverage:** - -- โœ… Page Management (create, delete, UUID generation) -- โœ… Ruler Boundaries (initialization, updates, validation) -- โœ… Element Management (add, update, delete, UUID generation) -- โœ… Element Selection (select, deselect) -- โœ… Nested Elements (parent-child relationships, finding, moving) -- โœ… zIndex Management (automatic assignment) -- โœ… Store State Management (reactive updates) - -**Total Unit Tests**: 20+ tests covering all store functionality - -### End-to-End Tests - -```bash -yarn test:e2e -``` - -**Test Coverage:** - -- โœ… Navigation (home, create, about pages) -- โœ… Page Management (add pages, page counter) -- โœ… Drag and Drop (text, shape, image elements) -- โœ… Element Selection (select, deselect) -- โœ… Element Manipulation (resize handles, delete) -- โœ… Property Updates (font size, font family) -- โœ… UI Components (toolbar, canvas, property panel, rulers) -- โœ… Boundary Visualization (rulers, boundary box) -- โœ… Multi-element Workflows (adding multiple elements) - -**Total E2E Tests**: 14 comprehensive workflow tests - -### Run All Tests - -```bash -yarn test -``` - -This runs both unit and e2e tests sequentially. - -## ๐Ÿš€ Deployment - -### Vercel (Recommended) - -1. **Connect Repository**: Link your GitHub repository to Vercel -2. **Automatic Deployments**: Every push to main branch triggers deployment -3. **Environment Variables**: Configure any required environment variables +| Command | What it does | +| ----------------------- | ----------------------------------------------------------- | +| `yarn build` | Production build (targets Vercel) | +| `yarn preview` | Serve the production build | +| `yarn lint` | Prettier and ESLint checks | +| `yarn format` | Format the code | +| `yarn check` | Type check | +| `yarn test:unit:run` | Unit and browser-component tests (Vitest) | +| `yarn test:e2e` | End-to-end tests (Playwright; builds the app first) | +| `yarn test` | Both test suites | +| `yarn brand:assets` | Regenerate the favicons, app icons and social image | +| `yarn docs:screenshots` | Retake the screenshots in this README | +| `yarn notices` | Regenerate [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) | ### Docker -A multi-arch (amd64/arm64) image is published to GitHub Container Registry and Docker Hub on every release: +A multi-arch (amd64 and arm64) image is published to GitHub Container Registry and Docker Hub with every release. ```bash docker run -p 3000:3000 -e ORIGIN=http://localhost:3000 ghcr.io/deityhub/lienzo:latest ``` -The same image is on Docker Hub as `deityhub/lienzo`. Pin a version with a tag instead of `latest` (e.g. `ghcr.io/deityhub/lienzo:1.1.0`). To build it yourself: - -```bash -docker build -t lienzo . -docker compose up --build # http://localhost:3000 -``` +The same image is on Docker Hub as `deityhub/lienzo`. Use a version tag instead of `latest` to pin a release, for example `ghcr.io/deityhub/lienzo:1.1.0`. To build it yourself, run `docker compose up --build` (). | Variable | Default | Description | | -------- | ------------------------ | ------------------------------------------------------------------ | @@ -329,80 +69,40 @@ docker compose up --build # http://localhost:3000 | `PORT` | `3000` | Port the server listens on | | `HOST` | `0.0.0.0` | Interface the server binds to | -The image is built with `adapter-node` (`ADAPTER=node`); the default `yarn build` keeps targeting Vercel. Without Docker: `ADAPTER=node yarn build && node build`. - -## ๐Ÿค Contributing - -We welcome contributions! Here's how to get involved: - -### Getting Started - -1. **Fork** the repository -2. **Clone** your fork -3. **Create** a feature branch: `git checkout -b feature/amazing-feature` -4. **Install** dependencies: `yarn install` -5. **Start** development: `yarn dev` - -### Contribution Guidelines +The image uses `adapter-node` (`ADAPTER=node`); the default build targets Vercel. Without Docker: `ADAPTER=node yarn build && node build`. -1. **Code Style**: Follow existing patterns and run `yarn format` -2. **Tests**: Add tests for new features -3. **Documentation**: Update README for significant changes -4. **Pull Requests**: Use a [Conventional Commits](https://www.conventionalcommits.org/) title (e.g. `feat: add text alignment`, `fix: resize handle offset`). It is checked in CI and drives versioning +## Your documents and your data -### Development Workflow +Documents are stored only in your browser (IndexedDB). There is no server-side storage and no account, so export your documents to keep a backup or to move them. On the **Documents** page: -1. Create a feature branch -2. Make your changes -3. Add tests if applicable -4. Run the test suite: `yarn test` -5. Format code: `yarn format` -6. Submit a pull request +- **Export** on a card downloads that document as `.lienzo.json`, and **Export all** downloads everything in one file. +- **Import** reads `.lienzo.json` files and PDFs exported from Lienzo. If a document with the same id already exists, you choose **Replace existing** or **Keep both**. Documents from older versions are upgraded automatically, and invalid ones are skipped and listed. +- In the editor, **Import** loads a single document as a new one, so saving never overwrites an existing document. -## ๐Ÿ’พ Backup & Transfer +**About the PDF.** Every PDF exported from Lienzo has the editable document embedded as an attachment (`lienzo-document.json`), so the PDF you share is also a full backup. PDFs from other tools hold no such data and cannot be imported. Limits: characters outside Latin and Latin-extended show as `?`, images from sites that block downloads are left blank (you are told), image shadows are not drawn, and a PDF editor edits text line by line. -Documents are stored only in your browser (IndexedDB), so export them to keep a backup or move them to another browser or device. On the **Documents** page: +Images are kept inside the document when you paste a picture, and by address when you give a URL, in which case the address must stay reachable. -- **Export** (on a document card) downloads that document as `.lienzo.json`. -- **Export all** downloads every document in one `lienzo-documents-.lienzo.json` file. -- **Import** reads one or more `.lienzo.json` files. New documents are added as they are. If a document with the same id is already in your library, you choose **Replace existing** (overwrites it) or **Keep both** (imports a separate copy, with `(imported)` appended to the name). Documents from older versions are upgraded automatically; invalid ones are skipped and listed. +## Built with -**PDF export is real text and vector shapes, not a screenshot.** Text can be selected and edited in a PDF editor, and fonts are embedded (only the characters you use). Limits: characters outside Latin and Latin-extended show as `?`, images from other websites that block downloads are left blank (you are told when that happens), image shadows are not drawn, and text lines are separate text runs, so a PDF editor edits them line by line. The export fonts are generated from the editor fonts with `python3 scripts/generate-pdf-fonts.py` (needs `fonttools` and `brotli`); re-run it when a font is added. +[Svelte 5](https://svelte.dev/) and [SvelteKit](https://svelte.dev/docs/kit), TypeScript, [Tailwind CSS](https://tailwindcss.com/) 4, Vite, [pdf-lib](https://github.com/cantoo-scribe/pdf-lib) for the PDF, and [Lucide](https://lucide.dev/) icons. Tested with Vitest and Playwright. Deployed on Vercel, or as a Docker image. The visual design follows [Fluent 2](https://fluent2.microsoft.design/). Everything that ships with the app, with its license, is listed in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). -**PDFs exported from Lienzo can be imported too.** Every exported PDF has the editable document embedded inside it (as an attachment named `lienzo-document.json`), so the PDF you share is also a full backup. Choose it in either Import button, on the Documents page or in the editor. PDFs that were not exported from Lienzo contain no document data and cannot be imported. Import detects PDFs by content, so renaming the file does not matter. - -In the **editor**, the Import button loads a single-document file into the canvas, replacing its current content (you are asked first if the canvas is not empty). It is loaded as a new document, so saving it never overwrites an existing one. - -Image elements store a URL, so an imported document needs those images to still be reachable. - -## ๐Ÿท๏ธ Versioning & Releases - -Lienzo follows [Semantic Versioning](https://semver.org/) and keeps a [CHANGELOG](CHANGELOG.md) generated from [Conventional Commits](https://www.conventionalcommits.org/). PRs are squash-merged into `develop` with a Conventional Commit title (`feat:`, `fix:`, `perf:`, `refactor:`, `docs:` appear in the changelog; `chore:`, `ci:`, `test:` etc. do not). - -To cut a release: - -1. **Prepare:** In GitHub, go to Actions โ†’ **Prepare Release** โ†’ Run workflow on `develop` and choose `patch`, `minor` or `major`. It opens a `chore(release): vX.Y.Z` PR into `develop` that bumps `package.json` and updates `CHANGELOG.md`. -2. **Merge** that PR into `develop`. -3. **Publish:** Open a PR from `develop` into `main` and merge it (use a merge commit so branches stay aligned). The **Release** workflow tags `vX.Y.Z` and creates the GitHub Release with the changelog notes. - -The running version is shown in the landing page footer. To make CI run on the release PR, add a personal access token as the repo secret `RELEASE_TOKEN`. - -## ๐Ÿ“ License - -This project is open source and available under the [GNU GPLv3 License](LICENSE). - -## ๐Ÿ™ Acknowledgments +``` +src/lib/canvas editing behaviour: dragging, resizing, selection, autosave, clipboard +src/lib/pdf the PDF exporter +src/lib/stores app state and the IndexedDB layer, with migrations +src/lib/templates the template catalogue +src/lib/utils pure helpers: geometry, file formats, sorting +src/routes home, templates, documents and the editor +e2e end-to-end tests +``` -- Built with [Svelte 5](https://svelte.dev/) and [SvelteKit](https://svelte.dev/docs/kit) -- Styled with [Tailwind CSS](https://tailwindcss.com/) -- Icons from [Lucide Svelte](https://lucide.dev/) +## Contributing -## ๐Ÿ“ž Support +Contributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) first (it covers setup, checks, commit titles and releases) and follow the [Code of Conduct](CODE_OF_CONDUCT.md). To report a security problem, see [SECURITY.md](SECURITY.md). Changes are listed in the [CHANGELOG](CHANGELOG.md). -- **Issues**: Use GitHub Issues for bug reports and feature requests -- **Discussions**: Use GitHub Discussions for questions and ideas -- **Contributing**: See our contributing guidelines above +## License ---- +Lienzo is open source under the [GNU GPLv3](LICENSE). Third-party software and fonts keep their own licenses; see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). -**Made with โค๏ธ by [Deityhub](https://github.com/Deityhub) - Create beautiful documents with ease** +Made by [Chizoba Jude Ojini](https://judeojini.com). diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..da65230 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,40 @@ +# Security policy + +## Reporting a vulnerability + +Please do not open a public issue for a security problem. + +Report it privately instead: + +- Use GitHub's [private vulnerability reporting](https://github.com/Deityhub/lienzo/security/advisories/new) for this repository, or +- Email [contact@deityhub.com](mailto:contact@deityhub.com) with "Lienzo security" in the subject. + +Please include what you found, the steps to reproduce it, the browser and version, and what an attacker could do with it. A small example file or a screen recording helps. + +What you can expect: + +- A reply within 5 working days to confirm that we have your report. +- A fix, or a plan for one, as soon as the problem is understood. We will keep you updated. +- Credit in the release notes when the fix ships, unless you would rather stay anonymous. + +Please give us a reasonable time to fix the problem before you share it publicly. + +## Supported versions + +Only the latest release gets security fixes. Lienzo is a web app, so the hosted site at is always the latest release. If you run your own copy (for example the Docker image), please keep it up to date. + +## What matters most here + +Lienzo has no accounts and no server-side storage. Documents live in the browser (IndexedDB) and are never uploaded. The areas where a bug would matter most are: + +- **Opening files.** Importing a `.lienzo.json` file or a PDF exported from Lienzo reads untrusted content. A crafted file should never run code, break out of the page or damage other saved documents. +- **Pasting and dropping.** Content from the clipboard or dragged in from elsewhere. +- **Images from a web address.** Image elements load a URL, and PDF export fetches it. +- **Saved data.** Anything that could let one site read or change the documents saved by another. +- **The Docker image and the Node server build,** including the headers and defaults they ship with. + +Out of scope: problems that need a user to already control their own browser (for example, running code in their own developer console), and findings in third-party services we link to. + +## Dependencies + +Dependencies are updated weekly by Dependabot, and every change goes through CI. The packages that ship with the app are listed in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md new file mode 100644 index 0000000..b5e0d87 --- /dev/null +++ b/THIRD_PARTY_NOTICES.md @@ -0,0 +1,145 @@ +# Third-party notices + +Lienzo itself is licensed under the [GNU GPLv3](LICENSE). It includes the open source software and fonts below, each under its own license. This file is generated by `yarn notices`; do not edit it by hand. + +## Software + +These packages are part of the app that runs in your browser or on the server. Tools used only to build and test Lienzo are not included, because they are not distributed with it. + +| Package | Version | License | Copyright | +| --------------------------- | ------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| @cantoo/fontkit | 2.0.12 | MIT | Copyright 2014-present Devon Govett | +| @cantoo/pdf-lib | 2.11.1 | MIT | Copyright 2019 Andrew Dillon | +| @jridgewell/gen-mapping | 0.3.13 | MIT | Copyright 2024 Justin Ridgewell | +| @jridgewell/remapping | 2.3.5 | MIT | Copyright 2024 Justin Ridgewell | +| @jridgewell/resolve-uri | 3.1.2 | MIT | Copyright 2019 Justin Ridgewell | +| @jridgewell/sourcemap-codec | 1.5.5 | MIT | Copyright 2024 Justin Ridgewell | +| @jridgewell/trace-mapping | 0.3.31 | MIT | Copyright 2024 Justin Ridgewell | +| @lucide/svelte | 0.548.0 | ISC | Copyright for portions of Lucide are held by Cole Bemis 2013-2023 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2025. | +| @polka/url | 1.0.0-next.29 | MIT | See the package | +| @standard-schema/spec | 1.0.0 | MIT | Copyright 2024 Colin McDonnell | +| @sveltejs/acorn-typescript | 1.0.5 | MIT | Copyright 2022 Tyreal Hu | +| @sveltejs/kit | 2.43.4 | MIT | Copyright 2020 these people | +| @types/cookie | 0.6.0 | MIT | See the package | +| @types/estree | 1.0.8 | MIT | See the package | +| acorn | 8.15.0 | MIT | Copyright 2012-2022 by various contributors (see AUTHORS) | +| aria-query | 5.3.0 | Apache-2.0 | Copyright 2020 A11yance | +| axobject-query | 4.1.0 | Apache-2.0 | Copyright 2020 A11yance | +| base64-js | 1.5.1 | MIT | Copyright 2014 Jameson Little | +| brotli | 1.3.3 | MIT | See the package | +| clsx | 2.1.1 | MIT | See the package | +| cookie | 0.6.0 | MIT | Copyright 2012-2014 Roman Shtylman | +| culori | 4.0.2 | MIT | Copyright 2018 Dan Burzo | +| dequal | 2.0.3 | MIT | See the package | +| devalue | 5.3.2 | MIT | Copyright 2018-19 these people | +| dfa | 1.2.0 | MIT | See the package | +| esm-env | 1.2.2 | MIT | Copyright 2022 Benjamin McCann | +| esrap | 2.1.0 | MIT | Copyright 2023-2025 these people | +| fflate | 0.8.3 | MIT | Copyright 2026 Arjun Barrett | +| html-entities | 2.6.0 | MIT | Copyright 2021 Dulin Marat | +| html-to-image | 1.11.13 | MIT | Copyright 2017-2025 W.Y. | +| is-reference | 1.2.1 | MIT | See the package | +| kleur | 4.1.5 | MIT | See the package | +| locate-character | 3.0.0 | MIT | See the package | +| magic-string | 0.30.19 | MIT | Copyright 2018 Rich Harris | +| mri | 1.2.0 | MIT | See the package | +| mrmime | 2.0.1 | MIT | See the package | +| node-html-better-parser | 1.5.9 | MIT | Copyright 2019 Tao Qiufeng | +| restructure | 3.0.2 | MIT | Copyright 2015-present Devon Govett | +| sade | 1.8.1 | MIT | See the package | +| set-cookie-parser | 2.7.1 | MIT | Copyright 2015 Nathan Friedly (http://nfriedly.com/) | +| sirv | 3.0.2 | MIT | See the package | +| svelte | 5.39.5 | MIT | Copyright 2016-2025 Svelte Contributors | +| totalist | 3.0.1 | MIT | See the package | +| tslib | 2.9.1 | 0BSD | See the package | +| zimmerframe | 1.1.4 | MIT | Copyright 2023 these people | + +## Fonts + +The fonts in `src/lib/fonts` and the static copies used for PDF export in `static/pdf-fonts` come from the projects below, as published on Google Fonts and by their authors. Roboto, Roboto Condensed and Roboto Slab have been published under both the Apache License 2.0 and the SIL Open Font License; the full text of the Apache License is at . + +| Font | Copyright holder | License | Source | +| ---------------- | ------------------------------------ | --------------------- | ---------------------------------------------------- | +| Inter | The Inter Project Authors | OFL-1.1 | | +| Lato | ลukasz Dziedzic | OFL-1.1 | | +| Merriweather | The Merriweather Project Authors | OFL-1.1 | | +| Montserrat | The Montserrat Project Authors | OFL-1.1 | | +| Nunito | The Nunito Project Authors | OFL-1.1 | | +| Open Sans | The Open Sans Project Authors | OFL-1.1 | | +| Oswald | The Oswald Project Authors | OFL-1.1 | | +| Playfair Display | The Playfair Project Authors | OFL-1.1 | | +| Poppins | Indian Type Foundry | OFL-1.1 | | +| Raleway | The Raleway Project Authors | OFL-1.1 | | +| Roboto | The Roboto Project Authors | Apache-2.0 or OFL-1.1 | | +| Roboto Condensed | The Roboto Condensed Project Authors | Apache-2.0 or OFL-1.1 | | +| Roboto Slab | The Roboto Slab Project Authors | Apache-2.0 or OFL-1.1 | | +| Source Code Pro | Adobe | OFL-1.1 | | + +Fonts that were made from the originals (subset to Latin and Latin-extended, converted to WOFF2 and, for PDF export, to static instances) are modified versions as the OFL describes. None of them is sold on its own. + +## Design + +The look of the app follows the public design guidance of [Fluent 2](https://fluent2.microsoft.design/) from Microsoft. No Microsoft code or assets are included. + +## License texts + +### MIT License + +Applies to the packages marked MIT. Each has its own copyright line, listed above. + +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +### ISC License + +Applies to `@lucide/svelte` (Lucide Contributors, and Cole Bemis for the parts derived from Feather). + +> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. +> +> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +### BSD Zero Clause License (0BSD) + +Applies to `tslib`. It permits use, copying, modification and distribution without conditions. + +### Apache License 2.0 + +Applies to `aria-query` and `axobject-query`. The full text is at . + +### SIL Open Font License 1.1 + +Applies to the fonts marked OFL-1.1. The text below is the license itself; each font's copyright holder is in the table above. + +> PREAMBLE +> The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. +> +> The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. +> +> DEFINITIONS +> "Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. +> +> "Reserved Font Name" refers to any names specified as such after the copyright statement(s). +> +> "Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s). +> +> "Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. +> +> "Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. +> +> PERMISSION & CONDITIONS +> Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: +> +> 1. Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. +> 2. Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. +> 3. No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. +> 4. The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. +> 5. The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. +> +> TERMINATION +> This license becomes null and void if any of the above conditions are not met. +> +> DISCLAIMER +> THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/screenshots/editor-dark.png b/docs/screenshots/editor-dark.png new file mode 100644 index 0000000..8f2bfaf Binary files /dev/null and b/docs/screenshots/editor-dark.png differ diff --git a/docs/screenshots/editor-light.png b/docs/screenshots/editor-light.png new file mode 100644 index 0000000..b8d746a Binary files /dev/null and b/docs/screenshots/editor-light.png differ diff --git a/docs/screenshots/home-dark.png b/docs/screenshots/home-dark.png new file mode 100644 index 0000000..5e4c124 Binary files /dev/null and b/docs/screenshots/home-dark.png differ diff --git a/docs/screenshots/home-light.png b/docs/screenshots/home-light.png new file mode 100644 index 0000000..d2fef98 Binary files /dev/null and b/docs/screenshots/home-light.png differ diff --git a/docs/screenshots/templates-dark.png b/docs/screenshots/templates-dark.png new file mode 100644 index 0000000..0f99113 Binary files /dev/null and b/docs/screenshots/templates-dark.png differ diff --git a/docs/screenshots/templates-light.png b/docs/screenshots/templates-light.png new file mode 100644 index 0000000..3bc159f Binary files /dev/null and b/docs/screenshots/templates-light.png differ diff --git a/package.json b/package.json index c767f3b..3836a02 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "1.1.0", "author": { "name": "Chizoba Jude Ojini", - "email": "contact@judeojini.com", + "email": "contact@deityhub.com", "url": "https://judeojini.com" }, "license": "GPL-3.0-only", @@ -28,7 +28,9 @@ "test:unit:coverage": "svelte-kit sync && vitest --run --coverage", "test": "yarn test:unit:run && yarn test:e2e", "brand:assets": "node scripts/generate-brand-assets.mjs", - "test:e2e": "playwright test" + "test:e2e": "playwright test", + "notices": "node scripts/generate-notices.mjs", + "docs:screenshots": "yarn build && node scripts/generate-screenshots.mjs" }, "devDependencies": { "@cantoo/pdf-lib": "^2.11.1", diff --git a/scripts/generate-notices.mjs b/scripts/generate-notices.mjs new file mode 100644 index 0000000..0daded6 --- /dev/null +++ b/scripts/generate-notices.mjs @@ -0,0 +1,218 @@ +// Writes THIRD_PARTY_NOTICES.md: the open source code and fonts that ship with the app. +// Run after changing runtime dependencies or fonts: yarn notices +import fs from 'node:fs'; +import path from 'node:path'; + +const root = path.resolve(import.meta.dirname, '..'); +// What the browser bundle and the server build contain. Build and test tools are not listed: they do not ship. +const ROOTS = [ + 'svelte', + '@sveltejs/kit', + '@lucide/svelte', + '@cantoo/pdf-lib', + '@cantoo/fontkit', + 'html-to-image' +]; + +const packages = new Map(); +function visit(name) { + if (packages.has(name)) return; + const dir = path.join(root, 'node_modules', name); + const file = path.join(dir, 'package.json'); + if (!fs.existsSync(file)) return; + const json = JSON.parse(fs.readFileSync(file, 'utf8')); + let copyright = ''; + for (const entry of fs.readdirSync(dir)) { + if (!/^(licen[cs]e|copying)/i.test(entry)) continue; + const line = fs + .readFileSync(path.join(dir, entry), 'utf8') + .split('\n') + .find((l) => /copyright/i.test(l) && /\d{4}/.test(l)); + if (line) { + copyright = line + .replace(/^[\s#*>-]+/, '') + .replace(/\(c\)\s*/i, '') + .replace(/\[([^\]]+)\]\([^)]*\)/g, '$1') // keep the words of a markdown link + .trim(); + break; + } + } + packages.set(name, { version: json.version, license: json.license, copyright }); + for (const dep of Object.keys(json.dependencies ?? {})) visit(dep); +} +ROOTS.forEach(visit); + +const rows = [...packages] + .sort(([a], [b]) => a.localeCompare(b)) + .map( + ([name, p]) => `| ${name} | ${p.version} | ${p.license} | ${p.copyright || 'See the package'} |` + ) + .join('\n'); + +const fonts = [ + ['Inter', 'The Inter Project Authors', 'https://github.com/rsms/inter', 'OFL-1.1'], + ['Lato', 'ลukasz Dziedzic', 'https://fonts.google.com/specimen/Lato', 'OFL-1.1'], + [ + 'Merriweather', + 'The Merriweather Project Authors', + 'https://fonts.google.com/specimen/Merriweather', + 'OFL-1.1' + ], + [ + 'Montserrat', + 'The Montserrat Project Authors', + 'https://fonts.google.com/specimen/Montserrat', + 'OFL-1.1' + ], + ['Nunito', 'The Nunito Project Authors', 'https://fonts.google.com/specimen/Nunito', 'OFL-1.1'], + [ + 'Open Sans', + 'The Open Sans Project Authors', + 'https://fonts.google.com/specimen/Open+Sans', + 'OFL-1.1' + ], + ['Oswald', 'The Oswald Project Authors', 'https://fonts.google.com/specimen/Oswald', 'OFL-1.1'], + [ + 'Playfair Display', + 'The Playfair Project Authors', + 'https://fonts.google.com/specimen/Playfair+Display', + 'OFL-1.1' + ], + ['Poppins', 'Indian Type Foundry', 'https://fonts.google.com/specimen/Poppins', 'OFL-1.1'], + [ + 'Raleway', + 'The Raleway Project Authors', + 'https://fonts.google.com/specimen/Raleway', + 'OFL-1.1' + ], + [ + 'Roboto', + 'The Roboto Project Authors', + 'https://fonts.google.com/specimen/Roboto', + 'Apache-2.0 or OFL-1.1' + ], + [ + 'Roboto Condensed', + 'The Roboto Condensed Project Authors', + 'https://fonts.google.com/specimen/Roboto+Condensed', + 'Apache-2.0 or OFL-1.1' + ], + [ + 'Roboto Slab', + 'The Roboto Slab Project Authors', + 'https://fonts.google.com/specimen/Roboto+Slab', + 'Apache-2.0 or OFL-1.1' + ], + ['Source Code Pro', 'Adobe', 'https://github.com/adobe-fonts/source-code-pro', 'OFL-1.1'] +] + .map(([n, c, u, l]) => `| ${n} | ${c} | ${l} | <${u}> |`) + .join('\n'); + +const MIT = `Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.`; + +const ISC = `Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.`; + +const OFL = `PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the copyright statement(s). + +"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. + +5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`; + +const quote = (text) => + text + .split('\n') + .map((l) => (l ? `> ${l}` : '>')) + .join('\n'); + +const out = `# Third-party notices + +Lienzo itself is licensed under the [GNU GPLv3](LICENSE). It includes the open source software and fonts below, each under its own license. This file is generated by \`yarn notices\`; do not edit it by hand. + +## Software + +These packages are part of the app that runs in your browser or on the server. Tools used only to build and test Lienzo are not included, because they are not distributed with it. + +| Package | Version | License | Copyright | +| ------- | ------- | ------- | --------- | +${rows} + +## Fonts + +The fonts in \`src/lib/fonts\` and the static copies used for PDF export in \`static/pdf-fonts\` come from the projects below, as published on Google Fonts and by their authors. Roboto, Roboto Condensed and Roboto Slab have been published under both the Apache License 2.0 and the SIL Open Font License; the full text of the Apache License is at . + +| Font | Copyright holder | License | Source | +| ---- | ---------------- | ------- | ------ | +${fonts} + +Fonts that were made from the originals (subset to Latin and Latin-extended, converted to WOFF2 and, for PDF export, to static instances) are modified versions as the OFL describes. None of them is sold on its own. + +## Design + +The look of the app follows the public design guidance of [Fluent 2](https://fluent2.microsoft.design/) from Microsoft. No Microsoft code or assets are included. + +## License texts + +### MIT License + +Applies to the packages marked MIT. Each has its own copyright line, listed above. + +${quote(MIT)} + +### ISC License + +Applies to \`@lucide/svelte\` (Lucide Contributors, and Cole Bemis for the parts derived from Feather). + +${quote(ISC)} + +### BSD Zero Clause License (0BSD) + +Applies to \`tslib\`. It permits use, copying, modification and distribution without conditions. + +### Apache License 2.0 + +Applies to \`aria-query\` and \`axobject-query\`. The full text is at . + +### SIL Open Font License 1.1 + +Applies to the fonts marked OFL-1.1. The text below is the license itself; each font's copyright holder is in the table above. + +${quote(OFL)} +`; + +fs.writeFileSync(path.join(root, 'THIRD_PARTY_NOTICES.md'), out); +process.stdout.write(`THIRD_PARTY_NOTICES.md: ${packages.size} packages, 14 font families\n`); diff --git a/scripts/generate-screenshots.mjs b/scripts/generate-screenshots.mjs new file mode 100644 index 0000000..8b5fe3e --- /dev/null +++ b/scripts/generate-screenshots.mjs @@ -0,0 +1,90 @@ +/** + * Takes the screenshots used in the README (docs/screenshots), in the light and the dark theme. + * + * yarn docs:screenshots (builds the app first) + * + * It starts the production preview itself. Needs the Playwright browser (`yarn playwright install chromium`). + */ +import { chromium } from '@playwright/test'; +import { spawn } from 'node:child_process'; +import { mkdirSync } from 'node:fs'; +import { resolve } from 'node:path'; + +const root = resolve(import.meta.dirname, '..'); +const out = resolve(root, 'docs/screenshots'); +const PORT = 4174; // not 4173, so it does not clash with the end-to-end tests +const BASE = `http://localhost:${PORT}`; +mkdirSync(out, { recursive: true }); + +const server = spawn( + process.execPath, + ['node_modules/vite/bin/vite.js', 'preview', '--port', String(PORT), '--strictPort'], + { + cwd: root, + stdio: 'ignore' + } +); +const stop = () => server.kill(); +process.on('exit', stop); + +async function waitForServer() { + for (let i = 0; i < 60; i++) { + try { + if ((await fetch(BASE)).ok) return; + } catch { + // not up yet + } + await new Promise((r) => setTimeout(r, 500)); + } + throw new Error('The preview server did not start. Run `yarn build` first.'); +} + +const shots = [ + { + name: 'home', + run: async (page) => { + await page.goto(BASE); + } + }, + { + name: 'templates', + run: async (page) => { + await page.goto(`${BASE}/templates`); + } + }, + { + name: 'editor', + run: async (page) => { + await page.goto(`${BASE}/templates`); + await page.waitForLoadState('networkidle'); // hydrated: the button works + await page.getByTestId('use-invoice').click(); + await page.waitForURL('**/canvas'); + await page.locator('textarea').first().waitFor(); + } + } +]; + +const browser = await chromium.launch(); +try { + await waitForServer(); + for (const theme of ['light', 'dark']) { + const context = await browser.newContext({ + viewport: { width: 1440, height: 900 }, + colorScheme: theme + }); + await context.addInitScript((value) => localStorage.setItem('lienzo-theme', value), theme); + for (const shot of shots) { + const page = await context.newPage(); + await shot.run(page); + await page.waitForLoadState('networkidle'); + await page.evaluate(() => document.fonts.ready); + await page.screenshot({ path: resolve(out, `${shot.name}-${theme}.png`) }); + await page.close(); + process.stdout.write(`docs/screenshots/${shot.name}-${theme}.png\n`); + } + await context.close(); + } +} finally { + await browser.close(); + stop(); +} diff --git a/src/lib/templates/builders.ts b/src/lib/templates/builders.ts index d86e9c4..37442e2 100644 --- a/src/lib/templates/builders.ts +++ b/src/lib/templates/builders.ts @@ -1,4 +1,5 @@ -import { DISPLAY_SCALE } from '../const/dimension'; +import { CANVAS_HEIGHT, DISPLAY_SCALE } from '../const/dimension'; +import { MIN_ELEMENT_SIZE } from '../utils/geometry'; import type { TemplateElement } from './types'; /** @@ -6,8 +7,9 @@ import type { TemplateElement } from './types'; * so a 16 px font here is a 16 px font in the editor. Everything is converted to page units. */ export const PAGE_W = 868; -export const PAGE_H = 1228; +export const PAGE_H = CANVAS_HEIGHT * DISPLAY_SCALE; const u = (px: number) => Math.round(px / DISPLAY_SCALE); +const MIN_BOX = MIN_ELEMENT_SIZE; /** Side margin, and the width between the margins */ export const MARGIN = 56; @@ -76,7 +78,7 @@ interface BoxOptions { } function shape( - shapeType: 'rectangle' | 'ellipse', + shapeType: 'rectangle' | 'ellipse' | 'line-horizontal', x: number, y: number, w: number, @@ -108,9 +110,24 @@ export const rect = (x: number, y: number, w: number, h: number, fill: string, o export const ellipse = (x: number, y: number, w: number, h: number, fill: string, o?: BoxOptions) => shape('ellipse', x, y, w, h, fill, o); -/** A horizontal rule: a thin filled bar, because a line shape is drawn smaller than its box when it is this thin */ -export const line = (x: number, y: number, w: number, color = rule, thickness = 1) => - rect(x, y, w, thickness, color); +/** + * A horizontal rule. It is a line shape in a box of the editor's minimum height (20 page units), centred on `y`, + * because the editor makes every element at least that tall and would stretch a thinner box. + */ +export const line = ( + x: number, + y: number, + w: number, + color = rule, + thickness = 1 +): TemplateElement => ({ + ...shape('line-horizontal', x, y, w, 0, color, { + outline: color, + lineWidth: thickness + }), + y: u(y) - MIN_BOX / 2, + height: MIN_BOX +}); /** Rows of text at an even step, e.g. the lines of an invoice */ export const rows = ( diff --git a/src/lib/templates/catalog.ts b/src/lib/templates/catalog.ts index ae5aef0..0211d88 100644 --- a/src/lib/templates/catalog.ts +++ b/src/lib/templates/catalog.ts @@ -87,7 +87,7 @@ const coverLetter: Template = { category: 'Career', accent: '#0f6cbd', elements: [ - rect(M, 56, 6, 64, '#0f6cbd'), + rect(M, 56, 8, 64, '#0f6cbd'), text(M + 22, 56, 400, 'Alex Morgan', { size: 26, weight: '700' }), text(M + 22, 94, 400, 'Product designer', { size: 13, color: muted }), text(M, 56, W, 'alex@example.com\n+1 555 010 2030\nLisbon, Portugal', { @@ -323,8 +323,8 @@ const flyer: Template = { accent: '#c239b3', elements: [ rect(0, 0, PAGE_W, PAGE_H, '#1f1f1f'), - ellipse(470, 60, 470, 470, '#c239b3', { opacity: 0.9 }), - ellipse(560, 880, 420, 420, '#0f6cbd', { opacity: 0.9 }), + ellipse(470, 60, 390, 390, '#c239b3', { opacity: 0.9 }), + ellipse(480, 820, 380, 380, '#0f6cbd', { opacity: 0.9 }), text(M, 80, 420, 'Summer\nNight\nMarket', { size: 84, weight: '800', @@ -332,7 +332,7 @@ const flyer: Template = { lines: 3 }), text(M, 440, 420, 'Food, music and local makers', { size: 18, color: '#f2f2f2' }), - rect(M, 760, W, 3, '#ffffff'), + line(M, 761, W, '#ffffff', 3), text(M, 790, 360, 'Saturday\nJuly 12', { size: 34, weight: '700', color: '#ffffff', lines: 2 }), text(M + 360, 790, W - 360, '6 pm until late\nHarbour Square\nFree entry', { size: 18, diff --git a/src/lib/templates/catalogMore.ts b/src/lib/templates/catalogMore.ts index af5bb64..2e2f560 100644 --- a/src/lib/templates/catalogMore.ts +++ b/src/lib/templates/catalogMore.ts @@ -22,7 +22,7 @@ const agenda: Template = { category: 'Business', accent: '#0f6cbd', elements: [ - rect(M, 56, 6, 76, '#0f6cbd'), + rect(M, 56, 8, 76, '#0f6cbd'), text(M + 22, 52, W - 22, 'Team meeting', { size: 34, weight: '700' }), text(M + 22, 100, W - 22, 'Thursday, March 5 ยท 10:00 โ€“ 11:00 ยท Room 3 or video call', { size: 13, @@ -173,8 +173,8 @@ const proposal: Template = { accent: '#0f6cbd', elements: [ rect(0, 0, PAGE_W, PAGE_H, '#0b3a66'), - ellipse(420, 560, 640, 640, '#0f6cbd', { opacity: 0.55 }), - ellipse(560, 760, 360, 360, '#2b88d8', { opacity: 0.6 }), + ellipse(330, 520, 520, 520, '#0f6cbd', { opacity: 0.55 }), + ellipse(470, 700, 300, 300, '#2b88d8', { opacity: 0.6 }), text(M, 70, W, 'Northwind Studio', { size: 16, weight: '600', color: '#cfe4f7' }), text(M, 340, 640, 'Website redesign\nproposal', { size: 62, @@ -182,7 +182,7 @@ const proposal: Template = { color: '#ffffff', lines: 2 }), - rect(M, 520, 90, 5, '#ffffff'), + line(M, 522, 90, '#ffffff', 5), text(M, 550, 560, 'Prepared for Fabrikam Ltd\nMarch 2026', { size: 18, color: '#cfe4f7', @@ -215,7 +215,7 @@ const saveTheDate: Template = { color: '#3b1f27', lines: 3 }), - rect(PAGE_W / 2 - 50, 650, 100, 2, '#b4546b'), + line(PAGE_W / 2 - 50, 651, 100, '#b4546b', 2), text(M, 690, W, 'September 12, 2026', { size: 26, align: 'center', font: 'Playfair Display' }), text(M, 740, W, 'Villa Rosa, Tuscany', { size: 15, color: muted, align: 'center' }), text(M, 960, W, 'Invitation to follow', { @@ -447,8 +447,8 @@ const thankYou: Template = { accent: '#107c10', elements: [ rect(0, 0, PAGE_W, PAGE_H, '#f3faf2'), - ellipse(-140, -140, 420, 420, '#107c10', { opacity: 0.16 }), - ellipse(PAGE_W - 280, PAGE_H - 280, 520, 520, '#107c10', { opacity: 0.16 }), + ellipse(40, 40, 260, 260, '#107c10', { opacity: 0.16 }), + ellipse(PAGE_W - 300, PAGE_H - 300, 260, 260, '#107c10', { opacity: 0.16 }), text(M, 300, W, 'Thank you', { size: 84, align: 'center', @@ -456,7 +456,7 @@ const thankYou: Template = { font: 'Playfair Display', color: '#0b5a08' }), - rect(PAGE_W / 2 - 40, 450, 80, 3, '#107c10'), + line(PAGE_W / 2 - 40, 451, 80, '#107c10', 3), text( M + 80, 500, diff --git a/src/lib/templates/index.ts b/src/lib/templates/index.ts index 813b732..522ca00 100644 --- a/src/lib/templates/index.ts +++ b/src/lib/templates/index.ts @@ -1,6 +1,6 @@ import { CANVAS_HEIGHT, CANVAS_WIDTH } from '../const/dimension'; import { CURRENT_SCHEMA_VERSION } from '../stores/migrations'; -import type { DocumentData, TCanvasElement } from '../types/canvas'; +import type { DocumentData, RulerBoundaries, TCanvasElement } from '../types/canvas'; import { uuidv4 } from '../utils/uuid'; import type { Template } from './types'; @@ -8,6 +8,27 @@ export { templates, templateById } from './catalog'; export { TEMPLATE_CATEGORIES, type Template, type TemplateCategory } from './types'; /** A new document with the template's page. Ids are new, so each use is its own document. */ +const MARGIN = 100; // the editor's default margins, in page units + +/** + * The page's boundaries: the usual margins, moved out on any side where the design reaches past them. The + * editor pulls every element inside the boundaries, so a full-bleed background needs them out of its way. + */ +export function boundariesFor(template: Template): RulerBoundaries { + const edge = (pick: (e: Template['elements'][number]) => number, margin: number, min: boolean) => + template.elements.reduce((v, e) => (min ? Math.min(v, pick(e)) : Math.max(v, pick(e))), margin); + return { + horizontal: { + start: edge((e) => e.x, MARGIN, true), + end: edge((e) => e.x + e.width, CANVAS_WIDTH - MARGIN, false) + }, + vertical: { + start: edge((e) => e.y, MARGIN, true), + end: edge((e) => e.y + e.height, CANVAS_HEIGHT - MARGIN, false) + } + }; +} + export function documentFromTemplate(template: Template): DocumentData { const pageId = uuidv4(); const elements: Record = {}; @@ -24,10 +45,7 @@ export function documentFromTemplate(template: Template): DocumentData { [pageId]: { id: pageId, elements, - boundaries: { - horizontal: { start: 100, end: CANVAS_WIDTH - 100 }, - vertical: { start: 100, end: CANVAS_HEIGHT - 100 } - } + boundaries: boundariesFor(template) } }, createdAt: now, diff --git a/src/lib/templates/templates.spec.ts b/src/lib/templates/templates.spec.ts index d4127eb..58fb520 100644 --- a/src/lib/templates/templates.spec.ts +++ b/src/lib/templates/templates.spec.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest'; import { CANVAS_HEIGHT, CANVAS_WIDTH } from '../const/dimension'; +import { boundaryAdjustments } from '../utils/geometry'; import { documentFromTemplate, templates } from '.'; describe('templates', () => { @@ -23,6 +24,22 @@ describe('templates', () => { } }); + it('open in the editor exactly as designed: it does not move or resize anything', () => { + const moved: Record = {}; + for (const t of templates) { + const [page] = Object.values(documentFromTemplate(t).pages); + const changes = boundaryAdjustments(Object.values(page.elements), page.boundaries); + const texts = Object.keys(changes).map((id) => { + const el = page.elements[id]; + return el.type === 'text' + ? el.text.slice(0, 20) + : `${el.type} at ${el.x},${el.y} ${el.width}x${el.height}`; + }); + if (texts.length) moved[t.id] = texts; + } + expect(moved).toEqual({}); + }); + it('make a new document each time, with ids that point at the right page', () => { const a = documentFromTemplate(templates[0]); const b = documentFromTemplate(templates[0]);