File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -267,7 +267,37 @@ export const Block: React.FC<Block> = props => {
267267 const start = getListNumber ( blockValue . id , blockMap ) ;
268268
269269 return isTopLevel ? wrapList ( output , start ) : output ;
270+ case "to_do" :
271+ /**
272+ * There are only 3 possible cases when no nested to_dos:
273+ * 1. properties: {title: [["test"]], checked: [["No"]]}
274+ * 2. properties: {title: [["test"]], checked: [["Yes"]]}
275+ * 3. properties: {title: [["test"]]}
276+ */
277+ const checkbox = block . value . properties ;
278+ const { id } = block . value ;
279+
280+ // remove other styles in to-do.
281+ const label : string = checkbox ?. title
282+ . flat ( 1 ) // only flatten the first level
283+ . filter ( ( ele : string | Array < string > ) => typeof ele === "string" )
284+ . join ( "" ) ;
285+
286+ const isChecked =
287+ checkbox ?. checked && checkbox ?. checked [ 0 ] [ 0 ] === "Yes" ;
270288
289+ return (
290+ < div >
291+ < input
292+ className = "notion-checkbox"
293+ type = "checkbox"
294+ name = ""
295+ id = { id }
296+ checked = { isChecked }
297+ />
298+ < label htmlFor = { id } > { label } </ label >
299+ </ div >
300+ ) ;
271301 case "image" :
272302 case "embed" :
273303 case "figma" :
Original file line number Diff line number Diff line change @@ -313,6 +313,10 @@ img.notion-page-icon {
313313 padding-left : 0px ;
314314}
315315
316+ .notion-checkbox {
317+ accent-color : # eb5757 ;
318+ }
319+
316320.notion-asset-wrapper {
317321 margin : 0.5rem auto 0.5rem ;
318322 max-width : 100% ;
You can’t perform that action at this time.
0 commit comments