2
2
3
3
import { Tooltip } from "bootstrap" ;
4
4
import { Editor } from "./editor.js" ;
5
+ import { Balloon } from "./balloon.js" ;
5
6
import { StructureView } from "./structure_view.js" ;
6
7
import { SyntaxView } from "./syntax_view.js" ;
7
8
import { StatisticsView } from "./statistics_view.js" ;
@@ -18,6 +19,7 @@ export class App {
18
19
19
20
constructor ( ) {
20
21
this . editor = new Editor ( document . getElementById ( "editor-container" ) ) ;
22
+ this . balloon = new Balloon ( ) ;
21
23
22
24
this . structureView = new StructureView (
23
25
document . getElementById ( "structure" )
@@ -145,8 +147,19 @@ export class App {
145
147
146
148
updateStructure ( structureData ) {
147
149
this . structureView . update ( structureData ) ;
150
+
148
151
this . structureView . onmouseover = ( event , target , data ) => {
149
- this . editor . setSelection ( data . range ) ;
152
+ const title = data . token ? "Token" : `${ data . text } ` ;
153
+ const range = data . range ;
154
+
155
+ this . balloon . content = `<div class="title">${ title } </div><div class="range">${ range . startRow } :${ range . startColumn } - ${ range . endRow } :${ range . endColumn } </div>` ;
156
+ this . balloon . show ( this . editor . charCoords ( range ) ) ;
157
+
158
+ this . editor . setSelection ( range ) ;
159
+ } ;
160
+ this . structureView . onmouseout = ( event , target , data ) => {
161
+ this . balloon . hide ( ) ;
162
+ this . editor . clearSelection ( ) ;
150
163
} ;
151
164
}
152
165
0 commit comments