Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text-based Image Viewer? #8494

Closed
bollwyvl opened this issue May 29, 2020 · 2 comments · Fixed by #8495
Closed

Text-based Image Viewer? #8494

bollwyvl opened this issue May 29, 2020 · 2 comments · Fixed by #8495
Labels
status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.

Comments

@bollwyvl
Copy link
Contributor

bollwyvl commented May 29, 2020

Hello! Current (probably all) versions of JupyterLab's imageviewer-extension treat all the supported image formats as base64. To my understanding, this means that a text contents model held by another Document of one of the two text-based types (svg and xbm) won't be updated as it is being edited.

Steps to reproduce:

  • make a file, test.svg and open it with the Editor
  • put some svg in it
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg id="svg2" xmlns="http://www.w3.org/2000/svg" version="1.1">
    <circle r="10" cx="10" cy="10" fill="red"></circle>
</svg>
  • open the file in Image
  • change the fill to blue in the Editor
  • the circle stays red
  • close the Image
  • open the image, see a blue circle

Goal:
I'd like to be able to live edit svg (but xbm might be nice, too?) with Editor (or another Document widget). No doubt there are other text-based image formats.

Motivation:
Over on QuantStack/jupyterlab-drawio#61 the drawio document can generate svg and png that retain their editability. The pngs reload like a dream, while the svg need to be reloaded (for which there isn't a button).

Approaches:

  • add an extra tracker to the existing extension, which actually yields two plugins
  • listen for same-file, different model and re-request (ick)
  • add an entirely new core extension, textimageviewer
  • change the imageviewer contract to be an (extensible) manager pattern than other images can extend

I'm happy to submit a PR, but seems like kind of a sticky wicket as to the best approach.

Related:

  • jsonviewer has similar behavior
@bollwyvl
Copy link
Contributor Author

bollwyvl commented May 29, 2020

Actually, on closer reading, the factory isn't published... it may be possible to do this without changing the contract...

@bollwyvl
Copy link
Contributor Author

bollwyvl commented May 30, 2020

So seems CI is backed up, but #8495 looks alright..

I realized while trying it out that getting editable SVG to fit into the image box might indeed introduce additional shortcomings... perhaps what is needed (in addition to #8495) is a dedicated svgviewer and svgviewer-extension which can support opening an SVG in a dedicated iframe. This would allow for some of its cooler features, like clickable links, reactive CSS, and animations, to function properly, without stomping all over the DOM.

Given that SVG is pretty important to branding labextensions (core or otherwise), another feature this could provide would be a LabIcon preview... it took me a while to figure out what was happening with all the magic classes. Again, the iframe might be interesting, as you could preview the small multiple view of your icon at the various sizes (e.g. launch card, tab icon) by all of your currently-installed themes.

And finally, just because, even though everybody likes to poo-poo XML, it may be worth having a core XML viewer based on, e.g. https://github.com/storybookjs/react-inspector. That may also be a better JSON experience than the existing one. Though in my dreams i sometimes see a @lumino/datagrid with collapsible hierarchy, schema validation and other things for JSON/XML...

@github-actions github-actions bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 8, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant