lexgui 0.7.15 → 8.1.0
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/LICENSE +201 -21
- package/README.md +14 -5
- package/build/components/AlertDialog.d.ts +7 -0
- package/build/components/ArrayInput.d.ts +9 -0
- package/build/components/BaseComponent.d.ts +73 -0
- package/build/components/Button.d.ts +14 -0
- package/build/components/Calendar.d.ts +41 -0
- package/build/components/CalendarRange.d.ts +16 -0
- package/build/components/CanvasCurve.d.ts +10 -0
- package/build/components/CanvasDial.d.ts +11 -0
- package/build/components/CanvasMap2D.d.ts +61 -0
- package/build/components/Card.d.ts +8 -0
- package/build/components/Checkbox.d.ts +8 -0
- package/build/components/Color.d.ts +20 -0
- package/build/components/ColorInput.d.ts +13 -0
- package/build/components/ColorPicker.d.ts +29 -0
- package/build/components/ComboButtons.d.ts +8 -0
- package/build/components/ContextMenu.d.ts +16 -0
- package/build/components/Counter.d.ts +9 -0
- package/build/components/Curve.d.ts +10 -0
- package/build/components/DatePicker.d.ts +13 -0
- package/build/components/Dial.d.ts +10 -0
- package/build/components/Dialog.d.ts +20 -0
- package/build/components/DropdownMenu.d.ts +32 -0
- package/build/components/FileInput.d.ts +8 -0
- package/build/components/Footer.d.ts +14 -0
- package/build/components/Form.d.ts +8 -0
- package/build/components/Layers.d.ts +9 -0
- package/build/components/List.d.ts +9 -0
- package/build/components/Map2D.d.ts +12 -0
- package/build/components/Menubar.d.ts +59 -0
- package/build/components/NodeTree.d.ts +26 -0
- package/build/components/NumberInput.d.ts +9 -0
- package/build/components/OTPInput.d.ts +8 -0
- package/build/components/Pad.d.ts +8 -0
- package/build/components/Pagination.d.ts +26 -0
- package/build/components/PocketDialog.d.ts +11 -0
- package/build/components/Popover.d.ts +20 -0
- package/build/components/Progress.d.ts +8 -0
- package/build/components/RadioGroup.d.ts +8 -0
- package/build/components/RangeInput.d.ts +11 -0
- package/build/components/Rate.d.ts +8 -0
- package/build/components/Select.d.ts +10 -0
- package/build/components/Sheet.d.ts +10 -0
- package/build/components/Sidebar.d.ts +84 -0
- package/build/components/SizeInput.d.ts +8 -0
- package/build/components/Skeleton.d.ts +5 -0
- package/build/components/Spinner.d.ts +9 -0
- package/build/components/TabSections.d.ts +11 -0
- package/build/components/Table.d.ts +34 -0
- package/build/components/Tabs.d.ts +20 -0
- package/build/components/Tags.d.ts +9 -0
- package/build/components/TextArea.d.ts +8 -0
- package/build/components/TextInput.d.ts +11 -0
- package/build/components/Title.d.ts +8 -0
- package/build/components/Toggle.d.ts +8 -0
- package/build/components/Tour.d.ts +36 -0
- package/build/components/Vector.d.ts +9 -0
- package/build/core/Area.d.ts +143 -0
- package/build/core/Branch.d.ts +19 -0
- package/build/core/Core.d.ts +1 -0
- package/build/core/Event.d.ts +26 -0
- package/build/core/Icons.d.ts +4 -0
- package/build/core/Namespace.d.ts +2 -0
- package/build/core/Namespace.js +34 -0
- package/build/core/Namespace.js.map +1 -0
- package/build/core/Panel.d.ts +538 -0
- package/build/core/Utils.d.ts +1 -0
- package/build/core/Vec2.d.ts +21 -0
- package/build/extensions/AssetView.d.ts +136 -0
- package/build/extensions/AssetView.js +1367 -0
- package/build/extensions/AssetView.js.map +1 -0
- package/build/extensions/Audio.d.ts +9 -0
- package/build/extensions/Audio.js +163 -0
- package/build/extensions/Audio.js.map +1 -0
- package/build/extensions/CodeEditor.d.ts +350 -0
- package/build/extensions/CodeEditor.js +5022 -0
- package/build/extensions/CodeEditor.js.map +1 -0
- package/build/extensions/DocMaker.d.ts +27 -0
- package/build/extensions/DocMaker.js +327 -0
- package/build/extensions/DocMaker.js.map +1 -0
- package/build/extensions/GraphEditor.d.ts +276 -0
- package/build/extensions/GraphEditor.js +2770 -0
- package/build/extensions/GraphEditor.js.map +1 -0
- package/build/extensions/ImUi.d.ts +46 -0
- package/build/extensions/ImUi.js +227 -0
- package/build/extensions/ImUi.js.map +1 -0
- package/build/extensions/Timeline.d.ts +670 -0
- package/build/extensions/Timeline.js +3955 -0
- package/build/extensions/Timeline.js.map +1 -0
- package/build/extensions/VideoEditor.d.ts +128 -0
- package/build/extensions/VideoEditor.js +898 -0
- package/build/extensions/VideoEditor.js.map +1 -0
- package/build/extensions/index.d.ts +8 -0
- package/build/extensions/index.js +10 -0
- package/build/extensions/index.js.map +1 -0
- package/build/index.all.d.ts +2 -0
- package/build/index.css.d.ts +4 -0
- package/build/index.d.ts +56 -0
- package/build/lexgui.all.js +28498 -0
- package/build/lexgui.all.js.map +1 -0
- package/build/lexgui.all.min.js +1 -0
- package/build/lexgui.all.module.js +28422 -0
- package/build/lexgui.all.module.js.map +1 -0
- package/build/lexgui.all.module.min.js +1 -0
- package/build/lexgui.css +939 -346
- package/build/lexgui.js +13406 -17286
- package/build/lexgui.js.map +1 -0
- package/build/lexgui.min.css +3 -10
- package/build/lexgui.min.js +1 -1
- package/build/lexgui.module.js +12762 -16698
- package/build/lexgui.module.js.map +1 -0
- package/build/lexgui.module.min.js +1 -1
- package/changelog.md +170 -74
- package/demo.js +162 -48
- package/examples/all-components.html +45 -14
- package/examples/asset-view.html +110 -47
- package/examples/code-editor.html +5 -5
- package/examples/dialogs.html +3 -3
- package/examples/editor.html +27 -13
- package/examples/index.html +19 -14
- package/examples/node-graph.html +2 -2
- package/examples/previews/video-editor.png +0 -0
- package/examples/timeline.html +1 -1
- package/examples/video-editor.html +2 -2
- package/package.json +25 -9
- package/build/extensions/audio.js +0 -212
- package/build/extensions/codeeditor.js +0 -6319
- package/build/extensions/docmaker.js +0 -432
- package/build/extensions/imui.js +0 -325
- package/build/extensions/nodegraph.js +0 -3696
- package/build/extensions/timeline.js +0 -4636
- package/build/extensions/videoeditor.js +0 -953
- package/build/lexgui-docs.css +0 -352
|
@@ -1,432 +0,0 @@
|
|
|
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', 'auto'];
|
|
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', 'await'];
|
|
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_LIST( list, type, target )
|
|
194
|
-
{
|
|
195
|
-
const validTypes = [ 'bullet', 'numbered' ];
|
|
196
|
-
console.assert( list && list.length > 0 && validTypes.includes(type), "Invalid list type or empty list" + type );
|
|
197
|
-
const typeString = type == 'bullet' ? 'ul' : 'ol';
|
|
198
|
-
let ul = document.createElement( typeString );
|
|
199
|
-
target = target ?? mainContainer;
|
|
200
|
-
target.appendChild( ul );
|
|
201
|
-
for( var el of list ) {
|
|
202
|
-
if( el.constructor === Array ) {
|
|
203
|
-
MAKE_LIST( el, type, ul );
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
let li = document.createElement( 'li' );
|
|
207
|
-
li.className = "leading-loose";
|
|
208
|
-
li.innerHTML = el;
|
|
209
|
-
ul.appendChild( li );
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function MAKE_BULLET_LIST( list )
|
|
214
|
-
{
|
|
215
|
-
MAKE_LIST( list, 'bullet' );
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
window.MAKE_BULLET_LIST = MAKE_BULLET_LIST;
|
|
219
|
-
|
|
220
|
-
function MAKE_NUMBERED_LIST( list )
|
|
221
|
-
{
|
|
222
|
-
MAKE_LIST( list, 'numbered' );
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
window.MAKE_NUMBERED_LIST = MAKE_NUMBERED_LIST;
|
|
226
|
-
|
|
227
|
-
function ADD_CODE_LIST_ITEM( item, target )
|
|
228
|
-
{
|
|
229
|
-
target = target ?? window.listQueued;
|
|
230
|
-
let split = (item.constructor === Array);
|
|
231
|
-
if( split && item[0].constructor === Array ) {
|
|
232
|
-
MAKE_CODE_BULLET_LIST( item, target );
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
let li = document.createElement('li');
|
|
236
|
-
li.className = "leading-loose";
|
|
237
|
-
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 );
|
|
238
|
-
target.appendChild( li );
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
window.ADD_CODE_LIST_ITEM = ADD_CODE_LIST_ITEM;
|
|
242
|
-
|
|
243
|
-
function MAKE_CLASS_METHOD( name, desc, params, ret )
|
|
244
|
-
{
|
|
245
|
-
START_CODE_BULLET_LIST();
|
|
246
|
-
let paramsHTML = "";
|
|
247
|
-
for( var p of params ) {
|
|
248
|
-
const name = p[ 0 ];
|
|
249
|
-
const type = p[ 1 ];
|
|
250
|
-
paramsHTML += name + ": <span class='desc'>" + type + "</span>" + ( params.indexOf( p ) != (params.length - 1) ? ', ' : '' );
|
|
251
|
-
}
|
|
252
|
-
let li = document.createElement('li');
|
|
253
|
-
li.innerHTML = INLINE_CODE( "<span class='method'>" + name + " (" + paramsHTML + ")" + ( ret ? (": " + ret) : "" ) + "</span>" );
|
|
254
|
-
window.listQueued.appendChild( li );
|
|
255
|
-
END_CODE_BULLET_LIST();
|
|
256
|
-
MAKE_PARAGRAPH( desc );
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
window.MAKE_CLASS_METHOD = MAKE_CLASS_METHOD;
|
|
260
|
-
|
|
261
|
-
function MAKE_CLASS_CONSTRUCTOR( name, params, language = "js" )
|
|
262
|
-
{
|
|
263
|
-
let paramsHTML = "";
|
|
264
|
-
for( var p of params ) {
|
|
265
|
-
const str1 = p[ 0 ]; // cpp: param js: name
|
|
266
|
-
const str2 = p[ 1 ]; // cpp: defaultValue js: type
|
|
267
|
-
if( language == "cpp" ) {
|
|
268
|
-
paramsHTML += str1 + ( str2 ? " = <span class='desc'>" + str2 + "</span>" : "" ) + ( params.indexOf( p ) != (params.length - 1) ? ', ' : '' );
|
|
269
|
-
} else if( language == "js" ) {
|
|
270
|
-
paramsHTML += str1 + ": <span class='desc'>" + str2 + "</span>" + ( params.indexOf( p ) != (params.length - 1) ? ', ' : '' );
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
let pr = document.createElement('p');
|
|
274
|
-
pr.innerHTML = INLINE_CODE( "<span class='constructor'>" + name + "(" + paramsHTML + ")" + "</span>" );
|
|
275
|
-
mainContainer.appendChild( pr );
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
window.MAKE_CLASS_CONSTRUCTOR = MAKE_CLASS_CONSTRUCTOR;
|
|
279
|
-
|
|
280
|
-
function MAKE_CODE_BULLET_LIST( list, target )
|
|
281
|
-
{
|
|
282
|
-
console.assert(list && list.length > 0);
|
|
283
|
-
let ul = document.createElement('ul');
|
|
284
|
-
for( var el of list ) {
|
|
285
|
-
ADD_CODE_LIST_ITEM( el, ul );
|
|
286
|
-
}
|
|
287
|
-
if( target ) {
|
|
288
|
-
target.appendChild( ul );
|
|
289
|
-
} else {
|
|
290
|
-
mainContainer.appendChild( ul );
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
window.MAKE_CODE_BULLET_LIST = MAKE_CODE_BULLET_LIST;
|
|
295
|
-
|
|
296
|
-
function START_CODE_BULLET_LIST()
|
|
297
|
-
{
|
|
298
|
-
let ul = document.createElement('ul');
|
|
299
|
-
window.listQueued = ul;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
window.START_CODE_BULLET_LIST = START_CODE_BULLET_LIST;
|
|
303
|
-
|
|
304
|
-
function END_CODE_BULLET_LIST()
|
|
305
|
-
{
|
|
306
|
-
console.assert( window.listQueued );
|
|
307
|
-
mainContainer.appendChild( window.listQueued );
|
|
308
|
-
window.listQueued = undefined;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
window.END_CODE_BULLET_LIST = END_CODE_BULLET_LIST;
|
|
312
|
-
|
|
313
|
-
function INLINE_LINK( string, href )
|
|
314
|
-
{
|
|
315
|
-
console.assert(string && href);
|
|
316
|
-
return `<a href="` + href + `">` + string + `</a>`;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
window.INLINE_LINK = INLINE_LINK;
|
|
320
|
-
|
|
321
|
-
function INLINE_PAGE( string, page )
|
|
322
|
-
{
|
|
323
|
-
console.assert(string && page);
|
|
324
|
-
const startPage = page.replace(".html", "");
|
|
325
|
-
const tabName = window.setPath( startPage );
|
|
326
|
-
return `<a onclick="loadPage('${ page }', true, '${ tabName }')">${ string }</a>`;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
window.INLINE_PAGE = INLINE_PAGE;
|
|
330
|
-
|
|
331
|
-
function INLINE_CODE( string, codeClass )
|
|
332
|
-
{
|
|
333
|
-
console.assert(string);
|
|
334
|
-
return `<code class="inline ${ codeClass ?? "" }">` + string + `</code>`;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
window.INLINE_CODE = INLINE_CODE;
|
|
338
|
-
|
|
339
|
-
function COPY_SNIPPET( b )
|
|
340
|
-
{
|
|
341
|
-
b.innerHTML = "";
|
|
342
|
-
b.appendChild(LX.makeIcon( "Check" ));
|
|
343
|
-
b.classList.add('copied');
|
|
344
|
-
|
|
345
|
-
setTimeout( () => {
|
|
346
|
-
b.innerHTML = "";
|
|
347
|
-
b.appendChild(LX.makeIcon( "Copy" ));
|
|
348
|
-
b.classList.remove('copied');
|
|
349
|
-
}, 2000 );
|
|
350
|
-
|
|
351
|
-
navigator.clipboard.writeText( b.dataset['snippet'] ?? b.parentElement.innerText );
|
|
352
|
-
console.log("Copied!");
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
function INSERT_IMAGE( src, caption = "", parent )
|
|
356
|
-
{
|
|
357
|
-
let img = document.createElement('img');
|
|
358
|
-
img.src = src;
|
|
359
|
-
img.alt = caption;
|
|
360
|
-
img.className = "my-1";
|
|
361
|
-
( parent ?? mainContainer ).appendChild( img );
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
window.INSERT_IMAGE = INSERT_IMAGE;
|
|
365
|
-
|
|
366
|
-
function INSERT_IMAGES( sources, captions = [], width, height )
|
|
367
|
-
{
|
|
368
|
-
const mobile = navigator && /Android|iPhone/i.test(navigator.userAgent);
|
|
369
|
-
|
|
370
|
-
if( !mobile )
|
|
371
|
-
{
|
|
372
|
-
let div = document.createElement('div');
|
|
373
|
-
div.style.width = width ?? "auto";
|
|
374
|
-
div.style.height = height ?? "256px";
|
|
375
|
-
div.className = "flex flex-row justify-center";
|
|
376
|
-
|
|
377
|
-
for( let i = 0; i < sources.length; ++i )
|
|
378
|
-
{
|
|
379
|
-
INSERT_IMAGE( sources[ i ], captions[ i ], div );
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
mainContainer.appendChild( div );
|
|
383
|
-
}
|
|
384
|
-
else
|
|
385
|
-
{
|
|
386
|
-
for( let i = 0; i < sources.length; ++i )
|
|
387
|
-
{
|
|
388
|
-
INSERT_IMAGE( sources[ i ], captions[ i ] );
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
window.INSERT_IMAGES = INSERT_IMAGES;
|
|
394
|
-
|
|
395
|
-
function INSERT_VIDEO( src, caption = "", controls = true, autoplay = false )
|
|
396
|
-
{
|
|
397
|
-
let video = document.createElement( 'video' );
|
|
398
|
-
video.src = src;
|
|
399
|
-
video.controls = controls;
|
|
400
|
-
video.autoplay = autoplay;
|
|
401
|
-
if( autoplay )
|
|
402
|
-
{
|
|
403
|
-
video.muted = true;
|
|
404
|
-
}
|
|
405
|
-
video.loop = true;
|
|
406
|
-
video.alt = caption;
|
|
407
|
-
mainContainer.appendChild( video );
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
window.INSERT_VIDEO = INSERT_VIDEO;
|
|
411
|
-
|
|
412
|
-
function MAKE_NOTE( string, warning, title, icon )
|
|
413
|
-
{
|
|
414
|
-
console.assert( string );
|
|
415
|
-
|
|
416
|
-
const note = LX.makeContainer( [], "border rounded-lg overflow-hidden text-md fg-secondary my-6", "", mainContainer );
|
|
417
|
-
|
|
418
|
-
let header = document.createElement( 'div' );
|
|
419
|
-
header.className = "flex bg-tertiary font-semibold px-3 py-2 gap-2 fg-secondary";
|
|
420
|
-
header.appendChild( LX.makeIcon( icon ?? ( warning ? "MessageSquareWarning" : "NotepadText" ) ) );
|
|
421
|
-
header.innerHTML += ( title ?? ( warning ? "Important" : "Note" ) );
|
|
422
|
-
note.appendChild( header );
|
|
423
|
-
|
|
424
|
-
const body = LX.makeContainer( [], "leading-6 p-3", string, note );
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
window.MAKE_NOTE = MAKE_NOTE;
|
|
428
|
-
|
|
429
|
-
export { SET_DOM_TARGET, MAKE_LINE_BREAK, MAKE_HEADER, MAKE_PARAGRAPH, MAKE_CODE, MAKE_BULLET_LIST,
|
|
430
|
-
MAKE_CLASS_METHOD, MAKE_CLASS_CONSTRUCTOR, MAKE_CODE_BULLET_LIST, START_CODE_BULLET_LIST, ADD_CODE_LIST_ITEM,
|
|
431
|
-
END_CODE_BULLET_LIST, INLINE_LINK, INLINE_PAGE, INLINE_CODE, INSERT_IMAGE, INSERT_IMAGES, INSERT_VIDEO, MAKE_NOTE
|
|
432
|
-
}
|