Skip to content

Commit a463f16

Browse files
committed
Disabled JSON control + A
1 parent 2796543 commit a463f16

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

packages/firecms_core/src/components/EntityJsonPreview.tsx

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef, useEffect, useCallback } from "react";
1+
import React, { useRef } from "react";
22
import { Highlight, themes } from "prism-react-renderer";
33
import { useModeController } from "../hooks";
44

@@ -8,33 +8,33 @@ export function EntityJsonPreview({ values }: { values: object }) {
88
const preRef = useRef<HTMLPreElement>(null);
99

1010
// Global keydown handler
11-
const handleGlobalKeyDown = useCallback((e: KeyboardEvent) => {
12-
// Check for Control (Windows/Linux) or Command (macOS) + "a":
13-
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a") {
14-
// If our code view is mounted, perform selection
15-
if (preRef.current) {
16-
e.preventDefault();
17-
e.stopPropagation();
11+
// const handleGlobalKeyDown = useCallback((e: KeyboardEvent) => {
12+
// // Check for Control (Windows/Linux) or Command (macOS) + "a":
13+
// if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a") {
14+
// // If our code view is mounted, perform selection
15+
// if (preRef.current) {
16+
// e.preventDefault();
17+
// e.stopPropagation();
18+
//
19+
// const selection = window.getSelection();
20+
// const range = document.createRange();
21+
// range.selectNodeContents(preRef.current);
22+
// if (selection) {
23+
// selection.removeAllRanges();
24+
// selection.addRange(range);
25+
// }
26+
// }
27+
// }
28+
// }, []);
1829

19-
const selection = window.getSelection();
20-
const range = document.createRange();
21-
range.selectNodeContents(preRef.current);
22-
if (selection) {
23-
selection.removeAllRanges();
24-
selection.addRange(range);
25-
}
26-
}
27-
}
28-
}, []);
29-
30-
// Attach the global keydown listener when component mounts,
31-
// and remove it when it unmounts.
32-
useEffect(() => {
33-
document.addEventListener("keydown", handleGlobalKeyDown);
34-
return () => {
35-
document.removeEventListener("keydown", handleGlobalKeyDown);
36-
};
37-
}, [handleGlobalKeyDown]);
30+
// // Attach the global keydown listener when component mounts,
31+
// // and remove it when it unmounts.
32+
// useEffect(() => {
33+
// document.addEventListener("keydown", handleGlobalKeyDown);
34+
// return () => {
35+
// document.removeEventListener("keydown", handleGlobalKeyDown);
36+
// };
37+
// }, [handleGlobalKeyDown]);
3838

3939
return (
4040
<Highlight

0 commit comments

Comments
 (0)