scriptbase.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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.CHTMLscriptbase = void 0;
  46. var Wrapper_js_1 = require("../Wrapper.js");
  47. var scriptbase_js_1 = require("../../common/Wrappers/scriptbase.js");
  48. var CHTMLscriptbase = (function (_super) {
  49. __extends(CHTMLscriptbase, _super);
  50. function CHTMLscriptbase() {
  51. return _super !== null && _super.apply(this, arguments) || this;
  52. }
  53. CHTMLscriptbase.prototype.toCHTML = function (parent) {
  54. this.chtml = this.standardCHTMLnode(parent);
  55. var _a = __read(this.getOffset(), 2), x = _a[0], v = _a[1];
  56. var dx = x - (this.baseRemoveIc ? this.baseIc : 0);
  57. var style = { 'vertical-align': this.em(v) };
  58. if (dx) {
  59. style['margin-left'] = this.em(dx);
  60. }
  61. this.baseChild.toCHTML(this.chtml);
  62. this.scriptChild.toCHTML(this.adaptor.append(this.chtml, this.html('mjx-script', { style: style })));
  63. };
  64. CHTMLscriptbase.prototype.setDeltaW = function (nodes, dx) {
  65. for (var i = 0; i < dx.length; i++) {
  66. if (dx[i]) {
  67. this.adaptor.setStyle(nodes[i], 'paddingLeft', this.em(dx[i]));
  68. }
  69. }
  70. };
  71. CHTMLscriptbase.prototype.adjustOverDepth = function (over, overbox) {
  72. if (overbox.d >= 0)
  73. return;
  74. this.adaptor.setStyle(over, 'marginBottom', this.em(overbox.d * overbox.rscale));
  75. };
  76. CHTMLscriptbase.prototype.adjustUnderDepth = function (under, underbox) {
  77. var e_1, _a;
  78. if (underbox.d >= 0)
  79. return;
  80. var adaptor = this.adaptor;
  81. var v = this.em(underbox.d);
  82. var box = this.html('mjx-box', { style: { 'margin-bottom': v, 'vertical-align': v } });
  83. try {
  84. for (var _b = __values(adaptor.childNodes(adaptor.firstChild(under))), _c = _b.next(); !_c.done; _c = _b.next()) {
  85. var child = _c.value;
  86. adaptor.append(box, child);
  87. }
  88. }
  89. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  90. finally {
  91. try {
  92. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  93. }
  94. finally { if (e_1) throw e_1.error; }
  95. }
  96. adaptor.append(adaptor.firstChild(under), box);
  97. };
  98. CHTMLscriptbase.prototype.adjustBaseHeight = function (base, basebox) {
  99. if (this.node.attributes.get('accent')) {
  100. var minH = this.font.params.x_height * basebox.scale;
  101. if (basebox.h < minH) {
  102. this.adaptor.setStyle(base, 'paddingTop', this.em(minH - basebox.h));
  103. basebox.h = minH;
  104. }
  105. }
  106. };
  107. CHTMLscriptbase.kind = 'scriptbase';
  108. return CHTMLscriptbase;
  109. }((0, scriptbase_js_1.CommonScriptbaseMixin)(Wrapper_js_1.CHTMLWrapper)));
  110. exports.CHTMLscriptbase = CHTMLscriptbase;
  111. //# sourceMappingURL=scriptbase.js.map