In Visual Mode, select the video view, copy it (Ctrl+c) and paste it (Ctrl+v) below. Switch to Text mode. Multiple newlines are added which results in the shortcode being broken on both back-end and front-end.

The same happens with the gallery shortcode or any wpview shortcode where the shortcode text is a bit long.
(e.g. [gallery link="file" columns="5" size="large" ids="495,499,498,533,664,638,577,575,497,773,943,670,668,496,494,487,479,673,675,676" orderby="rand"] )

Change History (36)

Can't reproduce in Firefox on Win10 (or any other browser). Tested with the above example in trunk and 4.6. Looks like "something" is adding line breaks before shortcode attributes on purpose. Could this be caused by a plugin? Or perhaps there were some "invisible" characters in the shortcodes when they were pasted in the editor for the first time that aren't in the example above?

In Visual Mode, click on Add Media, create a gallery with a lot of images and set its settings (Link To, Columns, Random order, Size) different than the default ones in order to generate a long shortcode string. Insert the gallery, copy and paste the wpview.

This is a really strange issue... Scripts are run at first (so the contents set), but then shortly afterwards the whole iframe unloads. Try the patch above and you'll see it "test"in the console, then "unload". I've been looking for hours but couldn't find the cause so far.

This is a really strange issue... Scripts are run at first (so the contents set), but then shortly afterwards the whole iframe unloads.

This is caused by the quirks routine refreshContentEditable() which (Firefox-only) reloads the body if there's no selection. Calling this early (so that later calls are a noop) is one way to workaround this issue.

The OP is caused by Firefox prettyprinting text/html into the clipboard, wrapping long lines by inserting newlines. Shortcodes with attributes then get wpautoped causing them not to parse. The following patch uses the existing pastepreprocess action in "wpviews/plugin.js" to remove them.

I'd prefer fixing this so that whenever the whole content reloads by something, the iframes contents are reloaded as well.

We can still trigger the quirks function beforehand though to prevent excessive reloading. Instead of running editor.quirks.refreshContentEditable() we can run editor.focus() which runs the former internally.

38511.6.patch looks good. In 38511.7.patch also added the removal of line breaks from shortcodes from 38511.4.patch (props @gitlost). Moved it to createInstance() as discussed in Slack, but it makes sense to try to fix that in Firefox for all pasted content. Not sure if we should do that, probably better to be handled upstream in the paste plugin.

Also noticing (non-fatal) mediaelement.js errors in Firefox and IE11 when switching to the Text editor while a movie is playing. Seems pausing the player and removal of player instances fails in these browsers. This is not caused by the above patch.

Other bug: when you copy paste a view, the toolbar with the edit/delete buttons appears above the pasted view while the view is not selected (clicking on the buttons does nothing). Bug on all browsers.

Normally we'll never have more than one shortcode in createInstance, because they are already matched, so I'm not sure if the extra loop is necessary. Also, I don't think it would be bad to disallow line breaks in general in these view texts as it will lead to nothing but problems.

Ideally this is handled by mce indeed, but it doesn't seem like we can wait for that. Let's fix it like this for now.