Skip to content

Commit

Permalink
Minor docs improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed May 16, 2024
1 parent ec9b919 commit 3b02216
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/ckeditor5-code-block/src/codeblockediting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ export default class CodeBlockEditing extends Plugin {
schema.register( 'codeBlock', {
allowWhere: '$block',
allowChildren: '$text',
// `$inlineObject` inherits from `$text`, so it would be allowed by `codeBlock` element. This would allow elements like inline
// image inside a code block. This is an incorrect situation, as we want only text inside `codeBlock`.
// Disallow `$inlineObject` and its derivatives like `inlineWidget` inside `codeBlock` to ensure that only text,
// not other inline elements like inline images, are allowed. This maintains the semantic integrity of code blocks.
disallowChildren: '$inlineObject',
allowAttributes: [ 'language' ],
allowAttributesOf: '$listItem',
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-code-block/tests/codeblockediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ describe( 'CodeBlockEditing', () => {
} );

it( 'disallows $inlineObject', () => {
// `$inlineObject` inherits from `$text`, so it would be allowed by `codeBlock` element. This would allow elements like inline
// image inside a code block. This is an incorrect situation, as we want only text inside `codeBlock`.
// Disallow `$inlineObject` and its derivatives like `inlineWidget` inside `codeBlock` to ensure that only text,
// not other inline elements like inline images, are allowed. This maintains the semantic integrity of code blocks.
model.schema.register( 'inlineWidget', {
inheritAllFrom: '$inlineObject'
} );
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-engine/docs/framework/deep-dive/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Both the `{@link module:engine/model/schema~SchemaItemDefinition#allowIn}` and `

## Disallowing structures

The schema, in addition to allowing certain structures, can be also used to ensure some structures are explicitly disallowed. This can be achieved with the use of disallow rules.
The schema, in addition to allowing certain structures, can also be used to ensure some structures are explicitly disallowed. This can be achieved with the use of disallow rules.

Typically, you will use {@link module:engine/model/schema~SchemaItemDefinition#disallowChildren} property for that. It can be used to define which nodes are disallowed inside given element:

Expand Down Expand Up @@ -126,7 +126,7 @@ This changes how schema rules are resolved. `baseChild` will still be disallowed

Of course, you can mix `allowIn` with `disallowChildren` as well as `allowChildren` with `disallowIn`.

Finally, a situation may come up, when you want to inherit from an item which is already disallowed, but the new element should be re-allowed again. In this case the definitions should look like this:
Finally, a situation may come up, when you want to inherit from an item which is already disallowed, but the new element should be re-allowed again. In this case, the definitions should look like this:

```js
schema.register( 'baseParent', { inheritAllFrom: 'paragraph', disallowChildren: [ 'imageInline' ] } );
Expand Down

0 comments on commit 3b02216

Please sign in to comment.