WordPress.org

Make WordPress Core

#22407 closed defect (bug) (fixed)

Undo and redo in TinyMCE are broken after deleting a view

Reported by: azaozz Owned by: koopersmith
Milestone: 3.5 Priority: low
Severity: normal Version: 3.5
Component: Media Keywords:
Focuses: Cc:

Description

As the title. To reproduce:

  • Add an image or a gallery to a post using the Add Media button.
  • Click on it to select it and delete it (with the backspace or delete key).
  • Press Crtl+Z or click on the Undo button in the editor.

Attachments (1)

22407.patch (3.0 KB) - added by azaozz 20 months ago.

Download all attachments as: .zip

Change History (5)

azaozz20 months ago

comment:1 azaozz20 months ago

22407.patch seems to work well (still includes some debug code for testing). It converts all views to their text mode before adding new undo level in TinyMCE and converts them back to dom nodes when doing redo.

In addition it adds another step when deleting a view, so deleting now does:

  • Convert the view to it's text.
  • Replace the view wrapper node with a temp span containing that text.
  • Run any 'delete' callbacks.
  • Remove the temp span keeping its content.
  • Cancel the undo level up to this point.
  • Delete the view's text (this is captured in the undo level).

This introduces quite a bit of overhead on adding new undo levels in TinyMCE (which happens pretty often, like on every new paragraph or on node changes), but seems to work well with contenteditable=false nodes.

comment:2 azaozz20 months ago

  • Keywords early added
  • Milestone changed from 3.5 to Future Release
  • Priority changed from high to normal
  • Severity changed from blocker to normal

Leaving for 3.6 after discussing in IRC.

comment:3 koopersmith20 months ago

  • Keywords early removed
  • Milestone changed from Future Release to 3.5
  • Priority changed from normal to low

Moving back to 3.5 and grouping with the rest of the views tickets. When we take a crack at views in the future, we'll create and parcel out tickets from there.

comment:4 koopersmith20 months ago

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

In 22567:

Media: Restore 3.4 editor behavior and remove TinyMCE views.

  • Reactivates the wpgallery and wpeditimage TinyMCE plugins. Deactivates the wpviews TinyMCE plugin.
  • Moves still-relevant logic from mce-views.js to media-upload.js and shortcode.js.
  • No longer include wp-includes/js/mce-views.js. This code will not be used in 3.5, and should be considered unstable.
  • Currently, this is the real 3.4 experience; as such, editing triggers the old modals. Changing this is the next major step.

When reassessing views, we should look over all of these tickets and anticipate these bugs accordingly.

fixes #21813, #22123, #22155, #22161, #22257, #22266, #22318, #22407, see #21390.

Note: See TracTickets for help on using tickets.