WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#34247 closed enhancement (wontfix)

Make <!--nextpage--> work in visual editor

Reported by: prasad-nevase Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Editor Keywords: close
Focuses: Cc:

Description

I think it can be thought of as a bug or as an enhancement. I am marking this under 'bug' because I came across a question on WordPress stackexchange.

Currently if <!--nextpage--> is inserted using 'Visual' mode of the post/page editor it gets translated to &lt;!--nextpage--&gt; which is obvious. This can be seen in text mode. Although it is recommended that this tag shall be used by switching to 'Text' mode, since its a WordPress tag, this can be very well handled with an additional condition in setup_postdata function of query.php file.

Attachments (2)

34247.patch (1.1 KB) - added by prasad-nevase 6 years ago.
Updated query.php to handle <!--nextpage--> WordPress tag inserted through Visual mode of the editor.
34247.diff (2.5 KB) - added by swissspidy 6 years ago.

Download all attachments as: .zip

Change History (13)

@prasad-nevase
6 years ago

Updated query.php to handle <!--nextpage--> WordPress tag inserted through Visual mode of the editor.

#1 @prasad-nevase
6 years ago

  • Focuses administration added
  • Keywords has-patch added

#2 @swissspidy
6 years ago

  • Component changed from Query to Editor
  • Focuses administration removed
  • Keywords needs-patch added; has-patch removed
  • Summary changed from Make <!--nextpage--> work even when it is placed from 'Visual' mode of the post editor to Make <!--nextpage--> work in visual editor
  • Type changed from defect (bug) to enhancement
  • Version 4.3.1 deleted

I think this should be handled at the editor level, just like <!--more --> (which even has a button and a nice preview).

@swissspidy
6 years ago

#3 @swissspidy
6 years ago

  • Keywords has-patch dev-feedback added; needs-patch removed
  • Milestone changed from Awaiting Review to Future Release

Interestingly, this is already supported by the editor, but is somewhat broken.

When inserting (i.e. pasting) <!--nextpage--> or <!--more-->, the editor should replace the tags with the preview. That doesn't work though, because TinyMCE receives it as &lt;!--nextpage--&gt;.

Besides that, there are configurations for a dedicated button to add a page break. It's just missing from the $mce_buttons array.

34247.diff fixes this by:

  • Changing the indexOf check when inserting the tags
  • Adding the page break button back to the editor.

I don't know why or when the button was removed from the editor, but with the recent efforts to improve pagination there's no harm in adding it back.

@iseulde Would you mind having a look at this?

#4 @swissspidy
6 years ago

  • Keywords needs-refresh added

Seems my patch doesn't work when inserting <!--more--> in the text editor and then switching back. So in plugin.js we need to check for both <!--more and &lt;!--more (same for nextpage).

Also, what about adding a quicktags button for <!--nextpage--> in the text editor?

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

#5 follow-up: @iseulde
6 years ago

I don't think it makes sense to have <!--nextpage--> in the visual editor. When you add it there, it will be escaped, just like any other code you paste.

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

Replying to iseulde:

I don't think it makes sense to have <!--nextpage--> in the visual editor. When you add it there, it will be escaped, just like any other code you paste.

That's why I suggest making the preview actually work when you add it. There's currently no way in the visual editor to add a page break, but support for it is there, see https://cloudup.com/cLD6qrh17Jl

#7 @iseulde
6 years ago

That's right, there is no button, but one can easily be added. I don't know why there's no button, maybe a decision was made in the past. @azaozz, do you know more?

#8 @azaozz
6 years ago

As far as I know this comes from the time before WordPress had a visual editor. There was never a "page break" button. However there is a shortcut in TinyMCE: control + option + P (on Mac), see the keyboard shortcuts help dialog.

#9 @nacin
6 years ago

I would be against a button in core by default, because pagination is not a thing that most sites should ever _want_ to do, and is not a thing readers want, either. I loathe the idea of encouraging its use.

#10 @swissspidy
5 years ago

  • Keywords close added; dev-feedback needs-refresh removed
  • Milestone changed from Future Release to Awaiting Review

Just had a look at this again.

I don't think it makes sense to have <!--nextpage--> in the visual editor. When you add it there, it will be escaped, just like any other code you paste.

I agree here. This would make it harder for someone who really wanted to have escaped output.

I would be against a button in core by default, because pagination is not a thing that most sites should ever _want_ to do, and is not a thing readers want, either. I loathe the idea of encouraging its use.

I agree as well.

After all, I think this is a wontfix. There's a keyboard shortcut, plugins can add a button if they want, but pagination is bad practice in general anyway.

#11 @swissspidy
5 years ago

  • Keywords has-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.