Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
made Highlighter Singleton to prevent multiple instances of the same …
Browse files Browse the repository at this point in the history
…class
  • Loading branch information
NicoMorenoSirius committed Jun 20, 2024
1 parent f3c9318 commit 87c6e31
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion apps/mocksi-lite/content/ContentApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import closeIcon from "../public/close-icon.png";
import mocksiLogo from "../public/mocksi-logo.png";
import { setRootPosition } from "../utils";
import { setEditorMode } from "./EditMode/editMode";
import { ContentHighlighter } from "./EditMode/highlighter";
import { getHighlighter } from "./EditMode/highlighter";
import Popup from "./Popup";
import { RecordButton } from "./RecordButton";

Expand Down Expand Up @@ -40,6 +40,7 @@ export default function ContentApp({ isOpen, email }: ContentProps) {
const [state, setState] = useState<RecordingState>(
RecordingState.UNAUTHORIZED,
);
const ContentHighlighter = getHighlighter()

useEffect(() => {
// Load initial state from chrome storage
Expand Down
4 changes: 2 additions & 2 deletions apps/mocksi-lite/content/EditMode/actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DOMManipulator } from "@repo/dodom";
import { saveModification } from "../../utils";
import { ContentHighlighter } from "./highlighter";
import { getHighlighter } from "./highlighter";

export function cancelEditWithoutChanges(nodeWithTextArea: HTMLElement | null) {
if (nodeWithTextArea) {
Expand All @@ -24,7 +24,7 @@ export function applyChanges(
// TODO: check if we should keep the singleton behavior we had before
const domManipulator = new DOMManipulator(
fragmentTextNode,
ContentHighlighter,
getHighlighter(),
saveModification,
);
domManipulator.addPattern(oldValue, newValue);
Expand Down

0 comments on commit 87c6e31

Please sign in to comment.