@yuneta/gobj-ui 7.23.133 → 7.23.134
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 +221 -108
- package/dist/gobj-ui.es.js +221 -108
- package/package.json +1 -1
- package/src/c_g6_nodes_tree.js +279 -142
package/src/c_g6_nodes_tree.js
CHANGED
|
@@ -2840,57 +2840,17 @@ function draw_link(
|
|
|
2840
2840
|
* Create the edge with independent id and semantic data
|
|
2841
2841
|
* HACK: source/target are interchanged so arrows point parent -> child
|
|
2842
2842
|
*/
|
|
2843
|
-
// Doc-style default: neutral grey edges, teal for the
|
|
2844
|
-
// containment/tree relation (parent and child same topic, i.e.
|
|
2845
|
-
// a self-hierarchy). Saturated topic colour is dropped.
|
|
2846
|
-
// `themed_default` marks edges still on the default colour so a
|
|
2847
|
-
// theme toggle can re-theme them without touching user-saved ones.
|
|
2848
|
-
let dark = (priv.theme === "dark");
|
|
2849
2843
|
let is_tree = (parent_topic === child_topic);
|
|
2850
|
-
let
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
:
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
let edge_props = topic_props.edges[edge_key];
|
|
2861
|
-
if(edge_props) {
|
|
2862
|
-
if(edge_props.lineWidth != null) {
|
|
2863
|
-
saved_lineWidth = edge_props.lineWidth;
|
|
2864
|
-
}
|
|
2865
|
-
if(edge_props.stroke) {
|
|
2866
|
-
saved_stroke = edge_props.stroke;
|
|
2867
|
-
themed_default = false;
|
|
2868
|
-
}
|
|
2869
|
-
}
|
|
2870
|
-
}
|
|
2871
|
-
// Fall back to topic defaults (only if not user-overridden)
|
|
2872
|
-
if(themed_default && is_object(topic_props.defaults)) {
|
|
2873
|
-
let defs = topic_props.defaults;
|
|
2874
|
-
if(defs.edge_styles && defs.edge_styles[hook_name]) {
|
|
2875
|
-
let hook_style = defs.edge_styles[hook_name];
|
|
2876
|
-
if(hook_style.lineWidth != null) {
|
|
2877
|
-
saved_lineWidth = hook_style.lineWidth;
|
|
2878
|
-
}
|
|
2879
|
-
if(hook_style.stroke) {
|
|
2880
|
-
saved_stroke = hook_style.stroke;
|
|
2881
|
-
themed_default = false;
|
|
2882
|
-
}
|
|
2883
|
-
} else if(defs.edge_style) {
|
|
2884
|
-
if(defs.edge_style.lineWidth != null) {
|
|
2885
|
-
saved_lineWidth = defs.edge_style.lineWidth;
|
|
2886
|
-
}
|
|
2887
|
-
if(defs.edge_style.stroke) {
|
|
2888
|
-
saved_stroke = defs.edge_style.stroke;
|
|
2889
|
-
themed_default = false;
|
|
2890
|
-
}
|
|
2891
|
-
}
|
|
2892
|
-
}
|
|
2893
|
-
}
|
|
2844
|
+
let edge_style = edge_style_of(gobj, {
|
|
2845
|
+
parent_topic: parent_topic,
|
|
2846
|
+
parent_id: parent_id,
|
|
2847
|
+
hook_name: hook_name,
|
|
2848
|
+
child_id: child_id,
|
|
2849
|
+
is_tree: is_tree,
|
|
2850
|
+
});
|
|
2851
|
+
let saved_lineWidth = edge_style.lineWidth;
|
|
2852
|
+
let saved_stroke = edge_style.stroke;
|
|
2853
|
+
let themed_default = edge_style.themed_default;
|
|
2894
2854
|
|
|
2895
2855
|
let edge = {
|
|
2896
2856
|
id: build_edge_id(gobj),
|
|
@@ -8302,9 +8262,89 @@ function apply_edge_properties(gobj, edge_id, lineWidth, stroke, scope)
|
|
|
8302
8262
|
deselect_edge(gobj);
|
|
8303
8263
|
}
|
|
8304
8264
|
|
|
8265
|
+
/************************************************************
|
|
8266
|
+
* The style an edge INHERITS, before anything saved for the
|
|
8267
|
+
* edge itself: its hook's default in the parent topic, else the
|
|
8268
|
+
* parent topic's default for every edge, else the library's.
|
|
8269
|
+
*
|
|
8270
|
+
* The library's: neutral grey, teal for the containment/tree
|
|
8271
|
+
* relation (parent and child of the same topic, a
|
|
8272
|
+
* self-hierarchy). `themed_default` says the colour is still the
|
|
8273
|
+
* library's, so a theme toggle re-themes it and leaves a chosen
|
|
8274
|
+
* one alone.
|
|
8275
|
+
************************************************************/
|
|
8276
|
+
function edge_inherited_style_of(gobj, d)
|
|
8277
|
+
{
|
|
8278
|
+
let priv = gobj.priv;
|
|
8279
|
+
let dark = (priv.theme === "dark");
|
|
8280
|
+
let style = {
|
|
8281
|
+
lineWidth: d.is_tree ? 2 : 1.6,
|
|
8282
|
+
stroke: d.is_tree
|
|
8283
|
+
? (dark ? '#22a7c2' : '#0e7490')
|
|
8284
|
+
: (dark ? '#8b94a3' : '#6b7280'),
|
|
8285
|
+
themed_default: true,
|
|
8286
|
+
};
|
|
8287
|
+
|
|
8288
|
+
let defs = topic_defaults_of(gobj, d.parent_topic);
|
|
8289
|
+
if(!defs) {
|
|
8290
|
+
return style;
|
|
8291
|
+
}
|
|
8292
|
+
let chosen = null;
|
|
8293
|
+
if(is_object(defs.edge_styles) && is_object(defs.edge_styles[d.hook_name])) {
|
|
8294
|
+
chosen = defs.edge_styles[d.hook_name];
|
|
8295
|
+
} else if(is_object(defs.edge_style)) {
|
|
8296
|
+
chosen = defs.edge_style;
|
|
8297
|
+
}
|
|
8298
|
+
if(chosen) {
|
|
8299
|
+
if(chosen.lineWidth != null) {
|
|
8300
|
+
style.lineWidth = chosen.lineWidth;
|
|
8301
|
+
}
|
|
8302
|
+
if(chosen.stroke) {
|
|
8303
|
+
style.stroke = chosen.stroke;
|
|
8304
|
+
style.themed_default = false;
|
|
8305
|
+
}
|
|
8306
|
+
}
|
|
8307
|
+
return style;
|
|
8308
|
+
}
|
|
8309
|
+
|
|
8310
|
+
/* The key of an edge's own entry in its parent topic's `edges`. */
|
|
8311
|
+
function edge_key_of(d)
|
|
8312
|
+
{
|
|
8313
|
+
return d.hook_name + ":" + d.parent_id + ":" + d.child_id;
|
|
8314
|
+
}
|
|
8315
|
+
|
|
8316
|
+
/************************************************************
|
|
8317
|
+
* The style an edge WEARS: what it inherits, with what was saved
|
|
8318
|
+
* for the edge itself on top.
|
|
8319
|
+
************************************************************/
|
|
8320
|
+
function edge_style_of(gobj, d)
|
|
8321
|
+
{
|
|
8322
|
+
let style = edge_inherited_style_of(gobj, d);
|
|
8323
|
+
let topic_props = gobj.priv._graph_properties[d.parent_topic];
|
|
8324
|
+
let own = (is_object(topic_props) && is_object(topic_props.edges))?
|
|
8325
|
+
topic_props.edges[edge_key_of(d)] : null;
|
|
8326
|
+
if(is_object(own)) {
|
|
8327
|
+
if(own.lineWidth != null) {
|
|
8328
|
+
style.lineWidth = own.lineWidth;
|
|
8329
|
+
}
|
|
8330
|
+
if(own.stroke) {
|
|
8331
|
+
style.stroke = own.stroke;
|
|
8332
|
+
style.themed_default = false;
|
|
8333
|
+
}
|
|
8334
|
+
}
|
|
8335
|
+
return style;
|
|
8336
|
+
}
|
|
8337
|
+
|
|
8305
8338
|
/************************************************************
|
|
8306
8339
|
* Save edge styles into _graph_properties (called from
|
|
8307
8340
|
* save_geometry).
|
|
8341
|
+
*
|
|
8342
|
+
* Only what differs from what the edge INHERITS is written. It
|
|
8343
|
+
* used to be "any line width but 2", and the library's own width
|
|
8344
|
+
* for an edge between two topics is 1.6: every Save wrote every
|
|
8345
|
+
* such edge down with its width and its theme's colour, so the
|
|
8346
|
+
* default was frozen on it -- a theme toggle no longer re-themed
|
|
8347
|
+
* it after a reload, and a topic default never reached it.
|
|
8308
8348
|
************************************************************/
|
|
8309
8349
|
function update_edge_geometry(gobj, edge_id)
|
|
8310
8350
|
{
|
|
@@ -8317,16 +8357,20 @@ function update_edge_geometry(gobj, edge_id)
|
|
|
8317
8357
|
}
|
|
8318
8358
|
|
|
8319
8359
|
let style = edgeData.style || {};
|
|
8320
|
-
let
|
|
8321
|
-
let
|
|
8360
|
+
let d = edgeData.data;
|
|
8361
|
+
let inherited = edge_inherited_style_of(gobj, d);
|
|
8362
|
+
let parent_topic = d.parent_topic;
|
|
8363
|
+
let edge_key = edge_key_of(d);
|
|
8322
8364
|
|
|
8323
|
-
let
|
|
8324
|
-
|
|
8325
|
-
|
|
8365
|
+
let edge_props = {};
|
|
8366
|
+
if(style.lineWidth != null && style.lineWidth !== inherited.lineWidth) {
|
|
8367
|
+
edge_props.lineWidth = style.lineWidth;
|
|
8368
|
+
}
|
|
8369
|
+
if(style.stroke && style.stroke !== inherited.stroke) {
|
|
8370
|
+
edge_props.stroke = style.stroke;
|
|
8371
|
+
}
|
|
8326
8372
|
|
|
8327
|
-
|
|
8328
|
-
let hasCustom = (lineWidth != null && lineWidth !== 2);
|
|
8329
|
-
if(!hasCustom) {
|
|
8373
|
+
if(Object.keys(edge_props).length === 0) {
|
|
8330
8374
|
let topic_props = priv._graph_properties[parent_topic];
|
|
8331
8375
|
if(topic_props && is_object(topic_props.edges)) {
|
|
8332
8376
|
delete topic_props.edges[edge_key];
|
|
@@ -8344,11 +8388,6 @@ function update_edge_geometry(gobj, edge_id)
|
|
|
8344
8388
|
if(!is_object(topic_props.edges)) {
|
|
8345
8389
|
topic_props.edges = {};
|
|
8346
8390
|
}
|
|
8347
|
-
|
|
8348
|
-
let edge_props = { lineWidth: lineWidth };
|
|
8349
|
-
if(stroke) {
|
|
8350
|
-
edge_props.stroke = stroke;
|
|
8351
|
-
}
|
|
8352
8391
|
topic_props.edges[edge_key] = edge_props;
|
|
8353
8392
|
}
|
|
8354
8393
|
|
|
@@ -8435,11 +8474,14 @@ function build_node_context_menu(gobj, node_id)
|
|
|
8435
8474
|
if(gobj.priv.edit_mode && !node_is_compact(gobj, node_id)) {
|
|
8436
8475
|
items.push(ctx_item('g6-icon-resize', t('resize all'), 'resize_all_nodes'));
|
|
8437
8476
|
items.push(ctx_item('g6-icon-resize', t('resize topic nodes'), 'resize_topic_nodes'));
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
8477
|
+
}
|
|
8478
|
+
if(gobj.priv.edit_mode) {
|
|
8479
|
+
/* The way back, in every view: what the node properties and
|
|
8480
|
+
* the resizes saved -- or a Save froze before 7.23.80 --
|
|
8481
|
+
* forgotten, the library's defaults back. */
|
|
8482
|
+
items.push(ctx_item('g6-icon-undo', t('reset node'), 'reset_node'));
|
|
8483
|
+
items.push(ctx_item('g6-icon-undo', t('reset topic nodes'), 'reset_topic_nodes'));
|
|
8484
|
+
items.push(ctx_item('g6-icon-undo', t('reset all nodes'), 'reset_all_nodes'));
|
|
8443
8485
|
}
|
|
8444
8486
|
|
|
8445
8487
|
return items;
|
|
@@ -8481,6 +8523,9 @@ function build_edge_context_menu(gobj)
|
|
|
8481
8523
|
inject_svg_icons();
|
|
8482
8524
|
items.push(ctx_item('g6-icon-edit', t('edge properties'), 'edge_properties'));
|
|
8483
8525
|
items.push(ctx_item('g6-icon-delete', t('unlink'), 'unlink_edge'));
|
|
8526
|
+
items.push(ctx_item('g6-icon-undo', t('reset edge'), 'reset_edge'));
|
|
8527
|
+
items.push(ctx_item('g6-icon-undo', t('reset same type edges'), 'reset_same_type_edges'));
|
|
8528
|
+
items.push(ctx_item('g6-icon-undo', t('reset all edges'), 'reset_all_edges'));
|
|
8484
8529
|
}
|
|
8485
8530
|
|
|
8486
8531
|
return items;
|
|
@@ -8505,11 +8550,23 @@ function handle_context_menu_click(gobj, value)
|
|
|
8505
8550
|
case 'resize_topic_nodes':
|
|
8506
8551
|
copy_size_to_nodes(gobj, true);
|
|
8507
8552
|
break;
|
|
8508
|
-
case '
|
|
8509
|
-
|
|
8553
|
+
case 'reset_node':
|
|
8554
|
+
reset_nodes(gobj, 'this');
|
|
8555
|
+
break;
|
|
8556
|
+
case 'reset_topic_nodes':
|
|
8557
|
+
reset_nodes(gobj, 'same_topic');
|
|
8558
|
+
break;
|
|
8559
|
+
case 'reset_all_nodes':
|
|
8560
|
+
reset_nodes(gobj, 'all');
|
|
8561
|
+
break;
|
|
8562
|
+
case 'reset_edge':
|
|
8563
|
+
reset_edges(gobj, 'this');
|
|
8564
|
+
break;
|
|
8565
|
+
case 'reset_same_type_edges':
|
|
8566
|
+
reset_edges(gobj, 'same_type');
|
|
8510
8567
|
break;
|
|
8511
|
-
case '
|
|
8512
|
-
|
|
8568
|
+
case 'reset_all_edges':
|
|
8569
|
+
reset_edges(gobj, 'all');
|
|
8513
8570
|
break;
|
|
8514
8571
|
case 'port_properties':
|
|
8515
8572
|
if(priv._context_node_id && priv._context_port_key) {
|
|
@@ -8647,40 +8704,47 @@ function copy_size_to_nodes(gobj, same_topic_only)
|
|
|
8647
8704
|
}
|
|
8648
8705
|
}
|
|
8649
8706
|
|
|
8707
|
+
/*
|
|
8708
|
+
* What a reset forgets, by what it resets. A node's own look is
|
|
8709
|
+
* its size, its colours, its line width and its figure; its ports
|
|
8710
|
+
* have their own reset. The POSITION is not a property and no reset
|
|
8711
|
+
* touches it: it is where somebody put the node.
|
|
8712
|
+
*/
|
|
8713
|
+
const NODE_STYLE_KEYS = ["size", "fill", "stroke", "lineWidth", "node_shape"];
|
|
8714
|
+
const PORT_STYLE_KEYS = ["portR", "port_sizes", "port_shapes", "port_shape"];
|
|
8715
|
+
|
|
8650
8716
|
/************************************************************
|
|
8651
|
-
* Forget
|
|
8652
|
-
*
|
|
8653
|
-
*
|
|
8654
|
-
*
|
|
8655
|
-
*
|
|
8656
|
-
*
|
|
8657
|
-
* they are a different choice.
|
|
8717
|
+
* Forget these saved keys -- on the node of the menu alone
|
|
8718
|
+
* ('this'), or on every node of its topic and in the topic's
|
|
8719
|
+
* defaults ('same_topic'), or everywhere ('all'). Both copies of
|
|
8720
|
+
* an entry are stripped: the one in `_graph_properties` (which
|
|
8721
|
+
* Save writes, folded nodes included) and the one the node
|
|
8722
|
+
* carries. Returns the ids of the nodes on screen to reshape.
|
|
8658
8723
|
************************************************************/
|
|
8659
|
-
function
|
|
8724
|
+
function forget_saved_node_keys(gobj, nd, scope, keys)
|
|
8660
8725
|
{
|
|
8661
8726
|
let priv = gobj.priv;
|
|
8662
8727
|
let graph = priv.graph;
|
|
8663
|
-
|
|
8664
|
-
let topic = "";
|
|
8665
|
-
if(same_topic_only) {
|
|
8666
|
-
let nd = priv._context_node_id? graph.getNodeData(priv._context_node_id) : null;
|
|
8667
|
-
if(!nd || !nd.data || !nd.data.topic_name) {
|
|
8668
|
-
log_error(`${gobj_short_name(gobj)}: reset topic sizes without a node`);
|
|
8669
|
-
return;
|
|
8670
|
-
}
|
|
8671
|
-
topic = nd.data.topic_name;
|
|
8672
|
-
}
|
|
8673
|
-
const SIZE_KEYS = ["size", "portR", "port_sizes"];
|
|
8674
8728
|
let strip = (props) => {
|
|
8675
8729
|
if(!is_object(props)) {
|
|
8676
8730
|
return;
|
|
8677
8731
|
}
|
|
8678
|
-
for(let k of
|
|
8732
|
+
for(let k of keys) {
|
|
8679
8733
|
delete props[k];
|
|
8680
8734
|
}
|
|
8681
8735
|
};
|
|
8682
8736
|
|
|
8683
|
-
|
|
8737
|
+
if(scope === 'this') {
|
|
8738
|
+
strip(node_props_entry(gobj, nd));
|
|
8739
|
+
strip(nd.data.graph_props);
|
|
8740
|
+
if(nd.data.record) {
|
|
8741
|
+
strip(nd.data.record._geometry);
|
|
8742
|
+
}
|
|
8743
|
+
return [nd.id];
|
|
8744
|
+
}
|
|
8745
|
+
|
|
8746
|
+
let topic = (scope === 'same_topic')? nd.data.topic_name : "";
|
|
8747
|
+
|
|
8684
8748
|
for(const [topic_name, props] of Object.entries(priv._graph_properties || {})) {
|
|
8685
8749
|
if(topic && topic_name !== topic) {
|
|
8686
8750
|
continue;
|
|
@@ -8693,29 +8757,55 @@ function reset_sizes(gobj, same_topic_only)
|
|
|
8693
8757
|
strip(props.defaults);
|
|
8694
8758
|
}
|
|
8695
8759
|
|
|
8696
|
-
/* The nodes on screen: their own copy of the entry, then the shape. */
|
|
8697
8760
|
let ids = [];
|
|
8698
|
-
for(let
|
|
8699
|
-
if(!
|
|
8761
|
+
for(let n of (graph.getNodeData() || [])) {
|
|
8762
|
+
if(!n || !n.data || !n.data.desc || is_more_node(n)) {
|
|
8700
8763
|
continue;
|
|
8701
8764
|
}
|
|
8702
|
-
if(topic &&
|
|
8765
|
+
if(topic && n.data.topic_name !== topic) {
|
|
8703
8766
|
continue;
|
|
8704
8767
|
}
|
|
8705
|
-
strip(
|
|
8706
|
-
if(
|
|
8707
|
-
strip(
|
|
8768
|
+
strip(n.data.graph_props);
|
|
8769
|
+
if(n.data.record) {
|
|
8770
|
+
strip(n.data.record._geometry);
|
|
8708
8771
|
}
|
|
8709
|
-
ids.push(
|
|
8772
|
+
ids.push(n.id);
|
|
8710
8773
|
}
|
|
8774
|
+
return ids;
|
|
8775
|
+
}
|
|
8776
|
+
|
|
8777
|
+
/* The nodes are reshaped from what is left saved, and Save writes
|
|
8778
|
+
* the cleared entries: a value nobody chose is not written back
|
|
8779
|
+
* (see update_geometry). */
|
|
8780
|
+
function reshape_after_reset(gobj, ids)
|
|
8781
|
+
{
|
|
8782
|
+
let graph = gobj.priv.graph;
|
|
8711
8783
|
reshape_nodes(gobj, ids);
|
|
8712
8784
|
graph.draw().then(() => {
|
|
8713
8785
|
update_resize_handles_position(gobj);
|
|
8714
8786
|
update_port_resize_handles_position(gobj);
|
|
8787
|
+
update_port_icon_position(gobj);
|
|
8715
8788
|
mark_graph_dirty(gobj);
|
|
8716
8789
|
});
|
|
8717
8790
|
}
|
|
8718
8791
|
|
|
8792
|
+
/************************************************************
|
|
8793
|
+
* Forget the saved look of nodes (NODE_STYLE_KEYS), back to the
|
|
8794
|
+
* library's: this node, its topic's, or all of them. A figure
|
|
8795
|
+
* saved as a square before the circle became the default goes
|
|
8796
|
+
* back to the default this way.
|
|
8797
|
+
************************************************************/
|
|
8798
|
+
function reset_nodes(gobj, scope)
|
|
8799
|
+
{
|
|
8800
|
+
let priv = gobj.priv;
|
|
8801
|
+
let nd = priv._context_node_id? priv.graph.getNodeData(priv._context_node_id) : null;
|
|
8802
|
+
if(!nd || !nd.data || !nd.data.topic_name) {
|
|
8803
|
+
log_error(`${gobj_short_name(gobj)}: reset nodes without a node`);
|
|
8804
|
+
return;
|
|
8805
|
+
}
|
|
8806
|
+
reshape_after_reset(gobj, forget_saved_node_keys(gobj, nd, scope, NODE_STYLE_KEYS));
|
|
8807
|
+
}
|
|
8808
|
+
|
|
8719
8809
|
/************************************************************
|
|
8720
8810
|
* Forget the saved SHAPE and RADIUS of ports, back to the
|
|
8721
8811
|
* library's own:
|
|
@@ -8723,7 +8813,7 @@ function reset_sizes(gobj, same_topic_only)
|
|
|
8723
8813
|
* 'same_topic' every port of the node's topic, with the
|
|
8724
8814
|
* topic's port defaults
|
|
8725
8815
|
* 'all' every port of every topic, likewise
|
|
8726
|
-
* The node
|
|
8816
|
+
* The node's own look is not touched: that is `reset node`.
|
|
8727
8817
|
************************************************************/
|
|
8728
8818
|
function reset_ports(gobj, scope)
|
|
8729
8819
|
{
|
|
@@ -8738,7 +8828,12 @@ function reset_ports(gobj, scope)
|
|
|
8738
8828
|
return;
|
|
8739
8829
|
}
|
|
8740
8830
|
|
|
8741
|
-
|
|
8831
|
+
if(scope !== 'this') {
|
|
8832
|
+
reshape_after_reset(gobj, forget_saved_node_keys(gobj, nd, scope, PORT_STYLE_KEYS));
|
|
8833
|
+
return;
|
|
8834
|
+
}
|
|
8835
|
+
|
|
8836
|
+
/* One port: its entries in the per-port maps, not the maps. */
|
|
8742
8837
|
let strip_port = (props) => {
|
|
8743
8838
|
if(!is_object(props)) {
|
|
8744
8839
|
return;
|
|
@@ -8752,59 +8847,101 @@ function reset_ports(gobj, scope)
|
|
|
8752
8847
|
}
|
|
8753
8848
|
}
|
|
8754
8849
|
};
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8850
|
+
strip_port(node_props_entry(gobj, nd));
|
|
8851
|
+
strip_port(nd.data.graph_props);
|
|
8852
|
+
if(nd.data.record) {
|
|
8853
|
+
strip_port(nd.data.record._geometry);
|
|
8854
|
+
}
|
|
8855
|
+
reshape_after_reset(gobj, [node_id]);
|
|
8856
|
+
}
|
|
8857
|
+
|
|
8858
|
+
/************************************************************
|
|
8859
|
+
* Forget the saved style of edges, back to what they inherit:
|
|
8860
|
+
* 'this' the edge of the menu, its own entry
|
|
8861
|
+
* 'same_type' every edge of its hook in its parent topic,
|
|
8862
|
+
* with that hook's default
|
|
8863
|
+
* 'all' every edge, with every edge default
|
|
8864
|
+
* The same three scopes as the edge properties popover.
|
|
8865
|
+
************************************************************/
|
|
8866
|
+
function reset_edges(gobj, scope)
|
|
8867
|
+
{
|
|
8868
|
+
let priv = gobj.priv;
|
|
8869
|
+
let graph = priv.graph;
|
|
8870
|
+
|
|
8871
|
+
let ed = priv._context_edge_id? graph.getEdgeData(priv._context_edge_id) : null;
|
|
8872
|
+
if(!ed || !ed.data || !ed.data.parent_topic) {
|
|
8873
|
+
log_error(`${gobj_short_name(gobj)}: reset edges without an edge`);
|
|
8874
|
+
return;
|
|
8875
|
+
}
|
|
8876
|
+
let src = ed.data;
|
|
8877
|
+
let hits = (d) => {
|
|
8878
|
+
if(!d || !d.parent_topic) {
|
|
8879
|
+
return false; /* a `+N` chip's line */
|
|
8758
8880
|
}
|
|
8759
|
-
|
|
8760
|
-
|
|
8881
|
+
if(scope === 'this') {
|
|
8882
|
+
return edge_key_of(d) === edge_key_of(src) && d.parent_topic === src.parent_topic;
|
|
8883
|
+
}
|
|
8884
|
+
if(scope === 'same_type') {
|
|
8885
|
+
return d.parent_topic === src.parent_topic && d.hook_name === src.hook_name;
|
|
8761
8886
|
}
|
|
8887
|
+
return true;
|
|
8762
8888
|
};
|
|
8763
8889
|
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
if(nd.data.record) {
|
|
8769
|
-
strip_port(nd.data.record._geometry);
|
|
8890
|
+
/* The saved entries, on screen or folded away. */
|
|
8891
|
+
for(const [topic_name, props] of Object.entries(priv._graph_properties || {})) {
|
|
8892
|
+
if(!is_object(props)) {
|
|
8893
|
+
continue;
|
|
8770
8894
|
}
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8895
|
+
if(scope !== 'all' && topic_name !== src.parent_topic) {
|
|
8896
|
+
continue;
|
|
8897
|
+
}
|
|
8898
|
+
if(is_object(props.edges)) {
|
|
8899
|
+
for(let key of Object.keys(props.edges)) {
|
|
8900
|
+
let hook_name = key.split(":")[0];
|
|
8901
|
+
if(scope === 'this' && key !== edge_key_of(src)) {
|
|
8902
|
+
continue;
|
|
8903
|
+
}
|
|
8904
|
+
if(scope === 'same_type' && hook_name !== src.hook_name) {
|
|
8905
|
+
continue;
|
|
8906
|
+
}
|
|
8907
|
+
delete props.edges[key];
|
|
8908
|
+
}
|
|
8909
|
+
if(Object.keys(props.edges).length === 0) {
|
|
8910
|
+
delete props.edges;
|
|
8779
8911
|
}
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8912
|
+
}
|
|
8913
|
+
if(is_object(props.defaults)) {
|
|
8914
|
+
if(scope === 'same_type' && is_object(props.defaults.edge_styles)) {
|
|
8915
|
+
delete props.defaults.edge_styles[src.hook_name];
|
|
8916
|
+
if(Object.keys(props.defaults.edge_styles).length === 0) {
|
|
8917
|
+
delete props.defaults.edge_styles;
|
|
8783
8918
|
}
|
|
8919
|
+
} else if(scope === 'all') {
|
|
8920
|
+
delete props.defaults.edge_styles;
|
|
8921
|
+
delete props.defaults.edge_style;
|
|
8784
8922
|
}
|
|
8785
|
-
strip_all(props.defaults);
|
|
8786
8923
|
}
|
|
8924
|
+
}
|
|
8787
8925
|
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
if(topic && n.data.topic_name !== topic) {
|
|
8794
|
-
continue;
|
|
8795
|
-
}
|
|
8796
|
-
strip_all(n.data.graph_props);
|
|
8797
|
-
if(n.data.record) {
|
|
8798
|
-
strip_all(n.data.record._geometry);
|
|
8799
|
-
}
|
|
8800
|
-
ids.push(n.id);
|
|
8926
|
+
/* The edges on screen, restyled from what is left. */
|
|
8927
|
+
let updates = [];
|
|
8928
|
+
for(let e of (graph.getEdgeData() || [])) {
|
|
8929
|
+
if(!e || !hits(e.data)) {
|
|
8930
|
+
continue;
|
|
8801
8931
|
}
|
|
8932
|
+
let style = edge_style_of(gobj, e.data);
|
|
8933
|
+
updates.push({
|
|
8934
|
+
id: e.id,
|
|
8935
|
+
style: {lineWidth: style.lineWidth, stroke: style.stroke},
|
|
8936
|
+
data: Object.assign({}, e.data, {themed_default: style.themed_default}),
|
|
8937
|
+
});
|
|
8802
8938
|
}
|
|
8803
8939
|
|
|
8804
|
-
|
|
8940
|
+
deselect_edge(gobj);
|
|
8941
|
+
if(updates.length > 0) {
|
|
8942
|
+
graph.updateEdgeData(updates);
|
|
8943
|
+
}
|
|
8805
8944
|
graph.draw().then(() => {
|
|
8806
|
-
update_port_resize_handles_position(gobj);
|
|
8807
|
-
update_port_icon_position(gobj);
|
|
8808
8945
|
mark_graph_dirty(gobj);
|
|
8809
8946
|
});
|
|
8810
8947
|
}
|