Anchor tag placed with target="_blank" not opened in new tab in HTML viewer widget (#5883)

* fix :: queryname not updating in header while editing and saving in sidebar

* fix :: added hook to open a tags in new window

* revert :: code
This commit is contained in:
Kiran Ashok 2023-04-21 12:36:22 +05:30 committed by GitHub
parent 8017c3cea9
commit bdc9a52c19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,6 +13,13 @@ export const Html = function ({ height, properties, styles, darkMode, dataCy })
useEffect(() => {
setRawHtml(stringifyHTML);
}, [stringifyHTML]);
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
// set all elements owning target to target=_blank
if ('target' in node) {
node.setAttribute('target', '_blank');
node.setAttribute('rel', 'noopener');
}
});
return (
<div style={{ display: visibility ? '' : 'none', width: '100%', height, overflowY: 'auto' }} data-cy={dataCy}>