From 3b022161d172a79962cef2d9f45fbac0e5c1bd3b Mon Sep 17 00:00:00 2001 From: Szymon Cofalik Date: Thu, 16 May 2024 18:48:12 +0200 Subject: [PATCH] Minor docs improvements. --- packages/ckeditor5-code-block/src/codeblockediting.ts | 4 ++-- packages/ckeditor5-code-block/tests/codeblockediting.js | 4 ++-- packages/ckeditor5-engine/docs/framework/deep-dive/schema.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/ckeditor5-code-block/src/codeblockediting.ts b/packages/ckeditor5-code-block/src/codeblockediting.ts index 668dd04d4b9..d9f62f4b48c 100644 --- a/packages/ckeditor5-code-block/src/codeblockediting.ts +++ b/packages/ckeditor5-code-block/src/codeblockediting.ts @@ -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', diff --git a/packages/ckeditor5-code-block/tests/codeblockediting.js b/packages/ckeditor5-code-block/tests/codeblockediting.js index b1284523e45..9864e6e8baf 100644 --- a/packages/ckeditor5-code-block/tests/codeblockediting.js +++ b/packages/ckeditor5-code-block/tests/codeblockediting.js @@ -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' } ); diff --git a/packages/ckeditor5-engine/docs/framework/deep-dive/schema.md b/packages/ckeditor5-engine/docs/framework/deep-dive/schema.md index 5a7b80c921f..4ce9c44bb0e 100644 --- a/packages/ckeditor5-engine/docs/framework/deep-dive/schema.md +++ b/packages/ckeditor5-engine/docs/framework/deep-dive/schema.md @@ -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: @@ -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' ] } );