Skip to content

Difficulties modifying style dropdown due to use of AlloyEditor.Strings #301

Closed
@dantman

Description

@dantman

Changing the list of styles in the style dropdown (Normal, Header 1-2, Formatted, ...) is difficult.

The config you use is understandable, in toolbars.styles.selections[name: 'text'].buttons[] config instead of 'styles' you pass { name: 'styles', cfg: { styles: styles } } where styles is an array that matches the default array in _getStyles modified to suit your needs.

[
    {
        name: AlloyEditor.Strings.h1,
        style: {
            element: 'h1'
        }
    },
    {
        name: AlloyEditor.Strings.h2,
        style: {
            element: 'h2'
        }
    },
    {
        name: AlloyEditor.Strings.formatted,
        style: {
            element: 'pre'
        }
    },
    {
        name: AlloyEditor.Strings.cite,
        style: {
            element: 'cite'
        }
    },
    {
        name: AlloyEditor.Strings.code,
        style: {
            element: 'code'
        }
    }
]

The problem is AlloyEditor.Strings. At the time you pass config AlloyEditor.Strings isn't filled. In fact, AlloyEditor doesn't trigger the loading of the necessary lang data until after you create an AlloyEditor.Core instance using the AlloyEditor.editable function you're supposed to pass the config to. And if you leave these out of the config, then your styles list has no text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions