@@ -5,7 +5,10 @@ import { once } from '../misc';
55
66const getlazy = client . import ( 'getlazy' ) ;
77
8- // TODO this.ink is not imported!
8+ let ink ;
9+ export function activate ( ink_in ) {
10+ ink = ink_in
11+ }
912
1013export function dom ( { tag, attrs, contents} , opts ) {
1114 const view = document . createElement ( tag ) ;
@@ -38,7 +41,7 @@ export function html(...args) {
3841}
3942
4043export function tree ( { head, children, expand} , opts ) {
41- this . ink . tree . treeView ( render ( head , opts ) ,
44+ ink . tree . treeView ( render ( head , opts ) ,
4245 children . map ( x => render ( tags . div ( [ x ] ) , opts ) ) ,
4346 { expand} ) ;
4447}
@@ -51,13 +54,13 @@ export function lazy({head, id}, opts) {
5154 console . warn ( 'Unregistered lazy view' ) ;
5255 }
5356 let view ;
54- return view = this . ink . tree . treeView ( render ( head , opts ) , [ ] , {
57+ return view = ink . tree . treeView ( render ( head , opts ) , [ ] , {
5558 onToggle : once ( ( ) => {
5659 if ( client . conn !== conn ) { return ; }
5760 getlazy ( id ) . then ( children => {
5861 const body = view . querySelector ( ':scope > .body' ) ;
5962 children . map ( x => render ( tags . div ( [ x ] ) , opts ) ) . forEach ( x => {
60- body . appendChild ( this . ink . ansiToHTML ( x ) ) ;
63+ body . appendChild ( ink . ansiToHTML ( x ) ) ;
6164 } ) ;
6265 } ) ;
6366 } )
@@ -93,13 +96,13 @@ export function link({file, line, contents}) {
9396 // TODO: maybe need to dispose of the tooltip onclick and readd them, but
9497 // that doesn't seem to be necessary
9598 let tt ;
96- if ( this . ink . Opener . isUntitled ( file ) ) {
99+ if ( ink . Opener . isUntitled ( file ) ) {
97100 tt = atom . tooltips . add ( view , { title ( ) { return 'untitled' ; } } ) ;
98101 } else {
99102 tt = atom . tooltips . add ( view , { title ( ) { return file ; } } ) ;
100103 }
101104 view . onclick = e => {
102- this . ink . Opener . open ( file , line , {
105+ ink . Opener . open ( file , line , {
103106 pending : atom . config . get ( 'core.allowPendingPaneItems' )
104107 } ) ;
105108 e . stopPropagation ( ) ;
@@ -132,7 +135,7 @@ export function code({text, attrs, scope}) {
132135
133136export function latex ( { attrs, text} ) {
134137 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 ) ;
136139 return render ( { type : 'html' , block, content : latex } ) ;
137140}
138141
@@ -153,7 +156,7 @@ export const views = {
153156export function render ( data , opts = { } ) {
154157 if ( views . hasOwnProperty ( data . type ) ) {
155158 const r = views [ data . type ] ( data , opts ) ;
156- this . ink . ansiToHTML ( r ) ;
159+ ink . ansiToHTML ( r ) ;
157160 return r ;
158161 } else if ( ( data != null ? data . constructor : undefined ) === String ) { // data?.constructor === String
159162 return new Text ( data ) ;
0 commit comments