瀏覽代碼

Outbound links

master
Roderic Day 5 年之前
父節點
當前提交
8dbbba905d
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. +9
    -1
      pico.js

+ 9
- 1
pico.js 查看文件

@@ -373,13 +373,21 @@ const Chat = {
const S = `0${dt.getSeconds()}`.slice(-2)
return `${H}:${M}:${S}`
},
outboundLinks: (vnode) => {
vnode.dom.querySelectorAll('a').forEach(anchor => {
anchor.target = '_blank'
anchor.rel = 'noopener'
})
},
view() {
return m('.chat',
m('.posts',
State.posts.map(post => m('.post', {oncreate: scrollIntoView},
m('.ts', Chat.prettifyTime(post.ts)),
m('.source', post.source || '~'),
m('.text', m.trust(DOMPurify.sanitize(marked(post.value)))),
m('.text', {oncreate: Chat.outboundLinks},
m.trust(DOMPurify.sanitize(marked(post.value)))
),
)),
),
m(TextBox),

Loading…
取消
儲存