mfenced.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. var __read = (this && this.__read) || function (o, n) {
  18. var m = typeof Symbol === "function" && o[Symbol.iterator];
  19. if (!m) return o;
  20. var i = m.call(o), r, ar = [], e;
  21. try {
  22. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  23. }
  24. catch (error) { e = { error: error }; }
  25. finally {
  26. try {
  27. if (r && !r.done && (m = i["return"])) m.call(i);
  28. }
  29. finally { if (e) throw e.error; }
  30. }
  31. return ar;
  32. };
  33. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  34. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  35. if (ar || !(i in from)) {
  36. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  37. ar[i] = from[i];
  38. }
  39. }
  40. return to.concat(ar || Array.prototype.slice.call(from));
  41. };
  42. var __values = (this && this.__values) || function(o) {
  43. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  44. if (m) return m.call(o);
  45. if (o && typeof o.length === "number") return {
  46. next: function () {
  47. if (o && i >= o.length) o = void 0;
  48. return { value: o && o[i++], done: !o };
  49. }
  50. };
  51. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  52. };
  53. Object.defineProperty(exports, "__esModule", { value: true });
  54. exports.CommonMfencedMixin = void 0;
  55. function CommonMfencedMixin(Base) {
  56. return (function (_super) {
  57. __extends(class_1, _super);
  58. function class_1() {
  59. var args = [];
  60. for (var _i = 0; _i < arguments.length; _i++) {
  61. args[_i] = arguments[_i];
  62. }
  63. var _this = _super.apply(this, __spreadArray([], __read(args), false)) || this;
  64. _this.mrow = null;
  65. _this.createMrow();
  66. _this.addMrowChildren();
  67. return _this;
  68. }
  69. class_1.prototype.createMrow = function () {
  70. var mmlFactory = this.node.factory;
  71. var mrow = mmlFactory.create('inferredMrow');
  72. mrow.inheritAttributesFrom(this.node);
  73. this.mrow = this.wrap(mrow);
  74. this.mrow.parent = this;
  75. };
  76. class_1.prototype.addMrowChildren = function () {
  77. var e_1, _a;
  78. var mfenced = this.node;
  79. var mrow = this.mrow;
  80. this.addMo(mfenced.open);
  81. if (this.childNodes.length) {
  82. mrow.childNodes.push(this.childNodes[0]);
  83. }
  84. var i = 0;
  85. try {
  86. for (var _b = __values(this.childNodes.slice(1)), _c = _b.next(); !_c.done; _c = _b.next()) {
  87. var child = _c.value;
  88. this.addMo(mfenced.separators[i++]);
  89. mrow.childNodes.push(child);
  90. }
  91. }
  92. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  93. finally {
  94. try {
  95. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  96. }
  97. finally { if (e_1) throw e_1.error; }
  98. }
  99. this.addMo(mfenced.close);
  100. mrow.stretchChildren();
  101. };
  102. class_1.prototype.addMo = function (node) {
  103. if (!node)
  104. return;
  105. var mo = this.wrap(node);
  106. this.mrow.childNodes.push(mo);
  107. mo.parent = this.mrow;
  108. };
  109. class_1.prototype.computeBBox = function (bbox, recompute) {
  110. if (recompute === void 0) { recompute = false; }
  111. bbox.updateFrom(this.mrow.getOuterBBox());
  112. this.setChildPWidths(recompute);
  113. };
  114. return class_1;
  115. }(Base));
  116. }
  117. exports.CommonMfencedMixin = CommonMfencedMixin;
  118. //# sourceMappingURL=mfenced.js.map