@yuneta/gobj-ui 7.18.0 → 7.18.1

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.
@@ -53868,6 +53868,7 @@ var PRIVATE_DATA$1 = {
53868
53868
  _link_saved_styles: [],
53869
53869
  _focus_topic: null,
53870
53870
  _focus_ids: [],
53871
+ _on_pointerdown_focus: null,
53871
53872
  _selected_paint_ids: [],
53872
53873
  _pending_focus_topic: null,
53873
53874
  _pending_find: null,
@@ -53932,6 +53933,10 @@ function mt_destroy$1(gobj) {
53932
53933
  i18next.default.off("languageChanged", priv._on_language_changed);
53933
53934
  priv._on_language_changed = null;
53934
53935
  }
53936
+ if (priv._on_pointerdown_focus) {
53937
+ priv.$container.removeEventListener("pointerdown", priv._on_pointerdown_focus);
53938
+ priv._on_pointerdown_focus = null;
53939
+ }
53935
53940
  if (priv.theme_observer) {
53936
53941
  priv.theme_observer.disconnect();
53937
53942
  priv.theme_observer = null;
@@ -54097,6 +54102,16 @@ function configure_events(gobj) {
54097
54102
  update_toolbar(gobj);
54098
54103
  };
54099
54104
  i18next.default.on("languageChanged", priv._on_language_changed);
54105
+ priv._on_pointerdown_focus = (ev) => {
54106
+ let target = ev.target;
54107
+ if (target && typeof target.closest === "function") {
54108
+ if (target.closest("input, textarea, select, [contenteditable]")) return;
54109
+ if (target.closest(".g6-confirm-popover, .g6-create-popover,.g6-node-popover, .g6-edge-popover")) return;
54110
+ }
54111
+ let $canvas = priv.$container.querySelector("canvas");
54112
+ if ($canvas && typeof $canvas.focus === "function") $canvas.focus({ preventScroll: true });
54113
+ };
54114
+ priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus);
54100
54115
  graph.on("keydown", (evt) => {
54101
54116
  let ctrl = !!(evt.ctrlKey || evt.metaKey);
54102
54117
  if (ctrl && (evt.key === "a" || evt.key === "A")) {
@@ -58224,7 +58239,7 @@ function ac_key_down(gobj, event, kw, src) {
58224
58239
  let fullscreen = graph_get_plugin(gobj, "fullscreen");
58225
58240
  if (fullscreen) {
58226
58241
  if (key === "F" || key === "f") fullscreen.request();
58227
- else if (key === "Escape") fullscreen.exit();
58242
+ else if (key === "Escape" && priv.is_fullscreen) fullscreen.exit();
58228
58243
  }
58229
58244
  }
58230
58245
  if (!priv.edit_mode) return 0;
@@ -53855,6 +53855,7 @@ var PRIVATE_DATA$1 = {
53855
53855
  _link_saved_styles: [],
53856
53856
  _focus_topic: null,
53857
53857
  _focus_ids: [],
53858
+ _on_pointerdown_focus: null,
53858
53859
  _selected_paint_ids: [],
53859
53860
  _pending_focus_topic: null,
53860
53861
  _pending_find: null,
@@ -53919,6 +53920,10 @@ function mt_destroy$1(gobj) {
53919
53920
  i18next.off("languageChanged", priv._on_language_changed);
53920
53921
  priv._on_language_changed = null;
53921
53922
  }
53923
+ if (priv._on_pointerdown_focus) {
53924
+ priv.$container.removeEventListener("pointerdown", priv._on_pointerdown_focus);
53925
+ priv._on_pointerdown_focus = null;
53926
+ }
53922
53927
  if (priv.theme_observer) {
53923
53928
  priv.theme_observer.disconnect();
53924
53929
  priv.theme_observer = null;
@@ -54084,6 +54089,16 @@ function configure_events(gobj) {
54084
54089
  update_toolbar(gobj);
54085
54090
  };
54086
54091
  i18next.on("languageChanged", priv._on_language_changed);
54092
+ priv._on_pointerdown_focus = (ev) => {
54093
+ let target = ev.target;
54094
+ if (target && typeof target.closest === "function") {
54095
+ if (target.closest("input, textarea, select, [contenteditable]")) return;
54096
+ if (target.closest(".g6-confirm-popover, .g6-create-popover,.g6-node-popover, .g6-edge-popover")) return;
54097
+ }
54098
+ let $canvas = priv.$container.querySelector("canvas");
54099
+ if ($canvas && typeof $canvas.focus === "function") $canvas.focus({ preventScroll: true });
54100
+ };
54101
+ priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus);
54087
54102
  graph.on("keydown", (evt) => {
54088
54103
  let ctrl = !!(evt.ctrlKey || evt.metaKey);
54089
54104
  if (ctrl && (evt.key === "a" || evt.key === "A")) {
@@ -58211,7 +58226,7 @@ function ac_key_down(gobj, event, kw, src) {
58211
58226
  let fullscreen = graph_get_plugin(gobj, "fullscreen");
58212
58227
  if (fullscreen) {
58213
58228
  if (key === "F" || key === "f") fullscreen.request();
58214
- else if (key === "Escape") fullscreen.exit();
58229
+ else if (key === "Escape" && priv.is_fullscreen) fullscreen.exit();
58215
58230
  }
58216
58231
  }
58217
58232
  if (!priv.edit_mode) return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.18.0",
3
+ "version": "7.18.1",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -333,6 +333,7 @@ let PRIVATE_DATA = {
333
333
  _link_saved_styles: [], // saved port styles to restore on cancel
334
334
  _focus_topic: null, // topic currently focused (EV_FOCUS_TOPIC)
335
335
  _focus_ids: [], // node ids carrying the focus 'active' state
336
+ _on_pointerdown_focus: null, // listener keeping the keyboard on the canvas
336
337
  _selected_paint_ids: [], // node ids whose card is PAINTED selected
337
338
  // (G6's 'selected' state is the selection
338
339
  // itself; this is what is on screen, and
@@ -459,6 +460,13 @@ function mt_destroy(gobj)
459
460
  priv._on_language_changed = null;
460
461
  }
461
462
 
463
+ if(priv._on_pointerdown_focus) {
464
+ priv.$container.removeEventListener(
465
+ "pointerdown", priv._on_pointerdown_focus
466
+ );
467
+ priv._on_pointerdown_focus = null;
468
+ }
469
+
462
470
  if(priv.theme_observer) {
463
471
  priv.theme_observer.disconnect();
464
472
  priv.theme_observer = null;
@@ -787,6 +795,36 @@ function configure_events(gobj)
787
795
  };
788
796
  i18next.on('languageChanged', priv._on_language_changed);
789
797
 
798
+ /* Clicking a CARD is clicking a DOM element inside the container,
799
+ * and that takes the keyboard away from G6's canvas -- the only
800
+ * element that receives keydown. Selecting two nodes by clicking
801
+ * them and then pressing Escape did nothing, which is the most
802
+ * ordinary way there is to reach for it. The focus goes back on
803
+ * every press inside the graph.
804
+ *
805
+ * Except on what is there to be typed into: the popovers this
806
+ * gclass appends to its own container carry inputs, and stealing
807
+ * their focus on pointerdown would make them impossible to fill
808
+ * in.
809
+ */
810
+ priv._on_pointerdown_focus = (ev) => {
811
+ let target = ev.target;
812
+ if(target && typeof target.closest === "function") {
813
+ if(target.closest("input, textarea, select, [contenteditable]")) {
814
+ return;
815
+ }
816
+ if(target.closest(".g6-confirm-popover, .g6-create-popover," +
817
+ ".g6-node-popover, .g6-edge-popover")) {
818
+ return;
819
+ }
820
+ }
821
+ let $canvas = priv.$container.querySelector("canvas");
822
+ if($canvas && typeof $canvas.focus === "function") {
823
+ $canvas.focus({preventScroll: true});
824
+ }
825
+ };
826
+ priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus);
827
+
790
828
  /* The canvas carries a `tabIndex` of its own, so a keydown reaches
791
829
  * us only while the GRAPH has focus. That is what keeps Ctrl+A in
792
830
  * the find box a text selection and not a selection of every node:
@@ -6998,11 +7036,17 @@ function ac_key_down(gobj, event, kw, src)
6998
7036
  if(fullscreen) {
6999
7037
  if(key === "F" || key === "f") {
7000
7038
  fullscreen.request();
7001
- } else if(key === "Escape") {
7002
- /* Escape also clears the selection below, and both are
7003
- * right: the browser exits full screen on Escape
7004
- * whatever we do, so refusing to clear as well would
7005
- * only make the key do less than it appears to. */
7039
+ } else if(key === "Escape" && priv.is_fullscreen) {
7040
+ /* Only while actually IN full screen. Asking to leave
7041
+ * a full screen nobody entered throws, and since this
7042
+ * is now an action rather than a listener, that throw
7043
+ * takes the rest of the key with it -- which is how
7044
+ * Escape stopped clearing the selection.
7045
+ *
7046
+ * Escape does both when both apply, and that is right:
7047
+ * the browser leaves full screen on Escape whatever we
7048
+ * do, so refusing to clear as well would only make the
7049
+ * key do less than it appears to. */
7006
7050
  fullscreen.exit();
7007
7051
  }
7008
7052
  }