react-native-mathjax-html-to-svg
Version:
React Native component to display mathematics in html using MathJax. Uses [MathJax](https://github.com/mathjax/)
185 lines (184 loc) • 6.97 kB
JavaScript
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommonMunderoverMixin = exports.CommonMoverMixin = exports.CommonMunderMixin = void 0;
function CommonMunderMixin(Base) {
return (function (_super) {
__extends(class_1, _super);
function class_1() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.apply(this, __spread(args)) || this;
_this.stretchChildren();
return _this;
}
Object.defineProperty(class_1.prototype, "script", {
get: function () {
return this.childNodes[this.node.under];
},
enumerable: false,
configurable: true
});
class_1.prototype.computeBBox = function (bbox, recompute) {
if (recompute === void 0) { recompute = false; }
if (this.hasMovableLimits()) {
_super.prototype.computeBBox.call(this, bbox, recompute);
return;
}
bbox.empty();
var basebox = this.baseChild.getBBox();
var underbox = this.script.getBBox();
var v = this.getUnderKV(basebox, underbox)[1];
var delta = this.getDelta(true);
var _a = __read(this.getDeltaW([basebox, underbox], [0, -delta]), 2), bw = _a[0], uw = _a[1];
bbox.combine(basebox, bw, 0);
bbox.combine(underbox, uw, v);
bbox.d += this.font.params.big_op_spacing5;
bbox.ic = -this.baseCore.bbox.ic;
bbox.clean();
this.setChildPWidths(recompute);
};
return class_1;
}(Base));
}
exports.CommonMunderMixin = CommonMunderMixin;
function CommonMoverMixin(Base) {
return (function (_super) {
__extends(class_2, _super);
function class_2() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.apply(this, __spread(args)) || this;
_this.stretchChildren();
return _this;
}
Object.defineProperty(class_2.prototype, "script", {
get: function () {
return this.childNodes[this.node.over];
},
enumerable: false,
configurable: true
});
class_2.prototype.computeBBox = function (bbox) {
if (this.hasMovableLimits()) {
_super.prototype.computeBBox.call(this, bbox);
return;
}
bbox.empty();
var basebox = this.baseChild.getBBox();
var overbox = this.script.getBBox();
var u = this.getOverKU(basebox, overbox)[1];
var delta = this.getDelta();
var _a = __read(this.getDeltaW([basebox, overbox], [0, delta]), 2), bw = _a[0], ow = _a[1];
bbox.combine(basebox, bw, 0);
bbox.combine(overbox, ow, u);
bbox.h += this.font.params.big_op_spacing5;
bbox.ic = -this.baseCore.bbox.ic;
bbox.clean();
};
return class_2;
}(Base));
}
exports.CommonMoverMixin = CommonMoverMixin;
function CommonMunderoverMixin(Base) {
return (function (_super) {
__extends(class_3, _super);
function class_3() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.apply(this, __spread(args)) || this;
_this.stretchChildren();
return _this;
}
Object.defineProperty(class_3.prototype, "underChild", {
get: function () {
return this.childNodes[this.node.under];
},
enumerable: false,
configurable: true
});
Object.defineProperty(class_3.prototype, "overChild", {
get: function () {
return this.childNodes[this.node.over];
},
enumerable: false,
configurable: true
});
Object.defineProperty(class_3.prototype, "subChild", {
get: function () {
return this.underChild;
},
enumerable: false,
configurable: true
});
Object.defineProperty(class_3.prototype, "supChild", {
get: function () {
return this.overChild;
},
enumerable: false,
configurable: true
});
class_3.prototype.computeBBox = function (bbox) {
if (this.hasMovableLimits()) {
_super.prototype.computeBBox.call(this, bbox);
return;
}
bbox.empty();
var overbox = this.overChild.getBBox();
var basebox = this.baseChild.getBBox();
var underbox = this.underChild.getBBox();
var u = this.getOverKU(basebox, overbox)[1];
var v = this.getUnderKV(basebox, underbox)[1];
var delta = this.getDelta();
var _a = __read(this.getDeltaW([basebox, underbox, overbox], [0, -delta, delta]), 3), bw = _a[0], uw = _a[1], ow = _a[2];
bbox.combine(basebox, bw, 0);
bbox.combine(overbox, ow, u);
bbox.combine(underbox, uw, v);
var z = this.font.params.big_op_spacing5;
bbox.h += z;
bbox.d += z;
bbox.ic = -this.baseCore.bbox.ic;
bbox.clean();
};
return class_3;
}(Base));
}
exports.CommonMunderoverMixin = CommonMunderoverMixin;