Editor Clipboard issue

2 posts, 0 answers
  1. Afroz khan
    Afroz khan avatar
    38 posts
    Member since:
    Dec 2009

    Posted 19 Mar 2015 Link to this post

    Hello Team

    I am using Telerik RadEditor where I set the max length using JavaScript but when I paste the data from Clipboard to Editor, I gets the message
    " Do you want to allow this webpages to access your Clipboards?" if I click Don'tAllow and do the paste again then JavaScript which using to control the max length gets fail and user can paste large amount of data on Editor.

    <telerik:RadEditor ContentAreaCssFile="~/Styles/EditorContentAreaCss.css" ID="txtDetails" MaxTextLength="8000"
    runat="server" EditModes="Design" EnableResize="false" Height="150px" OnClientLoad="EditorMaxLengthvalidation8000"
    OnClientPasteHtml="OnClientPasteHtml8000" NewLineBr="false" NewLineMode="P" Style="border: 1px solid Navy;
    background-color: White;" ToolsFile="~/App_Data/RadControls/Editor/ToolsFile.xml"
    Width="503px">
    <CssFiles>
    <telerik:EditorCssFile Value="~/Styles/Editor.css" />
    </CssFiles>
    </telerik:RadEditor>


    JavaScript

    function OnClientPasteHtml8000(editor, args) {
    var limitCharacters = 8000;
    OnClientPasteHtml(editor, args, limitCharacters);
    }

    function OnClientPasteHtml(editor, args, limitCharacters) {
    try {
    var commandName = args.get_commandName();
    var value = args.get_value();
    var lengthWithOutHtml = 0;
    var lengthWithHtml = 0;
    var lengthDifference = 0;
    var messagePaste = 'Max length exceeded to ' + limitCharacters + ' characters. Content cannot paste.';
    lengthWithHtml = value.length;

    //This condition raise when user paste only text which does't contains any HTML code.
    //So due to this we don't suppose to update the 'value' field.
    if (value != "") {
    //value = $(value).text();
    lengthWithOutHtml = value.length;
    lengthDifference = lengthWithHtml - lengthWithOutHtml;
    }
    if (commandName == "PasteFromWord"
    || commandName == "PasteFromWordNoFontsNoSizes"
    || commandName == "PastePlainText"
    || commandName == "PasteAsHtml"
    || commandName == "Paste") {
    var textLength = CalculateLength(editor, value);
    var updatelimitCharacters = lengthDifference + limitCharacters;
    if (textLength > limitCharacters) {
    args.set_cancel(true);
    alert(messagePaste);
    }
                            
            }
    }
    catch (e) { }
    }

    function EditorMaxLengthvalidation8000(editor, args) {
    var limitCharacters = 8000;
    EditorMaxLengthvalidation(editor, args, limitCharacters);
    //Hide the tabbing
    HideTabbingInEditor(editor);

    }

    function EditorMaxLengthvalidation(editor, args, limitCharacters) {
    var rtfEditor = editor;
    var currentMode = rtfEditor.get_mode();
    rtfEditor.set_stripFormattingOptions(Telerik.Web.UI.StripFormattingOptions.NoneSupressCleanMessage | Telerik.Web.UI.StripFormattingOptions.MSWordNoMargins);
    AttachHandlers(currentMode, rtfEditor, limitCharacters);
    editor.get_contentArea().className = "fs-editor";
       
    }

    function HideTabbingInEditor(editor) {
    editor.removeShortCut("InsertTab");
    var buttonsHolder = $get(editor.get_id() + "Top"); //get a reference to the top toolbar zone of the editor
    var buttons = buttonsHolder.getElementsByTagName("A"); //get a reference to all A elements on the toolbar and disable the tabbing trough them
    for (var i = 0; i < buttons.length; i++) {
    var a = buttons[i];
    a.tabIndex = -1;
    a.tabStop = false;
    }
    var element = editor.get_element();
    editor.get_contentAreaElement().tabIndex = element.tabIndex;
    element.tabIndex = -1;
    }


  2. Afroz khan
    Afroz khan avatar
    38 posts
    Member since:
    Dec 2009

    Posted 27 Mar 2015 Link to this post

    Can anyone from Telerik team reply?
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top