lexgui 0.1.28 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/codeeditor.js +7 -2
- package/build/components/nodegraph.js +2746 -361
- package/build/lexgui.css +286 -36
- package/build/lexgui.js +156 -107
- package/build/lexgui.module.js +144 -95
- package/changelog.md +11 -0
- package/examples/code_editor.html +13 -10
- package/examples/node_graph.html +1 -1
- package/package.json +1 -1
package/build/lexgui.module.js
CHANGED
|
@@ -8,12 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
var LX = {
|
|
11
|
-
version: "0.1.
|
|
11
|
+
version: "0.1.29",
|
|
12
12
|
ready: false,
|
|
13
13
|
components: [], // specific pre-build components
|
|
14
14
|
signals: {} // events and triggers
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
LX.MOUSE_LEFT_CLICK = 0;
|
|
18
|
+
LX.MOUSE_MIDDLE_CLICK = 1;
|
|
19
|
+
LX.MOUSE_RIGHT_CLICK = 2;
|
|
20
|
+
|
|
17
21
|
LX.MOUSE_DOUBLE_CLICK = 2;
|
|
18
22
|
LX.MOUSE_TRIPLE_CLICK = 3;
|
|
19
23
|
|
|
@@ -75,27 +79,31 @@ function getBase64Image(img) {
|
|
|
75
79
|
|
|
76
80
|
LX.getBase64Image = getBase64Image;
|
|
77
81
|
|
|
78
|
-
function hexToRgb(
|
|
79
|
-
const red = parseInt(
|
|
80
|
-
const green = parseInt(
|
|
81
|
-
const blue = parseInt(
|
|
82
|
-
return [red, green, blue];
|
|
82
|
+
function hexToRgb( hexStr ) {
|
|
83
|
+
const red = parseInt( hexStr.substring( 1, 3 ), 16 ) / 255;
|
|
84
|
+
const green = parseInt( hexStr.substring( 3, 5 ), 16 ) / 255;
|
|
85
|
+
const blue = parseInt( hexStr.substring( 5, 7 ), 16 ) / 255;
|
|
86
|
+
return [ red, green, blue ];
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
|
|
89
|
+
LX.hexToRgb = hexToRgb;
|
|
90
|
+
|
|
91
|
+
function rgbToHex( rgb ) {
|
|
86
92
|
let hex = "#";
|
|
87
|
-
for(let c of rgb) {
|
|
88
|
-
c = Math.floor(c * 255);
|
|
89
|
-
hex += c.toString(16);
|
|
93
|
+
for( let c of rgb ) {
|
|
94
|
+
c = Math.floor( c * 255 );
|
|
95
|
+
hex += c.toString( 16 );
|
|
90
96
|
}
|
|
91
97
|
return hex;
|
|
92
98
|
}
|
|
93
99
|
|
|
100
|
+
LX.rgbToHex = rgbToHex;
|
|
101
|
+
|
|
94
102
|
function simple_guidGenerator() {
|
|
95
103
|
var S4 = function() {
|
|
96
104
|
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
|
|
97
105
|
};
|
|
98
|
-
return (S4()+"-"+S4());
|
|
106
|
+
return (S4()+"-"+S4()+"-"+S4());
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
// Timer that works everywhere (from litegraph.js)
|
|
@@ -140,6 +148,7 @@ class vec2 {
|
|
|
140
148
|
sub ( v, v0 = new vec2() ) { v0.set( this.x - v.x, this.y - v.y ); return v0; }
|
|
141
149
|
mul ( v, v0 = new vec2() ) { if( v.constructor == Number ) { v = new vec2( v ) } v0.set( this.x * v.x, this.y * v.y ); return v0; }
|
|
142
150
|
div ( v, v0 = new vec2() ) { if( v.constructor == Number ) { v = new vec2( v ) } v0.set( this.x / v.x, this.y / v.y ); return v0; }
|
|
151
|
+
abs ( v0 = new vec2() ) { v0.set( Math.abs( this.x ), Math.abs( this.y ) ); return v0; }
|
|
143
152
|
};
|
|
144
153
|
|
|
145
154
|
LX.vec2 = vec2;
|
|
@@ -153,45 +162,57 @@ function makeDraggable( domEl, options = { } ) {
|
|
|
153
162
|
let currentTarget = null;
|
|
154
163
|
let targetClass = options.targetClass;
|
|
155
164
|
|
|
156
|
-
|
|
157
|
-
|
|
165
|
+
let id = LX.UTILS.uidGenerator();
|
|
166
|
+
domEl[ 'draggable-id' ] = id;
|
|
167
|
+
|
|
168
|
+
const defaultMoveFunc = e => {
|
|
169
|
+
if( !currentTarget ) return;
|
|
158
170
|
let left = e.clientX - offsetX;
|
|
159
171
|
let top = e.clientY - offsetY;
|
|
160
|
-
if(left > 3 && (left + domEl.offsetWidth + 6) <= window.innerWidth)
|
|
172
|
+
if( left > 3 && ( left + domEl.offsetWidth + 6 ) <= window.innerWidth )
|
|
161
173
|
domEl.style.left = left + 'px';
|
|
162
|
-
if(top > 3 && (top + domEl.offsetHeight + 6) <= window.innerHeight)
|
|
174
|
+
if( top > 3 && ( top + domEl.offsetHeight + 6 ) <= window.innerHeight )
|
|
163
175
|
domEl.style.top = top + 'px';
|
|
164
176
|
};
|
|
165
177
|
|
|
166
|
-
|
|
178
|
+
const customMoveFunc = e => {
|
|
179
|
+
if( !currentTarget ) return;
|
|
180
|
+
if( options.onMove )
|
|
181
|
+
options.onMove( currentTarget );
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
let onMove = options.onMove ? customMoveFunc : defaultMoveFunc;
|
|
185
|
+
let onDragStart = options.onDragStart;
|
|
167
186
|
|
|
168
|
-
domEl.setAttribute('draggable', true);
|
|
169
|
-
domEl.addEventListener("mousedown", function(e) {
|
|
187
|
+
domEl.setAttribute( 'draggable', true );
|
|
188
|
+
domEl.addEventListener( "mousedown", function( e ) {
|
|
170
189
|
currentTarget = (e.target.classList.contains(targetClass) || !targetClass) ? e.target : null;
|
|
171
|
-
});
|
|
190
|
+
} );
|
|
172
191
|
|
|
173
|
-
domEl.addEventListener("dragstart", function(e) {
|
|
192
|
+
domEl.addEventListener( "dragstart", function( e ) {
|
|
174
193
|
e.preventDefault();
|
|
175
194
|
e.stopPropagation();
|
|
176
195
|
e.stopImmediatePropagation();
|
|
177
|
-
if(!currentTarget) return;
|
|
196
|
+
if( !currentTarget ) return;
|
|
178
197
|
// Remove image when dragging
|
|
179
198
|
var img = new Image();
|
|
180
199
|
img.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=';
|
|
181
|
-
e.dataTransfer.setDragImage(img, 0, 0);
|
|
200
|
+
e.dataTransfer.setDragImage( img, 0, 0 );
|
|
182
201
|
e.dataTransfer.effectAllowed = "move";
|
|
183
202
|
const rect = e.target.getBoundingClientRect();
|
|
184
203
|
offsetX = e.clientX - rect.x;
|
|
185
204
|
offsetY = e.clientY - rect.y;
|
|
186
|
-
document.addEventListener("mousemove", onMove );
|
|
187
|
-
|
|
205
|
+
document.addEventListener( "mousemove", onMove );
|
|
206
|
+
if( onDragStart )
|
|
207
|
+
onDragStart( currentTarget, e );
|
|
208
|
+
}, false );
|
|
188
209
|
|
|
189
|
-
document.addEventListener('mouseup', () => {
|
|
190
|
-
if(currentTarget) {
|
|
210
|
+
document.addEventListener( 'mouseup', () => {
|
|
211
|
+
if( currentTarget ) {
|
|
191
212
|
currentTarget = null;
|
|
192
|
-
document.removeEventListener("mousemove", onMove );
|
|
213
|
+
document.removeEventListener( "mousemove", onMove );
|
|
193
214
|
}
|
|
194
|
-
});
|
|
215
|
+
} );
|
|
195
216
|
}
|
|
196
217
|
|
|
197
218
|
LX.makeDraggable = makeDraggable;
|
|
@@ -3443,99 +3464,105 @@ class Panel {
|
|
|
3443
3464
|
|
|
3444
3465
|
addText( name, value, callback, options = {} ) {
|
|
3445
3466
|
|
|
3446
|
-
let widget = this.create_widget(name, Widget.TEXT, options);
|
|
3467
|
+
let widget = this.create_widget( name, Widget.TEXT, options );
|
|
3447
3468
|
widget.onGetValue = () => {
|
|
3448
3469
|
return wValue.value;
|
|
3449
3470
|
};
|
|
3450
|
-
widget.onSetValue =
|
|
3451
|
-
this.disabled ? wValue.innerText =
|
|
3452
|
-
Panel._dispatch_event(wValue, "focusout");
|
|
3471
|
+
widget.onSetValue = newValue => {
|
|
3472
|
+
this.disabled ? wValue.innerText = newValue : wValue.value = newValue;
|
|
3473
|
+
Panel._dispatch_event( wValue, "focusout" );
|
|
3453
3474
|
};
|
|
3454
3475
|
|
|
3455
3476
|
let element = widget.domEl;
|
|
3456
3477
|
|
|
3457
3478
|
// Add reset functionality
|
|
3458
|
-
if(widget.name && !(options.skipReset ?? false)) {
|
|
3459
|
-
Panel._add_reset_property(element.domName, function() {
|
|
3479
|
+
if( widget.name && !( options.skipReset ?? false ) ) {
|
|
3480
|
+
Panel._add_reset_property( element.domName, function() {
|
|
3460
3481
|
wValue.value = wValue.iValue;
|
|
3461
3482
|
this.style.display = "none";
|
|
3462
|
-
Panel._dispatch_event(wValue, "focusout");
|
|
3463
|
-
});
|
|
3483
|
+
Panel._dispatch_event( wValue, "focusout" );
|
|
3484
|
+
} );
|
|
3464
3485
|
}
|
|
3465
3486
|
|
|
3466
3487
|
// Add widget value
|
|
3467
3488
|
|
|
3468
|
-
let container = document.createElement('div');
|
|
3469
|
-
container.className = "lextext" + (options.warning ? " lexwarning" : "");
|
|
3489
|
+
let container = document.createElement( 'div' );
|
|
3490
|
+
container.className = "lextext" + ( options.warning ? " lexwarning" : "" );
|
|
3470
3491
|
container.style.width = options.inputWidth || "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + " )";
|
|
3471
3492
|
container.style.display = "flex";
|
|
3472
3493
|
|
|
3473
|
-
this.disabled = (options.disabled || options.warning) ?? ( options.url ? true : false );
|
|
3494
|
+
this.disabled = ( options.disabled || options.warning ) ?? ( options.url ? true : false );
|
|
3474
3495
|
let wValue = null;
|
|
3475
3496
|
|
|
3476
3497
|
if( !this.disabled )
|
|
3477
3498
|
{
|
|
3478
|
-
wValue = document.createElement('input');
|
|
3499
|
+
wValue = document.createElement( 'input' );
|
|
3479
3500
|
wValue.type = options.type || "";
|
|
3480
3501
|
wValue.value = wValue.iValue = value || "";
|
|
3481
3502
|
wValue.style.width = "100%";
|
|
3482
3503
|
wValue.style.textAlign = options.float ?? "";
|
|
3483
3504
|
|
|
3484
|
-
if(options.placeholder
|
|
3505
|
+
if( options.placeholder )
|
|
3506
|
+
wValue.setAttribute( "placeholder", options.placeholder );
|
|
3485
3507
|
|
|
3486
|
-
var resolve = (function(val, event) {
|
|
3487
|
-
let btn = element.querySelector(".lexwidgetname .lexicon");
|
|
3488
|
-
if(btn) btn.style.display = (val != wValue.iValue ? "block" : "none");
|
|
3489
|
-
this._trigger( new IEvent(name, val, event), callback );
|
|
3490
|
-
}).bind(this);
|
|
3508
|
+
var resolve = ( function( val, event ) {
|
|
3509
|
+
let btn = element.querySelector( ".lexwidgetname .lexicon" );
|
|
3510
|
+
if( btn ) btn.style.display = ( val != wValue.iValue ? "block" : "none" );
|
|
3511
|
+
this._trigger( new IEvent( name, val, event ), callback );
|
|
3512
|
+
}).bind( this );
|
|
3491
3513
|
|
|
3492
3514
|
const trigger = options.trigger ?? 'default';
|
|
3493
3515
|
|
|
3494
|
-
if(trigger == 'default')
|
|
3516
|
+
if( trigger == 'default' )
|
|
3495
3517
|
{
|
|
3496
|
-
wValue.addEventListener("keyup", function(e){
|
|
3518
|
+
wValue.addEventListener( "keyup", function( e ){
|
|
3497
3519
|
if(e.key == 'Enter')
|
|
3498
|
-
resolve(e.target.value, e);
|
|
3520
|
+
resolve( e.target.value, e );
|
|
3499
3521
|
});
|
|
3500
|
-
wValue.addEventListener("focusout", function(e){
|
|
3501
|
-
resolve(e.target.value, e);
|
|
3522
|
+
wValue.addEventListener( "focusout", function( e ){
|
|
3523
|
+
resolve( e.target.value, e );
|
|
3502
3524
|
});
|
|
3503
3525
|
}
|
|
3504
|
-
else if(trigger == 'input')
|
|
3526
|
+
else if( trigger == 'input' )
|
|
3505
3527
|
{
|
|
3506
|
-
wValue.addEventListener("input", function(e){
|
|
3507
|
-
resolve(e.target.value, e);
|
|
3528
|
+
wValue.addEventListener("input", function( e ){
|
|
3529
|
+
resolve( e.target.value, e );
|
|
3508
3530
|
});
|
|
3509
3531
|
}
|
|
3510
3532
|
|
|
3511
|
-
|
|
3533
|
+
wValue.addEventListener( "mousedown", function( e ){
|
|
3534
|
+
e.stopImmediatePropagation();
|
|
3535
|
+
e.stopPropagation();
|
|
3536
|
+
});
|
|
3537
|
+
|
|
3538
|
+
if( options.icon )
|
|
3512
3539
|
{
|
|
3513
|
-
let icon = document.createElement('a');
|
|
3540
|
+
let icon = document.createElement( 'a' );
|
|
3514
3541
|
icon.className = "inputicon " + options.icon;
|
|
3515
|
-
container.appendChild(icon);
|
|
3542
|
+
container.appendChild( icon );
|
|
3516
3543
|
}
|
|
3517
3544
|
|
|
3518
3545
|
} else
|
|
3519
3546
|
{
|
|
3520
|
-
wValue = document.createElement(options.url ? 'a' : 'div');
|
|
3521
|
-
if(options.url)
|
|
3547
|
+
wValue = document.createElement( options.url ? 'a' : 'div' );
|
|
3548
|
+
if( options.url )
|
|
3522
3549
|
{
|
|
3523
3550
|
wValue.href = options.url;
|
|
3524
3551
|
wValue.target = "_blank";
|
|
3525
3552
|
}
|
|
3526
3553
|
const icon = options.warning ? '<i class="fa-solid fa-triangle-exclamation"></i>' : '';
|
|
3527
|
-
wValue.innerHTML = (icon + value) || "";
|
|
3554
|
+
wValue.innerHTML = ( icon + value ) || "";
|
|
3528
3555
|
wValue.style.width = "100%";
|
|
3529
3556
|
wValue.style.textAlign = options.float ?? "";
|
|
3530
3557
|
}
|
|
3531
3558
|
|
|
3532
|
-
Object.assign(wValue.style, options.style ?? {});
|
|
3559
|
+
Object.assign( wValue.style, options.style ?? {} );
|
|
3533
3560
|
|
|
3534
|
-
container.appendChild(wValue);
|
|
3535
|
-
element.appendChild(container);
|
|
3561
|
+
container.appendChild( wValue );
|
|
3562
|
+
element.appendChild( container );
|
|
3536
3563
|
|
|
3537
3564
|
// Remove branch padding and margins
|
|
3538
|
-
if(!widget.name) {
|
|
3565
|
+
if( !widget.name ) {
|
|
3539
3566
|
element.className += " noname";
|
|
3540
3567
|
container.style.width = "100%";
|
|
3541
3568
|
}
|
|
@@ -3957,10 +3984,7 @@ class Panel {
|
|
|
3957
3984
|
delete list.unfocus_event;
|
|
3958
3985
|
return;
|
|
3959
3986
|
}
|
|
3960
|
-
|
|
3961
|
-
let rect = event.currentTarget.getBoundingClientRect();
|
|
3962
|
-
let y_pos = container.classList.contains('lexdialog') ? rect.top - 5 + rect.height : rect.y + rect.height - 5;
|
|
3963
|
-
element.querySelector(".lexoptions").style.top = y_pos + 'px';
|
|
3987
|
+
element.querySelector(".lexoptions").style.top = (selectedOption.offsetTop + selectedOption.offsetHeight) + 'px';
|
|
3964
3988
|
element.querySelector(".lexoptions").style.width = (event.currentTarget.clientWidth) + 'px';
|
|
3965
3989
|
element.querySelector(".lexoptions").toggleAttribute('hidden');
|
|
3966
3990
|
list.focus();
|
|
@@ -4888,6 +4912,8 @@ class Panel {
|
|
|
4888
4912
|
document.body.classList.add('nocursor');
|
|
4889
4913
|
document.body.classList.add('noevents');
|
|
4890
4914
|
drag_icon.classList.remove('hidden');
|
|
4915
|
+
e.stopImmediatePropagation();
|
|
4916
|
+
e.stopPropagation();
|
|
4891
4917
|
}
|
|
4892
4918
|
|
|
4893
4919
|
function inner_mousemove(e) {
|
|
@@ -5060,6 +5086,8 @@ class Panel {
|
|
|
5060
5086
|
document.body.classList.add('nocursor');
|
|
5061
5087
|
document.body.classList.add('noevents');
|
|
5062
5088
|
drag_icon.classList.remove('hidden');
|
|
5089
|
+
e.stopImmediatePropagation();
|
|
5090
|
+
e.stopPropagation();
|
|
5063
5091
|
}
|
|
5064
5092
|
|
|
5065
5093
|
function inner_mousemove(e) {
|
|
@@ -5244,11 +5272,11 @@ class Panel {
|
|
|
5244
5272
|
|
|
5245
5273
|
addFile( name, callback, options = { } ) {
|
|
5246
5274
|
|
|
5247
|
-
if(!name) {
|
|
5248
|
-
throw("Set Widget Name!");
|
|
5275
|
+
if( !name ) {
|
|
5276
|
+
throw( "Set Widget Name!" );
|
|
5249
5277
|
}
|
|
5250
5278
|
|
|
5251
|
-
let widget = this.create_widget(name, Widget.FILE, options);
|
|
5279
|
+
let widget = this.create_widget( name, Widget.FILE, options );
|
|
5252
5280
|
let element = widget.domEl;
|
|
5253
5281
|
|
|
5254
5282
|
let local = options.local ?? true;
|
|
@@ -5256,31 +5284,36 @@ class Panel {
|
|
|
5256
5284
|
let read = options.read ?? true;
|
|
5257
5285
|
|
|
5258
5286
|
// Create hidden input
|
|
5259
|
-
let input = document.createElement('input');
|
|
5287
|
+
let input = document.createElement( 'input' );
|
|
5260
5288
|
input.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + " - 10%)";
|
|
5261
5289
|
input.type = 'file';
|
|
5262
|
-
|
|
5290
|
+
|
|
5291
|
+
if( options.placeholder )
|
|
5263
5292
|
input.placeholder = options.placeholder;
|
|
5264
5293
|
|
|
5265
|
-
input.addEventListener('change', function(e) {
|
|
5294
|
+
input.addEventListener( 'change', function( e ) {
|
|
5295
|
+
|
|
5266
5296
|
const files = e.target.files;
|
|
5267
5297
|
if( !files.length ) return;
|
|
5268
|
-
if(read)
|
|
5298
|
+
if( read )
|
|
5269
5299
|
{
|
|
5300
|
+
if( options.onBeforeRead )
|
|
5301
|
+
options.onBeforeRead();
|
|
5302
|
+
|
|
5270
5303
|
const reader = new FileReader();
|
|
5271
5304
|
|
|
5272
|
-
if(type === 'text') reader.readAsText(files[0]);
|
|
5273
|
-
else if(type === 'buffer') reader.readAsArrayBuffer(files[0]);
|
|
5274
|
-
else if(type === 'bin') reader.readAsBinaryString(files[0]);
|
|
5275
|
-
else if(type === 'url') reader.readAsDataURL(files[0]);
|
|
5305
|
+
if( type === 'text' ) reader.readAsText( files[ 0 ] );
|
|
5306
|
+
else if( type === 'buffer' ) reader.readAsArrayBuffer( files[ 0 ] );
|
|
5307
|
+
else if( type === 'bin' ) reader.readAsBinaryString( files[ 0 ] );
|
|
5308
|
+
else if( type === 'url' ) reader.readAsDataURL( files[ 0 ] );
|
|
5276
5309
|
|
|
5277
|
-
reader.onload =
|
|
5310
|
+
reader.onload = e => { callback.call( this, e.target.result, files[ 0 ] ) } ;
|
|
5278
5311
|
}
|
|
5279
|
-
else
|
|
5280
|
-
|
|
5312
|
+
else
|
|
5313
|
+
callback( files[ 0 ] );
|
|
5281
5314
|
});
|
|
5282
5315
|
|
|
5283
|
-
element.appendChild(input);
|
|
5316
|
+
element.appendChild( input );
|
|
5284
5317
|
|
|
5285
5318
|
this.queue( element );
|
|
5286
5319
|
|
|
@@ -5288,9 +5321,9 @@ class Panel {
|
|
|
5288
5321
|
{
|
|
5289
5322
|
this.addButton(null, "<a style='margin-top: 0px;' class='fa-solid fa-gear'></a>", () => {
|
|
5290
5323
|
|
|
5291
|
-
new Dialog("Load Settings", p => {
|
|
5292
|
-
p.addDropdown("Type", ['text', 'buffer', 'bin', 'url'], type, v => { type = v } );
|
|
5293
|
-
p.addButton(null, "Reload", v => { input.dispatchEvent( new Event('change') ) } );
|
|
5324
|
+
new Dialog( "Load Settings", p => {
|
|
5325
|
+
p.addDropdown( "Type", [ 'text', 'buffer', 'bin', 'url' ], type, v => { type = v } );
|
|
5326
|
+
p.addButton( null, "Reload", v => { input.dispatchEvent( new Event( 'change' ) ) } );
|
|
5294
5327
|
});
|
|
5295
5328
|
|
|
5296
5329
|
}, { className: "micro", skipInlineCount: true });
|
|
@@ -5844,6 +5877,7 @@ class Dialog {
|
|
|
5844
5877
|
}
|
|
5845
5878
|
|
|
5846
5879
|
destroy() {
|
|
5880
|
+
|
|
5847
5881
|
this.root.remove();
|
|
5848
5882
|
}
|
|
5849
5883
|
|
|
@@ -5858,6 +5892,14 @@ class Dialog {
|
|
|
5858
5892
|
this.root.style.left = x + "px";
|
|
5859
5893
|
this.root.style.top = y + "px";
|
|
5860
5894
|
}
|
|
5895
|
+
|
|
5896
|
+
setTitle( title ) {
|
|
5897
|
+
|
|
5898
|
+
const titleDOM = this.root.querySelector( '.lexdialogtitle' );
|
|
5899
|
+
if( !titleDOM )
|
|
5900
|
+
return;
|
|
5901
|
+
titleDOM.innerText = title;
|
|
5902
|
+
}
|
|
5861
5903
|
}
|
|
5862
5904
|
|
|
5863
5905
|
LX.Dialog = Dialog;
|
|
@@ -5887,8 +5929,10 @@ class PocketDialog extends Dialog {
|
|
|
5887
5929
|
|
|
5888
5930
|
// Custom
|
|
5889
5931
|
this.root.classList.add( "pocket" );
|
|
5890
|
-
|
|
5891
|
-
|
|
5932
|
+
if( !options.position ) {
|
|
5933
|
+
this.root.style.left = "calc(100% - " + (this.root.offsetWidth + 6) + "px)";
|
|
5934
|
+
this.root.style.top = "0px";
|
|
5935
|
+
}
|
|
5892
5936
|
this.panel.root.style.width = "calc( 100% - 12px )";
|
|
5893
5937
|
this.panel.root.style.height = "calc( 100% - 40px )";
|
|
5894
5938
|
this.dock_pos = PocketDialog.TOP;
|
|
@@ -5927,7 +5971,7 @@ class PocketDialog extends Dialog {
|
|
|
5927
5971
|
this.root.style.top = "calc(100% - " + (this.root.offsetHeight + 6) + "px)";
|
|
5928
5972
|
break;
|
|
5929
5973
|
case 'l':
|
|
5930
|
-
this.root.style.left = "0px";
|
|
5974
|
+
this.root.style.left = options.position ? options.position[ 1 ] : "0px";
|
|
5931
5975
|
break;
|
|
5932
5976
|
}
|
|
5933
5977
|
}
|
|
@@ -6032,7 +6076,7 @@ class ContextMenu {
|
|
|
6032
6076
|
contextmenu.style.marginTop = 3.5 - c.offsetHeight + "px";
|
|
6033
6077
|
|
|
6034
6078
|
// Set final width
|
|
6035
|
-
contextmenu.style.width = contextmenu.offsetWidth + "px";
|
|
6079
|
+
// contextmenu.style.width = contextmenu.offsetWidth + "px";
|
|
6036
6080
|
this._adjust_position( contextmenu, 6, true );
|
|
6037
6081
|
}
|
|
6038
6082
|
|
|
@@ -7480,9 +7524,15 @@ Object.defineProperty(String.prototype, 'lastChar', {
|
|
|
7480
7524
|
configurable: true
|
|
7481
7525
|
});
|
|
7482
7526
|
|
|
7483
|
-
Element.prototype.insertChildAtIndex = function(child, index = Infinity) {
|
|
7484
|
-
if (index >= this.children.length) this.appendChild(child);
|
|
7485
|
-
else this.insertBefore(child, this.children[index]);
|
|
7527
|
+
Element.prototype.insertChildAtIndex = function( child, index = Infinity ) {
|
|
7528
|
+
if ( index >= this.children.length ) this.appendChild( child );
|
|
7529
|
+
else this.insertBefore( child, this.children[index] );
|
|
7530
|
+
}
|
|
7531
|
+
|
|
7532
|
+
Element.prototype.hasClass = function( list ) {
|
|
7533
|
+
list = [].concat( list );
|
|
7534
|
+
var r = list.filter( v => this.classList.contains( v ) );
|
|
7535
|
+
return !!r.length;
|
|
7486
7536
|
}
|
|
7487
7537
|
|
|
7488
7538
|
Element.prototype.getComputedSize = function() {
|
|
@@ -7498,7 +7548,7 @@ LX.UTILS = {
|
|
|
7498
7548
|
compareThreshold( v, p, n, t ) { return Math.abs(v - p) >= t || Math.abs(v - n) >= t },
|
|
7499
7549
|
compareThresholdRange( v0, v1, t0, t1 ) { return v0 >= t0 && v0 <= t1 || v1 >= t0 && v1 <= t1 || v0 <= t0 && v1 >= t1},
|
|
7500
7550
|
clamp (num, min, max) { return Math.min(Math.max(num, min), max) },
|
|
7501
|
-
|
|
7551
|
+
uidGenerator: simple_guidGenerator,
|
|
7502
7552
|
getControlPoints( x0, y0, x1, y1, x2, y2, t ) {
|
|
7503
7553
|
|
|
7504
7554
|
// x0,y0,x1,y1 are the coordinates of the end (knot) pts of this segment
|
|
@@ -7523,7 +7573,6 @@ LX.UTILS = {
|
|
|
7523
7573
|
|
|
7524
7574
|
return [p1x,p1y,p2x,p2y]
|
|
7525
7575
|
},
|
|
7526
|
-
|
|
7527
7576
|
drawSpline( ctx, pts, t ) {
|
|
7528
7577
|
|
|
7529
7578
|
ctx.save();
|
package/changelog.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# lexgui.js changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.29
|
|
4
|
+
|
|
5
|
+
GraphEditor:
|
|
6
|
+
- Graphs front end (Nodes, links, groups).
|
|
7
|
+
- Editor stuff (Panning, zoom, moving elements, serialize graph, Snapping...)
|
|
8
|
+
- Basic execution functionality.
|
|
9
|
+
|
|
10
|
+
Improved draggable elements.
|
|
11
|
+
Added "onBeforeLoad" callback in File widget.
|
|
12
|
+
Minor bug fixes.
|
|
13
|
+
|
|
3
14
|
## 0.1.28
|
|
4
15
|
|
|
5
16
|
GraphEditor:
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
5
6
|
<title>LexGUI Code Editor Demo</title>
|
|
6
7
|
<link rel="stylesheet" href="../build/lexgui.css">
|
|
7
8
|
<link rel="icon" href="../images/icon.png">
|
|
@@ -20,14 +21,16 @@
|
|
|
20
21
|
import { LX } from 'lexgui';
|
|
21
22
|
import 'lexgui/components/codeeditor.js';
|
|
22
23
|
|
|
24
|
+
window.LX = LX;
|
|
25
|
+
|
|
23
26
|
// init library and get main area
|
|
24
27
|
let area = LX.init();
|
|
25
28
|
|
|
26
|
-
const file_explorer =
|
|
29
|
+
const file_explorer = false;
|
|
27
30
|
|
|
28
31
|
if( !file_explorer )
|
|
29
32
|
{
|
|
30
|
-
var [leftArea, rightArea] = area.split({ sizes:["
|
|
33
|
+
var [leftArea, rightArea] = area.split({ sizes:["40%","60%"] });
|
|
31
34
|
|
|
32
35
|
var canvas = document.createElement('canvas');
|
|
33
36
|
canvas.id = "mycanvas";
|
|
@@ -52,14 +55,14 @@
|
|
|
52
55
|
file_explorer: file_explorer
|
|
53
56
|
});
|
|
54
57
|
|
|
55
|
-
editor.loadFile( "../
|
|
56
|
-
editor.loadFile( "../data/json_sample.json" );
|
|
57
|
-
editor.loadFile( "../data/css_sample.css" );
|
|
58
|
-
editor.loadFile( "../data/cpp_sample.cpp" );
|
|
59
|
-
editor.loadFile( "../data/xml_sample.xml" );
|
|
60
|
-
editor.loadFile( "../data/python_sample.py" );
|
|
61
|
-
editor.loadFile( "../data/rust_sample.rs" );
|
|
62
|
-
editor.loadFile( "../localhost.bat" );
|
|
58
|
+
editor.loadFile( "../demo.js" );
|
|
59
|
+
// editor.loadFile( "../data/json_sample.json" );
|
|
60
|
+
// editor.loadFile( "../data/css_sample.css" );
|
|
61
|
+
// editor.loadFile( "../data/cpp_sample.cpp" );
|
|
62
|
+
// editor.loadFile( "../data/xml_sample.xml" );
|
|
63
|
+
// editor.loadFile( "../data/python_sample.py" );
|
|
64
|
+
// editor.loadFile( "../data/rust_sample.rs" );
|
|
65
|
+
// editor.loadFile( "../localhost.bat" );
|
|
63
66
|
|
|
64
67
|
if( !file_explorer )
|
|
65
68
|
{
|
package/examples/node_graph.html
CHANGED