App
Public Class
Table of Contents
- Properties
- allShapesCommonBounds
- assets
- brush
- camera
- canMoveCamera
- canRedo
- canUndo
- config
- croppingId
- cullingBounds
- cullingBoundsExpanded
- currentPage
- currentPageId
- currentToolId
- cursor
- devicePixelRatio
- dispatch
- disposables
- documentSettings
- editingId
- editingShape
- erasingIds
- erasingIdsSet
- focusLayerId
- focusLayerShape
- getContainer
- gridSize
- hintingIds
- history
- hoveredId
- hoveredShape
- inputs
- instanceId
- instanceState
- isChangingStyle
- isChromeForIos
- isCoarsePointer
- isFocused
- isGridMode
- isIos
- isMenuOpen
- isPenMode
- isReadOnly
- isSafari
- onlySelectedShape
- openMenus
- pages
- pageState
- renderingShapes
- root
- scribble
- selectedIds
- selectedIdsSet
- selectedPageBounds
- selectedShapes
- selectionBounds
- selectionPageCenter
- selectionRotation
- shapeIds
- shapesArray
- shapeUtils
- snaps
- sortedShapesArray
- startFollowingUser
- stopFollowingUser
- store
- styles
- textMeasure
- updateUserPresence
- user
- userDocumentSettings
- userId
- userPresence
- userSettings
- viewportPageBounds
- viewportPageCenter
- viewportScreenBounds
- viewportScreenCenter
- zoomBrush
- zoomLevel
- Methods
- alignShapes
- animateCamera
- animateShapes
- animateToShape
- bail
- bailToMark
- batch
- blur
- bringForward
- bringToFront
- cancel
- cancelDoubleClick
- centerOnPoint
- complete
- createAssets
- createPage
- createShapeId
- createShapes
- deleteAssets
- deletePage
- deleteShapes
- deselect
- dispose
- distributeShapes
- duplicatePage
- duplicateShapes
- findAncestor
- findCommonAncestor
- flipShapes
- focus
- getAncestors
- getAncestorsById
- getArrowsBoundTo
- getAssetById
- getAssetBySrc
- getBounds
- getBoundsById
- getClipPathById
- getContent
- getCssColor
- getDeltaInParentSpace
- getDeltaInShapeSpace
- getDroppingShape
- getHighestIndexForParent
- getMaskedPageBounds
- getMaskedPageBoundsById
- getOutermostSelectableShape
- getOutline
- getOutlineById
- getPageBounds
- getPageBoundsById
- getPageById
- getPageCenter
- getPageCenterById
- getPageCorners
- getPageInfoById
- getPageMaskById
- getPagePointById
- getPageRotation
- getPageRotationById
- getPageStateByPageId
- getPageTransform
- getPageTransformById
- getParentIdForNewShapeAtPoint
- getParentPageId
- getParentShape
- getParentsMappedToChildren
- getParentTransform
- getPointInParentSpace
- getPointInShapeSpace
- getShapeById
- getShapesAndDescendantsInOrder
- getShapesAtPoint
- getShapesInPage
- getShapeUtil
- getShapeUtilByDef
- getSortedChildIds
- getStateDescendant
- getStrokeWidth
- getSvg
- getTransform
- groupShapes
- hasAncestor
- interrupt
- isIn
- isInAny
- isPointInShape
- isSelected
- isShapeInPage
- isShapeInViewport
- isWithinSelection
- lockShapes
- mark
- moveShapesToPage
- nudgeShapes
- onCreateAssetFromFile
- onCreateBookmarkFromUrl
- packShapes
- pageToScreen
- pan
- panZoomIntoView
- popFocusLayer
- putContent
- redo
- renamePage
- reorderShapes
- reparentShapesById
- replaceStoreContentsWithRecordsForOtherDocument
- resetZoom
- resizeShape
- rotateShapesBy
- screenToPage
- select
- selectAll
- selectNone
- sendBackward
- sendToBack
- setBrush
- setCamera
- setCroppingId
- setCurrentPageId
- setCursor
- setDarkMode
- setEditingId
- setErasingIds
- setFocusLayer
- setGridMode
- setHintingIds
- setHoveredId
- setInstancePageState
- setPenMode
- setProp
- setReadOnly
- setScribble
- setSelectedIds
- setSelectedTool
- setZoomBrush
- slideCamera
- stackShapes
- stopCameraAnimation
- stretchShapes
- undo
- ungroupShapes
- updateAssets
- updateInstanceState
- updatePage
- updateShapes
- updateUser
- updateUserDocumentSettings
- updateViewportScreenBounds
- visitDescendants
- zoomIn
- zoomOut
- zoomToBounds
- zoomToFit
- zoomToSelection
Signature
class App extends EventEmitter {}
References
Constructor
Public Constructor
Constructs a new instance of the App
class
Parameters
Name | Description |
---|---|
|
|
References
Properties
allShapesCommonBounds
Public Readonly Property
The common bounds of all of the shapes on the page.
Signature
get allShapesCommonBounds(): Box2d | null
References
assets
Public Readonly Property
Get all assets in the app.
Signature
get assets(): (
| import('@tldraw/tlschema').TLBookmarkAsset
| TLImageAsset
| TLVideoAsset
)[]
References
TLBookmarkAsset, TLImageAsset, TLVideoAsset
brush
Public Readonly Property
Signature
get brush(): Box2dModel | null
References
camera
Public Readonly Property
The current camera.
Signature
get camera(): TLCamera
References
canMoveCamera
Public Property
Set whether the editor's camera can move.
Example
app.canMoveCamera = false
Parameters
Name | Description |
---|---|
| Whether the camera can move. |
Signature
get canMoveCamera(): boolean
set canMoveCamera(canMove: boolean)
canRedo
Public Readonly Property
Whether the app can redo.
Signature
get canRedo(): boolean
canUndo
Public Readonly Property
Whether the app can undo.
Signature
get canUndo(): boolean
config
Public Readonly Property
The editor's config
Signature
readonly config: TldrawEditorConfig
References
croppingId
Public Readonly Property
The current cropping shape's id.
Signature
get croppingId(): null | TLShapeId
References
cullingBounds
Public Readonly Property
The current culling bounds in page space, used for checking which shapes are "on screen".
Signature
get cullingBounds(): Box2d
References
cullingBoundsExpanded
Public Readonly Property
The current culling bounds in page space, expanded slightly. Used for determining which shapes to render and which to "cull".
Signature
get cullingBoundsExpanded(): Box2d
References
currentPage
Public Readonly Property
The current page.
Signature
get currentPage(): TLPage
References
currentPageId
Public Readonly Property
The current page id.
Signature
get currentPageId(): TLPageId
References
currentToolId
Public Readonly Property
The id of the current selected tool.
Signature
get currentToolId(): string
cursor
Public Readonly Property
Signature
get cursor(): TLCursor
References
devicePixelRatio
Public Readonly Property
Signature
get devicePixelRatio(): number
dispatch
Public Property
Dispatch an event to the app.
Example
app.dispatch(myPointerEvent)
Parameters
Name | Description |
---|---|
| The event info. |
Signature
dispatch: (info: TLEventInfo) => this
References
disposables
Public Readonly Property
A set of functions to call when the app is disposed.
Signature
readonly disposables: Set<() => void>
References
documentSettings
Public Readonly Property
The global document settings that applies to all users
Signature
get documentSettings(): import('@tldraw/tlschema').TLDocument
References
editingId
Public Readonly Property
The current editing shape's id.
Signature
get editingId(): null | TLShapeId
References
editingShape
Public Readonly Property
Signature
get editingShape(): null | TLUnknownShape
References
erasingIds
Public Readonly Property
The editor's current erasing ids.
Signature
get erasingIds(): TLShapeId[]
References
erasingIdsSet
Public Readonly Property
A derived set containing the current erasing ids.
Signature
get erasingIdsSet(): Set<TLShapeId>
References
focusLayerId
Public Readonly Property
Signature
get focusLayerId(): TLPageId | TLShapeId
References
focusLayerShape
Public Readonly Property
Signature
get focusLayerShape(): TLShape | undefined
References
getContainer
Public Property
The current HTML element containing the editor.
Example
const container = app.getContainer()
Signature
getContainer: () => HTMLElement
References
gridSize
Public Readonly Property
Signature
get gridSize(): number
hintingIds
Public Readonly Property
The editor's current hinting ids.
Signature
get hintingIds(): TLShapeId[]
References
history
Public Readonly Property
A manager for the app's history.
Signature
readonly history: HistoryManager<this>
References
hoveredId
Public Readonly Property
Signature
get hoveredId(): null | TLShapeId
References
hoveredShape
Public Readonly Property
Signature
get hoveredShape(): null | TLUnknownShape
References
inputs
Public Property
The app's current input state.
Signature
inputs: {
originPagePoint: Vec2d
originScreenPoint: Vec2d
previousPagePoint: Vec2d
previousScreenPoint: Vec2d
currentPagePoint: Vec2d
currentScreenPoint: Vec2d
keys: Set<string>
buttons: Set<number>
isPen: boolean
shiftKey: boolean
ctrlKey: boolean
altKey: boolean
isDragging: boolean
isPointing: boolean
isPinching: boolean
isEditing: boolean
isPanning: boolean
pointerVelocity: Vec2d
}
References
instanceId
Public Readonly Property
The editor's instanceId (defined in its store.props).
Example
const instanceId = app.instanceId
Signature
get instanceId(): TLInstanceId
References
instanceState
Public Readonly Property
The current tab state
Signature
get instanceState(): TLInstance
References
isChangingStyle
Public Property
Whether the user is currently changing the style of a shape. This may cause the UI to change.
Example
app.isChangingStyle = true
Signature
get isChangingStyle(): boolean
set isChangingStyle(v: boolean)
isChromeForIos
Public Readonly Property
Whether the editor is running on iOS.
Signature
readonly isChromeForIos: boolean
isCoarsePointer
Public Property
Whether the user is using a "coarse" pointer, such as on a touch screen.
Signature
get isCoarsePointer(): boolean
set isCoarsePointer(v: boolean)
isFocused
Public Readonly Property
Whether or not the editor is focused.
Signature
get isFocused(): boolean
isGridMode
Public Readonly Property
Signature
get isGridMode(): boolean
isIos
Public Readonly Property
Whether the editor is running on iOS.
Signature
readonly isIos: boolean
isMenuOpen
Public Readonly Property
Get whether any menus are open.
Signature
get isMenuOpen(): boolean
isPenMode
Public Readonly Property
Signature
get isPenMode(): boolean
isReadOnly
Public Readonly Property
Signature
get isReadOnly(): boolean
isSafari
Public Readonly Property
Whether the editor is running in Safari.
Signature
readonly isSafari: boolean
onlySelectedShape
Public Readonly Property
The app's only selected shape.
Example
app.onlySelectedShape
Signature
get onlySelectedShape():
| import('@tldraw/tlschema').TLBaseShape<any, any>
| null
References
openMenus
Public Property
A set of strings representing any open menus or modals.
Signature
openMenus: Set<string>
References
pages
Public Readonly Property
Info about the project's current pages.
Signature
get pages(): TLPage[]
References
pageState
Public Readonly Property
The current page state.
Signature
get pageState(): TLInstancePageState
References
renderingShapes
Public Readonly Property
Get the shapes that should be displayed in the current viewport.
Signature
get renderingShapes(): {
id: TLShapeId
index: number
opacity: number
isCulled: boolean
isInViewport: boolean
}[]
References
root
Public Readonly Property
The root state of the statechart.
Signature
readonly root: RootState
References
scribble
Public Readonly Property
Signature
get scribble(): null | TLScribble
References
selectedIds
Public Readonly Property
The current selected ids.
Signature
get selectedIds(): TLShapeId[]
References
selectedIdsSet
Public Readonly Property
The current selected ids as a set
Signature
get selectedIdsSet(): ReadonlySet<TLShapeId>
References
selectedPageBounds
Public Readonly Property
The current page bounds of all the selected shapes (Not the same thing as the page bounds of the selection bounding box when the selection has been rotated)
Signature
get selectedPageBounds(): Box2d | null
References
selectedShapes
Public Readonly Property
An array containing all of the currently selected shapes.
Example
app.selectedShapes
Signature
get selectedShapes(): import('@tldraw/tlschema').TLBaseShape<any, any>[]
References
selectionBounds
Public Readonly Property
Signature
get selectionBounds(): Box2d | undefined
References
selectionPageCenter
Public Readonly Property
Signature
get selectionPageCenter(): null | Vec2d
References
selectionRotation
Public Readonly Property
The rotation of the selection bounding box.
Signature
get selectionRotation(): number
shapeIds
Public Readonly Property
An array of all of the shapes on the current page.
Signature
get shapeIds(): Set<TLShapeId>
References
shapesArray
Public Readonly Property
An array containing all of the shapes in the current page.
Example
app.shapesArray
Signature
get shapesArray(): TLShape[]
References
shapeUtils
Public Property
A map of shape utility classes (TLShapeUtils) by shape type.
Signature
shapeUtils: {
readonly [K in string]?: TLShapeUtil<TLUnknownShape>
}
References
snaps
Public Readonly Property
A manager for the app's snapping feature.
Signature
readonly snaps: SnapManager
References
sortedShapesArray
Public Readonly Property
An array containing all of the shapes in the current page, sorted in z-index order (accounting for nested shapes): e.g. A, B, BA, BB, C.
Example
app.sortedShapesArray
Signature
get sortedShapesArray(): TLShape[]
References
startFollowingUser
Public Property
Start viewport-following a user.
Parameters
Name | Description |
---|---|
| The id of the user to follow. |
Signature
startFollowingUser: (userId: TLUserId) => this | undefined
References
stopFollowingUser
Public Property
Stop viewport-following a user.
Signature
stopFollowingUser: () => this
store
Public Readonly Property
The editor's store
Signature
readonly store: TLStore
References
styles
Public Static Property
The app's set of styles.
Signature
static styles: import('@tldraw/tlschema').TLStyleCollections
References
textMeasure
Public Property
A helper for measuring text.
Signature
textMeasure: TextManager
References
updateUserPresence
Public Property
Signature
updateUserPresence: ({
cursor,
color,
viewportPageBounds,
}?: {
cursor?: undefined | Vec2dModel
color?: string | undefined
viewportPageBounds?: Box2dModel | undefined
}) => void
References
user
Public Readonly Property
The current user state.
Signature
get user(): TLUser
References
userDocumentSettings
Public Readonly Property
Signature
get userDocumentSettings(): TLUserDocument
References
userId
Public Readonly Property
The editor's userId (defined in its store.props).
Example
const userId = app.userId
Signature
get userId(): TLUserId
References
userPresence
Public Readonly Property
Signature
get userPresence(): import('@tldraw/tlschema').TLUserPresence | undefined
References
userSettings
Public Readonly Property
The user's global settings.
Signature
get userSettings(): TLUser
References
viewportPageBounds
Public Readonly Property
The current viewport in page space.
Signature
get viewportPageBounds(): Box2d
References
viewportPageCenter
Public Readonly Property
The center of the viewport in page space.
Signature
get viewportPageCenter(): Vec2d
References
viewportScreenBounds
Public Readonly Property
The bounds of the editor's viewport in screen space.
Signature
get viewportScreenBounds(): Box2d
References
viewportScreenCenter
Public Readonly Property
The center of the editor's viewport in screen space.
Signature
get viewportScreenCenter(): Vec2d
References
zoomBrush
Public Readonly Property
Signature
get zoomBrush(): Box2dModel | null
References
zoomLevel
Public Readonly Property
The current camera zoom level.
Signature
get zoomLevel(): number
Methods
alignShapes()
Public Method
Align shape positions.
Example
app.alignShapes('left')
app.alignShapes('left', ['box1', 'box2'])
Parameters
Name | Description |
---|---|
|
The align operation to apply. |
(optional) |
The ids of the shapes to align. Defaults to selected shapes. |
Returns
this
References
animateCamera()
Public Method
Animate the camera.
Example
app.animateCamera(0, 0)
app.animateCamera(0, 0, 1)
app.animateCamera(0, 0, 1, { duration: 1000, easing: (t) => t * t })
Parameters
Name | Description |
---|---|
|
The camera's x position. |
|
The camera's y position. |
(optional) |
The camera's z position. Defaults to the current zoom. |
(optional) |
Options for the animation. |
Returns
this
References
animateShapes()
Public Method
Animate shapes.
Example
app.animateShapes([{ id: 'box1', type: 'box', x: 100, y: 100 }])
Parameters
Name | Description |
---|---|
|
The shape partials to update. |
(optional) |
|
Returns
this
References
animateToShape()
Public Method
Parameters
Name | Description |
---|---|
|
|
(optional) |
|
Returns
this
References
bail()
Public Method
Clear all marks in the undo stack back to the next mark.
Example
app.bail()
Parameters
None
Returns
this
bailToMark()
Public Method
Clear all marks in the undo stack back to the mark with the provided mark id.
Example
app.bailToMark('creating')
Parameters
Name | Description |
---|---|
|
|
Returns
this
batch()
Public Method
Run a function in a batch, which will be undone/redone as a single action.
Example
app.batch(() => {
app.selectAll()
app.deleteShapes()
app.createShapes(myShapes)
app.selectNone()
})
app.undo() // will undo all of the above
Parameters
Name | Description |
---|---|
|
|
Returns
this
blur()
Public Method
Blur the app, cancelling any interaction state.
Example
app.blur()
Parameters
None
Returns
this
bringForward()
Public Method
Bring shapes forward in the page's object list.
Example
app.bringForward()
app.bringForward(['id1', 'id2'])
Parameters
Name | Description |
---|---|
(optional) |
The ids of the shapes to move. Defaults to the ids of the selected shapes. |
Returns
this
References
bringToFront()
Public Method
Bring shapes to the front of the page's object list.
Example
app.bringToFront()
app.bringToFront(['id1', 'id2'])
Parameters
Name | Description |
---|---|
(optional) |
The ids of the shapes to move. Defaults to the ids of the selected shapes. |
Returns
this
References
cancel()
Public Method
Dispatch a cancel event.
Example
app.cancel()
Parameters
None
Returns
this
cancelDoubleClick()
Public Method
Prevent a double click event from firing the next time the user clicks
Parameters
None
Returns
void
centerOnPoint()
Public Method
Center the camera on a point (in page space).
Example
app.centerOnPoint(100, 100)
Parameters
Name | Description |
---|---|
|
The x position of the point. |
|
The y position of the point. |
(optional) |
The options for an animation. |
Returns
this
References
complete()
Public Method
Dispatch a complete event.
Example
app.complete()
Parameters
None
Returns
this
createAssets()
Public Method
Create one or more assets.
Example
app.createAssets([...myAssets])
Parameters
Name | Description |
---|---|
|
The assets to create. |
Returns
this
References
createPage()
Public Method
Create a page.
Example
app.createPage('New Page')
app.createPage('New Page', 'page1')
Parameters
Name | Description |
---|---|
|
The new page's title. |
(optional) |
The new page's id. |
(optional) |
|
Returns
this
References
createShapeId()
Public Method
Get a unique id for a shape.
Example
app.createShapeId()
app.createShapeId('box1')
Parameters
Name | Description |
---|---|
(optional) |
The id to use. |
Returns
TLShapeId
References
createShapes()
Public Method
Create shapes.
Example
app.createShapes([{ id: 'box1', type: 'box' }])
Parameters
Name | Description |
---|---|
|
The shape partials to create. |
(optional) |
Whether to select the created shapes. Defaults to false. |
Returns
this
References
deleteAssets()
Public Method
Delete one or more assets.
Example
app.deleteAssets(['asset1', 'asset2'])
Parameters
Name | Description |
---|---|
|
The assets to delete. |
Returns
this
References
deletePage()
Public Method
Delete a page.
Example
app.deletePage('page1')
Parameters
Name | Description |
---|---|
|
The id of the page to delete. |
Returns
void
References
deleteShapes()
Public Method
Delete shapes.
Example
app.deleteShapes()
app.deleteShapes(['box1', 'box2'])
Parameters
Name | Description |
---|---|
(optional) |
The ids of the shapes to delete. Defaults to the selected shapes. |
Returns
this
References
deselect()
Public Method
Remove a shpae from the existing set of selected shapes.
Example
app.deselect(shape.id)
Parameters
Name | Description |
---|---|
|
|
Returns
this
References
dispose()
Public Method
Dispose the app.
Parameters
None
Returns
void
distributeShapes()
Public Method
Distribute shape positions.
Example
app.distributeShapes('left')
app.distributeShapes('left', ['box1', 'box2'])
Parameters
Name | Description |
---|---|
|
Whether to distribute shapes horizontally or vertically. |
(optional) |
The ids of the shapes to distribute. Defaults to selected shapes. |
Returns
this
References
duplicatePage()
Public Method
Parameters
Name | Description |
---|---|
(optional) |
|
(optional) |
|
Returns
void
References
duplicateShapes()
Public Method
Duplicate shapes.
Example
app.duplicateShapes()
app.duplicateShapes(['id1', 'id2'])
app.duplicateShapes(['id1', 'id2'], { x: 8, y: 8 })
Parameters
Name | Description |
---|---|
(optional) |
The ids of the shapes to duplicate. Defaults to the ids of the selected shapes. |
(optional) |
The offset (in pixels) to apply to the duplicated shapes. |
Returns
this
References
findAncestor()
Public Method
Find the first ancestor matching the given predicate
Example
const ancestor = app.findAncestor(myShape)
Parameters
Name | Description |
---|---|
|
The shape to check the ancestors for. |
|
|
Returns
TLShape | undefined
References
findCommonAncestor()
Public Method
Get the common ancestor of two or more shapes that matches a predicate.
Parameters
Name | Description |
---|---|
|
The shapes to check. |
(optional) |
The predicate to match. |
Returns
TLShapeId | undefined
References
flipShapes()
Public Method
Flip shape positions.
Example
app.flipShapes('horizontal')
app.flipShapes('horizontal', ['box1', 'box2'])
Parameters
Name | Description |
---|---|
|
Whether to flip horizontally or vertically. |
(optional) |
The ids of the shapes to flip. Defaults to selected shapes. |
Returns
this
References
focus()
Public Method
Focus the app.
Example
app.focus()
Parameters
None
Returns
this
getAncestors()
Public Method
Get the ancestors of a shape.
Example
const ancestors = app.getAncestors(myShape)
Parameters
Name | Description |
---|---|
|
The shape to get the ancestors for. |
(optional) |
|
Returns
TLShape[]
References
getAncestorsById()
Public Method
Get the ancestors of a shape by its id.
Example
const ancestors = app.getAncestorsById(myShape)
Parameters
Name | Description |
---|---|
|
The id of the shape to get the ancestors for. |
(optional) |
|
Returns
TLShape[]
References
getArrowsBoundTo()
Public Method
GetArrowsBoundTo
Parameters
Name | Description |
---|---|
|
|
Returns
{
arrowId: TLShapeId
handleId: 'end' | 'start'
}[]
References
getAssetById()
Public Method
Get an asset by its id.
Example
app.getAssetById('asset1')
Parameters
Name | Description |
---|---|
|
The id of the asset. |
Returns
TLAsset | undefined
References
getAssetBySrc()
Public Method
Get an asset by its src property.
Example
app.getAssetBySource('https://example.com/image.png')
Parameters
Name | Description |
---|---|
|
The source value of the asset. |
Returns
| import('@tldraw/tlschema').TLBookmarkAsset
| TLImageAsset
| TLVideoAsset
| undefined
References
TLBookmarkAsset, TLImageAsset, TLVideoAsset
getBounds()
Public Method
Get the local bounds of a shape.
Example
app.getBounds(myShape)
Parameters
Name | Description |
---|---|
|
The shape to get the bounds for. |
Returns
Box2d
References
getBoundsById()
Public Method
Get the local bounds of a shape by its id.
Example
app.getBoundsById(myShape)
Parameters
Name | Description |
---|---|
|
The id of the shape to get the bounds for. |
Returns
Box2d | undefined
References
getClipPathById()
Public Method
Get the clip path for a shape.
Example
const clipPath = app.getClipPathById(shape.id)
Parameters
Name | Description |
---|---|
|
The shape id. |
Returns
string | undefined
The clip path or undefined.
References
getContent()
Public Method
Parameters
Name | Description |
---|---|
(optional) |
|
Returns
TLClipboardModel | undefined
References
getCssColor()
Public Method
Get the CSS color value for a given color id.
Example
app.getCssColor('red')
Parameters
Name | Description |
---|---|
|
The id of the color to get. |
Returns
string
References
getDeltaInParentSpace()
Public Method
Convert a delta in page space to a delta in the parent space of a shape.
Example
app.getDeltaInParentSpace(myShape, { x: 100, y: 100 })
Parameters
Name | Description |
---|---|
|
The shape to get the delta in the parent space of. |
|
The page delta to convert. |
Returns
Vec2d
References
getDeltaInShapeSpace()
Public Method
Convert a delta in page space to a delta in the local space of a shape.
Example
app.getDeltaInShapeSpace(myShape, { x: 100, y: 100 })
Parameters
Name | Description |
---|---|
|
The shape to get the delta in the local space of. |
|
The page delta to convert. |
Returns
Vec2d
References
getDroppingShape()
Public Method
Parameters
Name | Description |
---|---|
|
|
(optional) |
|
Returns
TLUnknownShape | undefined
References
VecLike, TLShape, TLUnknownShape
getHighestIndexForParent()
Public Method
Parameters
Name | Description |
---|---|
|
|
Returns
string
References
getMaskedPageBounds()
Public Method
Get the page (or absolute) bounds of a shape, incorporating any masks. For example, if the shape were the child of a frame and was half way out of the frame, the bounds would be the half of the shape that was in the frame.
Example
app.getMaskedPageBounds(myShape)
Parameters
Name | Description |
---|---|
|
The shape to get the masked bounds for. |
Returns
Box2d | undefined
References
getMaskedPageBoundsById()
Public Method
Get the page (or absolute) bounds of a shape by its id, incorporating any masks. For example, if the shape were the child of a frame and was half way out of the frame, the bounds would be the half of the shape that was in the frame.
Example
app.getMaskedPageBoundsById(myShape)
Parameters
Name | Description |
---|---|
|
The id of the shape to get the masked page bounds for. |
Returns
Box2d | undefined
References
getOutermostSelectableShape()
Public Method
Parameters
Name | Description |
---|---|
|
|
(optional) |
|
Returns
TLShape
References
getOutline()
Public Method
Get the local outline of a shape.
Example
app.getOutline(myShape)
Parameters
Name | Description |
---|---|
|
The shape to get the outline for. |
Returns
Vec2dModel[]
References
getOutlineById()
Public Method
Get the local outline of a shape.
Example
app.getOutlineById(myShape)
Parameters
Name | Description |
---|---|
|
The shape id to get the outline for. |
Returns
Vec2dModel[]
References
getPageBounds()
Public Method
Get the page (or absolute) bounds of a shape.
Example
app.getPageBounds(myShape)
Parameters
Name | Description |
---|---|
|
The shape to get the bounds for. |
Returns
Box2d | undefined
References
getPageBoundsById()
Public Method
Get the page (or absolute) bounds of a shape by its id.
Example
app.getPageBoundsById(myShape)
Parameters
Name | Description |
---|---|
|
The id of the shape to get the page bounds for. |
Returns
Box2d | undefined
References
getPageById()
Public Method
Get a page by its ID.
Example
app.getPageById(myPage.id)
Parameters
Name | Description |
---|---|
|
|
Returns
TLPage | undefined
References
getPageCenter()
Public Method
Get the page point (or absolute point) of a shape.
Example
app.getPagePoint(myShape)
Parameters
Name | Description |
---|---|
|
The shape to get the page point for. |
Returns
null | Vec2d
References
getPageCenterById()
Public Method
Get the page point (or absolute point) of a shape by its id.
Example
app.getPagePoint(myShape)
Parameters
Name | Description |
---|---|
|
The shape id to get the page point for. |
Returns
null | Vec2d
References
getPageCorners()
Public Method
Get the corners of a shape in page space.
Example
const corners = app.getPageCorners(myShape)
Parameters
Name | Description |
---|---|
|
The shape to get the corners for. |
Returns
Vec2d[]
References
getPageInfoById()
Public Method
Get a page by its ID.
Example
app.getPageById(myPage.id)
Parameters
Name | Description |
---|---|
|
|
Returns
TLPage | undefined
References
getPageMaskById()
Public Method
Get the page mask for a shape.
Example
const pageMask = app.getPageMaskById(shape.id)
Parameters
Name | Description |
---|---|
|
The id of the shape to get the page mask for. |
Returns
undefined | VecLike[]
The page mask for the shape.
References
getPagePointById()
Public Method
Get the page point (or absolute point) of a shape.
Example
app.getPagePoint(myShape)
Parameters
Name | Description |
---|---|
|
|
Returns
undefined | Vec2d
References
getPageRotation()
Public Method
Get the page rotation (or absolute rotation) of a shape.
Example
app.getPageRotation(myShape)
Parameters
Name | Description |
---|---|
|
The shape to get the page rotation for. |
Returns
number
References
getPageRotationById()
Public Method
Get the page rotation (or absolute rotation) of a shape by its id.
Parameters
Name | Description |
---|---|
|
The id of the shape to get the page rotation for. |
Returns
number
References
getPageStateByPageId()
Public Method
Get a page state by its id.
Example
app.getPageStateByPageId('page1')
Parameters
Name | Description |
---|---|
|
|
Returns
TLInstancePageState | undefined
References
getPageTransform()
Public Method
Get the page transform (or absolute transform) of a shape.
Example
app.getPageTransform(myShape)
Parameters
Name | Description |
---|---|
|
The shape to get the page transform for. |
Returns
Matrix2d | undefined
References
getPageTransformById()
Public Method
Get the page transform (or absolute transform) of a shape by its id.
Example
app.getPageTransformById(myShape)
Parameters
Name | Description |
---|---|
|
The if of the shape to get the page transform for. |
Returns
Matrix2d | undefined
References
getParentIdForNewShapeAtPoint()
Public Method
Parameters
Name | Description |
---|---|
|
|
|
|
Returns
TLPageId | TLShapeId
References
VecLike, TLShapeType, TLPageId, TLShapeId
getParentPageId()
Public Method
Get the id of the containing page for a given shape.
Parameters
Name | Description |
---|---|
(optional) |
|
Returns
TLPageId | undefined
References
getParentShape()
Public Method
Get the parent shape for a given shape. Returns undefined if the shape is the direct child of the page.
Example
app.getParentShape(myShape)
Parameters
Name | Description |
---|---|
(optional) |
|
Returns
TLShape | undefined
References
getParentsMappedToChildren()
Public Method
For a given set of ids, get a map containing the ids of their parents and the children of those parents.
Example
app.getParentsMappedToChildren(['id1', 'id2', 'id3'])
Parameters
Name | Description |
---|---|
|
The ids to get the parents and children of. |
Returns
Map<TLParentId, Set<TLShape>>
References
TLShapeId, Map, TLParentId, Set, TLShape
getParentTransform()
Public Method
Get the local transform of a shape's parent as a matrix model.
Example
app.getParentTransform(myShape)
Parameters
Name | Description |
---|---|
|
The shape to get the parent transform for. |
Returns
Matrix2d
References
getPointInParentSpace()
Public Method
Convert a delta in page space to a point in the local space of a shape. For example, if a shape's page point were { x: 100, y: 100 }
, a page point at { x: 110, y: 110 }
would be at { x: 10, y: 10 }
in the shape's local space.
Example
app.getPointInShapeSpace(myShape.id, { x: 100, y: 100 })
Parameters
Name | Description |
---|---|
|
|
|
The page point to get in the local space of the shape. |
Returns
Vec2d
References
getPointInShapeSpace()
Public Method
Convert a point in page space to a point in the local space of a shape. For example, if a shape's page point were { x: 100, y: 100 }
, a page point at { x: 110, y: 110 }
would be at { x: 10, y: 10 }
in the shape's local space.
Example
app.getPointInShapeSpace(myShape, { x: 100, y: 100 })
Parameters
Name | Description |
---|---|
|
The shape to get the point in the local space of. |
|
The page point to get in the local space of the shape. |
Returns
Vec2d
References
getShapeById()
Public Method
Get a shape by its id.
Example
app.getShapeById('box1')
Parameters
Name | Description |
---|---|
|
The id of the shape to get. |
Returns
T | undefined
References
getShapesAndDescendantsInOrder()
Public Method
Parameters
Name | Description |
---|---|
|
|
Returns
TLShape[]
References
getShapesAtPoint()
Public Method
Get the shapes, if any, at a given page point.
Example
app.getShapesAtPoint({ x: 100, y: 100 })
Parameters
Name | Description |
---|---|
|
The page point to test. |
Returns
TLShape[]
References
getShapesInPage()
Public Method
Get shapes on a page.
Parameters
Name | Description |
---|---|
|
|
Returns
TLShape[]
References
getShapeUtil()
Public Method
Get a shape util for a given shape or shape type.
Example
app.getShapeUtil(myBoxShape)
Parameters
Name | Description |
---|---|
|
|
Returns
TLShapeUtil<T>
References
getShapeUtilByDef()
Public Method
Get a shape util by its definition.
Example
app.getShapeUtilByDef(TLDrawShapeDef)
Parameters
Name | Description |
---|---|
|
The shape definition. |
Returns
ReturnType<Def['createShapeUtils']>
References
getSortedChildIds()
Public Method
Get an array of all the children of a shape.
Example
app.getSortedChildIds('frame1')
Parameters
Name | Description |
---|---|
|
The id of the parent shape. |
Returns
TLShapeId[]
References
getStateDescendant()
Public Method
Get a descendant by its path.
Example
state.getStateDescendant('select')
state.getStateDescendant('select.brushing')
Parameters
Name | Description |
---|---|
|
The descendant's path of state ids, separated by periods. |
Returns
StateNode | undefined
References
getStrokeWidth()
Public Method
Get the stroke width value for a given size id.
Example
app.getStrokeWidth('m')
Parameters
Name | Description |
---|---|
|
The id of the size to get. |
Returns
number
References
getSvg()
Public Method
Parameters
Name | Description |
---|---|
(optional) |
|
(optional) |
|
Returns
Promise<SVGSVGElement | undefined>
References
TLShapeId, Partial, React.SVGAttributes, SVGSVGElement, Promise
getTransform()
Public Method
Get the local transform for a shape as a matrix model. This transform reflects both its translation (x, y) from from either its parent's top left corner, if the shape's parent is another shape, or else from the 0,0 of the page, if the shape's parent is the page; and the shape's rotation.
Example
app.getTransform(myShape)
Parameters
Name | Description |
---|---|
|
The shape to get the local transform for. |
Returns
Matrix2d
References
groupShapes()
Public Method
Parameters
Name | Description |
---|---|
(optional) |
|
(optional) |
|
Returns
this
References
hasAncestor()
Public Method
Returns true if the the given shape has the given ancestor
Parameters
Name | Description |
---|---|
|
|
|
|
Returns
boolean
References
interrupt()
Public Method
Dispatch an interrupt event.
Example
app.interrupt()
Parameters
None
Returns
this
isIn()
Public Method
Get whether a certain tool (or other state node) is currently active.
Example
app.isIn('select')
app.isIn('select.brushing')
Parameters
Name | Description |
---|---|
|
The path of active states, separated by periods. |
Returns
boolean
isInAny()
Public Method
Get whether the state node is in any of the given active paths.
Example
state.isInAny('select', 'erase')
state.isInAny('select.brushing', 'erase.idle')
Parameters
Name | Description |
---|---|
|
|
Returns
boolean
isPointInShape()
Public Method
Test whether a point (in page space) will will a shape. This method takes into account masks, such as when a shape is the child of a frame and is partially clipped by the frame.
Example
app.isPointInShape({ x: 100, y: 100 }, myShape)
Parameters
Name | Description |
---|---|
|
The page point to test. |
|
The shape to test against. |
Returns
boolean
References
isSelected()
Public Method
Determine whether or not a shape is selected
Example
app.isSelected('id1')
Parameters
Name | Description |
---|---|
|
The id of the shape to check. |
Returns
boolean
References
isShapeInPage()
Public Method
Get whether the given shape is the descendant of the given page.
Example
app.isShapeInPage(myShape)
app.isShapeInPage(myShape, 'page1')
Parameters
Name | Description |
---|---|
|
The shape to check. |
(optional) |
The id of the page to check against. Defaults to the current page. |
Returns
boolean
References
isShapeInViewport()
Public Method
Check whether a shape is within the bounds of the current viewport.
Parameters
Name | Description |
---|---|
|
The id of the shape to check. |
Returns
boolean
References
isWithinSelection()
Public Method
Determine whether a not a shape is within the current selection. A shape is within the selection if it or any of its parents is selected.
Parameters
Name | Description |
---|---|
|
The id of the shape to check. |
Returns
boolean
References
lockShapes()
Public Method
Parameters
Name | Description |
---|---|
(optional) |
|
Returns
this
References
mark()
Public Method
Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear any redos.
Example
app.mark()
app.mark('flip shapes')
Parameters
Name | Description |
---|---|
(optional) |
The reason for the mark. |
(optional) |
Whether to stop at the mark when undoing. |
(optional) |
Whether to stop at the mark when redoing. |
Returns
string
moveShapesToPage()
Public Method
Move shapes to page.
Example
app.moveShapesToPage(['box1', 'box2'], 'page1')
Parameters
Name | Description |
---|---|
|
The ids of the shapes to move. |
|
The id of the page where the shapes will be moved. |
Returns
this
References
nudgeShapes()
Public Method
Move shapes by a delta.
Example
app.nudgeShapes(['box1', 'box2'], { x: 0, y: 1 })
app.nudgeShapes(['box1', 'box2'], { x: 0, y: 1 }, true)
Parameters
Name | Description |
---|---|
|
The ids of the shapes to move. |
|
The direction in which to move the shapes. |
(optional) |
Whether this is a major nudge, e.g. a shift + arrow nudge. |
(optional) |
|
Returns
this
References
onCreateAssetFromFile()
Public Method
A callback fired when a file is converted to an asset. This callback should return the asset partial.
Example
app.onCreateAssetFromFile(myFile)
Parameters
Name | Description |
---|---|
|
The file to upload. |
Returns
Promise<TLAsset>
References
onCreateBookmarkFromUrl()
Public Method
A callback fired when a URL is converted to a bookmark. This callback should return the metadata for the bookmark.
Example
app.onCreateBookmarkFromUrl(url, id)
Parameters
Name | Description |
---|---|
|
The url that was created. |
Returns
Promise<{
image: string
title: string
description: string
}>
References
packShapes()
Public Method
Pack shapes into a grid centered on their current position. Based on potpack (https://github.com/mapbox/potpack)
Parameters
Name | Description |
---|---|
(optional) |
The ids of the shapes to pack. Defaults to selected shapes. |
(optional) |
The padding to apply to the packed shapes. |
Returns
this
References
pageToScreen()
Public Method
Convert a point in page space to a point in screen space.
Example
app.pageToScreen(100, 100)
Parameters
Name | Description |
---|---|
|
The x coordinate of the point in screen space. |
|
The y coordinate of the point in screen space. |
(optional) |
|
(optional) |
The camera to use. Defaults to the current camera. |
Returns
{
x: number
y: number
z: number
}
References
pan()
Public Method
Pan the camera.
Example
app.pan(100, 100)
app.pan(100, 100, { duration: 1000 })
Parameters
Name | Description |
---|---|
|
The amount to pan on the x axis. |
|
The amount to pan on the y axis. |
(optional) |
The animation options |
Returns
this
References
panZoomIntoView()
Public Method
Pan or pan/zoom the selected ids into view. This method tries to not change the zoom if possible.
Parameters
Name | Description |
---|---|
|
The ids of the shapes to pan and zoom into view. |
(optional) |
The options for an animation. |
Returns
this
References
popFocusLayer()
Public Method
Parameters
None
Returns
this
putContent()
Public Method
Parameters
Name | Description |
---|---|
|
|
(optional) |
|
Returns
this
References
redo()
Public Method
Redo to the next mark.
Example
app.redo()
Parameters
None
Returns
this
renamePage()
Public Method
Rename a page.
Example
app.renamePage('page1', 'My Page')
Parameters
Name | Description |
---|---|
|
The id of the page to rename. |
|
The new name. |
(optional) |
|
Returns
this
References
reorderShapes()
Public Method
Reorder shapes.
Parameters
Name | Description |
---|---|
|
The operation to perform. |
|
The ids to reorder. |
Returns
this
References
reparentShapesById()
Public Method
Reparent shapes to a new parent. This operation preserves the shape's current page positions / rotations.
Example
app.reparentShapesById(['box1', 'box2'], 'frame1')
Parameters
Name | Description |
---|---|
|
The ids of the shapes to reparent. |
|
The id of the new parent shape. |
(optional) |
The index to insert the children. |
Returns
this
References
replaceStoreContentsWithRecordsForOtherDocument()
Public Method
Parameters
Name | Description |
---|---|
|
|
Returns
void
References
resetZoom()
Public Method
Set the zoom back to 100%.
Example
app.resetZoom()
Parameters
Name | Description |
---|---|
(optional) |
|
(optional) |
The options for an animation. |
Returns
this
References
resizeShape()
Public Method
Parameters
Name | Description |
---|---|
|
|
|
|
(optional) |
|
Returns
this
References
TLShapeId, VecLike, Box2d, TLShape, MatLike, TLResizeHandle, TLResizeMode
rotateShapesBy()
Public Method
Rotate shapes by a delta in radians.
Example
app.rotateShapesBy(['box1', 'box2'], Math.PI)
app.rotateShapesBy(['box1', 'box2'], Math.PI / 2)
Parameters
Name | Description |
---|---|
|
The ids of the shapes to move. |
|
The delta in radians to apply to the selection rotation. |
Returns
this
References
screenToPage()
Public Method
Convert a point in screen space to a point in page space.
Example
app.screenToPage(100, 100)
Parameters
Name | Description |
---|---|
|
The x coordinate of the point in screen space. |
|
The y coordinate of the point in screen space. |
(optional) |
|
(optional) |
The camera to use. Defaults to the current camera. |
Returns
{
x: number
y: number
z: number
}
References
select()
Public Method
Select one or more shapes.
Example
app.select('id1')
app.select('id1', 'id2')
Parameters
Name | Description |
---|---|
|
The ids to select. |
Returns
this
References
selectAll()
Public Method
Select all direct children of the current page.
Example
app.selectAll()
Parameters
None
Returns
this
selectNone()
Public Method
Clear the selection.
Example
app.selectNone()
Parameters
None
Returns
this
sendBackward()
Public Method
Send shapes backward in the page's object list.
Example
app.sendBackward()
app.sendBackward(['id1', 'id2'])
Parameters
Name | Description |
---|---|
(optional) |
The ids of the shapes to move. Defaults to the ids of the selected shapes. |
Returns
this
References
sendToBack()
Public Method
Send shapes to the back of the page's object list.
Example
app.sendToBack()
app.sendToBack(['id1', 'id2'])
Parameters
Name | Description |
---|---|
(optional) |
The ids of the shapes to move. Defaults to the ids of the selected shapes. |
Returns
this
References
setBrush()
Public Method
Set the current brush.
Example
app.setBrush({ x: 0, y: 0, w: 100, h: 100 })
app.setBrush() // Clears the brush
Parameters
Name | Description |
---|---|
(optional) |
The brush box model to set, or null for no brush model. |
Returns
this
References
setCamera()
Public Method
Set the current camera.
Example
app.setCamera(0, 0)
app.setCamera(0, 0, 1)
Parameters
Name | Description |
---|---|
|
The camera's x position. |
|
The camera's y position. |
(optional) |
The camera's z position. Defaults to the current zoom. |
(optional) |
|
Returns
this
References
setCroppingId()
Public Method
Parameters
Name | Description |
---|---|
|
|
Returns
this
References
setCurrentPageId()
Public Method
Set the current page.
Example
app.setCurrentPageId('page1')
Parameters
Name | Description |
---|---|
|
The id of the page to set as the current page. |
(optional) |
|
Returns
this
References
setCursor()
Public Method
Set the current cursor.
Example
app.setCursor({ type: 'default' })
app.setCursor({ type: 'default', rotation: Math.PI / 2, color: 'red' })
Parameters
Name | Description |
---|---|
|
A partial of the cursor object. |
Returns
this
References
setDarkMode()
Public Method
Parameters
Name | Description |
---|---|
|
|
Returns
void
setEditingId()
Public Method
Set the current editing id.
Parameters
Name | Description |
---|---|
|
The id of the shape to edit or null to clear the editing id. |
Returns
this
References
setErasingIds()
Public Method
Set the current erasing shapes.
Example
app.setErasingIds(['box1', 'box2'])
app.setErasingIds() // Clears the erasing set
Parameters
Name | Description |
---|---|
(optional) |
The ids of shapes to set as erasing. |
Returns
this
References
setFocusLayer()
Public Method
Set the focus layer to the given shape id.
Parameters
Name | Description |
---|---|
|
The next focus layer id or null to reset the focus layer to the page |
Returns
this
References
setGridMode()
Public Method
Parameters
Name | Description |
---|---|
|
|
Returns
void
setHintingIds()
Public Method
Set the hinted shape ids.
Parameters
Name | Description |
---|---|
|
The ids to set as hinted. |
Returns
this
References
setHoveredId()
Public Method
Set the current hovered shape.
Example
app.setHoveredId('box1')
app.setHoveredId() // Clears the hovered shape.
Parameters
Name | Description |
---|---|
(optional) |
The id of the page to set as the current page |
Returns
this
References
setInstancePageState()
Public Method
Update a page state.
Example
app.setInstancePageState({ id: 'page1', editingId: 'shape:123' })
app.setInstancePageState({ id: 'page1', editingId: 'shape:123' }, true)
Parameters
Name | Description |
---|---|
|
The partial of the page state object containing the changes. |
(optional) |
Whether the command is ephemeral. |
Returns
void
References
setPenMode()
Public Method
Parameters
Name | Description |
---|---|
|
|
Returns
void
setProp()
Public Method
Set the current props (generally styles).
Example
app.setProp('color', 'red')
app.setProp('color', 'red', true)
Parameters
Name | Description |
---|---|
|
The key to set. |
|
The value to set. |
(optional) |
Whether the style is ephemeral. Defaults to false. |
(optional) |
|
Returns
this
References
setReadOnly()
Public Method
Parameters
Name | Description |
---|---|
|
|
Returns
void
setScribble()
Public Method
Set the current scribble.
Example
app.setScribble(nextScribble)
app.setScribble() // clears the scribble
Parameters
Name | Description |
---|---|
(optional) |
The new scribble object. |
Returns
this
References
setSelectedIds()
Public Method
Select one or more shapes.
Example
app.setSelectedIds(['id1'])
app.setSelectedIds(['id1', 'id2'])
Parameters
Name | Description |
---|---|
|
The ids to select. |
(optional) |
Whether the change should create a new history entry or combine with the previous (if the previous is the same type). |
Returns
this
References
setSelectedTool()
Public Method
Set the selected tool.
Example
app.setSelectedTool('hand')
app.setSelectedTool('hand', { date: Date.now() })
Parameters
Name | Description |
---|---|
|
The id of the tool to select. |
(optional) |
Arbitrary data to pass along into the transition. |
Returns
this
setZoomBrush()
Public Method
Set the current zoom brush.
Example
app.setZoomBrush({ x: 0, y: 0, w: 100, h: 100 })
app.setZoomBrush() // Clears the zoom
Parameters
Name | Description |
---|---|
(optional) |
The zoom box model to set, or null for no zoom model. |
Returns
this
References
slideCamera()
Public Method
Parameters
Name | Description |
---|---|
(optional) |
|
Returns
this
References
stackShapes()
Public Method
Stack shape.
Example
app.stackShapes('horizontal')
app.stackShapes('horizontal', ['box1', 'box2'])
app.stackShapes('horizontal', ['box1', 'box2'], 20)
Parameters
Name | Description |
---|---|
|
Whether to stack horizontally or vertically. |
(optional) |
The ids of the shapes to stack. Defaults to selected shapes. |
(optional) |
A specific gap to use when stacking. |
Returns
this
References
stopCameraAnimation()
Public Method
Stop the current camera animation, if any.
Parameters
None
Returns
this
stretchShapes()
Public Method
Stretch shape sizes and positions to fill their common bounding box.
Example
app.stretchShapes('horizontal')
app.stretchShapes('horizontal', ['box1', 'box2'])
Parameters
Name | Description |
---|---|
|
Whether to stretch shapes horizontally or vertically. |
(optional) |
The ids of the shapes to stretch. Defaults to selected shapes. |
Returns
this
References
undo()
Public Method
Undo to the last mark.
Example
app.undo()
Parameters
None
Returns
HistoryManager<this>
References
ungroupShapes()
Public Method
Parameters
Name | Description |
---|---|
(optional) |
|
Returns
this
References
updateAssets()
Public Method
Update one or more assets.
Example
app.updateAssets([{ id: 'asset1', name: 'New name' }])
Parameters
Name | Description |
---|---|
|
The assets to update. |
Returns
this
References
updateInstanceState()
Public Method
Set the current user tab state
Parameters
Name | Description |
---|---|
|
|
(optional) |
|
(optional) |
|
Returns
this
References
updatePage()
Public Method
Update a page.
Example
app.updatePage({ id: 'page2', name: 'Page 2' })
Parameters
Name | Description |
---|---|
|
The partial of the shape to update. |
(optional) |
|
Returns
this
References
updateShapes()
Public Method
Update shapes.
Example
app.updateShapes([{ id: 'box1', type: 'box', x: 100, y: 100 }])
Parameters
Name | Description |
---|---|
|
The shape partials to update. |
(optional) |
Whether the change is ephemeral. |
Returns
this
References
updateUser()
Public Method
Set user state. Always ephemeral for now.
Example
app.updateUser({ color: '#923433' })
Parameters
Name | Description |
---|---|
|
The partial of the user state object containing the changes. |
Returns
void
References
updateUserDocumentSettings()
Public Method
Update user document settings
Example
app.updateUserDocumentSettings({ isGridMode: true })
Parameters
Name | Description |
---|---|
|
|
(optional) |
|
Returns
this
References
updateViewportScreenBounds()
Public Method
Update the viewport. The viewport will measure the size and screen position of its container element. This should be done whenever the container's position on the screen changes.
Example
app.updateViewportScreenBounds()
Parameters
Name | Description |
---|---|
(optional) |
Whether to preserve the viewport page center as the viewport changes. (optional) |
Returns
this
visitDescendants()
Public Method
Run a visitor function for all descendants of a shape.
Example
app.visitDescendants('frame1', myCallback)
Parameters
Name | Description |
---|---|
|
The id of the parent shape. |
|
The visitor function. |
Returns
void
References
zoomIn()
Public Method
Zoom the camera in.
Example
app.zoomIn()
app.zoomIn(app.viewportScreenCenter, { duration: 120 })
app.zoomIn(app.inputs.currentScreenPoint, { duration: 120 })
Parameters
Name | Description |
---|---|
(optional) |
|
(optional) |
The options for an animation. |
Returns
this
References
zoomOut()
Public Method
Zoom the camera out.
Example
app.zoomOut()
app.zoomOut(app.viewportScreenCenter, { duration: 120 })
app.zoomOut(app.inputs.currentScreenPoint, { duration: 120 })
Parameters
Name | Description |
---|---|
(optional) |
|
(optional) |
The options for an animation. |
Returns
this
References
zoomToBounds()
Public Method
Zoom the camera to fit a bounding box (in page space).
Example
app.zoomToBounds(0, 0, 100, 100)
Parameters
Name | Description |
---|---|
|
The bounding box's x position. |
|
The bounding box's y position. |
|
The bounding box's width. |
|
The bounding box's height. |
(optional) |
The desired zoom level. Defaults to 0.1. |
(optional) |
|
Returns
this
References
zoomToFit()
Public Method
Zoom the camera to fit the current page's content in the viewport.
Example
app.zoomToFit()
Parameters
Name | Description |
---|---|
(optional) |
|
Returns
this
References
zoomToSelection()
Public Method
Zoom the camera to fit the current selection in the viewport.
Example
app.zoomToSelection()
Parameters
Name | Description |
---|---|
(optional) |
The options for an animation. |
Returns
this