@ckeditor/ckeditor5-style 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.
@@ -0,0 +1,14 @@
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 style
7
+ */
8
+ export { default as Style } from './style.js';
9
+ export { default as StyleEditing } from './styleediting.js';
10
+ export { default as StyleUI } from './styleui.js';
11
+ export { default as StyleUtils } from './styleutils.js';
12
+ export type { StyleConfig, StyleDefinition } from './styleconfig.js';
13
+ export type { default as StyleCommand } from './stylecommand.js';
14
+ import './augmentation.js';
@@ -0,0 +1,37 @@
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 style/integrations/link
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import StyleUtils from '../styleutils.js';
10
+ export default class LinkStyleSupport extends Plugin {
11
+ private _styleUtils;
12
+ private _htmlSupport;
13
+ /**
14
+ * @inheritDoc
15
+ */
16
+ static get pluginName(): "LinkStyleSupport";
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ static get requires(): readonly [typeof StyleUtils, "GeneralHtmlSupport"];
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ init(): void;
25
+ /**
26
+ * Verifies if the given style is applicable to the provided document selection.
27
+ */
28
+ private _isStyleEnabled;
29
+ /**
30
+ * Returns true if the given style is applied to the specified document selection.
31
+ */
32
+ private _isStyleActive;
33
+ /**
34
+ * Returns a selectable that given style should be applied to.
35
+ */
36
+ private _getAffectedSelectable;
37
+ }
@@ -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 style/integrations/list
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import StyleUtils from '../styleutils.js';
10
+ export default class ListStyleSupport extends Plugin {
11
+ private _listUtils;
12
+ private _styleUtils;
13
+ private _htmlSupport;
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ static get pluginName(): "ListStyleSupport";
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get requires(): readonly [typeof StyleUtils, "GeneralHtmlSupport"];
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ init(): void;
26
+ /**
27
+ * Verifies if the given style is applicable to the provided block element.
28
+ */
29
+ private _isStyleEnabledForBlock;
30
+ /**
31
+ * Returns true if the given style is applied to the specified block element.
32
+ */
33
+ private _isStyleActiveForBlock;
34
+ /**
35
+ * Returns an array of block elements that style should be applied to.
36
+ */
37
+ private _getAffectedBlocks;
38
+ /**
39
+ * Returns a view template definition for the style preview.
40
+ */
41
+ private _getStylePreview;
42
+ }
@@ -0,0 +1,49 @@
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 style/integrations/table
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import StyleUtils from '../styleutils.js';
10
+ export default class TableStyleSupport extends Plugin {
11
+ private _tableUtils;
12
+ private _styleUtils;
13
+ /**
14
+ * @inheritDoc
15
+ */
16
+ static get pluginName(): "TableStyleSupport";
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ static get requires(): readonly [typeof StyleUtils];
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ init(): void;
25
+ /**
26
+ * Checks if this plugin's custom logic should be applied for defintion-block pair.
27
+ *
28
+ * @param definition Style definition that is being considered.
29
+ * @param block Block element to check if should be styled.
30
+ * @returns True if the defintion-block pair meet the plugin criteria, false otherwise.
31
+ */
32
+ private _isApplicable;
33
+ /**
34
+ * Checks if the style definition should be applied to selected block.
35
+ *
36
+ * @param definition Style definition that is being considered.
37
+ * @param block Block element to check if should be styled.
38
+ * @returns True if the block should be style with the style description, false otherwise.
39
+ */
40
+ private _isStyleEnabledForBlock;
41
+ /**
42
+ * Gets all blocks that the style should be applied to.
43
+ *
44
+ * @param definition Style definition that is being considered.
45
+ * @param block A block element from selection.
46
+ * @returns An array with the block that was passed as an argument if meets the criteria, null otherwise.
47
+ */
48
+ private _getAffectedBlocks;
49
+ }
@@ -0,0 +1,26 @@
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 style/style
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import StyleUI from './styleui.js';
10
+ import StyleEditing from './styleediting.js';
11
+ /**
12
+ * The style plugin.
13
+ *
14
+ * This is a "glue" plugin that loads the {@link module:style/styleediting~StyleEditing style editing feature}
15
+ * and {@link module:style/styleui~StyleUI style UI feature}.
16
+ */
17
+ export default class Style extends Plugin {
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get pluginName(): "Style";
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get requires(): readonly [typeof StyleEditing, typeof StyleUI];
26
+ }
@@ -0,0 +1,82 @@
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
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
6
+ import { type NormalizedStyleDefinitions } from './styleutils.js';
7
+ /**
8
+ * Style command.
9
+ *
10
+ * Applies and removes styles from selection and elements.
11
+ */
12
+ export default class StyleCommand extends Command {
13
+ /**
14
+ * Set of currently applied styles on the current selection.
15
+ *
16
+ * Names of styles correspond to the `name` property of
17
+ * {@link module:style/styleconfig~StyleDefinition configured definitions}.
18
+ *
19
+ * @observable
20
+ */
21
+ value: Array<string>;
22
+ /**
23
+ * Names of enabled styles (styles that can be applied to the current selection).
24
+ *
25
+ * Names of enabled styles correspond to the `name` property of
26
+ * {@link module:style/styleconfig~StyleDefinition configured definitions}.
27
+ *
28
+ * @observable
29
+ */
30
+ enabledStyles: Array<string>;
31
+ /**
32
+ * Normalized definitions of the styles.
33
+ */
34
+ private readonly _styleDefinitions;
35
+ /**
36
+ * The StyleUtils plugin.
37
+ */
38
+ private _styleUtils;
39
+ /**
40
+ * Creates an instance of the command.
41
+ *
42
+ * @param editor Editor on which this command will be used.
43
+ * @param styleDefinitions Normalized definitions of the styles.
44
+ */
45
+ constructor(editor: Editor, styleDefinitions: NormalizedStyleDefinitions);
46
+ /**
47
+ * @inheritDoc
48
+ */
49
+ refresh(): void;
50
+ /**
51
+ * Executes the command &ndash; applies the style classes to the selection or removes it from the selection.
52
+ *
53
+ * If the command value already contains the requested style, it will remove the style classes. Otherwise, it will set it.
54
+ *
55
+ * The execution result differs, depending on the {@link module:engine/model/document~Document#selection} and the
56
+ * style type (inline or block):
57
+ *
58
+ * * When applying inline styles:
59
+ * * If the selection is on a range, the command applies the style classes to all nodes in that range.
60
+ * * If the selection is collapsed in a non-empty node, the command applies the style classes to the
61
+ * {@link module:engine/model/document~Document#selection}.
62
+ *
63
+ * * When applying block styles:
64
+ * * If the selection is on a range, the command applies the style classes to the nearest block parent element.
65
+ *
66
+ * @fires execute
67
+ * @param options Command options.
68
+ * @param options.styleName Style name matching the one defined in the
69
+ * {@link module:style/styleconfig~StyleConfig#definitions configuration}.
70
+ * @param options.forceValue Whether the command should add given style (`true`) or remove it (`false`) from the selection.
71
+ * If not set (default), the command will toggle the style basing on the first selected node. Note, that this will not force
72
+ * setting a style on an element that cannot receive given style.
73
+ */
74
+ execute({ styleName, forceValue }: {
75
+ styleName: string;
76
+ forceValue?: boolean;
77
+ }): void;
78
+ /**
79
+ * Returns a set of elements that should be affected by the block-style change.
80
+ */
81
+ private _findAffectedBlocks;
82
+ }
@@ -0,0 +1,87 @@
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 style/styleconfig
7
+ */
8
+ /**
9
+ * The configuration of the style feature.
10
+ *
11
+ * ```ts
12
+ * ClassicEditor
13
+ * .create( {
14
+ * style: ... // Style feature config.
15
+ * } )
16
+ * .then( ... )
17
+ * .catch( ... );
18
+ * ```
19
+ *
20
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
21
+ */
22
+ export interface StyleConfig {
23
+ /**
24
+ * The available style definitions.
25
+ *
26
+ * Style definitions are displayed in the `'style'` UI dropdown and get applied by the
27
+ * {@link module:style/stylecommand~StyleCommand style command} to the content of the document.
28
+ *
29
+ * In the `'style'` UI dropdown, definitions are automatically grouped into two categories based on the of the `element` property:
30
+ *
31
+ * * **Block styles**: Can be applied to entire {@link module:html-support/dataschema~DataSchema#registerBlockElement block elements}
32
+ * only (e.g. headings, paragraphs, divs).
33
+ * * **Text styles**: Can by applied to any {@link module:html-support/dataschema~DataSchema#registerInlineElement text} in any element
34
+ * in the document.
35
+ *
36
+ * An example configuration:
37
+ *
38
+ * ```ts
39
+ * [
40
+ * // Definitions of block styles.
41
+ * {
42
+ * name: 'Red heading',
43
+ * element: 'h2',
44
+ * classes: [ 'red-heading' ]
45
+ * },
46
+ * {
47
+ * name: 'Vibrant code',
48
+ * element: 'pre',
49
+ * classes: [ 'vibrant-code' ]
50
+ * },
51
+ *
52
+ * // Definitions of text (inline) styles.
53
+ * {
54
+ * name: 'Marker',
55
+ * element: 'span',
56
+ * classes: [ 'marker' ]
57
+ * },
58
+ *
59
+ * // ...
60
+ * ]
61
+ * ```
62
+ *
63
+ * **Note**: Configuring style definitions will automatically configure the
64
+ * {@glink features/html/general-html-support General HTML Support feature}. **You do not need to repeat the configuration in
65
+ * {@link module:html-support/generalhtmlsupportconfig~GeneralHtmlSupportConfig}**.
66
+ */
67
+ definitions?: Array<StyleDefinition>;
68
+ }
69
+ /**
70
+ * Style definition.
71
+ *
72
+ * An object describing a style definition. It contains the style `name`, `element` name and an array of CSS `classes`.
73
+ *
74
+ * ```ts
75
+ * // This style will create <h2 class="foo">...</h2> in the document data.
76
+ * {
77
+ * name: 'Example style',
78
+ * element: 'h2',
79
+ * classes: [ 'foo' ]
80
+ * }
81
+ * ```
82
+ */
83
+ export interface StyleDefinition {
84
+ name: string;
85
+ element: string;
86
+ classes: Array<string>;
87
+ }
@@ -0,0 +1,33 @@
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 style/styleediting
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import StyleUtils from './styleutils.js';
10
+ import ListStyleSupport from './integrations/list.js';
11
+ import TableStyleSupport from './integrations/table.js';
12
+ import LinkStyleSupport from './integrations/link.js';
13
+ /**
14
+ * The style engine feature.
15
+ *
16
+ * It configures the {@glink features/html/general-html-support General HTML Support feature} based on
17
+ * {@link module:style/styleconfig~StyleConfig#definitions configured style definitions} and introduces the
18
+ * {@link module:style/stylecommand~StyleCommand style command} that applies styles to the content of the document.
19
+ */
20
+ export default class StyleEditing extends Plugin {
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get pluginName(): "StyleEditing";
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get requires(): readonly ["GeneralHtmlSupport", typeof StyleUtils, typeof ListStyleSupport, typeof TableStyleSupport, typeof LinkStyleSupport];
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ init(): void;
33
+ }
@@ -0,0 +1,30 @@
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 style/styleui
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import StyleUtils from './styleutils.js';
10
+ import '../theme/style.css';
11
+ /**
12
+ * The UI plugin of the style feature .
13
+ *
14
+ * It registers the `'style'` UI dropdown in the editor's {@link module:ui/componentfactory~ComponentFactory component factory}
15
+ * that displays a grid of styles and allows changing styles of the content.
16
+ */
17
+ export default class StyleUI extends Plugin {
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get pluginName(): "StyleUI";
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get requires(): readonly [typeof StyleUtils];
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ init(): void;
30
+ }
@@ -0,0 +1,138 @@
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 style/styleutils
7
+ */
8
+ import { Plugin, type Editor } from 'ckeditor5/src/core.js';
9
+ import type { Element, DocumentSelection, Selectable } from 'ckeditor5/src/engine.js';
10
+ import type { DecoratedMethodEvent } from 'ckeditor5/src/utils.js';
11
+ import type { TemplateDefinition } from 'ckeditor5/src/ui.js';
12
+ import type { DataSchema } from '@ckeditor/ckeditor5-html-support';
13
+ import type { StyleDefinition } from './styleconfig.js';
14
+ export default class StyleUtils extends Plugin {
15
+ private _htmlSupport;
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ static get pluginName(): "StyleUtils";
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ constructor(editor: Editor);
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ init(): void;
28
+ /**
29
+ * Normalizes {@link module:style/styleconfig~StyleConfig#definitions} in the configuration of the styles feature.
30
+ * The structure of normalized styles looks as follows:
31
+ *
32
+ * ```ts
33
+ * {
34
+ * block: [
35
+ * <module:style/style~StyleDefinition>,
36
+ * <module:style/style~StyleDefinition>,
37
+ * ...
38
+ * ],
39
+ * inline: [
40
+ * <module:style/style~StyleDefinition>,
41
+ * <module:style/style~StyleDefinition>,
42
+ * ...
43
+ * ]
44
+ * }
45
+ * ```
46
+ *
47
+ * @returns An object with normalized style definitions grouped into `block` and `inline` categories (arrays).
48
+ */
49
+ normalizeConfig(dataSchema: DataSchema, styleDefinitions?: Array<StyleDefinition>): NormalizedStyleDefinitions;
50
+ /**
51
+ * Verifies if the given style is applicable to the provided block element.
52
+ *
53
+ * @internal
54
+ */
55
+ isStyleEnabledForBlock(definition: BlockStyleDefinition, block: Element): boolean;
56
+ /**
57
+ * Returns true if the given style is applied to the specified block element.
58
+ *
59
+ * @internal
60
+ */
61
+ isStyleActiveForBlock(definition: BlockStyleDefinition, block: Element): boolean;
62
+ /**
63
+ * Returns an array of block elements that style should be applied to.
64
+ *
65
+ * @internal
66
+ */
67
+ getAffectedBlocks(definition: BlockStyleDefinition, block: Element): Array<Element> | null;
68
+ /**
69
+ * Verifies if the given style is applicable to the provided document selection.
70
+ *
71
+ * @internal
72
+ */
73
+ isStyleEnabledForInlineSelection(definition: InlineStyleDefinition, selection: DocumentSelection): boolean;
74
+ /**
75
+ * Returns true if the given style is applied to the specified document selection.
76
+ *
77
+ * @internal
78
+ */
79
+ isStyleActiveForInlineSelection(definition: InlineStyleDefinition, selection: DocumentSelection): boolean;
80
+ /**
81
+ * Returns a selectable that given style should be applied to.
82
+ *
83
+ * @internal
84
+ */
85
+ getAffectedInlineSelectable(definition: InlineStyleDefinition, selection: DocumentSelection): Selectable;
86
+ /**
87
+ * Returns the `TemplateDefinition` used by styles dropdown to render style preview.
88
+ *
89
+ * @internal
90
+ */
91
+ getStylePreview(definition: StyleDefinition, children: Iterable<TemplateDefinition>): TemplateDefinition;
92
+ /**
93
+ * Verifies if all classes are present in the given GHS attribute.
94
+ *
95
+ * @internal
96
+ */
97
+ hasAllClasses(ghsAttributeValue: unknown, classes: Array<string>): boolean;
98
+ /**
99
+ * This is where the styles feature configures the GHS feature. This method translates normalized
100
+ * {@link module:style/styleconfig~StyleDefinition style definitions} to
101
+ * {@link module:engine/view/matcher~MatcherObjectPattern matcher patterns} and feeds them to the GHS
102
+ * {@link module:html-support/datafilter~DataFilter} plugin.
103
+ *
104
+ * @internal
105
+ */
106
+ configureGHSDataFilter({ block, inline }: NormalizedStyleDefinitions): void;
107
+ /**
108
+ * Checks the attribute value of the first node in the selection that allows the attribute.
109
+ * For the collapsed selection, returns the selection attribute.
110
+ *
111
+ * @param selection The document selection.
112
+ * @param attributeName Name of the GHS attribute.
113
+ * @returns The attribute value.
114
+ */
115
+ private _getValueFromFirstAllowedNode;
116
+ }
117
+ export interface NormalizedStyleDefinitions {
118
+ block: Array<BlockStyleDefinition>;
119
+ inline: Array<InlineStyleDefinition>;
120
+ }
121
+ export interface BlockStyleDefinition extends StyleDefinition {
122
+ isBlock: true;
123
+ modelElements: Array<string>;
124
+ previewTemplate: TemplateDefinition;
125
+ }
126
+ export interface InlineStyleDefinition extends StyleDefinition {
127
+ ghsAttributes: Array<string>;
128
+ previewTemplate: TemplateDefinition;
129
+ }
130
+ export type NormalizedStyleDefinition = BlockStyleDefinition | InlineStyleDefinition;
131
+ export type StyleUtilsIsEnabledForBlockEvent = DecoratedMethodEvent<StyleUtils, 'isStyleEnabledForBlock'>;
132
+ export type StyleUtilsIsActiveForBlockEvent = DecoratedMethodEvent<StyleUtils, 'isStyleActiveForBlock'>;
133
+ export type StyleUtilsGetAffectedBlocksEvent = DecoratedMethodEvent<StyleUtils, 'getAffectedBlocks'>;
134
+ export type StyleUtilsIsStyleEnabledForInlineSelectionEvent = DecoratedMethodEvent<StyleUtils, 'isStyleEnabledForInlineSelection'>;
135
+ export type StyleUtilsIsStyleActiveForInlineSelectionEvent = DecoratedMethodEvent<StyleUtils, 'isStyleActiveForInlineSelection'>;
136
+ export type StyleUtilsGetAffectedInlineSelectableEvent = DecoratedMethodEvent<StyleUtils, 'getAffectedInlineSelectable'>;
137
+ export type StyleUtilsGetStylePreviewEvent = DecoratedMethodEvent<StyleUtils, 'getStylePreview'>;
138
+ export type StyleUtilsConfigureGHSDataFilterEvent = DecoratedMethodEvent<StyleUtils, 'configureGHSDataFilter'>;
@@ -0,0 +1,34 @@
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 style/ui/stylegridbuttonview
7
+ */
8
+ import type { Locale } from 'ckeditor5/src/utils.js';
9
+ import { ButtonView, View } from 'ckeditor5/src/ui.js';
10
+ import type { NormalizedStyleDefinition } from '../styleutils.js';
11
+ /**
12
+ * A class representing an individual button (style) in the grid. Renders a rich preview of the style.
13
+ */
14
+ export default class StyleGridButtonView extends ButtonView {
15
+ /**
16
+ * Definition of the style the button will apply when executed.
17
+ */
18
+ readonly styleDefinition: NormalizedStyleDefinition;
19
+ /**
20
+ * The view rendering the preview of the style.
21
+ */
22
+ readonly previewView: View;
23
+ /**
24
+ * Creates an instance of the {@link module:style/ui/stylegridbuttonview~StyleGridButtonView} class.
25
+ *
26
+ * @param locale The localization services instance.
27
+ * @param styleDefinition Definition of the style.
28
+ */
29
+ constructor(locale: Locale, styleDefinition: NormalizedStyleDefinition);
30
+ /**
31
+ * Creates the view representing the preview of the style.
32
+ */
33
+ private _createPreview;
34
+ }
@@ -0,0 +1,72 @@
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 style/ui/stylegridview
7
+ */
8
+ import { View, type ViewCollection, type FocusableView } from 'ckeditor5/src/ui.js';
9
+ import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
10
+ import StyleGridButtonView from './stylegridbuttonview.js';
11
+ import type { NormalizedStyleDefinition } from '../styleutils.js';
12
+ import '../../theme/stylegrid.css';
13
+ /**
14
+ * A class representing a grid of styles ({@link module:style/ui/stylegridbuttonview~StyleGridButtonView buttons}).
15
+ * Allows users to select a style.
16
+ */
17
+ export default class StyleGridView extends View<HTMLDivElement> implements FocusableView {
18
+ /**
19
+ * Tracks information about the DOM focus in the view.
20
+ */
21
+ readonly focusTracker: FocusTracker;
22
+ /**
23
+ * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
24
+ */
25
+ readonly keystrokes: KeystrokeHandler;
26
+ /**
27
+ * A collection of style {@link module:style/ui/stylegridbuttonview~StyleGridButtonView buttons}.
28
+ */
29
+ readonly children: ViewCollection<StyleGridButtonView>;
30
+ /**
31
+ * Array of active style names. They must correspond to the names of styles from
32
+ * definitions passed to the {@link #constructor}.
33
+ *
34
+ * @observable
35
+ */
36
+ readonly activeStyles: Array<string>;
37
+ /**
38
+ * Array of enabled style names. They must correspond to the names of styles from
39
+ * definitions passed to the {@link #constructor}.
40
+ *
41
+ * @observable
42
+ */
43
+ readonly enabledStyles: Array<string>;
44
+ /**
45
+ * Creates an instance of the {@link module:style/ui/stylegridview~StyleGridView} class.
46
+ *
47
+ * @param locale The localization services instance.
48
+ * @param styleDefinitions Definitions of the styles.
49
+ */
50
+ constructor(locale: Locale, styleDefinitions: Array<NormalizedStyleDefinition>);
51
+ /**
52
+ * @inheritDoc
53
+ */
54
+ render(): void;
55
+ /**
56
+ * Focuses the first style button in the grid.
57
+ */
58
+ focus(): void;
59
+ /**
60
+ * @inheritDoc
61
+ */
62
+ destroy(): void;
63
+ }
64
+ /**
65
+ * Fired when a {@link module:style/ui/stylegridbuttonview~StyleGridButtonView style} was selected (clicked) by the user.
66
+ *
67
+ * @eventName ~StyleGridView#execute
68
+ */
69
+ export type StyleGridViewExecuteEvent = {
70
+ name: 'execute';
71
+ args: [];
72
+ };