Skip to content

Commit

Permalink
feat: Fix the copied format not being applied to the selected text in…
Browse files Browse the repository at this point in the history
… some CKEditor instances - EXO-73291 - Meeds-io/MIPs#129 (#647)

Prior to this change, the copied format was not applied to the selected
text in some CKEditor instances. This issue was due to the mouseup event
being attached to the editor document and not being detected. This
change attaches the entire event to the editor's editable element,
resolving the issue.
  • Loading branch information
sofyenne authored and azayati committed Sep 24, 2024
1 parent ef4db6b commit d9cf25c
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() ) ) {
Expand Down

0 comments on commit d9cf25c

Please sign in to comment.