@ckeditor/ckeditor5-paragraph 36.0.1 → 37.0.0-alpha.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": "36.0.1",
3
+ "version": "37.0.0-alpha.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": "^36.0.1",
16
- "@ckeditor/ckeditor5-ui": "^36.0.1",
17
- "@ckeditor/ckeditor5-utils": "^36.0.1"
15
+ "@ckeditor/ckeditor5-core": "^37.0.0-alpha.0",
16
+ "@ckeditor/ckeditor5-ui": "^37.0.0-alpha.0",
17
+ "@ckeditor/ckeditor5-utils": "^37.0.0-alpha.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@ckeditor/ckeditor5-basic-styles": "^36.0.1",
21
- "@ckeditor/ckeditor5-clipboard": "^36.0.1",
22
- "@ckeditor/ckeditor5-editor-classic": "^36.0.1",
23
- "@ckeditor/ckeditor5-engine": "^36.0.1",
24
- "@ckeditor/ckeditor5-enter": "^36.0.1",
25
- "@ckeditor/ckeditor5-heading": "^36.0.1",
26
- "@ckeditor/ckeditor5-link": "^36.0.1",
27
- "@ckeditor/ckeditor5-typing": "^36.0.1",
28
- "@ckeditor/ckeditor5-undo": "^36.0.1",
20
+ "@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.0",
21
+ "@ckeditor/ckeditor5-clipboard": "^37.0.0-alpha.0",
22
+ "@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.0",
23
+ "@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
24
+ "@ckeditor/ckeditor5-enter": "^37.0.0-alpha.0",
25
+ "@ckeditor/ckeditor5-heading": "^37.0.0-alpha.0",
26
+ "@ckeditor/ckeditor5-link": "^37.0.0-alpha.0",
27
+ "@ckeditor/ckeditor5-typing": "^37.0.0-alpha.0",
28
+ "@ckeditor/ckeditor5-undo": "^37.0.0-alpha.0",
29
29
  "typescript": "^4.8.4",
30
30
  "webpack": "^5.58.1",
31
31
  "webpack-cli": "^4.9.0"
@@ -54,5 +54,6 @@
54
54
  "scripts": {
55
55
  "build": "tsc -p ./tsconfig.release.json",
56
56
  "postversion": "npm run build"
57
- }
57
+ },
58
+ "types": "src/index.d.ts"
58
59
  }
package/src/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module paragraph
7
+ */
8
+ export { default as Paragraph } from './paragraph';
9
+ export { default as ParagraphButtonUI } from './paragraphbuttonui';
10
+ export type { default as ParagraphCommand } from './paragraphcommand';
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module paragraph/insertparagraphcommand
7
+ */
8
+ import { Command } from '@ckeditor/ckeditor5-core';
9
+ import type { Position } from '@ckeditor/ckeditor5-engine';
10
+ /**
11
+ * The insert paragraph command. It inserts a new paragraph at a specific
12
+ * {@link module:engine/model/position~Position document position}.
13
+ *
14
+ * ```ts
15
+ * // Insert a new paragraph before an element in the document.
16
+ * editor.execute( 'insertParagraph', {
17
+ * position: editor.model.createPositionBefore( element )
18
+ * } );
19
+ * ```
20
+ *
21
+ * If a paragraph is disallowed in the context of the specific position, the command
22
+ * will attempt to split position ancestors to find a place where it is possible
23
+ * to insert a paragraph.
24
+ *
25
+ * **Note**: This command moves the selection to the inserted paragraph.
26
+ */
27
+ export default class InsertParagraphCommand extends Command {
28
+ /**
29
+ * Executes the command.
30
+ *
31
+ * @param options Options for the executed command.
32
+ * @param options.position The model position at which the new paragraph will be inserted.
33
+ * @param options.attributes Attributes keys and values to set on a inserted paragraph.
34
+ * @fires execute
35
+ */
36
+ execute(options: {
37
+ position: Position;
38
+ attributes: Record<string, unknown>;
39
+ }): void;
40
+ }
41
+ declare module '@ckeditor/ckeditor5-core' {
42
+ interface CommandsMap {
43
+ insertParagraph: InsertParagraphCommand;
44
+ }
45
+ }
@@ -10,27 +10,26 @@ import { Command } from '@ckeditor/ckeditor5-core';
10
10
  * The insert paragraph command. It inserts a new paragraph at a specific
11
11
  * {@link module:engine/model/position~Position document position}.
12
12
  *
13
- * // Insert a new paragraph before an element in the document.
14
- * editor.execute( 'insertParagraph', {
15
- * position: editor.model.createPositionBefore( element )
16
- * } );
13
+ * ```ts
14
+ * // Insert a new paragraph before an element in the document.
15
+ * editor.execute( 'insertParagraph', {
16
+ * position: editor.model.createPositionBefore( element )
17
+ * } );
18
+ * ```
17
19
  *
18
20
  * If a paragraph is disallowed in the context of the specific position, the command
19
21
  * will attempt to split position ancestors to find a place where it is possible
20
22
  * to insert a paragraph.
21
23
  *
22
24
  * **Note**: This command moves the selection to the inserted paragraph.
23
- *
24
- * @extends module:core/command~Command
25
25
  */
26
26
  export default class InsertParagraphCommand extends Command {
27
27
  /**
28
28
  * Executes the command.
29
29
  *
30
- * @param {Object} options Options for the executed command.
31
- * @param {module:engine/model/position~Position} options.position The model position at which
32
- * the new paragraph will be inserted.
33
- * @param {Object} attributes Attributes keys and values to set on a inserted paragraph
30
+ * @param options Options for the executed command.
31
+ * @param options.position The model position at which the new paragraph will be inserted.
32
+ * @param options.attributes Attributes keys and values to set on a inserted paragraph.
34
33
  * @fires execute
35
34
  */
36
35
  execute(options) {
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import { Plugin } from '@ckeditor/ckeditor5-core';
6
+ /**
7
+ * The paragraph feature for the editor.
8
+ *
9
+ * It introduces the `<paragraph>` element in the model which renders as a `<p>` element in the DOM and data.
10
+ *
11
+ * It also brings two editors commands:
12
+ *
13
+ * * The {@link module:paragraph/paragraphcommand~ParagraphCommand `'paragraph'`} command that converts all
14
+ * blocks in the model selection into paragraphs.
15
+ * * The {@link module:paragraph/insertparagraphcommand~InsertParagraphCommand `'insertParagraph'`} command
16
+ * that inserts a new paragraph at a specified location in the model.
17
+ */
18
+ export default class Paragraph extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName(): 'Paragraph';
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ init(): void;
27
+ /**
28
+ * A list of element names which should be treated by the autoparagraphing algorithms as
29
+ * paragraph-like. This means that e.g. the following content:
30
+ *
31
+ * ```html
32
+ * <h1>Foo</h1>
33
+ * <table>
34
+ * <tr>
35
+ * <td>X</td>
36
+ * <td>
37
+ * <ul>
38
+ * <li>Y</li>
39
+ * <li>Z</li>
40
+ * </ul>
41
+ * </td>
42
+ * </tr>
43
+ * </table>
44
+ * ```
45
+ *
46
+ * contains five paragraph-like elements: `<h1>`, two `<td>`s and two `<li>`s.
47
+ * Hence, if none of the features is going to convert those elements the above content will be automatically handled
48
+ * by the paragraph feature and converted to:
49
+ *
50
+ * ```html
51
+ * <p>Foo</p>
52
+ * <p>X</p>
53
+ * <p>Y</p>
54
+ * <p>Z</p>
55
+ * ```
56
+ *
57
+ * Note: The `<td>` containing two `<li>` elements was ignored as the innermost paragraph-like elements
58
+ * have a priority upon conversion.
59
+ */
60
+ static paragraphLikeElements: Set<string>;
61
+ }
62
+ declare module '@ckeditor/ckeditor5-core' {
63
+ interface PluginsMap {
64
+ [Paragraph.pluginName]: Paragraph;
65
+ }
66
+ }
package/src/paragraph.js CHANGED
@@ -19,8 +19,6 @@ import { Plugin } from '@ckeditor/ckeditor5-core';
19
19
  * blocks in the model selection into paragraphs.
20
20
  * * The {@link module:paragraph/insertparagraphcommand~InsertParagraphCommand `'insertParagraph'`} command
21
21
  * that inserts a new paragraph at a specified location in the model.
22
- *
23
- * @extends module:core/plugin~Plugin
24
22
  */
25
23
  export default class Paragraph extends Plugin {
26
24
  /**
@@ -61,33 +59,35 @@ export default class Paragraph extends Plugin {
61
59
  * A list of element names which should be treated by the autoparagraphing algorithms as
62
60
  * paragraph-like. This means that e.g. the following content:
63
61
  *
64
- * <h1>Foo</h1>
65
- * <table>
66
- * <tr>
67
- * <td>X</td>
68
- * <td>
69
- * <ul>
70
- * <li>Y</li>
71
- * <li>Z</li>
72
- * </ul>
73
- * </td>
74
- * </tr>
75
- * </table>
76
- *
77
- * contains five paragraph-like elements: `<h1>`, two `<td>`s and two `<li>`s.
78
- * Hence, if none of the features is going to convert those elements the above content will be automatically handled
79
- * by the paragraph feature and converted to:
80
- *
81
- * <p>Foo</p>
82
- * <p>X</p>
83
- * <p>Y</p>
84
- * <p>Z</p>
85
- *
86
- * Note: The `<td>` containing two `<li>` elements was ignored as the innermost paragraph-like elements
87
- * have a priority upon conversion.
88
- *
89
- * @member {Set.<String>} module:paragraph/paragraph~Paragraph.paragraphLikeElements
90
- */
62
+ * ```html
63
+ * <h1>Foo</h1>
64
+ * <table>
65
+ * <tr>
66
+ * <td>X</td>
67
+ * <td>
68
+ * <ul>
69
+ * <li>Y</li>
70
+ * <li>Z</li>
71
+ * </ul>
72
+ * </td>
73
+ * </tr>
74
+ * </table>
75
+ * ```
76
+ *
77
+ * contains five paragraph-like elements: `<h1>`, two `<td>`s and two `<li>`s.
78
+ * Hence, if none of the features is going to convert those elements the above content will be automatically handled
79
+ * by the paragraph feature and converted to:
80
+ *
81
+ * ```html
82
+ * <p>Foo</p>
83
+ * <p>X</p>
84
+ * <p>Y</p>
85
+ * <p>Z</p>
86
+ * ```
87
+ *
88
+ * Note: The `<td>` containing two `<li>` elements was ignored as the innermost paragraph-like elements
89
+ * have a priority upon conversion.
90
+ */
91
91
  Paragraph.paragraphLikeElements = new Set([
92
92
  'blockquote',
93
93
  'dd',
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module paragraph/paragraphbuttonui
7
+ */
8
+ import { Plugin, type PluginDependencies } from '@ckeditor/ckeditor5-core';
9
+ /**
10
+ * This plugin defines the `'paragraph'` button. It can be used together with
11
+ * {@link module:heading/headingbuttonsui~HeadingButtonsUI} to replace the standard heading dropdown.
12
+ *
13
+ * This plugin is not loaded automatically by the {@link module:paragraph/paragraph~Paragraph} plugin. It must
14
+ * be added manually.
15
+ *
16
+ * ```ts
17
+ * ClassicEditor
18
+ * .create( {
19
+ * plugins: [ ..., Heading, Paragraph, HeadingButtonsUI, ParagraphButtonUI ]
20
+ * toolbar: [ 'paragraph', 'heading1', 'heading2', 'heading3' ]
21
+ * } )
22
+ * .then( ... )
23
+ * .catch( ... );
24
+ * ```
25
+ */
26
+ export default class ParagraphButtonUI extends Plugin {
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ static get requires(): PluginDependencies;
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ init(): void;
35
+ }
@@ -16,15 +16,15 @@ const icon = icons.paragraph;
16
16
  * This plugin is not loaded automatically by the {@link module:paragraph/paragraph~Paragraph} plugin. It must
17
17
  * be added manually.
18
18
  *
19
- * ClassicEditor
20
- * .create( {
21
- * plugins: [ ..., Heading, Paragraph, HeadingButtonsUI, ParagraphButtonUI ]
22
- * toolbar: [ 'paragraph', 'heading1', 'heading2', 'heading3' ]
23
- * } )
24
- * .then( ... )
25
- * .catch( ... );
26
- *
27
- * @extends module:core/plugin~Plugin
19
+ * ```ts
20
+ * ClassicEditor
21
+ * .create( {
22
+ * plugins: [ ..., Heading, Paragraph, HeadingButtonsUI, ParagraphButtonUI ]
23
+ * toolbar: [ 'paragraph', 'heading1', 'heading2', 'heading3' ]
24
+ * } )
25
+ * .then( ... )
26
+ * .catch( ... );
27
+ * ```
28
28
  */
29
29
  export default class ParagraphButtonUI extends Plugin {
30
30
  /**
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module paragraph/paragraphcommand
7
+ */
8
+ import { Command } from '@ckeditor/ckeditor5-core';
9
+ import type { Selection, DocumentSelection } from '@ckeditor/ckeditor5-engine';
10
+ /**
11
+ * The paragraph command.
12
+ */
13
+ export default class ParagraphCommand extends Command {
14
+ /**
15
+ * The value of the command. Indicates whether the selection start is placed in a paragraph.
16
+ *
17
+ * @readonly
18
+ * @observable
19
+ */
20
+ value: boolean;
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ refresh(): void;
25
+ /**
26
+ * Executes the command. All the blocks (see {@link module:engine/model/schema~Schema}) in the selection
27
+ * will be turned to paragraphs.
28
+ *
29
+ * @fires execute
30
+ * @param options Options for the executed command.
31
+ * @param options.selection The selection that the command should be applied to. By default,
32
+ * if not provided, the command is applied to the {@link module:engine/model/document~Document#selection}.
33
+ */
34
+ execute(options?: {
35
+ selection?: Selection | DocumentSelection;
36
+ }): void;
37
+ }
38
+ declare module '@ckeditor/ckeditor5-core' {
39
+ interface CommandsMap {
40
+ paragraph: ParagraphCommand;
41
+ }
42
+ }
@@ -9,8 +9,6 @@ import { Command } from '@ckeditor/ckeditor5-core';
9
9
  import { first } from '@ckeditor/ckeditor5-utils';
10
10
  /**
11
11
  * The paragraph command.
12
- *
13
- * @extends module:core/command~Command
14
12
  */
15
13
  export default class ParagraphCommand extends Command {
16
14
  /**
@@ -28,10 +26,9 @@ export default class ParagraphCommand extends Command {
28
26
  * will be turned to paragraphs.
29
27
  *
30
28
  * @fires execute
31
- * @param {Object} [options] Options for the executed command.
32
- * @param {module:engine/model/selection~Selection|module:engine/model/documentselection~DocumentSelection} [options.selection]
33
- * The selection that the command should be applied to.
34
- * By default, if not provided, the command is applied to the {@link module:engine/model/document~Document#selection}.
29
+ * @param options Options for the executed command.
30
+ * @param options.selection The selection that the command should be applied to. By default,
31
+ * if not provided, the command is applied to the {@link module:engine/model/document~Document#selection}.
35
32
  */
36
33
  execute(options = {}) {
37
34
  const model = this.editor.model;
@@ -46,12 +43,12 @@ export default class ParagraphCommand extends Command {
46
43
  });
47
44
  }
48
45
  }
49
- // Checks whether the given block can be replaced by a paragraph.
50
- //
51
- // @private
52
- // @param {module:engine/model/element~Element} block A block to be tested.
53
- // @param {module:engine/model/schema~Schema} schema The schema of the document.
54
- // @returns {Boolean}
46
+ /**
47
+ * Checks whether the given block can be replaced by a paragraph.
48
+ *
49
+ * @param block A block to be tested.
50
+ * @param schema The schema of the document.
51
+ */
55
52
  function checkCanBecomeParagraph(block, schema) {
56
53
  return schema.checkChild(block.parent, 'paragraph') && !schema.isObject(block);
57
54
  }