monaco-yaml
Advanced tools
Comparing version 4.0.0-alpha.3 to 4.0.0
26
index.js
@@ -8,3 +8,3 @@ // src/index.ts | ||
// src/yamlMode.ts | ||
import { editor as editor2, languages as languages2 } from "monaco-editor/esm/vs/editor/editor.api.js"; | ||
import * as monaco from "monaco-editor/esm/vs/editor/editor.api.js"; | ||
import { registerMarkerDataProvider } from "monaco-marker-data-provider"; | ||
@@ -403,3 +403,3 @@ import { createWorkerManager } from "monaco-worker-manager"; | ||
beforeText: /:\s*$/, | ||
action: { indentAction: languages2.IndentAction.Indent } | ||
action: { indentAction: monaco.languages.IndentAction.Indent } | ||
} | ||
@@ -409,3 +409,3 @@ ] | ||
function setupMode(defaults) { | ||
const worker = createWorkerManager({ editor: editor2 }, { | ||
const worker = createWorkerManager(monaco, { | ||
label: "yaml", | ||
@@ -424,14 +424,14 @@ moduleId: "monaco-yaml/yaml.worker", | ||
}); | ||
languages2.registerCompletionItemProvider(languageId, createCompletionItemProvider(worker.getWorker)); | ||
languages2.registerHoverProvider(languageId, createHoverProvider(worker.getWorker)); | ||
languages2.registerDefinitionProvider(languageId, createDefinitionProvider(worker.getWorker)); | ||
languages2.registerDocumentSymbolProvider(languageId, createDocumentSymbolProvider(worker.getWorker)); | ||
languages2.registerDocumentFormattingEditProvider(languageId, createDocumentFormattingEditProvider(worker.getWorker)); | ||
languages2.registerLinkProvider(languageId, createLinkProvider(worker.getWorker)); | ||
languages2.registerCodeActionProvider(languageId, createCodeActionProvider(worker.getWorker)); | ||
languages2.setLanguageConfiguration(languageId, richEditConfiguration); | ||
let markerDataProvider = registerMarkerDataProvider({ editor: editor2 }, languageId, createMarkerDataProvider(worker.getWorker)); | ||
monaco.languages.registerCompletionItemProvider(languageId, createCompletionItemProvider(worker.getWorker)); | ||
monaco.languages.registerHoverProvider(languageId, createHoverProvider(worker.getWorker)); | ||
monaco.languages.registerDefinitionProvider(languageId, createDefinitionProvider(worker.getWorker)); | ||
monaco.languages.registerDocumentSymbolProvider(languageId, createDocumentSymbolProvider(worker.getWorker)); | ||
monaco.languages.registerDocumentFormattingEditProvider(languageId, createDocumentFormattingEditProvider(worker.getWorker)); | ||
monaco.languages.registerLinkProvider(languageId, createLinkProvider(worker.getWorker)); | ||
monaco.languages.registerCodeActionProvider(languageId, createCodeActionProvider(worker.getWorker)); | ||
monaco.languages.setLanguageConfiguration(languageId, richEditConfiguration); | ||
let markerDataProvider = registerMarkerDataProvider(monaco, languageId, createMarkerDataProvider(worker.getWorker)); | ||
defaults.onDidChange(() => { | ||
markerDataProvider.dispose(); | ||
markerDataProvider = registerMarkerDataProvider({ editor: editor2 }, languageId, createMarkerDataProvider(worker.getWorker)); | ||
markerDataProvider = registerMarkerDataProvider(monaco, languageId, createMarkerDataProvider(worker.getWorker)); | ||
}); | ||
@@ -438,0 +438,0 @@ } |
{ | ||
"name": "monaco-yaml", | ||
"version": "4.0.0-alpha.3", | ||
"version": "4.0.0", | ||
"description": "YAML plugin for the Monaco Editor", | ||
@@ -64,4 +64,4 @@ "homepage": "https://monaco-yaml.js.org", | ||
"eslint-config-remcohaszing": "^4.0.0", | ||
"husky": "^7.0.0", | ||
"lint-staged": "^12.0.0", | ||
"husky": "^8.0.0", | ||
"lint-staged": "^13.0.0", | ||
"monaco-editor": "^0.33.0", | ||
@@ -68,0 +68,0 @@ "typescript": "^4.0.0", |
@@ -232,2 +232,69 @@ # Monaco YAML | ||
### Using Monaco webpack loader plugin | ||
If you're using | ||
[monaco webpack plugin](https://github.com/microsoft/monaco-editor/tree/main/webpack-plugin), then | ||
instead of the above code, you can extend the plugin's configuration. Extend your | ||
`webpack.config.js` file with the following: | ||
```js | ||
import { MonacoWebpackPlugin } from 'monaco-editor-webpack-plugin'; | ||
export default { | ||
// ...the rest of your webpack configuration... | ||
plugins: [ | ||
new MonacoWebpackPlugin({ | ||
languages: ['yaml'], | ||
customLanguages: [ | ||
{ | ||
label: 'yaml', | ||
entry: 'monaco-yaml', | ||
worker: { | ||
id: 'monaco-yaml/yamlWorker', | ||
entry: 'monaco-yaml/yaml.worker', | ||
}, | ||
}, | ||
], | ||
}), | ||
], | ||
}; | ||
``` | ||
You can also refer to the | ||
[example](https://github.com/remcohaszing/monaco-yaml/tree/main/examples/monaco-editor-webpack-plugin) | ||
of a complete project. | ||
### Why does it try to download my schema even when I provided one as an object? | ||
You may have provided a schema configured like this: | ||
```Javascript | ||
{ | ||
uri: "http://example.com", | ||
fileMatch: ["file_name.yml"], | ||
schema: { | ||
$schema: "http://json-schema.org/draft-07/schema#", | ||
$id: "http://example.com", | ||
title: "placeholder title", | ||
description: "placeholder description", | ||
type: "object", | ||
properties: { | ||
name: { | ||
description: "name property description", | ||
type: "string", | ||
}, | ||
}, | ||
required: ["name"], | ||
}, | ||
} | ||
``` | ||
And would be surprised to see the error: | ||
> Unable to load schema from 'http://example.com': Failed to fetch. | ||
It happens because plugin uses schema URI not only as the URL to download the schema from, but also | ||
to determine the schema name. To fix this, change the `uri` parameter to | ||
`http://example.com/schema-name.json`. | ||
## Contributing | ||
@@ -234,0 +301,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
806722
9414
0
323