orcasvn-react-diagrams 0.1.25 → 0.1.26

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/cjs/index.js CHANGED
@@ -798,6 +798,14 @@ var EditorContext = /** @class */ (function () {
798
798
  this._texts = texts;
799
799
  this._eventEmitter = new EventEmitter();
800
800
  }
801
+ EditorContext.prototype.addEventListener = function (event, callback) {
802
+ var _this = this;
803
+ this._eventEmitter.on(event, callback);
804
+ var off = function () {
805
+ _this._eventEmitter.off(event, callback);
806
+ };
807
+ return off;
808
+ };
801
809
  Object.defineProperty(EditorContext.prototype, "elements", {
802
810
  get: function () {
803
811
  return this._elements;
@@ -847,144 +855,84 @@ var EditorContext = /** @class */ (function () {
847
855
  this._texts = this._texts.filter(function (t) { return t.id !== textId; });
848
856
  };
849
857
  EditorContext.prototype.onPaperClicked = function (callback) {
850
- var _this = this;
851
- this._eventEmitter.on(EVENT_PAPER_CLICKED, callback);
852
- var off = function () {
853
- _this._eventEmitter.off(EVENT_PAPER_CLICKED, callback);
854
- };
855
- return off;
858
+ return this.addEventListener(EVENT_PAPER_CLICKED, callback);
856
859
  };
857
860
  /** @internal */
858
861
  EditorContext.prototype.onPaperClickedHandler = function (position) {
859
862
  this._eventEmitter.emit(EVENT_PAPER_CLICKED, position);
860
863
  };
861
864
  EditorContext.prototype.onPaperMouseMoved = function (callback) {
862
- var _this = this;
863
- this._eventEmitter.on(EVENT_PAPER_CLICKED, callback);
864
- var off = function () {
865
- _this._eventEmitter.off(EVENT_PAPER_CLICKED, callback);
866
- };
867
- return off;
865
+ return this.addEventListener(EVENT_PAPER_MOUSE_MOVED, callback);
868
866
  };
869
867
  /** @internal */
870
868
  EditorContext.prototype.onPaperMouseMovedHandler = function (position) {
871
869
  this._eventEmitter.emit(EVENT_PAPER_MOUSE_MOVED, position);
872
870
  };
873
871
  EditorContext.prototype.onPaperMouseDown = function (callback) {
874
- var _this = this;
875
- this._eventEmitter.on(EVENT_PAPER_MOUSE_DOWN, callback);
876
- var off = function () {
877
- _this._eventEmitter.off(EVENT_PAPER_MOUSE_DOWN, callback);
878
- };
879
- return off;
872
+ return this.addEventListener(EVENT_PAPER_MOUSE_DOWN, callback);
880
873
  };
881
874
  /** @internal */
882
875
  EditorContext.prototype.onPaperMouseDownHandler = function (position) {
883
876
  this._eventEmitter.emit(EVENT_PAPER_MOUSE_DOWN, position);
884
877
  };
885
878
  EditorContext.prototype.onPaperMouseUp = function (callback) {
886
- var _this = this;
887
- this._eventEmitter.on(EVENT_PAPER_MOUSE_UP, callback);
888
- var off = function () {
889
- _this._eventEmitter.off(EVENT_PAPER_MOUSE_UP, callback);
890
- };
891
- return off;
879
+ return this.addEventListener(EVENT_PAPER_MOUSE_UP, callback);
892
880
  };
893
881
  /** @internal */
894
882
  EditorContext.prototype.onPaperMouseUpHandler = function (position) {
895
883
  this._eventEmitter.emit(EVENT_PAPER_MOUSE_UP, position);
896
884
  };
897
885
  EditorContext.prototype.onPortMoved = function (callback) {
898
- var _this = this;
899
- this._eventEmitter.on(EVENT_PORT_MOVED, callback);
900
- var off = function () {
901
- _this._eventEmitter.off(EVENT_PORT_MOVED, callback);
902
- };
903
- return off;
886
+ return this.addEventListener(EVENT_PORT_MOVED, callback);
904
887
  };
905
888
  /** @internal */
906
889
  EditorContext.prototype.onPortMovedHandler = function (position, port, element) {
907
890
  this._eventEmitter.emit(EVENT_PORT_MOVED, position, port, element);
908
891
  };
909
892
  EditorContext.prototype.onPortSelected = function (callback) {
910
- var _this = this;
911
- this._eventEmitter.on(EVENT_PORT_SELECTED, callback);
912
- var off = function () {
913
- _this._eventEmitter.off(EVENT_PORT_SELECTED, callback);
914
- };
915
- return off;
893
+ return this.addEventListener(EVENT_PORT_SELECTED, callback);
916
894
  };
917
895
  /** @internal */
918
896
  EditorContext.prototype.onPortSelectedHandler = function (port, element) {
919
897
  this._eventEmitter.emit(EVENT_PORT_SELECTED, port, element);
920
898
  };
921
899
  EditorContext.prototype.onElementContextMenu = function (callback) {
922
- var _this = this;
923
- this._eventEmitter.on(EVENT_ELEMENT_CONTEXT_MENU, callback);
924
- var off = function () {
925
- _this._eventEmitter.off(EVENT_ELEMENT_CONTEXT_MENU, callback);
926
- };
927
- return off;
900
+ return this.addEventListener(EVENT_ELEMENT_CONTEXT_MENU, callback);
928
901
  };
929
902
  /** @internal */
930
903
  EditorContext.prototype.onElementContextMenuHandler = function (element, mouseEvent) {
931
904
  this._eventEmitter.emit(EVENT_ELEMENT_CONTEXT_MENU, element, mouseEvent);
932
905
  };
933
906
  EditorContext.prototype.onElementMoved = function (callback) {
934
- var _this = this;
935
- this._eventEmitter.on(EVENT_ELEMENT_MOVED, callback);
936
- var off = function () {
937
- _this._eventEmitter.off(EVENT_ELEMENT_MOVED, callback);
938
- };
939
- return off;
907
+ return this.addEventListener(EVENT_ELEMENT_MOVED, callback);
940
908
  };
941
909
  /** @internal */
942
910
  EditorContext.prototype.onElementMovedHandler = function (position, element) {
943
911
  this._eventEmitter.emit(EVENT_ELEMENT_MOVED, position, element);
944
912
  };
945
913
  EditorContext.prototype.onElementResized = function (callback) {
946
- var _this = this;
947
- this._eventEmitter.on(EVENT_ELEMENT_RESIZED, callback);
948
- var off = function () {
949
- _this._eventEmitter.off(EVENT_ELEMENT_RESIZED, callback);
950
- };
951
- return off;
914
+ return this.addEventListener(EVENT_ELEMENT_RESIZED, callback);
952
915
  };
953
916
  /** @internal */
954
917
  EditorContext.prototype.onElementResizedHandler = function (size, element) {
955
918
  this._eventEmitter.emit(EVENT_ELEMENT_RESIZED, size, element);
956
919
  };
957
920
  EditorContext.prototype.onElementSelected = function (callback) {
958
- var _this = this;
959
- this._eventEmitter.on(EVENT_ELEMENT_SELECTED, callback);
960
- var off = function () {
961
- _this._eventEmitter.off(EVENT_ELEMENT_SELECTED, callback);
962
- };
963
- return off;
921
+ return this.addEventListener(EVENT_ELEMENT_SELECTED, callback);
964
922
  };
965
923
  /** @internal */
966
924
  EditorContext.prototype.onElementSelectedHandler = function (element) {
967
925
  this._eventEmitter.emit(EVENT_ELEMENT_SELECTED, element);
968
926
  };
969
927
  EditorContext.prototype.onLinkSelected = function (callback) {
970
- var _this = this;
971
- this._eventEmitter.on(EVENT_LINK_SELECTED, callback);
972
- var off = function () {
973
- _this._eventEmitter.off(EVENT_LINK_SELECTED, callback);
974
- };
975
- return off;
928
+ return this.addEventListener(EVENT_LINK_SELECTED, callback);
976
929
  };
977
930
  /** @internal */
978
931
  EditorContext.prototype.onLinkSelectedHandler = function (link) {
979
932
  this._eventEmitter.emit(EVENT_LINK_SELECTED, link);
980
933
  };
981
934
  EditorContext.prototype.onTextSelected = function (callback) {
982
- var _this = this;
983
- this._eventEmitter.on(EVENT_TEXT_SELECTED, callback);
984
- var off = function () {
985
- _this._eventEmitter.off(EVENT_TEXT_SELECTED, callback);
986
- };
987
- return off;
935
+ return this.addEventListener(EVENT_TEXT_SELECTED, callback);
988
936
  };
989
937
  /** @internal */
990
938
  EditorContext.prototype.onTextSelectedHandler = function (text) {
@@ -10622,7 +10570,7 @@ function Editor(_a) {
10622
10570
  editorContext.onPaperMouseUpHandler(position);
10623
10571
  }, [editorContext]);
10624
10572
  if (editorContext)
10625
- return (React$1.createElement(Paper$1, { size: { width: width, height: height }, elements: editorContext.elements, links: editorContext.links, texts: editorContext.texts, onPaperClicked: handlePaperClicked, onPortMoved: handlePortMoved, onPortSelected: handlePortSelected, onElementContextMenu: handleElementContextMenu, onElementMoved: handleElementMoved, onElementResized: handleElementResized, onElementSelected: handleElementSelected, onCreatingLink: handleOnCreatingLink, onCreatingPortByLinking: handleOnCreatingPortByLinking, onLinkSelected: handleLinkSelected, onTextSelected: handleTextSelected, onPaperMouseMoved: handlePaperMouseMoved, onPaperMouseUp: handlePaperMouseDown, onPaperMouseDown: handlePaperMouseUp }));
10573
+ return (React$1.createElement(Paper$1, { size: { width: width, height: height }, elements: editorContext.elements, links: editorContext.links, texts: editorContext.texts, onPaperClicked: handlePaperClicked, onPortMoved: handlePortMoved, onPortSelected: handlePortSelected, onElementContextMenu: handleElementContextMenu, onElementMoved: handleElementMoved, onElementResized: handleElementResized, onElementSelected: handleElementSelected, onCreatingLink: handleOnCreatingLink, onCreatingPortByLinking: handleOnCreatingPortByLinking, onLinkSelected: handleLinkSelected, onTextSelected: handleTextSelected, onPaperMouseMoved: handlePaperMouseMoved, onPaperMouseUp: handlePaperMouseUp, onPaperMouseDown: handlePaperMouseDown }));
10626
10574
  return null;
10627
10575
  }
10628
10576
 
@@ -14,6 +14,7 @@ export declare class EditorContext implements IEditorContext {
14
14
  onCreatingPortByLinkingHandler?: ((sourceElement: IElement, sourcePort: IPort, targetElement: IElement, position: IPosition) => IPort | null) | undefined;
15
15
  onCreatingLinkHandler?: ((sourcePort: IPort, sourceElement: IElement, targetPort: IPort, targetElement: IElement) => IElementLink | null) | undefined;
16
16
  constructor(elements: IElement[], links: IElementLink[], texts: IPaperText[]);
17
+ private addEventListener;
17
18
  get elements(): IElement[];
18
19
  get links(): IElementLink[];
19
20
  get texts(): IPaperText[];
package/dist/esm/index.js CHANGED
@@ -794,6 +794,14 @@ var EditorContext = /** @class */ (function () {
794
794
  this._texts = texts;
795
795
  this._eventEmitter = new EventEmitter();
796
796
  }
797
+ EditorContext.prototype.addEventListener = function (event, callback) {
798
+ var _this = this;
799
+ this._eventEmitter.on(event, callback);
800
+ var off = function () {
801
+ _this._eventEmitter.off(event, callback);
802
+ };
803
+ return off;
804
+ };
797
805
  Object.defineProperty(EditorContext.prototype, "elements", {
798
806
  get: function () {
799
807
  return this._elements;
@@ -843,144 +851,84 @@ var EditorContext = /** @class */ (function () {
843
851
  this._texts = this._texts.filter(function (t) { return t.id !== textId; });
844
852
  };
845
853
  EditorContext.prototype.onPaperClicked = function (callback) {
846
- var _this = this;
847
- this._eventEmitter.on(EVENT_PAPER_CLICKED, callback);
848
- var off = function () {
849
- _this._eventEmitter.off(EVENT_PAPER_CLICKED, callback);
850
- };
851
- return off;
854
+ return this.addEventListener(EVENT_PAPER_CLICKED, callback);
852
855
  };
853
856
  /** @internal */
854
857
  EditorContext.prototype.onPaperClickedHandler = function (position) {
855
858
  this._eventEmitter.emit(EVENT_PAPER_CLICKED, position);
856
859
  };
857
860
  EditorContext.prototype.onPaperMouseMoved = function (callback) {
858
- var _this = this;
859
- this._eventEmitter.on(EVENT_PAPER_CLICKED, callback);
860
- var off = function () {
861
- _this._eventEmitter.off(EVENT_PAPER_CLICKED, callback);
862
- };
863
- return off;
861
+ return this.addEventListener(EVENT_PAPER_MOUSE_MOVED, callback);
864
862
  };
865
863
  /** @internal */
866
864
  EditorContext.prototype.onPaperMouseMovedHandler = function (position) {
867
865
  this._eventEmitter.emit(EVENT_PAPER_MOUSE_MOVED, position);
868
866
  };
869
867
  EditorContext.prototype.onPaperMouseDown = function (callback) {
870
- var _this = this;
871
- this._eventEmitter.on(EVENT_PAPER_MOUSE_DOWN, callback);
872
- var off = function () {
873
- _this._eventEmitter.off(EVENT_PAPER_MOUSE_DOWN, callback);
874
- };
875
- return off;
868
+ return this.addEventListener(EVENT_PAPER_MOUSE_DOWN, callback);
876
869
  };
877
870
  /** @internal */
878
871
  EditorContext.prototype.onPaperMouseDownHandler = function (position) {
879
872
  this._eventEmitter.emit(EVENT_PAPER_MOUSE_DOWN, position);
880
873
  };
881
874
  EditorContext.prototype.onPaperMouseUp = function (callback) {
882
- var _this = this;
883
- this._eventEmitter.on(EVENT_PAPER_MOUSE_UP, callback);
884
- var off = function () {
885
- _this._eventEmitter.off(EVENT_PAPER_MOUSE_UP, callback);
886
- };
887
- return off;
875
+ return this.addEventListener(EVENT_PAPER_MOUSE_UP, callback);
888
876
  };
889
877
  /** @internal */
890
878
  EditorContext.prototype.onPaperMouseUpHandler = function (position) {
891
879
  this._eventEmitter.emit(EVENT_PAPER_MOUSE_UP, position);
892
880
  };
893
881
  EditorContext.prototype.onPortMoved = function (callback) {
894
- var _this = this;
895
- this._eventEmitter.on(EVENT_PORT_MOVED, callback);
896
- var off = function () {
897
- _this._eventEmitter.off(EVENT_PORT_MOVED, callback);
898
- };
899
- return off;
882
+ return this.addEventListener(EVENT_PORT_MOVED, callback);
900
883
  };
901
884
  /** @internal */
902
885
  EditorContext.prototype.onPortMovedHandler = function (position, port, element) {
903
886
  this._eventEmitter.emit(EVENT_PORT_MOVED, position, port, element);
904
887
  };
905
888
  EditorContext.prototype.onPortSelected = function (callback) {
906
- var _this = this;
907
- this._eventEmitter.on(EVENT_PORT_SELECTED, callback);
908
- var off = function () {
909
- _this._eventEmitter.off(EVENT_PORT_SELECTED, callback);
910
- };
911
- return off;
889
+ return this.addEventListener(EVENT_PORT_SELECTED, callback);
912
890
  };
913
891
  /** @internal */
914
892
  EditorContext.prototype.onPortSelectedHandler = function (port, element) {
915
893
  this._eventEmitter.emit(EVENT_PORT_SELECTED, port, element);
916
894
  };
917
895
  EditorContext.prototype.onElementContextMenu = function (callback) {
918
- var _this = this;
919
- this._eventEmitter.on(EVENT_ELEMENT_CONTEXT_MENU, callback);
920
- var off = function () {
921
- _this._eventEmitter.off(EVENT_ELEMENT_CONTEXT_MENU, callback);
922
- };
923
- return off;
896
+ return this.addEventListener(EVENT_ELEMENT_CONTEXT_MENU, callback);
924
897
  };
925
898
  /** @internal */
926
899
  EditorContext.prototype.onElementContextMenuHandler = function (element, mouseEvent) {
927
900
  this._eventEmitter.emit(EVENT_ELEMENT_CONTEXT_MENU, element, mouseEvent);
928
901
  };
929
902
  EditorContext.prototype.onElementMoved = function (callback) {
930
- var _this = this;
931
- this._eventEmitter.on(EVENT_ELEMENT_MOVED, callback);
932
- var off = function () {
933
- _this._eventEmitter.off(EVENT_ELEMENT_MOVED, callback);
934
- };
935
- return off;
903
+ return this.addEventListener(EVENT_ELEMENT_MOVED, callback);
936
904
  };
937
905
  /** @internal */
938
906
  EditorContext.prototype.onElementMovedHandler = function (position, element) {
939
907
  this._eventEmitter.emit(EVENT_ELEMENT_MOVED, position, element);
940
908
  };
941
909
  EditorContext.prototype.onElementResized = function (callback) {
942
- var _this = this;
943
- this._eventEmitter.on(EVENT_ELEMENT_RESIZED, callback);
944
- var off = function () {
945
- _this._eventEmitter.off(EVENT_ELEMENT_RESIZED, callback);
946
- };
947
- return off;
910
+ return this.addEventListener(EVENT_ELEMENT_RESIZED, callback);
948
911
  };
949
912
  /** @internal */
950
913
  EditorContext.prototype.onElementResizedHandler = function (size, element) {
951
914
  this._eventEmitter.emit(EVENT_ELEMENT_RESIZED, size, element);
952
915
  };
953
916
  EditorContext.prototype.onElementSelected = function (callback) {
954
- var _this = this;
955
- this._eventEmitter.on(EVENT_ELEMENT_SELECTED, callback);
956
- var off = function () {
957
- _this._eventEmitter.off(EVENT_ELEMENT_SELECTED, callback);
958
- };
959
- return off;
917
+ return this.addEventListener(EVENT_ELEMENT_SELECTED, callback);
960
918
  };
961
919
  /** @internal */
962
920
  EditorContext.prototype.onElementSelectedHandler = function (element) {
963
921
  this._eventEmitter.emit(EVENT_ELEMENT_SELECTED, element);
964
922
  };
965
923
  EditorContext.prototype.onLinkSelected = function (callback) {
966
- var _this = this;
967
- this._eventEmitter.on(EVENT_LINK_SELECTED, callback);
968
- var off = function () {
969
- _this._eventEmitter.off(EVENT_LINK_SELECTED, callback);
970
- };
971
- return off;
924
+ return this.addEventListener(EVENT_LINK_SELECTED, callback);
972
925
  };
973
926
  /** @internal */
974
927
  EditorContext.prototype.onLinkSelectedHandler = function (link) {
975
928
  this._eventEmitter.emit(EVENT_LINK_SELECTED, link);
976
929
  };
977
930
  EditorContext.prototype.onTextSelected = function (callback) {
978
- var _this = this;
979
- this._eventEmitter.on(EVENT_TEXT_SELECTED, callback);
980
- var off = function () {
981
- _this._eventEmitter.off(EVENT_TEXT_SELECTED, callback);
982
- };
983
- return off;
931
+ return this.addEventListener(EVENT_TEXT_SELECTED, callback);
984
932
  };
985
933
  /** @internal */
986
934
  EditorContext.prototype.onTextSelectedHandler = function (text) {
@@ -10618,7 +10566,7 @@ function Editor(_a) {
10618
10566
  editorContext.onPaperMouseUpHandler(position);
10619
10567
  }, [editorContext]);
10620
10568
  if (editorContext)
10621
- return (React$1.createElement(Paper$1, { size: { width: width, height: height }, elements: editorContext.elements, links: editorContext.links, texts: editorContext.texts, onPaperClicked: handlePaperClicked, onPortMoved: handlePortMoved, onPortSelected: handlePortSelected, onElementContextMenu: handleElementContextMenu, onElementMoved: handleElementMoved, onElementResized: handleElementResized, onElementSelected: handleElementSelected, onCreatingLink: handleOnCreatingLink, onCreatingPortByLinking: handleOnCreatingPortByLinking, onLinkSelected: handleLinkSelected, onTextSelected: handleTextSelected, onPaperMouseMoved: handlePaperMouseMoved, onPaperMouseUp: handlePaperMouseDown, onPaperMouseDown: handlePaperMouseUp }));
10569
+ return (React$1.createElement(Paper$1, { size: { width: width, height: height }, elements: editorContext.elements, links: editorContext.links, texts: editorContext.texts, onPaperClicked: handlePaperClicked, onPortMoved: handlePortMoved, onPortSelected: handlePortSelected, onElementContextMenu: handleElementContextMenu, onElementMoved: handleElementMoved, onElementResized: handleElementResized, onElementSelected: handleElementSelected, onCreatingLink: handleOnCreatingLink, onCreatingPortByLinking: handleOnCreatingPortByLinking, onLinkSelected: handleLinkSelected, onTextSelected: handleTextSelected, onPaperMouseMoved: handlePaperMouseMoved, onPaperMouseUp: handlePaperMouseUp, onPaperMouseDown: handlePaperMouseDown }));
10622
10570
  return null;
10623
10571
  }
10624
10572