Commit a0e92aba authored by Boris Kocherov's avatar Boris Kocherov

demo/with_monaco: use local schema7

parent 7e79da6c
...@@ -59,27 +59,26 @@ importScripts('https://unpkg.com/monaco-editor@0.14.3/min/vs/base/worker/workerM ...@@ -59,27 +59,26 @@ importScripts('https://unpkg.com/monaco-editor@0.14.3/min/vs/base/worker/workerM
let modelUri = monaco.Uri.parse("tmp://xxx.json"); // a made up unique URI for our model let modelUri = monaco.Uri.parse("tmp://xxx.json"); // a made up unique URI for our model
let model = monaco.editor.createModel("{\n}", "json", modelUri); let model = monaco.editor.createModel("{\n}", "json", modelUri);
const getSchema = relativeUrl => { const getSchema = (schemaUrl, mappedUrl)=> {
const schemaUrl = new URL(relativeUrl, baseUrl);
return fetch(schemaUrl) return fetch(schemaUrl)
.then(resp => { .then(resp => {
return resp.json(); return resp.json();
}) })
.then(s => { .then(s => {
return { return {
uri: relativeUrl, uri: mappedUrl || schemaUrl,
schema: s, schema: s,
schema_url: schemaUrl.toString() schema_url: mappedUrl || schemaUrl
}; };
}); });
}; };
Promise.all([ Promise.all([
getSchema(mainSchema).then(s => { getSchema(baseUrl + mainSchema).then(s => {
s.fileMatch = [modelUri.toString()]; // this is the main schema associated to the model s.fileMatch = [modelUri.toString()]; // this is the main schema associated to the model
return s; return s;
}), }),
getSchema("http://json-schema.org/draft-07/schema") getSchema("../../json-schema/schema7.json", "http://json-schema.org/draft-07/schema")
]).then(schemas => { ]).then(schemas => {
gadget.getDeclaredGadget("rjs_json_form").then(g => { gadget.getDeclaredGadget("rjs_json_form").then(g => {
return g.render({ return g.render({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment