const options = { showLogicTab: true };
var creator = new SurveyCreator.SurveyCreator(options);
ReactDOM.render(
<React.StrictMode>
<SurveyCreator.SurveyCreatorComponent creator={creator} />
</React.StrictMode>,
document.getElementById("creatorElement")
);
creator.onDefineElementMenuItems.add((sender, options) => {
// If an element doesn't have the `startWithNewLine` property, return from the function
if(options.obj.startWithNewLine === undefined) return;
var question = options.obj;
// A new action configuration
var barItem = {
id: "startWithNewLine", // Unique identifier
css: new Survey.ComputedUpdater(() => (question.startWithNewLine ? "sv-action-bar-item--secondary" : "")),
title: "On new line", // Action text
// The icon depends on the property value
iconName: new Survey.ComputedUpdater(() => {
if (question.startWithNewLine) {
return "icon-new-line";
}
return "icon-one-line";
}),
iconSize: 16,
// Change the property value on a click
action: () => {
question.startWithNewLine = !question.startWithNewLine;
}
};
// Find the `delete` action's position.
var index = -1;
for(var i = 0; i < options.items.length; i ++) {
if(options.items[i].id === "delete") {
index = i;
break;
}
}
// Insert the new action before `delete` or as the last action if `delete` is not found
if(index > -1) {
options.items.splice(index, 0, barItem);
} else {
options.items.push(barItem);
}
});
creator.JSON = {
"elements": [
{
"type": "text",
"name": "question1"
}
]
}
//Select the order table component
creator.selectedElement = creator.survey.getAllQuestions()[0];
<!DOCTYPE html>
<html lang="en">
<head>
<title>Custom Adorner, Survey Creator Example</title>
<meta name="viewport" content="width=device-width" />
<script src="https://unpkg.com/react@17.0.1/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@17.0.1/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone@7.2.5/babel.min.js"></script>
<script src="/DevBuilds/survey-core/survey.core.min.js"></script>
<script src="/DevBuilds/survey-core/survey.i18n.min.js"></script>
<script src="/DevBuilds/survey-react-ui/survey-react-ui.min.js"></script>
<link href="/DevBuilds/survey-core/defaultV2.min.css" type="text/css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.10/ace.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.10/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
<!-- Uncomment to enable Select2
<script src="https://unpkg.com/jquery"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
-->
<script src="/DevBuilds/survey-creator-core/survey-creator-core.min.js"></script>
<link href="/DevBuilds/survey-creator-core/survey-creator-core.min.css" type="text/css" rel="stylesheet" />
<script src="/DevBuilds/survey-creator-core/survey-creator-core.i18n.min.js"></script>
<script src="/DevBuilds/survey-creator-react/survey-creator-react.min.js"></script>
<style>
:root {
--tab-min-height: 600px;
}
</style>
<link rel="stylesheet" href="./index.css">
</head>
<body style="margin: 0">
<svg style="display:none;">
<symbol viewBox="0 0 20 22" id="icon-new-line">
<path d="M18 0H2C0.9 0 0 0.9 0 2V8C0 9.1 0.9 10 2 10H18C19.1 10 20 9.1 20 8V2C20 0.9 19.1 0 18 0ZM18 8H2V2H18V8ZM12 6H4V4H12V6ZM18 12H2C0.9 12 0 12.9 0 14V20C0 21.1 0.9 22 2 22H18C19.1 22 20 21.1 20 20V14C20 12.9 19.1 12 18 12ZM18 20H2V14H18V20ZM12 18H4V16H12V18Z" />
</symbol>
<symbol viewBox="0 0 20 10" id="icon-one-line">
<path d="M18 0H2C0.9 0 0 0.9 0 2V10C0 11.1 0.9 12 2 12H18C19.1 12 20 11.1 20 10V2C20 0.9 19.1 0 18 0ZM18 10H2V2H18V10ZM12 7H4V5H12V7Z" />
</symbol>
</svg>
<div id="surveyContainer">
<div id="creatorElement" style="height: 100vh;"></div>
</div>
<script type="text/babel" src="./index.js"></script>
</body>
</html>
Help us serve you better by taking this brief survey.
We are interested to learn more about your
experience of using our libraries.
We'd really appreciate your feedback.
Start the SurveyApproximate time to complete: 2 min.