sunrize 1.9.1 → 1.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sunrize",
3
3
  "productName": "Sunrize X3D Editor",
4
- "version": "1.9.1",
4
+ "version": "1.10.0",
5
5
  "description": "A Multi-Platform X3D Editor",
6
6
  "main": "src/main.js",
7
7
  "bin": {
@@ -20,9 +20,7 @@
20
20
  "premake": "npm i -D electron",
21
21
  "make": "electron-forge make",
22
22
  "postmake": "npm i -P electron",
23
- "pregithub": "npm i -D electron",
24
- "github": "electron-forge publish",
25
- "postgithub": "npm i -P electron",
23
+ "publish-to-github": "node build/publish-to-github.js",
26
24
  "predocs": "rm -f -r docs/_site/",
27
25
  "docs": "cd docs && bundle exec jekyll serve --ssl-key ssl/server.key --ssl-cert ssl/server.crt --incremental --host=`ipconfig getifaddr en0`",
28
26
  "predocs-install": "cd docs && ln -s -f ../../ssl ./",
@@ -103,14 +101,14 @@
103
101
  "material-symbols": "^0.35.0",
104
102
  "md5": "^2.3.0",
105
103
  "mime-types": "^3.0.1",
106
- "monaco-editor": "^0.50.0",
104
+ "monaco-editor": "^0.53.0",
107
105
  "node-localstorage": "^3.0.5",
108
106
  "qtip2": "^3.0.3",
109
107
  "spectrum-colorpicker2": "^2.0.10",
110
108
  "string-similarity": "^4.0.4",
111
109
  "tweakpane": "^3.1.10",
112
110
  "update-electron-app": "^3.1.1",
113
- "x_ite": "^12.0.7",
111
+ "x_ite": "^12.0.8",
114
112
  "x3d-traverse": "^1.0.13"
115
113
  }
116
114
  }
@@ -384,9 +384,14 @@ module .exports = class Application
384
384
  },
385
385
  { type: "separator" },
386
386
  {
387
- label: _("Close"),
387
+ label: _("Close Tab"),
388
388
  accelerator: "CmdOrCtrl+W",
389
- click: () => this .mainWindow .webContents .send ("close"),
389
+ click: () => this .mainWindow .webContents .send ("close-tab"),
390
+ },
391
+ {
392
+ label: _("Close All Tabs"),
393
+ accelerator: "Option+CmdOrCtrl+W",
394
+ click: () => this .mainWindow .webContents .send ("close-all-tabs"),
390
395
  },
391
396
  ... process .platform === "darwin" ?
392
397
  [ ]
@@ -424,22 +429,49 @@ module .exports = class Application
424
429
  { type: "separator" },
425
430
  { role: "selectAll" },
426
431
  ],
432
+ ]
433
+ }
434
+ : this .menuOptions .monacoEditor ?
435
+ {
436
+ role: "editMenu",
437
+ submenu: [
438
+ {
439
+ label: _("Undo"),
440
+ accelerator: "CmdOrCtrl+Z",
441
+ click: () => this .mainWindow .webContents .send ("script-editor", "triggerEvent", "keyboard", "undo", null),
442
+ },
443
+ {
444
+ label: _("Redo"),
445
+ accelerator: "CmdOrCtrl+Shift+Z",
446
+ click: () => this .mainWindow .webContents .send ("script-editor", "triggerEvent", "keyboard", "redo", null),
447
+ },
448
+ { type: "separator" },
449
+ {
450
+ role: "cut",
451
+ click: () => this .mainWindow .webContents .send ("script-editor", "cutOrCopy", "cut"),
452
+ },
453
+ {
454
+ role: "copy",
455
+ click: () => this .mainWindow .webContents .send ("script-editor", "cutOrCopy", "copy"),
456
+ },
457
+ {
458
+ role: "paste",
459
+ click: () => this .mainWindow .webContents .send ("script-editor", "paste"),
460
+ },
427
461
  { type: "separator" },
428
462
  {
429
463
  label: _("Toggle Line Comment"),
430
464
  accelerator: process .platform === "darwin" ? "CmdOrCtrl+Shift+7" : "CmdOrCtrl+#",
431
- enabled: this .menuOptions .monacoEditor,
432
465
  click: () => this .mainWindow .webContents .send ("script-editor", "runAction", "editor.action.commentLine"),
433
466
  },
434
467
  {
435
468
  label: _("Toggle Block Comment"),
436
469
  accelerator: "Alt+Shift+A",
437
- enabled: this .menuOptions .monacoEditor,
438
470
  click: () => this .mainWindow .webContents .send ("script-editor", "runAction", "editor.action.blockComment"),
439
471
  },
440
472
  ]
441
473
  }
