Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#39337 closed defect (bug) (fixed)

TinyMCE: when a wpview is the last element, insert an empty paragraph (caret placeholder) under it

Reported by: azaozz's profile azaozz Owned by: azaozz's profile azaozz
Milestone: 4.8 Priority: normal
Severity: normal Version: 4.4
Component: TinyMCE Keywords: has-patch
Focuses: Cc:

Description

This will make the user experience a bit better: the users will be able to continue typing right away.

It will also fix the problem with "half-selected" wpviews after initializing the editor. Moving the caret to the placeholder also moves the focus off the first element when it is a non-editable wpview.

Attachments (4)

39337.patch (2.0 KB) - added by azaozz 8 years ago.
39337.2.patch (1.4 KB) - added by azaozz 8 years ago.
39337.3.patch (3.2 KB) - added by azaozz 8 years ago.
39337.4.patch (711 bytes) - added by iseuldebot 8 years ago.

Download all attachments as: .zip

Change History (12)

@azaozz
8 years ago

#1 @iseulde
8 years ago

What about blocks that are inserted after init? Maybe we should just create a paragraph whenever the area after the block is clicked? In my opinion it's still better to keep "native" behaviour and place the caret after the block, where the user can press enter to create a new paragraph. I see that this currently doesn't happen. This was the behaviour before we switched to the mce implementation.

@azaozz
8 years ago

#2 @azaozz
8 years ago

...better to keep "native" behaviour and place the caret after the block, where the user can press enter to create a new paragraph.

Agreed. In 39337.2.patch: select the wpview node after inserting it, then collapse the selection. This places the caret after the wpview node. It also fixes the "half-selected" bug when the node is first in the body.

@azaozz
8 years ago

#3 @azaozz
8 years ago

In 39337.3.patch: Pass the editor event to wp.mce.views.setMarkers() for context, then use it to move the cursor after the newly inserted wpview node, or to deselect the wpview on initial loading.

#4 @azaozz
8 years ago

  • Keywords has-patch added

#5 @iseulde
8 years ago

I'll give the patch a try. My initial thought was to add this to the wpview plugin.

#6 @azaozz
8 years ago

Yeah, would have been better if it was in the plugin, but not possible. It needs to run when we replace the markers, the plugin is not used then. This may be possible when we have UI for entering these "blocks". Then we would know that something is a block as soon as it is entered, may even not need the "markers" any more.

Was also thinking wpview would need some refactoring, and we should move the TinyMCE parts to the plugin. Looking at things like setMarkers(), getMarkers(), replaceMarkers(), setContent(), etc. Can export them in editor.wp or add custom events where it makes sense.

@iseuldebot
8 years ago

#7 @azaozz
8 years ago

39337.4.patch works properly here and makes it exactly as before.

It doesn't fix the "wpview node partially selected after page load when it is first in the body". This seems identical to #37753 and very similar to #38849. Lets track that in #37753.

Version 0, edited 8 years ago by azaozz (next)

#8 @azaozz
8 years ago

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

In 39903:

TinyMCE: when inserting a wpview, place the caret after is so the user can continue typing without interruption.

Props iseulde.
Fixes #39337.

Note: See TracTickets for help on using tickets.