Skip to content

Commit

Permalink
Support line break. Fix for adding new content.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuess committed Jul 31, 2022
1 parent 4f4a658 commit a89c9f4
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,26 @@ import { useLocation } from 'react-router-dom';
*/
const applyLineBreakSupport = (children) => {
const klass = undefined;
return children.split('\n').map((t, i) => {
return (
<React.Fragment key={`${i}`}>
{children.indexOf('\n') > -1 && children.split('\n').length - 1 > i ? (
<>
{klass ? <span className={klass}>{t}</span> : t}
<br />
</>
) : klass ? (
<span className={klass}>{t}</span>
) : (
t
)}
</React.Fragment>
);
});

return typeof children === 'string'
? children.split('\n').map((t, i) => {
return (
<React.Fragment key={`${i}`}>
{children.indexOf('\n') > -1 &&
children.split('\n').length - 1 > i ? (
<>
{klass ? <span className={klass}>{t}</span> : t}
<br />
</>
) : klass ? (
<span className={klass}>{t}</span>
) : (
t
)}
</React.Fragment>
);
})
: children;
};

export const TextWithGlossaryTooltips = ({ text }) => {
Expand All @@ -41,7 +45,8 @@ export const TextWithGlossaryTooltips = ({ text }) => {
return text;
}
const isEditMode = location.pathname.slice(-5) === '/edit';
if (isEditMode || location.pathname === '/' || !__CLIENT__) {
const isAddMode = location.pathname.slice(-4) === '/add';
if (isEditMode || isAddMode || location.pathname === '/' || !__CLIENT__) {
return text;
}

Expand Down

0 comments on commit a89c9f4

Please sign in to comment.