Skip to content

CanvasViewCanvas

Unofficial

Main canvas controller that manages rendering, selection, drag, zoom, pan, nodes, and edges for the canvas view.

Import:

import type { CanvasViewCanvas } from '@obsidian-typings/obsidian-catalyst-latest';

Signature:

export interface CanvasViewCanvas

Properties

PropertyTypeDescription
appAppReference to the Obsidian app instance.
backgroundPatternElSVGPatternElementSVG pattern element used for rendering the canvas background grid.
canvasControlsElHTMLDivElementContainer element for canvas control buttons (zoom, undo/redo, etc.).
canvasElHTMLDivElementMain canvas container element.
canvasRectCanvasRectExExtended rectangle representing the canvas bounds.
cardMenuElHTMLDivElementContainer element for the card creation menu.
configCanvasViewConfigConfiguration settings for the canvas view.
dataCanvasViewDataSerialized canvas data containing nodes and edges.
dirtySet<unknown>Set of items that have been modified and need saving.
edgeContainerElSVGElementSVG container element for edge lines.
edgeEndContainerElSVGElementSVG container element for edge endpoint markers.
edgeFromMapOfSets<CanvasViewCanvasEdge, CanvasViewCanvasNode>Mapping of edges to their source nodes.
edgeIndexEdgeIndexSpatial index (R-tree) for efficient edge hit-testing.
edgesMap<string, CanvasViewCanvasEdge>Map of all edges on the canvas, keyed by edge ID.
edgeToMapOfSets<CanvasViewCanvasEdge, CanvasViewCanvasNode>Mapping of edges to their target nodes.
finishViewportAnimationbooleanWhether to finish the current viewport animation on the next frame.
framenumberCurrent animation frame request ID.
frameWinnullAnimation frame window reference, null when not animating.
gridSpacingnumberSpacing between grid lines in pixels.
historyCanvasViewHistoryUndo/redo history manager for canvas state.
isDraggingbooleanWhether the user is currently dragging on the canvas.
isHoldingSpacebooleanWhether the spacebar is currently held (for pan mode).
keysobjectMap of currently pressed keyboard keys.
lastEdgesInViewportSet<CanvasViewCanvasEdge>Set of edges that were visible in the viewport on the last render frame.
lastNodesInViewportSet<CanvasViewCanvasNode>Set of nodes that were visible in the viewport on the last render frame.
menuCanvasMenuContext menu and toolbar for the canvas.
movedSet<unknown>Set of items that have been moved and need re-indexing.
moverElHTMLDivElementElement used for dragging/moving the canvas viewport.
nodeIndexEdgeIndexSpatial index (R-tree) for efficient node hit-testing.
nodeInteractionLayerNodeInteractionLayerLayer handling user interactions with nodes (resize, connect, etc.).
nodesMap<string, CanvasViewCanvasNode>Map of all nodes on the canvas, keyed by node ID.
options?unknownOptional configuration options for the canvas.
pauseAnimationnumberCounter for pausing animation frames.
pointerPointCurrent pointer position in canvas coordinates.
pointerFramenumberAnimation frame request ID for pointer tracking.
pointerFrameWinnullPointer frame window reference, null when not tracking.
quickSettingsButtonHTMLDivElementButton element for opening the quick settings menu.
readonlybooleanWhether the canvas is in read-only mode.
redoBtnElHTMLDivElementButton element for the redo action.
requestPushHistoryDebouncer<[], unknown>Debounced function to push the current state to history.
requestUpdateFileOpenDebouncer<[], unknown>Debounced function to update the file open state.
scalenumberCurrent zoom scale factor of the canvas viewport.
screenshottingbooleanWhether the canvas is currently being screenshotted.
selectionSet<Selection>Set of currently selected nodes and edges.
selectionChangedbooleanWhether the selection has changed since the last update.
snapDistance?unknownDistance threshold for snapping behavior.
staleSelectionnullPreviously stale selection, null when selection is current.
txnumberTarget X translation for viewport animation.
tynumberTarget Y translation for viewport animation.
tZoomnumberTarget zoom level for viewport animation.
undoBtnElHTMLDivElementButton element for the undo action.
viewCanvasViewReference to the parent CanvasView.
viewportChangedbooleanWhether the viewport has changed since the last render frame.
wasAnimatingbooleanWhether the canvas was animating on the previous frame.
wrapperElHTMLDivElementOutermost wrapper element for the canvas.
xnumberCurrent X offset of the viewport in canvas coordinates.
ynumberCurrent Y offset of the viewport in canvas coordinates.
zIndexCounternumberCounter for assigning z-index values to nodes.
zoomnumberCurrent zoom level of the viewport.
zoomBreakpoint?unknownZoom level threshold for switching rendering detail levels.
zoomCenternullCenter point for zoom operations, null when not zooming.
zoomToFitQueuedbooleanWhether a zoom-to-fit operation is queued for the next frame.

