Skip to content

@fabwcie/free-drawing / Drawer

Drawer ​

Classes ​

Drawer ​

Defined in: packages/free-drawing/src/Drawer.ts:194

Infinite canvas drawing board created in an element: Konva stage of the drawing, toolbar and interface, public API. Events of the drawer are listened with on (see drawerEvents).

Example

ts
const drawer = new Drawer(document.getElementById('draw'), {
  width: 500,
  height: 800,
});

Extends

Constructors ​

Constructor ​

new Drawer($el, options?): Drawer

Defined in: packages/free-drawing/src/Drawer.ts:377

Create a drawer in an element: its content is replaced by the drawer

Parameters
$el ​

HTMLDivElement

Element of the drawer

options? ​

Partial<DrawerOptions> = {}

Options merged with defaultOptions (widgets replaces default list)

Returns

Drawer

Overrides

default.constructor

Properties ​

_events ​

_events: Record<string, Listener[]> = {}

Defined in: packages/free-drawing/src/utils/MicroEvent.ts:44

Listeners by event name, in order of registration

Inherited from

Dropdown._events

$el ​

$el: HTMLDivElement

Defined in: packages/free-drawing/src/Drawer.ts:227

Element given to the constructor, holding the container of the drawer

$liveRegion ​

$liveRegion: HTMLDivElement

Defined in: packages/free-drawing/src/Drawer.ts:231

Live region of messages read by screen readers (toasts), see _announce

$stageContainer ​

$stageContainer: HTMLDivElement

Defined in: packages/free-drawing/src/Drawer.ts:233

Konva content of the stage (its canvases): cursor of active tool is set on it

activeTool ​

activeTool: AvailableTools = 'brush'

Defined in: packages/free-drawing/src/Drawer.ts:258

Id of active tool, see activeWidget

activeWidget ​

activeWidget: BaseWidget

Defined in: packages/free-drawing/src/Drawer.ts:260

Widget of active tool, set by toolbar.setActiveWidget (activate one with widget.setActive(true))

arrowHandle ​

arrowHandle: ArrowHandle

Defined in: packages/free-drawing/src/Drawer.ts:248

Handle of a selected curved or elbow arrow: bends the curve, moves the middle segment of the elbow

background ​

background: Rect

Defined in: packages/free-drawing/src/Drawer.ts:265

Background rectangle of the drawing, its color set with setBgColor

bgLayer ​

bgLayer: Layer

Defined in: packages/free-drawing/src/Drawer.ts:368

Layer of background rectangle, first one (not listening), moved with the view

clearConfirmModal ​

clearConfirmModal: ConfirmModal | null = null

Defined in: packages/free-drawing/src/Drawer.ts:305

Confirmation of clearCanvas, created on first use

clearStoredConfirmModal ​

clearStoredConfirmModal: ConfirmModal | null = null

Defined in: packages/free-drawing/src/Drawer.ts:307

Confirmation of clearStoredData, created on first use

collaboration ​

collaboration: Collaboration | null = null

Defined in: packages/free-drawing/src/Drawer.ts:204

Collaboration session: drawing changes sent to and received from other users of a room

collaborationIndicator ​

collaborationIndicator: CollaborationIndicator | undefined

Defined in: packages/free-drawing/src/Drawer.ts:225

Reminder of a live session in header, with the collaboration option

collaborationModal ​

collaborationModal: CollaborationModal | null = null

Defined in: packages/free-drawing/src/Drawer.ts:206

Created on first use, see showCollaboration

commandPalette ​

commandPalette: CommandPalette | null = null

Defined in: packages/free-drawing/src/Drawer.ts:311

Created on first use, see showCommandPalette

contextMenu ​

contextMenu: ContextMenu

Defined in: packages/free-drawing/src/Drawer.ts:364

Menu of right click on drawing

debug ​

debug: boolean = false

Defined in: packages/free-drawing/src/Drawer.ts:316

Development messages: collaboration connection logged, toast when shapes are moved without selection tool

drawLayer ​

drawLayer: Layer

Defined in: packages/free-drawing/src/Drawer.ts:240

Drawing shapes, add them with addShape (named ' draw': select it with .draw)

exportModal ​

exportModal: ExportModal | null = null

Defined in: packages/free-drawing/src/Drawer.ts:309

Created on first use, see showExport

files ​

files: Map<string, string>

Defined in: packages/free-drawing/src/Drawer.ts:327

Image files of the drawing by id: data URLs of PNG, JPEG, WebP or GIF images, shown by images (fileId attribute), saved, exported in files and links and shared with the drawing. Add files with addFiles

frameHighlight ​

frameHighlight: FrameHighlight

Defined in: packages/free-drawing/src/Drawer.ts:244

Highlights of frames entered and left by moved shapes, in the selection layer

gestures ​

gestures: TouchGestures

Defined in: packages/free-drawing/src/Drawer.ts:250

Two finger gestures on the canvas: pinch zoom and move of the view (tools ignore touches while active)

grid ​

grid: boolean = false

Defined in: packages/free-drawing/src/Drawer.ts:366

Grid shown (see showGrid, hideGrid), shapes snapped to it

gridLayer ​

gridLayer: Layer

Defined in: packages/free-drawing/src/Drawer.ts:238

Grid shown with showGrid (not listening)

help ​

help: Help

Defined in: packages/free-drawing/src/Drawer.ts:301

Help dialog (shortcuts, documentation links) and its footer button

hotKey ​

hotKey: HotKey

Defined in: packages/free-drawing/src/Drawer.ts:370

Keyboard shortcuts of the drawer (keydown on its container)

i18n ​

i18n: I18n

Defined in: packages/free-drawing/src/Drawer.ts:295

Texts of interface, see t and setLanguage

layersPanel ​

layersPanel: LayersPanel | undefined

Defined in: packages/free-drawing/src/Drawer.ts:277

Panel listing shapes (layersPanel option)

layout ​

layout: DrawerLayout

Defined in: packages/free-drawing/src/Drawer.ts:229

Container of the drawer and regions of its interface, see layout.add

library ​

library: Library

Defined in: packages/free-drawing/src/Drawer.ts:279

Library of shapes saved to be inserted again in any drawing, kept in the browser

libraryPanel ​

libraryPanel: LibraryPanel | undefined

Defined in: packages/free-drawing/src/Drawer.ts:281

Panel of the library (library option)

linkEditor ​

linkEditor: LinkEditor | undefined

Defined in: packages/free-drawing/src/Drawer.ts:273

Link of selected shapes above them (with selection widget, see setShapeLink)

navigation: ShapeNavigation

Defined in: packages/free-drawing/src/Drawer.ts:289

Keyboard navigation between the shapes (Enter, Tab, Shift + Tab, Escape), described to screen readers

options ​

options: DrawerOptions

Defined in: packages/free-drawing/src/Drawer.ts:262

Options given to the constructor merged with defaults, updated by setters (color, width...) and preferences

plugins ​

plugins: PluginCollection

Defined in: packages/free-drawing/src/Drawer.ts:275

Plugins of the drawer (plugins option): get, has, widgets and commands they added

position ​

position: Position | undefined

Defined in: packages/free-drawing/src/Drawer.ts:269

Position of view with a button back to origin (positionWidget option)

preferencesModal ​

preferencesModal: PreferencesModal | null = null

Defined in: packages/free-drawing/src/Drawer.ts:313

Created on first use, see showPreferences

readOnly ​

readOnly: boolean = false

Defined in: packages/free-drawing/src/Drawer.ts:196

Drawing can't be modified by user (see setReadOnly)

ready ​

ready: Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:339

