Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
text.split(/\n/).forEach((line) => {
const breaker = LineBreaker(line, {lineBreak, wordBreak});
const words = [];
let bk = breaker.next();
while(!bk.done) {
words.push(bk.value.slice());
bk = breaker.next();
}
let l = '';
words.forEach((word) => {
if(!l) {
l = word;
} else {
const ll = `${l}${word}`;
const [w] = measureText(node, ll, font);
if(w > (lines.length === 0 ? textboxWidth - textIndent : textboxWidth)) {
lines.push(l);
l = word;
export const breakWords = (str: string, parent: NodeContainer): Array => {
const breaker = LineBreaker(str, {
lineBreak: parent.style.lineBreak,
wordBreak:
parent.style.overflowWrap === OVERFLOW_WRAP.BREAK_WORD
? 'break-word'
: parent.style.wordBreak
});
const words = [];
let bk;
while (!(bk = breaker.next()).done) {
words.push(bk.value.slice());
}
return words;
};