File tree 2 files changed +26
-9
lines changed
ui/arduino/views/components/elements
2 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -3,26 +3,43 @@ class CodeMirrorEditor extends Component {
3
3
super ( )
4
4
this . editor = null
5
5
this . content = '# empty file'
6
+ this . scrollTop = 0
6
7
}
7
8
9
+ createElement ( content ) {
10
+ if ( content ) this . content = content
11
+ return html `< div id ="code-editor "> </ div > `
12
+ }
13
+
14
+
8
15
load ( el ) {
9
16
const onCodeChange = ( update ) => {
10
- // console.log('code change', this.content)
11
17
this . content = update . state . doc . toString ( )
12
18
this . onChange ( )
13
19
}
14
20
this . editor = createEditor ( this . content , el , onCodeChange )
15
- }
16
21
17
- createElement ( content ) {
18
- if ( content ) this . content = content
19
- return html `< div id ="code-editor "> </ div > `
22
+ setTimeout ( ( ) => {
23
+ this . editor . scrollDOM . addEventListener ( 'scroll' , this . updateScrollPosition . bind ( this ) )
24
+ this . editor . scrollDOM . scrollTo ( {
25
+ top : this . scrollTop ,
26
+ left : 0
27
+ } )
28
+ } , 10 )
20
29
}
21
30
22
31
update ( ) {
23
32
return false
24
33
}
25
34
35
+ unload ( ) {
36
+ this . editor . scrollDOM . removeEventListener ( 'scroll' , this . updateScrollPosition )
37
+ }
38
+
39
+ updateScrollPosition ( e ) {
40
+ this . scrollTop = e . target . scrollTop
41
+ }
42
+
26
43
onChange ( ) {
27
44
return false
28
45
}
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ function Tab(args) {
57
57
}
58
58
59
59
function selectTab ( e ) {
60
- if ( e . target . tagName === 'BUTTON' || e . target . tagName === 'IMG' ) return
60
+ if ( e . target . classList . contains ( 'close-tab' ) ) return
61
61
onSelectTab ( e )
62
62
}
63
63
@@ -71,9 +71,9 @@ function Tab(args) {
71
71
< div class ="text ">
72
72
${ hasChanges ? '*' : '' } ${ text }
73
73
</ div >
74
- < div class ="options ">
75
- < button onclick =${ onCloseTab } >
76
- < img class ="icon " src ="media/close.svg " />
74
+ < div class ="options close-tab ">
75
+ < button class =" close-tab " onclick =${ onCloseTab } >
76
+ < img class ="close-tab icon " src ="media/close.svg " />
77
77
</ button >
78
78
</ div >
79
79
</ div >
You can’t perform that action at this time.
0 commit comments