sunrize 2.1.20 → 2.2.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/package.json +6 -6
- package/src/Application/Application.js +14 -15
- package/src/Application/Document.js +113 -60
- package/src/Application/Interface.js +1 -1
- package/src/Application/Tabs.js +377 -48
- package/src/Controls/AddPrototypePopover.js +2 -1
- package/src/Controls/AnimationPropertiesPopover.js +3 -4
- package/src/Controls/EditNodePopover.js +4 -1
- package/src/Controls/EditUserDefinedFieldPopover.js +4 -1
- package/src/Controls/ExportNodePopover.js +3 -1
- package/src/Controls/ImportNodePopover.js +3 -1
- package/src/Editors/AnimationEditor.js +8 -3
- package/src/Editors/BrowserFrame.js +44 -30
- package/src/Editors/NodeList.js +2 -2
- package/src/Editors/SceneProperties.js +7 -3
- package/src/Editors/ScriptEditor.js +1 -0
- package/src/Tools/Core/X3DPrototypeInstanceTool.js +2 -0
- package/src/Tools/Grids/AxonometricGridTool.js +1 -1
- package/src/Tools/Grids/X3DGridNodeTool.js +7 -13
- package/src/Tools/Rendering/X3DGeometryNodeTool.x3d +6 -7
- package/src/Tools/Shaders/ToolShader.x3d +13 -6
- package/src/Undo/Editor.js +81 -79
- package/src/assets/html/application-template.html +95 -27
- package/src/assets/html/application.html +95 -27
- package/src/assets/images/seti/audio.svg +44 -0
- package/src/assets/images/seti/default.svg +36 -0
- package/src/assets/images/seti/html.svg +37 -0
- package/src/assets/images/seti/image.svg +37 -0
- package/src/assets/images/seti/json.svg +37 -0
- package/src/assets/images/seti/obj.svg +50 -0
- package/src/assets/images/seti/others.svg +50 -0
- package/src/assets/images/seti/ply.svg +50 -0
- package/src/assets/images/seti/sog.svg +57 -0
- package/src/assets/images/seti/spz.svg +57 -0
- package/src/assets/images/seti/stl.svg +50 -0
- package/src/assets/images/seti/svg.svg +41 -0
- package/src/assets/images/seti/video.svg +36 -0
- package/src/assets/images/seti/vrml.svg +34 -0
- package/src/assets/themes/default.css +12 -1
- package/src/assets/themes/system-colors.css +4 -9
package/src/Application/Tabs.js
CHANGED
|
@@ -3,35 +3,53 @@
|
|
|
3
3
|
const
|
|
4
4
|
$ = require ("jquery"),
|
|
5
5
|
electron = require ("electron"),
|
|
6
|
-
TabGroup = require ("electron-tabs"),
|
|
7
6
|
DataStorage = require ("./DataStorage"),
|
|
8
7
|
url = require ("url"),
|
|
9
8
|
path = require ("path"),
|
|
10
9
|
fs = require ("fs"),
|
|
11
10
|
md5 = require ("md5"),
|
|
12
|
-
CSS = require ("./CSS"),
|
|
13
11
|
_ = require ("./GetText");
|
|
14
12
|
|
|
13
|
+
require ("electron-tabs");
|
|
14
|
+
require ("./CSS");
|
|
15
|
+
|
|
15
16
|
module .exports = new class Tabs
|
|
16
17
|
{
|
|
17
18
|
// Construction
|
|
18
19
|
|
|
19
20
|
config = new DataStorage (localStorage, "Sunrize.Application.");
|
|
20
21
|
|
|
22
|
+
// Most icons from https://github.com/jesseweed/seti-ui.
|
|
23
|
+
|
|
24
|
+
icons = new Map ([
|
|
25
|
+
["DEFAULT", "../images/seti/default.svg"],
|
|
26
|
+
["OTHERS", "../images/seti/others.svg"],
|
|
27
|
+
["XML", "../images/seti/html.svg"],
|
|
28
|
+
["VRML", "../images/seti/vrml.svg"],
|
|
29
|
+
["JSON", "../images/seti/json.svg"],
|
|
30
|
+
["GLTF", "../images/seti/json.svg"],
|
|
31
|
+
["SPZ", "../images/seti/spz.svg"],
|
|
32
|
+
["OBJ", "../images/seti/obj.svg"],
|
|
33
|
+
["STL", "../images/seti/stl.svg"],
|
|
34
|
+
["PLY", "../images/seti/ply.svg"],
|
|
35
|
+
["SOG", "../images/seti/sog.svg"],
|
|
36
|
+
["IMAGE", "../images/seti/image.svg"],
|
|
37
|
+
["AUDIO", "../images/seti/audio.svg"],
|
|
38
|
+
["VIDEO", "../images/seti/video.svg"],
|
|
39
|
+
["SVG", "../images/seti/svg.svg"],
|
|
40
|
+
]);
|
|
41
|
+
|
|
21
42
|
constructor ()
|
|
22
43
|
{
|
|
23
|
-
this .tabs = $("tab-group") .get (0);
|
|
24
|
-
|
|
25
44
|
this .config .setDefaultValues ({
|
|
26
45
|
openTabs: [ ],
|
|
27
46
|
scrollLeft: 0,
|
|
28
47
|
});
|
|
29
48
|
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
// Connect to TabGroup Events
|
|
50
|
+
|
|
51
|
+
this .tabs = $("tab-group") .get (0);
|
|
32
52
|
|
|
33
|
-
initialize ()
|
|
34
|
-
{
|
|
35
53
|
this .tabs .on ("tab-active", tab =>
|
|
36
54
|
{
|
|
37
55
|
electron .ipcRenderer .send ("title", tab .getTitle ());
|
|
@@ -39,25 +57,25 @@ module .exports = new class Tabs
|
|
|
39
57
|
|
|
40
58
|
tab .initialized = true;
|
|
41
59
|
|
|
42
|
-
|
|
43
|
-
tab .webview .send ("activate");
|
|
44
|
-
|
|
60
|
+
this .activateTab (tab);
|
|
45
61
|
this .saveTabs ();
|
|
46
62
|
});
|
|
47
63
|
|
|
48
|
-
this .tabs .on ("tab-removed", (
|
|
64
|
+
this .tabs .on ("tab-removed", () => this .saveTabs ());
|
|
49
65
|
|
|
50
66
|
// Actions
|
|
51
67
|
|
|
52
|
-
electron .ipcRenderer .on ("
|
|
53
|
-
|
|
68
|
+
electron .ipcRenderer .on ("tabs-menu", (event, key, ... args) => this [key] (... args));
|
|
69
|
+
|
|
70
|
+
electron .ipcRenderer .on ("open-files", (event, urls) => this .openTabs (urls));
|
|
71
|
+
electron .ipcRenderer .on ("reload" , () => this .reloadTab ());
|
|
54
72
|
electron .ipcRenderer .on ("save-file-as", (event, filePath) => this .saveFileAs (filePath));
|
|
55
|
-
electron .ipcRenderer .on ("save-all-files", (
|
|
56
|
-
electron .ipcRenderer .on ("close-tab", (
|
|
57
|
-
electron .ipcRenderer .on ("close-all-tabs", (
|
|
58
|
-
electron .ipcRenderer .on ("quit", (
|
|
73
|
+
electron .ipcRenderer .on ("save-all-files", () => this .saveAllFiles ());
|
|
74
|
+
electron .ipcRenderer .on ("close-tab", () => this .tabs .getActiveTab () ?.close (true));
|
|
75
|
+
electron .ipcRenderer .on ("close-all-tabs", () => this .closeAllTabs ());
|
|
76
|
+
electron .ipcRenderer .on ("quit", () => this .quit ());
|
|
59
77
|
|
|
60
|
-
electron .ipcRenderer .on ("toggle-developer-tools", (
|
|
78
|
+
electron .ipcRenderer .on ("toggle-developer-tools", () => this .tabs .getActiveTab () .webview .openDevTools ());
|
|
61
79
|
|
|
62
80
|
$(window) .on ("beforeunload", () => this .close ());
|
|
63
81
|
|
|
@@ -94,7 +112,6 @@ module .exports = new class Tabs
|
|
|
94
112
|
this .forwardToActiveTab ("tone-mapping");
|
|
95
113
|
this .forwardToActiveTab ("order-independent-transparency");
|
|
96
114
|
this .forwardToActiveTab ("logarithmic-depth-buffer");
|
|
97
|
-
this .forwardToActiveTab ("mute");
|
|
98
115
|
this .forwardToActiveTab ("display-rubberband");
|
|
99
116
|
this .forwardToActiveTab ("display-timings");
|
|
100
117
|
this .forwardToActiveTab ("show-library");
|
|
@@ -121,8 +138,6 @@ module .exports = new class Tabs
|
|
|
121
138
|
|
|
122
139
|
restoreTabs (activeTab)
|
|
123
140
|
{
|
|
124
|
-
const config = new DataStorage (localStorage, "Sunrize.");
|
|
125
|
-
|
|
126
141
|
const openTabs = this .config .openTabs .filter (fileURL =>
|
|
127
142
|
{
|
|
128
143
|
if (!fileURL .startsWith ("file:"))
|
|
@@ -131,13 +146,6 @@ module .exports = new class Tabs
|
|
|
131
146
|
if (fs .existsSync (url .fileURLToPath (fileURL)))
|
|
132
147
|
return true;
|
|
133
148
|
|
|
134
|
-
// Delete keys of deleted file.
|
|
135
|
-
|
|
136
|
-
const hash = `.${md5 (fileURL)}.`;
|
|
137
|
-
|
|
138
|
-
for (const key of Object .keys (config) .filter (key => key .includes (hash)))
|
|
139
|
-
config [key] = undefined;
|
|
140
|
-
|
|
141
149
|
return false;
|
|
142
150
|
});
|
|
143
151
|
|
|
@@ -168,6 +176,8 @@ module .exports = new class Tabs
|
|
|
168
176
|
|
|
169
177
|
for (let fileURL of urls)
|
|
170
178
|
{
|
|
179
|
+
// Make Tab URL
|
|
180
|
+
|
|
171
181
|
if (fileURL && this .tabs .getTabs () .some (tab => tab .url === fileURL))
|
|
172
182
|
continue;
|
|
173
183
|
|
|
@@ -176,6 +186,8 @@ module .exports = new class Tabs
|
|
|
176
186
|
|
|
177
187
|
src .searchParams .set ("url", fileURL);
|
|
178
188
|
|
|
189
|
+
// Create Tab
|
|
190
|
+
|
|
179
191
|
const tab = this .tabs .addTab ({
|
|
180
192
|
src: src,
|
|
181
193
|
webviewAttributes: {
|
|
@@ -189,18 +201,73 @@ module .exports = new class Tabs
|
|
|
189
201
|
|
|
190
202
|
this .setTabURL (tab, fileURL);
|
|
191
203
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
204
|
+
const config = this .getTabConfig (tab);
|
|
205
|
+
|
|
206
|
+
config .setDefaultValues ({
|
|
207
|
+
pinned: false,
|
|
195
208
|
});
|
|
196
209
|
|
|
210
|
+
// Tab Context Menu
|
|
211
|
+
|
|
212
|
+
$(tab .element)
|
|
213
|
+
.attr ("tabindex", 0)
|
|
214
|
+
.on ("contextmenu", () => this .showContextMenu (tab));
|
|
215
|
+
|
|
216
|
+
// Tab Icon
|
|
217
|
+
|
|
218
|
+
tab .setIcon (this .getIcon (config .encoding ?? "DEFAULT"));
|
|
219
|
+
|
|
220
|
+
// Close Button
|
|
221
|
+
|
|
197
222
|
tab .on ("closing", (tab, abort) => this .tabClosing (tab, abort));
|
|
198
223
|
tab .on ("close", (tab) => this .tabClose (tab));
|
|
199
224
|
|
|
200
|
-
tab .
|
|
225
|
+
tab .closeButton = $(tab .element) .find (".tab-close");
|
|
226
|
+
|
|
227
|
+
tab .closeButton .find ("button")
|
|
228
|
+
.addClass ("material-symbols-outlined")
|
|
229
|
+
.text ("close");
|
|
230
|
+
|
|
231
|
+
// Audio Button
|
|
232
|
+
|
|
233
|
+
tab .audioButton = $("<span></span>")
|
|
234
|
+
.addClass (["tab-audio", "material-symbols-outlined"])
|
|
235
|
+
.text ("volume_up")
|
|
236
|
+
.on ("click", () => tab .webview .send ("mute", !tab .mute));
|
|
237
|
+
|
|
238
|
+
tab .closeButton .before (tab .audioButton);
|
|
239
|
+
|
|
240
|
+
// Pin Button
|
|
241
|
+
|
|
242
|
+
tab .pinButton = $("<span></span>")
|
|
243
|
+
.addClass ("tab-pin")
|
|
244
|
+
.append ($("<span></span>")
|
|
245
|
+
.addClass ("material-symbols-outlined")
|
|
246
|
+
.text ("keep"));
|
|
247
|
+
|
|
248
|
+
tab .closeButton .before (tab .pinButton);
|
|
249
|
+
|
|
250
|
+
this .menuPinTab (tab .getPosition (), config .pinned);
|
|
251
|
+
|
|
252
|
+
// Events
|
|
253
|
+
|
|
254
|
+
tab .webview .addEventListener ("dom-ready", () =>
|
|
255
|
+
{
|
|
256
|
+
tab .domReady = true;
|
|
257
|
+
|
|
258
|
+
this .activateTab (tab);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
tab .webview .addEventListener ("ipc-message", event =>
|
|
201
262
|
{
|
|
202
263
|
switch (event .channel)
|
|
203
264
|
{
|
|
265
|
+
case "scene-encoding":
|
|
266
|
+
{
|
|
267
|
+
config .encoding = event .args [0];
|
|
268
|
+
tab .setIcon (this .getIcon (event .args [0]));
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
204
271
|
case "focus":
|
|
205
272
|
{
|
|
206
273
|
document .activeElement ?.blur ();
|
|
@@ -212,15 +279,22 @@ module .exports = new class Tabs
|
|
|
212
279
|
this .setTabURL (tab, tab .url, ... event .args);
|
|
213
280
|
break;
|
|
214
281
|
}
|
|
282
|
+
case "audio":
|
|
283
|
+
{
|
|
284
|
+
this .toggleAudio (tab, ... event .args);
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
case "mute":
|
|
288
|
+
{
|
|
289
|
+
this .toggleMute (tab, ... event .args);
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
215
292
|
}
|
|
216
293
|
});
|
|
217
294
|
|
|
218
|
-
tab .webview .addEventListener ("
|
|
295
|
+
tab .webview .addEventListener ("console-message", (event) =>
|
|
219
296
|
{
|
|
220
|
-
tab .
|
|
221
|
-
|
|
222
|
-
if (this .tabs .getActiveTab () === tab)
|
|
223
|
-
tab .webview .send ("activate");
|
|
297
|
+
tab .webview .send ("console-message", event .level, event .sourceId, event .line, event .message);
|
|
224
298
|
});
|
|
225
299
|
}
|
|
226
300
|
|
|
@@ -235,19 +309,208 @@ module .exports = new class Tabs
|
|
|
235
309
|
this .saveTabs ();
|
|
236
310
|
}
|
|
237
311
|
|
|
238
|
-
|
|
312
|
+
getIcon (encoding)
|
|
313
|
+
{
|
|
314
|
+
return this .icons .get (encoding) ?? this .icons .get ("OTHERS");
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Context Menu
|
|
318
|
+
|
|
319
|
+
showContextMenu (tab)
|
|
320
|
+
{
|
|
321
|
+
$(tab .element) .trigger ("focus");
|
|
322
|
+
|
|
323
|
+
const menu = [
|
|
324
|
+
{
|
|
325
|
+
label: tab .url .startsWith ("file:") ? _("Copy Path") : _("Copy URL"),
|
|
326
|
+
visible: !tab .url .startsWith ("id:"),
|
|
327
|
+
args: ["menuCopyURL", tab .getPosition ()],
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
label: (() =>
|
|
331
|
+
{
|
|
332
|
+
switch (process .platform)
|
|
333
|
+
{
|
|
334
|
+
case "darwin": return _("Reveal File in Finder");
|
|
335
|
+
case "win32": return _("Reveal File in File Explorer");
|
|
336
|
+
default: return _("Reveal File in File Manager");
|
|
337
|
+
}
|
|
338
|
+
})(),
|
|
339
|
+
visible: tab .url .startsWith ("file:"),
|
|
340
|
+
args: ["menuShowItemInFolder", tab .getPosition ()],
|
|
341
|
+
},
|
|
342
|
+
{ type: "separator" },
|
|
343
|
+
{
|
|
344
|
+
label: _("Reload Tab"),
|
|
345
|
+
accelerator: "F5",
|
|
346
|
+
args: ["menuReloadTab", tab .getPosition ()],
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
label: tab .pinButton .is (":visible") ? _("Unpin Tab") : _("Pin Tab"),
|
|
350
|
+
args: ["menuPinTab", tab .getPosition ()],
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
label: tab .mute ? _("Unmute Tab") : _("Mute Tab"),
|
|
354
|
+
args: ["menuToggleMuteTab", tab .getPosition ()],
|
|
355
|
+
},
|
|
356
|
+
{ type: "separator" },
|
|
357
|
+
{
|
|
358
|
+
label: _("Move Tab"),
|
|
359
|
+
submenu: [
|
|
360
|
+
{
|
|
361
|
+
label: _("Move to Start"),
|
|
362
|
+
enabled: tab .getPosition () !== 0,
|
|
363
|
+
args: ["menuMoveTabToStart", tab .getPosition ()],
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
label: _("Move to End"),
|
|
367
|
+
enabled: tab .getPosition () !== this .getTabs () .length - 1,
|
|
368
|
+
args: ["menuMoveTabToEnd", tab .getPosition ()],
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
},
|
|
372
|
+
{ type: "separator" },
|
|
373
|
+
{
|
|
374
|
+
label: _("Close Tab"),
|
|
375
|
+
args: ["menuCloseTab", tab .getPosition ()],
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
label: _("Close Other Tabs"),
|
|
379
|
+
args: ["menuCloseOtherTabs", tab .getPosition ()],
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
label: _("Close All Tabs"),
|
|
383
|
+
accelerator: "Option+CmdOrCtrl+W",
|
|
384
|
+
args: ["menuCloseOtherTabs", -1],
|
|
385
|
+
},
|
|
386
|
+
{ type: "separator" },
|
|
387
|
+
{
|
|
388
|
+
label: _("Reopen Closed Tab"),
|
|
389
|
+
enabled: this .config .closedTabs .length,
|
|
390
|
+
args: ["menuReopenClosedTab"],
|
|
391
|
+
},
|
|
392
|
+
];
|
|
393
|
+
|
|
394
|
+
electron .ipcRenderer .send ("context-menu", "tabs-menu", menu);
|
|
395
|
+
electron .ipcRenderer .once ("tabs-menu-will-close", () => $(tab .element) .trigger ("blur"));
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
menuCopyURL (position)
|
|
399
|
+
{
|
|
400
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
401
|
+
|
|
402
|
+
if (tab .url .startsWith ("file:"))
|
|
403
|
+
navigator .clipboard .writeText (url .fileURLToPath (tab .url));
|
|
404
|
+
else
|
|
405
|
+
navigator .clipboard .writeText (tab .url);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
menuShowItemInFolder (position)
|
|
409
|
+
{
|
|
410
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
411
|
+
|
|
412
|
+
electron .shell .showItemInFolder (url .fileURLToPath (tab .url));
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
menuReloadTab (position)
|
|
416
|
+
{
|
|
417
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
418
|
+
|
|
419
|
+
this .reloadTab (tab);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
menuPinTab (position, pinned)
|
|
239
423
|
{
|
|
240
424
|
const
|
|
241
|
-
tab
|
|
242
|
-
|
|
425
|
+
tab = this .tabs .getTabByPosition (position),
|
|
426
|
+
config = this .getTabConfig (tab);
|
|
243
427
|
|
|
244
|
-
|
|
428
|
+
if (pinned ?? !tab .pinButton .is (":visible"))
|
|
429
|
+
{
|
|
430
|
+
config .pinned = true;
|
|
245
431
|
|
|
246
|
-
|
|
432
|
+
tab .pinButton .show ();
|
|
433
|
+
tab .closeButton .hide ();
|
|
434
|
+
}
|
|
435
|
+
else
|
|
436
|
+
{
|
|
437
|
+
config .pinned = false;
|
|
247
438
|
|
|
248
|
-
|
|
439
|
+
tab .pinButton .hide ();
|
|
440
|
+
tab .closeButton .show ();
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
menuMoveTabToStart (position)
|
|
445
|
+
{
|
|
446
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
447
|
+
|
|
448
|
+
tab .setPosition (0);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
menuMoveTabToEnd (position)
|
|
452
|
+
{
|
|
453
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
454
|
+
|
|
455
|
+
tab .setPosition (this .getTabs () .length);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
menuToggleMuteTab (position)
|
|
459
|
+
{
|
|
460
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
461
|
+
|
|
462
|
+
tab .webview .send ("mute", !tab .mute);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
menuCloseTab (position)
|
|
466
|
+
{
|
|
467
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
468
|
+
|
|
469
|
+
tab .close (true);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
menuCloseOtherTabs (position)
|
|
473
|
+
{
|
|
474
|
+
const
|
|
475
|
+
tabs = this .getTabs (),
|
|
476
|
+
length = tabs .length;
|
|
477
|
+
|
|
478
|
+
for (let i = length - 1; i >= 0; -- i)
|
|
479
|
+
{
|
|
480
|
+
if (i === position)
|
|
481
|
+
continue;
|
|
482
|
+
|
|
483
|
+
const tab = this .tabs .getTabByPosition (i);
|
|
484
|
+
|
|
485
|
+
if (tab .pinButton .is (":visible"))
|
|
486
|
+
continue;
|
|
487
|
+
|
|
488
|
+
tab .close (true);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
menuReopenClosedTab ()
|
|
493
|
+
{
|
|
494
|
+
const
|
|
495
|
+
closedTabs = this .config .closedTabs,
|
|
496
|
+
closedTabURL = closedTabs .pop ();
|
|
497
|
+
|
|
498
|
+
this .config .closedTabs = closedTabs;
|
|
499
|
+
|
|
500
|
+
if (!closedTabURL)
|
|
501
|
+
return;
|
|
502
|
+
|
|
503
|
+
if (closedTabURL .startsWith ("file:"))
|
|
504
|
+
{
|
|
505
|
+
if (!fs .existsSync (url .fileURLToPath (closedTabURL)))
|
|
506
|
+
return this .menuReopenClosedTab (); // Try next.
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
this .openTabs ([closedTabURL]);
|
|
249
510
|
}
|
|
250
511
|
|
|
512
|
+
// Tab Handling
|
|
513
|
+
|
|
251
514
|
getTabs ()
|
|
252
515
|
{
|
|
253
516
|
const cmp = (a, b) => (a > b) - (a < b);
|
|
@@ -256,6 +519,22 @@ module .exports = new class Tabs
|
|
|
256
519
|
.sort ((a, b) => cmp (a .getPosition (), b .getPosition ()));
|
|
257
520
|
}
|
|
258
521
|
|
|
522
|
+
getTabConfig (tab)
|
|
523
|
+
{
|
|
524
|
+
return new DataStorage (localStorage, `Sunrize.Tabs.${md5 (tab .url)}.`);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
reloadTab (tab = this .tabs .getActiveTab ())
|
|
528
|
+
{
|
|
529
|
+
const src = url .pathToFileURL (path .join (__dirname, "../assets/html/window.html"));
|
|
530
|
+
|
|
531
|
+
src .searchParams .set ("url", tab .url);
|
|
532
|
+
|
|
533
|
+
tab .webview .src = src;
|
|
534
|
+
|
|
535
|
+
this .setTabURL (tab, tab .url, true);
|
|
536
|
+
}
|
|
537
|
+
|
|
259
538
|
getTabByURL (fileURL)
|
|
260
539
|
{
|
|
261
540
|
return this .getTabs () .findLast (tab => tab .url === fileURL);
|
|
@@ -275,6 +554,22 @@ module .exports = new class Tabs
|
|
|
275
554
|
this .saveTabs ();
|
|
276
555
|
}
|
|
277
556
|
|
|
557
|
+
activeTab = null;
|
|
558
|
+
|
|
559
|
+
activateTab (tab)
|
|
560
|
+
{
|
|
561
|
+
if (!tab .domReady)
|
|
562
|
+
return;
|
|
563
|
+
|
|
564
|
+
if (tab !== this .tabs .getActiveTab ())
|
|
565
|
+
return;
|
|
566
|
+
|
|
567
|
+
this .activeTab ?.webview .send ("activate", false);
|
|
568
|
+
tab .webview .send ("activate", true);
|
|
569
|
+
|
|
570
|
+
this .activeTab = tab;
|
|
571
|
+
}
|
|
572
|
+
|
|
278
573
|
saveTabs ()
|
|
279
574
|
{
|
|
280
575
|
const
|
|
@@ -285,10 +580,30 @@ module .exports = new class Tabs
|
|
|
285
580
|
this .config .activeTab = tabs .length ? this .tabs .getActiveTab () .url : undefined;
|
|
286
581
|
}
|
|
287
582
|
|
|
288
|
-
|
|
583
|
+
toggleAudio (tab, audio)
|
|
584
|
+
{
|
|
585
|
+
if (audio)
|
|
586
|
+
tab .audioButton .show ();
|
|
587
|
+
else
|
|
588
|
+
tab .audioButton .hide ();
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
toggleMute (tab, mute)
|
|
592
|
+
{
|
|
593
|
+
tab .mute = mute;
|
|
594
|
+
|
|
595
|
+
if (mute)
|
|
596
|
+
tab .audioButton .text ("volume_mute");
|
|
597
|
+
else
|
|
598
|
+
tab .audioButton .text ("volume_up");
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
tabClosing (tab)
|
|
289
602
|
{
|
|
290
603
|
tab .webview .send ("close");
|
|
291
604
|
|
|
605
|
+
this .menuPinTab (tab .getPosition (), false);
|
|
606
|
+
|
|
292
607
|
if (tab !== this .tabs .getActiveTab ())
|
|
293
608
|
return;
|
|
294
609
|
|
|
@@ -308,6 +623,12 @@ module .exports = new class Tabs
|
|
|
308
623
|
{
|
|
309
624
|
// If all tabs are closed, open empty tab.
|
|
310
625
|
|
|
626
|
+
const closedTabs = this .config .closedTabs;
|
|
627
|
+
|
|
628
|
+
closedTabs .push (tab .url);
|
|
629
|
+
|
|
630
|
+
this .config .closedTabs = closedTabs;
|
|
631
|
+
|
|
311
632
|
electron .ipcRenderer .send ("add-recent-location", tab .url);
|
|
312
633
|
|
|
313
634
|
if (!this .tabs .getTabs () .length)
|
|
@@ -336,7 +657,12 @@ module .exports = new class Tabs
|
|
|
336
657
|
closeAllTabs ()
|
|
337
658
|
{
|
|
338
659
|
for (const tab of this .tabs .getTabs ())
|
|
660
|
+
{
|
|
661
|
+
if (tab .pinButton .is (":visible"))
|
|
662
|
+
continue;
|
|
663
|
+
|
|
339
664
|
tab .close (true);
|
|
665
|
+
}
|
|
340
666
|
}
|
|
341
667
|
|
|
342
668
|
close ()
|
|
@@ -372,20 +698,23 @@ module .exports = new class Tabs
|
|
|
372
698
|
for (const tab of tabs)
|
|
373
699
|
tab .webview .send ("close");
|
|
374
700
|
|
|
375
|
-
|
|
701
|
+
this .maintenance ();
|
|
376
702
|
}
|
|
377
703
|
|
|
378
704
|
maintenance ()
|
|
379
705
|
{
|
|
706
|
+
// Limit closed tabs.
|
|
707
|
+
this .config .closedTabs = this .config .closedTabs .slice (-1000);
|
|
708
|
+
|
|
380
709
|
// Remove items older than one year, time in milliseconds.
|
|
381
|
-
new DataStorage (localStorage, "Sunrize.") .removeItems (Date .now () - (1000 * 60 * 60 * 24 * 365));
|
|
710
|
+
// new DataStorage (localStorage, "Sunrize.") .removeItems (Date .now () - (1000 * 60 * 60 * 24 * 365));
|
|
382
711
|
}
|
|
383
712
|
|
|
384
713
|
// Send messages to tabs
|
|
385
714
|
|
|
386
715
|
forwardToActiveTab (channel)
|
|
387
716
|
{
|
|
388
|
-
electron .ipcRenderer .on (channel, (event, ... args) => this .tabs .getActiveTab ()
|
|
717
|
+
electron .ipcRenderer .on (channel, (event, ... args) => this .tabs .getActiveTab () ?.webview .send (channel, ... args));
|
|
389
718
|
}
|
|
390
719
|
|
|
391
720
|
forwardToAllTabs (channel)
|
|
@@ -41,11 +41,12 @@ $.fn.addPrototypePopover = function (executionContext, type)
|
|
|
41
41
|
|
|
42
42
|
const nameInput = $("<input></input>")
|
|
43
43
|
.attr ("placeholder", _("Enter a name"))
|
|
44
|
+
.attr ("spellcheck", "true")
|
|
44
45
|
.appendTo (content);
|
|
45
46
|
|
|
46
47
|
// Create tooltip.
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
this .popover ({
|
|
49
50
|
content: content,
|
|
50
51
|
events: {
|
|
51
52
|
show (event, api)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const
|
|
4
|
-
X3D = require ("../X3D"),
|
|
5
4
|
util = require ("util"),
|
|
6
5
|
$ = require ("jquery"),
|
|
7
6
|
_ = require ("../Application/GetText");
|
|
@@ -50,7 +49,7 @@ $.fn.animationPropertiesPopover = function (editor)
|
|
|
50
49
|
if (editor .config .file .scaleKeyframes)
|
|
51
50
|
scaleInput .attr ("checked", "");
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
$("<label></label>")
|
|
54
53
|
.attr ("for", "keyframe-scale")
|
|
55
54
|
.text (_("Scale Keyframes"))
|
|
56
55
|
.appendTo (content);
|
|
@@ -77,7 +76,7 @@ $.fn.animationPropertiesPopover = function (editor)
|
|
|
77
76
|
|
|
78
77
|
// Create tooltip.
|
|
79
78
|
|
|
80
|
-
|
|
79
|
+
this .popover ({
|
|
81
80
|
position: {
|
|
82
81
|
my: "bottom right",
|
|
83
82
|
at: "top left",
|
|
@@ -95,7 +94,7 @@ $.fn.animationPropertiesPopover = function (editor)
|
|
|
95
94
|
api .toggle (false);
|
|
96
95
|
});
|
|
97
96
|
|
|
98
|
-
applyButton .on ("click", (event) =>
|
|
97
|
+
applyButton .on ("click", (/* event */) =>
|
|
99
98
|
{
|
|
100
99
|
api .toggle (false);
|
|
101
100
|
editor .resizeAnimation (parseInt (durationInput .val ()), parseInt (frameRateInput .val ()), scaleInput .prop ("checked"));
|
|
@@ -20,6 +20,7 @@ $.fn.editNodePopover = function (node)
|
|
|
20
20
|
|
|
21
21
|
const nameInput = $("<input></input>")
|
|
22
22
|
.attr ("placeholder", _("Enter a name"))
|
|
23
|
+
.attr ("spellcheck", "true")
|
|
23
24
|
.appendTo (content);
|
|
24
25
|
|
|
25
26
|
if (node instanceof X3D .X3DProtoDeclaration)
|
|
@@ -31,6 +32,7 @@ $.fn.editNodePopover = function (node)
|
|
|
31
32
|
$("<input></input>")
|
|
32
33
|
.addClass ("appinfo")
|
|
33
34
|
.attr ("placeholder", _("Enter application information"))
|
|
35
|
+
.attr ("spellcheck", "true")
|
|
34
36
|
.val (node .getAppInfo ())
|
|
35
37
|
.appendTo (content);
|
|
36
38
|
|
|
@@ -41,6 +43,7 @@ $.fn.editNodePopover = function (node)
|
|
|
41
43
|
$("<input></input>")
|
|
42
44
|
.addClass ("documentation")
|
|
43
45
|
.attr ("placeholder", _("Enter documentation"))
|
|
46
|
+
.attr ("spellcheck", "true")
|
|
44
47
|
.val (node .getDocumentation ())
|
|
45
48
|
.appendTo (content);
|
|
46
49
|
}
|
|
@@ -50,7 +53,7 @@ $.fn.editNodePopover = function (node)
|
|
|
50
53
|
|
|
51
54
|
// Create tooltip.
|
|
52
55
|
|
|
53
|
-
|
|
56
|
+
this .popover ({
|
|
54
57
|
content: content,
|
|
55
58
|
extension:
|
|
56
59
|
{
|