TextNode.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 __values = (this && this.__values) || function(o) {
  18. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  19. if (m) return m.call(o);
  20. if (o && typeof o.length === "number") return {
  21. next: function () {
  22. if (o && i >= o.length) o = void 0;
  23. return { value: o && o[i++], done: !o };
  24. }
  25. };
  26. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  27. };
  28. Object.defineProperty(exports, "__esModule", { value: true });
  29. exports.SVGTextNode = void 0;
  30. var MmlNode_js_1 = require("../../../core/MmlTree/MmlNode.js");
  31. var Wrapper_js_1 = require("../Wrapper.js");
  32. var TextNode_js_1 = require("../../common/Wrappers/TextNode.js");
  33. var SVGTextNode = (function (_super) {
  34. __extends(SVGTextNode, _super);
  35. function SVGTextNode() {
  36. return _super !== null && _super.apply(this, arguments) || this;
  37. }
  38. SVGTextNode.prototype.toSVG = function (parent) {
  39. var e_1, _a;
  40. var text = this.node.getText();
  41. var variant = this.parent.variant;
  42. if (text.length === 0)
  43. return;
  44. if (variant === '-explicitFont') {
  45. this.element = this.adaptor.append(parent, this.jax.unknownText(text, variant));
  46. }
  47. else {
  48. var chars = this.remappedText(text, variant);
  49. if (this.parent.childNodes.length > 1) {
  50. parent = this.element = this.adaptor.append(parent, this.svg('g', { 'data-mml-node': 'text' }));
  51. }
  52. var x = 0;
  53. try {
  54. for (var chars_1 = __values(chars), chars_1_1 = chars_1.next(); !chars_1_1.done; chars_1_1 = chars_1.next()) {
  55. var n = chars_1_1.value;
  56. x += this.placeChar(n, x, 0, parent, variant);
  57. }
  58. }
  59. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  60. finally {
  61. try {
  62. if (chars_1_1 && !chars_1_1.done && (_a = chars_1.return)) _a.call(chars_1);
  63. }
  64. finally { if (e_1) throw e_1.error; }
  65. }
  66. }
  67. };
  68. SVGTextNode.kind = MmlNode_js_1.TextNode.prototype.kind;
  69. SVGTextNode.styles = {
  70. 'mjx-container[jax="SVG"] path[data-c], mjx-container[jax="SVG"] use[data-c]': {
  71. 'stroke-width': 3
  72. }
  73. };
  74. return SVGTextNode;
  75. }((0, TextNode_js_1.CommonTextNodeMixin)(Wrapper_js_1.SVGWrapper)));
  76. exports.SVGTextNode = SVGTextNode;
  77. //# sourceMappingURL=TextNode.js.map