@@ -5,7 +5,10 @@ import { once } from '../misc';
5
5
6
6
const getlazy = client . import ( 'getlazy' ) ;
7
7
8
- // TODO this.ink is not imported!
8
+ let ink ;
9
+ export function activate ( ink_in ) {
10
+ ink = ink_in
11
+ }
9
12
10
13
export function dom ( { tag, attrs, contents} , opts ) {
11
14
const view = document . createElement ( tag ) ;
@@ -38,7 +41,7 @@ export function html(...args) {
38
41
}
39
42
40
43
export function tree ( { head, children, expand} , opts ) {
41
- this . ink . tree . treeView ( render ( head , opts ) ,
44
+ ink . tree . treeView ( render ( head , opts ) ,
42
45
children . map ( x => render ( tags . div ( [ x ] ) , opts ) ) ,
43
46
{ expand} ) ;
44
47
}
@@ -51,13 +54,13 @@ export function lazy({head, id}, opts) {
51
54
console . warn ( 'Unregistered lazy view' ) ;
52
55
}
53
56
let view ;
54
- return view = this . ink . tree . treeView ( render ( head , opts ) , [ ] , {
57
+ return view = ink . tree . treeView ( render ( head , opts ) , [ ] , {
55
58
onToggle : once ( ( ) => {
56
59
if ( client . conn !== conn ) { return ; }
57
60
getlazy ( id ) . then ( children => {
58
61
const body = view . querySelector ( ':scope > .body' ) ;
59
62
children . map ( x => render ( tags . div ( [ x ] ) , opts ) ) . forEach ( x => {
60
- body . appendChild ( this . ink . ansiToHTML ( x ) ) ;
63
+ body . appendChild ( ink . ansiToHTML ( x ) ) ;
61
64
} ) ;
62
65
} ) ;
63
66
} )
@@ -93,13 +96,13 @@ export function link({file, line, contents}) {
93
96
// TODO: maybe need to dispose of the tooltip onclick and readd them, but
94
97
// that doesn't seem to be necessary
95
98
let tt ;
96
- if ( this . ink . Opener . isUntitled ( file ) ) {
99
+ if ( ink . Opener . isUntitled ( file ) ) {
97
100
tt = atom . tooltips . add ( view , { title ( ) { return 'untitled' ; } } ) ;
98
101
} else {
99
102
tt = atom . tooltips . add ( view , { title ( ) { return file ; } } ) ;
100
103
}
101
104
view . onclick = e => {
102
- this . ink . Opener . open ( file , line , {
105
+ ink . Opener . open ( file , line , {
103
106
pending : atom . config . get ( 'core.allowPendingPaneItems' )
104
107
} ) ;
105
108
e . stopPropagation ( ) ;
@@ -132,7 +135,7 @@ export function code({text, attrs, scope}) {
132
135
133
136
export function latex ( { attrs, text} ) {
134
137
const block = ( attrs != null ? attrs . block : undefined ) || false ; // attrs?.block || false
135
- const latex = this . ink . KaTeX . texify ( text , block ) ;
138
+ const latex = ink . KaTeX . texify ( text , block ) ;
136
139
return render ( { type : 'html' , block, content : latex } ) ;
137
140
}
138
141
@@ -153,7 +156,7 @@ export const views = {
153
156
export function render ( data , opts = { } ) {
154
157
if ( views . hasOwnProperty ( data . type ) ) {
155
158
const r = views [ data . type ] ( data , opts ) ;
156
- this . ink . ansiToHTML ( r ) ;
159
+ ink . ansiToHTML ( r ) ;
157
160
return r ;
158
161
} else if ( ( data != null ? data . constructor : undefined ) === String ) { // data?.constructor === String
159
162
return new Text ( data ) ;
0 commit comments