11
11
12
12
/* global MathJax:false */
13
13
14
- var Plotly = require ( '../plotly' ) ;
15
14
var d3 = require ( 'd3' ) ;
16
15
17
16
var Lib = require ( '../lib' ) ;
18
17
var xmlnsNamespaces = require ( '../constants/xmlns_namespaces' ) ;
19
18
20
- var util = module . exports = { } ;
21
-
22
19
// Append SVG
23
20
24
21
d3 . selection . prototype . appendSVG = function ( _svgString ) {
@@ -45,7 +42,7 @@ d3.selection.prototype.appendSVG = function(_svgString) {
45
42
46
43
// Text utilities
47
44
48
- util . html_entity_decode = function ( s ) {
45
+ exports . html_entity_decode = function ( s ) {
49
46
var hiddenDiv = d3 . select ( 'body' ) . append ( 'div' ) . style ( { display : 'none' } ) . html ( '' ) ;
50
47
var replaced = s . replace ( / ( & [ ^ ; ] * ; ) / gi, function ( d ) {
51
48
if ( d === '<' ) { return '<' ; } // special handling for brackets
@@ -56,7 +53,7 @@ util.html_entity_decode = function(s) {
56
53
return replaced ;
57
54
} ;
58
55
59
- util . xml_entity_encode = function ( str ) {
56
+ exports . xml_entity_encode = function ( str ) {
60
57
return str . replace ( / & (? ! \w + ; | \# [ 0 - 9 ] + ; | \# x [ 0 - 9 A - F ] + ; ) / g, '&' ) ;
61
58
} ;
62
59
@@ -66,7 +63,7 @@ function getSize(_selection, _dimension) {
66
63
return _selection . node ( ) . getBoundingClientRect ( ) [ _dimension ] ;
67
64
}
68
65
69
- util . convertToTspans = function ( _context , _callback ) {
66
+ exports . convertToTspans = function ( _context , _callback ) {
70
67
var str = _context . text ( ) ;
71
68
var converted = convertToSVG ( str ) ;
72
69
var that = _context ;
@@ -112,7 +109,7 @@ util.convertToTspans = function(_context, _callback) {
112
109
}
113
110
114
111
if ( tex ) {
115
- var td = Plotly . Lib . getPlotDiv ( that . node ( ) ) ;
112
+ var td = Lib . getPlotDiv ( that . node ( ) ) ;
116
113
( ( td && td . _promises ) || [ ] ) . push ( new Promise ( function ( resolve ) {
117
114
that . style ( { visibility : 'hidden' } ) ;
118
115
var config = { fontSize : parseInt ( that . style ( 'font-size' ) , 10 ) } ;
@@ -195,7 +192,7 @@ function cleanEscapesForTex(s) {
195
192
}
196
193
197
194
function texToSVG ( _texString , _config , _callback ) {
198
- var randomID = 'math-output-' + Plotly . Lib . randstr ( [ ] , 64 ) ;
195
+ var randomID = 'math-output-' + Lib . randstr ( [ ] , 64 ) ;
199
196
var tmpDiv = d3 . select ( 'body' ) . append ( 'div' )
200
197
. attr ( { id : randomID } )
201
198
. style ( { visibility : 'hidden' , position : 'absolute' } )
@@ -236,7 +233,7 @@ var PROTOCOLS = ['http:', 'https:', 'mailto:'];
236
233
237
234
var STRIP_TAGS = new RegExp ( '</?(' + Object . keys ( TAG_STYLES ) . join ( '|' ) + ')( [^>]*)?/?>' , 'g' ) ;
238
235
239
- util . plainText = function ( _str ) {
236
+ exports . plainText = function ( _str ) {
240
237
// strip out our pseudo-html so we have a readable
241
238
// version to put into text fields
242
239
return ( _str || '' ) . replace ( STRIP_TAGS , ' ' ) ;
@@ -316,7 +313,7 @@ function convertToSVG(_str) {
316
313
}
317
314
}
318
315
else {
319
- return Plotly . util . xml_entity_encode ( d ) . replace ( / < / g, '<' ) ;
316
+ return exports . xml_entity_encode ( d ) . replace ( / < / g, '<' ) ;
320
317
}
321
318
} ) ;
322
319
@@ -397,7 +394,7 @@ function alignHTMLWith(_base, container, options) {
397
394
398
395
// Editable title
399
396
400
- util . makeEditable = function ( context , _delegate , options ) {
397
+ exports . makeEditable = function ( context , _delegate , options ) {
401
398
if ( ! options ) options = { } ;
402
399
var that = this ;
403
400
var dispatch = d3 . dispatch ( 'edit' , 'input' , 'cancel' ) ;
@@ -431,7 +428,7 @@ util.makeEditable = function(context, _delegate, options) {
431
428
}
432
429
433
430
function appendEditable ( ) {
434
- var plotDiv = d3 . select ( Plotly . Lib . getPlotDiv ( that . node ( ) ) ) ,
431
+ var plotDiv = d3 . select ( Lib . getPlotDiv ( that . node ( ) ) ) ,
435
432
container = plotDiv . select ( '.svg-container' ) ,
436
433
div = container . append ( 'div' ) ;
437
434
div . classed ( 'plugin-editable editable' , true )
0 commit comments