Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

56 lines
1.4 KiB

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="editor-sdk.js"></script>
<script src="https://cdn.ckeditor.com/ckeditor5/10.0.0/classic/ckeditor.js"></script>
<style>
.ck-editor__editable {
min-height: 250px;
}
</style>
</head>
<body>
<textarea name="content" id="editor"></textarea>
<script>
var element = document.getElementById('editor');
ClassicEditor
.create(element)
.catch(error => {
console.error(error);
})
.then(editor => {
var field = new SquidexFormField();
field.onValueChanged(function (value) {
if (value) {
editor.setData(value);
}
});
field.onDisabled(function (disabled) {
editor.set('isReadOnly', disabled);
});
editor.model.document.on('change', function () {
var data = editor.getData();
field.valueChanged(data);
});
editor.ui.focusTracker.on('change:isFocused', function (event, name, isFocused) {
if (!isFocused) {
field.touched();
}
});
});
</script>
</body>
</html>