@foblex/flow 16.0.4 → 16.0.5

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.
@@ -2706,7 +2706,7 @@ class FConnectionTextPathDirective {
2706
2706
  getSymbolWidth(name) {
2707
2707
  const text = name || 'connection';
2708
2708
  const { fontFamily, fontSize } = this.getFontStyles(this.hostElement);
2709
- this.fontSize = fontSize;
2709
+ this.fontSize = fontSize || '12px';
2710
2710
  const canvas = this.fBrowser.document.createElement('canvas');
2711
2711
  let context;
2712
2712
  try {
@@ -3884,10 +3884,21 @@ class ConnectionBaseDragHandler {
3884
3884
  this.fInputWithRect = this.fMediator.send(new GetConnectorWithRectRequest(this.getInput()));
3885
3885
  }
3886
3886
  getOutput() {
3887
- return this.fComponentsStore.fOutputs.find((x) => x.id === this.connection.fOutputId);
3887
+ const result = this.fComponentsStore.fOutputs.find((x) => x.id === this.connection.fOutputId);
3888
+ if (!result) {
3889
+ throw new Error(this.connectorNotFoundPrefix(`fOutput with id ${this.connection.fOutputId} not found`));
3890
+ }
3891
+ return result;
3888
3892
  }
3889
3893
  getInput() {
3890
- return this.fComponentsStore.fInputs.find((x) => x.id === this.connection.fInputId);
3894
+ const result = this.fComponentsStore.fInputs.find((x) => x.id === this.connection.fInputId);
3895
+ if (!result) {
3896
+ throw new Error(this.connectorNotFoundPrefix(`fInput with id ${this.connection.fInputId} not found`));
3897
+ }
3898
+ return result;
3899
+ }
3900
+ connectorNotFoundPrefix(message) {
3901
+ return `ConnectionDragHandler Error: Connection From (fOutput)${this.connection.fOutputId} To (fInput)${this.connection.fInputId}. ${message}. Please ensure that all f-connections are associated with existing connectors`;
3891
3902
  }
3892
3903
  getDifference(difference, restrictions) {
3893
3904
  return {
@@ -4123,6 +4134,9 @@ const DEFAULT_RESTRICTIONS = {
4123
4134
  };
4124
4135
 
4125
4136
  class CreateMoveNodesDragModelFromSelectionRequest {
4137
+ constructor(nodeWithDisabledSelection) {
4138
+ this.nodeWithDisabledSelection = nodeWithDisabledSelection;
4139
+ }
4126
4140
  }
4127
4141
 
4128
4142
  class NodeDragHandler {
@@ -4176,13 +4190,17 @@ let CreateMoveNodesDragModelFromSelectionExecution = class CreateMoveNodesDragMo
4176
4190
  this.fMediator = fMediator;
4177
4191
  }
4178
4192
  handle(request) {
4179
- const itemsToDrag = this.getNodesWithRestrictions(this.getSelectedNodes());
4193
+ const itemsToDrag = this.getNodesWithRestrictions(this.getSelectedNodes(request.nodeWithDisabledSelection));
4180
4194
  return this.getDragHandlersWithConnections(this.getDragHandlersFromNodes(itemsToDrag), this.getAllOutputIds(itemsToDrag), this.getAllInputIds(itemsToDrag));
4181
4195
  }
4182
- getSelectedNodes() {
4183
- return this.fDraggableDataContext.selectedItems
4196
+ getSelectedNodes(nodeWithDisabledSelection) {
4197
+ const result = this.fDraggableDataContext.selectedItems
4184
4198
  .map((x) => this.fComponentsStore.findNode(x.hostElement))
4185
4199
  .filter((x) => !!x);
4200
+ if (nodeWithDisabledSelection) {
4201
+ result.push(nodeWithDisabledSelection);
4202
+ }
4203
+ return result;
4186
4204
  }
4187
4205
  getNodesWithRestrictions(selectedNodes) {
4188
4206
  const result = [];
@@ -4263,22 +4281,32 @@ let NodeMovePreparationExecution = class NodeMovePreparationExecution {
4263
4281
  this.fMediator = fMediator;
4264
4282
  }
4265
4283
  handle(request) {
4266
- this.selectAndUpdateNodeLayer(request.event.targetElement);
4267
- const itemsToDrag = this.createDragModelFromSelection();
4284
+ const node = this.getNode(request.event.targetElement);
4285
+ if (!node) {
4286
+ throw new Error('Node not found');
4287
+ }
4288
+ let itemsToDrag = [];
4289
+ if (!node.fSelectionDisabled) {
4290
+ this.selectAndUpdateNodeLayer(node);
4291
+ itemsToDrag = this.createDragModelFromSelection();
4292
+ }
4293
+ else {
4294
+ itemsToDrag = this.createDragModelFromSelection(node);
4295
+ }
4268
4296
  this.initializeLineAlignment(this.filterNodesFromDraggableItems(itemsToDrag));
4269
4297
  this.fDraggableDataContext.onPointerDownScale = this.transform.scale;
4270
4298
  this.fDraggableDataContext.onPointerDownPosition = Point.fromPoint(request.event.getPosition())
4271
4299
  .elementTransform(this.flowHost).div(this.transform.scale);
4272
4300
  this.fDraggableDataContext.draggableItems = itemsToDrag;
4273
4301
  }
4274
- selectAndUpdateNodeLayer(targetElement) {
4275
- this.fMediator.send(new SelectAndUpdateNodeLayerRequest(this.getNode(targetElement)));
4302
+ selectAndUpdateNodeLayer(node) {
4303
+ this.fMediator.send(new SelectAndUpdateNodeLayerRequest(node));
4276
4304
  }
4277
4305
  getNode(targetElement) {
4278
4306
  return this.fComponentsStore.findNode(targetElement);
4279
4307
  }
4280
- createDragModelFromSelection() {
4281
- return this.fMediator.send(new CreateMoveNodesDragModelFromSelectionRequest());
4308
+ createDragModelFromSelection(nodeWithDisabledSelection) {
4309
+ return this.fMediator.send(new CreateMoveNodesDragModelFromSelectionRequest(nodeWithDisabledSelection));
4282
4310
  }
4283
4311
  initializeLineAlignment(nodesToDrag) {
4284
4312
  this.fDraggableDataContext.fLineAlignment?.initialize(this.fComponentsStore.fNodes, nodesToDrag);
@@ -4871,6 +4899,9 @@ let SingleSelectExecution = class SingleSelectExecution {
4871
4899
  this.clearSelection();
4872
4900
  this.selectItem(item);
4873
4901
  }
4902
+ else if (item.fSelectionDisabled) {
4903
+ this.clearSelection();
4904
+ }
4874
4905
  }
4875
4906
  else {
4876
4907
  this.clearSelection();
@@ -7762,6 +7793,38 @@ class FZoomBase {
7762
7793
  this.fComponentsStore = fComponentsStore;
7763
7794
  this.isEnabled = false;
7764
7795
  this.listeners = EventExtensions.emptyListener();
7796
+ this.onWheel = (event) => {
7797
+ event.preventDefault();
7798
+ const targetElement = event.target;
7799
+ if (this.fComponentsStore.fDraggable?.isDragStarted || targetElement?.closest('[fLockedContext]')) {
7800
+ return;
7801
+ }
7802
+ let result = this.getScale();
7803
+ const direction = event.deltaY > 0 ? -1 : 1;
7804
+ const step = this.step;
7805
+ result = result + step * direction;
7806
+ result = Math.max(this.minimum, Math.min(result, this.maximum));
7807
+ const pointerPositionInFlow = new Point(event.clientX, event.clientY).elementTransform(this.flowHost);
7808
+ this.fCanvas.setZoom(result, pointerPositionInFlow);
7809
+ this.fCanvas.redraw();
7810
+ this.fCanvas.emitCanvasChangeEvent();
7811
+ };
7812
+ this.onDoubleClick = (event) => {
7813
+ event.preventDefault();
7814
+ const targetElement = event.target;
7815
+ if (this.fComponentsStore.fDraggable?.isDragStarted || isNode(targetElement) || targetElement?.closest('[fLockedContext]')) {
7816
+ return;
7817
+ }
7818
+ let result = this.getScale();
7819
+ const direction = 1;
7820
+ const step = this.dblClickStep;
7821
+ result = result + step * direction;
7822
+ result = Math.max(this.minimum, Math.min(result, this.maximum));
7823
+ const pointerPositionInFlow = new Point(event.clientX, event.clientY).elementTransform(this.flowHost);
7824
+ this.fCanvas.setZoom(result, pointerPositionInFlow);
7825
+ this.fCanvas.redrawWithAnimation();
7826
+ this.fCanvas.emitCanvasChangeEvent();
7827
+ };
7765
7828
  }
7766
7829
  toggleZoom() {
7767
7830
  if (this.isEnabled) {
@@ -7776,48 +7839,16 @@ class FZoomBase {
7776
7839
  if (!this.flowHost) {
7777
7840
  return;
7778
7841
  }
7779
- this.flowHost.addEventListener('wheel', this.onWheel.bind(this));
7780
- this.flowHost.addEventListener('dblclick', this.onDoubleClick.bind(this));
7842
+ this.flowHost.addEventListener('wheel', this.onWheel);
7843
+ this.flowHost.addEventListener('dblclick', this.onDoubleClick);
7781
7844
  this.listeners = () => {
7782
- this.flowHost.removeEventListener('wheel', this.onWheel.bind(this));
7783
- this.flowHost.removeEventListener('dblclick', this.onDoubleClick.bind(this));
7845
+ this.flowHost.removeEventListener('wheel', this.onWheel);
7846
+ this.flowHost.removeEventListener('dblclick', this.onDoubleClick);
7784
7847
  };
7785
7848
  }
7786
7849
  getScale() {
7787
7850
  return this.fCanvas.transform.scale || 1;
7788
7851
  }
7789
- onWheel(event) {
7790
- event.preventDefault();
7791
- const targetElement = event.target;
7792
- if (this.fComponentsStore.fDraggable?.isDragStarted || targetElement?.closest('[fLockedContext]')) {
7793
- return;
7794
- }
7795
- let result = this.getScale();
7796
- const direction = event.deltaY > 0 ? -1 : 1;
7797
- const step = this.step;
7798
- result = result + step * direction;
7799
- result = Math.max(this.minimum, Math.min(result, this.maximum));
7800
- const pointerPositionInFlow = new Point(event.clientX, event.clientY).elementTransform(this.flowHost);
7801
- this.fCanvas.setZoom(result, pointerPositionInFlow);
7802
- this.fCanvas.redraw();
7803
- this.fCanvas.emitCanvasChangeEvent();
7804
- }
7805
- onDoubleClick(event) {
7806
- event.preventDefault();
7807
- const targetElement = event.target;
7808
- if (this.fComponentsStore.fDraggable?.isDragStarted || isNode(targetElement) || targetElement?.closest('[fLockedContext]')) {
7809
- return;
7810
- }
7811
- let result = this.getScale();
7812
- const direction = 1;
7813
- const step = this.dblClickStep;
7814
- result = result + step * direction;
7815
- result = Math.max(this.minimum, Math.min(result, this.maximum));
7816
- const pointerPositionInFlow = new Point(event.clientX, event.clientY).elementTransform(this.flowHost);
7817
- this.fCanvas.setZoom(result, pointerPositionInFlow);
7818
- this.fCanvas.redrawWithAnimation();
7819
- this.fCanvas.emitCanvasChangeEvent();
7820
- }
7821
7852
  onZoomToCenter(deltaY, position) {
7822
7853
  const preventDefault = () => {
7823
7854
  };