@codingame/monaco-vscode-api 1.67.14 → 1.67.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,6 +28,8 @@ Services.install({
28
28
  })
29
29
  ```
30
30
 
31
+ ## Monaco standalone services
32
+
31
33
  Also, monaco-editor use `standalone` versions or the vscode services, which are much simpler.
32
34
 
33
35
  You may want to provide your custom implementations of them, especially for: `textModelService`, `codeEditorService` and `notificationService`. To do so, you can provide them as the third parameter while creating your first editor.
@@ -46,27 +48,58 @@ StandaloneService.initialize({
46
48
  })
47
49
  ```
48
50
 
49
- Additionally, this library exposes 2 modules that include the vscode version of some services (with some glue to make it work with monaco):
51
+ Additionally, this library exposes 3 modules that include the vscode version of some services (with some glue to make it work with monaco):
50
52
  - Notification / Dialog: `vscode/service-override/messages`
51
53
  - Model / Editor: `vscode/service-override/modelEditor`
54
+ - Configuration: `vscode/service-override/configuration`
52
55
 
53
56
  Usage:
54
57
  ```typescript
55
58
  import { StandaloneService } from 'vscode/services'
56
59
  import getModelEditorServiceOverride from 'vscode/service-override/modelEditor'
57
60
  import getMessageServiceOverride from 'vscode/service-override/messages'
61
+ import getConfigurationServiceOverride from 'vscode/service-override/configuration'
58
62
 
59
63
  StandaloneServices.initialize({
60
64
  ...getModelEditorServiceOverride((model, input, sideBySide) => {
61
65
  // Open a new editor here and return it
62
66
  // It will be called when for instance the user ctrl+click on an import
63
67
  }),
64
- ...getMessageServiceOverride(document.body)
68
+ ...getMessageServiceOverride(document.body),
69
+ ...getConfigurationServiceOverride(() => userConfigurationJson, configurationChangeEvent)
65
70
  })
66
71
  ```
67
72
 
68
73
  Note: using `vscode/service-override/modelEditor`, you'll be able to use the `vscode.workspace.registerTextDocumentContentProvider` api
69
74
 
75
+ ### Troubleshoot
76
+
77
+ `StandaloneServices.initialize` can only be called once (note that `monaco.editor.create` calls `StandaloneServices.initialize`).
78
+
79
+ Also, a service that is used cannot be overriden anymore. So `StandaloneServices.initialize` should be called as soon as possible to prevent most of the issues.
80
+
81
+ ## Editor configuration
82
+
83
+ The editors created using `monaco.editor.create` don't use the configuration from the configurationService.
84
+
85
+ This library exposes functions to create editors binded on the configuration:
86
+
87
+ before:
88
+ ```typescript
89
+ import * as monaco from 'monaco-editor'
90
+ monaco.editor.create(...)
91
+ ```
92
+
93
+ after:
94
+ ```typescript
95
+ import { createConfiguredEditor } from 'vscode/monaco'
96
+
97
+ createConfiguredEditor(...)
98
+ ```
99
+
100
+ `createConfiguredEditor` returns a subclass of what is returned by `monaco.editor.create`, the `updateOptions` method can still be used.
101
+ The only difference is that is will use the `configurationService` as a default configuration
102
+
70
103
  ### Installation
71
104
 
72
105
  ```bash
@@ -81,7 +114,7 @@ Just import it as if you were in a vscode extension:
81
114
  ```typescript
82
115
  import * as vscode from 'vscode'
83
116
 
84
- const range = new new vscode.Range(...)
117
+ const range = new vscode.Range(...)
85
118
  vscode.languages.registerCompletionItemProvider(...)
86
119
  ```
87
120