Project

General

Profile

Actions

Bug #18492

closed

CSS conflict with htmlarearte custom stylesheet

Added by Christopher about 16 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
-
Start date:
2008-03-22
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.1
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

The RTE can be customized to display custom CSS styles in the edit window using "RTE.default.contentCSS" in page TSconfig. This is typically used to make RTE content in the BE resemble or match the styles of the website FE.

It's also possible (obviously) for skins to supply custom styles in the BE, but in the current implementation, these often incorrectly override custom RTE styles.

There is a simple method to avoid this problem. See Additional Information section below.

When RTE is enabled, the edit window is rendered in an iFrame by /typo3/alt_doc.php. The <head> section output by alt_doc.php. Just after the comment '', alt_doc.php renders three <link> elements for specific stylesheets:

1. The custom RTE stylesheet

2. the RTE's default stylesheet (/typo3/sysext/rtehtmlarea/htmlarea/skins/default/htmlarea-edited-content.css)

3. the skin-specific RTE stylesheet (/typo3/sysext/rtehtmlarea/htmlarea/skins/default/htmlarea.css)

Since e.g. the skin-specific RTE stylesheet can specify font-family styles for the body element, and since the custom RTE stylesheet is declared before this one, style declarations of equivalent specificity in the supposedly custom stylesheet will be overridden.

This problem can be addressed by making the declarations in html.css more specific (i.e. by using '!important,' the '.htmlarea-content-body' class etc), but since the RTE custom stylesheet is often the same stylesheet that is used to style FE content, it should not be necessary to make adjustments for BE styles in it.

Since the final declaration for a given selector and property will override all earlier declarations of the same property with equivalent specificity, I suggest that the CSS declarations occurs in the following order:

1. the RTE's default stylesheet (/typo3/sysext/rtehtmlarea/htmlarea/skins/default/htmlarea-edited-content.css)

2. the skin-specific RTE stylesheet (/typo3/sysext/rtehtmlarea/htmlarea/skins/default/htmlarea.css)

3. The custom RTE stylesheet

In this scenario, the RTE provides its own styles, any given skin has the option of overriding those styles, and implementation-specific RTE styles can override the previous two.
(issue imported from #M7924)


Files

rtehtmlarea_bugfix_7924.patch (3.97 KB) rtehtmlarea_bugfix_7924.patch Administrator Admin, 2008-03-24 16:04
Actions #1

Updated by Christopher about 16 years ago

It should be possible to edit bugs, or I should get more sleep. The report is correct, but I've incorrectly identified the purposes of the stylesheets. They occur in this order:

1. The custom RTE stylesheet
2. The RTE's content stylesheet
3. The RTE's general stylesheet

And I suggest they occur instead in this order:

1. The RTE's content stylesheet
2. The RTE's general stylesheet
3. The custom RTE stylesheet

Sorry for confusion ;-)

Actions #2

Updated by Stanislas Rolland about 16 years ago

Please apply and test the attached patch on SVN TYPO3_4-2 revision 3471.

Actions #3

Updated by Stanislas Rolland about 16 years ago

Could you provide a test case for this issue?

I don't think the proposed solution will make any difference. I am not even sure there is a problem. The iframe is constructed with linked stylesheets RTE content stylesheet followed by custom RTE stylesheet.
Actions #4

Updated by Christopher about 16 years ago

I don't think the proposed solution will make any difference. I am not even sure there is a
problem. The iframe is constructed with linked stylesheets RTE content stylesheet followed
by custom RTE stylesheet.

I don't understand what you mean. As I indicated in the bug report, in TYPO3 4.1.5, the resulting iFrame includes the custom content stylesheet FIRST. If the new TYPO3 skin is used, the RTE content stylesheet sets a font-family for the class ".htmlarea-content-body". Here's the code (edited for readability) from the installation where I discovered the problem:

------ Start:

<div class="typo3-mediumDoc">
<form action=" [ snipped ] " method="post" enctype="multipart/form-data" name="editform" onsubmit="return TBE_EDITOR.checkSubmit(1);">
<link rel="alternate stylesheet" type="text/css" href=" [ snipped ] custom-content.css" />
<link rel="alternate stylesheet" type="text/css" href=" [ snipped ] htmlarea-edited-content.css" />
<link rel="stylesheet" type="text/css" href=" [ snipped ] htmlarea.css" />

------ End

Any font-family declaration of equal or lesser specificity on the same class in the custom content stylesheet will be overriden by the regular content stylesheet since it comes last in the cascade [1]. So, for the test-case, simply add something like this to a custom content stylesheet--there will be no change in the RTE's appearance after the BE is reloaded:

.htmlarea-content-body { font-family:palatino,"times new roman",serif; }

As also mentioned in the original bug report, in this specific case it should be possible to override this by using a more specific selector, or by using "!important" in the custom CSS file, but this will not necessarily be true in every case or for every skin.

It's not a huge bug, but there most definitely is a problem in that the load-order of the stylesheets is opposite what you'd do in cases where you had control of the source code.

Notes
----------
[1] http://www.w3.org/TR/REC-CSS2/cascade.html#cascading-order

"Finally, sort by order specified: if two rules have the same weight, origin and specificity, the latter specified wins."

Actions #5

Updated by Stanislas Rolland about 16 years ago

The css order that you see on the page source and that you are describing is used only for pre-loading purposes. It is not the order used in the iframe itself (which you do not see in the page source, right?).

If you add

.htmlarea-content-body { font-family:palatino,"times new roman",serif; }

to your custom-content.css file and clear your browser cache, it will be applied inside the iframe.

I just (re-)tested this in IE7, FF2 and Safari 3 with TYPO3 4.2.

Actions #6

Updated by Stanislas Rolland about 15 years ago

I re-tested this issue again with current trunk. I think there is no issue. The RTE iframe is dynamically created and the stylesheets are also dynamically linked in the following order (see initIframe() in htmlarea.js):

htmlarea-edited-content.css
defaultPageStyle (generated based on Page TSConfig)
custom-content.css

Thus providing the requested order.

Note: Reloading the page may not be sufficient to replace the RTE iframe css. Clearing the browser cache may be necessary.

Actions

Also available in: Atom PDF