mml_highlighter.js 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.MmlHighlighter = void 0;
  4. const abstract_highlighter_js_1 = require("./abstract_highlighter.js");
  5. class MmlHighlighter extends abstract_highlighter_js_1.AbstractHighlighter {
  6. constructor() {
  7. super();
  8. this.mactionName = 'maction';
  9. }
  10. highlightNode(node) {
  11. let style = node.getAttribute('style');
  12. style += ';background-color: ' + this.colorString().background;
  13. style += ';color: ' + this.colorString().foreground;
  14. node.setAttribute('style', style);
  15. return { node: node };
  16. }
  17. unhighlightNode(info) {
  18. let style = info.node.getAttribute('style');
  19. style = style.replace(';background-color: ' + this.colorString().background, '');
  20. style = style.replace(';color: ' + this.colorString().foreground, '');
  21. info.node.setAttribute('style', style);
  22. }
  23. colorString() {
  24. return this.color.rgba();
  25. }
  26. getMactionNodes(node) {
  27. return Array.from(node.getElementsByTagName(this.mactionName));
  28. }
  29. isMactionNode(node) {
  30. return node.tagName === this.mactionName;
  31. }
  32. }
  33. exports.MmlHighlighter = MmlHighlighter;