442
- :
474
+ : // Outline Editor, Browser
443
475
  {
444
476
  role: "editMenu",
445
477
  submenu: [
@@ -456,15 +488,9 @@ module .exports = class Application
456
488
  click: () => this .mainWindow .webContents .send ("redo"),
457
489
  },
458
490
  { type: "separator" },
459
- {
460
- role: "cut",
461
- },
462
- {
463
- role: "copy",
464
- },
465
- {
466
- role: "paste",
467
- },
491
+ { role: "cut" },
492
+ { role: "copy" },
493
+ { role: "paste" },
468
494
  {
469
495
  label: _("Delete"),
470
496
  accelerator: "CmdOrCtrl+Backspace",
@@ -932,7 +958,7 @@ module .exports = class Application
932
958
  {
933
959
  if (menuItem .submenu)
934
960
  this .addMenuItemHandlers (id, menuItem .submenu);
935
- else
961
+ else if (menuItem .args)
936
962
  menuItem .click = () => this .mainWindow .webContents .send (id, ... menuItem .args);
937
963
  }
938
964
 
@@ -92,7 +92,7 @@ module .exports = class Dashboard extends Interface
92
92
 
93
93
  this .showPanelsButton = $("<span></span>")
94
94
  .addClass (["material-symbols-outlined"])
95
- .attr ("title", _("Toggle visibility of Panel."))
95
+ .attr ("title", _("Show Node Panel."))
96
96
  .text ("edit_note")
97
97
  .appendTo (this .toolbar)
98
98
  .on ("click", () => this .togglePanel (!this .config .file .panel));
@@ -272,9 +272,37 @@ module .exports = class Document extends Interface
272
272
  {
273
273
  this .activeElement = document .activeElement ? $(document .activeElement) : null;
274
274
 
275
+ if (this .activeElement ?.is ("input, textarea"))
276
+ {
277
+ this .activeElement
278
+ .off ("contextmenu.Document")
279
+ .on ("contextmenu.Document", () => this .showContextMenu ());
280
+ }
281
+
275
282
  electron .ipcRenderer .send ("update-menu", this .updateEditMenu ({ }));
276
283
  }
277
284
 
285
+ async showContextMenu ()
286
+ {
287
+ await $.sleep ();
288
+
289
+ if (this .activeElementIsMonacoEditor ())
290
+ return;
291
+
292
+ const menu = [
293
+ { role: "undo", accelerator: "CmdOrCtrl+Z" },
294
+ { role: "redo", accelerator: "Shift+CmdOrCtrl+Z" },
295
+ { type: "separator" },
296
+ { role: "cut", accelerator: "CmdOrCtrl+X" },
297
+ { role: "copy", accelerator: "CmdOrCtrl+C" },
298
+ { role: "paste", accelerator: "CmdOrCtrl+P" },
299
+ { type: "separator" },
300
+ { role: "selectAll", accelerator: "CmdOrCtrl+A" },
301
+ ];
302
+
303
+ electron .ipcRenderer .send ("context-menu", "default-context-menu", menu);
304
+ }
305
+
278
306
  updateEditMenu (menu)
279
307
  {
280
308
  return Object .assign (menu,
@@ -314,6 +342,9 @@ module .exports = class Document extends Interface
314
342
  if (!this .activeElement .closest (".monaco-editor") .length)
315
343
  return false;
316
344
 
345
+ if (this .activeElement .closest (".ibwrapper") .length)
346
+ return false;
347
+
317
348
  return true;
318
349
  }
319
350
 
@@ -586,6 +617,9 @@ Viewpoint {
586
617
  if (this .activeElementIsInputOrOutput ())
587
618
  return;
588
619
 
620
+ if (this .activeElementIsMonacoEditor ())
621
+ return;
622
+
589
623
  this .sidebar .outlineEditor .cutNodes ();
590
624
  return false;
591
625
  }
@@ -595,6 +629,9 @@ Viewpoint {
595
629
  if (this .activeElementIsInputOrOutput ())
596
630
  return;
597
631
 
632
+ if (this .activeElementIsMonacoEditor ())
633
+ return;
634
+
598
635
  this .sidebar .outlineEditor .copyNodes (true);
599
636
  return false;
600
637
  }
@@ -604,6 +641,9 @@ Viewpoint {
604
641
  if (this .activeElementIsInputOrOutput ())
605
642
  return;
606
643
 
644
+ if (this .activeElementIsMonacoEditor ())
645
+ return;
646
+
607
647
  this .sidebar .outlineEditor .pasteNodes ();
608
648
  return false;
609
649
  }
@@ -54,7 +54,8 @@ module .exports = new class Tabs
54
54
  electron .ipcRenderer .on ("save-file", (event) => this .saveFile ());
55
55
  electron .ipcRenderer .on ("save-file-as", (event, filePath) => this .saveFileAs (filePath));
56
56
  electron .ipcRenderer .on ("save-all-files", (event) => this .saveAllFiles ());
57
- electron .ipcRenderer .on ("close", (event) => this .tabs .getActiveTab () ?.close (true));
57
+ electron .ipcRenderer .on ("close-tab", (event) => this .tabs .getActiveTab () ?.close (true));
58
+ electron .ipcRenderer .on ("close-all-tabs", (event) => this .closeAllTabs ());
58
59
  electron .ipcRenderer .on ("quit", (event) => this .quit ());
59
60
 
60
61
  electron .ipcRenderer .on ("toggle-developer-tools", (event) => this .tabs .getActiveTab () .webview .openDevTools ());
@@ -336,6 +337,12 @@ module .exports = new class Tabs
336
337
  tab .webview .send ("save-file");
337
338
  }
338
339
 
340
+ closeAllTabs ()
341
+ {
342
+ for (const tab of this .tabs .getTabs ())
343
+ tab .close (true);
344
+ }
345
+
339
346
  close ()
340
347
  {
341
348
  this .saveTabs ();
@@ -151,6 +151,7 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
151
151
  { type: "separator" },
152
152
  {
153
153
  label: _("Paste"),
154
+ accelerator: "CmdOrCtrl+V",
154
155
  visible: field .getType () === X3D .X3DConstants .SFNode || field .getType () === X3D .X3DConstants .MFNode,
155
156
  args: ["pasteNodes", element .attr ("id"), executionContext .getId (), node .getId (), field .getId ()],
156
157
  },
@@ -223,18 +224,22 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
223
224
  { type: "separator" },
224
225
  {
225
226
  label: _("Cut"),
227
+ accelerator: "CmdOrCtrl+X",
226
228
  args: ["cutNodes"],
227
229
  },
228
230
  {
229
231
  label: _("Copy"),
232
+ accelerator: "CmdOrCtrl+C",
230
233
  args: ["copyNodes"],
231
234
  },
232
235
  {
233
236
  label: _("Paste"),
237
+ accelerator: "CmdOrCtrl+V",
234
238
  args: ["pasteNodes", element .attr ("id"), executionContext .getId (), node .getId ()],
235
239
  },
236
240
  {
237
241
  label: _("Delete"),
242
+ accelerator: "CmdOrCtrl+Backspace",
238
243
  args: ["deleteNodes"],
239
244
  },
240
245
  {
@@ -537,14 +542,17 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
537
542
  var menu = [
538
543
  {
539
544
  label: _("Cut"),
545
+ accelerator: "CmdOrCtrl+X",
540
546
  args: ["cutNodes"],
541
547
  },
542
548
  {
543
549
  label: _("Copy"),
550
+ accelerator: "CmdOrCtrl+C",
544
551
  args: ["copyNodes"],
545
552
  },
546
553
  {
547
554
  label: _("Delete"),
555
+ accelerator: "CmdOrCtrl+Backspace",
548
556
  args: ["deleteNodes"],
549
557
  },
550
558
  ];
@@ -670,6 +678,7 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
670
678
  },
671
679
  {
672
680
  label: _("Paste"),
681
+ accelerator: "CmdOrCtrl+V",
673
682
  args: ["pasteNodes", element .attr ("id"), executionContext .getId ()],
674
683
  },
675
684
  ];
@@ -1716,7 +1716,7 @@ module .exports = class OutlineView extends Interface
1716
1716
  .addClass ("input-selector") .appendTo (map);
1717
1717
 
1718
1718
  const inputRoutesSelector = $("<area></area>")
1719
- .attr ("title", _("Select routes."))
1719
+ .attr ("title", _("Select route(s)."))
1720
1720
  .attr ("shape", "rect")
1721
1721
  .attr ("coords", "20,0,28,7")
1722
1722
  .addClass ("input-routes-selector") .appendTo (map);
@@ -1736,7 +1736,7 @@ module .exports = class OutlineView extends Interface
1736
1736
  .addClass ("output-selector") .appendTo (map);
1737
1737
 
1738
1738
  const outputRoutesSelector = $("<area></area>")
1739
- .attr ("title", _("Select routes."))
1739
+ .attr ("title", _("Select route(s)."))
1740
1740
  .attr ("shape", "rect")
1741
1741
  .attr ("coords", "20,5,28,12")
1742
1742
  .addClass ("output-routes-selector")
@@ -1765,7 +1765,7 @@ module .exports = class OutlineView extends Interface
1765
1765
  .appendTo (map);
1766
1766
 
1767
1767
  const inputRoutesSelector = $("<area></area>")
1768
- .attr ("title", _("Select routes."))
1768
+ .attr ("title", _("Select route(s)."))
1769
1769
  .attr ("shape", "rect")
1770
1770
  .attr ("coords", "34,0,42,7")
1771
1771
  .addClass ("input-routes-selector")
@@ -1775,7 +1775,7 @@ module .exports = class OutlineView extends Interface
1775
1775
  inputRoutesSelector .attr ("href", "#");
1776
1776
 
1777
1777
  const outputRoutesSelector = $("<area></area>")
1778
- .attr ("title", _("Select routes."))
1778
+ .attr ("title", _("Select route(s)."))
1779
1779
  .attr ("shape", "rect")
1780
1780
  .addClass ("output-routes-selector")
1781
1781
  .appendTo (map);
@@ -2359,7 +2359,7 @@ module .exports = class OutlineView extends Interface
2359
2359
 
2360
2360
  $("<div></div>")
2361
2361
  .addClass (type + "-value-container")
2362
- .append ($("<input></input>") .attr ("type", "text"))
2362
+ .append ($("<input></input>") .attr ("type", "text") .attr ("lang", "en"))
2363
2363
  .appendTo (li);
2364
2364
 
2365
2365
  // Make jsTree.
@@ -2467,7 +2467,7 @@ module .exports = class OutlineView extends Interface
2467
2467
 
2468
2468
  $("<div></div>")
2469
2469
  .addClass (type + "-value-container")
2470
- .append ($("<textarea></textarea>"))
2470
+ .append ($("<textarea></textarea>") .attr ("lang", "en"))
2471
2471
  .appendTo (li)
2472
2472
 
2473
2473
  // Make jsTree.
@@ -3827,7 +3827,7 @@ module .exports = class OutlineView extends Interface
3827
3827
 
3828
3828
  selectRoutes (type, event)
3829
3829
  {
3830
- // Select routes.
3830
+ // Select route(s).
3831
3831
  }
3832
3832
 
3833
3833
  selectSingleRoute (type, event)
@@ -120,7 +120,7 @@ module .exports = new class Panel extends Interface
120
120
 
121
121
  this .container .css ({
122
122
  "overflow": "visible",
123
- "max-height": "auto",
123
+ "max-height": "unset",
124
124
  });
125
125
 
126
126
  // Create folders.
@@ -227,9 +227,9 @@ module .exports = new class SceneProperties extends Dialog
227
227
 
228
228
  this .executionContext .getWorldInfos () .addInterest ("updateWorldInfo", this);
229
229
 
230
- const window = require ("../Application/Window");
230
+ const app = require ("../Application/Window");
231
231
 
232
- this .profileAndComponents .inputs .checkbox .prop ("checked", window .config .file .inferProfileAndComponents);
232
+ this .profileAndComponents .inputs .checkbox .prop ("checked", app .config .file .inferProfileAndComponents);
233
233
 
234
234
  this .toggleInferProfileAndComponents ();
235
235
  this .updateProfile ();
@@ -251,9 +251,9 @@ module .exports = new class SceneProperties extends Dialog
251
251
 
252
252
  toggleInferProfileAndComponents ()
253
253
  {
254
- const window = require ("../Application/Window");
254
+ const app = require ("../Application/Window");
255
255
 
256
- window .config .file .inferProfileAndComponents = this .profileAndComponents .inputs .checkbox .prop ("checked");
256
+ app .config .file .inferProfileAndComponents = this .profileAndComponents .inputs .checkbox .prop ("checked");
257
257
 
258
258
  if (this .profileAndComponents .inputs .checkbox .prop ("checked"))
259
259
  this .profileAndComponents .checkboxRow .addClass ("disabled");
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  const
4
- $ = require ("jquery"),
5
- electron = require ("electron"),
6
- path = require ("path"),
7
- url = require ("url"),
8
- fs = require ("fs"),
9
- X3D = require ("../X3D"),
10
- Interface = require ("../Application/Interface"),
11
- Splitter = require ("../Controls/Splitter"),
12
- NodeList = require ("./NodeList"),
13
- Console = require ("./Console"),
14
- Editor = require ("../Undo/Editor"),
15
- UndoManager = require ("../Undo/UndoManager"),
16
- monaco = require ("monaco-editor/min/vs/loader.js"),
17
- _ = require ("../Application/GetText");
18
-
19
- monaco .require .config ({
4
+ $ = require ("jquery"),
5
+ electron = require ("electron"),
6
+ path = require ("path"),
7
+ url = require ("url"),
8
+ fs = require ("fs"),
9
+ X3D = require ("../X3D"),
10
+ Interface = require ("../Application/Interface"),
11
+ Splitter = require ("../Controls/Splitter"),
12
+ NodeList = require ("./NodeList"),
13
+ Console = require ("./Console"),
14
+ Editor = require ("../Undo/Editor"),
15
+ UndoManager = require ("../Undo/UndoManager"),
16
+ monacoLoader = require ("monaco-editor/min/vs/loader.js"),
17
+ _ = require ("../Application/GetText");
18
+
19
+ monacoLoader .require .config ({
20
20
  baseUrl: url .pathToFileURL (path .resolve (path .dirname (require .resolve ("monaco-editor/package.json")), "min")) + "/",
21
21
  });
22
22
 
@@ -137,14 +137,21 @@ module .exports = class ScriptEditor extends Interface
137
137
  this .setup ();
138
138
  }
139
139
 
140
- colorScheme (shouldUseDarkColors)
140
+ getMonaco ()
141
141
  {
142
- monaco .require (["vs/editor/editor.main"], monaco =>
142
+ return new Promise (resolve =>
143
143
  {
144
- monaco .editor .setTheme (shouldUseDarkColors ? "vs-dark" : "vs-light");
144
+ monacoLoader .require (["vs/editor/editor.main"], ({ m: monaco }) => resolve (monaco));
145
145
  });
146
146
  }
147
147
 
148
+ async colorScheme (shouldUseDarkColors)
149
+ {
150
+ const monaco = await this .getMonaco ();
151
+
152
+ monaco .editor .setTheme (shouldUseDarkColors ? "vs-dark" : "vs-light");
153
+ }
154
+
148
155
  async setNode (node)
149
156
  {
150
157
  this .directOutputButton .hide ();
@@ -368,74 +375,92 @@ module .exports = class ScriptEditor extends Interface
368
375
  "ShaderPart": "c",
369
376
  };
370
377
 
371
- getEditor (node)
378
+ async getEditor (node)
379
+ {
380
+ if (!this .editors .has (node))
381
+ this .editors .set (node, await this .createEditor (node));
382
+
383
+ return this .editors .get (node);
384
+ }
385
+
386
+ async createEditor (node)
387
+ {
388
+ const
389
+ monaco = await this .getMonaco (),
390
+ element = $("<div></div>") .addClass ("script-editor-monaco");
391
+
392
+ const editor = monaco .editor .create (element .get (0),
393
+ {
394
+ language: this .languages [node .getTypeName ()],
395
+ contextmenu: false,
396
+ automaticLayout: true,
397
+ wordWrap: "on",
398
+ wrappingIndent: "indent",
399
+ minimap: { enabled: false },
400
+ bracketPairColorization: { enabled: true },
401
+ });
402
+
403
+ editor .viewState = editor .saveViewState ();
404
+
405
+ editor .onDidFocusEditorWidget (() => this .setDeclarations (monaco));
406
+ editor .onDidBlurEditorWidget (() => this .apply ());
407
+ editor .onKeyDown (event => this .onKeyDown (event));
408
+
409
+ element .on ("mouseenter", () => this .setDeclarations (monaco));
410
+ element .on ("contextmenu", () => this .showContextMenu ());
411
+
412
+ // this .debugFindActions (editor)
413
+ return { element, editor, monaco };
414
+ }
415
+
416
+ onKeyDown (event)
372
417
  {
373
- return new Promise ((resolve, reject) =>
418
+ const { keyCode, ctrlKey, metaKey } = event;
419
+
420
+ switch (keyCode)
374
421
  {
375
- if (this .editors .has (node))
422
+ case 33: // c
376
423
  {
377
- resolve (this .editors .get (node));
424
+ if (!(metaKey || ctrlKey))
425
+ break;
426
+
427
+ event .preventDefault ();
428
+ event .stopPropagation ();
429
+ this .cutOrCopy ("copy");
430
+ break;
378
431
  }
379
- else
432
+ case 52: // v
380
433
  {
381
- monaco .require (["vs/editor/editor.main"], monaco =>
382
- {
383
- const element = $("<div></div>")
384
- .addClass ("script-editor-monaco")
385
- .appendTo (this .verticalSplitterRight);
386
-
387
- self .MonacoEnvironment =
388
- {
389
- getWorkerUrl (moduleId, label)
390
- {
391
- return url .pathToFileURL (require .resolve ("monaco-editor/min/vs/base/worker/workerMain.js"));
392
- },
393
- };
394
-
395
- const editor = monaco .editor .create (element .get (0),
396
- {
397
- language: this .languages [node .getTypeName ()],
398
- contextmenu: false,
399
- automaticLayout: true,
400
- wordWrap: "on",
401
- wrappingIndent: "indent",
402
- minimap: { enabled: false },
403
- bracketPairColorization: { enabled: true },
404
- });
405
-
406
- editor .onDidFocusEditorWidget (() => this .setDeclarations (monaco));
407
- editor .onDidBlurEditorWidget (() => this .apply ());
408
-
409
- editor .onKeyDown ((event) =>
410
- {
411
- const { keyCode, ctrlKey, metaKey } = event;
412
-
413
- if (keyCode === 52 && (metaKey || ctrlKey))
414
- {
415
- event .preventDefault ();
416
- this .paste ();
417
- }
418
- });
419
-
420
- editor .viewState = editor .saveViewState ();
421
-
422
- element .on ("mouseenter", () => this .setDeclarations (monaco))
423
- element .on ("contextmenu", () => this .showContextMenu ());
424
- element .detach ();
425
-
426
- // this .debugFindActions (editor)
427
- this .editors .set (node, { element, editor, monaco });
428
-
429
- // Return editor.
430
-
431
- resolve (this .editors .get (node));
432
- });
434
+ if (!(metaKey || ctrlKey))
435
+ break;
436
+
437
+ event .preventDefault ();
438
+ event .stopPropagation ();
439
+ this .paste ();
440
+ break;
433
441
  }
434
- });
442
+ case 54: // x
443
+ {
444
+ if (!(metaKey || ctrlKey))
445
+ break;
446
+
447
+ event .preventDefault ();
448
+ event .stopPropagation ();
449
+ this .cutOrCopy ("cut");
450
+ break;
451
+ }
452
+ }
435
453
  }
436
454
 
437
- showContextMenu ()
455
+ async showContextMenu ()
438
456
  {
457
+ await $.sleep ();
458
+
459
+ const app = require ("../Application/Window");
460
+
461
+ if (!app .activeElementIsMonacoEditor ())
462
+ return;
463
+
439
464
  const menu = [
440
465
  // {
441
466
  // label: _("Go to Definition"),
@@ -478,14 +503,17 @@ module .exports = class ScriptEditor extends Interface
478
503
  { type: "separator" },
479
504
  {
480
505
  label: _("Cut"),
481
- args: ["cutOrCopy", true],
506
+ accelerator: "CmdOrCtrl+X",
507
+ args: ["cutOrCopy", "cut"],
482
508
  },
483
509
  {
484
510
  label: _("Copy"),
485
- args: ["cutOrCopy", false],
511
+ accelerator: "CmdOrCtrl+C",
512
+ args: ["cutOrCopy", "copy"],
486
513
  },
487
514
  {
488
515
  label: _("Paste"),
516
+ accelerator: "CmdOrCtrl+V",
489
517
  args: ["paste"],
490
518
  },
491
519
  { type: "separator" },
@@ -503,6 +531,16 @@ module .exports = class ScriptEditor extends Interface
503
531
  this .editor .getAction (id) .run ();
504
532
  }
505
533
 
534
+ triggerEvent (... args)
535
+ {
536
+ this .editor .trigger (... args);
537
+ }
538
+
539
+ // execCommand (command)
540
+ // {
541
+ // document .execCommand (command);
542
+ // }
543
+
506
544
  debugFindActions (editor = this .editor)
507
545
  {
508
546
  for (const action of editor .getSupportedActions ())
@@ -552,12 +590,7 @@ module .exports = class ScriptEditor extends Interface
552
590
  }
553
591
  }
554
592
 
555
- // execCommand (command)
556
- // {
557
- // document .execCommand (command);
558
- // }
559
-
560
- cutOrCopy (cut)
593
+ cutOrCopy (type)
561
594
  {
562
595
  this .editor .focus ();
563
596
 
@@ -576,7 +609,7 @@ module .exports = class ScriptEditor extends Interface
576
609
  // Set the clipboard contents.
577
610
  navigator .clipboard .writeText (data || "");
578
611
 
579
- if (!cut)
612
+ if (type === "copy")
580
613
  return;
581
614
 
582
615
  // This is a cut operation, so replace the selection with an empty string.