From 2ebe45c46c5efd379464c4e21352db2c800250a6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 12 Jun 2024 09:50:18 +0100 Subject: [PATCH 1/3] Support s tags for strikethrough for Matrix v1.10 Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/HtmlUtils.tsx | 1 + src/Linkify.tsx | 1 + src/Markdown.ts | 2 +- src/editor/deserialize.ts | 2 ++ 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/HtmlUtils.tsx b/src/HtmlUtils.tsx index b63ed1dcf0c..ca892532f9c 100644 --- a/src/HtmlUtils.tsx +++ b/src/HtmlUtils.tsx @@ -124,6 +124,7 @@ const topicSanitizeHtmlParams: IExtendedSanitizeOptions = { allowedTags: [ "font", // custom to matrix for IRC-style font coloring "del", // for markdown + "s", // for markdown "a", "sup", "sub", diff --git a/src/Linkify.tsx b/src/Linkify.tsx index 24a8a153c56..79827e08917 100644 --- a/src/Linkify.tsx +++ b/src/Linkify.tsx @@ -149,6 +149,7 @@ export const sanitizeHtmlParams: IExtendedSanitizeOptions = { allowedTags: [ "font", // custom to matrix for IRC-style font coloring "del", // for markdown + "s", // for markdown "h1", "h2", "h3", diff --git a/src/Markdown.ts b/src/Markdown.ts index 0d33e58b6f0..cf57f93542e 100644 --- a/src/Markdown.ts +++ b/src/Markdown.ts @@ -22,7 +22,7 @@ import { logger } from "matrix-js-sdk/src/logger"; import { linkify } from "./linkify-matrix"; -const ALLOWED_HTML_TAGS = ["sub", "sup", "del", "u", "br", "br/"]; +const ALLOWED_HTML_TAGS = ["sub", "sup", "del", "s", "u", "br", "br/"]; // These types of node are definitely text const TEXT_NODES = ["text", "softbreak", "linebreak", "paragraph", "document"]; diff --git a/src/editor/deserialize.ts b/src/editor/deserialize.ts index 1d2d1f6b29b..c3eccf718c1 100644 --- a/src/editor/deserialize.ts +++ b/src/editor/deserialize.ts @@ -195,6 +195,8 @@ function parseNode(n: Node, pc: PartCreator, opts: IParseOptions, mkListItem?: ( return [pc.plain("**"), ...parseChildren(n, pc, opts), pc.plain("**")]; case "DEL": return [pc.plain(""), ...parseChildren(n, pc, opts), pc.plain("")]; + case "S": + return [pc.plain(""), ...parseChildren(n, pc, opts), pc.plain("")]; case "SUB": return [pc.plain(""), ...parseChildren(n, pc, opts), pc.plain("")]; case "SUP": From 8f804a2d0cdd48d232e1f72fe7cac5839952aca6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 13 Jun 2024 08:51:49 +0100 Subject: [PATCH 2/3] iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/HtmlUtils.tsx | 2 +- src/Linkify.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/HtmlUtils.tsx b/src/HtmlUtils.tsx index ca892532f9c..655be4ac928 100644 --- a/src/HtmlUtils.tsx +++ b/src/HtmlUtils.tsx @@ -124,7 +124,7 @@ const topicSanitizeHtmlParams: IExtendedSanitizeOptions = { allowedTags: [ "font", // custom to matrix for IRC-style font coloring "del", // for markdown - "s", // for markdown + "s", "a", "sup", "sub", diff --git a/src/Linkify.tsx b/src/Linkify.tsx index 79827e08917..169db1f8e65 100644 --- a/src/Linkify.tsx +++ b/src/Linkify.tsx @@ -147,6 +147,7 @@ export const transformTags: NonNullable Date: Thu, 13 Jun 2024 12:52:02 +0100 Subject: [PATCH 3/3] Update src/Linkify.tsx --- src/Linkify.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Linkify.tsx b/src/Linkify.tsx index 169db1f8e65..910acc9dde8 100644 --- a/src/Linkify.tsx +++ b/src/Linkify.tsx @@ -150,7 +150,7 @@ export const sanitizeHtmlParams: IExtendedSanitizeOptions = { // These tags are suggested by the spec https://spec.matrix.org/v1.10/client-server-api/#mroommessage-msgtypes "font", // custom to matrix for IRC-style font coloring "del", // for markdown - "s", // for markdown + "s", "h1", "h2", "h3",