Opened 17 years ago

Closed 13 years ago

Last modified 13 years ago

#901 closed New Feature (fixed)

Parse stylesheet to make styles list

Reported by: poeg@… Owned by: Alfonso Martínez de Lizarrondo
Priority: Normal Milestone: CKEditor 3.6
Component: Core : Styles Version: 3.0
Keywords: SF Cc: kazador@…, astpaul@…, gazou78@…

Description

I would like it if the editor parsed the stylesheet defined in FCKConfig.EditorAreaCSS (or another stylesheet) and made its styles list with that instead of having to make a seperate XML Styles file.


Moved from SF:
http://sourceforge.net/tracker/index.php?func=detail&aid=1498014&group_id=75348&atid=543656

Attachments (8)

parseCSS.zip (2.6 KB) - added by Alfonso Martínez de Lizarrondo 16 years ago.
901.patch (5.5 KB) - added by Alfonso Martínez de Lizarrondo 13 years ago.
Proposed patch
901_2.patch (1.1 KB) - added by Alfonso Martínez de Lizarrondo 13 years ago.
Updated patch just for the Styles combo
901_3.patch (1.1 KB) - added by Alfonso Martínez de Lizarrondo 13 years ago.
Improved patch
901_4.patch (28.4 KB) - added by Alfonso Martínez de Lizarrondo 13 years ago.
Updated patch
901_5.patch (28.4 KB) - added by Alfonso Martínez de Lizarrondo 13 years ago.
Revised patch
stylesheetparser.html (4.3 KB) - added by Sa'ar Zac Elias 13 years ago.
901_6.patch (28.5 KB) - added by Alfonso Martínez de Lizarrondo 13 years ago.
Revised patch

Download all attachments as: .zip

Change History (36)

comment:1 Changed 17 years ago by Martin Kou

Cc: Alfonso Martínez de Lizarrondo added
Reporter: changed from Martin Kou to poeg@…

comment:2 Changed 17 years ago by Alfonso Martínez de Lizarrondo

Cc: Alfonso Martínez de Lizarrondo removed
Component: GeneralCore : Styles

comment:3 Changed 16 years ago by Alfonso Martínez de Lizarrondo

Milestone: FCKeditor 2.5

comment:4 Changed 16 years ago by Frederico Caldeira Knabben

Milestone: FCKeditor 2.5FCKeditor 3.0

The 2.5 is about to be released. No new important features will be added to it. Postponing.

comment:5 Changed 16 years ago by Frederico Caldeira Knabben

comment:6 Changed 16 years ago by Alfonso Martínez de Lizarrondo

Cc: kazador@… added

i had the same problem and i did the following:

in my asp file that invokes this great editor, add a css stylesheet in the head section:

<LINK REL="STYLESHEET" TYPE="text/css" HREF="<%=CSS%>"/>

In my case i have decided that the css is a param of the page, so i can use the stylesheet if certain conditions are executed.

and i have modified the js/fck_config.js file substituting:

//##
//## Style Names
//##
config.StyleNames = ';Main Header;Blue Title;Centered Title' ;
config.StyleValues = ';MainHeader;BlueTitle;CenteredTitle' ;

by the following code:

//##
//## Style Names
//##
// kazador: 24/05/2004
if (!parent.document.styleSheets)
{
config.StyleNames = ';Main Header;Blue Title;Centered Title' ;
config.StyleValues = ';MainHeader;BlueTitle;CenteredTitle' ;
}
else
{
var valores='';
var regla='';
var oStyleSheet=parent.document.styleSheets[0].rules;
for (var j=0;j<oStyleSheet.length-1;j++)
{
regla=oStyleSheet[j].selectorText;
if (regla.indexOf(':')==-1) {
valores=valores+';'+regla.substring(1,oStyleSheet[j].length); }
}
config.StyleNames = valores ;
config.StyleValues = valores ;
}
// fin kazador: 24/05/2004

in this way, if i dont pass any value to css variable at first page, i use default style definition; if not i use my own css and show it in combobox. The little parsing is to avoid show the event of class (:hover, etc) and eliminate the dot at begining of class.


Moved from sourceforge
Original author: kazador

Changed 16 years ago by Alfonso Martínez de Lizarrondo

Attachment: parseCSS.zip added

comment:7 Changed 16 years ago by Alfonso Martínez de Lizarrondo

Cc: astpaul@… added

I needed to include in the Style combo box the styles of a given CSS file so i modified 2 files:

  • fckEditor.php, implementing new variables
  • test.php, for example purposes

I think the comments should be self explaining.


Moved from sourceforge
Original Author Arnaud Saint-Paul

comment:8 Changed 16 years ago by Alfonso Martínez de Lizarrondo

Cc: gazou78@… added

Thank 4 this great add-on

Tips : don't forget to put the complete css path in the $oFCKeditor->EditorAreaCSS variable (it was the only missing point to be able to use this great work)

Regards,
Simon (France)


Moved from sourceforge Original author gazou78

comment:9 Changed 16 years ago by Wojciech Olchawa

Keywords: Confirmed HasPatch added

comment:10 Changed 15 years ago by Frederico Caldeira Knabben

Milestone: CKEditor 3.0CKEditor 3.x

comment:11 Changed 14 years ago by Frederico Caldeira Knabben

Milestone: CKEditor 3.x

Milestone CKEditor 3.x deleted

Changed 13 years ago by Alfonso Martínez de Lizarrondo

Attachment: 901.patch added

Proposed patch

comment:12 Changed 13 years ago by Alfonso Martínez de Lizarrondo

Owner: set to Alfonso Martínez de Lizarrondo
Status: confirmedreview

This plugin performs the task, and it includes two configuration options so it's easy to specify what kind of rules must be ignored while automatically parsing the data.

The styles are combined with the current styleset, so people can keep using the current format for non-classes styling as well as nicer names (the parsed styles are shown as element.class)

comment:13 Changed 13 years ago by Wiktor Walc

Version: 3.0

comment:14 Changed 13 years ago by Alfonso Martínez de Lizarrondo

Could it be possible to add just the new function to the stylescombo plugin to 3.5.2?

That's really all that it's needed to enable this functionality as the other file can be deployed as an external plugin and the change also allows being able to reload the stylesSet due to any other reason. Currently it's not possible to do this task in a plugin due to the use of the variable "stylesList" in a closure.

Changed 13 years ago by Alfonso Martínez de Lizarrondo

Attachment: 901_2.patch added

Updated patch just for the Styles combo

comment:15 Changed 13 years ago by Alfonso Martínez de Lizarrondo

Keywords: HasPatch removed

The 901_2 patch allows to reset the styles combo at any time, not only when the editor is first loaded.

Changed 13 years ago by Alfonso Martínez de Lizarrondo

Attachment: 901_3.patch added

Improved patch

comment:16 Changed 13 years ago by Wiktor Walc

Milestone: CKEditor 3.6

Looks like a really nice addition to the set of optional plugins like autogrow or tableresize.

comment:17 Changed 13 years ago by Wiktor Walc

Status: reviewreview_failed

I have tried 901.patch + 901_3.patch. Looks good, but I found one problem: all CKEditor specific styles should ignored by this plugin. Right now it shows CSS styles like:

img.cke_flash
img.cke_hidden
img.cke_iframe
img.cke_anchor
a.cke_anchor
img.cke_pagebreak
table.cke_show_border

comment:18 Changed 13 years ago by Wiktor Walc

Also, just like in #7240, it would be nice to have a sample page for this plugin with a dedicated stylesheet to show the capabilities of this plugin and possibly with default styles removed:

config.stylesSet = [];

comment:19 Changed 13 years ago by Alfonso Martínez de Lizarrondo

Status: review_failedreview

In order to exclude those classes I've extended just the default stylesheetParser_skipSelectors to reject "\.cke_"

The important part is the 901_3.patch, if that one is applied into the core then this plugin might be included in 3.6 or provided only as a test plugin until everybody is happy about how it works, but at least people will be able to download and use it.

I've created a sample page and provided a stylesheet from trac as it includes lots and lots of styles and rules. With regards to that, it can be trimmed down or replaced or whatever, it's just one stylesheet that I've found easily.

Changed 13 years ago by Alfonso Martínez de Lizarrondo

Attachment: 901_4.patch added

Updated patch

comment:20 Changed 13 years ago by Alfonso Martínez de Lizarrondo

Status: reviewassigned

Ops, I think that the cke_ problem is due to this line no longer working:

if ( node.getAttribute( 'cke_temp' ) ) 

I'll update it later.

Changed 13 years ago by Alfonso Martínez de Lizarrondo

Attachment: 901_5.patch added

Revised patch

comment:21 Changed 13 years ago by Alfonso Martínez de Lizarrondo

Status: assignedreview

The new patch correctly ignores the internal stylesheets.

comment:22 Changed 13 years ago by Sa'ar Zac Elias

Status: reviewreview_passed

comment:23 Changed 13 years ago by Sa'ar Zac Elias

Status: review_passedreview_failed

Sorry, one thing: the configurations are cross-editors, look at the attached sample.
Please also fix the coding styles.

Changed 13 years ago by Sa'ar Zac Elias

Attachment: stylesheetparser.html added

Changed 13 years ago by Alfonso Martínez de Lizarrondo

Attachment: 901_6.patch added

Revised patch

comment:24 Changed 13 years ago by Alfonso Martínez de Lizarrondo

Status: review_failedreview

Now there are no variables in the closure shared amongst instances.

comment:25 Changed 13 years ago by Sa'ar Zac Elias

Status: reviewreview_passed

comment:26 Changed 13 years ago by Alfonso Martínez de Lizarrondo

Resolution: fixed
Status: review_passedclosed

Fixed with [6691]

As I said, the parsesample.css was just a quick way to provide lots of contents, but it might be trimmed down as needed for the general release (although in its current way it can be also interesting to check how some tags behave with the style system).

comment:27 Changed 13 years ago by Wiktor Walc

I have updated the default set of styles with [6693]. Although loading the Trac stylesheet showed the power of this plugin, it also introduced lots of styles that made the sample less atractive.

I've noted some inconsistency between different browsers:

  • IE8: SPAN.markYellow
  • FF, Safari: span.markYellow

Perhaps the result could be aligned?

comment:28 Changed 13 years ago by Alfonso Martínez de Lizarrondo

The elements are now always lowercase with [6695]

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy