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