@@ -16,6 +16,9 @@ export default class HighlightCode extends Component {
|
|||||||
canCopy: PropTypes.bool
|
canCopy: PropTypes.bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#syntaxHighlighter;
|
||||||
|
#pre;
|
||||||
|
|
||||||
downloadText = () => {
|
downloadText = () => {
|
||||||
saveAs(this.props.value, this.props.fileName || "response.txt")
|
saveAs(this.props.value, this.props.fileName || "response.txt")
|
||||||
}
|
}
|
||||||
@@ -40,12 +43,12 @@ export default class HighlightCode extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
[this.syntaxHighlighter, this.pre]
|
[this.#syntaxHighlighter, this.#pre]
|
||||||
.map(element => element?.addEventListener("mousewheel", this.preventYScrollingBeyondElement, { passive: false }))
|
.map(element => element?.addEventListener("mousewheel", this.preventYScrollingBeyondElement, { passive: false }))
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
[this.syntaxHighlighter, this.pre]
|
[this.#syntaxHighlighter, this.#pre]
|
||||||
.map(element => element?.removeEventListener("mousewheel", this.preventYScrollingBeyondElement))
|
.map(element => element?.removeEventListener("mousewheel", this.preventYScrollingBeyondElement))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,14 +61,14 @@ export default class HighlightCode extends Component {
|
|||||||
|
|
||||||
const codeBlock = get(config, "syntaxHighlight.activated")
|
const codeBlock = get(config, "syntaxHighlight.activated")
|
||||||
? <SyntaxHighlighter
|
? <SyntaxHighlighter
|
||||||
ref={elem => this.syntaxHighlighter = elem}
|
ref={elem => this.#syntaxHighlighter = elem}
|
||||||
language={language}
|
language={language}
|
||||||
className={className + " microlight"}
|
className={className + " microlight"}
|
||||||
style={getStyle(get(config, "syntaxHighlight.theme"))}
|
style={getStyle(get(config, "syntaxHighlight.theme"))}
|
||||||
>
|
>
|
||||||
{value}
|
{value}
|
||||||
</SyntaxHighlighter>
|
</SyntaxHighlighter>
|
||||||
: <pre ref={elem => this.pre = elem} className={className + " microlight"}>{value}</pre>
|
: <pre ref={elem => this.#pre = elem} className={className + " microlight"}>{value}</pre>
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="highlight-code">
|
<div className="highlight-code">
|
||||||
|
|||||||
Reference in New Issue
Block a user