This is a migrated thread and some comments may be shown as answers.

Prevent <!DocType html> tag from being stripped

5 Answers 170 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Mark Kucera
Top achievements
Rank 1
Mark Kucera asked on 25 Aug 2014, 09:24 PM
It seems like no matter what i do, switching between HTML and code view removes the <!doctype> tag from my content.  I've recorded a video that demonstrates this behavior using your online demos. 

http://youtu.be/G7xR036tRXQ?hd=1

Is there a way to correct this behavior?

Thanks!
-Mark

5 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 26 Aug 2014, 04:00 PM
Hi Mark,

I tried to reproduce the problem, but to no avail. Please examine this screencast and let me know if I am missing something important.

Could you please test if you are able to reproduce the same behavior on your end using this online demo and get back to me with the exact steps to reproduce, so that I could be able to investigate it on my end?

If this is happening only with isolated scenario, please prvide some details about the specific configuration of the RadEditor control that leads to the described behavior.

Regards,
Ianko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mark Kucera
Top achievements
Rank 1
answered on 26 Aug 2014, 04:15 PM
Ok, so i figured out in your demo page that <!doctype html> is stripped out, but <!DOCTYPE html> is NOT stripped out.  I've confirmed our application also works as long as DOCTYPE is capitalized.  Do you know what that would be since HTML tags are case-insensitive?  Anything we can do to prevent?

Thanks!
0
Ianko
Telerik team
answered on 27 Aug 2014, 06:28 AM
Hi Mark,

Thank you for getting back. to me.

The RadEditor control supports only valid XHTML content and as per to validation requirements, the DOCTYPE declaration should be always upper case.

I am unable to suggest a possible approach to let users add lower case DOCTYPE.

More details about this matter is discussed in this Stackoverflow forum thread.

Regards,
Ianko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mark Kucera
Top achievements
Rank 1
answered on 27 Aug 2014, 01:59 PM
Thanks for the information.  I actually had found and read that same post already.  There seems to be a lot of ambiguity about the correct casing requirements for that tag.  But it does appear to be the consensus that using capital doesn't ever hurt.  Now that I know what is happening I believe that I can correct for this using a custom filter.

I've written custom filters before and this seems to be pretty straight forward. For anyone interested the filter code would look similar to this:

function OnClientLoad(editor, args) {
    try {
        editor.get_filtersManager().add(new SymbolsCustomFilter());
        editor.get_filtersManager().add(new ImageAlignmentCustomFilter());
        editor.get_filtersManager().add(new HorizontalAlignCustomFilter());
        editor.get_filtersManager().add(new BrReplacementInEmptyTableCellFilter());
        editor.get_filtersManager().add(new XSSFilter());
        editor.get_filtersManager().add(new DocTypeFilter());
    }
    catch (e) {
        alert(e);
    }
}
 
DocTypeFilter = function () {
    DocTypeFilter.initializeBase(this);
    this.set_isDom(false);
    this.set_enabled(true);
    this.set_name("Doctype filter");
    this.set_description("This filter will correct any lowercase doctype tags found in the document.");
}
 
DocTypeFilter.prototype =
{
    getDesignContent: function (content) {
        try {
            content = content.replace('<!doctype', '<!DOCTYPE');
        }
        catch (e) { }
 
        return content;
    },
 
    getHtmlContent: function (content) {
        try {
            content = content.replace('<!doctype', '<!DOCTYPE');
        }
        catch (e) { }
 
        return content;
    }
}
 
try {
    DocTypeFilter.registerClass('DocTypeFilter', Telerik.Web.UI.Editor.Filter);
}
catch (e)
{ }

Regards,
-Mark
0
Ianko
Telerik team
answered on 29 Aug 2014, 07:22 AM
Hi Mark,

Thank you for sharing this custom filter with the Telerik community.

I believe that it will be really useful to other developers, encountered the same behavior.

Regards,
Ianko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Editor
Asked by
Mark Kucera
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Mark Kucera
Top achievements
Rank 1
Share this question
or