ckeditor / ckeditor5

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.
https://ckeditor.com/ckeditor-5
Other
9.66k stars 3.71k forks source link

Validation rules on editable widgets #15364

Open Kocal opened 1 year ago

Kocal commented 1 year ago

📝 Provide a description of the new feature

Hi everyone! I'm sorry if this issues is duplicated, but I didn't find anything there on GitHub nor on documentation.

While implementing a custom BlockQuote plugin (when following https://ckeditor.com/docs/ckeditor5/latest/tutorials/widgets/implementing-a-block-widget.html), with 3 editable widgets:

https://github.com/ckeditor/ckeditor5/assets/2103975/69996f7b-ed42-4beb-b960-0683471fb1c2

I was wondering if it's possible to attach validation rules to editable widget?

Like, here, I would like to mark the content editable widget as required, if it's not filled then an error message should appears.

Maybe this can be added to the schema definition, or maybe an option to viewWriter.createEditableElement()?

Thanks :)


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

Witoso commented 1 year ago

Thanks for the request!

if it's not filled then an error message should appears.

I wonder how the logic for this would be implemented. It's also not filled when you create a widget. What's the trigger for that? What do you mean by error?

Kocal commented 1 year ago

Hi!

I wonder how the logic for this would be implemented. It's also not filled when you create a widget

I know some form validation library works with a state "touched" or "dirty", to know if the user typed in the field or not.

What's the trigger for that?

I suppose this can be done on keyup, maybe with a configurable debounce.

Or, maybe this can be triggered when a form is submitted/an action is performed? An HTML5 could block the form submission.

What do you mean by error?

A red text below the field, telling the user what's wrong with the value.

CKEditorBot commented 4 days ago

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.