File tree Expand file tree Collapse file tree 3 files changed +53
-0
lines changed
Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,11 @@ export interface State {
1717 locale : string ;
1818 /** Time zone selected, if any */
1919 timeZone : string | null ;
20+ /** Whether highlighting is enabled */
21+ highlightingEnabled : boolean ;
2022}
2123
24+
2225export interface BackgroundState {
2326 id : string ;
2427 key : string ;
@@ -87,8 +90,10 @@ const initData: State = {
8790 focus : false ,
8891 locale : defaultLocale ,
8992 timeZone : null ,
93+ highlightingEnabled : true , // Initialize as true
9094} ;
9195
96+
9297// Database storage
9398export const db = DB . init < State > ( initData ) ;
9499
Original file line number Diff line number Diff line change @@ -9,6 +9,20 @@ import { Dashboard } from "./dashboard";
99import { Settings } from "./settings" ;
1010import Errors from "./shared/Errors" ;
1111import StoreError from "./shared/StoreError" ;
12+ import { db } from "../db/state" ;
13+
14+ function setHighlighting ( ) {
15+ const checked = db . cache . get ( 'highlightingEnabled' ) ;
16+ console . log ( checked ) ;
17+ const element = document . querySelector ( ".Widgets" ) as HTMLElement ;
18+ if ( element ) {
19+ if ( checked || checked === undefined ) {
20+ element . style . userSelect = "auto" ;
21+ } else {
22+ element . style . userSelect = "none" ;
23+ }
24+ }
25+ }
1226
1327const messages = defineMessages ( {
1428 pageTitle : {
@@ -80,6 +94,9 @@ const Root: React.FC = () => {
8094 subscriptions . then ( ( ) => {
8195 setReady ( true ) ;
8296 migrate ( ) ;
97+ setTimeout ( ( ) => {
98+ setHighlighting ( ) ;
99+ } , 1 ) ;
83100 } ) ;
84101
85102 return ( ) => {
Original file line number Diff line number Diff line change @@ -7,6 +7,19 @@ import TimeZoneInput from "../shared/timeZone/TimeZoneInput";
77const System : React . FC = ( ) => {
88 const [ locale , setLocale ] = useKey ( db , "locale" ) ;
99 const [ timeZone , setTimeZone ] = useKey ( db , "timeZone" ) ;
10+ const [ highlightingEnabled , setHighlightingEnabled ] = useKey ( db , "highlightingEnabled" ) ;
11+
12+ function setHighlighting ( checked : boolean ) {
13+ setHighlightingEnabled ( checked ) ;
14+ const element = document . querySelector ( ".Widgets" ) as HTMLElement ;
15+ if ( element ) {
16+ if ( checked ) {
17+ element . style . userSelect = "auto" ;
18+ } else {
19+ element . style . userSelect = "none" ;
20+ }
21+ }
22+ }
1023
1124 return (
1225 < div >
@@ -184,6 +197,24 @@ const System: React.FC = () => {
184197 Time Zone
185198 < TimeZoneInput timeZone = { timeZone } onChange = { setTimeZone } />
186199 </ label >
200+
201+ < label
202+ style = { {
203+ alignItems : "center" ,
204+ display : "grid" ,
205+ gridGap : "0 0.5rem" ,
206+ gridTemplateColumns : "1fr 2fr" ,
207+ width : "100%" ,
208+ margin : 0 ,
209+ } }
210+ >
211+ < span > Allow Highlighting</ span >
212+ < input
213+ type = "checkbox"
214+ checked = { highlightingEnabled }
215+ onChange = { ( e ) => setHighlighting ( e . target . checked ) }
216+ />
217+ </ label >
187218 </ div >
188219 ) ;
189220} ;
You can’t perform that action at this time.
0 commit comments