- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Great, but … that's a lot of code 😅 I don't think anybody will find themselves with enough free time to carefully read & study all that. You have a better chance of getting help if you first distill it down to the essence to reproduce this 😊
- 🇺🇸United States bajah1701
Well my hands are tied here. How to reproduce it would eventually require writing lots of boilerplate code anyway. I really don't know how else I can explain the problem other than what I have already written.
Hi @bajah1701!
If I understand properly, you would like to have the possibility to insert an `` element, that will have additional classes, i.e. `btn` and `btn-primary`. I believe, the easiest way to achieve that, would be using existing link API, so you don't have to create a custom conversion.
The link plugin introduces the concept of decorators that allows the integrator to define which additional attributes the link element should have. The decorator could be automatic (added automatically to the element) or manual (toggled with UI). Learn more about automatic decorators here and manual decorators here.
The example configuration might look as below:
link: { decorators: { isButton: { mode: 'manual', label: 'Is button', classes: [ 'btn', 'btn-primary' ] } } }
Which will result in additional button in the link form:
and in the DOM:
If you want to keep the separate button for your plugin, you can still take advantage of Link API, get the input from your UI and simply run the Link command and pass the decorator name as an argument
editor.execute( 'link', 'https://ckeditor.com', { linkIsButton: true } )
Note that the decorator attribute name starts with the `link` prefix, so the pattern is `link` + name from your configuration (starting from uppercase).
Let me know if it helps!
- 🇺🇸United States bajah1701
@mgsy Thank you, thank you, thank you. I was not aware that this was possible. Greatly appreciated.
- Status changed to Closed: works as designed
over 1 year ago 9:41pm 14 April 2023