@ckeditor/ckeditor5-code-block 0.0.0-nightly-20240604.0 → 0.0.0-nightly-20240604.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-code-block",
3
- "version": "0.0.0-nightly-20240604.0",
3
+ "version": "0.0.0-nightly-20240604.1",
4
4
  "description": "Code block feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,7 +13,7 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "ckeditor5": "0.0.0-nightly-20240604.0",
16
+ "ckeditor5": "0.0.0-nightly-20240604.1",
17
17
  "lodash-es": "4.17.21"
18
18
  },
19
19
  "author": "CKSource (http://cksource.com/)",
@@ -63,8 +63,6 @@ export default class CodeBlockEditing extends Plugin {
63
63
  const schema = editor.model.schema;
64
64
  const model = editor.model;
65
65
  const view = editor.editing.view;
66
- const listEditing = editor.plugins.has('ListEditing') ?
67
- editor.plugins.get('ListEditing') : null;
68
66
  const normalizedLanguagesDefs = getNormalizedAndLocalizedLanguageDefinitions(editor);
69
67
  // The main command.
70
68
  editor.commands.add('codeBlock', new CodeBlockCommand(editor));
@@ -85,26 +83,19 @@ export default class CodeBlockEditing extends Plugin {
85
83
  schema.register('codeBlock', {
86
84
  allowWhere: '$block',
87
85
  allowChildren: '$text',
88
- isBlock: true,
89
- allowAttributes: ['language']
86
+ // Disallow `$inlineObject` and its derivatives like `inlineWidget` inside `codeBlock` to ensure that only text,
87
+ // not other inline elements like inline images, are allowed. This maintains the semantic integrity of code blocks.
88
+ disallowChildren: '$inlineObject',
89
+ allowAttributes: ['language'],
90
+ allowAttributesOf: '$listItem',
91
+ isBlock: true
90
92
  });
91
- // Allow all list* attributes on `codeBlock` (integration with DocumentList).
92
- // Disallow all attributes on $text inside `codeBlock`.
93
- schema.addAttributeCheck((context, attributeName) => {
94
- if (context.endsWith('codeBlock') &&
95
- listEditing && listEditing.getListAttributeNames().includes(attributeName)) {
96
- return true;
97
- }
93
+ // Disallow all attributes on `$text` inside `codeBlock`.
94
+ schema.addAttributeCheck(context => {
98
95
  if (context.endsWith('codeBlock $text')) {
99
96
  return false;
100
97
  }
101
98
  });
102
- // Disallow object elements inside `codeBlock`. See #9567.
103
- editor.model.schema.addChildCheck((context, childDefinition) => {
104
- if (context.endsWith('codeBlock') && childDefinition.isObject) {
105
- return false;
106
- }
107
- });
108
99
  // Conversion.
109
100
  editor.editing.downcastDispatcher.on('insert:codeBlock', modelToViewCodeBlockInsertion(model, normalizedLanguagesDefs, true));
110
101
  editor.data.downcastDispatcher.on('insert:codeBlock', modelToViewCodeBlockInsertion(model, normalizedLanguagesDefs));