@ckeditor/ckeditor5-heading 41.2.0 → 41.3.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/dist/content-index.css +4 -0
- package/dist/editor-index.css +16 -0
- package/dist/index.css +26 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +881 -0
- package/dist/index.js.map +1 -0
- package/dist/types/augmentation.d.ts +30 -0
- package/dist/types/heading.d.ts +32 -0
- package/dist/types/headingbuttonsui.d.ts +51 -0
- package/dist/types/headingcommand.d.ts +48 -0
- package/dist/types/headingconfig.d.ts +145 -0
- package/dist/types/headingediting.d.ts +42 -0
- package/dist/types/headingui.d.ts +22 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/title.d.ts +115 -0
- package/dist/types/utils.d.ts +18 -0
- package/package.json +3 -2
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 heading/headingconfig
|
|
7
|
+
*/
|
|
8
|
+
import type { ArrayOrItem } from 'ckeditor5/src/utils.js';
|
|
9
|
+
import type { MatcherPattern, ViewElementDefinition } from 'ckeditor5/src/engine.js';
|
|
10
|
+
/**
|
|
11
|
+
* The configuration of the heading feature.
|
|
12
|
+
* The option is used by the {@link module:heading/headingediting~HeadingEditing} feature.
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* ClassicEditor
|
|
16
|
+
* .create( {
|
|
17
|
+
* heading: ... // Heading feature config.
|
|
18
|
+
* } )
|
|
19
|
+
* .then( ... )
|
|
20
|
+
* .catch( ... );
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
24
|
+
*/
|
|
25
|
+
export interface HeadingConfig {
|
|
26
|
+
/**
|
|
27
|
+
* The available heading options.
|
|
28
|
+
*
|
|
29
|
+
* The default value is:
|
|
30
|
+
* ```ts
|
|
31
|
+
* const headingConfig = {
|
|
32
|
+
* options: [
|
|
33
|
+
* { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
|
|
34
|
+
* { model: 'heading1', view: 'h2', title: 'Heading 1', class: 'ck-heading_heading1' },
|
|
35
|
+
* { model: 'heading2', view: 'h3', title: 'Heading 2', class: 'ck-heading_heading2' },
|
|
36
|
+
* { model: 'heading3', view: 'h4', title: 'Heading 3', class: 'ck-heading_heading3' }
|
|
37
|
+
* ]
|
|
38
|
+
* };
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* It defines 3 levels of headings. In the editor model they will use `heading1`, `heading2`, and `heading3` elements.
|
|
42
|
+
* Their respective view elements (so the elements output by the editor) will be: `h2`, `h3`, and `h4`. This means that
|
|
43
|
+
* if you choose "Heading 1" in the headings dropdown the editor will turn the current block to `<heading1>` in the model
|
|
44
|
+
* which will result in rendering (and outputting to data) the `<h2>` element.
|
|
45
|
+
*
|
|
46
|
+
* The `title` and `class` properties will be used by the `headings` dropdown to render available options.
|
|
47
|
+
* Usually, the first option in the headings dropdown is the "Paragraph" option, hence it's also defined on the list.
|
|
48
|
+
* However, you don't need to define its view representation because it's handled by
|
|
49
|
+
* the {@link module:paragraph/paragraph~Paragraph} feature (which is required by
|
|
50
|
+
* the {@link module:heading/headingediting~HeadingEditing} feature).
|
|
51
|
+
*
|
|
52
|
+
* You can **read more** about configuring heading levels and **see more examples** in
|
|
53
|
+
* the {@glink features/headings Headings} guide.
|
|
54
|
+
*
|
|
55
|
+
* Note: In the model you should always start from `heading1`, regardless of how the headings are represented in the view.
|
|
56
|
+
* That's assumption is used by features like {@link module:autoformat/autoformat~Autoformat} to know which element
|
|
57
|
+
* they should use when applying the first level heading.
|
|
58
|
+
*
|
|
59
|
+
* The defined headings are also available as values passed to the `'heading'` command under their model names.
|
|
60
|
+
* For example, the below code will apply `<heading1>` to the current selection:
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* editor.execute( 'heading', { value: 'heading1' } );
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
options?: Array<HeadingOption>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Heading option descriptor.
|
|
70
|
+
*/
|
|
71
|
+
export type HeadingOption = HeadingElementOption | HeadingParagraphOption | HeadingCustomElementOption;
|
|
72
|
+
export interface HeadingElementOption {
|
|
73
|
+
/**
|
|
74
|
+
* Name of the model element to convert.
|
|
75
|
+
*/
|
|
76
|
+
model: 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6';
|
|
77
|
+
/**
|
|
78
|
+
* Definition of a view element to convert from/to.
|
|
79
|
+
*/
|
|
80
|
+
view: ViewElementDefinition;
|
|
81
|
+
/**
|
|
82
|
+
* The user-readable title of the option.
|
|
83
|
+
*/
|
|
84
|
+
title: string;
|
|
85
|
+
/**
|
|
86
|
+
* The class which will be added to the dropdown item representing this option.
|
|
87
|
+
*/
|
|
88
|
+
class: string;
|
|
89
|
+
/**
|
|
90
|
+
* Icon used by {@link module:heading/headingbuttonsui~HeadingButtonsUI}. It can be omitted when using the default configuration.
|
|
91
|
+
*/
|
|
92
|
+
icon?: string;
|
|
93
|
+
/**
|
|
94
|
+
* An array with all matched elements that the view-to-model conversion should also accept.
|
|
95
|
+
*/
|
|
96
|
+
upcastAlso?: ArrayOrItem<ViewElementDefinition | MatcherPattern>;
|
|
97
|
+
}
|
|
98
|
+
export interface HeadingCustomElementOption {
|
|
99
|
+
/**
|
|
100
|
+
* Name of the model element to convert.
|
|
101
|
+
*/
|
|
102
|
+
model: `heading${string}`;
|
|
103
|
+
/**
|
|
104
|
+
* Definition of a view element to convert from/to.
|
|
105
|
+
*/
|
|
106
|
+
view: ViewElementDefinition;
|
|
107
|
+
/**
|
|
108
|
+
* The user-readable title of the option.
|
|
109
|
+
*/
|
|
110
|
+
title: string;
|
|
111
|
+
/**
|
|
112
|
+
* The class which will be added to the dropdown item representing this option.
|
|
113
|
+
*/
|
|
114
|
+
class: string;
|
|
115
|
+
/**
|
|
116
|
+
* Icon used by {@link module:heading/headingbuttonsui~HeadingButtonsUI}. It can be omitted when using the default configuration.
|
|
117
|
+
*/
|
|
118
|
+
icon?: string;
|
|
119
|
+
/**
|
|
120
|
+
* An array with all matched elements that the view-to-model conversion should also accept.
|
|
121
|
+
*/
|
|
122
|
+
upcastAlso?: ArrayOrItem<ViewElementDefinition | MatcherPattern>;
|
|
123
|
+
}
|
|
124
|
+
export interface HeadingParagraphOption {
|
|
125
|
+
/**
|
|
126
|
+
* Name of the model element to convert.
|
|
127
|
+
*/
|
|
128
|
+
model: 'paragraph';
|
|
129
|
+
/**
|
|
130
|
+
* The user-readable title of the option.
|
|
131
|
+
*/
|
|
132
|
+
title: string;
|
|
133
|
+
/**
|
|
134
|
+
* The class which will be added to the dropdown item representing this option.
|
|
135
|
+
* */
|
|
136
|
+
class: string;
|
|
137
|
+
/**
|
|
138
|
+
* Icon used by {@link module:heading/headingbuttonsui~HeadingButtonsUI}. It can be omitted when using the default configuration.
|
|
139
|
+
*/
|
|
140
|
+
icon?: string;
|
|
141
|
+
/**
|
|
142
|
+
* An array with all matched elements that the view-to-model conversion should also accept.
|
|
143
|
+
*/
|
|
144
|
+
upcastAlso?: ArrayOrItem<ViewElementDefinition | MatcherPattern>;
|
|
145
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 heading/headingediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { Paragraph } from 'ckeditor5/src/paragraph.js';
|
|
10
|
+
/**
|
|
11
|
+
* The headings engine feature. It handles switching between block formats – headings and paragraph.
|
|
12
|
+
* This class represents the engine part of the heading feature. See also {@link module:heading/heading~Heading}.
|
|
13
|
+
* It introduces `heading1`-`headingN` commands which allow to convert paragraphs into headings.
|
|
14
|
+
*/
|
|
15
|
+
export default class HeadingEditing extends Plugin {
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
static get pluginName(): "HeadingEditing";
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
constructor(editor: Editor);
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get requires(): readonly [typeof Paragraph];
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
init(): void;
|
|
32
|
+
/**
|
|
33
|
+
* @inheritDoc
|
|
34
|
+
*/
|
|
35
|
+
afterInit(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Adds default conversion for `h1` -> `heading1` with a low priority.
|
|
38
|
+
*
|
|
39
|
+
* @param editor Editor instance on which to add the `h1` conversion.
|
|
40
|
+
*/
|
|
41
|
+
private _addDefaultH1Conversion;
|
|
42
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 heading/headingui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import '../theme/heading.css';
|
|
10
|
+
/**
|
|
11
|
+
* The headings UI feature. It introduces the `headings` dropdown.
|
|
12
|
+
*/
|
|
13
|
+
export default class HeadingUI extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get pluginName(): "HeadingUI";
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
init(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 heading
|
|
7
|
+
*/
|
|
8
|
+
export { default as Heading } from './heading.js';
|
|
9
|
+
export type { HeadingOption, HeadingElementOption } from './headingconfig.js';
|
|
10
|
+
export { default as HeadingEditing } from './headingediting.js';
|
|
11
|
+
export { default as HeadingUI } from './headingui.js';
|
|
12
|
+
export { default as HeadingButtonsUI } from './headingbuttonsui.js';
|
|
13
|
+
export { default as Title, type TitleConfig } from './title.js';
|
|
14
|
+
export type { HeadingConfig } from './headingconfig.js';
|
|
15
|
+
export type { default as HeadingCommand } from './headingcommand.js';
|
|
16
|
+
import './augmentation.js';
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 heading/title
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
/**
|
|
10
|
+
* The Title plugin.
|
|
11
|
+
*
|
|
12
|
+
* It splits the document into `Title` and `Body` sections.
|
|
13
|
+
*/
|
|
14
|
+
export default class Title extends Plugin {
|
|
15
|
+
/**
|
|
16
|
+
* A reference to an empty paragraph in the body
|
|
17
|
+
* created when there is no element in the body for the placeholder purposes.
|
|
18
|
+
*/
|
|
19
|
+
private _bodyPlaceholder;
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get pluginName(): "Title";
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get requires(): readonly ["Paragraph"];
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
init(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the title of the document. Note that because this plugin does not allow any formatting inside
|
|
34
|
+
* the title element, the output of this method will be a plain text, with no HTML tags.
|
|
35
|
+
*
|
|
36
|
+
* It is not recommended to use this method together with features that insert markers to the
|
|
37
|
+
* data output, like comments or track changes features. If such markers start in the title and end in the
|
|
38
|
+
* body, the result of this method might be incorrect.
|
|
39
|
+
*
|
|
40
|
+
* @param options Additional configuration passed to the conversion process.
|
|
41
|
+
* See {@link module:engine/controller/datacontroller~DataController#get `DataController#get`}.
|
|
42
|
+
* @returns The title of the document.
|
|
43
|
+
*/
|
|
44
|
+
getTitle(options?: Record<string, unknown>): string;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the body of the document.
|
|
47
|
+
*
|
|
48
|
+
* Note that it is not recommended to use this method together with features that insert markers to the
|
|
49
|
+
* data output, like comments or track changes features. If such markers start in the title and end in the
|
|
50
|
+
* body, the result of this method might be incorrect.
|
|
51
|
+
*
|
|
52
|
+
* @param options Additional configuration passed to the conversion process.
|
|
53
|
+
* See {@link module:engine/controller/datacontroller~DataController#get `DataController#get`}.
|
|
54
|
+
* @returns The body of the document.
|
|
55
|
+
*/
|
|
56
|
+
getBody(options?: Record<string, unknown>): string;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the `title` element when it is in the document. Returns `undefined` otherwise.
|
|
59
|
+
*/
|
|
60
|
+
private _getTitleElement;
|
|
61
|
+
/**
|
|
62
|
+
* Model post-fixer callback that ensures that `title` has only one `title-content` child.
|
|
63
|
+
* All additional children should be moved after the `title` element and renamed to a paragraph.
|
|
64
|
+
*/
|
|
65
|
+
private _fixTitleContent;
|
|
66
|
+
/**
|
|
67
|
+
* Model post-fixer callback that creates a title element when it is missing,
|
|
68
|
+
* takes care of the correct position of it and removes additional title elements.
|
|
69
|
+
*/
|
|
70
|
+
private _fixTitleElement;
|
|
71
|
+
/**
|
|
72
|
+
* Model post-fixer callback that adds an empty paragraph at the end of the document
|
|
73
|
+
* when it is needed for the placeholder purposes.
|
|
74
|
+
*/
|
|
75
|
+
private _fixBodyElement;
|
|
76
|
+
/**
|
|
77
|
+
* Model post-fixer callback that removes a paragraph from the end of the document
|
|
78
|
+
* if it was created for the placeholder purposes and is not needed anymore.
|
|
79
|
+
*/
|
|
80
|
+
private _fixExtraParagraph;
|
|
81
|
+
/**
|
|
82
|
+
* Attaches the `Title` and `Body` placeholders to the title and/or content.
|
|
83
|
+
*/
|
|
84
|
+
private _attachPlaceholders;
|
|
85
|
+
/**
|
|
86
|
+
* Creates navigation between the title and body sections using <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
|
|
87
|
+
*/
|
|
88
|
+
private _attachTabPressHandling;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The configuration of the {@link module:heading/title~Title title feature}.
|
|
92
|
+
*
|
|
93
|
+
* ```ts
|
|
94
|
+
* ClassicEditor
|
|
95
|
+
* .create( document.querySelector( '#editor' ), {
|
|
96
|
+
* plugins: [ Title, ... ],
|
|
97
|
+
* title: {
|
|
98
|
+
* placeholder: 'My custom placeholder for the title'
|
|
99
|
+
* },
|
|
100
|
+
* placeholder: 'My custom placeholder for the body'
|
|
101
|
+
* } )
|
|
102
|
+
* .then( ... )
|
|
103
|
+
* .catch( ... );
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.
|
|
107
|
+
*/
|
|
108
|
+
export interface TitleConfig {
|
|
109
|
+
/**
|
|
110
|
+
* Defines a custom value of the placeholder for the title field.
|
|
111
|
+
*
|
|
112
|
+
* Read more in {@link module:heading/title~TitleConfig}.
|
|
113
|
+
*/
|
|
114
|
+
placeholder?: string;
|
|
115
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 heading/utils
|
|
7
|
+
*/
|
|
8
|
+
import type { Editor } from 'ckeditor5/src/core.js';
|
|
9
|
+
import type { HeadingOption } from './headingconfig.js';
|
|
10
|
+
/**
|
|
11
|
+
* Returns heading options as defined in `config.heading.options` but processed to consider
|
|
12
|
+
* the editor localization, i.e. to display {@link module:heading/headingconfig~HeadingOption}
|
|
13
|
+
* in the correct language.
|
|
14
|
+
*
|
|
15
|
+
* Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
|
|
16
|
+
* when the user configuration is defined because the editor does not exist yet.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getLocalizedOptions(editor: Editor): Array<HeadingOption>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-heading",
|
|
3
|
-
"version": "41.
|
|
3
|
+
"version": "41.3.0-alpha.0",
|
|
4
4
|
"description": "Headings 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": "41.
|
|
16
|
+
"ckeditor5": "41.3.0-alpha.0"
|
|
17
17
|
},
|
|
18
18
|
"author": "CKSource (http://cksource.com/)",
|
|
19
19
|
"license": "GPL-2.0-or-later",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"directory": "packages/ckeditor5-heading"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
|
+
"dist",
|
|
28
29
|
"lang",
|
|
29
30
|
"src/**/*.js",
|
|
30
31
|
"src/**/*.d.ts",
|