marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
8k stars 285 forks source link

Copy / paste image as base64 data in Markdown #2932

Closed s-celles closed 3 days ago

s-celles commented 4 days ago

Description

Hello,

I was hoping to be able to copy/paste image in markdown cell simply (CTRL + C / CTRL + V). Unfortunately this is not the case.

Kind regards

Suggested solution

Encoding as base64 image could be a solution (I'm doing it through https://www.base64-image.de/ ) but that's not convenient at all.

Notebook could also have a kind of concept of resources which could be used in Markdown cells (at least).

Alternative

No response

Additional context

No response

mscolnick commented 3 days ago

great suggestion! i've added this here: https://github.com/marimo-team/marimo/pull/2934

s-celles commented 3 days ago

I haven't look at your PR but the main problem to consider is that we should avoid having cell be full of base64 code so I think resource should be stored inside notebook but in a different area than cell (what I called "resource"). And cell where we want image be displayed only contains a reference to that "resource". Resource could be image / sound / movie? I know this could be a problem for git if people want embedding too much things in a notebook.

mscolnick commented 3 days ago

Yea it would copy the base64. We could create a file and place it under resources/<resources> and instead make it a path to that file, but then all the files/data is not fully encapsulated in the notebook itself. We could also prompt the user if they would like to copy the file or embed it as base64.

s-celles commented 3 days ago

I would keep resource inside the notebook file (by default) to easily move notebook without the hassle of also thinking of external resources.

A UI like a "resource explorer" could be designed in Marimo notebook where user could give a name to the resource (to ease usage of a resource inside notebook)

mscolnick commented 3 days ago

I think the first step can first just inline these files (e.g. images). maybe that is another issue/discussion, since i can see a bigger debate on whether marimo should have a concept of "resources" attached to the notebook, or just use files (which is my preference)

s-celles commented 3 days ago

Thanks @mscolnick