feat: 支持對話視頻, wip: 文件
This commit is contained in:
@@ -33,7 +33,6 @@ const markedInstance = new marked.Marked({
|
|||||||
},
|
},
|
||||||
image({ text, href }) {
|
image({ text, href }) {
|
||||||
const type = /^(Video|File)=.*/.exec(text)?.[1] || 'Image'
|
const type = /^(Video|File)=.*/.exec(text)?.[1] || 'Image'
|
||||||
|
|
||||||
if (/uploaded_files\/[A-Za-z0-9]+$/.test(href)) {
|
if (/uploaded_files\/[A-Za-z0-9]+$/.test(href)) {
|
||||||
return ({
|
return ({
|
||||||
Image: `<chat-image src="${href}" alt="${text}"></chat-image>`,
|
Image: `<chat-image src="${href}" alt="${text}"></chat-image>`,
|
||||||
@@ -272,6 +271,8 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC
|
|||||||
const rendeText = DOMPurify.sanitize(markedInstance.parse(msg.text) as string, {
|
const rendeText = DOMPurify.sanitize(markedInstance.parse(msg.text) as string, {
|
||||||
ALLOWED_TAGS: [
|
ALLOWED_TAGS: [
|
||||||
"chat-image",
|
"chat-image",
|
||||||
|
"chat-video",
|
||||||
|
"chat-file",
|
||||||
"span",
|
"span",
|
||||||
"chat-link",
|
"chat-link",
|
||||||
],
|
],
|
||||||
|
|||||||
17
client/ui/custom-elements/chat-video.ts
Normal file
17
client/ui/custom-elements/chat-video.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { $ } from 'mdui/jq'
|
||||||
|
|
||||||
|
customElements.define('chat-video', class extends HTMLElement {
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
}
|
||||||
|
connectedCallback() {
|
||||||
|
this.style.display = 'block'
|
||||||
|
const e = new DOMParser().parseFromString(`<video controls>視頻無法播放</video>`, 'text/html').body.firstChild as Node
|
||||||
|
e.style.width = "100%"
|
||||||
|
e.style.height = "100%"
|
||||||
|
e.style.borderRadius = "var(--mdui-shape-corner-medium)"
|
||||||
|
e.alt = $(this).attr('alt') || ""
|
||||||
|
e.src = $(this).attr('src') as string
|
||||||
|
this.appendChild(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user