WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#21145 closed defect (bug) (fixed)

Switch from HTML to VISUAL mode - does not show anything in Visual mode

Reported by: selnomeria Owned by: azaozz
Milestone: 3.4.2 Priority: normal
Severity: major Version: 3.4
Component: Editor Keywords:
Focuses: Cc:

Description

why it hasn't been fixed yet?
when i insert a bunch of codes in html mode(for example, many of these codes:

 
<href...
<iframe...
and etc..

and switch to VISUAL MODE, and then to HTML again, all of the codes and formatting are lost!

Attachments (2)

21145.patch (864 bytes) - added by SergeyBiryukov 9 years ago.
21145.overlapping.png (19.3 KB) - added by SergeyBiryukov 9 years ago.

Download all attachments as: .zip

Change History (13)

#1 follow-up: @mati1000
9 years ago

  • Cc 7645314@… added
  • Severity changed from normal to major
  • Version changed from 3.4 to 3.4.1

We have upgraded to the latest version 3.4.1 and we have the same problem.

Posts that contain [caption] shortcode does not show anything in Visual mode.

with js error: Uncaught TypeError: Cannot read property '0' of null /wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js?ver=349-20805:1 Char: 2392

#2 @mati1000
9 years ago

  • Summary changed from Switch from HTML to VISUAL mode to Switch from HTML to VISUAL mode - does not show anything in Visual mode

#3 in reply to: ↑ 1 @SergeyBiryukov
9 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.5
  • Version changed from 3.4.1 to 3.4

Version number indicates when the bug was initially introduced/reported.

I could not reproduce the original bug from the description. This content is preserved when switching from Visual to HTML (Text) mode:

&nbsp;

<iframe src="http://trunk.wordpress/" width="320" height="240"></iframe>

<href> is not a valid tag, so I've excluded it from the test.

Replying to mati1000:

Uncaught TypeError: Cannot read property '0' of null /wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js?ver=349-20805:1 Char: 2392

The error corresponds to line 145, introduced in [19982]:
http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js#L144

I can only reproduce this if I manually remove the id attribute from the [caption] shortcode. It should be there by default. If it's not in your case, your theme or some plugin might interfere with captions.

We should probably check if match() was successful though (21145.patch), since the errors due to missing attributes also cause both editors to be rendered at the same time (21145.overlapping.png).

#4 @azaozz
9 years ago

The patch looks good. Not sure what would be the best thing to do when the caption shortcode is invalid. Perhaps it should be shown as-is (a text string) instead of being parsed.

#5 @azaozz
9 years ago

In [21232]:

TinyMCE: don't throw fatal errors for malformed/invalid image caption shortcodes, props SergeyBiryukov, see #21145

#6 @azaozz
9 years ago

  • Keywords has-patch removed
  • Milestone 3.5 deleted
  • Resolution set to invalid
  • Status changed from new to closed

Cannot reproduce the originally reported problem either. Since the browser parses the string from the Text editor (the textarea) into a HTML document, invalid/custom tags are only supported if registered in TinyMCE.

Closing as invalid for now, feel free to reopen with a valid example that can be reproduced.

#7 @mati1000
9 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Hi,

Our HTML example is:

[caption align="alignleft" width="500"]<img class="alignleft size-thumbnail wp-image-41536" src="http://core.trac.wordpress.org/raw-attachment/ticket/21145/21145.overlapping.png" alt="" width="500" height="72" /> Ticket #21145: 21145.overlapping.png[/caption]

and SergeyBiryukov is right, because the missing id attribute - the match is failed. In addition, I get both editors that are rendered at the same time - like in the 21145.overlapping.png.

And of course, after define the SCRIPT_DEBUG and applying the patch its works!

I don't know why we don't have the id in the shortcode, but we have a lot of posts with captions without ids, and we cannot now upgrade to the last version.

#8 @SergeyBiryukov
9 years ago

  • Milestone set to 3.4.2

Well, the patch is now committed, so the missing id attribute should no longer be an issue in 3.5. comment:6 was referring to the original ticket description.

Moving for 3.4.2 consideration of [21232].

#9 follow-up: @nacin
9 years ago

Did [21232] fix a regression in 3.4?

#10 in reply to: ↑ 9 @azaozz
9 years ago

Replying to nacin:

Yeah, it's "kind of" regression as the old shortcode replacement method was more error tolerant. [21232] brings that back.

#11 @azaozz
9 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from reopened to closed

In [21274]:

TinyMCE: don't throw fatal errors for malformed/invalid image caption shortcodes, props SergeyBiryukov, fixes #21145 for 3.4

Note: See TracTickets for help on using tickets.