page-wrapping
Generic page wrapping algorithm proposal.
How it works
import wrapPage from 'page-wrapping'
const node = Node({ left: 20, top: 20, width: 100, height: 100 })
await wrapPage([node], 40)
Node interface
Property | Description | Type |
---|
left | Node x coordinate | Number |
top | Node y coordinate | Number |
width | Node width | Number |
height | Node height | Number |
minPresenceAhead | Presence ahead of element to not to break | Number |
wrap | Whether a node should be able to split in two or more | Boolean |
break | Whether a node should create a page break | Boolean |
fixed | Whether a node should repeat throughout all pages | Boolean |
parent | Node pointer to parent | Node |
children | Children nodes | Array |
appendChild | Add node as children | Function |
remove | Detach node from paren | Function |
clone | Returns a copy of target node | Function |
nodeWillWrap | Callback before element wrap. Can return promise | Function |
onNodeSplit | Callback after element is split in two | Function |
isEmpty | Returns if node is empty or not | Function |