-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Option to enable localStorage in WebView panels #52246
Comments
(Experimental duplicate detection) |
It's disabled because we serve webview using data uris: https://stackoverflow.com/questions/37379254/how-to-save-data-to-the-browser-with-data-url/37541068 |
Do we have plan to enable this? I meet with the same issue on https://marketplace.visualstudio.com/items?itemName=formulahendry.vscode-node-red extension. Currently, we are using |
@formulahendry You should not need local storage. See the new persistence APIs instead |
Hi @mjbvz , in my extension, I embed https://www.npmjs.com/package/node-red (which is just a localhost website) into the webview. I have no control of node-red npm package to not to use local storage.. Any suggestion would be appreciated. Thanks! |
It a WebView, not a WebBrowser ;-) I don't think we can isolate local storage of web views with the local storage VS Code is using That would be cross pollution that's generally undesirable for us. |
If we have no plan to support that in WebView, do we have plan to make |
No. You should use a webview. The old html preview is deprecated and will not receive new features |
OK, so seems like I need to wait for localStorage to be enabled in WebView. |
This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider. If you wonder what we are up to, please see our roadmap and issue reporting guidelines. Thanks for your understanding and happy coding! |
I am currently using the
vscode.previewHtml
command to display a web app in VS Code (via iframe) which useslocalStorage
to store persisting state, and I am currently trying to convert it to use the new Webview API, in order to take advantage of the newretainContextWhenHidden
option. I noticed however that while accessinglocalStorage
works fine when usingvscode.previewHtml
, it is disabled in panels that use the Webview API.I saw that a persistence API is currently being worked on (#49022), but in order to even use that, I would have to wrap all my
localStorage
gets/sets in async functions that check to see iflocalStorage
is accessible, and if it isn't, use message passing between the iframe and the webview in order to usegetState
/setState
inside the webview.That would be doable but it's definitely not ideal.
This comment seems to imply that it is disabled intentionally but is something that can potentially be enabled.
The text was updated successfully, but these errors were encountered: