|
|
|
@ -4,6 +4,7 @@ |
|
|
|
<head> |
|
|
|
<meta charset="utf-8"> |
|
|
|
|
|
|
|
<!-- Load the editor sdk from the local folder or https://cloud.squidex.io/scripts/editor-sdk.js --> |
|
|
|
<script src="editor-sdk.js"></script> |
|
|
|
<script src="https://cdn.ckeditor.com/ckeditor5/10.0.0/classic/ckeditor.js"></script> |
|
|
|
|
|
|
|
@ -26,14 +27,17 @@ |
|
|
|
console.error(error); |
|
|
|
}) |
|
|
|
.then(editor => { |
|
|
|
// When the field is instantiated it notified the UI that it has been loaded. |
|
|
|
var field = new SquidexFormField(); |
|
|
|
|
|
|
|
// Handle the value change event and set the text to the editor. |
|
|
|
field.onValueChanged(function (value) { |
|
|
|
if (value) { |
|
|
|
editor.setData(value); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// Disable the editor when it should be disabled. |
|
|
|
field.onDisabled(function (disabled) { |
|
|
|
editor.set('isReadOnly', disabled); |
|
|
|
}); |
|
|
|
@ -41,11 +45,13 @@ |
|
|
|
editor.model.document.on('change', function () { |
|
|
|
var data = editor.getData(); |
|
|
|
|
|
|
|
// Notify the UI that the value has been changed. Will be used to trigger validation. |
|
|
|
field.valueChanged(data); |
|
|
|
}); |
|
|
|
|
|
|
|
editor.ui.focusTracker.on('change:isFocused', function (event, name, isFocused) { |
|
|
|
if (!isFocused) { |
|
|
|
// Notify the UI that the value has been touched. |
|
|
|
field.touched(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|