Opened 11 years ago

Closed 11 years ago

#11608 closed Bug (invalid)

Selecting a style with attributes and then selecting a style with styles (but no attributes) retains the original attributes (and vice versa)

Reported by: hel Owned by:
Priority: Normal Milestone:
Component: Core : Styles Version: 4.3.1
Keywords: Cc:

Description

Assuming the presence of the following style rules:

{ name: 'CSS Style', element: 'span', attributes: { 'class': 'my_style' } },
{ name: 'Marker: Yellow', element: 'span', styles: { 'background-color': 'Yellow' } }

Switching between the above styles using the Styles drop-down appears to be retaining styles/attributes from the originally selected style. This also results in both styles being selected when the Styles drop-down list is displayed.

Looking at the source, this appears to be due to the following lines of code at line number 1355 within the core\style.js file:

// #6226: attributes should be copied before the new ones are applied
if ( element )
   element.copyAttributes( el );

This looks to have been introduced to preserve the BIDI language direction when applying block formats. See ticket #6226.

Change History (2)

comment:1 Changed 11 years ago by hel

Apologies. I think I misunderstood how the editor styling works.

In our configuration I have included paragraph formats in the Styles drop-down, to avoid having a separate Format drop-down, and with the following style rules I was under the impression that selecting the Normal style would revert to a simple P and remove all other styling (because it does not have any attributes/styles defined).

{ name: "Normal", element: "p" }, { name: "Snippet", element: "p", attributes: {class: "snippet"}}

I no longer believe this to be the case.

Sorry again!

comment:2 Changed 11 years ago by Jakub Ś

Resolution: invalid
Status: newclosed

Yes, one style doesn't remove/replace another.

You can have span with attributes and span with styles and they both can be assigned. When you select this this part of text with styles assigned (best with elements path) you will see both styles selected. You can remove the style by deselecting it in styles droprown.

In your case, styled P is also P that is why you see them both selected? This is one of reasons (but not the only) we have also format dropdown.

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