Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10353 closed Bug (invalid)

CKEditor clears attributes when switching from source to design view

Reported by: Dave Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc: dave@…

Description

If you open CKEditor and select "source" view and assign an attribute to an HTML element (e.g. <p class="test">) and then go back to normal view and back to source view the attribute is gone (e.g. <p>).

This applies to other attributes as well. I tested with several including "id", "name", and "xyz"

Change History (6)

comment:1 Changed 11 years ago by Dave

Resolution: invalid
Status: newclosed

comment:2 Changed 11 years ago by Dave

realized the "bug" was caused by the advanced content filter. Note: to disable this filter you can set CKEDITOR.config.allowedContent to 'true'. More information can be found here: http://docs.ckeditor.com/#!/guide/dev_advanced_content_filter

comment:3 Changed 11 years ago by Piotrek Koszuliński

I advice you to configure ACF (e.g. using extraAllowedContent) rather than disabling it - it would ensure better quality of editor's output and better experience while pasting.

comment:4 Changed 11 years ago by Dave

@Reinmar, thanks for the information. However after reviewing the documentation I couldn't find any way to globally allow users to add specific attributes for all allowed HTML tags. For example I would have to create separate rules to allow users to add "class" attributes to div tags, p tags, table tags, etc... I would then have to create separate rules for other attributes like "ID" as well. My config file would be massive if I had to do that.

It's a shame there isn't a way to globally allow certain attributes like "class", "style", "id", etc... to all allowed HTML tags.

comment:5 Changed 11 years ago by Jakub Ś

Keywords: soruce attributes clearing removed
Version: 4.2 (GitHub - major)

It's a shame there isn't a way to globally allow certain attributes like "class", "style", "id", etc... to all allowed HTML tags.

Following docs I have found:

Asterisk used in the element list means: "This rule accepts the following properties for all elements, but not the elements themselves; there has to be another rule accepting these elements explicitly". p h1; a[!href]; *[id]


What about something like p h1; *[id,width]; *(*); *{*} or even p h1; *[*]; *(*); *{*}? That way you have elements you want to have in editor plus allowed all attributes (in second case), styles and classes. Seems to me that only thing you would have to define is list of elements.

comment:6 Changed 11 years ago by Piotrek Koszuliński

j.swiderski is right - it is possible and it was described in documentation.

Even better example for you would be to use extraAllowedContent: '*[*](*)' what would allow all classes and attributes on all elements allowed by default editor configuration (which is based on loaded features).

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