fix: Render links with target attribute (#4685)
This commit is contained in:
parent
2060f270d3
commit
45e2cd4903
6 changed files with 24 additions and 11 deletions
|
@ -6,3 +6,15 @@ export const escapeHtml = (unsafe = '') => {
|
|||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
};
|
||||
|
||||
export const afterSanitizeAttributes = currentNode => {
|
||||
if ('target' in currentNode) {
|
||||
currentNode.setAttribute('target', '_blank');
|
||||
}
|
||||
};
|
||||
|
||||
export const domPurifyConfig = {
|
||||
hooks: {
|
||||
afterSanitizeAttributes,
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue