I’m using the following code provided by Reinmar here to create multiple instances of CKEditor5. However in Firefox Inspector I get the error: CKEditorError: can't convert null to object
Perhaps this is related to adding the CKEditor object to the constant ‘editors’ array, does the ‘editors’ array need to be defined as a object? Any ideas please?
$(document).ready(function() {
const editors = {};
function createEditor( elementId ) {
return ClassicEditor
.create( document.getElementById( elementId ) )
.then( editor => {
editors[ elementId ] = editor;
} )
.catch( err => console.error( err.stack ) );
}
createEditor( 'editor1' );
createEditor( 'editor2' );
});
And the html:
<form method="post">
<input type="hidden" name="editor" value="1">
<textarea name="editor1" id="editor1" rows="10" cols="80">
Some text
</textarea>
<input type="submit" value="Save" class="btn btn-primary">
</form>
<form method="post">
<input type="hidden" name="editor" value="1">
<textarea name="editor2" id="editor2" rows="10" cols="80">
Some text
</textarea>
<input type="submit" value="Save" class="btn btn-primary">
</form>