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
|
<div id="editor">
<img src="../../../_assets/logo.png">
<p>Some text</p>
</div>
<label><input id="readonly" type="checkbox">Editor readonly</label>
<script>
// Drag & drop of widgets isn't supported on mobiles.
if ( bender.tools.env.mobile ) {
bender.ignore();
}
CKEDITOR.replace( 'editor', {
on: {
instanceReady: function() {
var readonlyCheckBox = CKEDITOR.document.findOne( '#readonly' ),
editor = this;
setReadOnly();
if ( CKEDITOR.env.ie && !CKEDITOR.env.edge ) {
setInterval( function() {
setReadOnly();
}, 150 );
} else {
readonlyCheckBox.on( 'change', function() {
setReadOnly( readonlyCheckBox.$.checked );
} );
}
function setReadOnly() {
if ( editor.readOnly !== readonlyCheckBox.$.checked ) {
editor.setReadOnly( readonlyCheckBox.$.checked );
}
}
}
}
} );
</script>
|