@joint/core 4.0.1 → 4.0.3

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.
@@ -123,12 +123,16 @@ const textAttributesNS = {
123
123
  if (text === undefined) text = attrs.text;
124
124
  if (text !== undefined) {
125
125
  const breakTextFn = value.breakText || breakText;
126
+ const computedStyles = getComputedStyle(node);
127
+
126
128
  wrappedText = breakTextFn('' + text, size, {
127
- 'font-weight': attrs['font-weight'],
128
- 'font-size': attrs['font-size'],
129
- 'font-family': attrs['font-family'],
129
+ 'font-weight': computedStyles.fontWeight,
130
+ 'font-family': computedStyles.fontFamily,
131
+ 'text-transform': computedStyles.textTransform,
132
+ 'font-size': computedStyles.fontSize,
133
+ 'letter-spacing': computedStyles.letterSpacing,
134
+ // The `line-height` attribute in SVG is JoinJS specific.
130
135
  'lineHeight': attrs['line-height'],
131
- 'letter-spacing': attrs['letter-spacing']
132
136
  }, {
133
137
  // Provide an existing SVG Document here
134
138
  // instead of creating a temporary one over again.
@@ -67,7 +67,7 @@ export const GridLayer = PaperLayer.extend({
67
67
 
68
68
  gridSettings.forEach((gridLayerSetting, index) => {
69
69
 
70
- const id = 'pattern_' + index;
70
+ const id = this._getPatternId(index);
71
71
  const options = merge({}, gridLayerSetting);
72
72
  const { scaleFactor = 1 } = options;
73
73
  options.width = gridSize * scaleFactor || 1;
@@ -107,12 +107,16 @@ export const GridLayer = PaperLayer.extend({
107
107
  }
108
108
  gridSettings.forEach((options, index) => {
109
109
  if (isFunction(options.update)) {
110
- const vPattern = patterns['pattern_' + index];
110
+ const vPattern = patterns[this._getPatternId(index)];
111
111
  options.update(vPattern.node.firstChild, options, paper);
112
112
  }
113
113
  });
114
114
  },
115
115
 
116
+ _getPatternId(index) {
117
+ return `pattern_${this.options.paper.cid}_${index}`;
118
+ },
119
+
116
120
  _getGridRefs() {
117
121
  let { _gridCache: grid } = this;
118
122
  if (grid) return grid;
package/src/dia/ports.mjs CHANGED
@@ -731,6 +731,13 @@ export const elementViewPortPrototype = {
731
731
  'port-group': port.group
732
732
  });
733
733
 
734
+ // If the port ID is a number, we need to add
735
+ // extra information to the port element to distinguish
736
+ // between ports with the same ID but different types.
737
+ if (util.isNumber(port.id)) {
738
+ portElement.attr('port-id-type', 'number');
739
+ }
740
+
734
741
  const labelMarkupDef = this._getPortLabelMarkup(port.label);
735
742
  if (Array.isArray(labelMarkupDef)) {
736
743
  // JSON Markup
@@ -48,12 +48,14 @@ const Arrowhead = ToolView.extend({
48
48
  evt.stopPropagation();
49
49
  evt.preventDefault();
50
50
  var relatedView = this.relatedView;
51
+ var paper = relatedView.paper;
51
52
  relatedView.model.startBatch('arrowhead-move', { ui: true, tool: this.cid });
52
53
  relatedView.startArrowheadMove(this.arrowheadType);
53
54
  this.delegateDocumentEvents();
54
- relatedView.paper.undelegateEvents();
55
+ paper.undelegateEvents();
55
56
  this.focus();
56
57
  this.el.style.pointerEvents = 'none';
58
+ relatedView.notifyPointerdown(...paper.getPointerArgs(evt));
57
59
  },
58
60
  onPointerMove: function(evt) {
59
61
  var normalizedEvent = util.normalizeEvent(evt);
package/src/mvc/View.mjs CHANGED
@@ -63,23 +63,25 @@ export const View = ViewBase.extend({
63
63
  return this;
64
64
  },
65
65
 
66
- findAttribute: function(attributeName, node) {
67
-
68
- var currentNode = node;
69
-
66
+ findAttributeNode: function(attributeName, node) {
67
+ let currentNode = node;
70
68
  while (currentNode && currentNode.nodeType === 1) {
71
- var attributeValue = currentNode.getAttribute(attributeName);
72
69
  // attribute found
73
- if (attributeValue) return attributeValue;
70
+ // (empty value does not count as attribute found)
71
+ if (currentNode.getAttribute(attributeName)) return currentNode;
74
72
  // do not climb up the DOM
75
73
  if (currentNode === this.el) return null;
76
74
  // try parent node
77
75
  currentNode = currentNode.parentNode;
78
76
  }
79
-
80
77
  return null;
81
78
  },
82
79
 
80
+ findAttribute: function(attributeName, node) {
81
+ const matchedNode = this.findAttributeNode(attributeName, node);
82
+ return matchedNode && matchedNode.getAttribute(attributeName);
83
+ },
84
+
83
85
  // Override the mvc ViewBase `_ensureElement()` method in order to create an
84
86
  // svg element (e.g., `<g>`) node that wraps all the nodes of the Cell view.
85
87
  // Expose class name setter as a separate method.