Can’t select image in CKEditor in order to apply style

Not sure this is connected to Drupal, but since I’m using CKEditor within Drupal, I’m asking here first because sometimes, using a feature in Drupal seems to change behavior.

  • In the empty body field of a node, I click the “Insert images using Imce File Mangager” button (which I have included in the CKEditor toolbar).
  • At the IMCE file browser window, I select an image, give it Alt text, and click Save.
  • The image appears in the editor window. The html is <p><img alt="test" data-entity-type="" data-entity-uuid="" height="300" src="/sites/default/files/Test_Image.jpg" width="200" /></p>
  • Now I want to apply a style from the Styles drop-down (which I have also included in the toolbar) to the image.
  • I click the image to select it and a blue border box appears around it.
  • I click the Styles dropdown. None of the image styles I have defined show up (which is the expected behavior when no image is selected).
  • If I double-click the image, I get an “Edit Image” dialog box where I can edit the image properties (same as when I right-click the image and choose Image Properties).
  • If I double-click out to the right of the image, instead of getting the blue box, the image appears to be selected.
  • In this case, my image styles do show up in the Styles dropdown. However, selecting a style does not apply it to the image, reason being that when the image appears to be selected, it’s actually the paragraph containing the image that’s selected. Thus, the img style isn’t applied, because img styles can’t be applied to paragraphs.
  • Once in a while, for reasons I haven’t been able to nail down, some sequence of toggling into and out of Source mode and/or changing what’s in the toolbar and/or something else I do makes it so that I CAN click directly on the image to select it. In this case, I CAN apply a style from the dropdown to the image and it works beautifully.
  • But even when image styles start working like this, pretty soon they stop working, again for unknown reasons.

Any suggestions on how to make it possible for editors to apply a style to an image will be greatly appreciated. None of the many posts I’ve read address this issue.