Skip to content

Commit ce18897

Browse files
committed
Links: Bugfix
- Multi-row Links that have WordCluster anchors are now properly drawn
1 parent 128a607 commit ce18897

File tree

5 files changed

+102
-17
lines changed

5 files changed

+102
-17
lines changed

demo/demo.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tag/js/tag.js

Lines changed: 77 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40714,8 +40714,8 @@ function () {
4071440714
}
4071540715
/**
4071640716
* Returns the maximum height above the baseline of the Word
40717-
* elements on the Row (accounting for their top WordTags, if present)
40718-
* TODO: Account for WordCluster height
40717+
* elements on the Row (accounting for their top WordTags and attached
40718+
* WordClusters, if present)
4071940719
*/
4072040720

4072140721
}, {
@@ -40730,6 +40730,32 @@ function () {
4073040730
for (var _iterator8 = this.words[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
4073140731
var word = _step8.value;
4073240732
wordHeight = Math.max(wordHeight, word.boxHeight);
40733+
40734+
if (word.clusters.length > 0) {
40735+
var _iteratorNormalCompletion10 = true;
40736+
var _didIteratorError10 = false;
40737+
var _iteratorError10 = undefined;
40738+
40739+
try {
40740+
for (var _iterator10 = word.clusters[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
40741+
var _cluster = _step10.value;
40742+
wordHeight = Math.max(wordHeight, _cluster.fullHeight);
40743+
}
40744+
} catch (err) {
40745+
_didIteratorError10 = true;
40746+
_iteratorError10 = err;
40747+
} finally {
40748+
try {
40749+
if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
40750+
_iterator10.return();
40751+
}
40752+
} finally {
40753+
if (_didIteratorError10) {
40754+
throw _iteratorError10;
40755+
}
40756+
}
40757+
}
40758+
}
4073340759
}
4073440760
} catch (err) {
4073540761
_didIteratorError8 = true;
@@ -40751,6 +40777,32 @@ function () {
4075140777
// last Word that was on this Row, for positioning any Links that are
4075240778
// still passing through
4075340779
wordHeight = this.lastRemovedWord.boxHeight;
40780+
40781+
if (this.lastRemovedWord.clusters.length > 0) {
40782+
var _iteratorNormalCompletion9 = true;
40783+
var _didIteratorError9 = false;
40784+
var _iteratorError9 = undefined;
40785+
40786+
try {
40787+
for (var _iterator9 = this.lastRemovedWord.clusters[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
40788+
var cluster = _step9.value;
40789+
wordHeight = Math.max(wordHeight, cluster.fullHeight);
40790+
}
40791+
} catch (err) {
40792+
_didIteratorError9 = true;
40793+
_iteratorError9 = err;
40794+
} finally {
40795+
try {
40796+
if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
40797+
_iterator9.return();
40798+
}
40799+
} finally {
40800+
if (_didIteratorError9) {
40801+
throw _iteratorError9;
40802+
}
40803+
}
40804+
}
40805+
}
4075440806
}
4075540807

4075640808
return wordHeight;
@@ -40764,26 +40816,26 @@ function () {
4076440816
key: "wordDescent",
4076540817
get: function get() {
4076640818
var wordDescent = 0;
40767-
var _iteratorNormalCompletion9 = true;
40768-
var _didIteratorError9 = false;
40769-
var _iteratorError9 = undefined;
40819+
var _iteratorNormalCompletion11 = true;
40820+
var _didIteratorError11 = false;
40821+
var _iteratorError11 = undefined;
4077040822

4077140823
try {
40772-
for (var _iterator9 = this.words[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
40773-
var word = _step9.value;
40824+
for (var _iterator11 = this.words[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
40825+
var word = _step11.value;
4077440826
wordDescent = Math.max(wordDescent, word.descendHeight);
4077540827
}
4077640828
} catch (err) {
40777-
_didIteratorError9 = true;
40778-
_iteratorError9 = err;
40829+
_didIteratorError11 = true;
40830+
_iteratorError11 = err;
4077940831
} finally {
4078040832
try {
40781-
if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
40782-
_iterator9.return();
40833+
if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
40834+
_iterator11.return();
4078340835
}
4078440836
} finally {
40785-
if (_didIteratorError9) {
40786-
throw _iteratorError9;
40837+
if (_didIteratorError11) {
40838+
throw _iteratorError11;
4078740839
}
4078840840
}
4078940841
}
@@ -41177,6 +41229,18 @@ function () {
4117741229
var thisHeight = this.svgs[0].bbox().height;
4117841230
return this.endpoints[0].absoluteY - thisHeight;
4117941231
}
41232+
/**
41233+
* Returns the height of this WordCluster, from Row baseline to the top of
41234+
* its label
41235+
*/
41236+
41237+
}, {
41238+
key: "fullHeight",
41239+
get: function get() {
41240+
// The text label lives with the left arm of the curly brace
41241+
var thisHeight = this.svgs[0].bbox().height;
41242+
return this.endpoints[0].boxHeight + thisHeight;
41243+
}
4118041244
}, {
4118141245
key: "idx",
4118241246
get: function get() {

dist/tag/js/tag.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/components/row.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,30 @@ class Row {
313313

314314
/**
315315
* Returns the maximum height above the baseline of the Word
316-
* elements on the Row (accounting for their top WordTags, if present)
317-
* TODO: Account for WordCluster height
316+
* elements on the Row (accounting for their top WordTags and attached
317+
* WordClusters, if present)
318318
*/
319319
get wordHeight() {
320320
let wordHeight = 0;
321321
for (const word of this.words) {
322322
wordHeight = Math.max(wordHeight, word.boxHeight);
323+
324+
if (word.clusters.length > 0) {
325+
for (const cluster of word.clusters) {
326+
wordHeight = Math.max(wordHeight, cluster.fullHeight);
327+
}
328+
}
323329
}
324330
if (wordHeight === 0) {
325331
// If we have no Words left on this Row, base our calculations on the
326332
// last Word that was on this Row, for positioning any Links that are
327333
// still passing through
328334
wordHeight = this.lastRemovedWord.boxHeight;
335+
if (this.lastRemovedWord.clusters.length > 0) {
336+
for (const cluster of this.lastRemovedWord.clusters) {
337+
wordHeight = Math.max(wordHeight, cluster.fullHeight);
338+
}
339+
}
329340
}
330341
return wordHeight;
331342
}

src/js/components/word-cluster.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,16 @@ class WordCluster {
310310
return this.endpoints[0].absoluteY - thisHeight;
311311
}
312312

313+
/**
314+
* Returns the height of this WordCluster, from Row baseline to the top of
315+
* its label
316+
*/
317+
get fullHeight() {
318+
// The text label lives with the left arm of the curly brace
319+
const thisHeight = this.svgs[0].bbox().height;
320+
return this.endpoints[0].boxHeight + thisHeight;
321+
}
322+
313323
get idx() {
314324
return this.endpoints[0].idx;
315325
}

0 commit comments

Comments
 (0)