Skip to content

Commit

Permalink
Prevent CKEditor from initializing an already initialized editor
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati committed Oct 14, 2020
1 parent d8bb4d0 commit dbbc95a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions concrete/src/Editor/CkeditorEditor.php
Expand Up @@ -159,8 +159,14 @@ function(identifier) {
CKEDITOR.stylesSet.add('concrete5styles', {$this->getStylesJson()});
}
var element = $(identifier),
destroyed = false,
form = element.closest('form'),
ckeditor = element.ckeditor({$options}).editor;
CKEDITOR.on('inline', function(e) {
if (destroyed === false && element.has(e.data.element.$)) {
return false;
}
});
function resetMode() {
if (ckeditor.mode === 'source' && ckeditor.setMode) {
ckeditor.setMode('wysiwyg');
Expand All @@ -172,6 +178,7 @@ function resetMode() {
ckeditor.on('remove', function(){
form.off('submit', resetMode);
$(this).destroy();
destroyed = true;
});
form.on('submit', resetMode);
if (CKEDITOR.env.ie) {
Expand Down

0 comments on commit dbbc95a

Please sign in to comment.