MCPcopy
hub / github.com/streetwriters/notesnook / enterNodeSelectionMode

Function enterNodeSelectionMode

packages/clipper/src/index.ts:188–229  ·  view source on GitHub ↗
(doc: Document, config?: Config)

Source from the content-addressed store, hash-verified

186}
187
188function 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
231export {
232 clipPage,

Callers 1

clipFunction · 0.90

Calls 13

registerClickListenersFunction · 0.85
registerHoverListenersFunction · 0.85
injectStylesFunction · 0.85
getPageFunction · 0.85
getInlinedNodeFunction · 0.85
resolveFetchOptionsFunction · 0.85
cleanupFunction · 0.70
removeMethod · 0.65
querySelectorAllMethod · 0.45
createElementMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected