@ckeditor/ckeditor5-paragraph 40.0.0 → 40.2.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/CHANGELOG.md +25 -25
- package/LICENSE.md +2 -2
- package/package.json +4 -4
- package/src/augmentation.d.ts +14 -14
- package/src/augmentation.js +5 -5
- package/src/index.d.ts +12 -12
- package/src/index.js +10 -10
- package/src/insertparagraphcommand.d.ts +45 -45
- package/src/insertparagraphcommand.js +90 -90
- package/src/paragraph.d.ts +61 -61
- package/src/paragraph.js +106 -106
- package/src/paragraphbuttonui.d.ts +36 -36
- package/src/paragraphbuttonui.js +57 -57
- package/src/paragraphcommand.d.ts +38 -38
- package/src/paragraphcommand.js +64 -64
package/src/paragraph.d.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
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
|
-
}
|
|
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
|
+
}
|
package/src/paragraph.js
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
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/paragraph
|
|
7
|
-
*/
|
|
8
|
-
import ParagraphCommand from './paragraphcommand';
|
|
9
|
-
import InsertParagraphCommand from './insertparagraphcommand';
|
|
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 default class Paragraph extends Plugin {
|
|
24
|
-
/**
|
|
25
|
-
* @inheritDoc
|
|
26
|
-
*/
|
|
27
|
-
static get pluginName() {
|
|
28
|
-
return 'Paragraph';
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @inheritDoc
|
|
32
|
-
*/
|
|
33
|
-
init() {
|
|
34
|
-
const editor = this.editor;
|
|
35
|
-
const model = editor.model;
|
|
36
|
-
editor.commands.add('paragraph', new ParagraphCommand(editor));
|
|
37
|
-
editor.commands.add('insertParagraph', new InsertParagraphCommand(editor));
|
|
38
|
-
// Schema.
|
|
39
|
-
model.schema.register('paragraph', { inheritAllFrom: '$block' });
|
|
40
|
-
editor.conversion.elementToElement({ model: 'paragraph', view: 'p' });
|
|
41
|
-
// Conversion for paragraph-like elements which has not been converted by any plugin.
|
|
42
|
-
editor.conversion.for('upcast').elementToElement({
|
|
43
|
-
model: (viewElement, { writer }) => {
|
|
44
|
-
if (!Paragraph.paragraphLikeElements.has(viewElement.name)) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
// Do not auto-paragraph empty elements.
|
|
48
|
-
if (viewElement.isEmpty) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
return writer.createElement('paragraph');
|
|
52
|
-
},
|
|
53
|
-
view: /.+/,
|
|
54
|
-
converterPriority: 'low'
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* A list of element names which should be treated by the autoparagraphing algorithms as
|
|
60
|
-
* paragraph-like. This means that e.g. the following content:
|
|
61
|
-
*
|
|
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
|
-
Paragraph.paragraphLikeElements = new Set([
|
|
92
|
-
'blockquote',
|
|
93
|
-
'dd',
|
|
94
|
-
'div',
|
|
95
|
-
'dt',
|
|
96
|
-
'h1',
|
|
97
|
-
'h2',
|
|
98
|
-
'h3',
|
|
99
|
-
'h4',
|
|
100
|
-
'h5',
|
|
101
|
-
'h6',
|
|
102
|
-
'li',
|
|
103
|
-
'p',
|
|
104
|
-
'td',
|
|
105
|
-
'th'
|
|
106
|
-
]);
|
|
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/paragraph
|
|
7
|
+
*/
|
|
8
|
+
import ParagraphCommand from './paragraphcommand';
|
|
9
|
+
import InsertParagraphCommand from './insertparagraphcommand';
|
|
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 default class Paragraph extends Plugin {
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get pluginName() {
|
|
28
|
+
return 'Paragraph';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
init() {
|
|
34
|
+
const editor = this.editor;
|
|
35
|
+
const model = editor.model;
|
|
36
|
+
editor.commands.add('paragraph', new ParagraphCommand(editor));
|
|
37
|
+
editor.commands.add('insertParagraph', new InsertParagraphCommand(editor));
|
|
38
|
+
// Schema.
|
|
39
|
+
model.schema.register('paragraph', { inheritAllFrom: '$block' });
|
|
40
|
+
editor.conversion.elementToElement({ model: 'paragraph', view: 'p' });
|
|
41
|
+
// Conversion for paragraph-like elements which has not been converted by any plugin.
|
|
42
|
+
editor.conversion.for('upcast').elementToElement({
|
|
43
|
+
model: (viewElement, { writer }) => {
|
|
44
|
+
if (!Paragraph.paragraphLikeElements.has(viewElement.name)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
// Do not auto-paragraph empty elements.
|
|
48
|
+
if (viewElement.isEmpty) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return writer.createElement('paragraph');
|
|
52
|
+
},
|
|
53
|
+
view: /.+/,
|
|
54
|
+
converterPriority: 'low'
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A list of element names which should be treated by the autoparagraphing algorithms as
|
|
60
|
+
* paragraph-like. This means that e.g. the following content:
|
|
61
|
+
*
|
|
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
|
+
Paragraph.paragraphLikeElements = new Set([
|
|
92
|
+
'blockquote',
|
|
93
|
+
'dd',
|
|
94
|
+
'div',
|
|
95
|
+
'dt',
|
|
96
|
+
'h1',
|
|
97
|
+
'h2',
|
|
98
|
+
'h3',
|
|
99
|
+
'h4',
|
|
100
|
+
'h5',
|
|
101
|
+
'h6',
|
|
102
|
+
'li',
|
|
103
|
+
'p',
|
|
104
|
+
'td',
|
|
105
|
+
'th'
|
|
106
|
+
]);
|
|
@@ -1,36 +1,36 @@
|
|
|
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 } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import Paragraph from './paragraph';
|
|
10
|
-
/**
|
|
11
|
-
* This plugin defines the `'paragraph'` button. It can be used together with
|
|
12
|
-
* {@link module:heading/headingbuttonsui~HeadingButtonsUI} to replace the standard heading dropdown.
|
|
13
|
-
*
|
|
14
|
-
* This plugin is not loaded automatically by the {@link module:paragraph/paragraph~Paragraph} plugin. It must
|
|
15
|
-
* be added manually.
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* ClassicEditor
|
|
19
|
-
* .create( {
|
|
20
|
-
* plugins: [ ..., Heading, Paragraph, HeadingButtonsUI, ParagraphButtonUI ]
|
|
21
|
-
* toolbar: [ 'paragraph', 'heading1', 'heading2', 'heading3' ]
|
|
22
|
-
* } )
|
|
23
|
-
* .then( ... )
|
|
24
|
-
* .catch( ... );
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export default class ParagraphButtonUI extends Plugin {
|
|
28
|
-
/**
|
|
29
|
-
* @inheritDoc
|
|
30
|
-
*/
|
|
31
|
-
static get requires(): readonly [typeof Paragraph];
|
|
32
|
-
/**
|
|
33
|
-
* @inheritDoc
|
|
34
|
-
*/
|
|
35
|
-
init(): void;
|
|
36
|
-
}
|
|
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 } from '@ckeditor/ckeditor5-core';
|
|
9
|
+
import Paragraph from './paragraph';
|
|
10
|
+
/**
|
|
11
|
+
* This plugin defines the `'paragraph'` button. It can be used together with
|
|
12
|
+
* {@link module:heading/headingbuttonsui~HeadingButtonsUI} to replace the standard heading dropdown.
|
|
13
|
+
*
|
|
14
|
+
* This plugin is not loaded automatically by the {@link module:paragraph/paragraph~Paragraph} plugin. It must
|
|
15
|
+
* be added manually.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* ClassicEditor
|
|
19
|
+
* .create( {
|
|
20
|
+
* plugins: [ ..., Heading, Paragraph, HeadingButtonsUI, ParagraphButtonUI ]
|
|
21
|
+
* toolbar: [ 'paragraph', 'heading1', 'heading2', 'heading3' ]
|
|
22
|
+
* } )
|
|
23
|
+
* .then( ... )
|
|
24
|
+
* .catch( ... );
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export default class ParagraphButtonUI extends Plugin {
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
static get requires(): readonly [typeof Paragraph];
|
|
32
|
+
/**
|
|
33
|
+
* @inheritDoc
|
|
34
|
+
*/
|
|
35
|
+
init(): void;
|
|
36
|
+
}
|
package/src/paragraphbuttonui.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
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, icons } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import { ButtonView } from '@ckeditor/ckeditor5-ui';
|
|
10
|
-
import Paragraph from './paragraph';
|
|
11
|
-
const icon = icons.paragraph;
|
|
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 default 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 = icon;
|
|
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
|
+
/**
|
|
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, icons } from '@ckeditor/ckeditor5-core';
|
|
9
|
+
import { ButtonView } from '@ckeditor/ckeditor5-ui';
|
|
10
|
+
import Paragraph from './paragraph';
|
|
11
|
+
const icon = icons.paragraph;
|
|
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 default 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 = icon;
|
|
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,38 +1,38 @@
|
|
|
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, type Editor } 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
|
-
constructor(editor: Editor);
|
|
15
|
-
/**
|
|
16
|
-
* The value of the command. Indicates whether the selection start is placed in a paragraph.
|
|
17
|
-
*
|
|
18
|
-
* @readonly
|
|
19
|
-
* @observable
|
|
20
|
-
*/
|
|
21
|
-
value: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
refresh(): void;
|
|
26
|
-
/**
|
|
27
|
-
* Executes the command. All the blocks (see {@link module:engine/model/schema~Schema}) in the selection
|
|
28
|
-
* will be turned to paragraphs.
|
|
29
|
-
*
|
|
30
|
-
* @fires execute
|
|
31
|
-
* @param options Options for the executed command.
|
|
32
|
-
* @param options.selection The selection that the command should be applied to. By default,
|
|
33
|
-
* if not provided, the command is applied to the {@link module:engine/model/document~Document#selection}.
|
|
34
|
-
*/
|
|
35
|
-
execute(options?: {
|
|
36
|
-
selection?: Selection | DocumentSelection;
|
|
37
|
-
}): void;
|
|
38
|
-
}
|
|
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, type Editor } 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
|
+
constructor(editor: Editor);
|
|
15
|
+
/**
|
|
16
|
+
* The value of the command. Indicates whether the selection start is placed in a paragraph.
|
|
17
|
+
*
|
|
18
|
+
* @readonly
|
|
19
|
+
* @observable
|
|
20
|
+
*/
|
|
21
|
+
value: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
refresh(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Executes the command. All the blocks (see {@link module:engine/model/schema~Schema}) in the selection
|
|
28
|
+
* will be turned to paragraphs.
|
|
29
|
+
*
|
|
30
|
+
* @fires execute
|
|
31
|
+
* @param options Options for the executed command.
|
|
32
|
+
* @param options.selection The selection that the command should be applied to. By default,
|
|
33
|
+
* if not provided, the command is applied to the {@link module:engine/model/document~Document#selection}.
|
|
34
|
+
*/
|
|
35
|
+
execute(options?: {
|
|
36
|
+
selection?: Selection | DocumentSelection;
|
|
37
|
+
}): void;
|
|
38
|
+
}
|