site/node_modules/speech-rule-engine/js/highlighter/mml_highlighter.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-10-14 06:09:33 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MmlHighlighter = void 0;
const abstract_highlighter_1 = require("./abstract_highlighter");
class MmlHighlighter extends abstract_highlighter_1.AbstractHighlighter {
constructor() {
super();
this.mactionName = 'maction';
}
highlightNode(node) {
let style = node.getAttribute('style');
style += ';background-color: ' + this.colorString().background;
style += ';color: ' + this.colorString().foreground;
node.setAttribute('style', style);
return { node: node };
}
unhighlightNode(info) {
let style = info.node.getAttribute('style');
style = style.replace(';background-color: ' + this.colorString().background, '');
style = style.replace(';color: ' + this.colorString().foreground, '');
info.node.setAttribute('style', style);
}
colorString() {
return this.color.rgba();
}
getMactionNodes(node) {
return Array.from(node.getElementsByTagName(this.mactionName));
}
isMactionNode(node) {
return node.tagName === this.mactionName;
}
}
exports.MmlHighlighter = MmlHighlighter;