-
Notifications
You must be signed in to change notification settings - Fork 80
/
SurveyCreator.js
41 lines (36 loc) · 1.21 KB
/
SurveyCreator.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
33
34
35
36
37
38
39
40
41
import { useState } from "react";
import { SurveyCreatorComponent, SurveyCreator } from "survey-creator-react";
import { registerMyQuestion } from "./MyQuestion";
import "survey-core/defaultV2.css";
import "survey-creator-core/survey-creator-core.css";
registerMyQuestion();
export default function SurveyCreatorWidget(props) {
let [creator, setCreator] = useState();
if (creator === undefined) {
let options = { showLogicTab: true, showTranslationTab: true };
creator = new SurveyCreator(options);
creator.saveSurveyFunc = (no, callback) => {
console.log(JSON.stringify(creator.JSON));
callback(no, true);
};
// creator.tabs().push({
// name: "survey-templates",
// title: "My Custom Tab",
// template: "custom-tab-survey-templates",
// action: () => {
// this.creator.makeNewViewActive("survey-templates");
// },
// data: {},
// });
setCreator(creator);
}
creator.JSON = props.json;
return (
<div style={{ height: "calc(100% - 70px)" }}>
{/* <script type="text/html" id="custom-tab-survey-templates">
{`<div id="test">TEST</div>`}
</script> */}
<SurveyCreatorComponent creator={creator} />
</div>
);
}