File tree Expand file tree Collapse file tree 1 file changed +12
-23
lines changed Expand file tree Collapse file tree 1 file changed +12
-23
lines changed Original file line number Diff line number Diff line change @@ -781,29 +781,18 @@ ${editor.getDoc().getSelection()}\n--- admonition\n`
781781 admonitionContent . querySelectorAll < HTMLInputElement > (
782782 ".task-list-item-checkbox"
783783 ) ;
784- if ( taskLists . length ) {
785- const file = this . app . vault . getAbstractFileByPath (
786- ctx . sourcePath
787- ) ;
788- const section = ctx . getSectionInfo ( el ) ;
789- if ( file && section ) {
790- const split = src . split ( "\n" ) ;
791- let slicer = 0 ;
792- taskLists . forEach ( ( task ) => {
793- const line =
794- src . slice ( slicer ) . search ( / ^ \- \[ .\] / m) + slicer ;
795- slicer = src . indexOf ( "\n" , line ) ;
796- const box = src . slice ( line , slicer ) . search ( / \[ .\] / ) ;
797- console . log (
798- "🚀 ~ file: main.ts ~ line 797 ~ box" ,
799- box
800- ) ;
801-
802- task . onclick = ( e ) => {
803- const { text, lineStart } = section ;
804- } ;
805- } ) ;
806- }
784+ if ( taskLists ?. length ) {
785+ const split = src . split ( "\n" ) ;
786+ let slicer = 0 ;
787+ taskLists . forEach ( ( task ) => {
788+ const line = split
789+ . slice ( slicer )
790+ . findIndex ( ( l ) => / ^ \- \[ .\] / . test ( l ) ) ;
791+
792+ if ( line == - 1 ) return ;
793+ task . dataset . line = `${ line + slicer + 1 } ` ;
794+ slicer = line + slicer + 1 ;
795+ } ) ;
807796 }
808797
809798 const links =
You can’t perform that action at this time.
0 commit comments