Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend data schema item definition with allowChildren property #9261

Closed
jacekbogdanski opened this issue Mar 17, 2021 · 0 comments · Fixed by #9428
Closed

Extend data schema item definition with allowChildren property #9261

jacekbogdanski opened this issue Mar 17, 2021 · 0 comments · Fixed by #9428
Assignees
Labels
domain:v4-compatibility This issue reports a CKEditor 4 feature/option that's missing in CKEditor 5. type:improvement This issue reports a possible enhancement of an existing feature.

Comments

@jacekbogdanski
Copy link
Member

📝 Provide a description of the improvement

Currently, to allow additional model children, we have to go with 2 steps:

  1. Register new model schema definition:
editor.model.schema.register( 'custom-model', {
  allowIn: '$root'
} );
  1. Extend existing model with allowIn property:
editor.model.schema.extend( '$text', {
  allowIn: 'custom-model'
} );

This code is so often used (especially for $text model) that we could improve it by extending current SchemaItemDefinition with additional member allowChildren which would simplify above code to:

editor.model.schema.register( 'custom-model', {
  allowIn: '$root',
  allowChildren: '$text'
} );

Of course, it can be used for other model elements, the feature is not restricted to $text node only:

editor.model.schema.register( 'custom-model', {
  allowIn: '$root',
  allowChildren: [ '$text', 'listItem' ]
} );

The new property should make sure if the children element is already registered or throw an error otherwise.


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

@jacekbogdanski jacekbogdanski added type:improvement This issue reports a possible enhancement of an existing feature. squad:compat domain:v4-compatibility This issue reports a CKEditor 4 feature/option that's missing in CKEditor 5. labels Mar 17, 2021
@jacekbogdanski jacekbogdanski added this to the iteration 42 milestone Mar 17, 2021
@jacekbogdanski jacekbogdanski self-assigned this Mar 17, 2021
@Mgsy Mgsy modified the milestones: iteration 43, iteration 42 Apr 15, 2021
niegowski added a commit that referenced this issue Apr 16, 2021
Features (engine): Introduced the `SchemaItemDefinition#allowChildren` property simplifying defining which other items are allowed inside this schema item definition. Closes #9261.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:v4-compatibility This issue reports a CKEditor 4 feature/option that's missing in CKEditor 5. type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants