TextNode.js 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.CHTMLTextNode = 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 CHTMLTextNode = (function (_super) {
  34. __extends(CHTMLTextNode, _super);
  35. function CHTMLTextNode() {
  36. return _super !== null && _super.apply(this, arguments) || this;
  37. }
  38. CHTMLTextNode.prototype.toCHTML = function (parent) {
  39. var e_1, _a;
  40. this.markUsed();
  41. var adaptor = this.adaptor;
  42. var variant = this.parent.variant;
  43. var text = this.node.getText();
  44. if (text.length === 0)
  45. return;
  46. if (variant === '-explicitFont') {
  47. adaptor.append(parent, this.jax.unknownText(text, variant, this.getBBox().w));
  48. }
  49. else {
  50. var chars = this.remappedText(text, variant);
  51. try {
  52. for (var chars_1 = __values(chars), chars_1_1 = chars_1.next(); !chars_1_1.done; chars_1_1 = chars_1.next()) {
  53. var n = chars_1_1.value;
  54. var data = this.getVariantChar(variant, n)[3];
  55. var font = (data.f ? ' TEX-' + data.f : '');
  56. var node = (data.unknown ?
  57. this.jax.unknownText(String.fromCodePoint(n), variant) :
  58. this.html('mjx-c', { class: this.char(n) + font }));
  59. adaptor.append(parent, node);
  60. !data.unknown && this.font.charUsage.add([variant, n]);
  61. }
  62. }
  63. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  64. finally {
  65. try {
  66. if (chars_1_1 && !chars_1_1.done && (_a = chars_1.return)) _a.call(chars_1);
  67. }
  68. finally { if (e_1) throw e_1.error; }
  69. }
  70. }
  71. };
  72. CHTMLTextNode.kind = MmlNode_js_1.TextNode.prototype.kind;
  73. CHTMLTextNode.autoStyle = false;
  74. CHTMLTextNode.styles = {
  75. 'mjx-c': {
  76. display: 'inline-block'
  77. },
  78. 'mjx-utext': {
  79. display: 'inline-block',
  80. padding: '.75em 0 .2em 0'
  81. }
  82. };
  83. return CHTMLTextNode;
  84. }((0, TextNode_js_1.CommonTextNodeMixin)(Wrapper_js_1.CHTMLWrapper)));
  85. exports.CHTMLTextNode = CHTMLTextNode;
  86. //# sourceMappingURL=TextNode.js.map