30
30
31
31
import ace from 'brace' ;
32
32
import { Editor as IAceEditor , IEditSession as IAceEditSession } from 'brace' ;
33
+ import $ from 'jquery' ;
33
34
import {
34
35
CoreEditor ,
35
36
Position ,
@@ -53,11 +54,11 @@ const rangeToAceRange = ({ start, end }: Range) =>
53
54
54
55
export class LegacyCoreEditor implements CoreEditor {
55
56
private _aceOnPaste : any ;
56
- actions : any ;
57
+ $ actions : any ;
57
58
resize : ( ) => void ;
58
59
59
60
constructor ( private readonly editor : IAceEditor , actions : HTMLElement ) {
60
- this . actions = actions ;
61
+ this . $ actions = $ ( actions ) ;
61
62
this . editor . setShowPrintMargin ( false ) ;
62
63
63
64
const session = this . editor . getSession ( ) ;
@@ -273,16 +274,20 @@ export class LegacyCoreEditor implements CoreEditor {
273
274
274
275
private setActionsBar = ( value ?: any , topOrBottom : 'top' | 'bottom' = 'top' ) => {
275
276
if ( value === null ) {
276
- this . actions . style . visibility = 'hidden' ;
277
+ this . $ actions. css ( ' visibility' , 'hidden' ) ;
277
278
} else {
278
279
if ( topOrBottom === 'top' ) {
279
- this . actions . style . bottom = 'auto' ;
280
- this . actions . style . top = value ;
281
- this . actions . style . visibility = 'visible' ;
280
+ this . $actions . css ( {
281
+ bottom : 'auto' ,
282
+ top : value ,
283
+ visibility : 'visible' ,
284
+ } ) ;
282
285
} else {
283
- this . actions . style . top = 'auto' ;
284
- this . actions . style . bottom = value ;
285
- this . actions . style . visibility = 'visible' ;
286
+ this . $actions . css ( {
287
+ top : 'auto' ,
288
+ bottom : value ,
289
+ visibility : 'visible' ,
290
+ } ) ;
286
291
}
287
292
}
288
293
} ;
@@ -313,14 +318,14 @@ export class LegacyCoreEditor implements CoreEditor {
313
318
}
314
319
315
320
legacyUpdateUI ( range : any ) {
316
- if ( ! this . actions ) {
321
+ if ( ! this . $ actions) {
317
322
return ;
318
323
}
319
324
if ( range ) {
320
325
// elements are positioned relative to the editor's container
321
326
// pageY is relative to page, so subtract the offset
322
327
// from pageY to get the new top value
323
- const offsetFromPage = this . editor . container . offsetTop ;
328
+ const offsetFromPage = $ ( this . editor . container ) . offset ( ) ! . top ;
324
329
const startLine = range . start . lineNumber ;
325
330
const startColumn = range . start . column ;
326
331
const firstLine = this . getLineValue ( startLine ) ;
@@ -340,11 +345,11 @@ export class LegacyCoreEditor implements CoreEditor {
340
345
let offset = 0 ;
341
346
if ( isWrapping ) {
342
347
// Try get the line height of the text area in pixels.
343
- const textArea = this . editor . container . querySelector ( 'textArea' ) ;
348
+ const textArea = $ ( this . editor . container . querySelector ( 'textArea' ) ! ) ;
344
349
const hasRoomOnNextLine = this . getLineValue ( startLine ) . length < maxLineLength ;
345
350
if ( textArea && hasRoomOnNextLine ) {
346
351
// Line height + the number of wraps we have on a line.
347
- offset += this . getLineValue ( startLine ) . length * textArea . getBoundingClientRect ( ) . height ;
352
+ offset += this . getLineValue ( startLine ) . length * textArea . height ( ) ! ;
348
353
} else {
349
354
if ( startLine > 1 ) {
350
355
this . setActionsBar ( getScreenCoords ( startLine - 1 ) ) ;
0 commit comments