FEATURE: supports mark tag in chat messages (#28949)

This brings feature parity with posts where you can use this tag.
This commit is contained in:
Joffrey JAFFEUX 2024-09-17 20:52:34 +02:00 committed by GitHub
parent c93235f4f5
commit 2aca41914a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 28 additions and 10 deletions

View File

@ -2,7 +2,7 @@
// note that allow lister will run on top of it, so if a tag is allowed here but not on
// the allow list, then it won't show up
const inline_names = ["kbd"];
const inline_names = ["kbd", "mark"];
const patterns = inline_names.join("|");
const attr_name = "[a-zA-Z_:][a-zA-Z0-9:._-]*";

View File

@ -64,6 +64,10 @@
min-width: 0;
width: 100%;
mark {
background-color: var(--highlight);
}
code {
box-sizing: border-box;
font-size: var(--font-down-1);

View File

@ -22,7 +22,7 @@ RSpec.describe "Chat | composer | channel", type: :system do
:chat_message,
use_service: true,
chat_channel: channel_1,
message: "<mark>not marked</mark>",
message: "<abbr>abbr</abbr>",
)
end
@ -33,7 +33,7 @@ RSpec.describe "Chat | composer | channel", type: :system do
expect(channel_page.composer.message_details).to have_message(
id: message_1.id,
exact_text: "<mark>not marked</mark>",
exact_text: "<abbr>abbr</abbr>",
)
end
end

View File

@ -278,7 +278,7 @@ RSpec.describe "Chat channel", type: :system do
user: other_user,
chat_channel: channel_1,
use_service: true,
message: "<mark>not marked</mark>",
message: "<abbr>not abbr</abbr>",
)
end
@ -292,7 +292,7 @@ RSpec.describe "Chat channel", type: :system do
chat_page.visit_channel(channel_1)
expect(find(".chat-reply .chat-reply__excerpt")["innerHTML"].strip).to eq(
"&lt;mark&gt;not marked&lt;/mark&gt;",
"&lt;abbr&gt;not abbr&lt;/abbr&gt;",
)
end
@ -300,12 +300,12 @@ RSpec.describe "Chat channel", type: :system do
update_message!(
message_2,
user: other_user,
text: "@#{other_user.username} <mark>not marked</mark>",
text: "@#{other_user.username} <abbr>not abbr</abbr>",
)
chat_page.visit_channel(channel_1)
expect(find(".chat-reply .chat-reply__excerpt")["innerHTML"].strip).to eq(
"@#{other_user.username} &lt;mark&gt;not marked&lt;/mark&gt;",
"@#{other_user.username} &lt;abbr&gt;not abbr&lt;/abbr&gt;",
)
end
end

View File

@ -102,13 +102,13 @@ RSpec.describe "Reply to message - channel - full page", type: :system do
update_message!(
original_message,
user: current_user,
text: "@#{other_user.username} <mark>not marked</mark>",
text: "@#{other_user.username} <abbr>not abbr</abbr>",
)
chat_page.visit_channel(channel_1)
channel_page.reply_to(original_message)
expect(find(".chat-reply .chat-reply__excerpt")["innerHTML"].strip).to eq(
"@#{other_user.username} &lt;mark&gt;not marked&lt;/mark&gt;",
"@#{other_user.username} &lt;abbr&gt;not abbr&lt;/abbr&gt;",
)
channel_page.fill_composer("reply to message")

View File

@ -3,7 +3,7 @@ import { clearRender, render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
module("Discourse Chat | Component | chat-message", function (hooks) {
@ -47,6 +47,20 @@ module("Discourse Chat | Component | chat-message", function (hooks) {
);
});
test("message with mark html tag", async function (assert) {
this.message = new ChatFabricators(getOwner(this)).message({
message: "what <mark>test</mark>",
});
await this.message.cook();
await render(template);
assert.true(
query(".chat-message-text")
.innerHTML.trim()
.includes("<p>what <mark>test</mark></p>")
);
});
test("Message with reply", async function (assert) {
this.message = new ChatFabricators(getOwner(this)).message({
inReplyTo: new ChatFabricators(getOwner(this)).message(),