mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-27 02:51:57 +02:00
[web] last features esm conversion GitOrigin-RevId: a35ab995bf654f1cdfe0e0062d8806761ecccf2d
29 lines
631 B
JavaScript
29 lines
631 B
JavaScript
import sanitizeHtml from 'sanitize-html'
|
|
const sanitizeOptions = {
|
|
html: {
|
|
allowedTags: ['a', 'span', 'b', 'br', 'i'],
|
|
allowedAttributes: {
|
|
a: ['href', 'style'],
|
|
span: ['style', 'class'],
|
|
},
|
|
},
|
|
plainText: {
|
|
allowedTags: [],
|
|
allowedAttributes: {},
|
|
},
|
|
}
|
|
|
|
function cleanHTML(text, isPlainText) {
|
|
if (!isPlainText) return sanitizeHtml(text, sanitizeOptions.html)
|
|
return sanitizeHtml(text, sanitizeOptions.plainText)
|
|
}
|
|
|
|
function displayLink(text, url, isPlainText) {
|
|
return isPlainText ? `${text} (${url})` : `<a href="${url}">${text}</a>`
|
|
}
|
|
|
|
export default {
|
|
cleanHTML,
|
|
displayLink,
|
|
}
|