File tree Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -57,11 +57,12 @@ export class Node {
57
57
const id = this . id . replace ( regex , '_' ) ;
58
58
const attributes : string [ ] = [ ] ;
59
59
const label = this . config . maximumNodeLabelLength !== - 1 && this . name . length > this . config . maximumNodeLabelLength ? this . name . substr ( 0 , this . config . maximumNodeLabelLength ) + '...' : this . name ;
60
- attributes . push ( `label="${ label } "` ) ;
60
+ attributes . push ( `label=<${ label } >` ) ;
61
+ attributes . push ( 'shape="box"' ) ;
62
+ attributes . push ( `style="filled,rounded"` ) ;
61
63
const color = this . getNodeTypeColor ( this . nodeType ) ;
62
64
if ( color ) {
63
65
attributes . push ( `color="${ color } "` ) ;
64
- attributes . push ( `style="filled"` ) ;
65
66
}
66
67
if ( this . position !== undefined ) {
67
68
const x = this . position . x ;
Original file line number Diff line number Diff line change 261
261
nodes . forEach ( node => {
262
262
nodeExport [ node . id ] = {
263
263
id : node . id ,
264
- label : cleanLabel ( node . label ) ,
264
+ label : command === 'saveAsDgml' ? cleanLabelDgml ( node . label ) : cleanLabelDot ( node . label ) ,
265
265
position : network . getPosition ( node . id ) ,
266
266
boundingBox : network . getBoundingBox ( node . id )
267
267
} ;
276
276
} ) ;
277
277
}
278
278
279
- function cleanLabel ( label ) {
280
- let regex = / ( < ( [ ^ > ] + ) > ) / ig;
281
- let cleanedLabel = label . replace ( regex , '' ) ;
282
- regex = / \s + / g;
283
- cleanedLabel = cleanedLabel . replace ( regex , ' ' ) ;
279
+ function cleanLabelDgml ( label ) {
280
+ let cleanedLabel = removeHtmlTags ( label ) ;
281
+ cleanedLabel = removeNewlines ( cleanedLabel ) ;
282
+ return cleanedLabel ;
283
+ }
284
+
285
+ function cleanLabelDot ( label ) {
286
+ let cleanedLabel = convertNewlinesToDotNewlines ( label ) + '<br align="left"/>' ;
287
+ return cleanedLabel ;
288
+ }
289
+
290
+ function removeHtmlTags ( label ) {
291
+ let cleanedLabel = label . replace ( / ( < ( [ ^ > ] + ) > ) / ig, '' ) ;
292
+ return cleanedLabel ;
293
+ }
294
+ function removeNewlines ( label ) {
295
+ let cleanedLabel = label . replace ( / \s + / g, '' ) ;
296
+ return cleanedLabel ;
297
+ }
298
+ function convertNewlinesToDotNewlines ( label ) {
299
+ let cleanedLabel = label . replace ( / \n / g, '<br align="left"/>' ) ;
284
300
return cleanedLabel ;
285
301
}
286
302
You can’t perform that action at this time.
0 commit comments