@yuneta/gobj-ui 7.18.0 → 7.18.2
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/dist/gobj-ui.cjs.js +34 -1
- package/dist/gobj-ui.es.js +34 -1
- package/package.json +1 -1
- package/src/c_g6_nodes_tree.js +86 -5
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -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,11 @@ 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, true);
|
|
53938
|
+
priv.$container.removeEventListener("click", priv._on_pointerdown_focus, true);
|
|
53939
|
+
priv._on_pointerdown_focus = null;
|
|
53940
|
+
}
|
|
53935
53941
|
if (priv.theme_observer) {
|
|
53936
53942
|
priv.theme_observer.disconnect();
|
|
53937
53943
|
priv.theme_observer = null;
|
|
@@ -54097,6 +54103,17 @@ function configure_events(gobj) {
|
|
|
54097
54103
|
update_toolbar(gobj);
|
|
54098
54104
|
};
|
|
54099
54105
|
i18next.default.on("languageChanged", priv._on_language_changed);
|
|
54106
|
+
priv._on_pointerdown_focus = (ev) => {
|
|
54107
|
+
let target = ev.target;
|
|
54108
|
+
if (target && typeof target.closest === "function") {
|
|
54109
|
+
if (target.closest("input, textarea, select, [contenteditable]")) return;
|
|
54110
|
+
if (target.closest(".g6-confirm-popover, .g6-create-popover,.g6-node-popover, .g6-edge-popover")) return;
|
|
54111
|
+
}
|
|
54112
|
+
let $canvas = main_canvas_of(priv.$container);
|
|
54113
|
+
if ($canvas && typeof $canvas.focus === "function") $canvas.focus({ preventScroll: true });
|
|
54114
|
+
};
|
|
54115
|
+
priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus, true);
|
|
54116
|
+
priv.$container.addEventListener("click", priv._on_pointerdown_focus, true);
|
|
54100
54117
|
graph.on("keydown", (evt) => {
|
|
54101
54118
|
let ctrl = !!(evt.ctrlKey || evt.metaKey);
|
|
54102
54119
|
if (ctrl && (evt.key === "a" || evt.key === "A")) {
|
|
@@ -55589,6 +55606,22 @@ function perform_history_op(gobj, is_redo) {
|
|
|
55589
55606
|
}
|
|
55590
55607
|
}
|
|
55591
55608
|
/************************************************************
|
|
55609
|
+
* The canvas G6 listens on.
|
|
55610
|
+
*
|
|
55611
|
+
* A G6 graph stacks four canvases and gives every one of them a
|
|
55612
|
+
* `tabIndex`, so `querySelector("canvas")` finds a focusable
|
|
55613
|
+
* element that receives nothing: only the MAIN layer carries the
|
|
55614
|
+
* listeners, and it is the only one G6 leaves with pointer events
|
|
55615
|
+
* (`configCanvasDom` sets `pointerEvents: none` on the rest).
|
|
55616
|
+
* Focusing the wrong one looks exactly like focusing the right one
|
|
55617
|
+
* and delivers no key.
|
|
55618
|
+
************************************************************/
|
|
55619
|
+
function main_canvas_of($container) {
|
|
55620
|
+
let canvases = $container.querySelectorAll("canvas");
|
|
55621
|
+
for (let i = 0; i < canvases.length; i++) if (window.getComputedStyle(canvases[i]).pointerEvents !== "none") return canvases[i];
|
|
55622
|
+
return canvases[0] || null;
|
|
55623
|
+
}
|
|
55624
|
+
/************************************************************
|
|
55592
55625
|
* The selection.
|
|
55593
55626
|
*
|
|
55594
55627
|
* G6's `selected` element state IS the selection: `drag-element`
|
|
@@ -58224,7 +58257,7 @@ function ac_key_down(gobj, event, kw, src) {
|
|
|
58224
58257
|
let fullscreen = graph_get_plugin(gobj, "fullscreen");
|
|
58225
58258
|
if (fullscreen) {
|
|
58226
58259
|
if (key === "F" || key === "f") fullscreen.request();
|
|
58227
|
-
else if (key === "Escape") fullscreen.exit();
|
|
58260
|
+
else if (key === "Escape" && priv.is_fullscreen) fullscreen.exit();
|
|
58228
58261
|
}
|
|
58229
58262
|
}
|
|
58230
58263
|
if (!priv.edit_mode) return 0;
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -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,11 @@ 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, true);
|
|
53925
|
+
priv.$container.removeEventListener("click", priv._on_pointerdown_focus, true);
|
|
53926
|
+
priv._on_pointerdown_focus = null;
|
|
53927
|
+
}
|
|
53922
53928
|
if (priv.theme_observer) {
|
|
53923
53929
|
priv.theme_observer.disconnect();
|
|
53924
53930
|
priv.theme_observer = null;
|
|
@@ -54084,6 +54090,17 @@ function configure_events(gobj) {
|
|
|
54084
54090
|
update_toolbar(gobj);
|
|
54085
54091
|
};
|
|
54086
54092
|
i18next.on("languageChanged", priv._on_language_changed);
|
|
54093
|
+
priv._on_pointerdown_focus = (ev) => {
|
|
54094
|
+
let target = ev.target;
|
|
54095
|
+
if (target && typeof target.closest === "function") {
|
|
54096
|
+
if (target.closest("input, textarea, select, [contenteditable]")) return;
|
|
54097
|
+
if (target.closest(".g6-confirm-popover, .g6-create-popover,.g6-node-popover, .g6-edge-popover")) return;
|
|
54098
|
+
}
|
|
54099
|
+
let $canvas = main_canvas_of(priv.$container);
|
|
54100
|
+
if ($canvas && typeof $canvas.focus === "function") $canvas.focus({ preventScroll: true });
|
|
54101
|
+
};
|
|
54102
|
+
priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus, true);
|
|
54103
|
+
priv.$container.addEventListener("click", priv._on_pointerdown_focus, true);
|
|
54087
54104
|
graph.on("keydown", (evt) => {
|
|
54088
54105
|
let ctrl = !!(evt.ctrlKey || evt.metaKey);
|
|
54089
54106
|
if (ctrl && (evt.key === "a" || evt.key === "A")) {
|
|
@@ -55576,6 +55593,22 @@ function perform_history_op(gobj, is_redo) {
|
|
|
55576
55593
|
}
|
|
55577
55594
|
}
|
|
55578
55595
|
/************************************************************
|
|
55596
|
+
* The canvas G6 listens on.
|
|
55597
|
+
*
|
|
55598
|
+
* A G6 graph stacks four canvases and gives every one of them a
|
|
55599
|
+
* `tabIndex`, so `querySelector("canvas")` finds a focusable
|
|
55600
|
+
* element that receives nothing: only the MAIN layer carries the
|
|
55601
|
+
* listeners, and it is the only one G6 leaves with pointer events
|
|
55602
|
+
* (`configCanvasDom` sets `pointerEvents: none` on the rest).
|
|
55603
|
+
* Focusing the wrong one looks exactly like focusing the right one
|
|
55604
|
+
* and delivers no key.
|
|
55605
|
+
************************************************************/
|
|
55606
|
+
function main_canvas_of($container) {
|
|
55607
|
+
let canvases = $container.querySelectorAll("canvas");
|
|
55608
|
+
for (let i = 0; i < canvases.length; i++) if (window.getComputedStyle(canvases[i]).pointerEvents !== "none") return canvases[i];
|
|
55609
|
+
return canvases[0] || null;
|
|
55610
|
+
}
|
|
55611
|
+
/************************************************************
|
|
55579
55612
|
* The selection.
|
|
55580
55613
|
*
|
|
55581
55614
|
* G6's `selected` element state IS the selection: `drag-element`
|
|
@@ -58211,7 +58244,7 @@ function ac_key_down(gobj, event, kw, src) {
|
|
|
58211
58244
|
let fullscreen = graph_get_plugin(gobj, "fullscreen");
|
|
58212
58245
|
if (fullscreen) {
|
|
58213
58246
|
if (key === "F" || key === "f") fullscreen.request();
|
|
58214
|
-
else if (key === "Escape") fullscreen.exit();
|
|
58247
|
+
else if (key === "Escape" && priv.is_fullscreen) fullscreen.exit();
|
|
58215
58248
|
}
|
|
58216
58249
|
}
|
|
58217
58250
|
if (!priv.edit_mode) return 0;
|
package/package.json
CHANGED
package/src/c_g6_nodes_tree.js
CHANGED
|
@@ -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,16 @@ 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, true
|
|
466
|
+
);
|
|
467
|
+
priv.$container.removeEventListener(
|
|
468
|
+
"click", priv._on_pointerdown_focus, true
|
|
469
|
+
);
|
|
470
|
+
priv._on_pointerdown_focus = null;
|
|
471
|
+
}
|
|
472
|
+
|
|
462
473
|
if(priv.theme_observer) {
|
|
463
474
|
priv.theme_observer.disconnect();
|
|
464
475
|
priv.theme_observer = null;
|
|
@@ -787,6 +798,46 @@ function configure_events(gobj)
|
|
|
787
798
|
};
|
|
788
799
|
i18next.on('languageChanged', priv._on_language_changed);
|
|
789
800
|
|
|
801
|
+
/* Clicking a CARD is clicking a DOM element inside the container,
|
|
802
|
+
* and that takes the keyboard away from G6's canvas -- the only
|
|
803
|
+
* element that receives keydown. Selecting two nodes by clicking
|
|
804
|
+
* them and then pressing Escape did nothing, which is the most
|
|
805
|
+
* ordinary way there is to reach for it. The focus goes back on
|
|
806
|
+
* every press inside the graph.
|
|
807
|
+
*
|
|
808
|
+
* Except on what is there to be typed into: the popovers this
|
|
809
|
+
* gclass appends to its own container carry inputs, and stealing
|
|
810
|
+
* their focus on pointerdown would make them impossible to fill
|
|
811
|
+
* in.
|
|
812
|
+
*/
|
|
813
|
+
priv._on_pointerdown_focus = (ev) => {
|
|
814
|
+
let target = ev.target;
|
|
815
|
+
if(target && typeof target.closest === "function") {
|
|
816
|
+
if(target.closest("input, textarea, select, [contenteditable]")) {
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
if(target.closest(".g6-confirm-popover, .g6-create-popover," +
|
|
820
|
+
".g6-node-popover, .g6-edge-popover")) {
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
let $canvas = main_canvas_of(priv.$container);
|
|
825
|
+
if($canvas && typeof $canvas.focus === "function") {
|
|
826
|
+
$canvas.focus({preventScroll: true});
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
/* Capture, and on the click as well as the press. Capture because
|
|
830
|
+
* the cards are DOM and may stop the press from bubbling; the
|
|
831
|
+
* click too because the browser does its OWN focus handling on
|
|
832
|
+
* mousedown, after ours, and it sends the focus to <body> when
|
|
833
|
+
* what was pressed cannot take it -- which a card cannot. */
|
|
834
|
+
priv.$container.addEventListener(
|
|
835
|
+
"pointerdown", priv._on_pointerdown_focus, true
|
|
836
|
+
);
|
|
837
|
+
priv.$container.addEventListener(
|
|
838
|
+
"click", priv._on_pointerdown_focus, true
|
|
839
|
+
);
|
|
840
|
+
|
|
790
841
|
/* The canvas carries a `tabIndex` of its own, so a keydown reaches
|
|
791
842
|
* us only while the GRAPH has focus. That is what keeps Ctrl+A in
|
|
792
843
|
* the find box a text selection and not a selection of every node:
|
|
@@ -3087,6 +3138,30 @@ function perform_history_op(gobj, is_redo)
|
|
|
3087
3138
|
}
|
|
3088
3139
|
}
|
|
3089
3140
|
|
|
3141
|
+
/************************************************************
|
|
3142
|
+
* The canvas G6 listens on.
|
|
3143
|
+
*
|
|
3144
|
+
* A G6 graph stacks four canvases and gives every one of them a
|
|
3145
|
+
* `tabIndex`, so `querySelector("canvas")` finds a focusable
|
|
3146
|
+
* element that receives nothing: only the MAIN layer carries the
|
|
3147
|
+
* listeners, and it is the only one G6 leaves with pointer events
|
|
3148
|
+
* (`configCanvasDom` sets `pointerEvents: none` on the rest).
|
|
3149
|
+
* Focusing the wrong one looks exactly like focusing the right one
|
|
3150
|
+
* and delivers no key.
|
|
3151
|
+
************************************************************/
|
|
3152
|
+
function main_canvas_of($container)
|
|
3153
|
+
{
|
|
3154
|
+
let canvases = $container.querySelectorAll("canvas");
|
|
3155
|
+
|
|
3156
|
+
for(let i = 0; i < canvases.length; i++) {
|
|
3157
|
+
if(window.getComputedStyle(canvases[i]).pointerEvents !== "none") {
|
|
3158
|
+
return canvases[i];
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3162
|
+
return canvases[0] || null;
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3090
3165
|
/************************************************************
|
|
3091
3166
|
* The selection.
|
|
3092
3167
|
*
|
|
@@ -6998,11 +7073,17 @@ function ac_key_down(gobj, event, kw, src)
|
|
|
6998
7073
|
if(fullscreen) {
|
|
6999
7074
|
if(key === "F" || key === "f") {
|
|
7000
7075
|
fullscreen.request();
|
|
7001
|
-
} else if(key === "Escape") {
|
|
7002
|
-
/*
|
|
7003
|
-
*
|
|
7004
|
-
*
|
|
7005
|
-
*
|
|
7076
|
+
} else if(key === "Escape" && priv.is_fullscreen) {
|
|
7077
|
+
/* Only while actually IN full screen. Asking to leave
|
|
7078
|
+
* a full screen nobody entered throws, and since this
|
|
7079
|
+
* is now an action rather than a listener, that throw
|
|
7080
|
+
* takes the rest of the key with it -- which is how
|
|
7081
|
+
* Escape stopped clearing the selection.
|
|
7082
|
+
*
|
|
7083
|
+
* Escape does both when both apply, and that is right:
|
|
7084
|
+
* the browser leaves full screen on Escape whatever we
|
|
7085
|
+
* do, so refusing to clear as well would only make the
|
|
7086
|
+
* key do less than it appears to. */
|
|
7006
7087
|
fullscreen.exit();
|
|
7007
7088
|
}
|
|
7008
7089
|
}
|