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

Issue in telerik editorfor

9 Answers 149 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Thiruppathi
Top achievements
Rank 1
Thiruppathi asked on 27 Aug 2012, 06:46 AM
Hi, I am using  telerik.EditorFor() control for sending description of article If I copy and paste the content from any of the word document, the text alignment is not in correct format and left side characters also  hided.
I am not able to move scrollbar to see the left side content.
Here I have attached my word document where I copied the content.
I want to format the text immediately after paste the content .
Is there any solution to format the content.And also I have tried your side I got same issue.

This is my code:

@{ Html.Telerik().EditorFor(model => model.Description)

.Name(

 

"Description")

 

.HtmlAttributes(

 

new { style = "width: 680px; height:400px;" })

 

.Tools(tools =>

tools.Clear().Bold().Italic().Underline().Strikethrough().Separator()

.FontName().FontSize().FontColor().BackColor().Separator()

.JustifyLeft().JustifyCenter().JustifyRight().JustifyFull().Separator()

.InsertOrderedList().InsertUnorderedList().Separator()

.Indent().Outdent().Separator()

.FormatBlock().Separator()

 

)

.Encode(

 

true)

 

.Value(@<text></text>)

.Render();

}



 

9 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 27 Aug 2012, 09:35 AM
Hello Thiruppathi,

Can you please send a Word document, which triggers the described problem?

Kind regards,
Dimo
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Thiruppathi
Top achievements
Rank 1
answered on 27 Aug 2012, 12:34 PM
Thanks.
0
Dimo
Telerik team
answered on 27 Aug 2012, 12:38 PM
Hi Thiruppathi,

The problem is caused by bad document formatting - please note that the main page margins are narrow and they are overridden by custom tabs. This leads to negative margins being applied in the MVC Editor component and part of the content is hidden to the sides. This can be fixed by toggling the Indent tool as well.

On a side note, please always make sure that uploaded attachments are suitable for public review. We may not be able to react quickly and delete attachments in other occasions.

Regards,
Dimo
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Accepted
sujith
Top achievements
Rank 1
answered on 06 Sep 2012, 09:02 PM
Hello Dimo,

We too are facing the same issue and not sure how to resolve this issue. Is there a way for the editor to remove the negative margins and clean up the content before it gets rendered?
We are even trying out htmlagility pack, but it isn't helping us out.

Since ours is a customer facing application, we aren't able to ask them to remove the bad formatting too.

Thank you,
Sujith
0
Thiruppathi
Top achievements
Rank 1
answered on 10 Sep 2012, 06:59 AM
Hello Dimo,

Please reply the following thread..

We too are facing the same issue and not sure how to resolve this issue. Is there a way for the editor to remove the negative margins and clean up the content before it gets rendered?
We are even trying out htmlagility pack, but it isn't helping us out.

Since ours is a customer facing application, we aren't able to ask them to remove the bad formatting too.

Thanks,
Thiruppathi.
0
Dimo
Telerik team
answered on 10 Sep 2012, 08:59 AM
Hello,

If removing the offending formatting in the Word document in advance is not an option, then you can use the Editor's paste event to iterate through the editable content's DOM elements and remove all negative margins manually. You will need to use setTimeout, as the paste event is fired before the new content is actually inserted inside the Editor.

The Editor content area's <body> tag can be referenced inside the paste event handler with

$(this).data("tEditor").body


All the best,
Dimo
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Thiruppathi
Top achievements
Rank 1
answered on 12 Sep 2012, 06:44 AM
Hi,

I have removed pre tag from my word document by using the below code.after removing i want to bind the resulting text without pre tag on the "tEditor" control.Is this correct way to bind the word document
"$(this).data('tEditor').content =str" kindly reply in this.

function Editor_onPaste(e)
{

    var str = e.html; 

    str = str.replace("<PRE.*?", "<p>")

    str.replace("</PRE>", "</p>")
    $(this).data('tEditor').content =str ;
}

  

@{ Html.Telerik().EditorFor(model => model.Description )
    .Name("Description")
    .HtmlAttributes(new { style = "width: 680px; height:400px;" })
    .Tools(tools =>
     tools.Clear().Bold().Italic().Underline().Strikethrough().Separator()
     .FontName().FontSize().FontColor().BackColor().Separator()
     .JustifyLeft().JustifyCenter().JustifyRight().JustifyFull().Separator()
     .InsertOrderedList().InsertUnorderedList().Separator()
      .Indent().Outdent().Separator()
      .FormatBlock().Separator()
      )

      .ClientEvents(events => events.OnPaste("Editor_onPaste"))
      .Encode(true)
      .Value(@<text></text>)
      .Render();
      }

 

 

Thanks,
Thiruppathi.


 

0
Thiruppathi
Top achievements
Rank 1
answered on 21 Sep 2012, 10:59 AM
Hello Dimo,

Can you reply my previous issue

Thanks,
Thiruppathi.
0
Dimo
Telerik team
answered on 24 Sep 2012, 08:56 AM
Hello Thiruppathi,

The Editor value is set with the value() method. There is no property "content".

In addition, as mentioned earlier, you have to use setTimeout to change the Editor's value in the paste handler, because the event is fired before the content is actually changed.

Greetings,
Dimo
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
General Discussions
Asked by
Thiruppathi
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Thiruppathi
Top achievements
Rank 1
sujith
Top achievements
Rank 1
Share this question
or