site/node_modules/mathjax-full/js/output/common/Wrappers/mglyph.js

85 lines
3.4 KiB
JavaScript
Raw Permalink Normal View History

2024-10-14 06:09:33 +00:00
"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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommonMglyphMixin = void 0;
function CommonMglyphMixin(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, __spreadArray([], __read(args), false)) || this;
_this.getParameters();
return _this;
}
class_1.prototype.getParameters = function () {
var _a = this.node.attributes.getList('width', 'height', 'valign', 'src', 'index'), width = _a.width, height = _a.height, valign = _a.valign, src = _a.src, index = _a.index;
if (src) {
this.width = (width === 'auto' ? 1 : this.length2em(width));
this.height = (height === 'auto' ? 1 : this.length2em(height));
this.valign = this.length2em(valign || '0');
}
else {
var text = String.fromCodePoint(parseInt(index));
var mmlFactory = this.node.factory;
this.charWrapper = this.wrap(mmlFactory.create('text').setText(text));
this.charWrapper.parent = this;
}
};
class_1.prototype.computeBBox = function (bbox, _recompute) {
if (_recompute === void 0) { _recompute = false; }
if (this.charWrapper) {
bbox.updateFrom(this.charWrapper.getBBox());
}
else {
bbox.w = this.width;
bbox.h = this.height + this.valign;
bbox.d = -this.valign;
}
};
return class_1;
}(Base));
}
exports.CommonMglyphMixin = CommonMglyphMixin;
//# sourceMappingURL=mglyph.js.map