0

I have a shortcode that has a 'style' attribute for a theme that I'm creating, which looks like this:

[shortcode_name type="normal" style="fixed"]

Now if I paste this in the TinyMCE editor, I get this:

[shortcode_name type="normal"]

So it's stripping away the entire style attribute, and it does this only if I have a value for the style attribute, so it works fine if I paste this:

[shortcode_name type="normal" style=""]

I think this is related to the new feature of TinyMCE 4.0 that now supports the formatting of where the text was copied.

Any way, please let me know what's wrong here, and what should I do about it. Thanks.

Edit: Also, this is nothing to do with the shortcode. Even if I try pasting something like this:

foo style="sfdf" bar

Only this gets pasted:

foo

This is very weird. Can someone please try the above and tell me if I'm the only one with this?

  • Is it your own shortcode? – Milo Apr 29 '14 at 1:50
  • Yes. But even if I try to paste this for example: "foo style="fsfds" bar" only "foo" gets pasted. – user1981248 Apr 29 '14 at 2:18
  • Can you use an attribute name other than style? – hereswhatidid Apr 29 '14 at 2:51
  • I'll probably end up doing that. But I at least wanted to know if I was the only one with this problem, and why exactly is this happening, and if there are other attribute names that I need to test. Can someone try pasting the above code in their editor and confirm if this is indeed a bug? – user1981248 Apr 29 '14 at 4:14
0

This is a bug between TinyMCE and WebKit based browsers. This is due to the fact that the style parameter is interpreted as a html attribute (ie img style="float: right"). If you go to Text mode and copy and paste all will be fine. As long as you stay away of naming your shortcodes parameters as HTML attributes all should be fine.

PS: I have found this in the Paste plugin for TinyMCE :) :

// Since WebKit/Chrome might clone the paste bin when pasting
// for example: <img style="float: right"> we need to check if any of them contains some useful html.
// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.