* Set the recipients in the Gmail Webmail editor.
({recipients = [], editElement})
| 98 | * Set the recipients in the Gmail Webmail editor. |
| 99 | */ |
| 100 | setRecipients({recipients = [], editElement}) { |
| 101 | const containerElement = editElement.closest('.I5'); |
| 102 | // find the relevant elements in the Gmail interface |
| 103 | const displayArea = containerElement.querySelector('.aoD.hl'); // email display only area |
| 104 | const tagRemove = containerElement.querySelectorAll('.afV[data-hovercard-id] .afX'); // email tags remove button |
| 105 | const input = containerElement.querySelectorAll('.agP.aFw'); // the actual recipient email address text input (a textarea) |
| 106 | const subject = containerElement.querySelector('.aoT'); // subject field |
| 107 | const editor = containerElement.querySelector('.Am.Al'); // editor |
| 108 | input.forEach(element => element.value = ''); |
| 109 | setFocus(displayArea) |
| 110 | .then(() => { |
| 111 | tagRemove.forEach(tag => tag.click()); |
| 112 | // enter address text into input |
| 113 | const text = joinEmail(recipients); |
| 114 | if (input.length) { |
| 115 | input.item(0).value = text; |
| 116 | } |
| 117 | }) |
| 118 | .then(() => { |
| 119 | setFocus(isVisible(subject) ? subject : editor); |
| 120 | }); |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Extract sender |
no test coverage detected