Skip to content

Commit

Permalink
Merge pull request #266 from NucleoidAI/chat-highlight-code
Browse files Browse the repository at this point in the history
Fix highlight disappearing issue
  • Loading branch information
canmingir authored May 10, 2024
2 parents be0296b + 7057887 commit 736c250
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/ReadOnlyEditor/ReadOnlyEditor.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import "highlight.js/styles/github-dark.css";

import EditIcon from "@mui/icons-material/Edit";
import ExpandLessIcon from "@mui/icons-material/ExpandLess";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import hljs from "highlight.js";

import { Box, Collapse, IconButton, Stack, Typography } from "@mui/material";
import React, { useEffect, useRef, useState } from "react";

import * as prettierStandalone from "prettier/standalone";
import * as typescriptPlugin from "prettier/parser-typescript";

Expand All @@ -20,6 +23,9 @@ const ReadOnlyEditor = ({

useEffect(() => {
if (codeRef.current) {
if (codeRef.current.dataset.highlighted === "yes") {
delete codeRef.current.dataset.highlighted;
}
hljs.highlightElement(codeRef.current);
}
}, [language, value]);
Expand Down

0 comments on commit 736c250

Please sign in to comment.