Files
wekan/docs/Features/Cards/Drawing.md
T
Lauri Ojansivu 7e1f9e89eb Docs: every feature topic in one folder under docs/Features, each with README.md as its main page.
- The General/ level is gone: its 109 files moved up into the folders of the
  same name, and its topic table is the "Shared topics" section of
  Features.md.
- Accessibility is one folder, docs/Features/Accessibility/, with the Admin
  Panel's accessibility page in it.
- Every folder's main page is README.md (110 X/X.md pages renamed with git mv,
  five merged with an existing README.md, 26 index pages added for folders
  that had none), so a folder opened on GitHub shows its page.
- The 73 "# Moved" forwarding pages are deleted, with the folders that held
  only them; every link that went to one goes to its final page.
- docs/Features/README.md has the website's "Features in WeKan" overview,
  each feature linking to its page here.

1,129 Markdown links in 262 files and 352 doc paths in code, tests, compose,
snap and release files follow. tests/docsFeaturesLayout.test.cjs fails when
General/ or a "# Moved" page comes back, a folder has no README.md, or a
relative link in the docs or README.md does not resolve.

Thanks to xet7 !
2026-11-24 20:02:06 +02:00

11 KiB

Drawing

What it is

Draw or write by hand on a card, with a mouse, a finger or a pen (#1178, #6802). A drawing is kept on the card as its lines, so it can be opened and edited again, and its picture is saved as an attachment of the card - a sketch, a diagram, a signature or a handwritten note beside the card's text.

Read more

How to use it

Opening it

  • Card hamburger menu → Drawing (under Appearance) - the card's drawings, a new one, and each saved drawing's Open as whiteboard (Whiteboard.md). It is shown to members who may change the card and are not a Worker.
  • Add attachment → Drawing - a new drawing on the whole window, saved as an SVG attachment of the card.
  • Add Card → Search / Template / Drawing / More options - Drawing is shown while the text adds ONE card: the card is added, opened, and a new drawing starts on the whole window, saved as an SVG attachment of the new card.

The Drawing popup moves by its title bar or the drag handle beside the title, and has the opened card's maximize / minimize button. Maximized it fills the window; minimizing puts it back where it was. A popup left maximized opens maximized again.

The drawing area takes all the room the popup has: a new drawing is as wide and high as that room. The handle at its bottom-right corner makes it larger (or smaller, never cutting off a line), and the magnifier buttons show it larger or smaller on the screen, scrolling when it no longer fits. A drawing keeps its size when saved; drawings made before this are 800 x 500.

Drawing

  1. Pick a colour and a line width, and draw.
  2. Undo steps back through every change: a line, an erase, a move, a resize, a grouping, a layer change - and then takes away the last line.
  3. The Eraser takes away every line it touches; Clear takes away all lines.
  4. Save keeps the lines on the card, so the drawing can be edited later, and stores the picture as an attachment: a PNG for a drawing from the card menu, an SVG for a new drawing. Download as SVG saves the drawing as a file.

There are seven colours and any custom colour, and four line widths.

Palm rejection: once a pen has drawn, a touch does not, so a hand resting on a tablet leaves no marks. While one pointer draws, no other one starts a line.

Save is above the drawing, at the end of the tools. A new drawing becomes the card's cover image; saving changes to an existing drawing leaves the cover as it is.

Colours

Clicking a colour picks it and opens the colour wheel (hue around it, saturation from the centre), a Brightness slider and the HTML colour code (#rrggbb). Add to colours puts the colour beside the palette, for the next drawing too; Remove colour takes a custom one away. Signed in, the custom colours are kept with the account (profile.drawingColors, the setDrawingColors method), so they are there in every browser; drawing on a public board without signing in, they are kept in this browser. The eyedropper picks a colour from anywhere on the screen where the browser can (Chrome, Edge); elsewhere it takes the colour of the line clicked in the drawing. Only #rrggbb is ever stored, so a colour never becomes anything else in the SVG.

The lasso

The Lasso tool selects the lines drawn around: a loop selects every line that lies wholly inside it. The selection is shown in a dashed box, and:

  • moves together, dragged from inside the box - stopping at the edge of the drawing, keeping its shape;
  • resizes by the handle at the box's bottom-right corner, from its top-left corner, line widths too (to the nearest of the four);
  • Group makes the selection one: selecting any of its lines selects all of them, and the group is saved with the drawing. Ungroup takes it apart;
  • Bring to front, Bring forward, Send backward and Send to back change which lines are drawn over which - all the way, or one line at a time.

A move or a resize is one Undo step. Pressing the Lasso again goes back to the pen.

Board Settings / Card

The Drawing row (Show on Card) shows or hides Open as whiteboard. It is on by default.

How the numbers are calculated

All from models/lib/cardDrawing.js, unless said otherwise:

Number Value and how it is used
Palette 7 colours: #000000, #e53935, #1e88e5, #43a047, #fb8c00, #8e24aa, #ffffff
Line widths 2, 4, 8 and 16; a resized line takes the nearest of them
Drawing size 100 to 4000 units each way, whole units; 800 x 500 when a drawing has no size
Smallest size the corner handle stops where the furthest point plus half its line width would be cut off, but never under 100
Zoom each magnifier click multiplies or divides by 1.25, between 0.25 and 4
Eraser removes every line that passes within 10 units of the pointer, plus half that line's width
Eyedropper on the drawing the topmost line within 6 units of the click, or white (#ffffff)
Undo up to 100 steps (HISTORY in client/components/cards/cardDrawing.js)
Lines kept at most 2000 lines of at most 5000 points each, coordinates rounded to 0.1
Drawings per card the 20 newest are kept
Custom colours at most 16, newest last, none repeating a palette colour
Lasso a loop needs at least 3 points; a line is selected when every point of it is inside the loop (even-odd rule)
Resize a selection is never made smaller than 4 units and stays inside the drawing
Colour wheel hue is the angle around the centre, saturation the distance from it divided by the radius, brightness the slider (HSV to #rrggbb)

How it works in WeKan

client/components/cards/cardDrawing.js (the popup), client/lib/newDrawing.js (opening a new drawing), models/lib/cardDrawing.js (lines, the eraser, palm rejection and the lasso's selection, moving, resizing, groups and layer order, pure), client/components/main/popup.js (moving and maximizing).

Tests: tests/cardDrawing.test.cjs, tests/cardDrawingPen.test.cjs, tests/cardDrawingLasso.test.cjs, tests/cardDrawingCanvasColors.test.cjs, tests/popupMoveMaximize.test.cjs, tests/svgServing.test.cjs, tests/svgSanitizerStreaming.test.cjs and the Playwright specs card-drawing-pen.e2e.js, card-drawing-lasso.e2e.js, card-drawing-canvas.e2e.js, popup-drawing-window.e2e.js and svg-attachment.e2e.js.

SVG files

SVG is an image like any other: an attachment, a card cover, a board background, an avatar. Every uploaded SVG is sanitized on the server before it is stored - no script, event handler, javascript: URI, foreignObject or DOCTYPE/ENTITY XML loop - and sanitized again, whole, whenever it is served, under a Content-Security-Policy with no script and sandbox, so it runs nothing even opened directly. Both are streamed through one tokenizer, models/lib/svgSanitizer.js, so an SVG of any size is sanitized whole, with bounded memory. Uploads used to be refused after JVN#74210258; server/lib/svgResponse.js, tests/svgServing.test.cjs and tests/svgSanitizerStreaming.test.cjs are where it is now handled and checked.

Commits