Resolved once drawing of storage option is loaded (rejected if it can't be) and plugins are initialized

replay ​

replay: Replay

Defined in: packages/free-drawing/src/Drawer.ts:287

Replay of how the drawing was made: its shapes again in the order they were created (Alt+Shift+R)

saveButton ​

saveButton: SaveButton | undefined

Defined in: packages/free-drawing/src/Drawer.ts:291

Button of header saving the drawing while auto save is off (saveButton option)

search: SearchBar

Defined in: packages/free-drawing/src/Drawer.ts:283

Search of the texts of the drawing (Ctrl+F)

selectionLayer ​

selectionLayer: Layer

Defined in: packages/free-drawing/src/Drawer.ts:242

Transient nodes: transformer, selection rectangle, snapping guides, cursors of collaborators

selectionMenu ​

selectionMenu: SelectionMenu | undefined

Defined in: packages/free-drawing/src/Drawer.ts:271

Menu next to selected shapes (selectionMenu option)

setting ​

setting: Settings

Defined in: packages/free-drawing/src/Drawer.ts:303

Settings menu of header: file actions, collaboration, view toggles, language, background color

shapeLinks: ShapeLinks

Defined in: packages/free-drawing/src/Drawer.ts:246

Icons of shapes having a link, in the selection layer (see setShapeLink)

signal ​

readonly signal: AbortSignal

Defined in: packages/free-drawing/src/Drawer.ts:213

Aborted by destroy: listeners of the page (window, document, media queries) added with it are removed with the drawer, e.g. window.addEventListener('resize', handler, { signal: drawer.signal }) (components, plugins, apps)

slideshow ​

slideshow: Slideshow

Defined in: packages/free-drawing/src/Drawer.ts:285

Presentation of the frames as slides (Alt+Shift+P)

socket ​

socket: CollaborationSocket | null = null

Defined in: packages/free-drawing/src/Drawer.ts:202

Collaboration socket, connected during a collaboration session

spacePan ​

spacePan: SpacePan

Defined in: packages/free-drawing/src/Drawer.ts:252

Space held: a drag moves the view whatever the tool (tools ignore the pointer while active)

stage ​

stage: Stage

Defined in: packages/free-drawing/src/Drawer.ts:235

Konva stage: background, grid, drawing and selection layers

theme ​

theme: Theme = 'light'

Defined in: packages/free-drawing/src/Drawer.ts:293

Theme chosen ('system': device one), see setTheme

toolbar ​

toolbar: Toolbar

Defined in: packages/free-drawing/src/Drawer.ts:256

Toolbar of the footer: widgets (tools) and their groups

undoRedo ​

undoRedo: UndoRedo

Defined in: packages/free-drawing/src/Drawer.ts:362

History of drawing (undo / redo) and its footer buttons

zoom ​

zoom: Zoom | undefined

Defined in: packages/free-drawing/src/Drawer.ts:267

Zoom out, level (reset) and zoom in buttons (zoomWidget option)

Accessors ​

$drawerContainer ​
Get Signature

get $drawerContainer(): HTMLDivElement

Defined in: packages/free-drawing/src/Drawer.ts:3553

Container of the drawer: canvas and interface (layout.$container)

Returns

HTMLDivElement

$footerContainer ​
Get Signature

get $footerContainer(): HTMLElement

Defined in: packages/free-drawing/src/Drawer.ts:3569

Footer region of the layout (toolbar, help)

Deprecated

use layout.add('footer', $element)

Returns

HTMLElement

$footerLeftElement ​
Get Signature

get $footerLeftElement(): HTMLDivElement

Defined in: packages/free-drawing/src/Drawer.ts:3577

Start of the footer (zoom, undo / redo)

Deprecated

use layout.add('footerStart', $element)

Returns

HTMLDivElement

$headerContainer ​
Get Signature

get $headerContainer(): HTMLDivElement

Defined in: packages/free-drawing/src/Drawer.ts:3561

Header region of the layout (top left: settings menu, layers button, position)

Deprecated

use layout.add('header', $element)

Returns

HTMLDivElement

copiedStyle ​
Get Signature

get copiedStyle(): OptionsChange | null

Defined in: packages/free-drawing/src/Drawer.ts:3482

Style copied by copyStyle

Returns

OptionsChange | null

Copied style, null before a copy

language ​
Get Signature

get language(): "en" | "fr" | "es" | "de"

Defined in: packages/free-drawing/src/Drawer.ts:3219

Language of interface shown

Returns

"en" | "fr" | "es" | "de"

languageChoice ​
Get Signature

get languageChoice(): "en" | "fr" | "es" | "de" | "auto"

Defined in: packages/free-drawing/src/Drawer.ts:3226

Language chosen: 'auto' (browser one) or a language

Returns

"en" | "fr" | "es" | "de" | "auto"

user ​
Get Signature

get user(): DrawerUser | null

Defined in: packages/free-drawing/src/Drawer.ts:902

User of the app (user option), null for anonymous user

Returns

DrawerUser | null

Methods ​

_addShape() ​

_addShape<T>(shape): T

Defined in: packages/free-drawing/src/Drawer.ts:1270

Add drawing shape keeping its ids, see addShape: shapes of history, of other users (collaboration), of a drawing file (ids made unique by parseDrawingFile)

Type Parameters
T ​

T extends DrawingShape

Parameters
shape ​

T

Shape or group to add on top of drawing, given an id if it has none

Returns

T

added shape

_afterAction() ​

_afterAction(): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:1075

End of the pointer action or text edit in progress (a stroke, a text being typed): work changing the drawing waits for it (else it would cancel the stroke, save the text hidden...)

Returns

Promise<void>

Resolved once it ended, at once without action

_announce() ​

_announce(message, urgent?): void

Defined in: packages/free-drawing/src/Drawer.ts:3516

Message read by screen readers (toasts): in the live region of the dialog shown (nothing out of an aria-modal dialog is read), else of the drawer

Parameters
message ​

string

Text read

urgent? ​

boolean = false

Read at once (problems), else when the user is idle

Returns

void

_applyChanges() ​

private _applyChanges(changes): void

Defined in: packages/free-drawing/src/Drawer.ts:1842

Changes made during a load applied again over the loaded drawing: shapes changed in their place (added ones on top), removed ones removed, background, then one change (saved, in history)

Parameters
changes ​

ChangesDuringLoad

Changes found by _changesSince

Returns

void

_applyTheme() ​

private _applyTheme(): void

Defined in: packages/free-drawing/src/Drawer.ts:3374

Show theme chosen (drawer-dark class on container), theme.change event

Returns

void

_arrangeShapes() ​

private _arrangeShapes(shapes, min, move): void

Defined in: packages/free-drawing/src/Drawer.ts:2864

Shapes moved by an alignment, a distribution or a stack: arrows moved without their shapes unlinked, shapes placed in the frames they are moved into or out of (highlighted), change saved

Parameters
shapes ​

DrawingShape[]

Shapes moved

min ​

number

Fewest shapes for this move (nothing done with less), texts of given shapes not counted

move ​

(shapes) => void

Move of the shapes, given without the texts of given shapes

Returns

void

_changesSince() ​

private _changesSince(start): ChangesDuringLoad | null

Defined in: packages/free-drawing/src/Drawer.ts:1819

Changes of the drawing since a load started: shapes added, changed and removed, background

Parameters
start ​

DrawingSnapshot

Drawing when the load started

Returns

ChangesDuringLoad | null

Changes with the image files of their shapes, null without change

_clearStoredData() ​

private _clearStoredData(): void

Defined in: packages/free-drawing/src/Drawer.ts:3628

Data of the browser removed (see clearStoredData), toast

Returns

void

_connected() ​

private _connected(socket): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:1023

Resolved when socket is connected, rejected if server can't be reached (no retry)

Parameters
socket ​

CollaborationSocket

Socket of the collaboration session being started

Returns

Promise<void>

Promise resolved on connection, rejected with the connection error

_createSocket() ​

protected _createSocket(): Promise<CollaborationSocket>

Defined in: packages/free-drawing/src/Drawer.ts:1037

Socket connected to collaboration server: true is page origin, string is server url, options give url and data read by server on connection (socket.io client is loaded only then)

Returns

Promise<CollaborationSocket>

New socket (new connection each session), connecting

_drawGrid() ​

private _drawGrid(): void

Defined in: packages/free-drawing/src/Drawer.ts:3787

Draw grid in its style (gridStyle option): one shape drawing the visible area, redrawn with stage (pan, zoom) without creating nodes

Returns

void

_duringAction() ​

_duringAction(): boolean

Defined in: packages/free-drawing/src/Drawer.ts:1521

Pointer action of active tool or text edition in progress: shortcuts and interface ignore keys and pointer

Returns

boolean

True while an action or a text edition is in progress

_duringMove() ​

_duringMove(): boolean

Defined in: packages/free-drawing/src/Drawer.ts:1531

Shapes of the drawing being dragged (also the handle of an arrow) or transformed, not the view: one change at the end (_endDrag), changes of collaborators received meanwhile are recorded with it

Returns

boolean

True during a drag or a transform of this drawer

_endDrag() ​

_endDrag(shapes): void

Defined in: packages/free-drawing/src/Drawer.ts:841

Shapes dragged and released: placed in the frame containing them, one change for the whole drag. Konva ends the drag of each node moved (every selected shape, transformer of the selection): the last one fires the change (saved, in history, sent to collaborators once)

Parameters
shapes ​

DrawingShape[]

Shapes moved by the drag

Returns

void

_endMove() ​

_endMove(): void

Defined in: packages/free-drawing/src/Drawer.ts:2690

Move of shapes ended: shapes drawn in their frame again (placed after by placeInFrames), highlights faded out

Returns

void

_followOtherTabs() ​

private _followOtherTabs(): void

Defined in: packages/free-drawing/src/Drawer.ts:1928

Drawing saved by another tab of the browser (same key, without storage option): shown here, so the next save of this tab does not replace it with an older drawing; nothing saved again nor added to the history of this tab. Not while this tab has changes not saved (its next save wins) nor during a collaboration session (the drawing of the room). Image files of the other tab added as they come

Returns

void

_getCenter() ​

private _getCenter(shapes): Vector2d

Defined in: packages/free-drawing/src/Drawer.ts:2250

Center of the box of shapes (absolute position)

Parameters
shapes ​

DrawingShape[]

Shapes whose client rects make the box

Returns

Vector2d

Absolute position of the center of the box

_getFiles() ​

private _getFiles(shapes): DrawingFiles

Defined in: packages/free-drawing/src/Drawer.ts:2027

Image files of shapes

Parameters
shapes ​

DrawingShape[]

Drawing shapes (images of groups and frames too)

Returns

DrawingFiles

Files of their images (known ones), by id

_getOwnerKey() ​

private _getOwnerKey(room): string | undefined

Defined in: packages/free-drawing/src/Drawer.ts:968

Secret of owner of a room created in this browser

Parameters
room ​

string

Room id

Returns

string | undefined

Owner key kept for this room, undefined if this browser did not create it

_getPointerPos() ​

_getPointerPos(): Vector2d

Defined in: packages/free-drawing/src/Drawer.ts:1361

Pointer in view, center of view when pointer is out of canvas (menu, keyboard)

Returns

Vector2d

Position relative to the stage container

_getRelativePointerPos() ​

_getRelativePointerPos(): Vector2d

Defined in: packages/free-drawing/src/Drawer.ts:1344

Pointer in drawing (view moved and zoomed), center of view when pointer is out of canvas (menu, keyboard)

Returns

Vector2d

Position in drawing coordinates

_getStorageItem() ​

private _getStorageItem(key): string | null

Defined in: packages/free-drawing/src/Drawer.ts:1867

Read localStorage item, null if storage is unavailable (blocked cookies, sandboxed iframe...)

Parameters
key ​

string

Key of the item

Returns

string | null

Item value, null if missing or storage unavailable

_getUserKey() ​

private _getUserKey(): string

Defined in: packages/free-drawing/src/Drawer.ts:947

Secret of this browser given to collaboration servers with the id of the user: they give this id to this browser only, not to another user who saw it (users of a room, by of links)

Returns

string

Secret kept in localStorage, or a new one (new each session if storage is unavailable)

_hasPointer() ​

_hasPointer(): boolean

Defined in: packages/free-drawing/src/Drawer.ts:1336

Pointer registered by stage: over canvas, or during a pointer action (konva forgets it when pointer leaves canvas)

Returns

boolean

True when stage knows a pointer position

_initEvents() ​

private _initEvents(): void

Defined in: packages/free-drawing/src/Drawer.ts:1384

Listen to shortcuts, zoom wheel, view moves, shape drags and transforms (frames, linked arrows, collaboration) and drawing changes (change of stage: save, history, change event)

Returns

void

_initFrameMoves() ​

private _initFrameMoves(): void

Defined in: packages/free-drawing/src/Drawer.ts:2586

Shapes dragged or transformed: drawn above the drawing while moved (not cut by their frame), frames they would enter or leave once dropped highlighted (frameHighlight), placed in frames when dropped (placeInFrames)

Returns

void

_initHotKey() ​

private _initHotKey(): void

Defined in: packages/free-drawing/src/Drawer.ts:1504

Keyboard shortcuts on drawer container

Returns

void

_initKeyboardFocus() ​

private _initKeyboardFocus(): void

Defined in: packages/free-drawing/src/Drawer.ts:1479

Focus frame on drawer only when focused with keyboard (Tab, Escape from a menu). Not with :focus-visible, which matches after programmatic focus (on load, after tool change...) for mouse users too.

Returns

void

_initSnapGridEvents() ​

private _initSnapGridEvents(): void

Defined in: packages/free-drawing/src/Drawer.ts:3682

Snap to grid while grid is shown: dragged shapes (but lines), resize anchors of selection, rotation by 90°

Returns

void

_initTheme() ​

private _initTheme(saved?): void

Defined in: packages/free-drawing/src/Drawer.ts:3358

Theme chosen in menu (saved) or by option, device theme followed with 'system'

Parameters
saved? ​

Theme

Theme of saved preferences, theme option when undefined

Returns

void

_initWheel() ​

private _initWheel(): void

Defined in: packages/free-drawing/src/Drawer.ts:1544

Mouse wheel (wheelAction preference): zoom around the pointer (zoom option, by scaling option for a notch of a mouse wheel, less for the small steps of a trackpad), Ctrl / Cmd + wheel moves the view (Shift + wheel: horizontally); or the other way round. A pinch of a trackpad (wheel with ctrlKey, Ctrl key not pressed) zooms

Returns

void

_isMovedAlone() ​

private _isMovedAlone(shape): boolean

Defined in: packages/free-drawing/src/Drawer.ts:2416

Shape dragged alone with the selection tool: shape of the drawing or of a frame, not of a group (moved with it)

Parameters
shape ​

DrawingShape

Shape or group in the drawing

Returns

boolean

True when it is draggable now (selection tool active)

_isPlaceable() ​

private _isPlaceable(shape): boolean

Defined in: packages/free-drawing/src/Drawer.ts:2578

Shape placed in frames by placeInFrames: not a frame nor a shape of a group

Parameters
shape ​

DrawingShape

drawing shape

Returns

boolean

true for a shape of the drawing or of a frame

_leaveDisabledTool() ​

_leaveDisabledTool(): void

Defined in: packages/free-drawing/src/Drawer.ts:686

Active tool disabled (its plugin disabled): the selection tool activated instead, else the first tool enabled, else none (its pointer action stopped)

Returns

void

private _loadFromLink(): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:3112

Drawing of a link (see getLink) replaces saved one (undo restores it), removed from page url at once: opened by one drawer only. Without id option, links of drawers without id, also #drawer-<n>= of previous versions

Returns

Promise<void>

_loadSavedStage() ​

private _loadSavedStage(): Stage | null

Defined in: packages/free-drawing/src/Drawer.ts:1879

Stage saved in localStorage, null if none or invalid (corrupted, other app data...)

Returns

Stage | null

Stage created from saved JSON with its required layers, else null

_onActionEnd() ​

_onActionEnd(): void

Defined in: packages/free-drawing/src/Drawer.ts:1055

Pointer action of a widget ended: changes of collaborators received meanwhile are applied once the tool finished it (tools end their action first, then erase shapes, link an arrow, fill a frame...): its change applies them first, else they are applied here, after it (not recorded with the shapes as they were during the action)

Returns

void

_oncePerMove() ​

private _oncePerMove(run): (e) => void

Defined in: packages/free-drawing/src/Drawer.ts:2628

Work on the whole drawing during drags done once per move of the pointer: konva moves each node of a selection and fires their dragmove in turn (each one snapped there, the transformer starts the drag of the others at the first one), the work is done once all of them moved: window mousemove / touchmove listened after the one of konva (added with the first stage). A node not dragged by konva (dragmove fired by code) does it at once

Parameters
run ​

(target) => void

Work done, given the last node moved

Returns

Listener of dragmove

(e) => void

_onCollaborationRight() ​

_onCollaborationRight(canEdit, joined?): void

Defined in: packages/free-drawing/src/Drawer.ts:699

Right to draw of this user given or removed by owner of collaboration room

Parameters
canEdit ​

boolean

True when this user may draw (still read only with readOnly option), told in a toast

joined? ​

boolean = false

Room just joined as viewer: told how to ask the owner to draw (no right removed)

Returns

void

_onSaved() ​

private _onSaved(): void

Defined in: packages/free-drawing/src/Drawer.ts:1743

Drawing saved: no unsaved changes, next failure warned again

Returns

void

_onSaveError() ​

private _onSaveError(error, type): void

Defined in: packages/free-drawing/src/Drawer.ts:1753

Drawing stays in page, warned once until a save succeeds

Parameters
error ​

Error

Error of the save, its message shown in the toast

type ​

"error" | "warning"

Toast type: warning for localStorage, error for app storage

Returns

void

_openFromUrl() ​

private _openFromUrl(): void

Defined in: packages/free-drawing/src/Drawer.ts:591

Drawing of a link, or room of a collaboration link

Returns

void

_placeBoundTexts() ​

private _placeBoundTexts(shapes, index): void

Defined in: packages/free-drawing/src/Drawer.ts:2560

Texts of shapes in the parent of their shape (drawing or frame), above it: a frame takes or gives back a shape with its text, never one without the other (the text would be hidden under its shape, or cut by another frame)

Parameters
shapes ​

DrawingShape[]

Shapes placed in frames, texts of shapes among them

index ​

LayerIndex

Index of the draw layer (indexLayer of utils/boundText)

Returns

void

_placeLinked() ​

_placeLinked(moved?): void

Defined in: packages/free-drawing/src/Drawer.ts:2613

Arrows on their linked shapes, then texts in their shapes (labels on their arrows): selected ones measured once by the transformer of the selection at the end (konva batch of updates), not after each one

Parameters
moved? ​

Set<string>

Ids of the nodes moved (drag, transform: getMovedIds of utils/binding): only what follows them, the whole drawing by default

Returns

void

_preferencesChanged() ​

_preferencesChanged(): void

Defined in: packages/free-drawing/src/Drawer.ts:3329

A preference may have changed: saved in browser, event once current code ends (several changes give one event)

Returns

void

_prepareExport() ​

private _prepareExport(format, options): { box: IRect; imageOptions: { background: string | undefined; dark: boolean; scale: number; }; shapes: DrawingShape[]; } | null

Defined in: packages/free-drawing/src/Drawer.ts:2943

Shapes, their box and image options of an export, null if nothing to export

Parameters
format ​

ImageFormat

Image format (pdf gets a white background when it has no color)

options ​

ExportImageOptions

Export options, defaults applied

Returns

Shapes, box and rendering options, null if nothing to export

Type Literal

{ box: IRect; imageOptions: { background: string | undefined; dark: boolean; scale: number; }; shapes: DrawingShape[]; }

box ​

box: IRect

Area of the image, around shapes

imageOptions ​

imageOptions: object

Rendering options

imageOptions.background ​

background: string | undefined

Background color, none for a transparent image

imageOptions.dark ​

dark: boolean

Dark mode colors

imageOptions.scale ​

scale: number

Pixel ratio of png and pdf

shapes ​

shapes: DrawingShape[]

Shapes exported


null

_pruneFiles() ​

private _pruneFiles(): void

Defined in: packages/free-drawing/src/Drawer.ts:1992

Image files no longer used by the drawing nor by its history forgotten, with their elements (memory of drawings opened one after the other, images of other users received)

Returns

void

_readPreferences() ​

private _readPreferences(): Partial<Preferences>

Defined in: packages/free-drawing/src/Drawer.ts:3295

Preferences saved in browser, and choices of previous versions (<key>-theme, <key>-language)

Returns

Partial<Preferences>

Valid saved preferences only, empty when none

_readSvgFiles() ​

private _readSvgFiles(files): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:3027

SVG images of a drawing of another app read as images of drawings (PNG, WebP: drawing files and collaboration servers keep these only), shown once read and once the stroke or text edit in progress ended, then saved and shared

Parameters
files ​

[string, Blob][]

SVG files by id (getSvgFiles), unread ones left empty

Returns

Promise<void>

_removeSnapGridEvents() ​

private _removeSnapGridEvents(): void

Defined in: packages/free-drawing/src/Drawer.ts:3765

Stop snapping to grid (grid hidden)

Returns

void

_restoreTool() ​

_restoreTool(tool): void

Defined in: packages/free-drawing/src/Drawer.ts:666

Tool of the user given back once the slideshow or the replay stops: activated; disabled by read only started meanwhile: activated once read only ends, pan meanwhile (not the tool of the slideshow); disabled by its plugin: another one

Parameters
tool ​

BaseWidget | null

Tool active before, null for none

Returns

void

_saveToStorage() ​

private _saveToStorage(storage): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:1703

One save at a time: changes made during a save are saved once it ends (last drawing only)

Parameters
storage ​

DrawerStorage

Storage of the app receiving the drawing file

Returns

Promise<void>

Promise of the save in progress, resolved once last changes are saved (errors shown in a toast)

_setBackground() ​

_setBackground(color): void

Defined in: packages/free-drawing/src/Drawer.ts:3148

Background color shown, without change (undo / redo, background of other users of a collaboration session)

Parameters
color ​

ColorLike

Color of the canvas background

Returns

void

_setOwnerKey() ​

private _setOwnerKey(room, ownerKey): void

Defined in: packages/free-drawing/src/Drawer.ts:981

Keep secret of owner of a room in browser (20 rooms used last), owner again when coming back to it

Parameters
room ​

string

Room id

ownerKey ​

string

Secret proving to the server that this user owns the room

Returns

void

_setReadOnly() ​

private _setReadOnly(readOnly): void

Defined in: packages/free-drawing/src/Drawer.ts:628

Read only applied, see setReadOnly: also by the right to draw of a collaboration session

Parameters
readOnly ​

boolean

True disables tools modifying drawing (pan activated), false enables them and the previous tool

Returns

void

_setShapesState() ​

private _setShapesState(changed, apply): boolean

Defined in: packages/free-drawing/src/Drawer.ts:2800

Lock or hide shapes of the drawing (not removed ones), selection updated, change saved

Parameters
changed ​

DrawingShape[]

Shapes whose state changes

apply ​

(shape) => void

Changes the state of a shape

Returns

boolean

true if a shape changed

_setUnsaved() ​

private _setUnsaved(unsaved): void

Defined in: packages/free-drawing/src/Drawer.ts:1691

Drawing has changes not saved or is saved: unsaved.change event when it changes

Parameters
unsaved ​

boolean

True when drawing has changes not saved, false once saved

Returns

void

_setupAdded() ​

_setupAdded(shape): void

Defined in: packages/free-drawing/src/Drawer.ts:1318

Node of another user added to a group or a frame of the drawing (collaboration): set up as by addShape, dragged alone or with its group

Parameters
shape ​

DrawingShape

Shape or group just added to its parent

Returns

void

_setupShape() ​

private _setupShape(shape): void

Defined in: packages/free-drawing/src/Drawer.ts:1283

Shape identity for collaboration and layers panel (kept in history and saves), also of shapes in groups (moved with their group, not alone), hit region

Parameters
shape ​

DrawingShape

Shape or group added to drawing, shapes of frames set up too

Returns

void

_setView() ​

_setView(position, scale): void

Defined in: packages/free-drawing/src/Drawer.ts:1173

View moved and zoomed: zoom level shown, background, position and collaboration updated

Parameters
position ​

Vector2d

Position of the stage (px)

scale ​

number

Zoom level

Returns

void

_shapeStates() ​

_shapeStates(): Map<string, string>

Defined in: packages/free-drawing/src/Drawer.ts:1210

JSON of each drawing shape (serializeShape) by id, bottom first: found once while a change is handled (history, collaboration), else each time

Returns

Map<string, string>

States of the top nodes of the drawing

_shapeType() ​

_shapeType(shape): string

Defined in: packages/free-drawing/src/Drawer.ts:2493

Type of a shape (layers panel, screen readers): type of a plugin (Plugin.addShapeType), else of the library

Parameters
shape ​

DrawingShape

Shape or group

Returns

string

translated type (rectangle, note, type of a plugin...), class name of other shapes

_showInView() ​

_showInView(area): void

Defined in: packages/free-drawing/src/Drawer.ts:1156

Move the view to an area of the drawing that is not entirely in it (with a margin): current zoom kept when the area fits, else zoomed out. Texts found by the search, shapes reached with the keyboard

Parameters
area ​

ViewArea

Area of the drawing, in drawing coordinates

Returns

void

_showSaved() ​

private _showSaved(json): void

Defined in: packages/free-drawing/src/Drawer.ts:1958

Drawing of a saved stage (stage.toJSON of another tab) shown: its shapes and background, history of this tab kept (its next changes only), change event

Parameters
json ​

string

Saved stage

Returns

void

_startCollaboration() ​

private _startCollaboration(room, name, invitedBy?, key?): Promise<string>

Defined in: packages/free-drawing/src/Drawer.ts:747

Session started, see startCollaboration: stops at each step once another start began meanwhile, so one socket only joins a room

Parameters
room ​

string | undefined

Room id, new room when undefined

name ​

string

Name shown to other users

invitedBy? ​

string

Id of user who shared the link

key? ​

string

Key of an encrypted room

Returns

Promise<string>

Link to join the room

_startMove() ​

_startMove(shapes): void

Defined in: packages/free-drawing/src/Drawer.ts:2650

Move of shapes started (drag, transform): frames they come from kept, shapes of frames drawn above the drawing

Parameters
shapes ​

DrawingShape[]

shapes moved (frames and shapes of groups ignored)

Returns

void

_storeFiles() ​

private _storeFiles(files): string[]

Defined in: packages/free-drawing/src/Drawer.ts:2051

Keep image files (not known ones)

Parameters
files ​

unknown

Files read (not trusted)

Returns

string[]

Ids of the files added

_takeFocus() ​

_takeFocus(): void

Defined in: packages/free-drawing/src/Drawer.ts:3853

Focus the drawer (its shortcuts) when it is created or its tool changes, unless the user is elsewhere: on another element of the page, in a field or a dialog of the drawer (e.g. tool changed by the right to draw given by the owner of a collaboration session); the page is not scrolled to the drawer

Returns

void

_triggerOptionsChange() ​

private _triggerOptionsChange(change): void

Defined in: packages/free-drawing/src/Drawer.ts:3158

Notify overlays (and any listener) that options changed

Parameters
change ​

OptionsChange

Changed options only

Returns

void

_unScale() ​

private _unScale(val): number

Defined in: packages/free-drawing/src/Drawer.ts:3779

Length of screen (px) in stage coordinates, at current zoom level

Parameters
val ​

number

Length on screen (px)

Returns

number

Length in stage coordinates

_update() ​

_update(): void

Defined in: packages/free-drawing/src/Drawer.ts:1371

Update bg position (grid is redrawn with stage) and position widget, after view move or zoom: view sent while presenting it in a collaboration session, moved by a user following a presentation: no longer followed

Returns

void

_updateMove() ​

_updateMove(): void

Defined in: packages/free-drawing/src/Drawer.ts:2669

Shapes moving: frames they would enter or leave if dropped now highlighted

Returns

void

addFiles() ​

addFiles(files): void

Defined in: packages/free-drawing/src/Drawer.ts:2039

Add image files to the drawing (files of a drawing, of another user): images using them are shown

Parameters
files ​

DrawingFiles

Data URLs by id, invalid ones (not a PNG, JPEG, WebP or GIF image) are ignored

Returns

void

addImage() ​

addImage(source, position?): Promise<Image | null>

Defined in: packages/free-drawing/src/Drawer.ts:2065

Add an image to the drawing: file reduced and encoded to stay small (see readImage), shown whole in the view (60 % of it at most, never enlarged), selected with the selection tool. Its file is kept in files

Parameters
source ​

Blob | DrawingImage

Image file (PNG, JPEG, WebP, GIF, SVG...) or image already read (data URL and size)

position? ​

Vector2d

Center of the image, in drawing coordinates (center of the view by default)

Returns

Promise<Image | null>

Image added, null when the file is not an image (error shown)

addShape() ​

addShape<T>(shape): T

Defined in: packages/free-drawing/src/Drawer.ts:1235

Add drawing shape (or group) to draw layer, draggable only with selection tool. Every drawing shape must be added with this method (tools, history, collaboration...)

Type Parameters
T ​

T extends DrawingShape

Parameters
shape ​

T

Shape or group to add on top of drawing, given an id if it has none; an id already in the drawing (a copy) or too long for collaboration servers (maxShapeIdLength) is replaced, also of its shapes

Returns

T

added shape

alignShapes() ​

alignShapes(alignment, shapes?): void

Defined in: packages/free-drawing/src/Drawer.ts:2834

Align shapes on a side or the center of their whole box (bounding boxes of rotated shapes)

Parameters
alignment ​

ShapeAlignment

left, center, right (horizontally), top, middle, bottom (vertically)

shapes? ​

DrawingShape[] = ...

Shapes to align (2 at least), selected shapes by default

Returns

void

canGroupShapes() ​

canGroupShapes(shapes?): boolean

Defined in: packages/free-drawing/src/Drawer.ts:2427

Shapes can be grouped: 2 at least, of the same group (or drawing)

Parameters
shapes? ​

DrawingShape[] = ...

Selected shapes by default

Returns

boolean

True for 2 shapes or more of the same parent, none of them a frame

clearCanvas() ​

clearCanvas(force?): void

Defined in: packages/free-drawing/src/Drawer.ts:3585

Clear canvas draw

Parameters
force? ​

boolean = false

Force clear (don't show confirm modal)

Returns

void

clearStoredData() ​

clearStoredData(force?): void

Defined in: packages/free-drawing/src/Drawer.ts:3610

Remove the data kept in the browser by the drawer: drawing, its image files and tool, library, preferences, drawings known by collaboration rooms (identity in collaboration sessions kept: id, name, secrets of rooms owned). The drawing shown is emptied (a new drawing, history cleared), unless it is the one of the storage option (drawing of the app), of a collaboration session or read only: kept, stored again by its next change. Preferences and library shown keep their values until the next visit (a preference changed is stored again)

Parameters
force? ​

boolean = false

Force clear (don't show confirm modal)

Returns

void

copyImage() ​

copyImage(format?, options?): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:2267

Copy image of selected shapes (whole drawing without selection) to clipboard: png image, or svg image and text (pasted as svg code in editors), message shown

Parameters
format? ​

"svg" | "png" = 'png'

Image format copied, png by default

options? ​

ExportImageOptions = {}

Export options (selection only, background, dark mode, scale)

Returns

Promise<void>

copyLink(): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:3096

Copy link to drawing (see getLink) to clipboard

Returns

Promise<void>

copyStyle() ​

copyStyle(shapes?): OptionsChange | null

Defined in: packages/free-drawing/src/Drawer.ts:3469

Copy the style of shapes (Ctrl + Alt + C), given to other shapes by pasteStyle: color, background, stroke width and style, corners, path and heads of arrows, text style, opacity, each part from the first shape it applies to

Parameters
shapes? ​

DrawingShape[] = ...

Shapes whose style is copied, selection by default

Returns

OptionsChange | null

Style copied (see getShapesStyle of utils/style), null without shape

deleteShapes() ​

deleteShapes(shapes?): boolean

Defined in: packages/free-drawing/src/Drawer.ts:2348

Remove shapes (selected ones by default), removed from selection

Parameters
shapes? ​

DrawingShape[] = ...

Shapes to remove (groups left empty removed too), selected shapes by default

Returns

boolean

true if a shape was removed (change saved)

destroy() ​

destroy(): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:818

Remove the drawer for good (apps mounting and unmounting it): plugins destroyed, tool deactivated (pointer action ended), collaboration session left, listeners of the page (window, document, media queries, resize observers: see signal) and of the drawer removed, stage destroyed and element of the drawer emptied. Changes not saved yet are not saved: call save() first. The drawer can't be used afterwards

Returns

Promise<void>

Resolved once the drawer is removed (after the destroy of plugins)

distributeShapes() ​

distributeShapes(direction, shapes?): void

Defined in: packages/free-drawing/src/Drawer.ts:2843

Same space between shapes along an axis: the first and last ones stay, the others are placed between them

Parameters
direction ​

Direction

horizontal (spaces between left and right sides) or vertical

shapes? ​

DrawingShape[] = ...

Shapes to distribute (3 at least), selected shapes by default

Returns

void

duplicateShapes() ​

duplicateShapes(shapes?): DrawingShape[]

Defined in: packages/free-drawing/src/Drawer.ts:2295

Copy shapes (selected ones by default) a little further, copies are selected

Parameters
shapes? ​

DrawingShape[] = ...

Shapes to copy (removed ones ignored), selected shapes by default

Returns

DrawingShape[]

copies, on top of drawing (change saved)

exportCanvas() ​

exportCanvas(options?): HTMLCanvasElement | null

Defined in: packages/free-drawing/src/Drawer.ts:2931

Drawing (or selected shapes) rendered on a canvas as exported in png, synchronous (preview), null if nothing to export

Parameters
options? ​

ExportImageOptions = {}

Export options (selection only, background, dark mode, scale)

Returns

HTMLCanvasElement | null

Canvas of the png image, null if nothing to export

exportImage() ​

exportImage(format, options?): Promise<Blob>

Defined in: packages/free-drawing/src/Drawer.ts:2893

Drawing (or selected shapes) as png, svg or pdf image, fonts of texts loaded first

Parameters
format ​

ImageFormat

Image format

options? ​

ExportImageOptions = {}

Export options (selection only, background, dark mode, scale)

Returns

Promise<Blob>

Image file of the format

Throws

nothing to export

fitFrame() ​

fitFrame(frame): void

Defined in: packages/free-drawing/src/Drawer.ts:2702

Frame drawn or resized: takes shapes of drawing entirely in it, gives back to drawing its shapes out of it

Parameters
frame ​

Frame

Frame drawn or resized

Returns

void

fitTextWidth() ​

fitTextWidth(shapes?): boolean

Defined in: packages/free-drawing/src/Drawer.ts:2237

Fit width of texts (selected ones by default, also texts of groups) to their content: box of their longest line, lines no longer wrapped, text stays in place

Parameters
shapes? ​

DrawingShape[] = ...

Shapes whose texts are fitted, selected shapes by default

Returns

boolean

true if a text changed (change saved)

flipShapes() ​

flipShapes(direction, shapes?): void

Defined in: packages/free-drawing/src/Drawer.ts:2141

Flip shapes (selected ones by default) around the center of their box, texts are still read from left to right

Parameters
direction ​

Direction

Horizontal mirrors left and right, vertical mirrors top and bottom

shapes? ​

DrawingShape[] = ...

Shapes to flip (frames ignored), selected shapes by default

Returns

void

focus() ​

focus(options?): void

Defined in: packages/free-drawing/src/Drawer.ts:3844

Focus drawer div container (usefull for keyevent for example)

Parameters
options? ​

FocusOptions

Focus options of the browser (e.g. preventScroll)

Returns

void

getCollaborationLink(room?): string

Defined in: packages/free-drawing/src/Drawer.ts:875

Link to join a room: current page with #room=<id>&by=<user id>, owner knows who shared it, and &key=<key> for the room of an encrypted session (browsers never send the # part to servers)

Parameters
room? ​

string | undefined = ...

Room id, room of current session by default

Returns

string

Url of current page with room hash, without hash when there is no room

getDrawingFile() ​

getDrawingFile(shapes?): DrawingFile

Defined in: packages/free-drawing/src/Drawer.ts:2008

Drawing as file content (.freedrawing file, link): background color and drawing shapes

Parameters
shapes? ​

DrawingShape[] = ...

Shapes written in the file, all drawing shapes by default (shapes of groups and frames: at their place in the drawing)

Returns

DrawingFile

Drawing file with background color and states of shapes

getDrawingShapeByName() ​

getDrawingShapeByName(shapeType): (Group | Shape<ShapeConfig>)[]

Defined in: packages/free-drawing/src/Drawer.ts:1328

Get all drawing shape by name

Parameters
shapeType ​

"ellipse" | "image" | "line" | "rect" | "text" | "checkbox" | "frame" | "selection" | "note" | "arrow" | "triangle" | "diamond" | "background" | "group" | "heart" | "cloud" | "star" | "hexagon" | "blockArrow" | "bubble" | "highlighter" | "straightLine" | "pathShape" | "guideLine" | "gridLine"

Shape type

Returns

(Group | Shape<ShapeConfig>)[]

Top nodes of draw layer having the name of this type

getDrawingShapes() ​

getDrawingShapes(): DrawingShape[]

Defined in: packages/free-drawing/src/Drawer.ts:1223

Get all shape drawing

Returns

DrawingShape[]

Copy of the top nodes of draw layer (shapes and groups), bottom first

getExportShapes() ​

getExportShapes(selected?): DrawingShape[]

Defined in: packages/free-drawing/src/Drawer.ts:2880

Shapes to export: selected ones when there is a selection, else all drawing shapes

Parameters
selected? ​

boolean = true

Selected shapes only

Returns

DrawingShape[]

Selected shapes, else visible drawing shapes

getLink(): Promise<string>

Defined in: packages/free-drawing/src/Drawer.ts:3085

Link to current page with drawing in its hash, no server needed: #drawing=<data>, #<id>=<data> with the id option (several drawers in a page)

Returns

Promise<string>

Url of current page with compressed drawing file in its hash

getPointerPosition() ​

getPointerPosition(): Vector2d

Defined in: packages/free-drawing/src/Drawer.ts:1353

Pointer in drawing coordinates (view moved and zoomed), for apps and plugins: center of the view when the pointer is out of the canvas (menu, keyboard)

Returns

Vector2d

Position of the pointer in the drawing

getPreferences() ​

getPreferences(): Preferences

Defined in: packages/free-drawing/src/Drawer.ts:3250

Interface settings of user (e.g. saved by the app for its logged in user)

Returns

Preferences

Current theme, language choice, grid and its style, snapping, zen mode, auto save, keep tool, shape recognition and action of the mouse wheel

getSelectedShapes() ​

getSelectedShapes(): DrawingShape[]

Defined in: packages/free-drawing/src/Drawer.ts:2130

Drawing shapes selected with selection tool

Returns

DrawingShape[]

Nodes of the transformer, empty without selection widget

getShapeLabel() ​

getShapeLabel(shape): string

Defined in: packages/free-drawing/src/Drawer.ts:2479

Name of a shape (layers panel): name given by user, else first line of a text, else type of shape

Parameters
shape ​

DrawingShape

Shape or group to name

Returns

string

Label shown for the shape, in current language for a type of shape

getShapeLink(shape): string | null

Defined in: packages/free-drawing/src/Drawer.ts:2749

Link of a shape (see setShapeLink)

Parameters
shape ​

DrawingShape

drawing shape, group or frame

Returns

string | null

url of its link, null without one

getUserId() ​

getUserId(): string

Defined in: packages/free-drawing/src/Drawer.ts:924

Id of this user in collaboration sessions (rights given by owners): of user option, else kept in browser

Returns

string

Id of the user, or a new one saved in localStorage (new each session if storage is unavailable)

getUserName() ​

getUserName(): string

Defined in: packages/free-drawing/src/Drawer.ts:999

Name shown to other users in collaboration sessions: given for this visit, else of user option, else kept in browser

Returns

string

User name, empty string if none was given

getViewArea() ​

getViewArea(): ViewArea

Defined in: packages/free-drawing/src/Drawer.ts:1119

Area of the drawing shown in the view (presented to other users of a collaboration session)

Returns

ViewArea

Visible area, in drawing coordinates

getWidget() ​

getWidget<T>(name): T | undefined

Defined in: packages/free-drawing/src/Drawer.ts:1513

Get widget by name

Type Parameters
T ​

T

Parameters
name ​

AvailableTools

Widget id

Returns

T | undefined

Widget of the toolbar, undefined if it is not in toolbar

getZoomLevel() ​

getZoomLevel(): number

Defined in: packages/free-drawing/src/Drawer.ts:1083

Get zoom level

Returns

number

Scale of the stage (1 = 100%)

groupShapes() ​

groupShapes(shapes?): Group | null

Defined in: packages/free-drawing/src/Drawer.ts:2382

Group shapes (selected ones by default, 2 at least, of the same group): moved, transformed, hidden, locked, ordered and named together. The group takes place of top shape and is selected

Parameters
shapes? ​

DrawingShape[] = ...

Shapes to group, selected shapes by default

Returns

Group | null

group (change saved), null if shapes can't be grouped

hasUnsavedChanges() ​

hasUnsavedChanges(): boolean

Defined in: packages/free-drawing/src/Drawer.ts:1648

Drawing has changes not saved yet: without auto save until save (or saveNow), during a save in storage option, after a failed save

Returns

boolean

True when changes are not saved

hideGrid() ​

hideGrid(): void

Defined in: packages/free-drawing/src/Drawer.ts:3815

Hide grid

Returns

void

insertImage() ​

insertImage(position?): Promise<Image | null>

Defined in: packages/free-drawing/src/Drawer.ts:2120

Add an image file chosen by the user (addImage)

Parameters
position? ​

Vector2d

Center of the image, in drawing coordinates (center of the view by default)

Returns

Promise<Image | null>

Image added, null when canceled or not an image

isDarkMode() ​

isDarkMode(): boolean

Defined in: packages/free-drawing/src/Drawer.ts:3397

Dark theme shown (chosen, or of device with 'system' theme)

Returns

boolean

True when dark theme is shown

loadDrawing() ​

loadDrawing(file): void

Defined in: packages/free-drawing/src/Drawer.ts:3000

Replace drawing by a drawing file content, undo restores previous drawing

Parameters
file ​

string | DrawingFile

Content or its JSON

Returns

void

Throws

not a drawing file

loadFromStorage() ​

loadFromStorage(): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:1767

Load drawing of storage option (on init, again after login...): it replaces drawing (kept if nothing is stored), history starts from it, changes are saved in storage once it is loaded. Only the last load started is applied (an app switching drawings quickly), once the stroke or text edit in progress ended; changes made during the load (slow download) are kept over the loaded drawing, as one change

Returns

Promise<void>

Rejected if drawing can't be loaded (shown in a toast): changes are not saved

off() ​

off<K>(events?, fct?): void

Defined in: packages/free-drawing/src/utils/MicroEvent.ts:71

Remove a listener of an event: without listener all listeners of this event, without arguments all listeners

Type Parameters
K ​

K extends EventName<DrawerEventMap>

name of the event

Parameters
events? ​

K

event name (several separated by spaces in JavaScript)

fct? ​

EmitterListener<DrawerEventMap, K>

listener given to on

Returns

void

Inherited from

default.off

on() ​

on<K>(events, fct): void

Defined in: packages/free-drawing/src/utils/MicroEvent.ts:57

Listen to an event

Type Parameters
K ​

K extends EventName<DrawerEventMap>

name of the event

Parameters
events ​

K

event name (several separated by spaces in JavaScript)

fct ​

EmitterListener<DrawerEventMap, K>

listener, called on each trigger with the arguments of the event

Returns

void

Inherited from

default.on

open() ​

open(): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:3063

Open a .freedrawing file chosen by user, it replaces drawing (undo restores it)

Returns

Promise<void>

openShapeLink(shape?): boolean

Defined in: packages/free-drawing/src/Drawer.ts:2758

Open the link of a shape: web page in a new tab, email address in the mail app

Parameters
shape? ​

DrawingShape | undefined = ...

Shape with a link, first selected shape with one by default

Returns

boolean

true if a link was opened

pasteStyle() ​

pasteStyle(style?): void

Defined in: packages/free-drawing/src/Drawer.ts:3491

Paste a style on the selected shapes (Ctrl + Alt + V), each part on the shapes it applies to (as the options panel does), in one change (one step of history); it becomes the style of new shapes too

Parameters
style? ​

OptionsChange | null = ...

Style to give, the copied one by default (see copyStyle)

Returns

void

placeInFrames() ​

placeInFrames(shapes): FrameChanges

Defined in: packages/free-drawing/src/Drawer.ts:2528

Shapes (drawn, moved, transformed) put in the frame containing their center, or back in drawing out of frames. Frames and shapes of groups are not concerned. Ends a move of shapes (_endMove): frames it highlighted fade out.

Parameters
shapes ​

DrawingShape[]

Shapes drawn, moved or transformed

Returns

FrameChanges

frames entered and left by the shapes

reorderShapes() ​

reorderShapes(order, shapes?): boolean

Defined in: packages/free-drawing/src/Drawer.ts:2821

Move shapes in stacking order: forward / backward above / below the next shape they overlap, front / back above / below all shapes (relative order of moved shapes is kept)

Parameters
order ​

ShapeOrder

Move: forward, backward, front or back

shapes? ​

DrawingShape[] = ...

Selected shapes by default

Returns

boolean

true if a shape moved (change saved)

resetDrawer() ​

resetDrawer(): void

Defined in: packages/free-drawing/src/Drawer.ts:3869

Reset drawer to its initial state: remove drawing (without confirmation), white background and drawing options given on init (color, width, opacity, text style...)

Returns

void

rotateShapes() ​

rotateShapes(angle, shapes?): void

Defined in: packages/free-drawing/src/Drawer.ts:2197

Rotate shapes (selected ones by default) around the center of their box

Parameters
angle ​

number

Degrees, clockwise when positive (90: quarter turn right, -90: left)

shapes? ​

DrawingShape[] = ...

Shapes to rotate (frames ignored), selected shapes by default

Returns

void

save() ​

save(): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:1601

Save drawing in storage option (once its drawing is loaded), else in localStorage. Changes are saved once it succeeds (hasUnsavedChanges), they stay unsaved if it fails or if the drawing of storage is not loaded

Returns

Promise<void>

Resolved once saved (errors are shown in a toast)

saveAs() ​

saveAs(name?): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:3049

Save drawing in a .freedrawing file, with browser save dialog when available (Chromium) else downloaded

Parameters
name? ​

string = 'drawing'

File name without extension

Returns

Promise<void>

saveNow() ​

saveNow(): Promise<void>

Defined in: packages/free-drawing/src/Drawer.ts:1638

Save drawing (save) and tell it, from menu and command palette: nothing told when it failed (error shown) or when nothing could be saved (drawing of storage option not loaded)

Returns

Promise<void>

setArrowheads() ​

setArrowheads(heads): void

Defined in: packages/free-drawing/src/Drawer.ts:3422

Heads of the ends of new arrows (given ends only), applied to selected arrows

Parameters
heads ​

Partial<Arrowheads>

Head of the start, of the end: 'none', 'arrow', 'triangle', 'dot' or 'bar'

Returns

void

setArrowType() ​

setArrowType(arrowType): void

Defined in: packages/free-drawing/src/Drawer.ts:3412

Path of new arrows, applied to selected arrows

Parameters
arrowType ​

ArrowType

'straight', 'curved' or 'elbow'

Returns

void

setAutoSave() ​

setAutoSave(autoSave): void

Defined in: packages/free-drawing/src/Drawer.ts:1656

Save drawing on each change, or only with save / saveNow (preference): pending changes saved when enabled

Parameters
autoSave ​

boolean

True saves on each change, false marks changes unsaved until a save

Returns

void

setBgColor() ​

setBgColor(color): void

Defined in: packages/free-drawing/src/Drawer.ts:3138

Change background color

Parameters
color ​

ColorLike

Color of the canvas background (change saved)

Returns

void

setEdges() ​

setEdges(value): void

Defined in: packages/free-drawing/src/Drawer.ts:3435

Set corners of rectangles (new and selected ones)

Parameters
value ​

Edges

'sharp', 'round' (radius following rectangle size) or radius (px, 0 is sharp)

Returns

void

setFillColor() ​

setFillColor(color): void

Defined in: packages/free-drawing/src/Drawer.ts:3176

Set background color of rectangles and ellipses (new and selected ones)

Parameters
color ​

ColorLike

'transparent' for none

Returns

void

setGridStyle() ​

setGridStyle(gridStyle): void

Defined in: packages/free-drawing/src/Drawer.ts:3829

Style of the grid (preference): squares, dots, lines of ruled paper or triangles of isometric paper; shapes snap to its lines or points, selections rotate by 30 degrees on isometric paper

Parameters
gridStyle ​

GridStyle

Style of the grid, drawn again when shown

Returns

void

setKeepTool() ​

setKeepTool(keepTool): void

Defined in: packages/free-drawing/src/Drawer.ts:1668

Keep drawing tool after drawing a shape, else selection tool is activated, nothing selected (preference)

Parameters
keepTool ​

boolean

True keeps the drawing tool, false activates selection tool after each drawing

Returns

void

setLanguage() ​

setLanguage(language): void

Defined in: packages/free-drawing/src/Drawer.ts:3235

Set language of interface (saved for next visits): every text is translated at once

Parameters
language ​

"en" | "fr" | "es" | "de" | "auto"

'en', 'fr', 'es', 'de' or 'auto' (browser one); a locale gives its language ('fr-FR'), a language not supported the one of the browser

Returns

void

setOpacity() ​

setOpacity(opacity): void

Defined in: packages/free-drawing/src/Drawer.ts:3447

Set opacity of shape 0 to 1

Parameters
opacity ​

number

Opacity of new shapes (0 transparent, 1 opaque), applied to selected ones

Returns

void

setPreferences() ​

setPreferences(preferences): void

Defined in: packages/free-drawing/src/Drawer.ts:3269

Apply interface settings (given ones only), one preferences.change event

Parameters
preferences ​

Partial<Preferences>

Grid wins when grid and snapping are both true

Returns

void

setReadOnly() ​

setReadOnly(readOnly): void

Defined in: packages/free-drawing/src/Drawer.ts:619

Read only: drawing can't be modified by user (tools except pan, shortcuts and menu items modifying drawing, text edition), API methods still modify it. Asked by the app (kept in options.readOnly): a collaboration session giving the right to draw keeps it, a viewer of a session stays read only

Parameters
readOnly ​

boolean

True disables tools modifying drawing (pan activated), false enables them and the previous tool

Returns

void

setShapeLabel() ​

setShapeLabel(shape, label, save?): boolean

Defined in: packages/free-drawing/src/Drawer.ts:2508

Give a name to a shape (saved with it), an empty name gives back its default name (frames: their title)

Parameters
shape ​

DrawingShape

Shape or group to name

label ​

string

New name, trimmed (empty removes it)

save? ​

boolean = true

Change saved (default true)

Returns

boolean

true if name changed

setShapeLink(link, shapes?): boolean

Defined in: packages/free-drawing/src/Drawer.ts:2726

Link of shapes (selected ones by default): web page or email address, opened from the link icon of the shape or from the selection panel

Parameters

string | null

address (https:// added without protocol, see parseLink), null or empty to remove the link

shapes? ​

DrawingShape[] = ...

Shapes linked (removed ones ignored), selected shapes by default

Returns

boolean

true if a link changed (change saved), false for an invalid address (nothing changed)

setShapeRecognition() ​

setShapeRecognition(shapeRecognition): void

Defined in: packages/free-drawing/src/Drawer.ts:1680

Brush strokes recognized as shapes (preference): a rectangle, an ellipse, a triangle, a diamond, a line or an arrow drawn in one stroke is replaced by the shape of its tool (undo gives back the stroke)

Parameters
shapeRecognition ​

boolean

True recognizes shapes, false keeps the strokes as drawn

Returns

void

setShapesHidden() ​

setShapesHidden(hidden, shapes?): boolean

Defined in: packages/free-drawing/src/Drawer.ts:2787

Hide shapes (selected ones by default), with their texts (texts with their shapes): not drawn, selected nor exported

Parameters
hidden ​

boolean

True hides shapes, false shows them

shapes? ​

DrawingShape[] = ...

Shapes to hide or show, selected shapes by default

Returns

boolean

true if a shape changed (change saved)

setShapesLocked() ​

setShapesLocked(locked, shapes?): boolean

Defined in: packages/free-drawing/src/Drawer.ts:2774

Lock shapes (selected ones by default), with their texts (texts with their shapes): not moved, transformed nor erased on canvas, only selected to be unlocked

Parameters
locked ​

boolean

True locks shapes, false unlocks them

shapes? ​

DrawingShape[] = ...

Shapes to lock or unlock, selected shapes by default

Returns

boolean

true if a shape changed (change saved)

setSize() ​

setSize(width, height): void

Defined in: packages/free-drawing/src/Drawer.ts:3891

Resize the stage (px), e.g. when the window of a drawer of window size is resized

Parameters
width ​

number

New width of the stage (px)

height ​

number

New height of the stage (px)

Returns

void

setStrokeColor() ​

setStrokeColor(color): void

Defined in: packages/free-drawing/src/Drawer.ts:3166

Set color for draw

Parameters
color ​

ColorLike

Stroke color of new shapes, applied to selected ones

Returns

void

setStrokeStyle() ​

setStrokeStyle(style): void

Defined in: packages/free-drawing/src/Drawer.ts:3198

Set stroke style of lines, arrows, rectangles and ellipses (new and selected ones)

Parameters
style ​

number[] | StrokeStyle | undefined

'solid', 'dashed' or 'dotted' (deprecated dash array gives 'dashed', undefined 'solid')

Returns

void

setStrokeWidth() ​

setStrokeWidth(width): void

Defined in: packages/free-drawing/src/Drawer.ts:3186

Set stroke width for draw

Parameters
width ​

string | number

Stroke width (px) of new shapes, applied to selected ones (string converted to number)

Returns

void

setTextStyle() ​

setTextStyle(style): void

Defined in: packages/free-drawing/src/Drawer.ts:3457

Set text style (font family, size, style, decoration, align) of new and selected text

Parameters
style ​

Partial<TextStyle>

Changed properties only, merged with current text style

Returns

void

setTheme() ​

setTheme(theme): void

Defined in: packages/free-drawing/src/Drawer.ts:3387

Set theme (saved for next visits): in dark mode, drawing is shown with inverted colors, its colors are kept

Parameters
theme ​

Theme

'light', 'dark' or 'system' (device one)

Returns

void

setUser() ​

setUser(user): void

Defined in: packages/free-drawing/src/Drawer.ts:910

User logged in or out: their id is used by next collaboration sessions, their name at once

Parameters
user ​

DrawerUser | null

null for anonymous user (id and name kept in browser)

Returns

void

setUserName() ​

setUserName(name): void

Defined in: packages/free-drawing/src/Drawer.ts:1007

Change name shown to other users (current session and next ones)

Parameters
name ​

string

New name, trimmed and cut to 40 characters

Returns

void

setWheelAction() ​

setWheelAction(wheelAction): void

Defined in: packages/free-drawing/src/Drawer.ts:1588

Action of the mouse wheel (preference): zoom (Ctrl / Cmd + wheel moves the view) or move of the view (Ctrl / Cmd + wheel zooms); a pinch of a trackpad always zooms

Parameters
wheelAction ​

WheelAction

'zoom' or 'pan'

Returns

void

setZoomLevel() ​

setZoomLevel(scale, point?): void

Defined in: packages/free-drawing/src/Drawer.ts:1092

Set zoom level, limited from 10% to 3000%

Parameters
scale ​

number

Zoom level (1 = 100%)

point? ​

Vector2d = ...

Absolute position that stays in place, stage center by default

Returns

void

showArea() ​

showArea(area, maxScale?, margin?): void

Defined in: packages/free-drawing/src/Drawer.ts:1137

Show an area of the drawing (view presented by another user): zoomed to fit in the view (zoom limits kept), centered in it

Parameters
area ​

ViewArea

Area of the drawing, in drawing coordinates

maxScale? ​

number = zoomLimits.max

Highest zoom (a small area is not enlarged beyond it)

margin? ​

number = 0

Space kept around the area in the view (px)

Returns

void

showCollaboration() ​

showCollaboration(joinRoom?, invitedBy?, key?): void

Defined in: packages/free-drawing/src/Drawer.ts:894

Live collaboration dialog: owner starts / stops session, shares link and QR code, gives rights; other users give their name

Parameters
joinRoom? ​

string | null = null

Room of a link, joined once user gave a name

invitedBy? ​

string

Id of user who shared the link

key? ​

string

Key of the encrypted room of the link

Returns

void

showCommandPalette() ​

showCommandPalette(): void

Defined in: packages/free-drawing/src/Drawer.ts:2982

Command palette: search a tool or command available now and run it

Returns

void

showExport() ​

showExport(): void

Defined in: packages/free-drawing/src/Drawer.ts:2974

Export dialog: preview, png, svg, pdf, drawing file, copy to clipboard

Returns

void

showGrid() ​

showGrid(): void

Defined in: packages/free-drawing/src/Drawer.ts:3664

Show grid

Returns

void

showPreferences() ​

showPreferences(): void

Defined in: packages/free-drawing/src/Drawer.ts:2990

Preferences dialog: theme, language, zen mode, grid, snapping, name in collaboration sessions

Returns

void

stackShapes() ​

stackShapes(direction, shapes?): void

Defined in: packages/free-drawing/src/Drawer.ts:2853

Shapes one after the other along an axis, 16 units between them: the first one stays, their place on the other axis is kept

Parameters
direction ​

Direction

horizontal (a row from left to right) or vertical (a column from top to bottom)

shapes? ​

DrawingShape[] = ...

Shapes to stack (2 at least), selected shapes by default

Returns

void

startCollaboration() ​

startCollaboration(room?, name?, invitedBy?, key?): Promise<string>

Defined in: packages/free-drawing/src/Drawer.ts:716

Start a live collaboration session in a room (collaboration option gives the server), current session is stopped. A new room is encrypted end to end (unless the encrypt option of collaboration is false): its key is in its links, the server never reads the drawing

Parameters
room? ​

string

Room id, new room by default

name? ​

string = ...

Name shown to other users, saved for next sessions

invitedBy? ​

string

Id of user who shared the link (see getCollaborationLink), shown to owner

key? ​

string

Key of an encrypted room (key of its link), none for a room in clear; a new room gets a new one

Returns

Promise<string>

Link to join the room; a new room asked again while it connects (double click) gives the same session

Throws

error.roomKey for a key cut or changed, error.insecurePage for an encrypted room on a page without Web Crypto (not https); an error when another session was started meanwhile (this one is not)

stopCollaboration() ​

stopCollaboration(): void

Defined in: packages/free-drawing/src/Drawer.ts:855

Stop live collaboration session (drawing is kept)

Returns

void

t() ​

t(key, params?): string

Defined in: packages/free-drawing/src/Drawer.ts:3212

Text of interface in current language

Parameters
key ​

"drawer.label" | "language.auto" | "toast.collaborationUnavailable" | "toast.collaborationFull" | "toast.collaborationTooBig" | "toast.canDraw" | "toast.viewOnly" | "toast.joinedViewOnly" | "toast.presentationStarted" | "toast.presentationEnded" | "toast.requestSent" | "toast.requestReceived" | "toast.requestRefused" | "toast.saveFailed" | "toast.saved" | "toast.styleCopied" | "toast.libraryImported" | "toast.libraryNotSaved" | "toast.loadFailed" | "toast.invalidFile" | "toast.linkCopied" | "toast.linkNotCopied" | "toast.invalidLink" | "toast.invalidShapeLink" | "toast.clipboardUnavailable" | "toast.exportFailed" | "toast.imageCopied" | "toast.storageCleared" | "toast.imageNotCopied" | "error.clipboardUnavailable" | "error.nothingToExport" | "error.notDrawingFile" | "error.notImage" | "error.damagedLink" | "error.drawingTooBig" | "error.imageNotCreated" | "error.serverUnreachable" | "error.notAllowed" | "error.storageFull" | "error.notLibraryFile" | "error.noDrawingInImage" | "error.insecurePage" | "error.roomKey" | "error.encryptionUnsupported" | "toast.selectionTool" | "modal.close" | "confirm.message" | "confirm.clearCanvas" | "confirm.clearStorage" | "confirm.stopCollaboration" | "confirm.leaveCollaboration" | "confirm.cancel" | "confirm.confirm" | "menu.label" | "menu.open" | "menu.saveAs" | "menu.save" | "menu.unsaved" | "menu.copyLink" | "menu.collaboration" | "menu.collaborationOn" | "menu.collaborationUsers" | "menu.export" | "menu.clearCanvas" | "menu.showGrid" | "menu.zenMode" | "menu.darkMode" | "menu.github" | "menu.githubLabel" | "menu.clearStorage" | "menu.background" | "menu.language" | "menu.commands" | "menu.preferences" | "preferences.title" | "preferences.autoSave" | "preferences.shapeRecognition" | "grid.style" | "grid.squares" | "grid.dots" | "grid.lines" | "grid.isometric" | "grid.styleCommand" | "preferences.wheel" | "wheel.zoom" | "wheel.pan" | "wheel.command" | "help.spaceDrag" | "help.wheelDrag" | "preferences.save" | "preferences.appearance" | "preferences.theme" | "preferences.light" | "preferences.dark" | "preferences.system" | "preferences.drawing" | "commands.search" | "commands.empty" | "commands.file" | "commands.language" | "color.white" | "color.lightGray" | "color.lightBlue" | "color.lightYellow" | "color.lightBeige" | "color.lightRed" | "color.lightGreen" | "color.black" | "color.red" | "color.green" | "color.blue" | "color.orange" | "color.yellow" | "color.pink" | "color.transparent" | "color.custom" | "color.pick" | "help.title" | "help.documentation" | "help.issue" | "help.shortcuts" | "help.tools" | "help.editor" | "help.view" | "help.or" | "help.selectAll" | "help.deleteSelection" | "help.duplicate" | "help.group" | "help.selectInGroup" | "help.constrainDrawing" | "help.whileDrawing" | "help.cancelDrawing" | "help.arrowUnlinked" | "help.constrainSelection" | "help.whileTransforming" | "help.move" | "help.forwardBackward" | "help.frontBack" | "help.lock" | "help.paste" | "help.open" | "help.save" | "help.export" | "help.grid" | "help.layers" | "help.layersSelect" | "help.snap" | "help.zoom" | "help.toolsConstrain" | "key.delete" | "key.arrows" | "key.click" | "key.space" | "key.wheel" | "key.ctrl" | "key.shift" | "key.alt" | "key.escape" | "key.enter" | "key.tab" | "key.home" | "key.end" | "key.backspace" | "toolbar.label" | "toolbar.moreTools" | "toolbar.keepTool" | "tools.pan" | "tools.selection" | "tools.brush" | "tools.eraser" | "tools.text" | "tools.note" | "tools.line" | "tools.square" | "tools.circle" | "tools.arrow" | "tools.image" | "tools.triangle" | "tools.diamond" | "tools.laser" | "tools.frame" | "zoom.label" | "zoom.out" | "zoom.in" | "zoom.reset" | "zoom.fit" | "zoom.selection" | "zoom.to100" | "history.label" | "history.undo" | "history.redo" | "position.label" | "position.recenter" | "context.paste" | "context.snap" | "context.lock" | "context.unlock" | "selectionMenu.label" | "action.duplicate" | "action.copyStyle" | "action.pasteStyle" | "library.title" | "library.add" | "library.empty" | "library.hint" | "library.insert" | "library.remove" | "library.import" | "library.export" | "library.close" | "library.shapes" | "search.label" | "search.count" | "search.none" | "slideshow.start" | "slideshow.presentFrom" | "slideshow.label" | "slideshow.previous" | "slideshow.next" | "slideshow.stop" | "slideshow.count" | "slideshow.slide" | "slideshow.slideTitled" | "slideshow.noFrames" | "slideshow.nextPrevious" | "slideshow.firstLast" | "slideshow.whilePresenting" | "replay.start" | "replay.label" | "replay.play" | "replay.pause" | "replay.restart" | "replay.speed" | "replay.stop" | "replay.count" | "replay.empty" | "replay.finished" | "replay.playPause" | "replay.step" | "replay.firstLast" | "replay.whileReplaying" | "navigation.description" | "navigation.text" | "navigation.shapes" | "navigation.from" | "navigation.to" | "navigation.link" | "navigation.locked" | "navigation.in" | "navigation.index" | "navigation.left" | "navigation.nextPrevious" | "navigation.enter" | "navigation.parent" | "navigation.leave" | "navigation.onDrawing" | "search.previous" | "search.next" | "search.close" | "action.group" | "action.ungroup" | "action.sendToBack" | "action.sendBackward" | "action.bringForward" | "action.bringToFront" | "action.delete" | "action.rotateRight" | "action.rotateLeft" | "action.flipHorizontal" | "action.flipVertical" | "action.insertImage" | "toast.imageFailed" | "action.alignLeft" | "action.alignCenter" | "action.alignRight" | "action.alignTop" | "action.alignMiddle" | "action.alignBottom" | "action.distributeHorizontal" | "action.distributeVertical" | "action.stackHorizontal" | "action.stackVertical" | "action.fitTextWidth" | "action.copyPng" | "action.copySvg" | "action.link" | "overlay.tool" | "overlay.selection" | "overlay.shape" | "overlay.brush" | "overlay.recognizeShapes" | "overlay.recognizeShapesHint" | "overlay.note" | "overlay.text" | "overlay.stroke" | "overlay.color" | "overlay.background" | "overlay.strokeWidth" | "overlay.strokeStyle" | "overlay.edges" | "overlay.arrowType" | "overlay.startHead" | "overlay.endHead" | "overlay.opacity" | "overlay.layers" | "overlay.align" | "overlay.distribute" | "overlay.actions" | "link.address" | "link.placeholder" | "link.open" | "link.remove" | "width.thin" | "width.medium" | "width.thick" | "width.extraThick" | "style.solid" | "style.dashed" | "style.dotted" | "edges.sharp" | "edges.round" | "edges.radius" | "edges.auto" | "arrow.straight" | "arrow.curved" | "arrow.elbow" | "arrowhead.none" | "arrowhead.arrow" | "arrowhead.triangle" | "arrowhead.dot" | "arrowhead.bar" | "text.fontFamily" | "text.fontSize" | "text.small" | "text.medium" | "text.large" | "text.extraLarge" | "text.style" | "text.bold" | "text.italic" | "text.underline" | "text.strikethrough" | "text.align" | "text.alignLeft" | "text.alignCenter" | "text.alignRight" | "layers.title" | "layers.group" | "layers.close" | "layers.empty" | "layers.drag" | "layers.shapesOf" | "layers.hide" | "layers.lock" | "layers.delete" | "layers.name" | "layers.toggle" | "layers.range" | "shapes.freehand" | "shapes.line" | "shapes.rect" | "shapes.ellipse" | "shapes.arrow" | "shapes.triangle" | "shapes.diamond" | "shapes.heart" | "shapes.cloud" | "shapes.star" | "shapes.hexagon" | "shapes.blockArrow" | "shapes.bubble" | "shapes.checkbox" | "shapes.shape" | "shapes.highlighter" | "shapes.frame" | "shapes.frameName" | "shapes.text" | "shapes.note" | "shapes.group" | "shapes.image" | "export.title" | "export.empty" | "export.options" | "export.selected" | "export.background" | "export.dark" | "export.withDrawing" | "export.scale" | "export.saveAs" | "export.saveFile" | "export.copy" | "export.preview" | "collab.title" | "collab.intro" | "collab.introInvited" | "collab.introJoined" | "collab.introJoinedOf" | "collab.name" | "collab.anonymous" | "collab.link" | "collab.copy" | "collab.qrCode" | "collab.start" | "collab.join" | "collab.stop" | "collab.leave" | "collab.live" | "collab.liveState" | "collab.connected" | "collab.connecting" | "collab.you" | "collab.invitedBy" | "collab.canDrawLabel" | "collab.canDraw" | "collab.newUsersCanDraw" | "collab.encrypted" | "collab.notEncrypted" | "collab.owner" | "collab.viewOnly" | "collab.present" | "collab.presenting" | "collab.follow" | "collab.followPresentation" | "collab.following" | "collab.youCanDraw" | "collab.youViewOnly" | "collab.requestEdit" | "collab.requestSent" | "collab.requests" | "collab.requestsCount" | "collab.accept" | "collab.refuse" | "collab.acceptLabel" | "collab.refuseLabel" | "collab.users" | "collab.settings"

Key of the text in translations

params? ​

TranslationParams

Values of {name} placeholders

Returns

string

Translated text with placeholders replaced

toast() ​

toast(message, type?, timeout?, showIcon?): Toast

Defined in: packages/free-drawing/src/Drawer.ts:3533

Show toast message for user

Parameters
message ​

string

Message to show

type? ​

AvailableTypes

Type of toast

timeout? ​

number

Delay (ms) before it hides, 5000 by default, 0 keeps it shown

showIcon? ​

boolean

Show the icon of its type (default true)

Returns

Toast

Toast shown

toggleDarkMode() ​

toggleDarkMode(): void

Defined in: packages/free-drawing/src/Drawer.ts:3404

Switch between light and dark themes

Returns

void

trigger() ​

trigger<K>(events, ...args): void

Defined in: packages/free-drawing/src/utils/MicroEvent.ts:100

Call listeners of an event, in order of registration. A listener may add or remove listeners: the ones added are called from the next trigger, the ones removed (not called yet) are not called, the others are all called.

Type Parameters
K ​

K extends EventName<DrawerEventMap>

name of the event

Parameters
events ​

K

event name (several separated by spaces in JavaScript)

args ​

...EventArgs<DrawerEventMap, K>

arguments given to listeners, as typed by the event

Returns

void

Inherited from

default.trigger

UIPointerEvents() ​

UIPointerEvents(state): void

Defined in: packages/free-drawing/src/Drawer.ts:3546

Interface panels receive pointer or not (--drawer-pointer-events)

Parameters
state ​

"none" | "all"

'none' during pointer actions, 'all' after

Returns

void

Deprecated

use layout.setPointerEvents

ungroupShapes() ​

ungroupShapes(shapes?): DrawingShape[]

Defined in: packages/free-drawing/src/Drawer.ts:2440

Ungroup groups (selected ones by default): their shapes take their place with the same look (transform, hidden, locked) and are selected

Parameters
shapes? ​

DrawingShape[] = ...

Groups to ungroup (other shapes and frames ignored), selected shapes by default

Returns

DrawingShape[]

shapes of groups (change saved)

zoomToFit() ​

zoomToFit(shapes?): void

Defined in: packages/free-drawing/src/Drawer.ts:1189

Show shapes in the view (whole drawing by default): centered, zoomed out when they do not fit (never zoomed in beyond 100 %), space around them for the interface. Done after a file or a link is opened

Parameters
shapes? ​

DrawingShape[] = ...

Shapes to show, visible drawing shapes by default (nothing done without shapes)

Returns

void

zoomToSelection() ​

zoomToSelection(): void

Defined in: packages/free-drawing/src/Drawer.ts:1199

Show the selected shapes in the view: centered, zoomed to fill it (200 % at most), space around them for the interface (Shift + 2). Nothing done without selection

Returns

void