Skip to content

Commit d46faf4

Browse files
Merge pull request #2160 from AletheiaFact/fix/input-overlap-on-reinsert
Fix: Input Component Overlapping on Reinsert
2 parents b57291b + eb090ef commit d46faf4

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

src/components/Collaborative/VisualEditorProvider.tsx

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { createContext, useContext, useEffect, useMemo, useState } from "react";
1+
import {
2+
createContext,
3+
useCallback,
4+
useContext,
5+
useEffect,
6+
useMemo,
7+
useState,
8+
} from "react";
29
import { useAppSelector } from "../../store/store";
310
import { createWebsocketConnection } from "./utils/createWebsocketConnection";
411
import ReviewTaskApi from "../../api/reviewTaskApi";
@@ -27,14 +34,15 @@ interface ContextType {
2734

2835
export const VisualEditorContext = createContext<ContextType>({});
2936

37+
const editorConfig = new EditorConfig();
38+
3039
interface VisualEditorProviderProps {
3140
data_hash: string;
3241
children: React.ReactNode;
3342
source?: string;
3443
}
3544

3645
export const VisualEditorProvider = (props: VisualEditorProviderProps) => {
37-
const editorConfig = new EditorConfig();
3846
const { machineService, reportModel, reviewTaskType } = useContext(
3947
ReviewTaskMachineContext
4048
);
@@ -101,26 +109,29 @@ export const VisualEditorProvider = (props: VisualEditorProviderProps) => {
101109
};
102110
}, [enableCollaborativeEdit, props.data_hash, websocketUrl]);
103111

104-
const extensions = useMemo(
112+
const getExtensions = useCallback(
105113
() =>
106114
editorConfig.getExtensions(
107115
reviewTaskType,
108116
websocketProvider,
109117
enableEditorAnnotations
110118
),
111-
[websocketProvider, reviewTaskType]
119+
[reviewTaskType, websocketProvider, enableEditorAnnotations]
112120
);
113121

114-
const editorConfiguration = {
115-
readonly,
116-
extensions,
117-
isCollaborative,
118-
core: { excludeExtensions: ["history"] },
119-
stringHandler: "html",
120-
content: isCollaborative
121-
? undefined
122-
: (editorContentObject as RemirrorContentType),
123-
};
122+
const editorConfiguration = useMemo(
123+
() => ({
124+
readonly,
125+
extensions: getExtensions,
126+
isCollaborative,
127+
core: { excludeExtensions: ["history"] },
128+
stringHandler: "html",
129+
content: isCollaborative
130+
? undefined
131+
: (editorContentObject as RemirrorContentType),
132+
}),
133+
[readonly, getExtensions, isCollaborative, editorContentObject]
134+
);
124135

125136
const value = useMemo(
126137
() => ({

0 commit comments

Comments
 (0)