Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Message) - support Markdown in messages #10063

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 56 additions & 13 deletions src/components/MessagesList/MessagesGroup/Message/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,34 @@ the main body of the message as well as a quote.
<div v-else-if="showJoinCallButton" class="message-body__main__text call-started">
<NcRichText :text="message"
:arguments="richParameters"
:autolink="true"
autolink
:reference-limit="0" />
<CallButton />
</div>
<div v-else-if="showResultsButton" class="message-body__main__text system-message">
<div v-else-if="showResultsButton || isSystemMessage" class="message-body__main__text system-message">
<NcRichText :text="message"
:arguments="richParameters"
:autolink="true"
autolink
:reference-limit="0" />
<!-- Displays only the "see results" button with the results modal -->
<Poll :id="messageParameters.poll.id"
<Poll v-if="showResultsButton"
:id="messageParameters.poll.id"
:poll-name="messageParameters.poll.name"
:token="token"
:show-as-button="true" />
show-as-button />
</div>
<div v-else-if="isDeletedMessage" class="message-body__main__text deleted-message">
<NcRichText :text="message"
:arguments="richParameters"
:autolink="true"
autolink
:reference-limit="0" />
</div>
<div v-else class="message-body__main__text" :class="{'system-message': isSystemMessage}">
<div v-else class="message-body__main__text message-body__main__text--markdown">
<Quote v-if="parent" :parent-id="parent" v-bind="quote" />
<NcRichText :text="message"
:arguments="richParameters"
:autolink="true"
autolink
:use-markdown="markdown"
Antreesy marked this conversation as resolved.
Show resolved Hide resolved
:reference-limit="1" />
</div>
<div v-if="!isDeletedMessage" class="message-body__main__right">
Expand Down Expand Up @@ -391,6 +393,13 @@ export default {
type: Number,
default: 0,
},
/**
* Is message allowed to render in markdown
*/
markdown: {
type: Boolean,
default: true,
},
sendingFailure: {
type: String,
default: '',
Expand Down Expand Up @@ -907,11 +916,6 @@ export default {
align-items: center;
}

:deep(.rich-text--wrapper) {
white-space: pre-wrap;
word-break: break-word;
}

&--quote {
border-left: 4px solid var(--color-primary-element);
padding: 4px 0 0 8px;
Expand Down Expand Up @@ -1020,4 +1024,43 @@ export default {
.reaction-details {
padding: 8px;
}

.message-body__main__text--markdown {
:deep(.rich-text--wrapper) {
h1 {
font-weight: bold;
font-size: 32px;
margin-bottom: 12px;
line-height: 36px;
color: var(--color-text-light);
}

em {
font-style: italic;
}

ul {
padding-left: 20px;
list-style-type: disc;
}

ol {
padding-left: 20px;
list-style-type: decimal;
}

pre,
code,
blockquote {
padding: 6px;
margin: 2px;
border-radius: var(--border-radius);
background-color: var(--color-background-dark);
}

pre {
overflow-x: auto;
}
}
}
</style>
Loading