Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions ui/src/components/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -531,18 +531,35 @@ const CodeNode = memo<Props>(function ({
}
}, [data.parent, setPodParent, id]);

const getPicture = async (pod) => {
const requesOptions = {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ code: pod.content }),
mode: "no-cors" as RequestMode,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CORS seems problematic. Let's add an Nginx route.

# nginx.conf
location /carbon {
        rewrite ^/carbon(.*)$ $1 break;
        proxy_pass http://carbon:3000;
}

and in compose.yml, add a container:

carbon:
    image: local/carbonara

The request URL will be http://localhost/carbon/api/cook

accept: "image/png",
};
const res = await fetch("http://localhost:3099/api/cook", requesOptions);
const pic = await res.blob();
// navigator.clipboard.write([new ClipboardItem({ "image/png": pic })]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this navigator.clipboard.write works. I can paste the image to Google Slides:

Screenshot 2022-12-26 at 6 19 08 PM

};

const onCopy = useCallback(
(clipboardData: any) => {
async (clipboardData: any) => {
const pod = getPod(id);
if (!pod) return;
clipboardData.setData("text/plain", pod.content);
clipboardData.setData(
"application/json",
JSON.stringify({
type: "pod",
data: pod,
})
);

clipboardData.setData("text/plain", "");
// clipboardData.clearData();
// clipboardData.setData(
// "application/json",
// JSON.stringify({
// type: "pod",
// data: pod,
// })
// );
getPicture(pod);
console.log("copied", clipboardData);
},
[getPod, id]
);
Expand Down