Methods

MethodReturnsDescription
addEdge(arg1)unknownAdd an edge to the canvas.
addNode(arg1)unknownAdd a node to the canvas.
applyHistory(arg1)unknownApply a history state to restore the canvas to a previous state.
cancelFrame()unknownCancel the current pending animation frame.
canSnap(arg1)unknownCheck whether snapping is currently possible for the given context.
clear()unknownRemove all nodes and edges from the canvas.
clearSnapPoints()unknownClear all active snap point guides.
cloneData(arg1, arg2)unknownClone canvas data, creating duplicates of the specified items at the given offset.
createFileNode(arg1)unknownCreate a new file-type node on the canvas.
createFileNodes(arg1, arg2)unknownCreate multiple file-type nodes on the canvas.
createGroupNode(arg1)unknownCreate a new group node on the canvas.
createLinkNode(arg1)unknownCreate a new link/URL node on the canvas.
createPlaceholder()unknownCreate a placeholder node for drag-and-drop operations.
createTextNode(arg1)unknownCreate a new text node on the canvas.
deleteSelection()unknownDelete all currently selected nodes and edges.
deselect(arg1)unknownRemove an item from the current selection.
deselectAll()unknownClear the entire selection.
domFromPos(arg1)unknownConvert a canvas position to DOM pixel coordinates.
domPosFromClient(arg1)unknownConvert client (screen) coordinates to DOM pixel coordinates.
domPosFromEvt(arg1)unknownConvert a DOM event's position to DOM pixel coordinates.
dragTempNode(arg1, arg2, arg3)unknownHandle dragging a temporary node during creation.
endSnapPointRendering()unknownStop rendering snap point guide lines.
generateHDImage()Promise<unknown>Generate a high-definition image of the canvas.
getContainingNodes(arg1)unknownGet all nodes that contain the specified bounding box or point.
getData()unknownGet the serialized canvas data.
getEdgesForNode(arg1)unknownGet all edges connected to the specified node.
getIntersectingEdges(arg1)unknownGet all edges that intersect the specified bounding box.
getIntersectingNodes(arg1)unknownGet all nodes that intersect the specified bounding box.
getSelectionData(arg1)unknownGet serialized data for the current selection.
getSnapping(arg1, arg2, arg3, arg4)unknownCalculate snap alignment guides for the given position and dimensions.
getState()unknownGet the current viewport state (position, zoom).
getViewportBBox()unknownGet the bounding box of the current viewport in canvas coordinates.
getViewportNodes(arg1)unknownGet all nodes currently visible within the viewport.
getZIndex()unknownGet the next available z-index value.
handleCopy(arg1)unknownHandle a copy event for the current selection.
handleCut(arg1)unknownHandle a cut event for the current selection.
handleDragToSelect(arg1, arg2, arg3)unknownHandle drag-to-select (rubber band selection) interaction.
handleDragWithPan(arg1, arg2)unknownHandle drag interaction with viewport panning.
handleMoverPointerdown(arg1)unknownHandle pointer down event on the mover element.
handlePaste(arg1)unknownHandle a paste event to add items to the canvas.
handleSelectionDrag(arg1, arg2, arg3)unknownHandle dragging the current selection.
hitTestNode(arg1, arg2)unknownTest whether a point hits a specific node.
importData(arg1, arg2)unknownImport canvas data from an external source.
interactionHitTest(arg1)unknownPerform a hit test for interactive elements at the given position.
load()unknownLoad and initialize the canvas from saved data.
markDirty(arg1)unknownMark an item as dirty (needing to be saved).
markMoved(arg1)unknownMark an item as having been moved (needing re-indexing).
markViewportChanged()unknownMark the viewport as changed, triggering a re-render.
nudgeSelection(arg1, arg2)unknownNudge the current selection by the specified offset.
onContextMenu(arg1)unknownHandle context menu event on the canvas background.
onDoubleClick(arg1)unknownHandle double-click event on the canvas.
onGlobalKeydown(arg1)unknownHandle global keydown events.
onGlobalKeyup(arg1)unknownHandle global keyup events.
onKeydown(arg1)unknownHandle keydown events on the canvas.
onPointerdown(arg1)unknownHandle pointer down events on the canvas.
onPointermove(arg1)unknownHandle pointer move events on the canvas.
onPriorityPointerdown(arg1)unknownHandle priority pointer down events (processed before other handlers).
onResize()unknownHandle canvas container resize events.
onSelectionContextMenu(arg1)unknownHandle context menu event on the current selection.
onTouchdown(arg1)unknownHandle touch start events on the canvas.
onWheel(arg1)unknownHandle mouse wheel events for zooming or panning.
overrideHistory()unknownOverride the current history entry with the latest state.
panBy(arg1, arg2)unknownPan the viewport by the specified delta.
panIntoView(arg1, arg2)unknownPan the viewport so the specified bounding box is visible.
panTo(arg1, arg2)unknownPan the viewport to the specified position.
posCenter()unknownGet the center position of the current viewport.
posFromClient(arg1)unknownConvert client (screen) coordinates to canvas coordinates.
posFromDom(arg1)unknownConvert DOM pixel coordinates to canvas coordinates.
posFromEvt(arg1)unknownConvert a DOM event's position to canvas coordinates.
posInViewport(arg1)unknownCheck whether a position is within the current viewport.
pushHistory(arg1)unknownPush the current canvas state onto the undo history stack.
redo()unknownRedo the last undone action.
removeEdge(arg1)unknownRemove an edge from the canvas.
removeNode(arg1)unknownRemove a node from the canvas.
renderSnapPoints(arg1, arg2, arg3, arg4)unknownRender snap point guide lines for alignment.
requestFrame(arg1)unknownRequest an animation frame for rendering.
requestSave(arg1)unknownRequest saving the canvas data to disk.
rerenderViewport()unknownForce a re-render of all items in the viewport.
select(arg1)unknownAdd an item to the current selection.
selectAll(arg1)unknownSelect all nodes and edges on the canvas.
selectOnly(arg1)unknownSelect only the specified item, deselecting everything else.
setData(arg1)unknownSet the canvas data, replacing existing nodes and edges.
setDragging(arg1)unknownSet the dragging state of the canvas.
setReadonly(arg1)unknownSet the read-only state of the canvas.
setState(arg1)unknownSet the viewport state (position, zoom).
setViewport(arg1, arg2, arg3)unknownSet the viewport position and zoom level.
showCreationMenu(arg1, arg2, arg3)unknownShow the node creation menu at the specified position.
showQuickSettingsMenu(arg1)unknownShow the quick settings menu for canvas options.
smartZoom(arg1)unknownPerform a smart zoom operation (toggle between zoom levels).
takeScreenshot(arg1, arg2)Promise<unknown>Capture a screenshot of the canvas.
toggleGridSnapping(arg1)unknownToggle grid snapping on or off.
toggleObjectSnapping(arg1)unknownToggle object-to-object snapping on or off.
toggleSelect(arg1)unknownToggle the selection state of an item.
undo()unknownUndo the last action.
unload()unknownUnload and clean up the canvas resources.
updateFileOpen(arg1)unknownUpdate the file open state for workspace tracking.
updateHistoryUI()unknownUpdate the undo/redo button enabled states.
updateSelection(arg1)unknownUpdate the visual state of the current selection.
virtualize()unknownVirtualize off-screen nodes to improve performance.
zoomBy(arg1, arg2)unknownZoom the viewport by a delta amount at the specified center point.
zoomToBbox(arg1)unknownZoom the viewport to fit the specified bounding box.
zoomToFit()unknownZoom the viewport to fit all canvas content.
zoomToSelection()unknownZoom the viewport to fit the current selection.

Links to this page: