Account created on 21 July 2022, almost 2 years ago
#

Recent comments

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!

Production build 0.69.0 2024