[feat] tag visible in realm

This commit is contained in:
kwaroran
2023-06-05 08:40:47 +09:00
parent 631635f7a7
commit a61bf24e36
2 changed files with 28 additions and 5 deletions

View File

@@ -10,6 +10,12 @@ const convertor = new showdown.Converter({
tables: true
})
const safeConvertor = new showdown.Converter({
simpleLineBreaks: true,
strikethrough: true,
tables: true,
backslashEscapesHTMLTags: true
})
DOMPurify.addHook("uponSanitizeElement", (node: HTMLElement, data) => {
if (data.tagName === "iframe") {
@@ -38,6 +44,12 @@ export async function ParseMarkdown(data:string, char:(character | groupChat) =
})
}
export function parseMarkdownSafe(data:string) {
return DOMPurify.sanitize(safeConvertor.makeHtml(data), {
FORBID_TAGS: ["a", "style"]
})
}
export async function hasher(data:Uint8Array){
return Buffer.from(await crypto.subtle.digest("SHA-256", data)).toString('hex');
}