lexgui 0.1.17 → 0.1.19
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 +507 -210
- package/build/lexgui.css +76 -18
- package/build/lexgui.js +110 -64
- package/build/lexgui.module.js +100 -55
- package/demo.js +1 -1
- package/examples/code_editor.html +32 -38
- package/package.json +1 -1
package/build/lexgui.css
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
--global-color-primary: #232323;
|
|
10
10
|
--global-color-secondary: #343434;
|
|
11
11
|
--global-color-terciary: #444;
|
|
12
|
-
--global-branch-darker: #
|
|
12
|
+
--global-branch-darker: #252525;
|
|
13
13
|
--branch-title-background: #2e3338;
|
|
14
14
|
--branch-title-inactive-background: #42484e;
|
|
15
15
|
--global-button-color: #4e4e4e;
|
|
@@ -17,10 +17,16 @@
|
|
|
17
17
|
--global-text-primary: #f4f4ffe6;
|
|
18
18
|
--global-text-secondary: #c6c6cfd9;
|
|
19
19
|
--global-dark-background: #14161a;
|
|
20
|
-
--global-blur-background: #
|
|
20
|
+
--global-blur-background: #28292ba9;
|
|
21
21
|
--transition-time: 1000;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/* Some global colors */
|
|
25
|
+
.orange { color: orange }
|
|
26
|
+
.gray { color: gray }
|
|
27
|
+
.dodgerblue { color: dodgerblue }
|
|
28
|
+
.lightblue { color: rgb(90, 168, 247) }
|
|
29
|
+
|
|
24
30
|
::-webkit-scrollbar {
|
|
25
31
|
height: 3px;
|
|
26
32
|
width: 4px;
|
|
@@ -126,7 +132,7 @@ body.nocursor * {
|
|
|
126
132
|
background-color: var(--global-blur-background);
|
|
127
133
|
-webkit-backdrop-filter: blur(12px);
|
|
128
134
|
backdrop-filter: blur(12px);
|
|
129
|
-
border-radius:
|
|
135
|
+
border-radius: 8px;
|
|
130
136
|
border: 1px solid #d0d0ec6b;
|
|
131
137
|
width: 30%;
|
|
132
138
|
top: 15%;
|
|
@@ -184,6 +190,26 @@ body.nocursor * {
|
|
|
184
190
|
float: left;
|
|
185
191
|
}
|
|
186
192
|
|
|
193
|
+
#global_search .searchitembox .searchitem i {
|
|
194
|
+
width: 12px;
|
|
195
|
+
font-size: 11px;
|
|
196
|
+
margin-right: 4px;
|
|
197
|
+
margin-top: -2px;
|
|
198
|
+
vertical-align: middle;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
#global_search .searchitembox .searchitem img {
|
|
202
|
+
width: 12px;
|
|
203
|
+
margin-right: 4px;
|
|
204
|
+
margin-top: -2px;
|
|
205
|
+
vertical-align: middle;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
#global_search .searchitembox .searchitem .lang-ext {
|
|
209
|
+
color: #676e75;
|
|
210
|
+
font-size: 12px;
|
|
211
|
+
}
|
|
212
|
+
|
|
187
213
|
#global_search .searchitembox .searchitem.last {
|
|
188
214
|
border-bottom-left-radius: 6px;
|
|
189
215
|
border-bottom-right-radius: 6px;
|
|
@@ -1409,6 +1435,22 @@ input[type="range"] {
|
|
|
1409
1435
|
user-select: none; /* Standard syntax */
|
|
1410
1436
|
}
|
|
1411
1437
|
|
|
1438
|
+
.lextree .lextreeitem img {
|
|
1439
|
+
width: 12px;
|
|
1440
|
+
height: 12px;
|
|
1441
|
+
margin-right: 4px;
|
|
1442
|
+
vertical-align: middle;
|
|
1443
|
+
margin-top: -1px;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
.lextree .lextreeitem .tree-item-icon {
|
|
1447
|
+
width: 12px;
|
|
1448
|
+
height: 12px;
|
|
1449
|
+
margin-right: 4px;
|
|
1450
|
+
vertical-align: middle;
|
|
1451
|
+
margin-top: -1px;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1412
1454
|
.lextree .lextreeitem.draggingover {
|
|
1413
1455
|
background: #7b8ae27b;
|
|
1414
1456
|
}
|
|
@@ -2002,6 +2044,7 @@ meter::-webkit-meter-even-less-good-value {
|
|
|
2002
2044
|
-ms-user-select: none; /* IE 10+ */
|
|
2003
2045
|
user-select: none; /* Standard syntax */
|
|
2004
2046
|
transition: 0.2s;
|
|
2047
|
+
line-height: 16px;
|
|
2005
2048
|
}
|
|
2006
2049
|
|
|
2007
2050
|
.lexareatabs.row {
|
|
@@ -2692,6 +2735,22 @@ ul.lexassetscontent {
|
|
|
2692
2735
|
padding: 0px;
|
|
2693
2736
|
}
|
|
2694
2737
|
|
|
2738
|
+
.codebasearea .lexareatab i {
|
|
2739
|
+
width: 12px;
|
|
2740
|
+
font-size: 10px;
|
|
2741
|
+
margin-right: 4px;
|
|
2742
|
+
vertical-align: middle;
|
|
2743
|
+
margin-top: -3px;
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2746
|
+
.codebasearea .lexareatab img {
|
|
2747
|
+
width: 12px;
|
|
2748
|
+
height: 12px;
|
|
2749
|
+
margin-right: 4px;
|
|
2750
|
+
vertical-align: middle;
|
|
2751
|
+
margin-top: -2px;
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2695
2754
|
.lexcodeeditor ::-webkit-scrollbar {
|
|
2696
2755
|
width: 6px;
|
|
2697
2756
|
height: 6px;
|
|
@@ -2751,10 +2810,6 @@ ul.lexassetscontent {
|
|
|
2751
2810
|
width: calc( 100% - 10px ) !important;
|
|
2752
2811
|
}
|
|
2753
2812
|
|
|
2754
|
-
/* .lexcodeeditor .codetabsarea.with-hscrollbar {
|
|
2755
|
-
height: calc( 100% - 72px ) !important;
|
|
2756
|
-
} */
|
|
2757
|
-
|
|
2758
2813
|
.lexcodeeditor .codetabsarea.dragging {
|
|
2759
2814
|
background-color: var(--global-color-secondary);
|
|
2760
2815
|
}
|
|
@@ -2786,7 +2841,7 @@ ul.lexassetscontent {
|
|
|
2786
2841
|
font-family: 'Inconsolata', monospace;
|
|
2787
2842
|
font-size: inherit;
|
|
2788
2843
|
font-weight: bold;
|
|
2789
|
-
margin:
|
|
2844
|
+
margin: 0px 0px;
|
|
2790
2845
|
white-space: pre;
|
|
2791
2846
|
word-wrap: normal;
|
|
2792
2847
|
line-height: inherit;
|
|
@@ -2794,7 +2849,7 @@ ul.lexassetscontent {
|
|
|
2794
2849
|
position: relative;
|
|
2795
2850
|
overflow: visible;
|
|
2796
2851
|
-webkit-tap-highlight-color: transparent;
|
|
2797
|
-
height:
|
|
2852
|
+
height: 20px;
|
|
2798
2853
|
pointer-events: none;
|
|
2799
2854
|
}
|
|
2800
2855
|
|
|
@@ -2817,11 +2872,12 @@ ul.lexassetscontent {
|
|
|
2817
2872
|
}
|
|
2818
2873
|
|
|
2819
2874
|
pre .line-gutter {
|
|
2820
|
-
color: #
|
|
2875
|
+
color: #8a8b97;
|
|
2821
2876
|
width: 48px;
|
|
2822
|
-
height:
|
|
2877
|
+
height: 20px;
|
|
2823
2878
|
font-size: 14px;
|
|
2824
|
-
|
|
2879
|
+
font-weight: 400;
|
|
2880
|
+
line-height: 20px;
|
|
2825
2881
|
text-align: center;
|
|
2826
2882
|
-webkit-user-select: none; /* Safari 3.1+ */
|
|
2827
2883
|
-moz-user-select: none; /* Firefox 2+ */
|
|
@@ -2843,7 +2899,6 @@ pre .line-gutter {
|
|
|
2843
2899
|
margin: 0;
|
|
2844
2900
|
padding: 0;
|
|
2845
2901
|
position: relative;
|
|
2846
|
-
z-index: 3;
|
|
2847
2902
|
pointer-events: none;
|
|
2848
2903
|
}
|
|
2849
2904
|
|
|
@@ -2867,7 +2922,7 @@ pre .line-gutter {
|
|
|
2867
2922
|
z-index: 0 !important;
|
|
2868
2923
|
left: 0px;
|
|
2869
2924
|
top: 0px;
|
|
2870
|
-
height:
|
|
2925
|
+
height: 20px;
|
|
2871
2926
|
}
|
|
2872
2927
|
|
|
2873
2928
|
.lexcodescrollbar {
|
|
@@ -2881,6 +2936,7 @@ pre .line-gutter {
|
|
|
2881
2936
|
margin-top: 26px;
|
|
2882
2937
|
z-index: 1 !important;
|
|
2883
2938
|
right: 0px;
|
|
2939
|
+
pointer-events: none;
|
|
2884
2940
|
}
|
|
2885
2941
|
|
|
2886
2942
|
.lexcodescrollbar.horizontal {
|
|
@@ -2906,6 +2962,7 @@ pre .line-gutter {
|
|
|
2906
2962
|
width: 10px;
|
|
2907
2963
|
height: 10px;
|
|
2908
2964
|
transition: linear 0.1s background-color;
|
|
2965
|
+
pointer-events: all;
|
|
2909
2966
|
}
|
|
2910
2967
|
|
|
2911
2968
|
.lexcodescrollbar div:hover { /* thumb */
|
|
@@ -2961,7 +3018,7 @@ pre .line-gutter {
|
|
|
2961
3018
|
margin: 0;
|
|
2962
3019
|
pointer-events: unset;
|
|
2963
3020
|
cursor: default;
|
|
2964
|
-
height:
|
|
3021
|
+
height: 22px;
|
|
2965
3022
|
}
|
|
2966
3023
|
|
|
2967
3024
|
.lexcodeeditor .autocomplete pre a {
|
|
@@ -3073,9 +3130,10 @@ pre .line-gutter {
|
|
|
3073
3130
|
.cm-sym.batch { color: #dfd85e; } /* symbol */
|
|
3074
3131
|
.cm-mtd.batch { color: inherit } /* method */
|
|
3075
3132
|
|
|
3076
|
-
|
|
3077
|
-
.cm-
|
|
3078
|
-
.cm-bln.
|
|
3133
|
+
.cm-str.html { color: #ca7d59; } /* string */
|
|
3134
|
+
.cm-kwd.html { color: #2194ce; } /* keyword */
|
|
3135
|
+
.cm-bln.html { color: #b4d7ec; } /* builtin */
|
|
3136
|
+
.cm-sym.html { color: #929292; } /* symbol */
|
|
3079
3137
|
|
|
3080
3138
|
|
|
3081
3139
|
/* Node Graph */
|
package/build/lexgui.js
CHANGED
|
@@ -12,7 +12,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
var LX = global.LX = {
|
|
15
|
-
version: "0.1.
|
|
15
|
+
version: "0.1.19",
|
|
16
16
|
ready: false,
|
|
17
17
|
components: [], // specific pre-build components
|
|
18
18
|
signals: {} // events and triggers
|
|
@@ -24,6 +24,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
24
24
|
function clamp (num, min, max) { return Math.min(Math.max(num, min), max) }
|
|
25
25
|
function round(num, n) { return +num.toFixed(n); }
|
|
26
26
|
|
|
27
|
+
function getSupportedDOMName( string )
|
|
28
|
+
{
|
|
29
|
+
return string.replace(/\s/g, '').replaceAll('@', '_').replaceAll('+', '_plus_').replaceAll('.', '');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
LX.getSupportedDOMName = getSupportedDOMName;
|
|
33
|
+
|
|
27
34
|
function has( component_name )
|
|
28
35
|
{
|
|
29
36
|
return (LX.components.indexOf( component_name ) > -1);
|
|
@@ -258,7 +265,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
258
265
|
e.stopPropagation();
|
|
259
266
|
global_search.classList.toggle('hidden');
|
|
260
267
|
global_search.querySelector('input').focus();
|
|
261
|
-
add_elements(undefined);
|
|
268
|
+
add_elements( undefined );
|
|
269
|
+
}
|
|
270
|
+
else
|
|
271
|
+
{
|
|
272
|
+
for( let c of LX.components )
|
|
273
|
+
if( LX[c].prototype.onKeyPressed )
|
|
274
|
+
{
|
|
275
|
+
const instances = LX.CodeEditor.getInstances();
|
|
276
|
+
for( let i of instances ) i.onKeyPressed( e );
|
|
277
|
+
}
|
|
262
278
|
}
|
|
263
279
|
});
|
|
264
280
|
|
|
@@ -342,18 +358,24 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
342
358
|
{
|
|
343
359
|
const instances = LX.CodeEditor.getInstances();
|
|
344
360
|
if(!instances.length) return;
|
|
345
|
-
|
|
346
|
-
const languages =
|
|
347
|
-
|
|
348
|
-
for( let l of languages ) {
|
|
349
|
-
|
|
350
|
-
const key = "
|
|
351
|
-
|
|
352
|
-
|
|
361
|
+
|
|
362
|
+
const languages = instances[ 0 ].languages;
|
|
363
|
+
|
|
364
|
+
for( let l of Object.keys( languages ) ) {
|
|
365
|
+
|
|
366
|
+
const key = "Language: " + l;
|
|
367
|
+
const icon = instances[ 0 ]._getFileIcon( null, languages[ l ].ext );
|
|
368
|
+
|
|
369
|
+
let value = icon.includes( 'fa-' ) ? "<i class='" + icon + "'></i>" :
|
|
370
|
+
"<img src='" + ( "https://raw.githubusercontent.com/jxarco/lexgui.js/master/" + icon ) + "'>";
|
|
371
|
+
|
|
372
|
+
value += key + " <span class='lang-ext'>(" + languages[ l ].ext + ")</span>";
|
|
373
|
+
if( key.toLowerCase().includes( filter ) ) {
|
|
374
|
+
add_element( value, () => {
|
|
353
375
|
for( let i of instances ) {
|
|
354
376
|
i._changeLanguage( l );
|
|
355
377
|
}
|
|
356
|
-
}, "", {});
|
|
378
|
+
}, "", {} );
|
|
357
379
|
}
|
|
358
380
|
}
|
|
359
381
|
}
|
|
@@ -1355,14 +1377,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1355
1377
|
|
|
1356
1378
|
_moveSplit( dt, force_animation = false, force_width = 0 ) {
|
|
1357
1379
|
|
|
1358
|
-
if(!this.type)
|
|
1359
|
-
throw("No split area");
|
|
1380
|
+
if( !this.type )
|
|
1381
|
+
throw( "No split area" );
|
|
1360
1382
|
|
|
1361
|
-
if(dt === undefined) //
|
|
1383
|
+
if( dt === undefined ) // Splitbar didn't move!
|
|
1362
1384
|
return;
|
|
1363
1385
|
|
|
1364
|
-
var a1 = this.sections[0];
|
|
1365
|
-
var a2 = this.sections[1];
|
|
1386
|
+
var a1 = this.sections[ 0 ];
|
|
1387
|
+
var a2 = this.sections[ 1 ];
|
|
1366
1388
|
var splitinfo = " - "+ LX.DEFAULT_SPLITBAR_SIZE + "px";
|
|
1367
1389
|
|
|
1368
1390
|
let transition = null;
|
|
@@ -1371,29 +1393,30 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1371
1393
|
// Remove transitions for this change..
|
|
1372
1394
|
transition = a1.root.style.transition;
|
|
1373
1395
|
a1.root.style.transition = a2.root.style.transition = "none";
|
|
1374
|
-
flushCss(a1.root);
|
|
1375
|
-
flushCss(a2.root);
|
|
1396
|
+
flushCss( a1.root );
|
|
1397
|
+
flushCss( a2.root );
|
|
1376
1398
|
}
|
|
1377
1399
|
|
|
1378
|
-
if(this.type == "horizontal")
|
|
1379
|
-
|
|
1380
|
-
var size = Math.max(a2.root.offsetWidth + dt, parseInt(a2.minWidth));
|
|
1400
|
+
if( this.type == "horizontal" )
|
|
1401
|
+
{
|
|
1402
|
+
var size = Math.max( a2.root.offsetWidth + dt, parseInt( a2.minWidth ) );
|
|
1381
1403
|
if( force_width ) size = force_width;
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
a1.root.style.minWidth = a1.minWidth + "px";
|
|
1386
|
-
|
|
1404
|
+
a1.root.style.width = "-moz-calc( 100% - " + size + "px " + splitinfo + " )";
|
|
1405
|
+
a1.root.style.width = "-webkit-calc( 100% - " + size + "px " + splitinfo + " )";
|
|
1406
|
+
a1.root.style.width = "calc( 100% - " + size + "px " + splitinfo + " )";
|
|
1407
|
+
a1.root.style.minWidth = parseInt( a1.minWidth ) + "px";
|
|
1408
|
+
a2.root.style.width = size + "px";
|
|
1409
|
+
if( a1.maxWidth != Infinity ) a2.root.style.minWidth = "calc( 100% - " + parseInt( a1.maxWidth ) + "px" + " )";
|
|
1387
1410
|
}
|
|
1388
|
-
else
|
|
1389
|
-
|
|
1411
|
+
else
|
|
1412
|
+
{
|
|
1390
1413
|
var size = Math.max((a2.root.offsetHeight + dt) + a2.offset, parseInt(a2.minHeight));
|
|
1391
1414
|
if( force_width ) size = force_width;
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1415
|
+
a1.root.style.height = "-moz-calc( 100% - " + size + "px " + splitinfo + " )";
|
|
1416
|
+
a1.root.style.height = "-webkit-calc( 100% - " + size + "px " + splitinfo + " )";
|
|
1417
|
+
a1.root.style.height = "calc( 100% - " + size + "px " + splitinfo + " )";
|
|
1395
1418
|
a1.root.style.minHeight = a1.minHeight + "px";
|
|
1396
|
-
|
|
1419
|
+
a2.root.style.height = ( size - a2.offset ) + "px";
|
|
1397
1420
|
}
|
|
1398
1421
|
|
|
1399
1422
|
if( !force_animation )
|
|
@@ -1541,11 +1564,23 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1541
1564
|
contentEl.style.display = isSelected ? "block" : "none";
|
|
1542
1565
|
contentEl.classList.add("lextabcontent");
|
|
1543
1566
|
|
|
1567
|
+
// Process icon
|
|
1568
|
+
if( options.icon )
|
|
1569
|
+
{
|
|
1570
|
+
if( options.icon.includes( 'fa-' ) ) // It's fontawesome icon...
|
|
1571
|
+
options.icon = "<i class='" + options.icon + "'></i>";
|
|
1572
|
+
else // an image..
|
|
1573
|
+
{
|
|
1574
|
+
const rootPath = "https://raw.githubusercontent.com/jxarco/lexgui.js/master/";
|
|
1575
|
+
options.icon = "<img src='" + ( rootPath + options.icon ) + "'>";
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1544
1579
|
// Create tab
|
|
1545
1580
|
let tabEl = document.createElement('span');
|
|
1546
1581
|
tabEl.dataset["name"] = name;
|
|
1547
1582
|
tabEl.className = "lexareatab" + (isSelected ? " selected" : "");
|
|
1548
|
-
tabEl.innerHTML = name;
|
|
1583
|
+
tabEl.innerHTML = (options.icon ?? "") + name;
|
|
1549
1584
|
tabEl.id = name.replace(/\s/g, '') + Tabs.TAB_ID++;
|
|
1550
1585
|
tabEl.title = options.title;
|
|
1551
1586
|
tabEl.selected = isSelected ?? false;
|
|
@@ -1592,9 +1627,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1592
1627
|
tabEl.addEventListener("mouseup", e => {
|
|
1593
1628
|
e.preventDefault();
|
|
1594
1629
|
e.stopPropagation();
|
|
1595
|
-
if(e.button == 1 ) {
|
|
1596
|
-
if(this.onclose)
|
|
1597
|
-
this.onclose( tabEl.dataset["name"] );
|
|
1630
|
+
if( e.button == 1 ) {
|
|
1598
1631
|
this.delete( tabEl.dataset["name"] );
|
|
1599
1632
|
}
|
|
1600
1633
|
});
|
|
@@ -1605,7 +1638,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1605
1638
|
e.preventDefault();
|
|
1606
1639
|
return;
|
|
1607
1640
|
}
|
|
1608
|
-
e.dataTransfer.setData("source", e.target.id);
|
|
1641
|
+
e.dataTransfer.setData( "source", e.target.id );
|
|
1609
1642
|
});
|
|
1610
1643
|
|
|
1611
1644
|
// Attach content
|
|
@@ -1634,6 +1667,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1634
1667
|
if(!tabEl || tabEl.fixed)
|
|
1635
1668
|
return;
|
|
1636
1669
|
|
|
1670
|
+
if( this.onclose )
|
|
1671
|
+
this.onclose( name );
|
|
1672
|
+
|
|
1637
1673
|
// Delete tab element
|
|
1638
1674
|
this.tabDOMs[ name ].remove();
|
|
1639
1675
|
delete this.tabDOMs[ name ];
|
|
@@ -2376,22 +2412,33 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
2376
2412
|
|
|
2377
2413
|
let item = document.createElement('li');
|
|
2378
2414
|
item.className = "lextreeitem " + "datalevel" + level + (is_parent ? " parent" : "") + (is_selected ? " selected" : "");
|
|
2379
|
-
item.id = node.id;
|
|
2415
|
+
item.id = LX.getSupportedDOMName( node.id );
|
|
2380
2416
|
item.tabIndex = "0";
|
|
2381
2417
|
|
|
2382
2418
|
// Select hierarchy icon
|
|
2383
|
-
let icon = "fa-solid fa-square"; // Default: no childs
|
|
2419
|
+
let icon = (this.options.skip_default_icon ?? true) ? "" : "fa-solid fa-square"; // Default: no childs
|
|
2384
2420
|
if( is_parent ) icon = node.closed ? "fa-solid fa-caret-right" : "fa-solid fa-caret-down";
|
|
2385
2421
|
item.innerHTML = "<a class='" + icon + " hierarchy'></a>";
|
|
2386
2422
|
|
|
2387
2423
|
// Add display icon
|
|
2388
2424
|
icon = node.icon;
|
|
2389
|
-
|
|
2425
|
+
|
|
2426
|
+
// Process icon
|
|
2427
|
+
if( node.icon )
|
|
2428
|
+
{
|
|
2429
|
+
if( node.icon.includes( 'fa-' ) ) // It's fontawesome icon...
|
|
2430
|
+
item.innerHTML += "<a class='" + node.icon + " tree-item-icon'></a>";
|
|
2431
|
+
else // an image..
|
|
2432
|
+
{
|
|
2433
|
+
const rootPath = "https://raw.githubusercontent.com/jxarco/lexgui.js/master/";
|
|
2434
|
+
item.innerHTML += "<img src='" + ( rootPath + node.icon ) + "'>";
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2390
2437
|
|
|
2391
2438
|
item.innerHTML += (node.rename ? "" : node.id);
|
|
2392
2439
|
|
|
2393
2440
|
item.setAttribute('draggable', true);
|
|
2394
|
-
item.style.paddingLeft = ((is_parent ? 0 : 3 ) + (3 + (level+1) *
|
|
2441
|
+
item.style.paddingLeft = ((is_parent ? 0 : 3 ) + (3 + (level+1) * 15)) + "px";
|
|
2395
2442
|
list.appendChild(item);
|
|
2396
2443
|
|
|
2397
2444
|
// Callbacks
|
|
@@ -2433,16 +2480,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
2433
2480
|
}
|
|
2434
2481
|
});
|
|
2435
2482
|
|
|
2436
|
-
|
|
2437
|
-
|
|
2483
|
+
item.addEventListener("dblclick", function() {
|
|
2484
|
+
if( that.options.rename ?? true )
|
|
2485
|
+
{
|
|
2438
2486
|
// Trigger rename
|
|
2439
2487
|
node.rename = true;
|
|
2440
2488
|
that.refresh();
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2489
|
+
}
|
|
2490
|
+
if( that.onevent )
|
|
2491
|
+
{
|
|
2492
|
+
const event = new TreeEvent(TreeEvent.NODE_DBLCLICKED, node);
|
|
2493
|
+
that.onevent( event );
|
|
2494
|
+
}
|
|
2495
|
+
});
|
|
2446
2496
|
|
|
2447
2497
|
item.addEventListener("contextmenu", e => {
|
|
2448
2498
|
e.preventDefault();
|
|
@@ -2480,7 +2530,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
2480
2530
|
else if( e.key == "ArrowUp" || e.key == "ArrowDown" ) // Unique or zero selected
|
|
2481
2531
|
{
|
|
2482
2532
|
var selected = this.selected.length > 1 ? (e.key == "ArrowUp" ? this.selected.shift() : this.selected.pop()) : this.selected[0];
|
|
2483
|
-
var el = this.domEl.querySelector("#" + selected.id);
|
|
2533
|
+
var el = this.domEl.querySelector("#" + LX.getSupportedDOMName( selected.id ) );
|
|
2484
2534
|
var sibling = e.key == "ArrowUp" ? el.previousSibling : el.nextSibling;
|
|
2485
2535
|
if( sibling ) sibling.click();
|
|
2486
2536
|
}
|
|
@@ -2508,7 +2558,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
2508
2558
|
that.onevent( event );
|
|
2509
2559
|
}
|
|
2510
2560
|
|
|
2511
|
-
node.id = this.value;
|
|
2561
|
+
node.id = LX.getSupportedDOMName( this.value );
|
|
2512
2562
|
delete node.rename;
|
|
2513
2563
|
that.frefresh( node.id );
|
|
2514
2564
|
list.querySelector("#" + this.value).classList.add('selected');
|
|
@@ -2659,21 +2709,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
2659
2709
|
}
|
|
2660
2710
|
}
|
|
2661
2711
|
|
|
2662
|
-
refresh(newData, selectedId) {
|
|
2712
|
+
refresh( newData, selectedId ) {
|
|
2663
2713
|
this.data = newData ?? this.data;
|
|
2664
|
-
this.domEl.querySelector("ul").innerHTML = "";
|
|
2714
|
+
this.domEl.querySelector( "ul" ).innerHTML = "";
|
|
2665
2715
|
this._create_item( null, this.data, 0, selectedId );
|
|
2666
2716
|
}
|
|
2667
|
-
|
|
2717
|
+
|
|
2668
2718
|
/* Refreshes the tree and focuses current element */
|
|
2669
2719
|
frefresh( id ) {
|
|
2670
2720
|
this.refresh();
|
|
2671
|
-
var el = this.domEl.querySelector("#" + id);
|
|
2672
|
-
if(el) el.focus();
|
|
2721
|
+
var el = this.domEl.querySelector( "#" + id );
|
|
2722
|
+
if( el ) el.focus();
|
|
2673
2723
|
}
|
|
2674
|
-
|
|
2675
|
-
select(id) {
|
|
2676
|
-
this.refresh(null, id);
|
|
2724
|
+
|
|
2725
|
+
select( id ) {
|
|
2726
|
+
this.refresh( null, id );
|
|
2677
2727
|
}
|
|
2678
2728
|
}
|
|
2679
2729
|
|
|
@@ -5840,7 +5890,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5840
5890
|
const hasSubmenu = o[ k ].length;
|
|
5841
5891
|
let entry = document.createElement('div');
|
|
5842
5892
|
entry.className = "lexcontextmenuentry" + (o[ 'className' ] ? " " + o[ 'className' ] : "" );
|
|
5843
|
-
entry.id = o.id ?? ("eId" +
|
|
5893
|
+
entry.id = o.id ?? ("eId" + getSupportedDOMName( k ));
|
|
5844
5894
|
entry.innerHTML = "";
|
|
5845
5895
|
const icon = o[ 'icon' ];
|
|
5846
5896
|
if(icon) {
|
|
@@ -5987,7 +6037,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5987
6037
|
for( let item of this.items )
|
|
5988
6038
|
{
|
|
5989
6039
|
let key = Object.keys(item)[0];
|
|
5990
|
-
let pKey = "eId" +
|
|
6040
|
+
let pKey = "eId" + getSupportedDOMName( key );
|
|
5991
6041
|
|
|
5992
6042
|
// Item already created
|
|
5993
6043
|
const id = "#" + (item.id ?? pKey);
|
|
@@ -6003,10 +6053,6 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
6003
6053
|
|
|
6004
6054
|
this.colors[ token ] = color;
|
|
6005
6055
|
}
|
|
6006
|
-
|
|
6007
|
-
_getSupportedDOMName( key ) {
|
|
6008
|
-
return key.replace(/\s/g, '').replaceAll('@', '_').replaceAll('+', '_plus_');
|
|
6009
|
-
}
|
|
6010
6056
|
};
|
|
6011
6057
|
|
|
6012
6058
|
LX.ContextMenu = ContextMenu;
|