* Set the recipients in the Yahoo Webmail editor.
({recipients = []})
| 152 | * Set the recipients in the Yahoo Webmail editor. |
| 153 | */ |
| 154 | setRecipients({recipients = []}) { |
| 155 | const input = document.querySelector('.compose-header [data-test-id="container-to"] ul.pill-list > li.pill-container input.input-to'); |
| 156 | const inputValue = joinEmail(recipients); |
| 157 | setReactValue(input, inputValue); |
| 158 | // trigger change event by switching focus |
| 159 | setFocus(input) |
| 160 | .then(() => { |
| 161 | const subject = document.querySelector('[data-test-id="compose-subject"]'); |
| 162 | // set focus to subject field, or to compose area in the reply case |
| 163 | setFocus(isVisible(subject) ? subject : document.querySelector('[id="editor-container"] > [data-test-id="rte"]')); |
| 164 | }); |
| 165 | |
| 166 | // remove existing recipients afterwards |
| 167 | setTimeout(() => { |
| 168 | document.querySelectorAll('.compose-header [data-test-id="container-to"] ul.pill-list > li:not(.pill-container)').forEach(element => { |
| 169 | const dataElement = element.querySelector('[data-test-id="pill"]'); |
| 170 | const parsed = parseAddressSafe(dataElement.getAttribute('title')); |
| 171 | if (parsed && !recipients.find(({email}) => email === parsed.email)) { |
| 172 | element.click(); |
| 173 | element.querySelector('.pill-close button').click(); |
| 174 | } |
| 175 | }); |
| 176 | }, 250); |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Extract sender |
nothing calls this directly
no test coverage detected