ckeditor / ckeditor4-angular

Official CKEditor 4 Angular component.
Other
55 stars 32 forks source link

Unable to add richCombo using editor.ui.addRichCombo() #101

Closed jpmrcado closed 4 years ago

jpmrcado commented 4 years ago

Are you reporting a feature request or a bug?

Bug

Provide detailed reproduction steps (if any)

Please see sample here (with workaround I'm currently using) https://stackblitz.com/edit/github-emmt7u?file=src%2Fapp%2Fsimple-usage%2Fsimple-usage.component.ts

I'm not sure if this really is a bug or I'm doing something incorrectly with my integration. I used the top editor's ready event to attempt to add a richcombo but is not rendering.

The bottom editor used a modified ckeditor component to emit the instanceCreated event which I then used to call editor.ui.addRichCombo() to work around the issue

Expected result

On load, calling editor.ui.addRichCombo() should display a richcombo in the editor.

Actual result

On load, calling editor.ui.addRichCombo() does not display a richcombo in the editor.

Other details

f1ames commented 4 years ago

Hello @jpmrcado,

The onReady event is a little too late to add stuff to the toolbar since it is already rendered and new entities would not be added - so this work as intended.

Your workaround makes sense, however, in most cases adding stuff to toolbar is done by plugins which has it's own lifecycle (see docs), so that would be the proper solution here. You may also try customizing component config and config.on to attach listeners, but that will be another workaround.

Since your custom change adds another place to hook into component lifecycle, feel free to wrap it in the PR so we can add it to the integration :+1:

jpmrcado commented 4 years ago

I decided to go with the plugin approach to fix my issue.

Looks like my work around might cause unwanted behavior when used with multiple ckeditor instances since the event I used was part of CKEDITOR instead of CKEDITOR.editor so I'll just leave it at that.

Thank you!