semantics.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.SVGxml = exports.SVGannotationXML = exports.SVGannotation = exports.SVGsemantics = void 0;
  19. var Wrapper_js_1 = require("../Wrapper.js");
  20. var semantics_js_1 = require("../../common/Wrappers/semantics.js");
  21. var semantics_js_2 = require("../../../core/MmlTree/MmlNodes/semantics.js");
  22. var MmlNode_js_1 = require("../../../core/MmlTree/MmlNode.js");
  23. var SVGsemantics = (function (_super) {
  24. __extends(SVGsemantics, _super);
  25. function SVGsemantics() {
  26. return _super !== null && _super.apply(this, arguments) || this;
  27. }
  28. SVGsemantics.prototype.toSVG = function (parent) {
  29. var svg = this.standardSVGnode(parent);
  30. if (this.childNodes.length) {
  31. this.childNodes[0].toSVG(svg);
  32. }
  33. };
  34. SVGsemantics.kind = semantics_js_2.MmlSemantics.prototype.kind;
  35. return SVGsemantics;
  36. }((0, semantics_js_1.CommonSemanticsMixin)(Wrapper_js_1.SVGWrapper)));
  37. exports.SVGsemantics = SVGsemantics;
  38. var SVGannotation = (function (_super) {
  39. __extends(SVGannotation, _super);
  40. function SVGannotation() {
  41. return _super !== null && _super.apply(this, arguments) || this;
  42. }
  43. SVGannotation.prototype.toSVG = function (parent) {
  44. _super.prototype.toSVG.call(this, parent);
  45. };
  46. SVGannotation.prototype.computeBBox = function () {
  47. return this.bbox;
  48. };
  49. SVGannotation.kind = semantics_js_2.MmlAnnotation.prototype.kind;
  50. return SVGannotation;
  51. }(Wrapper_js_1.SVGWrapper));
  52. exports.SVGannotation = SVGannotation;
  53. var SVGannotationXML = (function (_super) {
  54. __extends(SVGannotationXML, _super);
  55. function SVGannotationXML() {
  56. return _super !== null && _super.apply(this, arguments) || this;
  57. }
  58. SVGannotationXML.kind = semantics_js_2.MmlAnnotationXML.prototype.kind;
  59. SVGannotationXML.styles = {
  60. 'foreignObject[data-mjx-xml]': {
  61. 'font-family': 'initial',
  62. 'line-height': 'normal',
  63. overflow: 'visible'
  64. }
  65. };
  66. return SVGannotationXML;
  67. }(Wrapper_js_1.SVGWrapper));
  68. exports.SVGannotationXML = SVGannotationXML;
  69. var SVGxml = (function (_super) {
  70. __extends(SVGxml, _super);
  71. function SVGxml() {
  72. return _super !== null && _super.apply(this, arguments) || this;
  73. }
  74. SVGxml.prototype.toSVG = function (parent) {
  75. var xml = this.adaptor.clone(this.node.getXML());
  76. var em = this.jax.math.metrics.em * this.jax.math.metrics.scale;
  77. var scale = this.fixed(1 / em);
  78. var _a = this.getBBox(), w = _a.w, h = _a.h, d = _a.d;
  79. this.element = this.adaptor.append(parent, this.svg('foreignObject', {
  80. 'data-mjx-xml': true,
  81. y: this.jax.fixed(-h * em) + 'px',
  82. width: this.jax.fixed(w * em) + 'px',
  83. height: this.jax.fixed((h + d) * em) + 'px',
  84. transform: "scale(".concat(scale, ") matrix(1 0 0 -1 0 0)")
  85. }, [xml]));
  86. };
  87. SVGxml.prototype.computeBBox = function (bbox, _recompute) {
  88. if (_recompute === void 0) { _recompute = false; }
  89. var _a = this.jax.measureXMLnode(this.node.getXML()), w = _a.w, h = _a.h, d = _a.d;
  90. bbox.w = w;
  91. bbox.h = h;
  92. bbox.d = d;
  93. };
  94. SVGxml.prototype.getStyles = function () { };
  95. SVGxml.prototype.getScale = function () { };
  96. SVGxml.prototype.getVariant = function () { };
  97. SVGxml.kind = MmlNode_js_1.XMLNode.prototype.kind;
  98. SVGxml.autoStyle = false;
  99. return SVGxml;
  100. }(Wrapper_js_1.SVGWrapper));
  101. exports.SVGxml = SVGxml;
  102. //# sourceMappingURL=semantics.js.map