@ckeditor/ckeditor5-style 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/LICENSE.md CHANGED
@@ -2,7 +2,7 @@ Software License Agreement
2
2
  ==========================
3
3
 
4
4
  **CKEditor&nbsp;5 style feature** – https://github.com/ckeditor/ckeditor5-style <br>
5
- Copyright (c) 2003-2023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
5
+ Copyright (c) 20032023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
6
6
 
7
7
  Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
8
8
 
@@ -14,4 +14,4 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
14
14
  Trademarks
15
15
  ----------
16
16
 
17
- **CKEditor** is a trademark of [CKSource Holding sp. z o.o.](http://cksource.com) All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
17
+ **CKEditor** is a trademark of [CKSource Holding sp. z o.o.](http://cksource.com) All other brand and product names are trademarks, registered trademarks, or service marks of their respective holders.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-style",
3
- "version": "40.0.0",
3
+ "version": "40.2.0",
4
4
  "description": "Style feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,7 +12,7 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "40.0.0",
15
+ "ckeditor5": "40.2.0",
16
16
  "lodash-es": "4.17.21"
17
17
  },
18
18
  "author": "CKSource (http://cksource.com/)",
@@ -1,24 +1,24 @@
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 type { StyleConfig, StyleCommand, Style, StyleEditing, StyleUI, StyleUtils } from './index';
6
- declare module '@ckeditor/ckeditor5-core' {
7
- interface PluginsMap {
8
- [Style.pluginName]: Style;
9
- [StyleEditing.pluginName]: StyleEditing;
10
- [StyleUI.pluginName]: StyleUI;
11
- [StyleUtils.pluginName]: StyleUtils;
12
- }
13
- interface CommandsMap {
14
- style: StyleCommand;
15
- }
16
- interface EditorConfig {
17
- /**
18
- * The configuration of the {@link module:style/style~Style} feature.
19
- *
20
- * Read more in {@link module:style/styleconfig~StyleConfig}.
21
- */
22
- style?: StyleConfig;
23
- }
24
- }
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 type { StyleConfig, StyleCommand, Style, StyleEditing, StyleUI, StyleUtils } from './index';
6
+ declare module '@ckeditor/ckeditor5-core' {
7
+ interface PluginsMap {
8
+ [Style.pluginName]: Style;
9
+ [StyleEditing.pluginName]: StyleEditing;
10
+ [StyleUI.pluginName]: StyleUI;
11
+ [StyleUtils.pluginName]: StyleUtils;
12
+ }
13
+ interface CommandsMap {
14
+ style: StyleCommand;
15
+ }
16
+ interface EditorConfig {
17
+ /**
18
+ * The configuration of the {@link module:style/style~Style} feature.
19
+ *
20
+ * Read more in {@link module:style/styleconfig~StyleConfig}.
21
+ */
22
+ style?: StyleConfig;
23
+ }
24
+ }
@@ -1,5 +1,5 @@
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
- export {};
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
+ export {};
package/src/index.d.ts CHANGED
@@ -1,14 +1,14 @@
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 style
7
- */
8
- export { default as Style } from './style';
9
- export { default as StyleEditing } from './styleediting';
10
- export { default as StyleUI } from './styleui';
11
- export { default as StyleUtils } from './styleutils';
12
- export type { StyleConfig, StyleDefinition } from './styleconfig';
13
- export type { default as StyleCommand } from './stylecommand';
14
- import './augmentation';
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 style
7
+ */
8
+ export { default as Style } from './style';
9
+ export { default as StyleEditing } from './styleediting';
10
+ export { default as StyleUI } from './styleui';
11
+ export { default as StyleUtils } from './styleutils';
12
+ export type { StyleConfig, StyleDefinition } from './styleconfig';
13
+ export type { default as StyleCommand } from './stylecommand';
14
+ import './augmentation';
package/src/index.js CHANGED
@@ -1,12 +1,12 @@
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 style
7
- */
8
- export { default as Style } from './style';
9
- export { default as StyleEditing } from './styleediting';
10
- export { default as StyleUI } from './styleui';
11
- export { default as StyleUtils } from './styleutils';
12
- import './augmentation';
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 style
7
+ */
8
+ export { default as Style } from './style';
9
+ export { default as StyleEditing } from './styleediting';
10
+ export { default as StyleUI } from './styleui';
11
+ export { default as StyleUtils } from './styleutils';
12
+ import './augmentation';
@@ -1,42 +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 style/integrations/documentlist
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import StyleUtils from '../styleutils';
10
- export default class DocumentListStyleSupport extends Plugin {
11
- private _documentListUtils;
12
- private _styleUtils;
13
- private _htmlSupport;
14
- /**
15
- * @inheritDoc
16
- */
17
- static get pluginName(): "DocumentListStyleSupport";
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
- }
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 style/integrations/documentlist
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import StyleUtils from '../styleutils';
10
+ export default class DocumentListStyleSupport extends Plugin {
11
+ private _documentListUtils;
12
+ private _styleUtils;
13
+ private _htmlSupport;
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ static get pluginName(): "DocumentListStyleSupport";
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
+ }
@@ -1,141 +1,141 @@
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 style/integrations/documentlist
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import StyleUtils from '../styleutils';
10
- export default class DocumentListStyleSupport extends Plugin {
11
- /**
12
- * @inheritDoc
13
- */
14
- static get pluginName() {
15
- return 'DocumentListStyleSupport';
16
- }
17
- /**
18
- * @inheritDoc
19
- */
20
- static get requires() {
21
- return [StyleUtils, 'GeneralHtmlSupport'];
22
- }
23
- /**
24
- * @inheritDoc
25
- */
26
- init() {
27
- const editor = this.editor;
28
- if (!editor.plugins.has('DocumentListEditing')) {
29
- return;
30
- }
31
- this._styleUtils = editor.plugins.get(StyleUtils);
32
- this._documentListUtils = this.editor.plugins.get('DocumentListUtils');
33
- this._htmlSupport = this.editor.plugins.get('GeneralHtmlSupport');
34
- this.listenTo(this._styleUtils, 'isStyleEnabledForBlock', (evt, [definition, block]) => {
35
- if (this._isStyleEnabledForBlock(definition, block)) {
36
- evt.return = true;
37
- evt.stop();
38
- }
39
- }, { priority: 'high' });
40
- this.listenTo(this._styleUtils, 'isStyleActiveForBlock', (evt, [definition, block]) => {
41
- if (this._isStyleActiveForBlock(definition, block)) {
42
- evt.return = true;
43
- evt.stop();
44
- }
45
- }, { priority: 'high' });
46
- this.listenTo(this._styleUtils, 'getAffectedBlocks', (evt, [definition, block]) => {
47
- const blocks = this._getAffectedBlocks(definition, block);
48
- if (blocks) {
49
- evt.return = blocks;
50
- evt.stop();
51
- }
52
- }, { priority: 'high' });
53
- this.listenTo(this._styleUtils, 'getStylePreview', (evt, [definition, children]) => {
54
- const templateDefinition = this._getStylePreview(definition, children);
55
- if (templateDefinition) {
56
- evt.return = templateDefinition;
57
- evt.stop();
58
- }
59
- }, { priority: 'high' });
60
- }
61
- /**
62
- * Verifies if the given style is applicable to the provided block element.
63
- */
64
- _isStyleEnabledForBlock(definition, block) {
65
- const model = this.editor.model;
66
- if (!['ol', 'ul', 'li'].includes(definition.element)) {
67
- return false;
68
- }
69
- if (!this._documentListUtils.isListItemBlock(block)) {
70
- return false;
71
- }
72
- const attributeName = this._htmlSupport.getGhsAttributeNameForElement(definition.element);
73
- if (definition.element == 'ol' || definition.element == 'ul') {
74
- if (!model.schema.checkAttribute(block, attributeName)) {
75
- return false;
76
- }
77
- const viewElementName = block.getAttribute('listType') == 'numbered' ? 'ol' : 'ul';
78
- return definition.element == viewElementName;
79
- }
80
- else {
81
- return model.schema.checkAttribute(block, attributeName);
82
- }
83
- }
84
- /**
85
- * Returns true if the given style is applied to the specified block element.
86
- */
87
- _isStyleActiveForBlock(definition, block) {
88
- const attributeName = this._htmlSupport.getGhsAttributeNameForElement(definition.element);
89
- const ghsAttributeValue = block.getAttribute(attributeName);
90
- return this._styleUtils.hasAllClasses(ghsAttributeValue, definition.classes);
91
- }
92
- /**
93
- * Returns an array of block elements that style should be applied to.
94
- */
95
- _getAffectedBlocks(definition, block) {
96
- if (!this._isStyleEnabledForBlock(definition, block)) {
97
- return null;
98
- }
99
- if (definition.element == 'li') {
100
- return this._documentListUtils.expandListBlocksToCompleteItems(block, { withNested: false });
101
- }
102
- else {
103
- return this._documentListUtils.expandListBlocksToCompleteList(block);
104
- }
105
- }
106
- /**
107
- * Returns a view template definition for the style preview.
108
- */
109
- _getStylePreview(definition, children) {
110
- const { element, classes } = definition;
111
- if (element == 'ol' || element == 'ul') {
112
- return {
113
- tag: element,
114
- attributes: {
115
- class: classes
116
- },
117
- children: [
118
- {
119
- tag: 'li',
120
- children
121
- }
122
- ]
123
- };
124
- }
125
- else if (element == 'li') {
126
- return {
127
- tag: 'ol',
128
- children: [
129
- {
130
- tag: element,
131
- attributes: {
132
- class: classes
133
- },
134
- children
135
- }
136
- ]
137
- };
138
- }
139
- return null;
140
- }
141
- }
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 style/integrations/documentlist
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import StyleUtils from '../styleutils';
10
+ export default class DocumentListStyleSupport extends Plugin {
11
+ /**
12
+ * @inheritDoc
13
+ */
14
+ static get pluginName() {
15
+ return 'DocumentListStyleSupport';
16
+ }
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ static get requires() {
21
+ return [StyleUtils, 'GeneralHtmlSupport'];
22
+ }
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ init() {
27
+ const editor = this.editor;
28
+ if (!editor.plugins.has('DocumentListEditing')) {
29
+ return;
30
+ }
31
+ this._styleUtils = editor.plugins.get(StyleUtils);
32
+ this._documentListUtils = this.editor.plugins.get('DocumentListUtils');
33
+ this._htmlSupport = this.editor.plugins.get('GeneralHtmlSupport');
34
+ this.listenTo(this._styleUtils, 'isStyleEnabledForBlock', (evt, [definition, block]) => {
35
+ if (this._isStyleEnabledForBlock(definition, block)) {
36
+ evt.return = true;
37
+ evt.stop();
38
+ }
39
+ }, { priority: 'high' });
40
+ this.listenTo(this._styleUtils, 'isStyleActiveForBlock', (evt, [definition, block]) => {
41
+ if (this._isStyleActiveForBlock(definition, block)) {
42
+ evt.return = true;
43
+ evt.stop();
44
+ }
45
+ }, { priority: 'high' });
46
+ this.listenTo(this._styleUtils, 'getAffectedBlocks', (evt, [definition, block]) => {
47
+ const blocks = this._getAffectedBlocks(definition, block);
48
+ if (blocks) {
49
+ evt.return = blocks;
50
+ evt.stop();
51
+ }
52
+ }, { priority: 'high' });
53
+ this.listenTo(this._styleUtils, 'getStylePreview', (evt, [definition, children]) => {
54
+ const templateDefinition = this._getStylePreview(definition, children);
55
+ if (templateDefinition) {
56
+ evt.return = templateDefinition;
57
+ evt.stop();
58
+ }
59
+ }, { priority: 'high' });
60
+ }
61
+ /**
62
+ * Verifies if the given style is applicable to the provided block element.
63
+ */
64
+ _isStyleEnabledForBlock(definition, block) {
65
+ const model = this.editor.model;
66
+ if (!['ol', 'ul', 'li'].includes(definition.element)) {
67
+ return false;
68
+ }
69
+ if (!this._documentListUtils.isListItemBlock(block)) {
70
+ return false;
71
+ }
72
+ const attributeName = this._htmlSupport.getGhsAttributeNameForElement(definition.element);
73
+ if (definition.element == 'ol' || definition.element == 'ul') {
74
+ if (!model.schema.checkAttribute(block, attributeName)) {
75
+ return false;
76
+ }
77
+ const viewElementName = block.getAttribute('listType') == 'numbered' ? 'ol' : 'ul';
78
+ return definition.element == viewElementName;
79
+ }
80
+ else {
81
+ return model.schema.checkAttribute(block, attributeName);
82
+ }
83
+ }
84
+ /**
85
+ * Returns true if the given style is applied to the specified block element.
86
+ */
87
+ _isStyleActiveForBlock(definition, block) {
88
+ const attributeName = this._htmlSupport.getGhsAttributeNameForElement(definition.element);
89
+ const ghsAttributeValue = block.getAttribute(attributeName);
90
+ return this._styleUtils.hasAllClasses(ghsAttributeValue, definition.classes);
91
+ }
92
+ /**
93
+ * Returns an array of block elements that style should be applied to.
94
+ */
95
+ _getAffectedBlocks(definition, block) {
96
+ if (!this._isStyleEnabledForBlock(definition, block)) {
97
+ return null;
98
+ }
99
+ if (definition.element == 'li') {
100
+ return this._documentListUtils.expandListBlocksToCompleteItems(block, { withNested: false });
101
+ }
102
+ else {
103
+ return this._documentListUtils.expandListBlocksToCompleteList(block);
104
+ }
105
+ }
106
+ /**
107
+ * Returns a view template definition for the style preview.
108
+ */
109
+ _getStylePreview(definition, children) {
110
+ const { element, classes } = definition;
111
+ if (element == 'ol' || element == 'ul') {
112
+ return {
113
+ tag: element,
114
+ attributes: {
115
+ class: classes
116
+ },
117
+ children: [
118
+ {
119
+ tag: 'li',
120
+ children
121
+ }
122
+ ]
123
+ };
124
+ }
125
+ else if (element == 'li') {
126
+ return {
127
+ tag: 'ol',
128
+ children: [
129
+ {
130
+ tag: element,
131
+ attributes: {
132
+ class: classes
133
+ },
134
+ children
135
+ }
136
+ ]
137
+ };
138
+ }
139
+ return null;
140
+ }
141
+ }
@@ -1,37 +1,37 @@
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 style/integrations/link
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import StyleUtils from '../styleutils';
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
- }
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 style/integrations/link
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import StyleUtils from '../styleutils';
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
+ }