File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 99 < body >
1010 < main x-data ="app ">
1111 < div id ="editor " @doc-changed.camel.debounce ="calcExpressions "
12- @selection-changed.camel ="getCurrentLine "
12+ @selection-changed.camel ="getSelection "
1313 > </ div >
1414 < article id ="output " class ="markdown-body ">
1515 < template x-for ="expression in expressions ">
1616 < div class ="results "
17- :class =" (currentLine >= expression.from) && (currentLine <= expression.to) ? 'highligted' : '' "
17+ :class ="
18+ ((expression.from >= currentLineFrom) && (expression.from <= currentLineTo) ||
19+ (expression.to >= currentLineFrom) && (expression.to <= currentLineTo)) ? 'highligted' : '' "
1820 x-html ="expression.outputs " x-show ="expression.visible "
1921 x-effect ="if((currentLine >= expression.from) && (currentLine <= expression.to)) $el.scrollIntoView({ block: 'nearest', inline: 'start'}) ">
2022 </ div >
Original file line number Diff line number Diff line change @@ -75,11 +75,15 @@ Alpine.data(
7575 get calcExpressions ( ) {
7676 this . expressions = makeDoc ( editor . state . doc . toString ( ) )
7777 } ,
78- get getCurrentLine ( ) {
79- this . currentLine = editor . state . doc . lineAt (
78+ get getSelection ( ) {
79+ this . currentLineFrom = editor . state . doc . lineAt (
8080 editor . state . selection . ranges [ editor . state . selection . mainIndex ] . from
8181 ) . number - 1
82- }
82+ this . currentLineTo = editor . state . doc . lineAt (
83+ editor . state . selection . ranges [ editor . state . selection . mainIndex ] . to
84+ ) . number - 1
85+ } ,
86+
8387 } )
8488)
8589
You can’t perform that action at this time.
0 commit comments