MCPcopy Create free account
hub / github.com/NsLearning/LangHelper / downloadThread

Function downloadThread

ChatGPT/src-tauri/src/scripts/export.js:161–182  ·  view source on GitHub ↗
({ as = Format.PNG } = {})

Source from the content-addressed store, hash-verified

159 }
160
161 function downloadThread({ as = Format.PNG } = {}) {
162 const elements = new Elements();
163 elements.fixLocation();
164 const pixelRatio = window.devicePixelRatio;
165 const minRatio = as === Format.PDF ? 2 : 2.5;
166 window.devicePixelRatio = Math.max(pixelRatio, minRatio);
167
168 html2canvas(elements.thread, {
169 letterRendering: true,
170 }).then(async function (canvas) {
171 elements.restoreLocation();
172 window.devicePixelRatio = pixelRatio;
173 const imgData = canvas.toDataURL("image/png");
174 requestAnimationFrame(() => {
175 if (as === Format.PDF) {
176 return handlePdf(imgData, canvas, pixelRatio);
177 } else {
178 handleImg(imgData);
179 }
180 });
181 });
182 }
183
184 async function handleImg(imgData) {
185 const binaryData = atob(imgData.split("base64,")[1]);

Callers 1

addActionsButtonsFunction · 0.85

Calls 4

fixLocationMethod · 0.95
restoreLocationMethod · 0.95
handlePdfFunction · 0.85
handleImgFunction · 0.85

Tested by

no test coverage detected