Skip to content

Conversation

@i-just
Copy link
Contributor

@i-just i-just commented Jun 9, 2025

Description

When you define a CKEditor Config, the selected “Heading Levels” settings should be respected even if some of them are later not listed under the “Config Options”.

With the options that do not set the defaults when you drag the toolbar item (e.g. TableConfig), there is a default config that’s being applied even though you don’t see it under “Config Options”. If you want to add an option, you need to repeat the defaults and add to them. For example, the default table config will give you row, column and merge buttons:

table: {contentToolbar: ['tableRow', 'tableColumn', 'mergeTableCells']}

If you want to add table properties to that list, you need to repeat the values from the last link and add tableProperties like so:

table: {contentToolbar: [ 'tableRow', 'tableColumn', 'mergeTableCells', 'tableProperties']}

However, the heading options are a bit special as those are tied not only to the “Config Options” but also to the “Heading Levels” setting.

This PR ensures that when it comes to headings, the “Config Options” are only applied if the corresponding item is checked under the “Heading Levels”.

So, if you only selected “Heading 2” and “Heading 3” under “Heading Levels”, but under “Config Options”, you have the following:

heading: {
    options: [
        { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
        { model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
        { model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
        { model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' }
    ]
}

only paragraph, heading2 and heading3 from the above JS will be used.

Screenshot 2025-06-09 at 15 53 10

For clarity, I also removed the defaults listed here, so that if you have a config that doesn’t have the “Heading” toolbar item in it, and then you drag it in, you don’t see any defaults under “Config Options”.

Related issues

#431

@i-just i-just requested a review from brandonkelly as a code owner June 9, 2025 14:59
@brandonkelly brandonkelly merged commit 3443c46 into 3.x Aug 11, 2025
@brandonkelly brandonkelly deleted the bugfix/431-heading-levels-and-config-options branch August 11, 2025 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants