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

[Solved] Add CSS file to modify <p> style in editor iframe

5 Answers 40 Views
Editor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Vince
Top achievements
Rank 1
Vince asked on 06 Apr 2011, 02:51 AM
Hello,

In our application, we need to make <p> looks similar to <br> so we want to set its margin to 0. However, the editor iframe will take the style from the page which sets p {margin: 0 0 1em;}. I tried to hook up a custom style sheet when creating the text editor by the following code snippet:

@(Html.Telerik().Editor().StyleSheets(styleSheets => styleSheets.Add("~/Styles/Telerik/editor.custom.css")))
and I have

p
{
    margin: 0;
}
in my editor.custom.css, but it's not picking up by the editor. The style of <p> tag is still {margin: 0 0 1em;}

Did I miss something? Or is there an alternative way to set the style of <p> tag inside iframe editor? This is tested in FF4 and IE9, both are not working.

5 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 06 Apr 2011, 01:02 PM
Hello Vince,

One of the purposes of using an iframe for the Editor's editable area is to prevent styles from the main page to cascade into the editable area, which is practically a separate HTML document. What you are describing is rather odd and I can't reproduce it on my side (e.g. by modifying this demo locally - http://demos.telerik.com/aspnet-mvc/editor/styles).  Please double check. If the problem persists, you can send us a live URL or a demo, which reproduces the issue, so that we can take a look.

Greetings,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Vince
Top achievements
Rank 1
answered on 08 Apr 2011, 01:48 AM
Hi Dimo,

I tried to move the editor outside of our jQuery template and it will pick up the custom CSS file now. Have you tried adding the editor in a jQuery template and see whether it applies custom css files? Is there a workaround to allow this? I really need to have the editor in the jQuery template. Thanks,

Vince
0
Alex Gyoshev
Telerik team
answered on 08 Apr 2011, 07:23 AM
Hello Vince,

By jQuery template, do you mean the jQuery templating module? Can you please send the relevant code so that we may debug the problem?

All the best,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Vince
Top achievements
Rank 1
answered on 08 Apr 2011, 05:53 PM
Yes I mean jQuery templating module. The attach is a test prototype I created for this. You will find that editor inside template will not pick up custom css. Please take a look. Thanks,

Vince
0
Accepted
Alex Gyoshev
Telerik team
answered on 11 Apr 2011, 12:06 PM
Hello Vince,

The editor in the template did not work at all because it was not initialized. Since every editor needs a unique name in order to work, the template should define it like this: .Name("${Name}"). This way, you can populate the template with a unique editor by using .tmpl({ Name: "myEditor1" }), and initialize the editor by calling the tEditor jQuery plugin.

I am attaching the modified example.

Regards,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Editor
Asked by
Vince
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Vince
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or