Skip to content

Commit

Permalink
[field] Force show whitespace if only change in segment
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Oct 6, 2020
1 parent a58aaee commit aaeebf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@
text-decoration: line-through;
mix-blend-mode: multiply;
}

.empty {
white-space: pre-line;
white-space: break-spaces;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ function FormattedPreviewText({
}) {
const startsWithWhitespace = text.startsWith(' ')
const endsWithWhitespace = text.endsWith(' ')
const isWhitespace = text.trim().length === 0 ? styles.empty : false

return (
<>
{isFirstSegment && startsWithWhitespace && <>&nbsp;</>}
{text}
{isWhitespace ? <span className={styles.empty}>{text}</span> : text}
{isLastSegment && endsWithWhitespace && <>&nbsp;</>}
</>
)
Expand Down

0 comments on commit aaeebf4

Please sign in to comment.