sunrize 2.1.21 → 2.3.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 +7 -7
- package/src/Application/Application.js +42 -27
- package/src/Application/Dashboard.js +33 -0
- package/src/Application/Document.js +122 -67
- package/src/Application/Footer.js +8 -3
- package/src/Application/GetText.js +20 -2
- package/src/Application/Interface.js +1 -1
- package/src/Application/Tabs.js +384 -49
- package/src/Application/TopBar.js +32 -0
- package/src/Controls/AddPrototypePopover.js +2 -1
- package/src/Controls/AnimationPropertiesPopover.js +3 -4
- package/src/Controls/AudioPreviewPopover.js +2 -8
- 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/Controls/Tabs.js +28 -2
- package/src/Controls/TexturePreviewPopover.js +5 -5
- package/src/Controls/VideoPreviewPopover.js +5 -8
- package/src/Controls/VolumeSliderPopover.js +41 -0
- package/src/Editors/AnimationEditor.js +19 -5
- package/src/Editors/BrowserFrame.js +40 -26
- package/src/Editors/Console.js +4 -1
- package/src/Editors/NodeList.js +2 -2
- package/src/Editors/SceneProperties.js +7 -3
- package/src/Editors/ScriptEditor.js +2 -1
- package/src/Parser/AudioParser.js +2 -2
- package/src/Parser/VideoParser.js +2 -3
- package/src/Tools/Core/X3DNodeTool.js +3 -3
- 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/Grouping/X3DBoundedObjectTool.x3d +4 -2
- package/src/Tools/Grouping/X3DTransformNodeTool.x3d +4 -2
- package/src/Tools/Rendering/X3DGeometryNodeTool.x3d +4 -3
- package/src/Tools/Shaders/ToolShader.x3d +6 -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/html/window-template.html +2 -1
- package/src/assets/html/window.html +2 -1
- 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/locale/dictionary.json +43 -0
- package/src/assets/themes/default.css +312 -216
- package/src/assets/themes/system-colors.css +11 -11
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
const strings = require ("../assets/locale/dictionary.json");
|
|
4
|
+
|
|
5
|
+
let locale, language;
|
|
6
|
+
|
|
3
7
|
function gettext (string)
|
|
4
8
|
{
|
|
5
|
-
|
|
9
|
+
const translations = strings [string];
|
|
10
|
+
|
|
11
|
+
return translations ?.[locale]
|
|
12
|
+
?? translations ?.[language]
|
|
13
|
+
?? translations ?.["en"]
|
|
14
|
+
?? string;
|
|
6
15
|
}
|
|
7
16
|
|
|
8
|
-
gettext .
|
|
17
|
+
gettext .setLocale = function (value)
|
|
18
|
+
{
|
|
19
|
+
gettext .locale = value;
|
|
20
|
+
gettext .language = value .split ("-") [0];
|
|
21
|
+
|
|
22
|
+
locale = gettext .locale;
|
|
23
|
+
language = gettext .language;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
gettext .setLocale (Intl .DateTimeFormat () .resolvedOptions() .locale);
|
|
9
27
|
|
|
10
28
|
module .exports = gettext;
|
|
@@ -166,7 +166,7 @@ module .exports = class Interface
|
|
|
166
166
|
|
|
167
167
|
filePath ??= this .filePath ?? this .fileId ?? this .browser .getWorldURL ();
|
|
168
168
|
|
|
169
|
-
return global .addNameSpace (md5 (filePath)
|
|
169
|
+
return global .addNameSpace (`${md5 (filePath)}.`);
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
package/src/Application/Tabs.js
CHANGED
|
@@ -3,35 +3,56 @@
|
|
|
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: [ ],
|
|
46
|
+
closedTabs: [ ],
|
|
27
47
|
scrollLeft: 0,
|
|
28
48
|
});
|
|
29
49
|
|
|
30
|
-
|
|
31
|
-
|
|
50
|
+
electron .ipcRenderer .send ("locale", _.locale);
|
|
51
|
+
|
|
52
|
+
// Connect to TabGroup Events
|
|
53
|
+
|
|
54
|
+
this .tabs = $("tab-group") .get (0);
|
|
32
55
|
|
|
33
|
-
initialize ()
|
|
34
|
-
{
|
|
35
56
|
this .tabs .on ("tab-active", tab =>
|
|
36
57
|
{
|
|
37
58
|
electron .ipcRenderer .send ("title", tab .getTitle ());
|
|
@@ -39,25 +60,25 @@ module .exports = new class Tabs
|
|
|
39
60
|
|
|
40
61
|
tab .initialized = true;
|
|
41
62
|
|
|
42
|
-
|
|
43
|
-
tab .webview .send ("activate");
|
|
44
|
-
|
|
63
|
+
this .activateTab (tab);
|
|
45
64
|
this .saveTabs ();
|
|
46
65
|
});
|
|
47
66
|
|
|
48
|
-
this .tabs .on ("tab-removed", (
|
|
67
|
+
this .tabs .on ("tab-removed", () => this .saveTabs ());
|
|
49
68
|
|
|
50
69
|
// Actions
|
|
51
70
|
|
|
52
|
-
electron .ipcRenderer .on ("
|
|
53
|
-
|
|
71
|
+
electron .ipcRenderer .on ("tabs-menu", (event, key, ... args) => this [key] (... args));
|
|
72
|
+
|
|
73
|
+
electron .ipcRenderer .on ("open-files", (event, urls) => this .openTabs (urls));
|
|
74
|
+
electron .ipcRenderer .on ("reload" , () => this .reloadTab ());
|
|
54
75
|
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", (
|
|
76
|
+
electron .ipcRenderer .on ("save-all-files", () => this .saveAllFiles ());
|
|
77
|
+
electron .ipcRenderer .on ("close-tab", () => this .tabs .getActiveTab () ?.close (true));
|
|
78
|
+
electron .ipcRenderer .on ("close-all-tabs", () => this .closeAllTabs ());
|
|
79
|
+
electron .ipcRenderer .on ("quit", () => this .quit ());
|
|
59
80
|
|
|
60
|
-
electron .ipcRenderer .on ("toggle-developer-tools", (
|
|
81
|
+
electron .ipcRenderer .on ("toggle-developer-tools", () => this .tabs .getActiveTab () .webview .openDevTools ());
|
|
61
82
|
|
|
62
83
|
$(window) .on ("beforeunload", () => this .close ());
|
|
63
84
|
|
|
@@ -94,7 +115,6 @@ module .exports = new class Tabs
|
|
|
94
115
|
this .forwardToActiveTab ("tone-mapping");
|
|
95
116
|
this .forwardToActiveTab ("order-independent-transparency");
|
|
96
117
|
this .forwardToActiveTab ("logarithmic-depth-buffer");
|
|
97
|
-
this .forwardToActiveTab ("mute");
|
|
98
118
|
this .forwardToActiveTab ("display-rubberband");
|
|
99
119
|
this .forwardToActiveTab ("display-timings");
|
|
100
120
|
this .forwardToActiveTab ("show-library");
|
|
@@ -121,8 +141,6 @@ module .exports = new class Tabs
|
|
|
121
141
|
|
|
122
142
|
restoreTabs (activeTab)
|
|
123
143
|
{
|
|
124
|
-
const config = new DataStorage (localStorage, "Sunrize.");
|
|
125
|
-
|
|
126
144
|
const openTabs = this .config .openTabs .filter (fileURL =>
|
|
127
145
|
{
|
|
128
146
|
if (!fileURL .startsWith ("file:"))
|
|
@@ -131,13 +149,6 @@ module .exports = new class Tabs
|
|
|
131
149
|
if (fs .existsSync (url .fileURLToPath (fileURL)))
|
|
132
150
|
return true;
|
|
133
151
|
|
|
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
152
|
return false;
|
|
142
153
|
});
|
|
143
154
|
|
|
@@ -168,6 +179,8 @@ module .exports = new class Tabs
|
|
|
168
179
|
|
|
169
180
|
for (let fileURL of urls)
|
|
170
181
|
{
|
|
182
|
+
// Make Tab URL
|
|
183
|
+
|
|
171
184
|
if (fileURL && this .tabs .getTabs () .some (tab => tab .url === fileURL))
|
|
172
185
|
continue;
|
|
173
186
|
|
|
@@ -176,6 +189,8 @@ module .exports = new class Tabs
|
|
|
176
189
|
|
|
177
190
|
src .searchParams .set ("url", fileURL);
|
|
178
191
|
|
|
192
|
+
// Create Tab
|
|
193
|
+
|
|
179
194
|
const tab = this .tabs .addTab ({
|
|
180
195
|
src: src,
|
|
181
196
|
webviewAttributes: {
|
|
@@ -189,18 +204,73 @@ module .exports = new class Tabs
|
|
|
189
204
|
|
|
190
205
|
this .setTabURL (tab, fileURL);
|
|
191
206
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
207
|
+
const config = this .getTabConfig (tab);
|
|
208
|
+
|
|
209
|
+
config .setDefaultValues ({
|
|
210
|
+
pinned: false,
|
|
195
211
|
});
|
|
196
212
|
|
|
213
|
+
// Tab Context Menu
|
|
214
|
+
|
|
215
|
+
$(tab .element)
|
|
216
|
+
.attr ("tabindex", 0)
|
|
217
|
+
.on ("contextmenu", () => this .showContextMenu (tab));
|
|
218
|
+
|
|
219
|
+
// Tab Icon
|
|
220
|
+
|
|
221
|
+
tab .setIcon (this .getIcon (config .encoding ?? "DEFAULT"));
|
|
222
|
+
|
|
223
|
+
// Close Button
|
|
224
|
+
|
|
197
225
|
tab .on ("closing", (tab, abort) => this .tabClosing (tab, abort));
|
|
198
226
|
tab .on ("close", (tab) => this .tabClose (tab));
|
|
199
227
|
|
|
200
|
-
tab .
|
|
228
|
+
tab .closeButton = $(tab .element) .find (".tab-close");
|
|
229
|
+
|
|
230
|
+
tab .closeButton .find ("button")
|
|
231
|
+
.addClass ("material-symbols-outlined")
|
|
232
|
+
.text ("close");
|
|
233
|
+
|
|
234
|
+
// Sound Button
|
|
235
|
+
|
|
236
|
+
tab .muteButton = $("<span></span>")
|
|
237
|
+
.addClass (["tab-mute", "material-symbols-outlined"])
|
|
238
|
+
.text ("volume_up")
|
|
239
|
+
.on ("click", () => tab .webview .send ("mute", !tab .mute));
|
|
240
|
+
|
|
241
|
+
tab .closeButton .before (tab .muteButton);
|
|
242
|
+
|
|
243
|
+
// Pin Button
|
|
244
|
+
|
|
245
|
+
tab .pinButton = $("<span></span>")
|
|
246
|
+
.addClass ("tab-pin")
|
|
247
|
+
.append ($("<span></span>")
|
|
248
|
+
.addClass ("material-symbols-outlined")
|
|
249
|
+
.text ("keep"));
|
|
250
|
+
|
|
251
|
+
tab .closeButton .before (tab .pinButton);
|
|
252
|
+
|
|
253
|
+
this .menuPinTab (tab .getPosition (), config .pinned);
|
|
254
|
+
|
|
255
|
+
// Events
|
|
256
|
+
|
|
257
|
+
tab .webview .addEventListener ("dom-ready", () =>
|
|
258
|
+
{
|
|
259
|
+
tab .domReady = true;
|
|
260
|
+
|
|
261
|
+
this .activateTab (tab);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
tab .webview .addEventListener ("ipc-message", event =>
|
|
201
265
|
{
|
|
202
266
|
switch (event .channel)
|
|
203
267
|
{
|
|
268
|
+
case "scene-encoding":
|
|
269
|
+
{
|
|
270
|
+
config .encoding = event .args [0];
|
|
271
|
+
tab .setIcon (this .getIcon (event .args [0]));
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
204
274
|
case "focus":
|
|
205
275
|
{
|
|
206
276
|
document .activeElement ?.blur ();
|
|
@@ -212,15 +282,22 @@ module .exports = new class Tabs
|
|
|
212
282
|
this .setTabURL (tab, tab .url, ... event .args);
|
|
213
283
|
break;
|
|
214
284
|
}
|
|
285
|
+
case "mute-button":
|
|
286
|
+
{
|
|
287
|
+
this .showMuteButton (tab, ... event .args);
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
case "mute":
|
|
291
|
+
{
|
|
292
|
+
this .setMute (tab, ... event .args);
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
215
295
|
}
|
|
216
296
|
});
|
|
217
297
|
|
|
218
|
-
tab .webview .addEventListener ("
|
|
298
|
+
tab .webview .addEventListener ("console-message", (event) =>
|
|
219
299
|
{
|
|
220
|
-
tab .
|
|
221
|
-
|
|
222
|
-
if (this .tabs .getActiveTab () === tab)
|
|
223
|
-
tab .webview .send ("activate");
|
|
300
|
+
tab .webview .send ("console-message", event .level, event .sourceId, event .line, event .message);
|
|
224
301
|
});
|
|
225
302
|
}
|
|
226
303
|
|
|
@@ -235,19 +312,208 @@ module .exports = new class Tabs
|
|
|
235
312
|
this .saveTabs ();
|
|
236
313
|
}
|
|
237
314
|
|
|
238
|
-
|
|
315
|
+
getIcon (encoding)
|
|
316
|
+
{
|
|
317
|
+
return this .icons .get (encoding) ?? this .icons .get ("OTHERS");
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Context Menu
|
|
321
|
+
|
|
322
|
+
showContextMenu (tab)
|
|
323
|
+
{
|
|
324
|
+
$(tab .element) .trigger ("focus");
|
|
325
|
+
|
|
326
|
+
const menu = [
|
|
327
|
+
{
|
|
328
|
+
label: tab .url .startsWith ("file:") ? _("Copy Path") : _("Copy URL"),
|
|
329
|
+
visible: !tab .url .startsWith ("id:"),
|
|
330
|
+
args: ["menuCopyURL", tab .getPosition ()],
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
label: (() =>
|
|
334
|
+
{
|
|
335
|
+
switch (process .platform)
|
|
336
|
+
{
|
|
337
|
+
case "darwin": return _("Reveal File in Finder");
|
|
338
|
+
case "win32": return _("Reveal File in File Explorer");
|
|
339
|
+
default: return _("Reveal File in File Manager");
|
|
340
|
+
}
|
|
341
|
+
})(),
|
|
342
|
+
visible: tab .url .startsWith ("file:"),
|
|
343
|
+
args: ["menuShowItemInFolder", tab .getPosition ()],
|
|
344
|
+
},
|
|
345
|
+
{ type: "separator" },
|
|
346
|
+
{
|
|
347
|
+
label: _("Reload Tab"),
|
|
348
|
+
accelerator: "F5",
|
|
349
|
+
args: ["menuReloadTab", tab .getPosition ()],
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
label: tab .pinButton .is (":visible") ? _("Unpin Tab") : _("Pin Tab"),
|
|
353
|
+
args: ["menuPinTab", tab .getPosition ()],
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
label: tab .mute ? _("Unmute Tab") : _("Mute Tab"),
|
|
357
|
+
args: ["menuToggleMuteTab", tab .getPosition ()],
|
|
358
|
+
},
|
|
359
|
+
{ type: "separator" },
|
|
360
|
+
{
|
|
361
|
+
label: _("Move Tab"),
|
|
362
|
+
submenu: [
|
|
363
|
+
{
|
|
364
|
+
label: _("Move to Start"),
|
|
365
|
+
enabled: tab .getPosition () !== 0,
|
|
366
|
+
args: ["menuMoveTabToStart", tab .getPosition ()],
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
label: _("Move to End"),
|
|
370
|
+
enabled: tab .getPosition () !== this .getTabs () .length - 1,
|
|
371
|
+
args: ["menuMoveTabToEnd", tab .getPosition ()],
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
},
|
|
375
|
+
{ type: "separator" },
|
|
376
|
+
{
|
|
377
|
+
label: _("Close Tab"),
|
|
378
|
+
args: ["menuCloseTab", tab .getPosition ()],
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
label: _("Close Other Tabs"),
|
|
382
|
+
args: ["menuCloseOtherTabs", tab .getPosition ()],
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
label: _("Close All Tabs"),
|
|
386
|
+
accelerator: "Option+CmdOrCtrl+W",
|
|
387
|
+
args: ["menuCloseOtherTabs", -1],
|
|
388
|
+
},
|
|
389
|
+
{ type: "separator" },
|
|
390
|
+
{
|
|
391
|
+
label: _("Reopen Closed Tab"),
|
|
392
|
+
enabled: this .config .closedTabs .length,
|
|
393
|
+
args: ["menuReopenClosedTab"],
|
|
394
|
+
},
|
|
395
|
+
];
|
|
396
|
+
|
|
397
|
+
electron .ipcRenderer .send ("context-menu", "tabs-menu", menu);
|
|
398
|
+
electron .ipcRenderer .once ("tabs-menu-will-close", () => $(tab .element) .trigger ("blur"));
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
menuCopyURL (position)
|
|
402
|
+
{
|
|
403
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
404
|
+
|
|
405
|
+
if (tab .url .startsWith ("file:"))
|
|
406
|
+
navigator .clipboard .writeText (url .fileURLToPath (tab .url));
|
|
407
|
+
else
|
|
408
|
+
navigator .clipboard .writeText (tab .url);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
menuShowItemInFolder (position)
|
|
412
|
+
{
|
|
413
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
414
|
+
|
|
415
|
+
electron .shell .showItemInFolder (url .fileURLToPath (tab .url));
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
menuReloadTab (position)
|
|
419
|
+
{
|
|
420
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
421
|
+
|
|
422
|
+
this .reloadTab (tab);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
menuPinTab (position, pinned)
|
|
239
426
|
{
|
|
240
427
|
const
|
|
241
|
-
tab
|
|
242
|
-
|
|
428
|
+
tab = this .tabs .getTabByPosition (position),
|
|
429
|
+
config = this .getTabConfig (tab);
|
|
243
430
|
|
|
244
|
-
|
|
431
|
+
if (pinned ?? !tab .pinButton .is (":visible"))
|
|
432
|
+
{
|
|
433
|
+
config .pinned = true;
|
|
245
434
|
|
|
246
|
-
|
|
435
|
+
tab .pinButton .show ();
|
|
436
|
+
tab .closeButton .hide ();
|
|
437
|
+
}
|
|
438
|
+
else
|
|
439
|
+
{
|
|
440
|
+
config .pinned = false;
|
|
247
441
|
|
|
248
|
-
|
|
442
|
+
tab .pinButton .hide ();
|
|
443
|
+
tab .closeButton .show ();
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
menuMoveTabToStart (position)
|
|
448
|
+
{
|
|
449
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
450
|
+
|
|
451
|
+
tab .setPosition (0);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
menuMoveTabToEnd (position)
|
|
455
|
+
{
|
|
456
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
457
|
+
|
|
458
|
+
tab .setPosition (this .getTabs () .length);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
menuToggleMuteTab (position)
|
|
462
|
+
{
|
|
463
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
464
|
+
|
|
465
|
+
tab .webview .send ("mute", !tab .mute);
|
|
249
466
|
}
|
|
250
467
|
|
|
468
|
+
menuCloseTab (position)
|
|
469
|
+
{
|
|
470
|
+
const tab = this .tabs .getTabByPosition (position);
|
|
471
|
+
|
|
472
|
+
tab .close (true);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
menuCloseOtherTabs (position)
|
|
476
|
+
{
|
|
477
|
+
const
|
|
478
|
+
tabs = this .getTabs (),
|
|
479
|
+
length = tabs .length;
|
|
480
|
+
|
|
481
|
+
for (let i = length - 1; i >= 0; -- i)
|
|
482
|
+
{
|
|
483
|
+
if (i === position)
|
|
484
|
+
continue;
|
|
485
|
+
|
|
486
|
+
const tab = this .tabs .getTabByPosition (i);
|
|
487
|
+
|
|
488
|
+
if (tab .pinButton .is (":visible"))
|
|
489
|
+
continue;
|
|
490
|
+
|
|
491
|
+
tab .close (true);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
menuReopenClosedTab ()
|
|
496
|
+
{
|
|
497
|
+
const
|
|
498
|
+
closedTabs = this .config .closedTabs,
|
|
499
|
+
closedTabURL = closedTabs .pop ();
|
|
500
|
+
|
|
501
|
+
this .config .closedTabs = closedTabs;
|
|
502
|
+
|
|
503
|
+
if (!closedTabURL)
|
|
504
|
+
return;
|
|
505
|
+
|
|
506
|
+
if (closedTabURL .startsWith ("file:"))
|
|
507
|
+
{
|
|
508
|
+
if (!fs .existsSync (url .fileURLToPath (closedTabURL)))
|
|
509
|
+
return this .menuReopenClosedTab (); // Try next.
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
this .openTabs ([closedTabURL]);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// Tab Handling
|
|
516
|
+
|
|
251
517
|
getTabs ()
|
|
252
518
|
{
|
|
253
519
|
const cmp = (a, b) => (a > b) - (a < b);
|
|
@@ -256,6 +522,22 @@ module .exports = new class Tabs
|
|
|
256
522
|
.sort ((a, b) => cmp (a .getPosition (), b .getPosition ()));
|
|
257
523
|
}
|
|
258
524
|
|
|
525
|
+
getTabConfig (tab)
|
|
526
|
+
{
|
|
527
|
+
return new DataStorage (localStorage, `Sunrize.Tabs.${md5 (tab .url)}.`);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
reloadTab (tab = this .tabs .getActiveTab ())
|
|
531
|
+
{
|
|
532
|
+
const src = url .pathToFileURL (path .join (__dirname, "../assets/html/window.html"));
|
|
533
|
+
|
|
534
|
+
src .searchParams .set ("url", tab .url);
|
|
535
|
+
|
|
536
|
+
tab .webview .src = src;
|
|
537
|
+
|
|
538
|
+
this .setTabURL (tab, tab .url, true);
|
|
539
|
+
}
|
|
540
|
+
|
|
259
541
|
getTabByURL (fileURL)
|
|
260
542
|
{
|
|
261
543
|
return this .getTabs () .findLast (tab => tab .url === fileURL);
|
|
@@ -275,6 +557,22 @@ module .exports = new class Tabs
|
|
|
275
557
|
this .saveTabs ();
|
|
276
558
|
}
|
|
277
559
|
|
|
560
|
+
activeTab = null;
|
|
561
|
+
|
|
562
|
+
activateTab (tab)
|
|
563
|
+
{
|
|
564
|
+
if (!tab .domReady)
|
|
565
|
+
return;
|
|
566
|
+
|
|
567
|
+
if (tab !== this .tabs .getActiveTab ())
|
|
568
|
+
return;
|
|
569
|
+
|
|
570
|
+
this .activeTab ?.webview .send ("activate", false);
|
|
571
|
+
tab .webview .send ("activate", true);
|
|
572
|
+
|
|
573
|
+
this .activeTab = tab;
|
|
574
|
+
}
|
|
575
|
+
|
|
278
576
|
saveTabs ()
|
|
279
577
|
{
|
|
280
578
|
const
|
|
@@ -285,10 +583,27 @@ module .exports = new class Tabs
|
|
|
285
583
|
this .config .activeTab = tabs .length ? this .tabs .getActiveTab () .url : undefined;
|
|
286
584
|
}
|
|
287
585
|
|
|
288
|
-
|
|
586
|
+
showMuteButton (tab, value)
|
|
587
|
+
{
|
|
588
|
+
if (value)
|
|
589
|
+
tab .muteButton .show ();
|
|
590
|
+
else
|
|
591
|
+
tab .muteButton .hide ();
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
setMute (tab, value)
|
|
595
|
+
{
|
|
596
|
+
tab .mute = value;
|
|
597
|
+
|
|
598
|
+
tab .muteButton .text (value ? "volume_mute" : "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
|
|
|
@@ -306,13 +621,28 @@ module .exports = new class Tabs
|
|
|
306
621
|
|
|
307
622
|
tabClose (tab)
|
|
308
623
|
{
|
|
309
|
-
//
|
|
624
|
+
// Save closed tab.
|
|
625
|
+
|
|
626
|
+
const closedTabs = this .config .closedTabs;
|
|
627
|
+
|
|
628
|
+
if (closedTabs .at (-1) !== tab .url)
|
|
629
|
+
{
|
|
630
|
+
closedTabs .push (tab .url);
|
|
631
|
+
|
|
632
|
+
this .config .closedTabs = closedTabs .slice (-100);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// Add closed url to recent locations.
|
|
310
636
|
|
|
311
637
|
electron .ipcRenderer .send ("add-recent-location", tab .url);
|
|
312
638
|
|
|
639
|
+
// If all tabs are closed, open empty tab.
|
|
640
|
+
|
|
313
641
|
if (!this .tabs .getTabs () .length)
|
|
314
642
|
this .openTabs ();
|
|
315
643
|
|
|
644
|
+
// Save tabs.
|
|
645
|
+
|
|
316
646
|
this .saveTabs ();
|
|
317
647
|
}
|
|
318
648
|
|
|
@@ -336,7 +666,12 @@ module .exports = new class Tabs
|
|
|
336
666
|
closeAllTabs ()
|
|
337
667
|
{
|
|
338
668
|
for (const tab of this .tabs .getTabs ())
|
|
669
|
+
{
|
|
670
|
+
if (tab .pinButton .is (":visible"))
|
|
671
|
+
continue;
|
|
672
|
+
|
|
339
673
|
tab .close (true);
|
|
674
|
+
}
|
|
340
675
|
}
|
|
341
676
|
|
|
342
677
|
close ()
|
|
@@ -372,20 +707,20 @@ module .exports = new class Tabs
|
|
|
372
707
|
for (const tab of tabs)
|
|
373
708
|
tab .webview .send ("close");
|
|
374
709
|
|
|
375
|
-
|
|
710
|
+
this .maintenance ();
|
|
376
711
|
}
|
|
377
712
|
|
|
378
713
|
maintenance ()
|
|
379
714
|
{
|
|
380
715
|
// Remove items older than one year, time in milliseconds.
|
|
381
|
-
new DataStorage (localStorage, "Sunrize.") .removeItems (Date .now () - (1000 * 60 * 60 * 24 * 365));
|
|
716
|
+
// new DataStorage (localStorage, "Sunrize.") .removeItems (Date .now () - (1000 * 60 * 60 * 24 * 365));
|
|
382
717
|
}
|
|
383
718
|
|
|
384
719
|
// Send messages to tabs
|
|
385
720
|
|
|
386
721
|
forwardToActiveTab (channel)
|
|
387
722
|
{
|
|
388
|
-
electron .ipcRenderer .on (channel, (event, ... args) => this .tabs .getActiveTab ()
|
|
723
|
+
electron .ipcRenderer .on (channel, (event, ... args) => this .tabs .getActiveTab () ?.webview .send (channel, ... args));
|
|
389
724
|
}
|
|
390
725
|
|
|
391
726
|
forwardToAllTabs (channel)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const
|
|
4
|
+
$ = require ("jquery"),
|
|
5
|
+
electron = require ("electron"),
|
|
6
|
+
Interface = require ("./Interface"),
|
|
7
|
+
Editor = require("../Undo/Editor"),
|
|
8
|
+
_ = require ("./GetText");
|
|
9
|
+
|
|
10
|
+
module .exports = class TopBar extends Interface
|
|
11
|
+
{
|
|
12
|
+
constructor (element, document)
|
|
13
|
+
{
|
|
14
|
+
super ("Sunrize.TopBar.");
|
|
15
|
+
|
|
16
|
+
this .document = document;
|
|
17
|
+
this .topBar = element;
|
|
18
|
+
|
|
19
|
+
this .setup ();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async initialize ()
|
|
23
|
+
{
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
configure ()
|
|
27
|
+
{
|
|
28
|
+
this .config .file .setDefaultValues ({
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
@@ -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)
|