Using Ckeditor 4.3.4
I have setup Media and enabled the Media browser plugin. I can insert images fine, but when I insert links to files, it at first appears ok showing a link to a file like this (note the markup below):

When I save the node, the link is completely stripped. However, before saving, if I click "Source", I see the source is:
"<p>SampleDocument.pdf</a></span></p>"
Notice how its missing the opening <a> and <span> ?
I can confirm that the Advanced Content Filter is disabled. I also tried adding in additional configuration "config.allowedContent = true;"
It seems to me like it is something that Ckeditor is doing, as opposed to the Drupal text format/filtering because the value that is stored in the database is stripped, as opposed to it being stripped on output.
I tried installing the development version of Ckeditor so that I could debug this but I could not get it working.
Could anyone point me in the right direction of where to look or how to debug?
Note: I have tried multiple version of Ckeditor and am seeing this issues with all versions.
Comments
Comment #1
tim-e commentedComment #2
ericc3 commentedI have the same issue too. Using dev version of:
Media (7.x-2.0-alpha4+7-dev)
File Entity (7.x-2.0-beta1+1-dev)
CKEditor (7.x-1.15+3-dev)
Comment #3
tim-e commented@ericc3 Do you get the same issue with broken markup?
Comment #4
ericc3 commentedNot exactly. I went over the source code on the browser. The tag output seems fine.
As for my case, after I attach a media using "add media" the link inserts properly. But if you click the "source" icon, or hit the "switch to plain text mode" link , the source code strips the links and the file title becomes plain text wrapped in
<p>. This happens before saving the node. This too also only affected non-images.Comment #5
marcusx commentedCan confirm this. Having also applied #2159403: Make CKEditor plugin system modular and clean but I can't insert PDFs / Documents.
Comment #6
jessZ commentedI was having similar problems with CKeditor stripping style formatting even though all the filters in full html in the drupal settings are turned off.
The site was ported from 5>6>7 and is now in 7.3 the ckeditor is the newest one and it is using the default settings.
When I changes to
Disable the filters in the advanced set-up option it seems to have resolved most issues. Still looking to see what other tags it still strips/
It says:
"CKEditor will not filter any tags and as a result, the user will be able to insert any content into the editor. The content will only be filtered by server-side filters associated with input formats."
but i don't think that's the case. still checking various scenarios BUT IMHO the default should be DISABLED. If ckeditor is going into core in 8 this is even more important because lots of sites will have been using other editors (I was)
Comment #7
msmithcti commentedThe attached patch to Media 2.x should fix the issues described here. Media was being very specific about which fields it stored in the
mediaSourceMapwhich meant it was only taking notice of thetagNameandsrc- which doesn't work for anything that isn't an image. This patch changes that behaviour so the whole element is stored in themediaSourceMap.This patch works with Media 2.x and the patch from #2159403-91: Make CKEditor plugin system modular and clean but I would be interested to see how it works with other setups.
I am moving this issue into media now, as that seems to be where the issue is.
Comment #8
marcusx commentedGreat, I will apply and test this soon. Thanks!
Comment #9
msmithcti commentedActually, the patch in #7 only worked if the media already existed in the field, when inserting the document from the library there was an additional issue with the regex in
prepareDataForSourceModewhich is now fixed. Additionally span tags need to be registered with CKEditor as an allowed tag otherwise they get stripped out.Attached is an updated patch.
Comment #10
deggertsen commented#9 works! Thank you so much!
This is a must in connection with #2159403: Make CKEditor plugin system modular and clean
Comment #13
marcusx commentedTested this meanwhile as well. Works good. I can insert PDFs again. Great work thanks!
One sidenote - if I click into an existing link and press the media icon should I be able to change the file? Or should it be possible to edit the linktext? I don't know if this was possible before, at the moment I am quite happy that inserting PDFs is possible at all. Maybe we need an follow up if editing / changing an already inserted link is related to this problem.
Comment #14
rooby commentedThis patch no longer applies.
Comment #15
rooby commentedHere is the reroll.
It seems to work for me but I can't comment on whether or not the approach is technically correct.
Comment #16
devin carlson commentedComment #17
deggertsen commentedIs there anything still holding this back from being committed? For me at least this is needed in order to make media stable with my current setup with ckeditor.
Comment #18
dave reidThis portion of the patch is no longer included in the module. We moved the CKEditor module integration to https://www.drupal.org/project/media_ckeditor
Comment #19
LittleRedHen commentedHere's a re-rolled patch against the latest dev branch with just the changes to media_wysiwyg.filter.js included
Comment #20
LittleRedHen commentedAfter some experimenting, the following patch seems to be all that's needed to stop the markup from being stripped out in when using CKEditor with the Beta1 release of Media. It's just the tweak to the regex in the plugin to ensure that it correctly strips out the mediawrapper tag while leaving the contents of that tag.
This patch *should* move entirely into media_ckeditor when using the latest dev branch, without any patches on media needed. (I haven't tested that assumption yet - I will submit a patch for that project when I can confirm it)
Comment #21
LittleRedHen commentedComment #22
LittleRedHen commentedIn media_ckeditor, the changes in the patch at #20 above are contained in the patch for https://www.drupal.org/node/2177893#comment-10134852. You should apply that one instead.
Comment #23
deggertsen commentedSo is this now a duplicate of #2177893: Custom wrapper breaks tokens with CKEditor >=4.0 without widget plugin? Marking as a duplicate assuming that it is.