mpadded.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 __values = (this && this.__values) || function(o) {
  34. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  35. if (m) return m.call(o);
  36. if (o && typeof o.length === "number") return {
  37. next: function () {
  38. if (o && i >= o.length) o = void 0;
  39. return { value: o && o[i++], done: !o };
  40. }
  41. };
  42. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  43. };
  44. Object.defineProperty(exports, "__esModule", { value: true });
  45. exports.CHTMLmpadded = void 0;
  46. var Wrapper_js_1 = require("../Wrapper.js");
  47. var mpadded_js_1 = require("../../common/Wrappers/mpadded.js");
  48. var mpadded_js_2 = require("../../../core/MmlTree/MmlNodes/mpadded.js");
  49. var CHTMLmpadded = (function (_super) {
  50. __extends(CHTMLmpadded, _super);
  51. function CHTMLmpadded() {
  52. return _super !== null && _super.apply(this, arguments) || this;
  53. }
  54. CHTMLmpadded.prototype.toCHTML = function (parent) {
  55. var e_1, _a;
  56. var chtml = this.standardCHTMLnode(parent);
  57. var content = [];
  58. var style = {};
  59. var _b = __read(this.getDimens(), 9), W = _b[2], dh = _b[3], dd = _b[4], dw = _b[5], x = _b[6], y = _b[7], dx = _b[8];
  60. if (dw) {
  61. style.width = this.em(W + dw);
  62. }
  63. if (dh || dd) {
  64. style.margin = this.em(dh) + ' 0 ' + this.em(dd);
  65. }
  66. if (x + dx || y) {
  67. style.position = 'relative';
  68. var rbox = this.html('mjx-rbox', {
  69. style: { left: this.em(x + dx), top: this.em(-y), 'max-width': style.width }
  70. });
  71. if (x + dx && this.childNodes[0].getBBox().pwidth) {
  72. this.adaptor.setAttribute(rbox, 'width', 'full');
  73. this.adaptor.setStyle(rbox, 'left', this.em(x));
  74. }
  75. content.push(rbox);
  76. }
  77. chtml = this.adaptor.append(chtml, this.html('mjx-block', { style: style }, content));
  78. try {
  79. for (var _c = __values(this.childNodes), _d = _c.next(); !_d.done; _d = _c.next()) {
  80. var child = _d.value;
  81. child.toCHTML(content[0] || chtml);
  82. }
  83. }
  84. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  85. finally {
  86. try {
  87. if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
  88. }
  89. finally { if (e_1) throw e_1.error; }
  90. }
  91. };
  92. CHTMLmpadded.kind = mpadded_js_2.MmlMpadded.prototype.kind;
  93. CHTMLmpadded.styles = {
  94. 'mjx-mpadded': {
  95. display: 'inline-block'
  96. },
  97. 'mjx-rbox': {
  98. display: 'inline-block',
  99. position: 'relative'
  100. }
  101. };
  102. return CHTMLmpadded;
  103. }((0, mpadded_js_1.CommonMpaddedMixin)(Wrapper_js_1.CHTMLWrapper)));
  104. exports.CHTMLmpadded = CHTMLmpadded;
  105. //# sourceMappingURL=mpadded.js.map