@ckeditor/ckeditor5-paragraph 37.0.1 → 38.0.0-rc.0

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-paragraph",
3
- "version": "37.0.1",
3
+ "version": "38.0.0-rc.0",
4
4
  "description": "Paragraph feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,20 +12,20 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "@ckeditor/ckeditor5-core": "^37.0.1",
16
- "@ckeditor/ckeditor5-ui": "^37.0.1",
17
- "@ckeditor/ckeditor5-utils": "^37.0.1"
15
+ "@ckeditor/ckeditor5-core": "^38.0.0-rc.0",
16
+ "@ckeditor/ckeditor5-ui": "^38.0.0-rc.0",
17
+ "@ckeditor/ckeditor5-utils": "^38.0.0-rc.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@ckeditor/ckeditor5-basic-styles": "^37.0.1",
21
- "@ckeditor/ckeditor5-clipboard": "^37.0.1",
22
- "@ckeditor/ckeditor5-editor-classic": "^37.0.1",
23
- "@ckeditor/ckeditor5-engine": "^37.0.1",
24
- "@ckeditor/ckeditor5-enter": "^37.0.1",
25
- "@ckeditor/ckeditor5-heading": "^37.0.1",
26
- "@ckeditor/ckeditor5-link": "^37.0.1",
27
- "@ckeditor/ckeditor5-typing": "^37.0.1",
28
- "@ckeditor/ckeditor5-undo": "^37.0.1",
20
+ "@ckeditor/ckeditor5-basic-styles": "^38.0.0-rc.0",
21
+ "@ckeditor/ckeditor5-clipboard": "^38.0.0-rc.0",
22
+ "@ckeditor/ckeditor5-editor-classic": "^38.0.0-rc.0",
23
+ "@ckeditor/ckeditor5-engine": "^38.0.0-rc.0",
24
+ "@ckeditor/ckeditor5-enter": "^38.0.0-rc.0",
25
+ "@ckeditor/ckeditor5-heading": "^38.0.0-rc.0",
26
+ "@ckeditor/ckeditor5-link": "^38.0.0-rc.0",
27
+ "@ckeditor/ckeditor5-typing": "^38.0.0-rc.0",
28
+ "@ckeditor/ckeditor5-undo": "^38.0.0-rc.0",
29
29
  "typescript": "^4.8.4",
30
30
  "webpack": "^5.58.1",
31
31
  "webpack-cli": "^4.9.0"
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @module paragraph/insertparagraphcommand
7
7
  */
8
- import { Command } from '@ckeditor/ckeditor5-core';
8
+ import { Command, type Editor } from '@ckeditor/ckeditor5-core';
9
9
  import type { Position } from '@ckeditor/ckeditor5-engine';
10
10
  /**
11
11
  * The insert paragraph command. It inserts a new paragraph at a specific
@@ -25,6 +25,7 @@ import type { Position } from '@ckeditor/ckeditor5-engine';
25
25
  * **Note**: This command moves the selection to the inserted paragraph.
26
26
  */
27
27
  export default class InsertParagraphCommand extends Command {
28
+ constructor(editor: Editor);
28
29
  /**
29
30
  * Executes the command.
30
31
  *
@@ -24,6 +24,11 @@ import { Command } from '@ckeditor/ckeditor5-core';
24
24
  * **Note**: This command moves the selection to the inserted paragraph.
25
25
  */
26
26
  export default class InsertParagraphCommand extends Command {
27
+ constructor(editor) {
28
+ super(editor);
29
+ // Since this command passes position in execution block instead of selection, it should be checked directly.
30
+ this._isEnabledBasedOnSelection = false;
31
+ }
27
32
  /**
28
33
  * Executes the command.
29
34
  *
@@ -36,6 +41,10 @@ export default class InsertParagraphCommand extends Command {
36
41
  const model = this.editor.model;
37
42
  const attributes = options.attributes;
38
43
  let position = options.position;
44
+ // Don't execute command if position is in non-editable place.
45
+ if (!model.canEditAt(position)) {
46
+ return;
47
+ }
39
48
  model.change(writer => {
40
49
  const paragraph = writer.createElement('paragraph');
41
50
  if (attributes) {
@@ -5,12 +5,13 @@
5
5
  /**
6
6
  * @module paragraph/paragraphcommand
7
7
  */
8
- import { Command } from '@ckeditor/ckeditor5-core';
8
+ import { Command, type Editor } from '@ckeditor/ckeditor5-core';
9
9
  import type { Selection, DocumentSelection } from '@ckeditor/ckeditor5-engine';
10
10
  /**
11
11
  * The paragraph command.
12
12
  */
13
13
  export default class ParagraphCommand extends Command {
14
+ constructor(editor: Editor);
14
15
  /**
15
16
  * The value of the command. Indicates whether the selection start is placed in a paragraph.
16
17
  *
@@ -11,6 +11,11 @@ import { first } from '@ckeditor/ckeditor5-utils';
11
11
  * The paragraph command.
12
12
  */
13
13
  export default class ParagraphCommand extends Command {
14
+ constructor(editor) {
15
+ super(editor);
16
+ // Since this command may pass selection in execution block, it should be checked directly.
17
+ this._isEnabledBasedOnSelection = false;
18
+ }
14
19
  /**
15
20
  * @inheritDoc
16
21
  */
@@ -33,8 +38,13 @@ export default class ParagraphCommand extends Command {
33
38
  execute(options = {}) {
34
39
  const model = this.editor.model;
35
40
  const document = model.document;
41
+ const selection = options.selection || document.selection;
42
+ // Don't execute command if selection is in non-editable place.
43
+ if (!model.canEditAt(selection)) {
44
+ return;
45
+ }
36
46
  model.change(writer => {
37
- const blocks = (options.selection || document.selection).getSelectedBlocks();
47
+ const blocks = selection.getSelectedBlocks();
38
48
  for (const block of blocks) {
39
49
  if (!block.is('element', 'paragraph') && checkCanBecomeParagraph(block, model.schema)) {
40
50
  writer.rename(block, 'paragraph');