@@ -26,6 +26,7 @@ export const Console: React.FC<Props> = () => {
2626 label : string ;
2727 } [ ]
2828 > ( initialState ) ;
29+ const [ indentColoring , setIndentColoring ] = useState < boolean > ( false ) ;
2930
3031 useEffect ( ( ) => {
3132 chrome . storage . local . get ( 'scrapboxIndentOption' , ( result ) => {
@@ -38,8 +39,34 @@ export const Console: React.FC<Props> = () => {
3839 setIndentOptions ( scrapboxIndentOption ) ;
3940 }
4041 } ) ;
42+
43+ chrome . storage . local . get ( 'scrapboxIndentColoring' , ( result ) => {
44+ const scrapboxIndentColoring = result . scrapboxIndentColoring ;
45+
46+ if ( ! scrapboxIndentColoring ) {
47+ chrome . storage . local . set ( { scrapboxIndentColoring : false } ) ;
48+ setIndentColoring ( false ) ;
49+ } else {
50+ setIndentColoring ( scrapboxIndentColoring ) ;
51+ }
52+ } ) ;
4153 } , [ ] ) ;
4254
55+ const handleIndentColoringChange = ( checked : boolean ) => {
56+ chrome . storage . local . set ( { scrapboxIndentColoring : checked } ) ;
57+ setIndentColoring ( checked ) ;
58+
59+ chrome . tabs . query ( { active : true , currentWindow : true } , ( tabs ) => {
60+ tabs . forEach ( ( tab ) => {
61+ if ( tab . url === undefined || tab . id === undefined ) return ;
62+ const url = new URL ( tab . url ) ;
63+ if ( url . hostname === 'scrapbox.io' ) {
64+ chrome . tabs . sendMessage ( tab . id , 'scrapbox_indent_coloring' ) ;
65+ }
66+ } ) ;
67+ } ) ;
68+ } ;
69+
4370 const handleOnChange = (
4471 newValue : SingleValue < {
4572 value : string ;
@@ -68,7 +95,6 @@ export const Console: React.FC<Props> = () => {
6895 chrome . tabs . query ( { active : true , currentWindow : true } , ( tabs ) => {
6996 tabs . forEach ( ( tab ) => {
7097 if ( tab . url === undefined || tab . id === undefined ) return ;
71-
7298 const url = new URL ( tab . url ) ;
7399 if ( url . hostname === 'scrapbox.io' ) {
74100 chrome . tabs . sendMessage ( tab . id , 'scrapbox_list_maker' ) ;
@@ -83,14 +109,12 @@ export const Console: React.FC<Props> = () => {
83109 < Title > Select Favorite List Maker</ Title >
84110 < SwitchLabel >
85111 < Switch
86- checked = { true }
87- onChange = { ( ) => {
88- console . log ( 'aaa' ) ;
89- } }
112+ checked = { indentColoring }
113+ onChange = { handleIndentColoringChange }
90114 onColor = "#00b428"
91115 boxShadow = "0px 1px 5px rgba(0, 0, 0, 0.6)"
92116 height = { 16 }
93- width = { 28 }
117+ width = { 30 }
94118 handleDiameter = { 18 }
95119 checkedIcon = { false }
96120 uncheckedIcon = { false }
0 commit comments