Commit graph

79 commits

Author SHA1 Message Date
Matt Bierner 61f799f53b
Add proposed webview view API (#104601)
Add proposed webview view API

For #46585

This adds a new `WebviewView` proposed api to VS Code that lets webview be used inside views. Webview views can be contributed using a contribution point such as :

```json
    "views": {
      "explorer": [
        {
          "type": "webview",
          "id": "cats.cat",
          "name": "Cats",
          "visibility": "visible"
        }
      ]
    },
```

* Use proper activation event

* Transparent background

* Fix resize observer

* Adding documentation

* Move webview view to new directory under workbench

* Remove resolver

By moving the webviews view into their own fodler, I was able to avoid the cycle the resolver was originally introduced for

* Use enum in more places

* Hook up title and visible properties for webview views

* Remove test view

* Prefer Thenable

* Add unknown view type error to collector
2020-08-20 13:59:22 -07:00
Alex Dima 91cdca1bdb
Do not ship unnecessary files with extensions 2020-07-24 13:57:51 +02:00
Alex Dima 2fa41fb23e
Add "web" as extensionKind to extensions which support this 2020-07-24 10:41:03 +02:00
Martin Aeschlimann 16be2c9885 used shared webpack-config for browser 2020-06-25 23:22:02 +02:00
Martin Aeschlimann 917064c80c move polyfills to build/polyfills 2020-06-11 21:54:43 +02:00
Matt Bierner 0145e38e5f Enable the image preview in web/serverless
Fixes #99802
2020-06-10 16:44:10 -07:00
Matt Bierner 263baa79b0 Use extensionUri instead of Uri.file 2020-06-10 16:44:10 -07:00
Matt Bierner eb09996238 Move custom editor provider out of proposed to main api
For #77131
2020-06-01 14:45:05 -07:00
Matt Bierner 7a4880a6bd Add some extra guards around image loading 2020-05-27 19:56:02 -07:00
Christos Pappas 03beeec722
Prevent aggressive image name encoding (#96935)
* Prevent aggressive image name encoding

* Fix typo on function name

Changes getWebiewContents to getWebviewContents in image-preview extension
2020-05-11 15:21:16 -07:00
Matt Bierner 4862602c4c Align custom editor API proposal with notebook API
Fixes #95854
Fixes #95849
For #77131

- Move all editing functionality back onto the provider. This better matches the notebook API.

- Rename `CustomEditorProvider` to `CustomReadonlyEditorProvider`.  `CustomEditorProvider` is now how editable custom editors are implemented

- Give extension a full suggested backup path instead of just a folder
2020-04-24 14:47:08 -07:00
Matt Bierner f35758ab21 Rename supportsMultipleEditorsPerResource -> supportsMultipleEditorsPerDocument
For #77131
2020-04-23 17:33:06 -07:00
Matt Bierner 5913061e1b Allow a custom editor to opt out of supporting multiple instances for a single resource
#77131
2020-04-16 17:40:20 -07:00
Jackson Kearl 9d8bf6d842 Clean up services required 2020-04-09 06:17:48 -07:00
Matt Bierner d4ce7148dd New custom editor API proposal
For #77131

Fixes #93963
Fixes #94515
Fixes #94517
Fixes #94527
Fixes #94509
Fixes #94514
Fixes #93996
Fixes #93913

This removes explicit edits from the API and reshapes the API to more closely match VS Code's internal API. The change also tries to better express the lifecycle of backups
2020-04-08 17:53:39 -07:00
Matt Bierner 2e4d797e51 Add registerCustomEditorProvider2
Create a temporary overload for testing `CustomEditor`. In finalization, we'd update `registerCustomEditorProvider` to take both types of custom editor instead
2020-04-02 15:43:13 -07:00
Matt Bierner d41997790c Remove CustomDocument.viewType
Fixes #93867
For #77131

This property is no longer needed (or very helpful) with the current api design
2020-03-31 12:00:17 -07:00
Matt Bierner 579dab3196 Update custom editor api
For #77131

- Use a class for `CustomDocument` instead of an interface. Extensions can now add their own data to a `CustomDocument` by sublassing

- Renamed `resolveCustomDocument` to `openCustomDocument` and require that extensions return a `CustomDocument`

- Exposed edits on `CustomDocument`

- Made the third parameter of `registerCustomEditorProvider` a generic options bag that takes a `webviewOptions`
2020-03-23 13:10:49 -07:00
Matt Bierner 9dae408dc3 Switch webview api back to use delegate model
For #77131

Going back the the delegate based model for a few reasons:

- It gives us a better approach to add additional API hooks in the future (such as for rename)

- In practive, the capabilities were almost always the same as the `userData` on the document. It is rather confusing to have both `userData` and the capabilities 'on' the document
2020-03-12 16:54:48 -07: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 dc1e7871b8 Rename custom editor contribution point
Renaming to match new API proposal
2020-02-25 10:55:41 -08:00
Matt Bierner 8291f8c152 Polishing of custom editor api proposal for 1.43 release
For #77131
2020-02-25 10:55:41 -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
Joao Moreno a398adac13
revert git uri changes
fixes #88775
2020-01-22 15:29:13 +01:00
João Moreno 99d2801fa5
Merge branch 'master' into fix-gitfs-stat 2020-01-13 15:31:00 +01:00
Matt Bierner a0328d26ac Add 'vscode.reopenWith' API command
Fixes #88426

Add an api command that allows extensions to open/reopen a file with a specific we custom editor. Use this to allow re-opening a failed to load image as text/binary

For #77131
2020-01-10 14:25:21 -08:00
Matt Bierner 8e475f9b24
Implement draft 2 from #86802 (#87117) 2019-12-16 14:18:58 -08:00
Matt Bierner fb2eca62c2 Show empty image instead of error in git diff view for newly staged images
Fixes #86389
Fixes #86776

Uses `fs.stat` to check if we are showing an untracked image in the git diff view.

Also required fixing `stat` for `gitfs` so that it can try to return the proper sizes for objects
2019-12-11 15:41:01 -08:00
Matt Bierner 5a84679fd7 Remove tga from documented supported image format list
For #84533
2019-12-04 15:37:49 -08:00
Matt Bierner b0fb9f17da Note image preview's extension kind
For #85819
2019-12-02 15:43:37 -08:00
Matt Bierner 028e009ea2 Better name 2019-11-22 15:18:01 -08:00
Matt Bierner 71c3136106 Extract out common status bar entry management code 2019-11-22 15:18:01 -08:00
Matt Bierner aaa01eac73 Make previewManager implement WebviewEditorProvider directly 2019-11-22 15:18:01 -08:00
Matt Bierner f085deb2e0 Remove test editing code from preview 2019-11-22 15:18:01 -08:00
Jean Pierre 56a544b36c Don't encode image resource URI twice (#85355) 2019-11-22 14:33:33 -08:00
Matt Bierner d9c4923f98 Fix trailiing comma 2019-11-20 21:36:05 -08:00
Matt Bierner 8fa16bd74f Remove custom editor support for data uris
For #85203. Data uris are no longer used by VS Code core
2019-11-20 21:35:29 -08:00
Matt Bierner 8caf39ef37 Fix loading of images with spaces in the name
Partially revert #84667

Also seems to fix #85190
2019-11-20 11:43:09 -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
OneQuid ba19fe0e9b Fix opening image with '%' in the filename (#84667) 2019-11-15 18:14:30 -08:00
Matt Bierner 2dc8bac0a3 Use undefined instead of -1 to indicate that there is no size yet 2019-11-15 15:06:24 -08:00
Matt Bierner d628c3b82e Make sure we call update after the binary size of the image is computed
Fixes a possible race if the dimensions of the image are computed before the get the size (which is unlikely but possible)
2019-11-15 15:05:01 -08:00
Shizeng Zhou 14e6ad3138 Fix #84111 (#84610)
* Fix #84111

* Replace fs with vscode's fs

* Put binary size in the binarySizeStatusBar
2019-11-15 15:02:09 -08:00
Matt Bierner 60f8583d95 Adding setting to enable a test command for making a fake "edit" to an image preview
This will be use for testing custom editors
2019-11-12 16:08:04 -08:00
Matt Bierner cfbf6b58f6 Better fix for disabling pinch to zoom in a webview zooming the entire editor in chrome
Fixes #84406
2019-11-12 15:41:41 -08:00
Matt Bierner f50c8264fa Don't try rendering TGAs in the built-in image preview
Fixes #84533

Looks like tga is not currently supported by Chrome
2019-11-12 14:36:22 -08:00
Eric Amodio 8e94fc342b Fixes uri issue with remote uris w/ querystrings 2019-11-11 14:41:42 -05: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
MartinBrathen c53db9ba76 Fix zoom on first click (#83826)
* no zoom on fast click

* fixed a visual bug where the zoom-in icon would show briefly before zoom-out on first click when ctrl/alt is pressed
2019-11-05 15:00:34 -08:00