mglyph.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. Object.defineProperty(exports, "__esModule", { value: true });
  18. exports.SVGmglyph = void 0;
  19. var Wrapper_js_1 = require("../Wrapper.js");
  20. var mglyph_js_1 = require("../../common/Wrappers/mglyph.js");
  21. var mglyph_js_2 = require("../../../core/MmlTree/MmlNodes/mglyph.js");
  22. var SVGmglyph = (function (_super) {
  23. __extends(SVGmglyph, _super);
  24. function SVGmglyph() {
  25. return _super !== null && _super.apply(this, arguments) || this;
  26. }
  27. SVGmglyph.prototype.toSVG = function (parent) {
  28. var svg = this.standardSVGnode(parent);
  29. if (this.charWrapper) {
  30. this.charWrapper.toSVG(svg);
  31. return;
  32. }
  33. var _a = this.node.attributes.getList('src', 'alt'), src = _a.src, alt = _a.alt;
  34. var h = this.fixed(this.height);
  35. var w = this.fixed(this.width);
  36. var y = this.fixed(this.height + (this.valign || 0));
  37. var properties = {
  38. width: w, height: h,
  39. transform: 'translate(0 ' + y + ') matrix(1 0 0 -1 0 0)',
  40. preserveAspectRatio: 'none',
  41. 'aria-label': alt,
  42. href: src
  43. };
  44. var img = this.svg('image', properties);
  45. this.adaptor.append(svg, img);
  46. };
  47. SVGmglyph.kind = mglyph_js_2.MmlMglyph.prototype.kind;
  48. return SVGmglyph;
  49. }((0, mglyph_js_1.CommonMglyphMixin)(Wrapper_js_1.SVGWrapper)));
  50. exports.SVGmglyph = SVGmglyph;
  51. //# sourceMappingURL=mglyph.js.map