Skip to content

A platform for community discussion. Free, open, simple.

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

Joffrey JAFFEUX2aca41914a3b
diff --git a/plugins/chat/assets/javascripts/lib/discourse-markdown/chat-html-inline.js b/plugins/chat/assets/javascripts/lib/discourse-markdown/chat-html-inline.js
index 26e5b5a2aae..54888125201 100644
--- a/plugins/chat/assets/javascripts/lib/discourse-markdown/chat-html-inline.js
+++ b/plugins/chat/assets/javascripts/lib/discourse-markdown/chat-html-inline.js
@@ -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:._-]*";
diff --git a/plugins/chat/assets/stylesheets/common/chat-message.scss b/plugins/chat/assets/stylesheets/common/chat-message.scss
index c34d4a4f741..11f0426c124 100644
--- a/plugins/chat/assets/stylesheets/common/chat-message.scss
+++ b/plugins/chat/assets/stylesheets/common/chat-message.scss
@@ -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);
diff --git a/plugins/chat/spec/system/chat/composer/channel_spec.rb b/plugins/chat/spec/system/chat/composer/channel_spec.rb
index fb30596c980..429993376e8 100644
--- a/plugins/chat/spec/system/chat/composer/channel_spec.rb
+++ b/plugins/chat/spec/system/chat/composer/channel_spec.rb
@@ -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
diff --git a/plugins/chat/spec/system/chat_channel_spec.rb b/plugins/chat/spec/system/chat_channel_spec.rb
index dbae005662f..08583ac896b 100644
--- a/plugins/chat/spec/system/chat_channel_spec.rb
+++ b/plugins/chat/spec/system/chat_channel_spec.rb
@@ -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
diff --git a/plugins/chat/spec/system/reply_to_message/full_page_spec.rb b/plugins/chat/spec/system/reply_to_message/full_page_spec.rb
index a1a7186db1d..93dc0943c59 100644
--- a/plugins/chat/spec/system/reply_to_message/full_page_spec.rb
+++ b/plugins/chat/spec/system/reply_to_message/full_page_spec.rb
@@ -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")
diff --git a/plugins/chat/test/javascripts/components/chat-message-test.js b/plugins/chat/test/javascripts/components/chat-message-test.js
index 016d00943d0..ebba1578873 100644
--- a/plugins/chat/test/javascripts/components/chat-message-test.js
+++ b/plugins/chat/test/javascripts/components/chat-message-test.js
@@ -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(),