-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat(sdk): add vm methods for controlling the editor ui #1810
Merged
Conversation
This file contains 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
AleksandrSl
approved these changes
Mar 30, 2022
I agree with you - I'm much more in favor of |
sylwiavargas
approved these changes
Mar 30, 2022
ggdaltoso
pushed a commit
that referenced
this pull request
May 9, 2022
* Add vm methods for controlling the editor ui * Do not remove comments in types, add descriptions to public types and functions * Fix genID helper to have fixed width strings and lower collisions risk * Update sdk version to 1.7.0-alpha.0
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.
@stackblitz/[email protected]
and things might change.Adds a number of methods to the SDK's
VM
interface, enabling some control of embedded projects at runtime.All the VM methods return promises that may resolve to
null
or to a specific payload, or reject with an error message.UI controls
vm.editor.openFile
: extend to accept multiple file pathsvm.editor.setTheme
: change the color scheme of the embed (light or dark)vm.editor.setView
: change the primary UI view mode (default, editor or preview)vm.editor.showSidebar
: show or hide the sidebarPreview controls
vm.preview.origin
: changed type to indicate that it will benull
for WebContainers-based projects. I'm also considering marking it as@deprecated
, because it's only usable in EngineBlock projects, but we might have users of the SDK who actively rely on it and I’m not sure we want to spook them. Depends on if we want to remove it inv2.0
?vm.preview.getUrl
: allows retrieving the current preview URL. For EngineBlock projects, this is imprecise because it doesn't include the current path if modified by the user or the preview page. For WebContainer projects, it should be more precise (you get the correct path) but will reject when there is no previewed URL.vm.preview.setUrl
: allows setting a newpath
for the current URL. The URL origin cannot be modified, so this cannot be used to show arbitrary web pages in the preview area. Some questions:setPath
instead, if it only accepts a path? I like having matchinggetUrl
andsetUrl
, but thesetUrl(path: string)
signature might be confusing.path
and aport
, which could be used to switch between two web servers.Because the preview methods have different behavior in EngineBlock and WebContainers-based projects, and because we are not sure how stable they would be in practice and in the future (our implementation of setting, modifying or even getting the actual iframe location at runtime can easily bump into browser restrictions), I am marking them as
@experimental
. They would be marked experimental at least in1.7.x
, and probably until2.0
.