mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2026-09-03 20:53:09 -05:00
Refactor markdown/sanitize html code
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
export * from './abuse'
|
||||
export * from './i18n'
|
||||
export * from './logs'
|
||||
export * from './miscs'
|
||||
export * from './plugins'
|
||||
export * from './renderer'
|
||||
export * from './users'
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
export const SANITIZE_OPTIONS = {
|
||||
allowedTags: [ 'a', 'p', 'span', 'br', 'strong', 'em', 'ul', 'ol', 'li' ],
|
||||
allowedSchemes: [ 'http', 'https' ],
|
||||
allowedAttributes: {
|
||||
a: [ 'href', 'class', 'target', 'rel' ]
|
||||
},
|
||||
transformTags: {
|
||||
a: (tagName, attribs) => {
|
||||
let rel = 'noopener noreferrer'
|
||||
if (attribs.rel === 'me') rel += ' me'
|
||||
|
||||
return {
|
||||
tagName,
|
||||
attribs: Object.assign(attribs, {
|
||||
target: '_blank',
|
||||
rel
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './markdown'
|
||||
export * from './html'
|
||||
@@ -0,0 +1,23 @@
|
||||
export const TEXT_RULES = [
|
||||
'linkify',
|
||||
'autolink',
|
||||
'emphasis',
|
||||
'link',
|
||||
'newline',
|
||||
'list'
|
||||
]
|
||||
|
||||
export const TEXT_WITH_HTML_RULES = TEXT_RULES.concat([
|
||||
'html_inline',
|
||||
'html_block'
|
||||
])
|
||||
|
||||
export const ENHANCED_RULES = TEXT_RULES.concat([ 'image' ])
|
||||
export const ENHANCED_WITH_HTML_RULES = TEXT_WITH_HTML_RULES.concat([ 'image' ])
|
||||
|
||||
export const COMPLETE_RULES = ENHANCED_WITH_HTML_RULES.concat([
|
||||
'block',
|
||||
'inline',
|
||||
'heading',
|
||||
'paragraph'
|
||||
])
|
||||
Reference in New Issue
Block a user