Weave.js

WeaveStickyNoteNode

Sticky Note node API Reference

Overview

The WeaveStickyNoteNode class represents a sticky note primitive within the Weave.js canvas, designed for collaborative brainstorming, workshops, annotations, and visual boards.

Rendered as a Konva Group containing a faceted paper polygon, subtle top tape highlight, and bottom-right dog-ear fold flap, it supports interactive dragging, live resize without corner distortion, rotation, and inline text editing through Weave.js’s shared shape-label engine.

The class extends the WeaveNode class.

Label engine

Sticky note text is managed by the shared shape-label engine. By default the label uses Konva text and a DOM textarea overlay (legacy). Set config.label.engine to native to render with the on-canvas text engine and edit with the native editing session instead (including rich-text formatting stored in labelBlocks):

new WeaveStickyNoteNode({ config: { label: { engine: "native" } } });

Sticky notes override the generic shape-label defaults with STICKY_NOTE_LABEL_DEFAULTS: top-left alignment (labelAlign: "left", labelVerticalAlign: "top"), Inter, system-ui, sans-serif at 16px, #1F2937 fill, 1.35 line height, and 16px padding (labelPaddingX / labelPaddingY). With top and bottom vertical alignment the text bounds exclude the padding, the dog-ear fold corner and the optional author footer margin. With middle only the padding and the author line are excluded, so the text is centered in the space above the author line (on the sheet when there is no author) and a long text may run over the fold.

Label edit events

With the native label engine the node emits onEnterShapeLabelEditMode when a label edit session starts and onExitShapeLabelEditMode when it ends. Exit receives { node: Konva.Group }; enter also receives the live session. While editing, onShapeLabelFormatChange receives { node, format } whenever the selection format changes. The legacy engine does not emit them.

Type

This node nodeType property value is sticky-note.

Import

import { WeaveStickyNoteNode } from "@inditextech/weave-sdk";

Instantiation

new WeaveStickyNoteNode(params?: WeaveStickyNoteNodeParams);

TypeScript types

type WeaveNodeTransformerProperties = Konva.TransformerConfig;

type WeaveShapeLabelConfig = {
  engine: "legacy" | "native"; // default "legacy"
};

type WeaveStickyNoteProperties = {
  transform: Partial<WeaveNodeTransformerProperties>;
  label?: Partial<WeaveShapeLabelConfig>;
};

type WeaveStickyNoteNodeParams = {
  config?: Partial<WeaveStickyNoteProperties>;
};

interface StickyNoteAttributes extends WeaveElementAttributes {
  id: string;
  nodeType?: string;
  x?: number;
  y?: number;
  width?: number;
  height?: number;
  color?: string;
  dogEarSize?: number;
  author?: string;
  rotation?: number;
  zIndex?: number;
}

Parameters

For WeaveStickyNoteNodeParams:

Property Type Required Description

config

Partial<WeaveStickyNoteProperties>

Config parameters for the node.

For WeaveStickyNoteProperties:

Property Type Required Default Description

transform

Partial<WeaveNodeTransformerProperties>

check default values

Setup the transform properties for the sticky note (anchors, rotation, resize behavior, etc.).

label

Partial<WeaveShapeLabelConfig>

{ engine: "legacy" }

Shape-label rendering and editing engine configuration.

Node & Label properties

Property Type Required Default Description

width

number

Required

200

Width of the sticky note in pixels.

height

number

Required

200

Height of the sticky note in pixels.

color

string

#FEF08A

Background color of the sticky note in hex format.

dogEarSize

number

28

Size of the bottom-right folded corner in pixels.

author

string

undefined

Optional author text shown in the bottom-left footer row (rendered as-is).

labelText

string

Plain text content of the note label.

labelFontFamily

string

Inter, system-ui, sans-serif

CSS font-family string for the note label.

labelFontSize

number

16

Font size of the note label in pixels.

labelFill

string

#1F2937

Color of the note label text in hex format.

labelAlign

string

left

Horizontal alignment ("left", "center", "right").

labelVerticalAlign

string

top

Vertical alignment ("top", "middle", "bottom").

labelLineHeight

number

1.35

Line-height multiplier for the note label.

labelPaddingX

number

16

Horizontal inset padding in pixels.

labelPaddingY

number

16

Vertical inset padding in pixels.

labelBlocks

WeaveTextBlock[]

undefined

Rich-text blocks written by the native engine.

Default values & Constants

The SDK exports the following constants alongside WeaveStickyNoteNode:

  • WEAVE_STICKY_NOTE_NODE_TYPE ("sticky-note")

  • DEFAULT_STICKY_NOTE_WIDTH (200), DEFAULT_STICKY_NOTE_HEIGHT (200), MIN_STICKY_NOTE_SIZE (120)

  • DEFAULT_DOG_EAR_SIZE (28), STICKY_NOTE_AUTHOR_MARGIN (22), DEFAULT_STICKY_NOTE_PADDING (16)

  • DEFAULT_STICKY_NOTE_COLOR ("#FEF08A")

  • STICKY_NOTE_PASTEL_COLORS (8 curated pastel swatches)

  • STICKY_NOTE_LABEL_DEFAULTS (WeaveShapeLabelProps merged with sticky note typography and top-left padding)

  • getStickyNoteVerticalReserve(dogEarSize, hasAuthor, verticalAlign?) (returns the space reserved below the text: the fold and the author line, or only the author line when verticalAlign === "middle")