diff --git a/style.plugins.js b/style.plugins.js index f7d6964..1297777 100644 --- a/style.plugins.js +++ b/style.plugins.js @@ -418,11 +418,9 @@ function setTextRenderer({ node, props, middleStyle, content }, { printStyle }) const fontStyle = node.style; applyFontStyle(middleStyle, fontStyle); - const makeItFlex = () => { - middleStyle.display = 'flex'; - middleStyle.maxWidth = '-webkit-fill-available'; - middleStyle.alignContent = 'flex-start'; - }; + middleStyle.display = 'flex'; + middleStyle.maxWidth = '-webkit-fill-available'; + middleStyle.alignContent = 'flex-start'; if (fontStyle.textAlignHorizontal === 'CENTER') { middleStyle.justifyContent = 'center'; @@ -479,7 +477,6 @@ function setTextRenderer({ node, props, middleStyle, content }, { printStyle }) } if (Object.keys(props).includes('input')) { - makeItFlex(); const inputId = printStyle({ flex: 1, height: '100%' @@ -495,8 +492,6 @@ function setTextRenderer({ node, props, middleStyle, content }, { printStyle }) const styleCache = {}; let currStyle = 0; let currStyleIndex = 0; - let nextLineCounter = 0; - let nextLineIndicator = false; const maxCurrStyle = Object.keys(node.styleOverrideTable) .map(s => Number.parseInt(s, 10)) @@ -529,7 +524,6 @@ function setTextRenderer({ node, props, middleStyle, content }, { printStyle }) ) { styleCache[currStyle].overflow = 'hidden'; styleCache[currStyle].textOverflow = 'ellipsis'; - makeItFlex(); } if (Object.keys(props).includes('ellipsisFlex') && maxCurrStyle === currStyle) { @@ -551,30 +545,33 @@ function setTextRenderer({ node, props, middleStyle, content }, { printStyle }) .join(''); para = para.trim(); - const br = Array(nextLineCounter) - .fill('
') - .join(''); - - if (id) content.push(`${spaceBefore}{\`${para}\`}${spaceAfter}${br}`); - else content.push(`${spaceBefore}{\`${para}\`}${spaceAfter}${br}`); + if (id) content.push(`${spaceBefore}{\`${para}\`}${spaceAfter}`); + else content.push(`${spaceBefore}{\`${para}\`}${spaceAfter}`); para = ''; currStyleIndex++; - - nextLineCounter = 0; - nextLineIndicator = false; }; for (const i in node.characters) { let idx = node.characterStyleOverrides && node.characterStyleOverrides[i]; const char = node.characters[i]; - if (nextLineIndicator && node.characters[i] !== '\n') { - commitParagraph(i); - para += char; + if (node.characters[i] === '\n' && node.characters[i - 1] === '\n') { + const id = printStyle({ + flex: 1, + minWidth: '-webkit-fill-available' + }); + content.push(`
 
`); } else if (node.characters[i] === '\n') { - nextLineIndicator = true; - nextLineCounter++; + commitParagraph(i); + + const id = printStyle({ + flex: 1, + content: '""', + minWidth: '-webkit-fill-available' + }); + content.push(`
`); + middleStyle.flexWrap = 'wrap'; } else { if (idx == null) { idx = 0;