ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

Formatting custom html elements in source-editing

Open terjetorma opened this issue 7 months ago • 1 comments

📝 Provide a description of the improvement

Allow custom html elements to be formatted alongside other html elements in the source-editing package.

How the feature works now and what you'd like to change? Formatting of html-block-type-elements in the SourceEditing plugin adds newlines and indentation. This is done via the formatHtml-function in the ckeditor5-utils-package. The function uses a fixed list of html-tags to parse (elementsToFormat).

In my scenario, I have a custom html element that I would like to format the same way as other elements in this list. One solution could be to allow for extending this list, e.g. via config:

config.sourceEdting: {
   customElementsToFormat: [
      { name: 'my-custom-tag', isVoid: false }
   ]
}

If you'd like to see this improvement implemented, add a 👍 reaction to this post.

terjetorma avatar Jun 11 '25 10:06 terjetorma

Yeah, it's a valid idea. It should be possible to extend the configuration of the formatter. I'm only not sure if I'd go with doinh this via the config, or via some propo in the plugin interface.

Reinmar avatar Jun 12 '25 07:06 Reinmar