Updated GroupInfoPanel to be markdown enabled, linkable
• Updated: - GroupInfoPanel to be markdown enabled, linkable for users, hashtags, urls
This commit is contained in:
parent
d7cd258977
commit
a5ae957ac5
|
@ -39,6 +39,7 @@ class GroupInfoPanel extends ImmutablePureComponent {
|
|||
const isPrivate = !!group ? group.get('is_private') : false
|
||||
const isVisible = !!group ? group.get('is_visible') : false
|
||||
const tags = !!group ? group.get('tags') : []
|
||||
const descriptionHTML = !!group ? { __html: group.get('description_html') } : {}
|
||||
|
||||
if (noPanel) {
|
||||
return (
|
||||
|
@ -56,7 +57,7 @@ class GroupInfoPanel extends ImmutablePureComponent {
|
|||
</Text>
|
||||
}
|
||||
<Text className={[_s.mt10, _s.py2].join(' ')} color='secondary' size='small' align='center'>
|
||||
{group.get('description')}
|
||||
<div className={_s.dangerousContent} dangerouslySetInnerHTML={descriptionHTML} />
|
||||
</Text>
|
||||
<div className={[_s.d, _s.mt10, _s.flexRow, _s.jcCenter, _s.aiCenter].join(' ')}>
|
||||
<Text color='secondary' size='small' align='center'>
|
||||
|
@ -89,7 +90,7 @@ class GroupInfoPanel extends ImmutablePureComponent {
|
|||
<React.Fragment>
|
||||
|
||||
<Text className={_s.mb5}>
|
||||
{group.get('description')}
|
||||
<div className={_s.dangerousContent} dangerouslySetInnerHTML={descriptionHTML} />
|
||||
</Text>
|
||||
|
||||
<Divider isSmall />
|
||||
|
|
|
@ -125,6 +125,19 @@ class Formatter
|
|||
html
|
||||
end
|
||||
|
||||
def formatGroupDescription(raw_content)
|
||||
return '' if raw_content.blank?
|
||||
|
||||
html = raw_content
|
||||
html = format_markdown(html)
|
||||
html = encode_and_link_urls(html, nil, keep_html: true)
|
||||
html = html.gsub(/(?:\n\r?|\r\n?)/, '<br />')
|
||||
html = html.delete("\n")
|
||||
html.html_safe # rubocop:disable Rails/OutputSafety
|
||||
|
||||
html
|
||||
end
|
||||
|
||||
def format_markdown(html)
|
||||
html = markdown_formatter.render(html)
|
||||
html = html.gsub(/\n/, '<br />')
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class REST::GroupSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :id, :title, :description, :cover_image_url, :is_archived,
|
||||
attributes :id, :title, :description, :description_html, :cover_image_url, :is_archived,
|
||||
:member_count, :created_at, :is_private, :is_visible, :slug, :tags, :category
|
||||
|
||||
def id
|
||||
|
@ -14,6 +14,14 @@ class REST::GroupSerializer < ActiveModel::Serializer
|
|||
object.group_categories_id
|
||||
end
|
||||
|
||||
def description
|
||||
object.description
|
||||
end
|
||||
|
||||
def description_html
|
||||
Formatter.instance.formatGroupDescription(object.description).strip
|
||||
end
|
||||
|
||||
def clean_migrated_url
|
||||
object
|
||||
.cover_image_file_name
|
||||
|
|
Loading…
Reference in New Issue