forked from rjsf-team/react-jsonschema-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
32 lines (28 loc) · 1.37 KB
/
main.js
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
28
29
30
31
32
$(function() {
function escape(html) {
return html.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
}
$(".language-jsx").each(function() {
var text = escape($(this).text());
if (text.indexOf("render") === -1) {
return;
}
text = text.replace("\nrender", "\nReactDOM.render");
text = "const Form = JSONSchemaForm.default;\n" + text;
var prefill = {
"title":"RJSF example",
"tags":[],
"scripts":["https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.production.min.js","https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js","https://unpkg.com/@rjsf/core/dist/react-jsonschema-form.js"],
"stylesheets":["//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"]
};
var div = $("<div><div class=\"codepen\" data-height=\"400\" data-theme-id=\"light\" data-default-tab=\"js,result\" data-prefill='" + JSON.stringify(prefill) + " '>\"<pre data-lang=\"html\">\n<div id=\"app\"></div></pre><pre data-lang=\"babel\">" + text + "</pre></div></div>").css("margin", "30px 0px");
$(this).replaceWith(div);
});
var url = "https://static.codepen.io/assets/embed/ei.js";
var script = document.createElement('script');
script.onload = function () {
window.__CPEmbed(".jsx");
};
script.src = url;
document.head.appendChild(script);
});