@joint/core 4.1.3 → 4.2.0-alpha.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.
Files changed (58) hide show
  1. package/README.md +4 -2
  2. package/dist/geometry.js +129 -124
  3. package/dist/geometry.min.js +4 -3
  4. package/dist/joint.d.ts +352 -160
  5. package/dist/joint.js +3654 -2191
  6. package/dist/joint.min.js +4 -3
  7. package/dist/joint.nowrap.js +3653 -2188
  8. package/dist/joint.nowrap.min.js +4 -3
  9. package/dist/vectorizer.js +489 -279
  10. package/dist/vectorizer.min.js +4 -3
  11. package/dist/version.mjs +1 -1
  12. package/package.json +33 -27
  13. package/src/V/create.mjs +51 -0
  14. package/src/V/index.mjs +89 -159
  15. package/src/V/namespace.mjs +9 -0
  16. package/src/V/transform.mjs +183 -0
  17. package/src/V/traverse.mjs +16 -0
  18. package/src/alg/Deque.mjs +126 -0
  19. package/src/anchors/index.mjs +140 -33
  20. package/src/cellTools/Boundary.mjs +15 -13
  21. package/src/cellTools/Button.mjs +7 -5
  22. package/src/cellTools/Control.mjs +38 -15
  23. package/src/cellTools/HoverConnect.mjs +5 -1
  24. package/src/cellTools/helpers.mjs +44 -3
  25. package/src/config/index.mjs +8 -0
  26. package/src/connectionPoints/index.mjs +24 -9
  27. package/src/connectionStrategies/index.mjs +1 -1
  28. package/src/connectors/jumpover.mjs +1 -1
  29. package/src/dia/Cell.mjs +32 -12
  30. package/src/dia/CellView.mjs +53 -38
  31. package/src/dia/Element.mjs +81 -35
  32. package/src/dia/ElementView.mjs +2 -1
  33. package/src/dia/HighlighterView.mjs +54 -11
  34. package/src/dia/LinkView.mjs +118 -98
  35. package/src/dia/Paper.mjs +831 -231
  36. package/src/dia/PaperLayer.mjs +9 -2
  37. package/src/dia/ToolView.mjs +4 -0
  38. package/src/dia/ToolsView.mjs +12 -3
  39. package/src/dia/attributes/text.mjs +16 -5
  40. package/src/dia/layers/GridLayer.mjs +5 -0
  41. package/src/dia/ports.mjs +344 -111
  42. package/src/elementTools/HoverConnect.mjs +14 -8
  43. package/src/env/index.mjs +7 -4
  44. package/src/g/rect.mjs +7 -0
  45. package/src/highlighters/stroke.mjs +1 -1
  46. package/src/layout/ports/port.mjs +30 -15
  47. package/src/layout/ports/portLabel.mjs +1 -1
  48. package/src/linkAnchors/index.mjs +2 -2
  49. package/src/linkTools/Anchor.mjs +2 -2
  50. package/src/linkTools/Vertices.mjs +4 -6
  51. package/src/mvc/View.mjs +4 -0
  52. package/src/mvc/ViewBase.mjs +1 -1
  53. package/src/util/util.mjs +1 -1
  54. package/src/util/utilHelpers.mjs +2 -0
  55. package/types/geometry.d.ts +65 -59
  56. package/types/joint.d.ts +278 -102
  57. package/types/vectorizer.d.ts +11 -1
  58. package/src/V/annotation.mjs +0 -0
@@ -22,7 +22,9 @@ export const PaperLayer = View.extend({
22
22
  },
23
23
 
24
24
  className: function() {
25
- return addClassNamePrefix(`${this.options.name}-layer`);
25
+ const { name } = this.options;
26
+ if (!name) return null;
27
+ return addClassNamePrefix(`${name}-layer`);
26
28
  },
27
29
 
28
30
  init: function() {
@@ -70,6 +72,11 @@ export const PaperLayer = View.extend({
70
72
  const { el, pivotNodes } = this;
71
73
  for (let z in pivotNodes) el.removeChild(pivotNodes[z]);
72
74
  this.pivotNodes = {};
73
- }
75
+ },
76
+
77
+ isEmpty: function() {
78
+ // Check if the layer has any child elements (pivot comments are not counted).
79
+ return this.el.children.length === 0;
80
+ },
74
81
 
75
82
  });
