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

CSS option for Cleaning on Paste does not clean table styles

1 Answer 52 Views
Editor
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 2
David asked on 12 Jul 2016, 09:47 PM

What is the best way to remove the style tag from tables (table, tr, td tags)?

I've been working with the OnClientPasteHtml event but I don't know how to reference the pasted content or the most effective way to accomplish this. Anyone have any ideas?

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 15 Jul 2016, 08:00 AM
Hello,

Here is how you can modify the pasted tables using OnClientPasteHtml event:
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientPasteHtml="OnClientPasteHtml">
</telerik:RadEditor>
 
<script type="text/javascript">
    function OnClientPasteHtml(editor, args) {
        if (args.get_commandName() == "Paste") {
            var html = args.get_value();
            var container = document.createElement("div");
            container.innerHTML = html;
            $telerik.$(container).find("table,tbody,thead,tfoot,tr,td,th").each(function (i, item) {
                item.removeAttribute("style");
            });
            args.set_value(container.innerHTML);
        }
    }
</script>


Regards,
Nikolay
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Editor
Asked by
David
Top achievements
Rank 2
Answers by
Nikolay
Telerik team
Share this question
or