How to use the css-line-break.LineBreaker function in css-line-break

To help you get started, we’ve selected a few css-line-break examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spritejs / sprite-core / src / core / label.js View on Github external
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;
github niklasvh / html2canvas / src / Unicode.js View on Github external
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;
};

css-line-break

css-line-break ==============

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis