ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

[TS] Suggest and validate names of plugins and commands at type level

Open filipsobol opened this issue 2 years ago • 5 comments

Currently, TypeScript doesn't suggest names for available plugins and commands. It also doesn't check whether plugins or commands with the given name even exist.

Ideally, TypeScript should suggest names of registered plugins and commands, and show errors if we pass an invalid name.

filipsobol avatar Mar 23 '23 14:03 filipsobol

What about editor.execute()? AFAIU the augmentation was supposed to ensure exactly that.

Reinmar avatar Mar 23 '23 14:03 Reinmar

editor.execute() behaves exactly the same.

filipsobol avatar Mar 23 '23 15:03 filipsobol

This is working as expected. We did not want to force plugin developers to augment PluginsMap and CommandsMap so we added a fallback for not registered plugins and commands:

https://github.com/ckeditor/ckeditor5/blob/e40ee9cdef3ff420bb6454bf0e209c65e0bf187c/packages/ckeditor5-core/src/plugincollection.ts#L648-L650

https://github.com/ckeditor/ckeditor5/blob/e40ee9cdef3ff420bb6454bf0e209c65e0bf187c/packages/ckeditor5-core/src/commandcollection.ts#L133-L135

The progressive improvement with those maps is that if you specify a mapped command name then other parameters are validated:

image

Same for PluginsMap, it provides a plugin type for a specified plugin name:

image

niegowski avatar Mar 24 '23 10:03 niegowski

I guess the scope of this would be to include information in the docs on how to properly augment Plugins and Commands.

Witoso avatar May 08 '23 07:05 Witoso

There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.

CKEditorBot avatar May 08 '24 03:05 CKEditorBot

We've closed your issue due to inactivity. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).

CKEditorBot avatar Jun 07 '24 03:06 CKEditorBot