Turn off or customize Html editor code "clean-up"/embed tag removal?

Turn off or customize Html editor code "clean-up"/embed tag removal?

by Michael Penney -
Number of replies: 11

Hi, I'm trying to use custom object/embed tags for inserting flash files (in the lesson module-Moodle 1.2.1). I don't want to use the multimedia filter as it makes all the files one size, when they are not.

Inserting customized object/embed code for the flash files works fine, except that when the page is re-opened in the html editor, it 'cleans' out the embed tags. Well this works fine in Explorer 5+, which ignores embed tags anyway, but of course the flash is no longer played in Netscape & other embed using browsers.

So is there a file somewhere where html editor is being told what code to remove or not to add?

Is this fixed in Moodle 1.3?

Thanks!

Average of ratings: -
In reply to Michael Penney

Re: Turn off or customize Html editor code "clean-up"/embed tag removal?

by Janne Mikkonen -

Hi Michael.

I'm not quite sure is this causing it (could be the case in older browsers):

Embed tag is a single tag and the editor is a xhtml compatible, so it adds a slash at the end of embed tag. Like:

<embed src="flashfile" width="300" height="300">

becomes

<embed src="flashfile" width="300" height="300" type="application/x-shockwave-flash" />

So Netscape might not understand this tag anymore? Could you include some example code?

In reply to Janne Mikkonen

Re: Turn off or customize Html editor code "clean-up"/embed tag removal?

by Janne Mikkonen -

I've played around with this a while and tested also other RichText editors and none of them displays embedded flash or any other embedded media in the editor.

But this doesn't affect how embedded media show on the end page.

Design mode on the gecko just does not support showing embedded objects.

In reply to Janne Mikkonen

PS Screenshot of Flash in the editor

by Michael Penney -
It shows up fine in the editor in MSIE, if you paste in the object tag. Trouble is, it cleans up the object tag so it doesn't work in Netscape any more.

Attachment flashineditor.gif
In reply to Janne Mikkonen

Re: Turn off or customize Html editor code "clean-up"/embed tag removal?

by Michael Penney -
Hi Janne, the trouble is the editor is deleting the embed tag altogether.

Example:

pasted into the plain text editor in html format:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="240" height="240">
  <param name="movie" value="lms/vid/q22/correct.swf">
  <param name="quality" value="high">
  <embed src="lms/vid/q22/correct.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="240" height="240"></embed></object>

Which plays fine in netscape

Becomes:

<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" height="240" width="240" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param value="6350" name="_cx" /><param value="6350" name="_cy" /><param name="FlashVars" /><param value="lms/vid/q22/correct.swf" name="Movie" /><param value="lms/vid/q22/correct.swf" name="Src" /><param value="Window" name="WMode" /><param value="-1" name="Play" /><param value="-1" name="Loop" /><param value="High" name="Quality" /><param name="SAlign" /><param value="-1" name="Menu" /><param name="Base" /><param value="always" name="AllowScriptAccess" /><param value="ShowAll" name="Scale" /><param value="0" name="DeviceFont" /><param value="0" name="EmbedMovie" /><param name="BGColor" /><param name="SWRemote" /><param name="MovieData" /><param value="1" name="SeamlessTabbing" /></object>

When opened in the html editor. Now it no longer playes in Netscape, though it plays fine in IE 6 and shows up in the editor.

So is there any way to turn off this code re-writing in the editor?

Bascially, I'd like the editor to leave alone any code that is already written, if possible.

Thanks!

In reply to Michael Penney

Re: Turn off or customize Html editor code "clean-up"/embed tag removal?

by Janne Mikkonen -
Hi Michael

Ah! You  mean embed tag inside the object tags.

Well, turning into "well" formed xhtml code can be turned off from the editor but I'm not so sure can we do anything about the editor deleting the embed tag inside of object tag. It sounds wery much like a IE "feature sad". The editor code it self doesn't strip embed tags.

Does it get deleted when using editor on Mozilla/FireFox/Netscape?
In reply to Janne Mikkonen