@@ -69,6 +69,10 @@ export const ToolView = mvc.View.extend({
69
69
  return !!this._visible;
70
70
  },
71
71
 
72
+ isOverlay: function() {
73
+ return !!this.parentView && this.parentView.hasLayer();
74
+ },
75
+
72
76
  focus: function() {
73
77
  var opacity = this.options.focusOpacity;
74
78
  if (isFinite(opacity)) this.el.style.opacity = opacity;
@@ -138,12 +138,21 @@ export const ToolsView = mvc.View.extend({
138
138
  this.tools = null;
139
139
  },
140
140
 
141
+ getLayer() {
142
+ const { layer = LayersNames.TOOLS } = this.options;
143
+ return layer;
144
+ },
145
+
146
+ hasLayer() {
147
+ return !!this.getLayer();
148
+ },
149
+
141
150
  mount: function() {
142
151
  const { options, el } = this;
143
- const { relatedView, layer = LayersNames.TOOLS, z } = options;
152
+ const { relatedView, z } = options;
144
153
  if (relatedView) {
145
- if (layer) {
146
- relatedView.paper.getLayerView(layer).insertSortedNode(el, z);
154
+ if (this.hasLayer()) {
155
+ relatedView.paper.getLayerView(this.getLayer()).insertSortedNode(el, z);
147
156
  } else {
148
157
  relatedView.el.appendChild(el);
149
158
  }
@@ -54,9 +54,10 @@ const textAttributesNS = {
54
54
  const eol = attrs.eol;
55
55
  const x = attrs.x;
56
56
  let textPath = attrs['text-path'];
57
+ const useNoBreakSpace = attrs['use-no-break-space'] === true;
57
58
  // Update the text only if there was a change in the string
58
59
  // or any of its attributes.
59
- const textHash = JSON.stringify([text, lineHeight, annotations, textVerticalAnchor, eol, displayEmpty, textPath, x, fontSize]);
60
+ const textHash = JSON.stringify([text, lineHeight, annotations, textVerticalAnchor, eol, displayEmpty, textPath, x, fontSize, useNoBreakSpace]);
60
61
  if (cache === undefined || cache !== textHash) {
61
62
  // Chrome bug:
62
63
  // <tspan> positions defined as `em` are not updated
@@ -79,7 +80,8 @@ const textAttributesNS = {
79
80
  x,
80
81
  textVerticalAnchor,
81
82
  eol,
82
- displayEmpty
83
+ displayEmpty,
84
+ useNoBreakSpace
83
85
  });
84
86
  $.data.set(node, cacheName, textHash);
85
87
  }
@@ -148,10 +150,19 @@ const textAttributesNS = {
148
150
  // TODO: change the `lineHeight` to breakText option.
149
151
  wrapFontAttributes.lineHeight = attrs['line-height'];
150
152
 
153
+ let svgDocument = this.paper.svg;
154
+ if (!svgDocument.checkVisibility()) {
155
+ // If the paper is visible, we can utilize
156
+ // its SVG element to measure the text size
157
+ // when breaking the text.
158
+ // Otherwise, we need to create a temporary
159
+ // SVG document and append it to the DOM,
160
+ // (the default behavior of `breakText`).
161
+ svgDocument = null;
162
+ }
163
+
151
164
  wrappedText = breakTextFn('' + text, size, wrapFontAttributes, {
152
- // Provide an existing SVG Document here
153
- // instead of creating a temporary one over again.
154
- svgDocument: this.paper.svg,
165
+ svgDocument,
155
166
  ellipsis: value.ellipsis,
156
167
  hyphen: value.hyphen,
157
168
  separator: value.separator,
@@ -177,4 +177,9 @@ export const GridLayer = PaperLayer.extend({
177
177
  return isArray ? options : [options];
178
178
  },
179
179
 
180
+ isEmpty() {
181
+ const { _gridCache: grid } = this;
182
+ return this.el.children.length === (grid ? 1 : 0);
183
+ }
184
+
180
185
  });