Override TinyMCE settings for Paste in EPiServer CMS 8

During the last days I have revived complaints from our editors regarding that to much junk gets pasted into the XHtml text-editors.

I decided to try to clear all the class and styles and other junk during paste (CTRL+ V) in to XHtml editor. Eliminating the old paste to notepad first approach.
It is of great concern to keep the editorial text as clean as possible for SEO and other purposes.
This was not as straight forward as you can imagine….

After spending more then a day looking through all the documentation for Tiny and EPiServer I decided to try making my own plugin override.

We already had one plugin override but this seemed not to work as I wanted.

The problem is the default implementation of the paste.js plugin found here:  \modules\_protected\CMS\EPiServer.Cms.Shell.UI.zip\Util\Editor\tinymce\plugins\paste\

I wanted CTRL+ V to completely clear all the style and class data but the default setting shipped with EPiServer is set to:

paste_strip_class_attributes : “mso”

This means clear class defind in MS Word but keep class from web sites.

To accomplish the task I simply created a new class and added the TinyMCEPluginNonVisual attribute.

 

What this plugin simply does is  sticking the “paste as plain text” button in on mode and then some…

Here is how to do this

 [TinyMCEPluginNonVisual(
PlugInName = "DefaultSettings",
AlwaysEnabled = true,
EditorInitConfigurationOptions = @"{
paste_text_sticky : true,
paste_text_sticky_default: true,
paste_auto_cleanup_on_paste : true,
paste_strip_class_attributes: 'all',
formats: {
removeformat : [
{selector : 'b,strong,em,i,font,u,strike,h1,h2,h3,h4,h5,h6', remove : 'all', split : true, expand : false, block_expand : true, deep : true},
{selector : 'span', attributes : ['style', 'class'], remove : 'empty', split : true, expand : false, deep : true},
{selector : '*', attributes : ['style', 'class'], split : false, expand : false, deep : true}
]
},
extended_valid_elements : 'td[style|data-mce-style|class|align|valign|title|hspace|vspace|width|height|scope|name]' }")]

public class DefaultSettingsPlugin
{
}

Thats it!
This will simpley override the original paste.js with the new settings.
This can be applied to all the TinyMCE plugins.

Export XForms data to Excel fails when more than 1000 rows

I have notice that an exception is thrown if you try to export more than 1000 rows of data to excel in EPiServer CMS 6.0 R2.
The problem can emerge if you have a lot of answers in a XForm survey for example.

The exception info that is shown is: The URL-encoded form data is not valid. And System.InvalidOperationException: Operation is not valid due to the current state of the object.

Don’t worry there is a quick fix to this problem!

Microsoft security update MS11-100 limits the maximum number of form keys, files, and JSON members to 1000 in an HTTP request. Because of this change, ASP.NET applications reject requests that have more than 1000 of these elements. HTTP clients that make these kinds of requests will be denied, and an error message will appear in the web browser. The error message will usually have an HTTP 500 status code

To override this behavior you just add the following to your web.config

<add key="aspnet:MaxHttpCollectionKeys" value="2000" />

View Event logs in EPiServer admin mode

void Page_Load(Object sender, EventArgs e)
{
BindGrid();
}

void LogGrid_Change(Object sender, DataGridPageChangedEventArgs e)
{
// Set CurrentPageIndex to the page the user clicked.
LogGrid.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.
BindGrid();
}

void BindGrid()
{
System.Diagnostics.EventLog aLog = new System.Diagnostics.EventLog();
aLog.Log = "Application";
aLog.MachineName = ".";

var result = (from System.Diagnostics.EventLogEntry elog in aLog.Entries
where (elog.Source.ToString().Equals("EPiServer"))
orderby elog.TimeGenerated descending
select elog).ToList();

LogGrid.DataSource = result;
LogGrid.DataBind();
}

<asp:content  id="Content3" contentplaceholderid="MainRegion" runat="server">

    <div class="epi-contentContainer epi-padding">
        <div class="epi-contentArea">
            <h2>Eventloggar</h2>
            <asp:DataGrid id="LogGrid"   runat="server" OnPageIndexChanged="LogGrid_Change"
              AllowPaging="True"
                PageSize="20"
                PagerStyle-Mode="NumericPages"
                PagerStyle-HorizontalAlign="Right"
                PagerStyle-NextPageText="Next"
                PagerStyle-PrevPageText="Prev"
                HeaderStyle-BackColor="#aaaadd"
                AutoGenerateColumns="False"
                ForeColor="#333333" >
                <AlternatingItemStyle BackColor="White" ForeColor="#284775" />
                <Columns>
                  <asp:BoundColumn HeaderText="Severity" DataField="EntryType" ReadOnly="True" />
                  <asp:BoundColumn HeaderText="Date/Time" DataField="TimeGenerated"/>
                  <asp:BoundColumn HeaderText="Message" DataField="Message"/>
                </Columns>
                <EditItemStyle BackColor="#999999" />
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"></HeaderStyle>
                     <ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <PagerStyle Mode="NumericPages" NextPageText="Next" PrevPageText="Prev"
                   BackColor="#284775" ForeColor="White"></PagerStyle>
                <SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            </asp:DataGrid>
        </div>
    </div>
</asp:content>