Comments (15)
I also found the JSONContribution which seems interesting also in my case, but could not find a way to register my own.
from monaco-editor.
@aeschli will know
from monaco-editor.
Oh, but first we'd need to ship a new monaco-editor
that contains the now extracted monaco-json
.
from monaco-editor.
The JSON plugin has an API that lets you add schemas (and schema associations).
Check out https://github.com/Microsoft/monaco-json/blob/master/src/monaco.d.ts
from monaco-editor.
@aeschli I don't think we've shipped an editor version that contains the json language as a plugin yet
from monaco-editor.
up ?
I also cannot see the JsonContribution interface in https://github.com/Microsoft/monaco-json/blob/master/src/monaco.d.ts. Any chance to see it appearing ?
from monaco-editor.
Yes, I made the update.
Check out https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-configure-json-defaults
from monaco-editor.
Thanks, this is one part of the solution. The other part would be to have the posibility to apply the schema based on a file pattern (eg. package.json files).
from monaco-editor.
Use the fileMatch property for that...
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
schemas: [{
uri: "http://myserver/foo-schema.json",
fileMatch: [ 'foo.json' ],
schema: {
type: "object",
properties: {
p1: {
enum: [ "v1", "v2"]
},
p2: {
$ref: "http://myserver/bar-schema.json"
}
}
}
},{
uri: "http://myserver/bar-schema.json",
schema: {
type: "object",
properties: {
q1: {
enum: [ "x1", "x2"]
}
}
}
}]
});
monaco.editor.create(document.getElementById("container"), {
model: monaco.editor.createModel("{\n}\n", 'json', "inmemory://inmemory/foo.json")
});
from monaco-editor.
great ! 👍
Is it possible also to have custom values for intellisense (like dependencies in package.json files) ?
from monaco-editor.
I added https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-completion-provider-example to show how to add custom completions.
from monaco-editor.
awesome.
Thanks a lot.
from monaco-editor.
One question though, wouldn't it be cleaner to expose the Jsoncontribution interface and a way to add customs ?
It just looked better to my eyes as the retrieval of the current "node" is done in background.
from monaco-editor.
That's not so easy as the JSON language service runs in a web worker. Your contribution would have to be bundled as part of this web worker.
Sure possible to do, the parts are all there.
from monaco-editor.
I have tried fileMatch but useless..
from monaco-editor.
Related Issues (20)
- [Bug]
- [Bug] ESM Code contains require code HOT 1
- [Feature Request] Reduce Code size, by not creating the __decorate helper function 148 times
- [Bug] Monaco Editor always set up Native environment instead of Web environment on load. HOT 2
- [Bug] Regex without anchor `^` in the tokenizer rule matches only the beginning of the string
- [Bug] Background color does not seems to be working on monaco.editor.defineTheme rules section. HOT 1
- [Feature Request] Close peek problem/definition window programmatically
- [Bug] Reusing the same container for diff editor and normal editor doubles some key events HOT 1
- [Bug] Paste from on-screen keyboard
- [Feature Request] How to set the maximum editable line for the Monaco editor
- monaco-edito is only 5px tall HOT 2
- Update Monaco's vendored TypeScript from v5.0.2 to support React JSX types and other language changes HOT 1
- [Feature Request] Add tools section to README.md
- [Bug] 0.47.0 TypeError: Cannot read properties of undefined (reading 'CI') HOT 1
- [Bug] No alternate for getDiffLineInformationForOriginal or getDiffLineInformationForModified in diff editor
- Adjust suggest filter in monaco editor
- [Bug] The setMonarchTokensProvider rule matches incorrectly
- [Bug] Setting tabFocusMode on initial monaco.editor.create does not properly set value
- [Bug] When multiple Monaco editors exist simultaneously, the theme of each editor is forced to be unified HOT 1
- How do I display the full suggestion detail directly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monaco-editor.