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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>wysiwyg-sceditor</title>
<!-- json editor -->
<script src="../../dist/jsoneditor.js"></script>
<!-- jquery -->
<script src="./../../node_modules/jquery/dist/jquery.min.js"></script>
<!-- sceditor -->
<script src="./../../node_modules/sceditor/minified/jquery.sceditor.bbcode.min.js"></script>
<script src="./../../node_modules/sceditor/minified/jquery.sceditor.xhtml.min.js"></script>
<link rel="stylesheet" href="./../../node_modules/sceditor/minified/themes/default.min.css">
</head>
<body>
<textarea class="debug" cols="30" rows="10"></textarea>
<button class='get-value'>Get Value</button>
<div class='container'></div>
<script>
var container = document.querySelector('.container');
var debug = document.querySelector('.debug');
var schema = {
type: "object",
title: "Car",
properties: {
custom_attributes: {
title: "i have a custom attribute",
type: "string",
"options": {
"inputAttributes": {
"custom-attribute": 'custom-value'
}
}
}
}
};
// sceditor quirk. Styles must be specified in the options at creation
// if you want to be able to focus on the iframes he creates.
//JSONEditor.plugins.sceditor.style = '//cdn.jsdelivr.net/sceditor/1.4.3/jquery.sceditor.default.min.css';
JSONEditor.plugins.sceditor.style = '';
var editor = new JSONEditor(container, {
schema: schema
});
document.querySelector('.get-value').addEventListener('click', function () {
debug.value = JSON.stringify(editor.getValue());
});
</script>
</body>
</html>
|