(doc: Document, config?: Config)
| 186 | } |
| 187 | |
| 188 | function enterNodeSelectionMode(doc: Document, config?: Config) { |
| 189 | setTimeout(() => { |
| 190 | registerClickListeners(doc); |
| 191 | registerHoverListeners(doc); |
| 192 | }, 0); |
| 193 | |
| 194 | injectStyles(); |
| 195 | |
| 196 | return new Promise((resolve, reject) => { |
| 197 | injectNodeSelectionControls( |
| 198 | async () => { |
| 199 | cleanup(); |
| 200 | |
| 201 | const selectedNodes = document.querySelectorAll( |
| 202 | `.${CLASSES.nodeSelected}` |
| 203 | ); |
| 204 | |
| 205 | const { head } = await getPage(document, config, false); |
| 206 | const html = document.createElement("html"); |
| 207 | html.append(head!); |
| 208 | const body = document.createElement("body"); |
| 209 | html.append(body); |
| 210 | for (const node of selectedNodes) { |
| 211 | node.classList.remove(CLASSES.nodeSelected); |
| 212 | const inlined = await getInlinedNode(node as HTMLElement, { |
| 213 | raster: false, |
| 214 | fetchOptions: resolveFetchOptions(config), |
| 215 | inlineOptions: { |
| 216 | ...inlineOptions, |
| 217 | images: config?.images, |
| 218 | inlineImages: config?.inlineImages |
| 219 | } |
| 220 | }); |
| 221 | if (!inlined) continue; |
| 222 | body.appendChild(inlined); |
| 223 | } |
| 224 | resolve(html?.outerHTML); |
| 225 | }, |
| 226 | () => reject("Cancelled.") |
| 227 | ); |
| 228 | }); |
| 229 | } |
| 230 | |
| 231 | export { |
| 232 | clipPage, |
no test coverage detected