diff --git a/src/bundle/Resources/public/js/scripts/admin.distraction.free.mode.js b/src/bundle/Resources/public/js/scripts/admin.distraction.free.mode.js index 7b0e72fcc4..602ff2977a 100644 --- a/src/bundle/Resources/public/js/scripts/admin.distraction.free.mode.js +++ b/src/bundle/Resources/public/js/scripts/admin.distraction.free.mode.js @@ -1,6 +1,7 @@ (function (global, doc) { let activeFieldEdit = null; let clearedPositionNodesData = []; + let previousDistractionFreeModeActive = null; const DISTRACTION_FREE_MODE_ENABLE_EVENT_NAME = 'ibexa-distraction-free:enable'; const DISTRACTION_FREE_DISABLE_EVENT_NAME = 'ibexa-distraction-free:disable'; const distractionFreeModeEnableBtns = doc.querySelectorAll('.ibexa-field-edit__distraction-free-mode-control-btn--enable'); @@ -43,10 +44,12 @@ clearedPositionNodesData = []; } const changeDistractionFreeModeState = (active) => { - if (!activeFieldEdit) { + if (!activeFieldEdit || previousDistractionFreeModeActive === active) { return; } + previousDistractionFreeModeActive = active; + const dispatchEventName = active ? DISTRACTION_FREE_MODE_ENABLE_EVENT_NAME : DISTRACTION_FREE_DISABLE_EVENT_NAME; const editorSourceElement = activeFieldEdit.querySelector('.ibexa-data-source__richtext'); const editorInstance = editorSourceElement.ckeditorInstance;