Documentation
Widget System
DnD widgets, basic nodes, and rich text architecture.
PaperCast features a modular widget system. Widgets are predefined Node structures that users can drag and drop into the visual builder.
Basic vs Advanced Nodes
In src/registry/categories/, widgets are grouped into categories:
- Basic Nodes: Core primitives like
text,image, anddivider. These are usually atomic (they do not split across pages). - Layout Nodes: Containers like
row,column, andstack. These nodes often implement customsplitfunctions to allow their children to paginate seamlessly. - Advanced Nodes: Complex components like
tableor rich text components.
Drag and Drop
The visual builder uses a DnD system to allow users to pull from the widget registry and drop them into the document.
When a widget is dropped:
- The builder reads the default JSON schema defined for that widget (e.g., a basic Text widget drops with
{ type: "text", content: "New Text" }). - The
astManipulatorsinject this new node into the active AST. - The store updates, triggering a re-render and re-pagination.
Widget IDs
Every node requires a universally unique id. When a widget is dropped from
the registry, PaperCast automatically generates a new UUID for that node to
ensure the AST remains strictly valid.