blob: b41eae88c544067c8d2fc792b344e349e7f0fee5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import ciSchemaPath from '~/editor/schema/ci.json';
import { registerSchema } from '~/ide/utils';
export class CiSchemaExtension {
static get extensionName() {
return 'CiSchema';
}
// eslint-disable-next-line class-methods-use-this
provides() {
return {
registerCiSchema: (instance) => {
// In order for workers loaded from `data://` as the
// ones loaded by monaco editor, we use absolute URLs
// to fetch schema files, hence the `gon.gitlab_url`
// reference. This prevents error:
// "Failed to execute 'fetch' on 'WorkerGlobalScope'"
const absoluteSchemaUrl = new URL(ciSchemaPath, gon.gitlab_url).href;
const modelFileName = instance.getModel().uri.path.split('/').pop();
registerSchema({
uri: absoluteSchemaUrl,
fileMatch: [modelFileName],
});
},
};
}
}
|