Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to apply CKEditor 5 Bold Plugin to my own inline elements? #6033

Closed
mike-hogan opened this issue Dec 29, 2019 · 1 comment
Closed

How to apply CKEditor 5 Bold Plugin to my own inline elements? #6033

mike-hogan opened this issue Dec 29, 2019 · 1 comment
Labels
resolution:duplicate This issue is a duplicate of another issue and was merged into it. type:task This issue reports a chore (non-production change) and other types of "todos".

Comments

@mike-hogan
Copy link

I followed the Implementing an inline widget tutorial at https://ckeditor.com/docs/ckeditor5/latest/framework/guides/tutorials/implementing-an-inline-widget.html.

I want to extend it to enable bolding of placeholders.

I added this.editor.model.schema.extend( 'placeholder', { allowAttributes: 'bold' } ); to PlaceholderEditing.init(), so it now looks like this:

    init() {
        this._defineSchema();
        this._defineConverters();

        this.editor.commands.add('placeholder', new PlaceholderCommand(this.editor));

        this.editor.editing.mapper.on(
            'viewToModelPosition',
            viewToModelPositionOutsideModelElement(this.editor.model, viewElement => viewElement.hasClass('placeholder'))
        );
        this.editor.config.define( 'placeholderConfig', {
            types: [ 'date', 'first name', 'surname' ]
        } );
        this.editor.model.schema.extend( 'placeholder', { allowAttributes: 'bold' } ); //ADDED
    }

Then I wrapped my placeholder in <strong></strong>, like so:

<strong><span class="placeholder" >{mike}</span></strong>

The inspector shows me the attribute gets added to placeholder in the model, like so:

https://i.stack.imgur.com/zDVNm.png

But, the rendered html in the editor does not have <strong></strong> downcast on it

https://i.stack.imgur.com/sHsYP.png

How can I make this work?

Thanks.

@mike-hogan mike-hogan added the type:task This issue reports a chore (non-production change) and other types of "todos". label Dec 29, 2019
@mike-hogan mike-hogan changed the title How to apply CKEDitor 5 Bold Plugin to my own inline elements? How to apply CKEditor 5 Bold Plugin to my own inline elements? Dec 29, 2019
@Mgsy
Copy link
Member

Mgsy commented Dec 30, 2019

Hi! Unfortunately, styling inline widgets isn't supported and introducing it will require some bigger changes. Please, read the discussion in the proper ticket - #1633.

@Mgsy Mgsy closed this as completed Dec 30, 2019
@Mgsy Mgsy added the resolution:duplicate This issue is a duplicate of another issue and was merged into it. label Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution:duplicate This issue is a duplicate of another issue and was merged into it. type:task This issue reports a chore (non-production change) and other types of "todos".
Projects
None yet
Development

No branches or pull requests

2 participants