WordPress.org

Make WordPress Core

Opened 10 months ago

Closed 9 months ago

Last modified 8 months ago

#42029 closed task (blessed) (fixed)

Editor: Improve keeping text selection between Visual and Text modes

Reported by: biskobe Owned by: iseulde
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.9
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 10 months ago.

Download all attachments as: .zip

Change History (20)

@biskobe
10 months ago

#1 @ocean90
10 months ago

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

#2 @biskobe
10 months ago

  • Keywords needs-testing added

#3 @azaozz
10 months ago

In 41645:

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

Props biskobe.
See #42029.

#4 @azaozz
10 months ago

In 41646:

Editor: improve attaching a callback on editor init.

See #42029

#5 @azaozz
10 months 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
10 months ago

In 41655:

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

See #42029

#7 @azaozz
10 months ago

In 41656:

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

See #42029

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


10 months ago

#9 @jbpaul17
10 months ago

  • Type changed from enhancement to task (blessed)

Converting to task per the 4.9 bug scrub earlier today.

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


9 months ago

#11 @obenland
9 months ago

  • Owner set to iseulde
  • Status changed from new to assigned

@iseulde Could you check if this needs any more work please?

#12 @iseulde
9 months ago

@obenland Sorry for the late reply. Will check tomorrow morning!

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


9 months ago

#14 @iseulde
9 months ago

From https://wordpress.slack.com/archives/C02RQBWTW/p1509034012000623 it seems that this ticket can be closed with all issues addressed. If there's anything else left, let's open new tickets for it.

#15 @iseulde
9 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

#16 @westonruter
8 months ago

In 42183:

Editor: Improve scrolling behavior and prevent autosave logic from causing dirty state when just switching between Visual and Text tabs.

Props pento.
See #41962, #42029.
Fixes #42530 for trunk.

#17 @westonruter
8 months ago

In 42184:

Editor: Improve scrolling behavior and prevent autosave logic from causing dirty state when just switching between Visual and Text tabs.

Props pento.
See #41962, #42029.
Fixes #42530 for 4.9.

#18 @westonruter
8 months ago

In 42191:

Editor: Disable wp_keep_scroll_position in IE11 since buggy; fix matches polyfill conflict with ME.js by doing runtime feature detection in context window.

Props westonruter, SergeyBiryukov, Clorith for testing.
See #41962, #42029.
Fixes #42553 for trunk.

#19 @westonruter
8 months ago

In 42192:

Editor: Disable wp_keep_scroll_position in IE11 since buggy; fix matches polyfill conflict with ME.js by doing runtime feature detection in context window.

Props westonruter, SergeyBiryukov, Clorith for testing.
See #41962, #42029.
Fixes #42553 for 4.9.

Note: See TracTickets for help on using tickets.