lexgui 0.6.4 → 0.6.6
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 +10 -10
- package/build/components/docmaker.js +417 -0
- package/build/components/nodegraph.js +12 -12
- package/build/components/timeline.js +170 -175
- package/build/lexgui-docs.css +410 -0
- package/build/lexgui.css +11 -0
- package/build/lexgui.js +1226 -1139
- package/build/lexgui.min.css +1 -1
- package/build/lexgui.min.js +1 -1
- package/build/lexgui.module.js +1236 -1149
- package/build/lexgui.module.min.js +1 -1
- package/changelog.md +21 -1
- package/demo.js +1 -1
- package/examples/all_widgets.html +1 -1
- package/examples/editor.html +1 -1
- package/package.json +1 -1
|
@@ -2097,7 +2097,7 @@ class CodeEditor {
|
|
|
2097
2097
|
if( deltaY >= 0 )
|
|
2098
2098
|
{
|
|
2099
2099
|
while( deltaY < ( cursorSelections.childElementCount - 1 ) )
|
|
2100
|
-
LX.
|
|
2100
|
+
LX.deleteElement( cursorSelections.lastChild );
|
|
2101
2101
|
|
|
2102
2102
|
for(let i = fromY; i <= toY; i++){
|
|
2103
2103
|
|
|
@@ -2148,7 +2148,7 @@ class CodeEditor {
|
|
|
2148
2148
|
else // Selection goes up...
|
|
2149
2149
|
{
|
|
2150
2150
|
while( Math.abs( deltaY ) < ( cursorSelections.childElementCount - 1 ) )
|
|
2151
|
-
LX.
|
|
2151
|
+
LX.deleteElement( cursorSelections.firstChild );
|
|
2152
2152
|
|
|
2153
2153
|
for( let i = toY; i <= fromY; i++ ){
|
|
2154
2154
|
|
|
@@ -2837,7 +2837,7 @@ class CodeEditor {
|
|
|
2837
2837
|
// Single line
|
|
2838
2838
|
if( !force )
|
|
2839
2839
|
{
|
|
2840
|
-
LX.
|
|
2840
|
+
LX.deleteElement( this.code.childNodes[ local_line_num ] );
|
|
2841
2841
|
this.code.insertChildAtIndex( document.createElement( 'pre' ), local_line_num );
|
|
2842
2842
|
}
|
|
2843
2843
|
|
|
@@ -3470,7 +3470,7 @@ class CodeEditor {
|
|
|
3470
3470
|
|
|
3471
3471
|
if( cursor )
|
|
3472
3472
|
{
|
|
3473
|
-
LX.
|
|
3473
|
+
LX.deleteElement( this.selections[ cursor.name ] );
|
|
3474
3474
|
delete this.selections[ cursor.name ];
|
|
3475
3475
|
delete cursor.selection;
|
|
3476
3476
|
}
|
|
@@ -3478,7 +3478,7 @@ class CodeEditor {
|
|
|
3478
3478
|
{
|
|
3479
3479
|
for( let cursor of this.cursors.children )
|
|
3480
3480
|
{
|
|
3481
|
-
LX.
|
|
3481
|
+
LX.deleteElement( this.selections[ cursor.name ] );
|
|
3482
3482
|
delete this.selections[ cursor.name ];
|
|
3483
3483
|
delete cursor.selection;
|
|
3484
3484
|
}
|
|
@@ -3667,9 +3667,9 @@ class CodeEditor {
|
|
|
3667
3667
|
|
|
3668
3668
|
removeCursor( cursor ) {
|
|
3669
3669
|
|
|
3670
|
-
LX.
|
|
3670
|
+
LX.deleteElement( this.selections[ cursor.name ] );
|
|
3671
3671
|
delete this.selections[ cursor.name ];
|
|
3672
|
-
LX.
|
|
3672
|
+
LX.deleteElement( cursor );
|
|
3673
3673
|
}
|
|
3674
3674
|
|
|
3675
3675
|
resetCursorPos( flag, cursor ) {
|
|
@@ -3962,7 +3962,7 @@ class CodeEditor {
|
|
|
3962
3962
|
line.appendChild( text );
|
|
3963
3963
|
text.innerText = char;
|
|
3964
3964
|
var rect = text.getBoundingClientRect();
|
|
3965
|
-
LX.
|
|
3965
|
+
LX.deleteElement( parentContainer );
|
|
3966
3966
|
const bb = [ use_floating ? rect.width : Math.floor( rect.width ), use_floating ? rect.height : Math.floor( rect.height ) ];
|
|
3967
3967
|
return get_bb ? bb : bb[ 0 ];
|
|
3968
3968
|
}
|
|
@@ -4238,7 +4238,7 @@ class CodeEditor {
|
|
|
4238
4238
|
|
|
4239
4239
|
else if( this._lastResult )
|
|
4240
4240
|
{
|
|
4241
|
-
LX.
|
|
4241
|
+
LX.deleteElement( this._lastResult.dom );
|
|
4242
4242
|
delete this._lastResult;
|
|
4243
4243
|
}
|
|
4244
4244
|
|
|
@@ -4261,7 +4261,7 @@ class CodeEditor {
|
|
|
4261
4261
|
|
|
4262
4262
|
if( this._lastResult )
|
|
4263
4263
|
{
|
|
4264
|
-
LX.
|
|
4264
|
+
LX.deleteElement( this._lastResult.dom );
|
|
4265
4265
|
cursorData = this._lastResult.pos;
|
|
4266
4266
|
delete this._lastResult;
|
|
4267
4267
|
}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
// @jxarco
|
|
2
|
+
|
|
3
|
+
import { LX } from 'lexgui';
|
|
4
|
+
|
|
5
|
+
if( !LX )
|
|
6
|
+
{
|
|
7
|
+
throw( "lexgui.js missing!" );
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const CPP_KEY_WORDS = ['int', 'float', 'double', 'bool', 'char', 'wchar_t', 'const', 'static_cast', 'dynamic_cast', 'new', 'delete', 'void', 'true', 'false', 'auto', 'struct', 'typedef', 'nullptr', 'NULL', 'unsigned', 'namespace'];
|
|
11
|
+
const CLASS_WORDS = ['uint32_t', 'uint64_t', 'uint8_t'];
|
|
12
|
+
const STATEMENT_WORDS = ['for', 'if', 'else', 'return', 'continue', 'break', 'case', 'switch', 'while', 'import', 'from'];
|
|
13
|
+
|
|
14
|
+
const JS_KEY_WORDS = ['var', 'let', 'const', 'static', 'function', 'null', 'undefined', 'new', 'delete', 'true', 'false', 'NaN', 'this'];
|
|
15
|
+
const HTML_ATTRIBUTES = ['html', 'charset', 'rel', 'src', 'href', 'crossorigin', 'type', 'lang'];
|
|
16
|
+
const HTML_TAGS = ['html', 'DOCTYPE', 'head', 'meta', 'title', 'link', 'script', 'body', 'style'];
|
|
17
|
+
|
|
18
|
+
let mainContainer = document.body;
|
|
19
|
+
|
|
20
|
+
function SET_DOM_TARGET( element )
|
|
21
|
+
{
|
|
22
|
+
mainContainer = element;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
window.SET_DOM_TARGET = SET_DOM_TARGET;
|
|
26
|
+
|
|
27
|
+
function MAKE_LINE_BREAK()
|
|
28
|
+
{
|
|
29
|
+
mainContainer.appendChild( document.createElement('br') );
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
window.MAKE_LINE_BREAK = MAKE_LINE_BREAK;
|
|
33
|
+
|
|
34
|
+
function MAKE_HEADER( string, type, id )
|
|
35
|
+
{
|
|
36
|
+
console.assert(string && type);
|
|
37
|
+
let header = document.createElement(type);
|
|
38
|
+
header.innerHTML = string;
|
|
39
|
+
if(id) header.id = id;
|
|
40
|
+
mainContainer.appendChild( header );
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
window.MAKE_HEADER = MAKE_HEADER;
|
|
44
|
+
|
|
45
|
+
function MAKE_PARAGRAPH( string, sup )
|
|
46
|
+
{
|
|
47
|
+
console.assert(string);
|
|
48
|
+
let paragraph = document.createElement(sup ? 'sup' : 'p');
|
|
49
|
+
paragraph.className = "leading-relaxed";
|
|
50
|
+
paragraph.innerHTML = string;
|
|
51
|
+
mainContainer.appendChild( paragraph );
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
window.MAKE_PARAGRAPH = MAKE_PARAGRAPH;
|
|
55
|
+
|
|
56
|
+
function MAKE_CODE( text, language = "js" )
|
|
57
|
+
{
|
|
58
|
+
console.assert(text);
|
|
59
|
+
|
|
60
|
+
text.replaceAll('<', '<');
|
|
61
|
+
text.replaceAll('>', '>');
|
|
62
|
+
|
|
63
|
+
let highlight = "";
|
|
64
|
+
let content = "";
|
|
65
|
+
|
|
66
|
+
const getHTML = ( h, c ) => {
|
|
67
|
+
return `<span class="${ h }">${ c }</span>`;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
for( let i = 0; i < text.length; ++i )
|
|
71
|
+
{
|
|
72
|
+
const char = text[ i ];
|
|
73
|
+
const string = text.substr( i );
|
|
74
|
+
|
|
75
|
+
const endLineIdx = string.indexOf( '\n' );
|
|
76
|
+
const line = string.substring( 0, endLineIdx > -1 ? endLineIdx : undefined );
|
|
77
|
+
|
|
78
|
+
if( char == '@' )
|
|
79
|
+
{
|
|
80
|
+
const str = line.substr( 1 );
|
|
81
|
+
|
|
82
|
+
if ( !( str.indexOf( '@' ) > -1 ) && !( str.indexOf( '[' ) > -1 ) )
|
|
83
|
+
{
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let html = null;
|
|
88
|
+
|
|
89
|
+
const tagIndex = str.indexOf( '@' );
|
|
90
|
+
const skipTag = ( str[ tagIndex - 1 ] == '|' );
|
|
91
|
+
|
|
92
|
+
// Highlight is specified
|
|
93
|
+
if( text[ i + 1 ] == '[' )
|
|
94
|
+
{
|
|
95
|
+
highlight = str.substr( 1, 3 );
|
|
96
|
+
content = str.substring( 5, tagIndex );
|
|
97
|
+
|
|
98
|
+
if( skipTag )
|
|
99
|
+
{
|
|
100
|
+
const newString = str.substring( 6 + content.length );
|
|
101
|
+
const preContent = content;
|
|
102
|
+
const postContent = newString.substring( 0, newString.indexOf( '@' ) );
|
|
103
|
+
const finalContent = preContent.substring( 0, preContent.length - 1 ) + '@' + postContent;
|
|
104
|
+
html = getHTML( highlight, finalContent );
|
|
105
|
+
|
|
106
|
+
const ogContent = preContent + '@' + postContent;
|
|
107
|
+
text = text.replace( `@[${ highlight }]${ ogContent }@`, html );
|
|
108
|
+
}
|
|
109
|
+
else
|
|
110
|
+
{
|
|
111
|
+
html = getHTML( highlight, content );
|
|
112
|
+
text = text.replace( `@[${ highlight }]${ content }@`, html );
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else
|
|
116
|
+
{
|
|
117
|
+
content = str.substring( 0, tagIndex );
|
|
118
|
+
if( skipTag )
|
|
119
|
+
{
|
|
120
|
+
const preContent = str.substring( 0, str.indexOf( '@' ) - 1 );
|
|
121
|
+
content = str.substring( preContent.length + 1 );
|
|
122
|
+
content = preContent + content.substring( 0, content.substring( 1 ).indexOf( '@' ) + 1 );
|
|
123
|
+
text = text.substr( 0, i ) + '@' + content + '@' + text.substr( i + content.length + 3 );
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if( language == "cpp" && CPP_KEY_WORDS.includes( content ) )
|
|
127
|
+
{
|
|
128
|
+
highlight = "kwd";
|
|
129
|
+
}
|
|
130
|
+
else if( language == "js" && JS_KEY_WORDS.includes( content ) )
|
|
131
|
+
{
|
|
132
|
+
highlight = "kwd";
|
|
133
|
+
}
|
|
134
|
+
else if( CLASS_WORDS.includes( content ) )
|
|
135
|
+
{
|
|
136
|
+
highlight = "cls";
|
|
137
|
+
}
|
|
138
|
+
else if( STATEMENT_WORDS.includes( content ) )
|
|
139
|
+
{
|
|
140
|
+
highlight = "lit";
|
|
141
|
+
}
|
|
142
|
+
else if( HTML_TAGS.includes( content ) )
|
|
143
|
+
{
|
|
144
|
+
highlight = "tag";
|
|
145
|
+
}
|
|
146
|
+
else if( HTML_ATTRIBUTES.includes( content ) )
|
|
147
|
+
{
|
|
148
|
+
highlight = "atn";
|
|
149
|
+
}
|
|
150
|
+
else if( ( content[ 0 ] == '"' && content[ content.length - 1 ] == '"' ) ||
|
|
151
|
+
( content[ 0 ] == "'" && content[ content.length - 1 ] == "'" ) ||
|
|
152
|
+
( content[ 0 ] == "`" && content[ content.length - 1 ] == "`" ) )
|
|
153
|
+
{
|
|
154
|
+
highlight = "str";
|
|
155
|
+
}
|
|
156
|
+
else if( parseFloat( content ) != NaN )
|
|
157
|
+
{
|
|
158
|
+
highlight = "dec";
|
|
159
|
+
}
|
|
160
|
+
else
|
|
161
|
+
{
|
|
162
|
+
console.error( "ERROR[Code Parsing]: Unknown highlight type: " + content );
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
html = getHTML( highlight, content );
|
|
167
|
+
text = text.replace( `@${ content }@`, html );
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
i += ( html.length - 1 );
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
let container = document.createElement('div');
|
|
175
|
+
container.className = "code-container";
|
|
176
|
+
let pre = document.createElement('pre');
|
|
177
|
+
let code = document.createElement('code');
|
|
178
|
+
code.innerHTML = text;
|
|
179
|
+
|
|
180
|
+
let button = document.createElement('button');
|
|
181
|
+
button.title = "Copy code sample";
|
|
182
|
+
button.appendChild(LX.makeIcon( "Copy" ));
|
|
183
|
+
button.addEventListener('click', COPY_SNIPPET.bind(this, button));
|
|
184
|
+
container.appendChild( button );
|
|
185
|
+
|
|
186
|
+
pre.appendChild( code );
|
|
187
|
+
container.appendChild( pre );
|
|
188
|
+
mainContainer.appendChild( container );
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
window.MAKE_CODE = MAKE_CODE;
|
|
192
|
+
|
|
193
|
+
function MAKE_BULLET_LIST( list )
|
|
194
|
+
{
|
|
195
|
+
console.assert(list && list.length > 0);
|
|
196
|
+
let ul = document.createElement('ul');
|
|
197
|
+
for( var el of list ) {
|
|
198
|
+
let li = document.createElement('li');
|
|
199
|
+
li.className = "leading-loose";
|
|
200
|
+
li.innerHTML = el;
|
|
201
|
+
ul.appendChild( li );
|
|
202
|
+
}
|
|
203
|
+
mainContainer.appendChild( ul );
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
window.MAKE_BULLET_LIST = MAKE_BULLET_LIST;
|
|
207
|
+
|
|
208
|
+
function ADD_CODE_LIST_ITEM( item, target )
|
|
209
|
+
{
|
|
210
|
+
target = target ?? window.listQueued;
|
|
211
|
+
let split = (item.constructor === Array);
|
|
212
|
+
if( split && item[0].constructor === Array ) {
|
|
213
|
+
MAKE_CODE_BULLET_LIST( item, target );
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
let li = document.createElement('li');
|
|
217
|
+
li.className = "leading-loose";
|
|
218
|
+
li.innerHTML = split ? ( item.length == 2 ? INLINE_CODE( item[0] ) + ": " + item[1] : INLINE_CODE( item[0] + " <span class='desc'>(" + item[1] + ")</span>" ) + ": " + item[2] ) : INLINE_CODE( item );
|
|
219
|
+
target.appendChild( li );
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
window.ADD_CODE_LIST_ITEM = ADD_CODE_LIST_ITEM;
|
|
223
|
+
|
|
224
|
+
function MAKE_CLASS_METHOD( name, desc, params, ret )
|
|
225
|
+
{
|
|
226
|
+
START_CODE_BULLET_LIST();
|
|
227
|
+
let paramsHTML = "";
|
|
228
|
+
for( var p of params ) {
|
|
229
|
+
const name = p[ 0 ];
|
|
230
|
+
const type = p[ 1 ];
|
|
231
|
+
paramsHTML += name + ": <span class='desc'>" + type + "</span>" + ( params.indexOf( p ) != (params.length - 1) ? ', ' : '' );
|
|
232
|
+
}
|
|
233
|
+
let li = document.createElement('li');
|
|
234
|
+
li.innerHTML = INLINE_CODE( "<span class='method'>" + name + " (" + paramsHTML + ")" + ( ret ? (": " + ret) : "" ) + "</span>" );
|
|
235
|
+
window.listQueued.appendChild( li );
|
|
236
|
+
END_CODE_BULLET_LIST();
|
|
237
|
+
MAKE_PARAGRAPH( desc );
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
window.MAKE_CLASS_METHOD = MAKE_CLASS_METHOD;
|
|
241
|
+
|
|
242
|
+
function MAKE_CLASS_CONSTRUCTOR( name, params, language = "js" )
|
|
243
|
+
{
|
|
244
|
+
let paramsHTML = "";
|
|
245
|
+
for( var p of params ) {
|
|
246
|
+
const str1 = p[ 0 ]; // cpp: param js: name
|
|
247
|
+
const str2 = p[ 1 ]; // cpp: defaultValue js: type
|
|
248
|
+
if( language == "cpp" ) {
|
|
249
|
+
paramsHTML += str1 + ( str2 ? " = <span class='desc'>" + str2 + "</span>" : "" ) + ( params.indexOf( p ) != (params.length - 1) ? ', ' : '' );
|
|
250
|
+
} else if( language == "js" ) {
|
|
251
|
+
paramsHTML += str1 + ": <span class='desc'>" + str2 + "</span>" + ( params.indexOf( p ) != (params.length - 1) ? ', ' : '' );
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
let pr = document.createElement('p');
|
|
255
|
+
pr.innerHTML = INLINE_CODE( "<span class='constructor'>" + name + "(" + paramsHTML + ")" + "</span>" );
|
|
256
|
+
mainContainer.appendChild( pr );
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
window.MAKE_CLASS_CONSTRUCTOR = MAKE_CLASS_CONSTRUCTOR;
|
|
260
|
+
|
|
261
|
+
function MAKE_CODE_BULLET_LIST( list, target )
|
|
262
|
+
{
|
|
263
|
+
console.assert(list && list.length > 0);
|
|
264
|
+
let ul = document.createElement('ul');
|
|
265
|
+
for( var el of list ) {
|
|
266
|
+
ADD_CODE_LIST_ITEM( el, ul );
|
|
267
|
+
}
|
|
268
|
+
if( target ) {
|
|
269
|
+
target.appendChild( ul );
|
|
270
|
+
} else {
|
|
271
|
+
mainContainer.appendChild( ul );
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
window.MAKE_CODE_BULLET_LIST = MAKE_CODE_BULLET_LIST;
|
|
276
|
+
|
|
277
|
+
function START_CODE_BULLET_LIST()
|
|
278
|
+
{
|
|
279
|
+
let ul = document.createElement('ul');
|
|
280
|
+
window.listQueued = ul;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
window.START_CODE_BULLET_LIST = START_CODE_BULLET_LIST;
|
|
284
|
+
|
|
285
|
+
function END_CODE_BULLET_LIST()
|
|
286
|
+
{
|
|
287
|
+
console.assert( window.listQueued );
|
|
288
|
+
mainContainer.appendChild( window.listQueued );
|
|
289
|
+
window.listQueued = undefined;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
window.END_CODE_BULLET_LIST = END_CODE_BULLET_LIST;
|
|
293
|
+
|
|
294
|
+
function INLINE_LINK( string, href )
|
|
295
|
+
{
|
|
296
|
+
console.assert(string && href);
|
|
297
|
+
return `<a href="` + href + `">` + string + `</a>`;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
window.INLINE_LINK = INLINE_LINK;
|
|
301
|
+
|
|
302
|
+
function INLINE_PAGE( string, page )
|
|
303
|
+
{
|
|
304
|
+
console.assert(string && page);
|
|
305
|
+
return `<a onclick="loadPage('` + page + `')">` + string + `</a>`;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
window.INLINE_PAGE = INLINE_PAGE;
|
|
309
|
+
|
|
310
|
+
function INLINE_CODE( string, codeClass )
|
|
311
|
+
{
|
|
312
|
+
console.assert(string);
|
|
313
|
+
return `<code class="inline ${ codeClass ?? "" }">` + string + `</code>`;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
window.INLINE_CODE = INLINE_CODE;
|
|
317
|
+
|
|
318
|
+
function COPY_SNIPPET( b )
|
|
319
|
+
{
|
|
320
|
+
b.innerHTML = "";
|
|
321
|
+
b.appendChild(LX.makeIcon( "Check" ));
|
|
322
|
+
b.classList.add('copied');
|
|
323
|
+
|
|
324
|
+
setTimeout( () => {
|
|
325
|
+
b.innerHTML = "";
|
|
326
|
+
b.appendChild(LX.makeIcon( "Copy" ));
|
|
327
|
+
b.classList.remove('copied');
|
|
328
|
+
}, 2000 );
|
|
329
|
+
|
|
330
|
+
navigator.clipboard.writeText( b.dataset['snippet'] ?? b.parentElement.innerText );
|
|
331
|
+
console.log("Copied!");
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function INSERT_IMAGE( src, caption = "", parent )
|
|
335
|
+
{
|
|
336
|
+
let img = document.createElement('img');
|
|
337
|
+
img.src = src;
|
|
338
|
+
img.alt = caption;
|
|
339
|
+
img.className = "my-1";
|
|
340
|
+
( parent ?? mainContainer ).appendChild( img );
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
window.INSERT_IMAGE = INSERT_IMAGE;
|
|
344
|
+
|
|
345
|
+
function INSERT_IMAGES( sources, captions = [], width, height )
|
|
346
|
+
{
|
|
347
|
+
const mobile = navigator && /Android|iPhone/i.test(navigator.userAgent);
|
|
348
|
+
|
|
349
|
+
if( !mobile )
|
|
350
|
+
{
|
|
351
|
+
let div = document.createElement('div');
|
|
352
|
+
div.style.width = width ?? "auto";
|
|
353
|
+
div.style.height = height ?? "256px";
|
|
354
|
+
div.className = "flex flex-row justify-center";
|
|
355
|
+
|
|
356
|
+
for( let i = 0; i < sources.length; ++i )
|
|
357
|
+
{
|
|
358
|
+
INSERT_IMAGE( sources[ i ], captions[ i ], div );
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
mainContainer.appendChild( div );
|
|
362
|
+
}
|
|
363
|
+
else
|
|
364
|
+
{
|
|
365
|
+
for( let i = 0; i < sources.length; ++i )
|
|
366
|
+
{
|
|
367
|
+
INSERT_IMAGE( sources[ i ], captions[ i ] );
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
window.INSERT_IMAGES = INSERT_IMAGES;
|
|
373
|
+
|
|
374
|
+
function INSERT_VIDEO( src, caption = "", controls = true, autoplay = false )
|
|
375
|
+
{
|
|
376
|
+
let video = document.createElement( 'video' );
|
|
377
|
+
video.src = src;
|
|
378
|
+
video.controls = controls;
|
|
379
|
+
video.autoplay = autoplay;
|
|
380
|
+
if( autoplay )
|
|
381
|
+
{
|
|
382
|
+
video.muted = true;
|
|
383
|
+
}
|
|
384
|
+
video.loop = true;
|
|
385
|
+
video.alt = caption;
|
|
386
|
+
mainContainer.appendChild( video );
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
window.INSERT_VIDEO = INSERT_VIDEO;
|
|
390
|
+
|
|
391
|
+
function MAKE_NOTE( string, title = "Note" )
|
|
392
|
+
{
|
|
393
|
+
console.assert( string );
|
|
394
|
+
|
|
395
|
+
let note = document.createElement( 'div' );
|
|
396
|
+
note.className = "note";
|
|
397
|
+
|
|
398
|
+
let header = document.createElement( 'div' );
|
|
399
|
+
header.className = "note-header";
|
|
400
|
+
header.appendChild( LX.makeIcon( "NotepadText" ) );
|
|
401
|
+
header.innerHTML += "<b>" + title + "</b>";
|
|
402
|
+
|
|
403
|
+
let body = document.createElement( 'div' );
|
|
404
|
+
body.className = "note-body";
|
|
405
|
+
body.innerHTML = string;
|
|
406
|
+
|
|
407
|
+
note.appendChild( header );
|
|
408
|
+
note.appendChild( body );
|
|
409
|
+
mainContainer.appendChild( note );
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
window.MAKE_NOTE = MAKE_NOTE;
|
|
413
|
+
|
|
414
|
+
export { SET_DOM_TARGET, MAKE_LINE_BREAK, MAKE_HEADER, MAKE_PARAGRAPH, MAKE_CODE, MAKE_BULLET_LIST,
|
|
415
|
+
MAKE_CLASS_METHOD, MAKE_CLASS_CONSTRUCTOR, MAKE_CODE_BULLET_LIST, START_CODE_BULLET_LIST, ADD_CODE_LIST_ITEM,
|
|
416
|
+
END_CODE_BULLET_LIST, INLINE_LINK, INLINE_PAGE, INLINE_CODE, INSERT_IMAGE, INSERT_IMAGES, INSERT_VIDEO, MAKE_NOTE
|
|
417
|
+
}
|
|
@@ -393,7 +393,7 @@ class GraphEditor {
|
|
|
393
393
|
|
|
394
394
|
this.clear();
|
|
395
395
|
|
|
396
|
-
graph.id = graph.id ?? graph.constructor.name + '-' + LX.
|
|
396
|
+
graph.id = graph.id ?? graph.constructor.name + '-' + LX.guidGenerator();
|
|
397
397
|
|
|
398
398
|
this.graphs[ graph.id ] = graph;
|
|
399
399
|
|
|
@@ -730,7 +730,7 @@ class GraphEditor {
|
|
|
730
730
|
// {
|
|
731
731
|
// var panel = new LX.Panel();
|
|
732
732
|
|
|
733
|
-
// p.signal = "@" + LX.
|
|
733
|
+
// p.signal = "@" + LX.guidGenerator() + node.title;
|
|
734
734
|
|
|
735
735
|
// switch( p.type )
|
|
736
736
|
// {
|
|
@@ -862,7 +862,7 @@ class GraphEditor {
|
|
|
862
862
|
|
|
863
863
|
this._addNodeIOEvents( nodeContainer );
|
|
864
864
|
|
|
865
|
-
const id = node.id ?? node.title.toLowerCase().replaceAll( /\s/g, '-' ) + '-' + LX.
|
|
865
|
+
const id = node.id ?? node.title.toLowerCase().replaceAll( /\s/g, '-' ) + '-' + LX.guidGenerator();
|
|
866
866
|
this.nodes[ id ] = { data: node, dom: nodeContainer };
|
|
867
867
|
|
|
868
868
|
node.id = id;
|
|
@@ -1035,7 +1035,7 @@ class GraphEditor {
|
|
|
1035
1035
|
if( !this._onLink( e ) )
|
|
1036
1036
|
{
|
|
1037
1037
|
// Delete entire SVG if not a successful connection..
|
|
1038
|
-
LX.
|
|
1038
|
+
LX.deleteElement( this._generatingLink.path ? this._generatingLink.path.parentElement : null );
|
|
1039
1039
|
}
|
|
1040
1040
|
|
|
1041
1041
|
delete this._generatingLink;
|
|
@@ -1272,7 +1272,7 @@ class GraphEditor {
|
|
|
1272
1272
|
return;
|
|
1273
1273
|
}
|
|
1274
1274
|
|
|
1275
|
-
LX.
|
|
1275
|
+
LX.deleteElement( el );
|
|
1276
1276
|
|
|
1277
1277
|
// Delete from the editor
|
|
1278
1278
|
|
|
@@ -1302,7 +1302,7 @@ class GraphEditor {
|
|
|
1302
1302
|
{
|
|
1303
1303
|
var link = this.currentGraph.links[ key ][ i ];
|
|
1304
1304
|
|
|
1305
|
-
LX.
|
|
1305
|
+
LX.deleteElement( link.path.parentElement );
|
|
1306
1306
|
|
|
1307
1307
|
const targetNodeId = targetIsInput ? link.inputNode : link.outputNode;
|
|
1308
1308
|
|
|
@@ -1344,7 +1344,7 @@ class GraphEditor {
|
|
|
1344
1344
|
_deleteGroup( groupId ) {
|
|
1345
1345
|
|
|
1346
1346
|
const dom = this.groups[ groupId ];
|
|
1347
|
-
LX.
|
|
1347
|
+
LX.deleteElement( dom );
|
|
1348
1348
|
|
|
1349
1349
|
// Delete from the editor
|
|
1350
1350
|
|
|
@@ -1428,7 +1428,7 @@ class GraphEditor {
|
|
|
1428
1428
|
var links = this._getLinks( targetId, nodeId );
|
|
1429
1429
|
|
|
1430
1430
|
var linkIdx = links.findIndex( i => ( i.inputIdx == srcIndex && i.outputIdx == targetIndex ) );
|
|
1431
|
-
LX.
|
|
1431
|
+
LX.deleteElement( links[ linkIdx ].path.parentElement );
|
|
1432
1432
|
links.splice( linkIdx, 1 );
|
|
1433
1433
|
|
|
1434
1434
|
// Input has no longer any connected link
|
|
@@ -1478,7 +1478,7 @@ class GraphEditor {
|
|
|
1478
1478
|
var links = this._getLinks( nodeId, targetId );
|
|
1479
1479
|
|
|
1480
1480
|
var linkIdx = links.findIndex( i => ( i.inputIdx == targetIndex && i.outputIdx == srcIndex ) );
|
|
1481
|
-
LX.
|
|
1481
|
+
LX.deleteElement( links[ linkIdx ].path.parentElement );
|
|
1482
1482
|
links.splice( linkIdx, 1 );
|
|
1483
1483
|
|
|
1484
1484
|
// Remove a connection from the output connections
|
|
@@ -1674,7 +1674,7 @@ class GraphEditor {
|
|
|
1674
1674
|
const linkInfo = Object.assign( { }, this._generatingLink );
|
|
1675
1675
|
|
|
1676
1676
|
// Delete old link
|
|
1677
|
-
LX.
|
|
1677
|
+
LX.deleteElement( this._generatingLink.path ? this._generatingLink.path.parentElement : null );
|
|
1678
1678
|
delete this._generatingLink;
|
|
1679
1679
|
|
|
1680
1680
|
// Open contextmenu to auto-connect something..
|
|
@@ -1688,7 +1688,7 @@ class GraphEditor {
|
|
|
1688
1688
|
|
|
1689
1689
|
this._selectNodesInBox( this._boxSelecting, this._mousePosition, e.altKey );
|
|
1690
1690
|
|
|
1691
|
-
LX.
|
|
1691
|
+
LX.deleteElement( this._currentBoxSelectionSVG );
|
|
1692
1692
|
|
|
1693
1693
|
delete this._currentBoxSelectionSVG;
|
|
1694
1694
|
delete this._boxSelecting;
|
|
@@ -2526,7 +2526,7 @@ class GraphEditor {
|
|
|
2526
2526
|
return;
|
|
2527
2527
|
}
|
|
2528
2528
|
|
|
2529
|
-
const group_id = bb ? bb.id : "group-" + LX.
|
|
2529
|
+
const group_id = bb ? bb.id : "group-" + LX.guidGenerator();
|
|
2530
2530
|
|
|
2531
2531
|
let groupDOM = document.createElement( 'div' );
|
|
2532
2532
|
groupDOM.id = group_id;
|