Skip to content

Commit

Permalink
Delete previous highlight before highlighting again
Browse files Browse the repository at this point in the history
  • Loading branch information
durulkoca committed May 10, 2024
1 parent 9b82389 commit 7057887
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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
7 changes: 6 additions & 1 deletion src/lib/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,12 @@ function compile(blocks) {

const api = createAPI(uniqueFunctions);
api.unshift(rootObject);
return { api, functions: uniqueFunctions, declarations, imperatives };
return {
api,
functions: uniqueFunctions,
declarations: uniqueDeclarations,
imperatives,
};
}

export default { compile };

0 comments on commit 7057887

Please sign in to comment.