Overview
The WeaveTextV2Node class represents a text element on the Weave.js canvas, with editing drawn natively on the canvas instead of a DOM textarea overlay. It is a drop-in replacement for WeaveTextNode; the existing class is unchanged and stays available.
Built on a Konva.Shape with its own layout engine, it keeps the editing and idle appearance
identical, and is the foundation for rich text.
The class extends the WeaveNode class
Type
This node nodeType property value is text, the same as WeaveTextNode.
|
Existing documents load and render without migration. Register |
Instantiation
const node = new WeaveTextV2Node({
config: {
edition: { outline: { color: "#0074ff", width: 1, padding: 0 } },
sizeWarning: { threshold: 200000 },
},
});
Differences from WeaveTextNode
-
Renders through
WeaveTextV2Shape(aKonva.Shape) with Konva.Text-compatible getters (text(),fontSize(),getTextWidth(), …). TheonEnterTextNodeEditModeandonExitTextNodeEditModeevent payloadnodeis aWeaveTextV2Shape, not aKonva.Text. -
Editing happens on the canvas: a hidden proxy textarea handles typing, IME and clipboard, and the caret and selection are painted on the utility layer, together with an outline of the text box (useful with fixed width or height). There is no DOM overlay.
-
Entering edit mode on existing text selects all of it (like Figma), so typing replaces it; a newly created node starts with the caret.
-
Selection supports click, drag, double-click (word), triple-click (paragraph), arrows, Home/End and Up/Down on visual lines.
-
Undo/redo is local to the edit session (typing, deletion, paste and IME composition each coalesce into one step). Leaving edit mode commits a single
updateNode, skipped when the text is unchanged. While editing, keydown does not propagate to the page, so app-level undo does not fire;window.weaveTextEditingholds the editing node id. -
Clipboard is plain text only. Large pastes are laid out in time slices.
-
All four layouts (
smart,auto-all,auto-height,fixed) keep their behavior. Auto-sized layouts measure from the engine and no longer depend on the zoom level. -
WeaveTextToolAction works with it unchanged.
Content model
Content is stored as blocks (paragraphs) of runs ({ t, m }: text and marks). The text prop
stays as a derived mirror. A node without blocks is synthesized from text on load without
rewriting the document; a whole-text link becomes a full-range link mark.
Marks already present in a document are preserved when the text is edited, but they are not rendered yet and cannot be created from the editor: rich formatting is out of scope for now.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
|
|
Config parameters for the node. |
Configuration
Same properties as WeaveTextNode, except edition, plus:
|
|
| Property | Default | Description |
|---|---|---|
|
|
Draw an outline of the text box while editing. |
|
|
Outline colour. |
|
|
Outline width in screen pixels (constant across zoom levels). |
|
|
Gap between the text box and the outline, in screen pixels. |
|
|
Serialized size of |
Events
| Event | Payload | Description |
|---|---|---|
|
|
An edit session started. |
|
|
An edit session ended and its content was committed. |
|
|
The serialized |
Hyperlinks
Same behavior and methods as WeaveTextNode:
getLink, setLink and removeLink.