|
Fck editor inserting xhtml and browser specific code |
I've been using the fck editor to handle my rich text areas in a content management application. I have to say I like the way it works, and it integrates easily with a Coldfusion platform. It does however have a few issues. This article deals with fck editor using xhtml code, and the editor using a few browser specific html rewrites.
Note: I can't have xhtml code in my site, as the definition type is not xhtml, and it fails an accessibility check if any is present.
I have an article here that deals with how to set the html that is used when a user hits the carriage return. By doing this you can edit whether the fck editor uses 'P' tags, 'div' tags or 'br' tags. The only issues from here is that it uses xhtml breaks.
IE:
It also changes the formatting of the last carriage return in the textarea to be browser specific in some instances. In this case firefox. You can edit each config.js file (there is one per browser and version) in your fck server directory, or you could intercept the request and clean it, which is what I've done.
2
3<cfargument name="strToClean" type="string" required="true" hint="this is the string to clean">
4
5<cfset var cleanedString = arguments.strToClean>
6<cfset var listIndex = "">
7<cfset var replacementString = '<br/>,<br />,<br type="_moz" />'>
8
9<cfdump var="#cleanedString#" label="before">
10
11<cfloop list="#replacementString#" index="listIndex">
12<cfset cleanedString = replaceNoCase(cleanedString, listIndex, '<br>','all')>
13</cfloop>
14
15<cfdump var="#cleanedString#" label="after">
16
17<cfreturn cleanedString>
18</cffunction>
This function accepts a string, and loops through a list, replacing each value with a non xhtml 'br' tag. The output changes as per below.
2first line<br> <br> second line<br> <br> <br>
I'd rather do this at a server level but there doesn't seem to be a straightforward way of doing it.