1- import React , { useRef , useEffect , useCallback } from "react" ;
1+ import React , { useRef } from "react" ;
22import { Highlight , themes } from "prism-react-renderer" ;
33import { 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