Improve viewer handling of data URLs and add a corresponding test case - #1096
Open
david-hall wants to merge 3 commits into
Open
Improve viewer handling of data URLs and add a corresponding test case#1096david-hall wants to merge 3 commits into
david-hall wants to merge 3 commits into
Conversation
Viewer already handles data URLs, but this improves the behavior in a few ways: 1) Preemptively trims leading whitespace from incoming and outgoing text to ensure that downloaded vZome files can be opened in desktop. 2) Avoids trying to find a .shapes.json preview file when opening a data URL since the preview file can't exist. 3) Displays a truncated version of the data URL in the console rather than the full data URL which is typically several KB. 4) Test case shows two different ways to encode data URLs and also pass the vZome file name to the viewer as part of the data URL for use when downloading the design from the viewer. TODO: The option to open in vZome online should be disabled when the viewer's src is a data URL, but I couldn't figure out how to do that.
Restored original console.log output for non-data URLs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Viewer already handles data URLs, but this improves the behavior in a few ways:
Preemptively trims leading whitespace from incoming and outgoing text to ensure that downloaded vZome files can be opened in desktop.
Avoids trying to find a .shapes.json preview file when opening a data URL since the preview file can't exist.
Displays a truncated version of the data URL in the console rather than the full data URL which is typically several KB.
Test case shows two different ways to encode data URLs and also pass the vZome file name to the viewer as part of the data URL for use when downloading the design from the viewer.
TODO: The option to open in vZome online should be disabled when the viewer's src is a data URL, but I couldn't figure out how to do that.