Commit Graph

85 Commits

Author SHA1 Message Date
Matt Bierner
0fa3af8b60 Use es6 version of methods 2020-03-02 16:20:36 -08:00
Matt Bierner
dc68e6578e rename custom editor activation event
For #77131

Renames the activation event from `onWebviewEditor` to `onCustomEditor` to be consistent with the reset of the API
2020-02-26 10:59:36 -08:00
Matt Bierner
99d5733e5f New iteration of webview editor API proposal
For #77131

**Motivation**
While our existing webview editor API proposal more or less works, building an editable webview editor is fairly tricky using it! This is especially true for simple text based editors.

It'd also be nice if we could get bi-directional live editing for text files. For example, if I open the same file in a webview editor and in VS Code's normal editor, edits on either side should be reflected in the other. While this can sort of be implemented using the existing API, it has some big limitations

**Overview of changes**
To address these problems, we've decided have two types of webview editors:

- Text based webview editors. These editors used a `TextDocument` as their data model, which considerably simplifies implementing an editable webview. In almost all cases, this should be what you use for text files

- Complex webview editors. This is basically the existing proposed API. This gives extension hooks into all the VS Code events, such as `save`, `undo`, and so on. These should be used for binary files or in very complex text editor cases.

Both editor types now have an explicit model layer based on documents. Text editor use `TextDocument` for this, while custom editors use `WebviewEditorCustomDocument`. This replaces the delegate based approach previously used.
2020-02-21 16:26:01 -08:00
Benjamin Pasero
bde31da263 editors - getResource => resource 2020-02-18 15:53:34 +01:00
Matt Bierner
f3dbcea32a Adds a backup method (#88948)
Adds a backup method to the custom editor API proposal. This method allows custom editors to hook in to VS Code's hot exit behavior

If `backup` is not implemented, VS Code will assume that the custom editor cannot be hot exited.

When `backup` is implemented, VS Code will invoke the method after every edit (this is debounced). At this point, this extension should back up the current resource.  The result is a promise indicating if the backup was successful or not

VS Code will only hot exit if all backups were successful.
2020-01-23 16:14:27 -08:00
Matt Bierner
ff9fd2fa1a Custom Editors: pass original edit objects back to extensions
For #88719

With this change, instead of passing custom editor edit json back and forth with the extension host, we keep the original edit objects on the extension host. This means that we can pass extensions back the exact same edit object they first hand to us. It also means that edits no longer need to be json serializable.
2020-01-19 20:14:25 -08:00
Matt Bierner
5335a721fa Add backup capability for custom editors 2020-01-19 20:14:25 -08:00
Benjamin Pasero
664836ec0e debt - loadOrCreate => resolve 2020-01-16 15:39:09 +01:00
Matt Bierner
8520f74c08 Implement a default saveAs for readonly custom editors
Fixes #88414
2020-01-10 18:19:41 -08:00
Matt Bierner
b435511d7b Fixing undo/redo for new custom editor proposal 2019-12-17 15:02:36 -08:00
Matt Bierner
8e475f9b24 Implement draft 2 from #86802 (#87117) 2019-12-16 14:18:58 -08:00
Matt Bierner
d43ca55162 Move more functionality into registerCapabilities 2019-12-02 13:35:36 -08:00
Matt Bierner
e3fb9ceca1 Use single editable capability 2019-12-02 13:35:36 -08:00
Matt Bierner
e33be1b0af Explicitly register for save and saveAs 2019-12-02 13:35:35 -08:00
Johannes Rieken
a71694386d keep links from web view untouch for as long as possible, #83645 2019-11-29 15:51:44 +01:00
Matt Bierner
a8158aee89 Make sure we dispose of webviews in correct order
Fixes #85621

We must fire the the dispose event before  disposing of the event
2019-11-26 11:49:02 -08:00
Matt Bierner
5ec2e40b21 Fixing webview getting disposed after rename
For #83961
2019-11-25 22:38:02 -08:00
Matt Bierner
750f28769d Sync custom editor edits
If multiple instances of the same  custom editor are opened for the same resource, the edit stack should be shared between them. This matches how we work with text files
2019-11-25 15:44:25 -08:00
Matt Bierner
f3d70dbf92 Working on sharing models for same custom editor 2019-11-25 15:44:25 -08:00
Matt Bierner
b52f1c7dae Trying to hook up background to implement custom editor rename 2019-11-25 15:44:25 -08:00
Matt Bierner
ffe3749d5a Working on hooking up custom editor saveAs 2019-11-25 15:44:25 -08:00
Matt Bierner
9b89cca38e Working on hooking up revert properly for custom editors 2019-11-22 15:18:01 -08:00
Matt Bierner
8bbe3157f0 Trying to hook up basic save for custom editors 2019-11-18 11:27:45 -08:00
Matt Bierner
27a33ee6fe Hook up very basic undo/redo for webview editors
For #77131
2019-11-15 18:21:46 -08:00
Matt Bierner
7ac686d6cc Working on hooking up undo/redo for custom editors 2019-11-15 15:53:25 -08:00
Matt Bierner
7e71822af3 Hook up CustomEditorModel to workingCopyService 2019-11-12 15:54:32 -08:00
Matt Bierner
278b4f8cfa Hookup experimental undo for customEditors
This currently is not connected to any actual actions in the editor
2019-11-07 17:22:21 -08:00
Matt Bierner
bca7206f59 Forward onEdit from webviewEditor to mainthread 2019-11-07 15:57:47 -08:00
Matt Bierner
dcecb9eea6 Documenting thoughts on direction for custom editor API
This documents the current thinking on the custom editor api. The current api proposal is not actually implemented yet
2019-11-04 15:11:54 -08:00
Benjamin Pasero
d3972c622f opener - adopt fromUserGesture in more places 2019-10-18 16:16:33 +02:00
Matt Bierner
d6ab43118d Create WebviewExtensionDescription in extHostProtocol 2019-10-17 10:50:34 -07:00
Matt Bierner
721886ce10 Allow registerWebviewEditorProvider to pass in a set of initial webview options
Fixes #82128
2019-10-17 10:50:34 -07:00
Matt Bierner
d4cebcd450 Move filling in of default localResourceRoots into extHost
The main VS Code process should not need to know about the default values for `localResourceRoots`. Leave this up to the extension instead
2019-10-15 11:31:25 -07:00
Matt Bierner
dc9ca65375 Use instanceof checks 2019-10-15 11:31:25 -07:00
Matt Bierner
e08b22ba73 Extract reviveWebviewExtension 2019-10-15 11:31:25 -07:00
Matt Bierner
c142b04817 Prefer using the name webviewInput for variables that manage WebviewInput objects 2019-10-15 11:31:24 -07:00
Matt Bierner
019bce14ec Remove extra handler for onDidUpdateState
The current implementation is a noop since we've already updated the state when it is invoked
2019-10-15 11:31:24 -07:00
Matt Bierner
431f446b5b Use Schemas 2019-10-15 11:31:24 -07:00
Matt Bierner
1c2e5df289 Convert static class to constant 2019-10-15 11:31:24 -07:00
Matt Bierner
01dcd28add Extract InternalWebviewViewType 2019-10-15 11:31:24 -07:00
Matt Bierner
48195455a1 Remove the setExtension helper
Instead pass over the extension when resolving the extension itself
2019-10-15 11:31:24 -07:00
Matt Bierner
9c3d060aff Rename webviewEditorService to webviewWorkbenchService
This matchs the naming of a few other services we have
2019-10-10 14:16:26 -07:00
Matt Bierner
d3eb24828e Use strict compare for checking if an editor is active/visible
Fixes #81889

Using `.matches` can cause a custom editor to match all custom editors for that resource. Use a strict compare instead.
2019-10-03 13:53:30 -07:00
Matt Bierner
af070ee0a0 Move custom editor extension activation out of input
Inputs should not need to know about extensions
2019-10-01 15:05:22 -07:00
Matt Bierner
e0762af258 Move webview content state into webviewPanel instead of webviewEditor
Split out from #77131

The current webview editor api is very procedural. This model has some problems when it comes to supporting editing resources, but actually does make a lot of sense for webviews that aren't backed by real file system resources. For example, if you have a webview that edits some document in the cloud, you should not be required to implement a custom file system provider just to enable basic saving.

This change moves the `onWillSave` and `webviewEditorState` properties back onto `WebviewPanel` instead of keeping them specific to `WebviewEditor`. The save implementation does not fully work yet, as the will require #81521
2019-09-26 18:05:37 -07:00
Matt Bierner
0506f7f736 Make sure image views (and custom editors) work properly on the web
This fixes an issue where webviews for custom editors did not have any associated extension information, which caused them try reading `file:` uri resources instead of remote uri resources
2019-09-25 16:25:39 -07:00
Matt Bierner
fd9528257e Make sure we use consistent unique ids for custom editors 2019-09-25 16:25:39 -07:00
Matt Bierner
79dbd4d7c0 Replace todo 2019-09-23 10:58:21 -07:00
Matt Bierner
e62f2e3e2e Only require a reviver being registered to revive a webview
Fixes #80184

Don't rely on a state being set as well
2019-09-23 10:58:21 -07:00
Matt Bierner
ad1cb1f661 Make sure exthost has same id for webview as main thread 2019-09-19 10:31:37 -07:00