WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#28335 closed defect (bug) (wontfix)

More tag can't be inserted if inside div

Reported by: programmin Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: TinyMCE Keywords:
Focuses: javascript Cc:

Description

When content is inside a div tag, clicking the "more" icon just adds more after the div it was inserted in.

I don't remember this ever happening before 3.9, it's a major UI problem that it doesn't get added where your cursor is, but far below it.

This happens no matter the theme, I tried in Twenty Thirteen and 2 others.

Attachments (2)

trac-28335.diff (979 bytes) - added by ebinnion 6 years ago.
28335.diff (937 bytes) - added by DrewAPicture 6 years ago.

Download all attachments as: .zip

Change History (14)

#1 @SergeyBiryukov
6 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 3.9.2

Confirmed. Doesn't happen in 3.8.x.

#2 @ebinnion
6 years ago

  • Keywords has-patch dev-feedback added; needs-patch removed

Confirmed that something similar to the described behavior happened in trunk when the following content was in the text tab.

<div>

hello world

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

</div>

When switching back to the editor, if I clicked the more button when the cursor was directly beside 'hello world', the more shortcode was added at the bottom of the div. Which, in this case, is considerably further down the page from the 'hello world'.

I am attaching a patch that fixes the behavior and, in my opinion, simplifies some of the code.

Note: This patch only addresses /wp-includes/js/tinymce/plugins/wordpress/plugin.js and not any of the minified versions.

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

@ebinnion
6 years ago

@DrewAPicture
6 years ago

#3 @DrewAPicture
6 years ago

  • Keywords commit added

28335.diff refreshes the patch and fixes the issue as described.

#4 @iseulde
6 years ago

  • Component changed from Editor to TinyMCE
  • Focuses ui removed
  • Keywords commit removed
  • Version changed from 3.9.1 to 3.9

So what will now happen when you select a wpview and insert a more tag? Or if you set your cursor before or after it? What will happen when you insert a more tag when the cursor is inside some bold text, or some other inline element? As far as I can see, it will break the html...

I think we'll first need to use an inline placeholder for the tag, so it can be inserted anywhere.

#5 follow-up: @azaozz
6 years ago

The <!--more--> tag is a "logical separator" of the content. Ideally it should go at the end of a paragraph that is a direct child of the body, and that is how most people use it. It's not (well) supported in other contexts, like in table, blockquote, pre, etc. Currently we are avoiding broken html by inserting it after the current block tag.

Was thinking to replace it inside the editor with <hr> element instead of the current <img>. That would make the placement a bit better and produce a bit cleaner html when "more" is inserted in an arbitrary place.

#6 in reply to: ↑ 5 @bordoni
6 years ago

Replying to azaozz:
I like this approach. Would allow people to give it style easier.

#7 @azaozz
6 years ago

  • Keywords has-patch dev-feedback removed
  • Milestone changed from 3.9.2 to 4.0

Anybody wants to try replacing the placeholder <img> with a placeholder <hr> for 4.0? It's mostly CSS and a little JS :)

#8 @DrewAPicture
6 years ago

  • Keywords needs-patch added

Sounds like we still need a patch here, see comment:7. Any takers?

#9 @iseulde
6 years ago

  • Milestone changed from 4.0 to Future Release

Too late for 4.0... These tags also have to be direct children of the body, so I think this is a wontfix.

#10 @programmin
6 years ago

Why must the more tag be a child of body? Is Wordpress not going to be doing force_balance_tags on excerpts anymore?

#11 @mycota
6 years ago

Is it wise to replace the <img> with just an <hr>, considering the image is descriptive and has text indicating what it does?

#12 @iseulde
6 years ago

  • Keywords needs-patch removed
  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Is it wise to replace the <img> with just an <hr>, considering the image is descriptive and has text indicating what it does?

We can use :before and :after to add some text. Moving to #29804.

Why must the more tag be a child of body? Is Wordpress not going to be doing force_balance_tags on excerpts anymore?

Because it's better if we don't have to. force_balance_tags doesn't really work well. <!--more--> is kind of meant to include some extra html such as an image, table or shortcode in the excerpt.

Note: See TracTickets for help on using tickets.