mmultiscripts.js 4.7 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. Object.defineProperty(exports, "__esModule", { value: true });
  34. exports.CHTMLmmultiscripts = void 0;
  35. var msubsup_js_1 = require("./msubsup.js");
  36. var mmultiscripts_js_1 = require("../../common/Wrappers/mmultiscripts.js");
  37. var mmultiscripts_js_2 = require("../../../core/MmlTree/MmlNodes/mmultiscripts.js");
  38. var string_js_1 = require("../../../util/string.js");
  39. var CHTMLmmultiscripts = (function (_super) {
  40. __extends(CHTMLmmultiscripts, _super);
  41. function CHTMLmmultiscripts() {
  42. return _super !== null && _super.apply(this, arguments) || this;
  43. }
  44. CHTMLmmultiscripts.prototype.toCHTML = function (parent) {
  45. var chtml = this.standardCHTMLnode(parent);
  46. var data = this.scriptData;
  47. var scriptalign = this.node.getProperty('scriptalign') || 'right left';
  48. var _a = __read((0, string_js_1.split)(scriptalign + ' ' + scriptalign), 2), preAlign = _a[0], postAlign = _a[1];
  49. var sub = this.combinePrePost(data.sub, data.psub);
  50. var sup = this.combinePrePost(data.sup, data.psup);
  51. var _b = __read(this.getUVQ(sub, sup), 2), u = _b[0], v = _b[1];
  52. if (data.numPrescripts) {
  53. var scripts = this.addScripts(u, -v, true, data.psub, data.psup, this.firstPrescript, data.numPrescripts);
  54. preAlign !== 'right' && this.adaptor.setAttribute(scripts, 'script-align', preAlign);
  55. }
  56. this.childNodes[0].toCHTML(chtml);
  57. if (data.numScripts) {
  58. var scripts = this.addScripts(u, -v, false, data.sub, data.sup, 1, data.numScripts);
  59. postAlign !== 'left' && this.adaptor.setAttribute(scripts, 'script-align', postAlign);
  60. }
  61. };
  62. CHTMLmmultiscripts.prototype.addScripts = function (u, v, isPre, sub, sup, i, n) {
  63. var adaptor = this.adaptor;
  64. var q = (u - sup.d) + (v - sub.h);
  65. var U = (u < 0 && v === 0 ? sub.h + u : u);
  66. var rowdef = (q > 0 ? { style: { height: this.em(q) } } : {});
  67. var tabledef = (U ? { style: { 'vertical-align': this.em(U) } } : {});
  68. var supRow = this.html('mjx-row');
  69. var sepRow = this.html('mjx-row', rowdef);
  70. var subRow = this.html('mjx-row');
  71. var name = 'mjx-' + (isPre ? 'pre' : '') + 'scripts';
  72. var m = i + 2 * n;
  73. while (i < m) {
  74. this.childNodes[i++].toCHTML(adaptor.append(subRow, this.html('mjx-cell')));
  75. this.childNodes[i++].toCHTML(adaptor.append(supRow, this.html('mjx-cell')));
  76. }
  77. return adaptor.append(this.chtml, this.html(name, tabledef, [supRow, sepRow, subRow]));
  78. };
  79. CHTMLmmultiscripts.kind = mmultiscripts_js_2.MmlMmultiscripts.prototype.kind;
  80. CHTMLmmultiscripts.styles = {
  81. 'mjx-prescripts': {
  82. display: 'inline-table',
  83. 'padding-left': '.05em'
  84. },
  85. 'mjx-scripts': {
  86. display: 'inline-table',
  87. 'padding-right': '.05em'
  88. },
  89. 'mjx-prescripts > mjx-row > mjx-cell': {
  90. 'text-align': 'right'
  91. },
  92. '[script-align="left"] > mjx-row > mjx-cell': {
  93. 'text-align': 'left'
  94. },
  95. '[script-align="center"] > mjx-row > mjx-cell': {
  96. 'text-align': 'center'
  97. },
  98. '[script-align="right"] > mjx-row > mjx-cell': {
  99. 'text-align': 'right'
  100. }
  101. };
  102. return CHTMLmmultiscripts;
  103. }((0, mmultiscripts_js_1.CommonMmultiscriptsMixin)(msubsup_js_1.CHTMLmsubsup)));
  104. exports.CHTMLmmultiscripts = CHTMLmmultiscripts;
  105. //# sourceMappingURL=mmultiscripts.js.map