Re: Turn off or customize Html editor code "clean-up"/embed tag removal?

by Michael Penney -
Firefox on windows leaves the object/embed tag as written (though it doesn't display the flash in the editor).

I wonder if the editor is checking with IE to see what 'well formed' is?

Since I can't really expect none of my course creators to edit in MSIE how do I turn off the xhtml conversion in the editor to check this?

Maybe there is a way to have it not do any code correction when opened in MSIE?

Thanks!
In reply to Michael Penney

Another problem with code 'clean up' and MSIE Please Help

by Michael Penney -

When <nolink></nolink> is entered in code view in the editor in MSIE, it also gets 'cleaned up' into XHTML: <nolink /></nolink />.

Now this breaks the nolink function to turn off automatic linking of glossary itemssad.

Janne, you said here:

"Well, turning into "well" formed xhtml code can be turned off from the editor..."

http://moodle.org/mod/forum/discuss.php?d=8724&parent=42288

Can you please tell me where this can be done, as I would rather have the nolink feature work than xhtml?

Thanks!

In reply to Michael Penney

Re: Another problem with code 'clean up' and MSIE Please Help

by Janne Mikkonen -
Sorry, been little busy.

I'll have to do some digging and testing. Hopefully it can be turned off but I can't give any guarantees.
In reply to Michael Penney

Re: Another problem with code 'clean up' and MSIE Please Help

by Janne Mikkonen -

It seem this turns off xhtml tagging:

Open /lib/editor/htmlarea.php

Goto line 2143 and replace line:
html += closed ? " />" : ">";
with:
html += closed ? ">" : ">";

It leaves <nolink> alone. Do not put it on a production until you've tested it thoroughly. And make a backup of your older htmlarea.php file.

Cheers,
Janne

In reply to Janne Mikkonen

Re: Another problem with code 'clean up' and MSIE Please Help

by Michael Penney -

Hi Janne, made that change, didn't work for me, HTMLArea was still rewrting autolinks.


What I did was change the glossary filter on linke 146 to recognize <nolink /> instead of  <nolink> and now it works. More details in the glossary forum.

For the flash files I did some rewriting on the media plugin filter to auto-generate different size object/embed tags for our different flash files. More details in the filters forum.

Thanks!
Michael

In reply to Michael Penney

Re: Another problem with code 'clean up' and MSIE Please Help

by lou Charrier MIS -

i had a similar situation ,
i use the html version of htmlArea
  (not moodle's PHP version) as an editor for the body of email message to be sent to newsletter subscribers of a non-moodle site and i created some custom buttons for my mail merge tags to place member data like 'name' , 'address' etc...

onSubmit htmlArea
would re-write my mail merge tags and that would make them useless ... nobody likes to read " hello 'firstname' " , kinda defeats the whole thing...

what i did to 'cure' this is: i saw that onSubmit htmlArea runs a 'clean-up' routine that will format the text from the wysiwyg editing 'container' and put that into the proper 'textarea' field of the form that is being submitted, i then run my own javascript function on the contents of the 'textarea' , at that point htmlArea
is done munging my tags but my function 'kicks in' just before submitting the form to the server ...

i called it 'fixmytags()' , in my function i use javascript regexp to search for htmlArea's 'corrections' and then replace with my own 'proper' tags...

so your 'fixmytags()' function would regexp search for what HTMLarea likes to output and then replace that with the proper tag .... you can then allow javascript to submit the form to your server , there will be no further 'touching' by htmlArea as it has finished it's job...

 if you re-open that message , sure enough htmlArea will munge your tags again, but if you are carefull to not  'mess-em-up' by typing in-between the end/close tags (in plain text mode), your function 'fixmytags()' will run every time the form is submitted and will re-clean-up your tags after htmlArea's clean-up is finished but just before the form is actually submitted.... 

you will need to play around with the regular expresion , to grab the right  'bad tags' ... here is the on-line tool i used to get the javascript search pattern i needed :

http://www.regular-expressions.info/javascriptexample.html


hope that helps .


LouCharrierMIS@go.com