Not what you’re really looking for, but Leo already supports @svg nodes.  Of course, those are just the image in a node, viewable in VR — no text around them in the same node, to my knowledge.

I’ve done kinda-sorta similar things with one of my personal use ‘leo apps’.  In that use case, I had a new pane that was effectively a rendered-to-html view of a running markdown document that would be appended to as various actions happened — including embedding images.  It included a button to swap out the webview widget for a textedit widget that contained the markdown source.  So kind of like a livecoding-styled viewrendered panel.  It was overkill but it had data that needed to live ‘outside’ the outline it was in.

Anyway, there are many approaches to this.  It would be interesting to see, but I’m not sure it’s really something that core Leo needs to support.  A plug-in would be pretty neat though.

Jake



On Mar 28, 2023, at 6:04 PM, Thomas Passin <tbp100...@gmail.com> wrote:


It would be very useful if an image could be embedded into a Leo body.  Probably no one would want to do this in a program or script, but for documentation it could be very helpful.  You can put an image into a ReST, MD, or Asciidoc node and view it with VR3 or by creating Sphinx output.  But even better would be to have an image in an ordinary text page.

In theory it should be possible to put an image into a Leo node.  Qt has a way to do it, and I have written a little test Qt program that can put one into a QTextBrowser or a QTextEdit widget at the cursor location.

The way Qt does it is to insert a special Unicode character:

"Inline images are represented by a Unicode value U+FFFC (OBJECT REPLACEMENT CHARACTER) which has an associated QTextImageFormat."

I *think* that Qt converts an image file to a data: url and stores it in that character.  Aside from the issue of how to implement commands to let a user work with an image (have text reflow around it, delete it, etc), there is the question of how to save and restore the image  data along with the rest of the outline.

One possibility is that saving the file will simply include the data: url's data (which would be encoded as base64, so it should not be a problem to save), and the file load will simply restore it with no extra effort.  This is probably too much to hope for.

If that turns out not to happen, maybe it would not be too hard to save the data as a UA, and restore it from the UA.  The problem, I think, is to get the data into that special character in the right place.  Another possibility would be to write Leo code to restore the image from the original image file.  That sounds harder to me, but I'm not sure.  It would be better not to have to depend on an external image file if possible.

I'm very interested in this, and I hope we can have a good discussion about it!

--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/7723eb4d-8495-4107-8c6a-dd79180479a7n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/B9291211-F702-4905-9405-3AF05C7E8FF3%40gmail.com.

Reply via email to