@ckeditor/ckeditor5-paragraph 47.6.1 → 48.0.0-alpha.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.
@@ -4,7 +4,7 @@
4
4
  "name": "Paragraph",
5
5
  "className": "Paragraph",
6
6
  "description": "Enables support for adding paragraphs to your content.",
7
- "path": "src/paragraph.js",
7
+ "path": "src/paragraph.ts",
8
8
  "htmlOutput": [
9
9
  {
10
10
  "elements": "p",
package/dist/index.css CHANGED
@@ -2,3 +2,6 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
+
6
+
7
+ /*# sourceMappingURL=index.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.css"],"names":[],"mappings":";;;;;;AAEA,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC","file":"index.css.map","sourcesContent":["\n\n/*# sourceMappingURL=index.css.map */"]}
package/package.json CHANGED
@@ -1,60 +1,41 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-paragraph",
3
- "version": "47.6.1",
3
+ "version": "48.0.0-alpha.1",
4
4
  "description": "Paragraph feature for CKEditor 5.",
5
+ "license": "SEE LICENSE IN LICENSE.md",
6
+ "author": "CKSource (http://cksource.com/)",
7
+ "homepage": "https://ckeditor.com/ckeditor-5",
8
+ "bugs": "https://github.com/ckeditor/ckeditor5/issues",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/ckeditor/ckeditor5.git",
12
+ "directory": "packages/ckeditor5-paragraph"
13
+ },
5
14
  "keywords": [
6
15
  "ckeditor",
7
16
  "ckeditor5",
8
17
  "ckeditor 5",
9
18
  "ckeditor5-feature",
10
- "ckeditor5-plugin",
11
- "ckeditor5-dll"
19
+ "ckeditor5-plugin"
12
20
  ],
13
21
  "type": "module",
14
- "main": "src/index.js",
15
- "dependencies": {
16
- "@ckeditor/ckeditor5-core": "47.6.1",
17
- "@ckeditor/ckeditor5-icons": "47.6.1",
18
- "@ckeditor/ckeditor5-engine": "47.6.1",
19
- "@ckeditor/ckeditor5-ui": "47.6.1",
20
- "@ckeditor/ckeditor5-utils": "47.6.1"
22
+ "main": "./dist/index.js",
23
+ "exports": {
24
+ ".": "./dist/index.js",
25
+ "./dist/*": "./dist/*",
26
+ "./package.json": "./package.json"
21
27
  },
22
- "author": "CKSource (http://cksource.com/)",
23
- "license": "SEE LICENSE IN LICENSE.md",
24
- "homepage": "https://ckeditor.com/ckeditor-5",
25
- "bugs": "https://github.com/ckeditor/ckeditor5/issues",
26
- "repository": {
27
- "type": "git",
28
- "url": "https://github.com/ckeditor/ckeditor5.git",
29
- "directory": "packages/ckeditor5-paragraph"
28
+ "dependencies": {
29
+ "@ckeditor/ckeditor5-core": "48.0.0-alpha.1",
30
+ "@ckeditor/ckeditor5-icons": "48.0.0-alpha.1",
31
+ "@ckeditor/ckeditor5-engine": "48.0.0-alpha.1",
32
+ "@ckeditor/ckeditor5-ui": "48.0.0-alpha.1",
33
+ "@ckeditor/ckeditor5-utils": "48.0.0-alpha.1"
30
34
  },
31
35
  "files": [
32
36
  "dist",
33
- "lang",
34
- "src/**/*.js",
35
- "src/**/*.d.ts",
36
- "theme",
37
37
  "ckeditor5-metadata.json",
38
38
  "CHANGELOG.md"
39
39
  ],
40
- "types": "src/index.d.ts",
41
- "exports": {
42
- ".": {
43
- "types": "./src/index.d.ts",
44
- "import": "./src/index.js",
45
- "default": "./src/index.js"
46
- },
47
- "./dist/*": {
48
- "types": "./src/index.d.ts",
49
- "import": "./dist/*",
50
- "default": "./dist/*"
51
- },
52
- "./src/*": {
53
- "types": "./src/*.d.ts",
54
- "import": "./src/*",
55
- "default": "./src/*"
56
- },
57
- "./ckeditor5-metadata.json": "./ckeditor5-metadata.json",
58
- "./package.json": "./package.json"
59
- }
40
+ "types": "./dist/index.d.ts"
60
41
  }
@@ -1,5 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- export {};
package/src/index.js DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module paragraph
7
- */
8
- export { Paragraph } from './paragraph.js';
9
- export { ParagraphButtonUI } from './paragraphbuttonui.js';
10
- export { ParagraphCommand } from './paragraphcommand.js';
11
- export { InsertParagraphCommand } from './insertparagraphcommand.js';
12
- import './augmentation.js';
@@ -1,91 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module paragraph/insertparagraphcommand
7
- */
8
- import { Command } from '@ckeditor/ckeditor5-core';
9
- /**
10
- * The insert paragraph command. It inserts a new paragraph at a specific
11
- * {@link module:engine/model/position~ModelPosition document position}.
12
- *
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
- * ```
19
- *
20
- * If a paragraph is disallowed in the context of the specific position, the command
21
- * will attempt to split position ancestors to find a place where it is possible
22
- * to insert a paragraph.
23
- *
24
- * **Note**: This command moves the selection to the inserted paragraph.
25
- */
26
- export 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
- }
32
- /**
33
- * Executes the command.
34
- *
35
- * @param options Options for the executed command.
36
- * @param options.position The model position at which the new paragraph will be inserted.
37
- * @param options.attributes Attributes keys and values to set on a inserted paragraph.
38
- * @fires execute
39
- */
40
- execute(options) {
41
- const model = this.editor.model;
42
- const attributes = options.attributes;
43
- let position = options.position;
44
- // Don't execute command if position is in non-editable place.
45
- if (!model.canEditAt(position)) {
46
- return null;
47
- }
48
- return model.change(writer => {
49
- position = this._findPositionToInsertParagraph(position, writer);
50
- if (!position) {
51
- return null;
52
- }
53
- const paragraph = writer.createElement('paragraph');
54
- if (attributes) {
55
- model.schema.setAllowedAttributes(paragraph, attributes, writer);
56
- }
57
- model.insertContent(paragraph, position);
58
- writer.setSelection(paragraph, 'in');
59
- return writer.createPositionAt(paragraph, 0);
60
- });
61
- }
62
- /**
63
- * Returns the best position to insert a new paragraph.
64
- */
65
- _findPositionToInsertParagraph(position, writer) {
66
- const model = this.editor.model;
67
- if (model.schema.checkChild(position, 'paragraph')) {
68
- return position;
69
- }
70
- const allowedParent = model.schema.findAllowedParent(position, 'paragraph');
71
- // It could be there's no ancestor limit that would allow paragraph.
72
- // In theory, "paragraph" could be disallowed even in the "$root".
73
- if (!allowedParent) {
74
- return null;
75
- }
76
- const positionParent = position.parent;
77
- const isTextAllowed = model.schema.checkChild(positionParent, '$text');
78
- // At empty $block or at the end of $block.
79
- // <paragraph>[]</paragraph> ---> <paragraph></paragraph><paragraph>[]</paragraph>
80
- // <paragraph>foo[]</paragraph> ---> <paragraph>foo</paragraph><paragraph>[]</paragraph>
81
- if (positionParent.isEmpty || isTextAllowed && position.isAtEnd) {
82
- return model.createPositionAfter(positionParent);
83
- }
84
- // At the start of $block with text.
85
- // <paragraph>[]foo</paragraph> ---> <paragraph>[]</paragraph><paragraph>foo</paragraph>
86
- if (!positionParent.isEmpty && isTextAllowed && position.isAtStart) {
87
- return model.createPositionBefore(positionParent);
88
- }
89
- return writer.split(position, allowedParent).position;
90
- }
91
- }
package/src/paragraph.js DELETED
@@ -1,112 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module paragraph/paragraph
7
- */
8
- import { ParagraphCommand } from './paragraphcommand.js';
9
- import { InsertParagraphCommand } from './insertparagraphcommand.js';
10
- import { Plugin } from '@ckeditor/ckeditor5-core';
11
- /**
12
- * The paragraph feature for the editor.
13
- *
14
- * It introduces the `<paragraph>` element in the model which renders as a `<p>` element in the DOM and data.
15
- *
16
- * It also brings two editors commands:
17
- *
18
- * * The {@link module:paragraph/paragraphcommand~ParagraphCommand `'paragraph'`} command that converts all
19
- * blocks in the model selection into paragraphs.
20
- * * The {@link module:paragraph/insertparagraphcommand~InsertParagraphCommand `'insertParagraph'`} command
21
- * that inserts a new paragraph at a specified location in the model.
22
- */
23
- export class Paragraph extends Plugin {
24
- /**
25
- * @inheritDoc
26
- */
27
- static get pluginName() {
28
- return 'Paragraph';
29
- }
30
- /**
31
- * @inheritDoc
32
- */
33
- static get isOfficialPlugin() {
34
- return true;
35
- }
36
- /**
37
- * @inheritDoc
38
- */
39
- init() {
40
- const editor = this.editor;
41
- const model = editor.model;
42
- editor.commands.add('paragraph', new ParagraphCommand(editor));
43
- editor.commands.add('insertParagraph', new InsertParagraphCommand(editor));
44
- // Schema.
45
- model.schema.register('paragraph', { inheritAllFrom: '$block' });
46
- editor.conversion.elementToElement({ model: 'paragraph', view: 'p' });
47
- // Conversion for paragraph-like elements which has not been converted by any plugin.
48
- editor.conversion.for('upcast').elementToElement({
49
- model: (viewElement, { writer }) => {
50
- if (!Paragraph.paragraphLikeElements.has(viewElement.name)) {
51
- return null;
52
- }
53
- // Do not auto-paragraph empty elements.
54
- if (viewElement.isEmpty) {
55
- return null;
56
- }
57
- return writer.createElement('paragraph');
58
- },
59
- view: /.+/,
60
- converterPriority: 'low'
61
- });
62
- }
63
- /**
64
- * A list of element names which should be treated by the autoparagraphing algorithms as
65
- * paragraph-like. This means that e.g. the following content:
66
- *
67
- * ```html
68
- * <h1>Foo</h1>
69
- * <table>
70
- * <tr>
71
- * <td>X</td>
72
- * <td>
73
- * <ul>
74
- * <li>Y</li>
75
- * <li>Z</li>
76
- * </ul>
77
- * </td>
78
- * </tr>
79
- * </table>
80
- * ```
81
- *
82
- * contains five paragraph-like elements: `<h1>`, two `<td>`s and two `<li>`s.
83
- * Hence, if none of the features is going to convert those elements the above content will be automatically handled
84
- * by the paragraph feature and converted to:
85
- *
86
- * ```html
87
- * <p>Foo</p>
88
- * <p>X</p>
89
- * <p>Y</p>
90
- * <p>Z</p>
91
- * ```
92
- *
93
- * Note: The `<td>` containing two `<li>` elements was ignored as the innermost paragraph-like elements
94
- * have a priority upon conversion.
95
- */
96
- static paragraphLikeElements = new Set([
97
- 'blockquote',
98
- 'dd',
99
- 'div',
100
- 'dt',
101
- 'h1',
102
- 'h2',
103
- 'h3',
104
- 'h4',
105
- 'h5',
106
- 'h6',
107
- 'li',
108
- 'p',
109
- 'td',
110
- 'th'
111
- ]);
112
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module paragraph/paragraphbuttonui
7
- */
8
- import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import { ButtonView } from '@ckeditor/ckeditor5-ui';
10
- import { IconParagraph } from '@ckeditor/ckeditor5-icons';
11
- import { Paragraph } from './paragraph.js';
12
- /**
13
- * This plugin defines the `'paragraph'` button. It can be used together with
14
- * {@link module:heading/headingbuttonsui~HeadingButtonsUI} to replace the standard heading dropdown.
15
- *
16
- * This plugin is not loaded automatically by the {@link module:paragraph/paragraph~Paragraph} plugin. It must
17
- * be added manually.
18
- *
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
- */
29
- export class ParagraphButtonUI extends Plugin {
30
- /**
31
- * @inheritDoc
32
- */
33
- static get requires() {
34
- return [Paragraph];
35
- }
36
- /**
37
- * @inheritDoc
38
- */
39
- init() {
40
- const editor = this.editor;
41
- const t = editor.t;
42
- editor.ui.componentFactory.add('paragraph', locale => {
43
- const view = new ButtonView(locale);
44
- const command = editor.commands.get('paragraph');
45
- view.label = t('Paragraph');
46
- view.icon = IconParagraph;
47
- view.tooltip = true;
48
- view.isToggleable = true;
49
- view.bind('isEnabled').to(command);
50
- view.bind('isOn').to(command, 'value');
51
- view.on('execute', () => {
52
- editor.execute('paragraph');
53
- });
54
- return view;
55
- });
56
- }
57
- }
@@ -1,64 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module paragraph/paragraphcommand
7
- */
8
- import { Command } from '@ckeditor/ckeditor5-core';
9
- import { first } from '@ckeditor/ckeditor5-utils';
10
- /**
11
- * The paragraph command.
12
- */
13
- export 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
- }
19
- /**
20
- * @inheritDoc
21
- */
22
- refresh() {
23
- const model = this.editor.model;
24
- const document = model.document;
25
- const block = first(document.selection.getSelectedBlocks());
26
- this.value = !!block && block.is('element', 'paragraph');
27
- this.isEnabled = !!block && checkCanBecomeParagraph(block, model.schema);
28
- }
29
- /**
30
- * Executes the command. All the blocks (see {@link module:engine/model/schema~ModelSchema}) in the selection
31
- * will be turned to paragraphs.
32
- *
33
- * @fires execute
34
- * @param options Options for the executed command.
35
- * @param options.selection The selection that the command should be applied to. By default,
36
- * if not provided, the command is applied to the {@link module:engine/model/document~ModelDocument#selection}.
37
- */
38
- execute(options = {}) {
39
- const model = this.editor.model;
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
- }
46
- model.change(writer => {
47
- const blocks = selection.getSelectedBlocks();
48
- for (const block of blocks) {
49
- if (!block.is('element', 'paragraph') && checkCanBecomeParagraph(block, model.schema)) {
50
- writer.rename(block, 'paragraph');
51
- }
52
- }
53
- });
54
- }
55
- }
56
- /**
57
- * Checks whether the given block can be replaced by a paragraph.
58
- *
59
- * @param block A block to be tested.
60
- * @param schema The schema of the document.
61
- */
62
- function checkCanBecomeParagraph(block, schema) {
63
- return schema.checkChild(block.parent, 'paragraph') && !schema.isObject(block);
64
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes