Skip to content

How to check if editor has no content/is empty? #401

Closed
ckeditor/ckeditor5-engine
#1656
@oskarwrobel

Description

In most of cases editor will have an empty paragraph on init. So getData() == '' will be false almost all the time. What if someone adds some spaces or new lines?
For example, you use CKE as an input to write posts or comments and you want to prevent user from submitting form until content.trim() == ''. How to do it?

My first thought was to add an option getData( { trim: true } ) or create method isEmpty( document ) but @pjasiun and @scofalik pointed out that it won't be so easy because there is no common rule for every feature that defines when feature is empty. Eg. Can table be empty? or image?

Metadata

Assignees

Labels

type:featureThis issue reports a feature request (an idea for a new functionality or a missing option).

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions