WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#30565 closed defect (bug) (fixed)

WordPress 4.1 is not firing Justify ExecCommands

Reported by: programmin Owned by: azaozz
Milestone: 4.1 Priority: normal
Severity: normal Version: 4.1
Component: TinyMCE Keywords: has-patch
Focuses: ui, javascript Cc:

Description

In pre-4.1, you could catch attempts to align anything with:

ed.onExecCommand.add(function(editor, command) {
   //command is JustifyCenter, JustifyLeft, JustifyRight, etc.
}

This let scripts know when user aligned anything. However, in 4.1 beta it calls the execCommand when text is selected and align left/center/right button is clicked, but never when an image is selected and the left/center/right button is clicked.

Perhaps something in the new pop-up-alignment image toolbar is interfering?

Attachments (1)

30565.patch (669 bytes) - added by iseulde 6 years ago.

Download all attachments as: .zip

Change History (7)

#1 @programmin
6 years ago

You can see the expected behavior here http://www.tinymce.com/tryit/inline.php - after running:

tinymce.activeEditor.on('ExecCommand',function(evt) {
  console.log(evt);
})

It logs every time align button is clicked - both for selected image and selected text.

#2 @SergeyBiryukov
6 years ago

  • Summary changed from Wordpress 4.1 is not firing Justify ExecCommands to WordPress 4.1 is not firing Justify ExecCommands

#3 @iseulde
6 years ago

  • Milestone changed from Awaiting Review to 4.1

We used to only preventDefault for images wrapped in a caption. Now we do it for any image.

[30318], #30147,
https://github.com/tinymce/tinymce/blob/master/js/tinymce/classes/Editor.js#L1400

@iseulde
6 years ago

#4 @iseulde
6 years ago

  • Keywords has-patch added

Leaving for @azaozz to take a look at this.

#5 @iseulde
6 years ago

@programmin how did you stumble upon this? What are you doing on ExecCommand? (Just curious.)

Last edited 6 years ago by iseulde (previous) (diff)

#6 @azaozz
6 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 30748:

TinyMCE: manually fire ExecCommand when aligning images as we do preventDefault() on BeforeExecCommand for them. Props avryl, fixes #30565.

Note: See TracTickets for help on using tickets.