From c53eb53cfd4fdbd19d3f0be362b01a85bfc50dfc Mon Sep 17 00:00:00 2001 From: sofyenne Date: Mon, 23 Sep 2024 10:22:17 +0100 Subject: [PATCH] feat: Fix the copied format not being applied to the selected text in some CKEditor instances - EXO-73291 - Meeds-io/MIPs#129 --- .../webapp/ckeditor/plugins/copyformatting/plugin.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/commons-extension-webapp/src/main/webapp/ckeditor/plugins/copyformatting/plugin.js b/commons-extension-webapp/src/main/webapp/ckeditor/plugins/copyformatting/plugin.js index e4d33e8844..ea42af735f 100644 --- a/commons-extension-webapp/src/main/webapp/ckeditor/plugins/copyformatting/plugin.js +++ b/commons-extension-webapp/src/main/webapp/ckeditor/plugins/copyformatting/plugin.js @@ -109,6 +109,15 @@ } } ); + if (mouseupHost === editor.document) { + editable.attachListener( editable, 'mouseup', function( evt ) { + // Apply formatting only if any styles are copied (#2780, #2655, #2470). + if ( getMouseButton( evt ) === CKEDITOR.MOUSE_BUTTON_LEFT && cmd.state === CKEDITOR.TRISTATE_ON ) { + editor.execCommand( 'applyFormatting' ); + } + } ); + } + editable.attachListener( CKEDITOR.document, 'mouseup', function( evt ) { if ( getMouseButton( evt ) === CKEDITOR.MOUSE_BUTTON_LEFT && cmd.state === CKEDITOR.TRISTATE_ON && !editable.contains( evt.data.getTarget() ) ) {