Linkify studio descriptions

This commit is contained in:
apple502j 2021-05-18 05:22:02 +09:00
parent bc77b4b257
commit 536caf994a
No known key found for this signature in database
GPG key ID: 13BE71607A63CDF2
2 changed files with 30 additions and 11 deletions

View file

@ -12,6 +12,7 @@ import {
} from '../../redux/studio-mutations';
import ValidationMessage from '../../components/forms/validation-message.jsx';
import decorateText from '../../lib/decorate-text.jsx';
const errorToMessageId = error => {
switch (error) {
@ -32,18 +33,30 @@ const StudioDescription = ({
});
return (
<div className="studio-info-section">
<textarea
rows="20"
className={fieldClassName}
disabled={isMutating || !canEditInfo || isFetching}
defaultValue={description}
onBlur={e => e.target.value !== description &&
{ canEditInfo ? (
<React.Fragment>
<textarea
rows="20"
className={fieldClassName}
disabled={isMutating || isFetching}
defaultValue={description}
onBlur={e => e.target.value !== description &&
handleUpdate(e.target.value)}
/>
{descriptionError && <ValidationMessage
mode="error"
message={<FormattedMessage id={errorToMessageId(descriptionError)} />}
/>}
/>
{descriptionError && <ValidationMessage
mode="error"
message={<FormattedMessage id={errorToMessageId(descriptionError)} />}
/>}
</React.Fragment>
) : (
<div className="studio-description studio-description-text">
{decorateText(description, {
usernames: true,
hashtags: false,
scratchLinks: true
})}
</div>
)}
</div>
);
};

View file

@ -79,6 +79,12 @@ $radius: 8px;
.studio-description:disabled {
background: $ui-blue-10percent;
}
.studio-description-text {
word-wrap: break-word;
white-space: pre-wrap;
height: 24rem;
overflow-y: scroll;
}
.studio-follow-button {
padding-top: 14px;