WordPress.org

Make WordPress Core

Opened 3 weeks ago

Last modified 2 weeks ago

#42029 new task (blessed)

Editor: Improve keeping text selection between Visual and Text modes

Reported by: biskobe Owned by:
Milestone: 4.9 Priority: normal
Severity: normal Version: trunk
Component: Editor Keywords: has-patch needs-testing
Focuses: javascript Cc:

Description

This patch is a continuation from #41962 / [41630].

What's new?

  • Shortcodes should no longer break when selecting them from text mode and switching to Visual mode.
  • No longer inserting empty paragraphs where the selection markers were, when going back and forth between Visual and Text modes.
  • Live Preview shortcodes should now be properly selected in Text mode, when they were selected in Visual mode.
  • Other general bug fixes and code improvements.

To test

  1. Apply patch
  2. Open the editor
  3. Add content, click around, select things
  4. Switch between modes
  5. Try adding embeds
  6. Try adding shortcodes

Look for JS errors in the console, weird behavior, etc.

Feedback

Please, add any feedback as a comment here or as a comment on the development PR, linked below.

Attachments (1)

42029.diff (24.5 KB) - added by biskobe 3 weeks ago.

Download all attachments as: .zip

Change History (10)

@biskobe
3 weeks ago

#1 @ocean90
3 weeks ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.9
  • Version set to trunk

#2 @biskobe
3 weeks ago

  • Keywords needs-testing added

#3 @azaozz
3 weeks ago

In 41645:

Editor: Improve keeping text selection when switching between Visual and Text modes.

Props biskobe.
See #42029.

#4 @azaozz
3 weeks ago

In 41646:

Editor: improve attaching a callback on editor init.

See #42029

#5 @azaozz
3 weeks ago

Still to do:

  • There are couple of places where Underscore/Lodash is used, but it is not guaranteed it will be available. Refactor them to use similar helper methods in window.tinymce.
  • Add support for disabling this from the editor settings?
  • Perhaps use editor.on( 'beforeGetContent', ...) to always remove the selection marker. Can filter the editor DOM before serializing. This will remove it on switching editors, on saving, and when other plugins extract (some of) the content.

#6 @azaozz
3 weeks ago

In 41655:

Editor: pass the DOM library instance instead of a (fake) editor instance to getCursorMarkerSpan().

See #42029

#7 @azaozz
3 weeks ago

In 41656:

Editor: Use editor.$ to improve removeSelectionMarker().

See #42029

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


2 weeks ago

#9 @jbpaul17
2 weeks ago

  • Type changed from enhancement to task (blessed)

Converting to task per the 4.9 bug scrub earlier today.

Note: See TracTickets for help on using tickets.