Skip to content

Commit 2c933f9

Browse files
committed
Fix load from github
1 parent 49515f9 commit 2c933f9

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

src/main.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,18 @@ function isEligible(tagName) {
6161
return match && parseInt(match[1], 10) >= MINIMUM_SUPPORTED_VERSION;
6262
}
6363

64-
async function loadEditorData(schemaUrl, exampleUrl) {
65-
const [schema, data] = await Promise.all([
66-
fetch(schemaUrl).then(r => r.json()),
67-
exampleUrl ? fetch(exampleUrl).then(r => r.json()).catch(() => null) : Promise.resolve(null)
68-
]);
69-
70-
const refParser = new Jedison.RefParser();
71-
await refParser.dereference(schema);
72-
refParser.expandRecursive(schema);
73-
74-
return { schema, data };
75-
}
76-
7764
// --- Editor initialization ---
7865

79-
function createEditor(schema, containerId, outputId) {
66+
async function createEditor(schema, containerId, outputId) {
8067
const container = document.querySelector(`#${containerId}`);
8168
const output = document.querySelector(`#${outputId}`);
8269

8370
container.innerHTML = '';
8471

72+
const refParser = new Jedison.RefParser();
73+
await refParser.dereference(schema);
74+
refParser.expandRecursive(schema);
75+
8576
const jedison = new Jedison.Create({
8677
container,
8778
theme: new Jedison.ThemeBootstrap5(),
@@ -91,6 +82,7 @@ function createEditor(schema, containerId, outputId) {
9182
enablePropertiesToggle: true,
9283
deactivateNonRequired: false,
9384
customEditors: [EditorColorCustom],
85+
refParser,
9486
schema
9587
});
9688

@@ -113,7 +105,8 @@ function initEditor({ schemaUrl, containerId, outputId }) {
113105
const container = document.querySelector(`#${containerId}`);
114106
container.innerHTML = '<div class="loader"></div>';
115107

116-
loadEditorData(schemaUrl)
108+
fetch(schemaUrl)
109+
.then((res) => res.json())
117110
.then((schema) => createEditor(schema, containerId, outputId))
118111
.catch(err => {
119112
container.textContent = `Failed to load schema: ${err.message}`;

0 commit comments

Comments
 (0)