X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fcommon%2FRawHTML.js;h=dde6d530fed21f58dd5a736d64d7f6b1b22d01fd;hb=HEAD;hp=fb0b51ef2b43ec3b5672768818bc2e8a78e056cb;hpb=6b75ddb40eedcdf1b27e82b94b6f0fa7a4af0547;p=alttp.git diff --git a/resources/js/components/common/RawHTML.js b/resources/js/components/common/RawHTML.js deleted file mode 100644 index fb0b51e..0000000 --- a/resources/js/components/common/RawHTML.js +++ /dev/null @@ -1,48 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { useNavigate } from 'react-router-dom'; - -const RawHTML = ({ html }) => { - const navigate = useNavigate(); - - const onClick = e => { - if (e.defaultPrevented) return; - if (e.metaKey || e.ctrlKey || e.shiftKey) return; - if (e.button !== 0) return; - - let el = e.target; - while (el && el.nodeName !== 'A') { - el = el.parentNode; - } - if (!el) return; - - if (el.target && el.target !== '_self') return; - if (el.attributes.download) return; - if (el.rel && /(?:^|\s+)external(?:\s+|$)/.test(el.rel)) return; - - const href = el.getAttribute('href'); - - if (href.startsWith('#')) return; - if (href.startsWith('http')) return; - if (href.startsWith('mailto')) return; - if (href.startsWith('tel')) return; - - el.blur(); - e.preventDefault(); - - setTimeout(() => { - // scroll to top on location change - scrollTo({ top: 0, behavior: 'smooth' }); - }, 50); - - navigate(href); - }; - - return
; -}; - -RawHTML.propTypes = { - html: PropTypes.string, -}; - -export default RawHTML;