@react-pdf/textkit
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -26,2 +26,38 @@ "use strict"; | ||
/** | ||
* Slice block at given height | ||
* | ||
* @param {number} height | ||
* @param {Object} paragraph block | ||
* @return {number} sliced paragraph block | ||
*/ | ||
var sliceBlockAtHeight = function sliceBlockAtHeight(height, block) { | ||
var newBlock = []; | ||
var counter = 0; | ||
for (var _iterator = block, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref = _i.value; | ||
} | ||
var line = _ref; | ||
counter += line.box.height; | ||
if (counter < height) { | ||
newBlock.push(line); | ||
} else { | ||
break; | ||
} | ||
} | ||
return newBlock; | ||
}; | ||
/** | ||
* Layout paragraphs inside container until it does not | ||
@@ -37,2 +73,3 @@ * fit anymore, performing line wrapping in the process. | ||
var typesetter = function typesetter(engines, options, container, attributedStrings) { | ||
@@ -53,3 +90,3 @@ var blocks = []; | ||
} else { | ||
paragraphs.unshift(nextParagraph); | ||
blocks.push(sliceBlockAtHeight(paragraphRect.height, block)); | ||
break; | ||
@@ -56,0 +93,0 @@ } |
{ | ||
"name": "@react-pdf/textkit", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "An advanced text layout framework", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
175654
4790