mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-24 17:03:47 +01:00
Bugfix/links in docs (#2561)
* chore: fix markdown component * Refactor MarkDown component to remove unnecessary useCallback hooks
This commit is contained in:
parent
0d204694a6
commit
01605f6f2a
@ -1,15 +1,28 @@
|
||||
import MarkdownIt from 'markdown-it';
|
||||
import StyledWrapper from './StyledWrapper';
|
||||
import * as React from 'react';
|
||||
import React from 'react';
|
||||
|
||||
const md = new MarkdownIt();
|
||||
|
||||
const Markdown = ({ onDoubleClick, content }) => {
|
||||
const handleOnClick = (event) => {
|
||||
const target = event.target;
|
||||
if (target.tagName === 'A') {
|
||||
event.preventDefault();
|
||||
const href = target.getAttribute('href');
|
||||
if (href) {
|
||||
window.open(href, '_blank');
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleOnDoubleClick = (event) => {
|
||||
if (event?.detail === 2) {
|
||||
if (event.detail === 2) {
|
||||
onDoubleClick();
|
||||
}
|
||||
};
|
||||
|
||||
const htmlFromMarkdown = md.render(content || '');
|
||||
|
||||
return (
|
||||
@ -17,7 +30,8 @@ const Markdown = ({ onDoubleClick, content }) => {
|
||||
<div
|
||||
className="markdown-body"
|
||||
dangerouslySetInnerHTML={{ __html: htmlFromMarkdown }}
|
||||
onClick={handleOnDoubleClick}
|
||||
onClick={handleOnClick}
|
||||
onDoubleClick={handleOnDoubleClick}
|
||||
/>
|
||||
</StyledWrapper>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user