fix(ui): render markdown headings properly in event descriptions (#29648)
* fix(ui): render markdown headings properly in event descriptions * fix(ui): Add noopener and noreferrer to external links in markdownToSafeHTML * fix(ui): revert external link changes in markdownToSafeHTML * fix(ui): update markdown heading styles
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import sanitizeHtml from "sanitize-html";
|
||||
|
||||
import { md } from "@calcom/lib/markdownIt";
|
||||
import sanitizeHtml from "sanitize-html";
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
// This file imports markdown parser which is a costly dependency, so we want to make sure it's not imported on the client side.
|
||||
@@ -24,7 +23,9 @@ export function markdownToSafeHTML(markdown: string | null) {
|
||||
/<ol>/g,
|
||||
"<ol style='list-style-type: decimal; list-style-position: inside; margin-left: 12px; margin-bottom: 4px'>"
|
||||
)
|
||||
.replace(/<a\s+href=/g, "<a target='_blank' class='text-blue-500 hover:text-blue-600' href=");
|
||||
.replace(/<a\s+href=/g, "<a target='_blank' class='text-blue-500 hover:text-blue-600' href=")
|
||||
.replace(/<h1[^>]*>/g, "<h1 style='font-size: 25px; font-weight: bold; margin-bottom: 8px'>")
|
||||
.replace(/<h2[^>]*>/g, "<h2 style='font-size: 20px; font-weight: bold; margin-bottom: 8px'>");
|
||||
|
||||
// Match: <li>Some text </li><li><ul>...</ul></li>
|
||||
// Convert to: <li>Some text <ul>...</ul></li>
|
||||
@@ -34,4 +35,4 @@ export function markdownToSafeHTML(markdown: string | null) {
|
||||
);
|
||||
|
||||
return safeHTMLWithListFormatting;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import DOMPurify from "dompurify";
|
||||
|
||||
import { md } from "@calcom/lib/markdownIt";
|
||||
import DOMPurify from "dompurify";
|
||||
|
||||
if (typeof window == "undefined") {
|
||||
console.warn(
|
||||
@@ -24,7 +23,9 @@ export function markdownToSafeHTMLClient(markdown: string | null) {
|
||||
/<ol>/g,
|
||||
"<ol style='list-style-type: decimal; list-style-position: inside; margin-left: 12px; margin-bottom: 4px'>"
|
||||
)
|
||||
.replace(/<a\s+href=/g, "<a target='_blank' class='text-blue-500 hover:text-blue-600' href=");
|
||||
.replace(/<a\s+href=/g, "<a target='_blank' class='text-blue-500 hover:text-blue-600' href=")
|
||||
.replace(/<h1[^>]*>/g, "<h1 style='font-size: 25px; font-weight: bold; margin-bottom: 8px'>")
|
||||
.replace(/<h2[^>]*>/g, "<h2 style='font-size: 20px; font-weight: bold; margin-bottom: 8px'>");
|
||||
|
||||
// Match: <li>Some text </li><li><ul>...</ul></li> or
|
||||
// Convert to: <li>Some text <ul>...</ul></li>
|
||||
|
||||
Reference in New Issue
Block a user