SayYou.ts 615 B

123456789101112131415161718
  1. class SayYou extends Say {
  2. private node : Text = document.createTextNode("a ");
  3. private uppercase = true;
  4. public constructor (autoUppercase = true) {
  5. super();
  6. this.uppercase = autoUppercase;
  7. }
  8. public async getPureElements (say : Say) : Promise<Array<Element | Text>> {
  9. this.node.nodeValue = "you";
  10. if (this.uppercase && say.currentParagraph.length == 0) {
  11. this.node.nodeValue = this.node.nodeValue.charAt(0).toUpperCase()
  12. + this.node.nodeValue.substr(1, this.node.nodeValue.length - 1);
  13. }
  14. return [this.node];
  15. }
  16. }