@ckeditor/ckeditor5-list 35.4.0 → 36.0.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.
Files changed (54) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/list.js +2 -2
  3. package/package.json +43 -39
  4. package/src/documentlist/converters.js +303 -419
  5. package/src/documentlist/documentlistcommand.js +136 -207
  6. package/src/documentlist/documentlistediting.js +538 -698
  7. package/src/documentlist/documentlistindentcommand.js +115 -168
  8. package/src/documentlist/documentlistmergecommand.js +161 -222
  9. package/src/documentlist/documentlistsplitcommand.js +59 -103
  10. package/src/documentlist/documentlistutils.js +31 -45
  11. package/src/documentlist/utils/listwalker.js +138 -236
  12. package/src/documentlist/utils/model.js +322 -421
  13. package/src/documentlist/utils/postfixers.js +98 -126
  14. package/src/documentlist/utils/view.js +74 -105
  15. package/src/documentlist.js +13 -19
  16. package/src/documentlistproperties/converters.js +33 -47
  17. package/src/documentlistproperties/documentlistpropertiesediting.js +265 -356
  18. package/src/documentlistproperties/documentlistpropertiesutils.js +32 -57
  19. package/src/documentlistproperties/documentlistreversedcommand.js +40 -61
  20. package/src/documentlistproperties/documentliststartcommand.js +42 -61
  21. package/src/documentlistproperties/documentliststylecommand.js +97 -147
  22. package/src/documentlistproperties/utils/style.js +27 -47
  23. package/src/documentlistproperties.js +13 -19
  24. package/src/index.js +1 -3
  25. package/src/list/converters.js +772 -929
  26. package/src/list/indentcommand.js +105 -140
  27. package/src/list/listcommand.js +262 -315
  28. package/src/list/listediting.js +141 -200
  29. package/src/list/listui.js +16 -25
  30. package/src/list/listutils.js +37 -59
  31. package/src/list/utils.js +295 -378
  32. package/src/list.js +13 -44
  33. package/src/listcommands.js +5 -0
  34. package/src/listconfig.js +5 -0
  35. package/src/listproperties/listpropertiesediting.js +656 -803
  36. package/src/listproperties/listpropertiesui.js +244 -296
  37. package/src/listproperties/listreversedcommand.js +37 -49
  38. package/src/listproperties/liststartcommand.js +37 -49
  39. package/src/listproperties/liststylecommand.js +82 -115
  40. package/src/listproperties/ui/collapsibleview.js +75 -138
  41. package/src/listproperties/ui/listpropertiesview.js +289 -415
  42. package/src/listproperties.js +13 -118
  43. package/src/liststyle.js +18 -24
  44. package/src/todolist/checktodolistcommand.js +60 -102
  45. package/src/todolist/todolistconverters.js +189 -271
  46. package/src/todolist/todolistediting.js +141 -206
  47. package/src/todolist/todolistui.js +14 -21
  48. package/src/todolist.js +13 -19
  49. package/theme/collapsible.css +1 -1
  50. package/theme/documentlist.css +1 -1
  51. package/theme/list.css +40 -0
  52. package/theme/listproperties.css +1 -1
  53. package/theme/liststyles.css +1 -37
  54. package/theme/todolist.css +1 -1
@@ -1,135 +1,30 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module list/listproperties
8
7
  */
9
-
10
8
  import { Plugin } from 'ckeditor5/src/core';
11
9
  import ListPropertiesEditing from './listproperties/listpropertiesediting';
12
10
  import ListPropertiesUI from './listproperties/listpropertiesui';
13
-
14
11
  /**
15
12
  * The list properties feature.
16
13
  *
17
14
  * This is a "glue" plugin that loads the {@link module:list/listproperties/listpropertiesediting~ListPropertiesEditing list properties
18
15
  * editing feature} and the {@link module:list/listproperties/listpropertiesui~ListPropertiesUI list properties UI feature}.
19
- *
20
- * @extends module:core/plugin~Plugin
21
16
  */
22
17
  export default class ListProperties extends Plugin {
23
- /**
24
- * @inheritDoc
25
- */
26
- static get requires() {
27
- return [ ListPropertiesEditing, ListPropertiesUI ];
28
- }
29
-
30
- /**
31
- * @inheritDoc
32
- */
33
- static get pluginName() {
34
- return 'ListProperties';
35
- }
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get requires() {
22
+ return [ListPropertiesEditing, ListPropertiesUI];
23
+ }
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get pluginName() {
28
+ return 'ListProperties';
29
+ }
36
30
  }
37
-
38
- /**
39
- * The configuration of the {@link module:list/listproperties~ListProperties list properties} feature and the
40
- * {@link module:list/documentlistproperties~DocumentListProperties document list properties} feature.
41
- *
42
- * This configuration controls the individual list properties. For instance, it enables or disables specific editor commands
43
- * operating on lists ({@link module:list/listproperties/liststylecommand~ListStyleCommand `'listStyle'`},
44
- * {@link module:list/listproperties/liststartcommand~ListStartCommand `'listStart'`},
45
- * {@link module:list/listproperties/listreversedcommand~ListReversedCommand `'listReversed'`}, or on the document lists
46
- * {@link module:list/documentlistproperties/documentliststylecommand~DocumentListStyleCommand `'listStyle'`},
47
- * {@link module:list/documentlistproperties/documentliststartcommand~DocumentListStartCommand `'listStart'`},
48
- * {@link module:list/documentlistproperties/documentlistreversedcommand~DocumentListReversedCommand `'listReversed'`}), the look of the UI
49
- * (`'numberedList'` and `'bulletedList'` dropdowns), and the editor data pipeline (allowed HTML attributes).
50
- *
51
- * ClassicEditor
52
- * .create( editorElement, {
53
- * list: {
54
- * properties: {
55
- * styles: true,
56
- * startIndex: true,
57
- * reversed: true
58
- * }
59
- * }
60
- * } )
61
- * .then( ... )
62
- * .catch( ... );
63
- *
64
- * @interface ListPropertiesConfig
65
- */
66
-
67
- /**
68
- * When set, the list style feature will be enabled. It allows changing the `list-style-type` style or the `type` HTML attribute of a list.
69
- *
70
- * **Note**: Styling using the `type` HTML attribute is only available in
71
- * {@link module:list/documentlistproperties~DocumentListProperties document list properties}
72
- * ({@link module:list/listproperties~ListPropertiesStyleConfig learn more}).
73
- *
74
- * @default true
75
- * @member {Boolean|module:list/listproperties~ListPropertiesStyleConfig} module:list/listproperties~ListPropertiesConfig#styles
76
- */
77
-
78
- /**
79
- * When set, the list start index feature will be enabled. It allows changing the `start` HTML attribute of the numbered lists. As a
80
- * result, it will be possible to specify the start value of the first item in an ordered list.
81
- *
82
- * **Note**: This configuration does not affect bulleted and to-do lists.
83
- *
84
- * @default false
85
- * @member {Boolean} module:list/listproperties~ListPropertiesConfig#startIndex
86
- */
87
-
88
- /**
89
- * When set, the reversed list feature will be enabled. It allows changing the `reversed` HTML attribute of the numbered lists. As a
90
- * result, it will be possible to make the list order descending instead of ascending.
91
- *
92
- * **Note**: This configuration does not affect bulleted and to-do lists.
93
- *
94
- * @default false
95
- * @member {Boolean} module:list/listproperties~ListPropertiesConfig#reversed
96
- */
97
-
98
- /**
99
- * The configuration of the {@link module:list/listproperties~ListProperties} feature and the
100
- * {@link module:list/documentlistproperties~DocumentListProperties document list properties} feature.
101
- *
102
- * Read more in {@link module:list/listproperties~ListPropertiesConfig}.
103
- *
104
- * @member {module:list/listproperties~ListPropertiesConfig} module:list/list~ListConfig#properties
105
- */
106
-
107
- /**
108
- * @interface ListPropertiesStyleConfig
109
- */
110
-
111
- /**
112
- * When set `true`, the list style feature will use the `type` attribute of `<ul>` and `<ol>` elements instead of the `list-style-type`
113
- * style.
114
- *
115
- * {
116
- * list: {
117
- * properties: {
118
- * styles: {
119
- * useAttribute: true
120
- * },
121
- *
122
- * // ...
123
- * }
124
- * },
125
- *
126
- * // ...
127
- * }
128
- *
129
- * **Note**: Due to limitations of HTML, the "Decimal with leading zero" style is impossible to set using the `type` attribute.
130
- *
131
- * **Note**: This configuration works only with {@link module:list/documentlistproperties~DocumentListProperties document list properties}.
132
- *
133
- * @default false
134
- * @member {Boolean} module:list/listproperties~ListPropertiesStyleConfig#useAttribute
135
- */
package/src/liststyle.js CHANGED
@@ -1,42 +1,36 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module list/liststyle
8
7
  */
9
-
10
8
  import { Plugin } from 'ckeditor5/src/core';
11
9
  import ListProperties from './listproperties';
12
10
  import { logWarning } from 'ckeditor5/src/utils';
13
-
14
11
  /**
15
12
  * The list style feature.
16
13
  *
17
14
  * This is an obsolete plugin that exists for backward compatibility only.
18
15
  * Use the {@link module:list/listproperties~ListProperties list properties plugin} instead.
19
16
  *
20
- * @extends module:core/plugin~Plugin
17
+ * @deprecated
21
18
  */
22
19
  export default class ListStyle extends Plugin {
23
- /**
24
- * @inheritDoc
25
- */
26
- static get requires() {
27
- return [ ListProperties ];
28
- }
29
-
30
- /**
31
- * @inheritDoc
32
- */
33
- static get pluginName() {
34
- return 'ListStyle';
35
- }
36
-
37
- constructor( editor ) {
38
- super( editor );
39
-
40
- logWarning( 'The `ListStyle` plugin is obsolete. Use `ListProperties` instead.' );
41
- }
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ static get requires() {
24
+ return [ListProperties];
25
+ }
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get pluginName() {
30
+ return 'ListStyle';
31
+ }
32
+ constructor(editor) {
33
+ super(editor);
34
+ logWarning('The `ListStyle` plugin is obsolete. Use `ListProperties` instead.');
35
+ }
42
36
  }
@@ -1,118 +1,76 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module list/todolist/checktodolistcommand
8
7
  */
9
-
10
8
  import { Command } from 'ckeditor5/src/core';
11
-
12
9
  const attributeKey = 'todoListChecked';
13
-
14
10
  /**
15
11
  * The check to-do command.
16
12
  *
17
13
  * The command is registered by the {@link module:list/todolist/todolistediting~TodoListEditing} as
18
14
  * the `checkTodoList` editor command and it is also available via aliased `todoListCheck` name.
19
- *
20
- * @extends module:core/command~Command
21
15
  */
22
16
  export default class CheckTodoListCommand extends Command {
23
- /**
24
- * @inheritDoc
25
- */
26
- constructor( editor ) {
27
- super( editor );
28
-
29
- /**
30
- * A flag indicating whether the command is active. The command is active when at least one of
31
- * {@link module:engine/model/selection~Selection selected} elements is a to-do list item.
32
- *
33
- * @observable
34
- * @readonly
35
- * @member {Boolean} #isEnabled
36
- */
37
-
38
- /**
39
- * A list of to-do list items selected by the {@link module:engine/model/selection~Selection}.
40
- *
41
- * @observable
42
- * @readonly
43
- * @member {Array.<module:engine/model/element~Element>} #value
44
- */
45
-
46
- /**
47
- * A list of to-do list items selected by the {@link module:engine/model/selection~Selection}.
48
- *
49
- * @protected
50
- * @type {Array.<module:engine/model/element~Element>}
51
- */
52
- this._selectedElements = [];
53
-
54
- // Refresh command before executing to be sure all values are up to date.
55
- // It is needed when selection has changed before command execution, in the same change block.
56
- this.on( 'execute', () => {
57
- this.refresh();
58
- }, { priority: 'highest' } );
59
- }
60
-
61
- /**
62
- * Updates the command's {@link #value} and {@link #isEnabled} properties based on the current selection.
63
- */
64
- refresh() {
65
- this._selectedElements = this._getSelectedItems();
66
- this.value = this._selectedElements.every( element => !!element.getAttribute( 'todoListChecked' ) );
67
- this.isEnabled = !!this._selectedElements.length;
68
- }
69
-
70
- /**
71
- * Gets all to-do list items selected by the {@link module:engine/model/selection~Selection}.
72
- *
73
- * @private
74
- * @returns {Array.<module:engine/model/element~Element>}
75
- */
76
- _getSelectedItems() {
77
- const model = this.editor.model;
78
- const schema = model.schema;
79
-
80
- const selectionRange = model.document.selection.getFirstRange();
81
- const startElement = selectionRange.start.parent;
82
- const elements = [];
83
-
84
- if ( schema.checkAttribute( startElement, attributeKey ) ) {
85
- elements.push( startElement );
86
- }
87
-
88
- for ( const item of selectionRange.getItems() ) {
89
- if ( schema.checkAttribute( item, attributeKey ) && !elements.includes( item ) ) {
90
- elements.push( item );
91
- }
92
- }
93
-
94
- return elements;
95
- }
96
-
97
- /**
98
- * Executes the command.
99
- *
100
- * @param {Object} [options]
101
- * @param {Boolean} [options.forceValue] If set, it will force the command behavior. If `true`, the command will apply
102
- * the attribute. Otherwise, the command will remove the attribute. If not set, the command will look for its current
103
- * value to decide what it should do.
104
- */
105
- execute( options = {} ) {
106
- this.editor.model.change( writer => {
107
- for ( const element of this._selectedElements ) {
108
- const value = ( options.forceValue === undefined ) ? !this.value : options.forceValue;
109
-
110
- if ( value ) {
111
- writer.setAttribute( attributeKey, true, element );
112
- } else {
113
- writer.removeAttribute( attributeKey, element );
114
- }
115
- }
116
- } );
117
- }
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ constructor(editor) {
21
+ super(editor);
22
+ this._selectedElements = [];
23
+ // Refresh command before executing to be sure all values are up to date.
24
+ // It is needed when selection has changed before command execution, in the same change block.
25
+ this.on('execute', () => {
26
+ this.refresh();
27
+ }, { priority: 'highest' });
28
+ }
29
+ /**
30
+ * Updates the command's {@link #value} and {@link #isEnabled} properties based on the current selection.
31
+ */
32
+ refresh() {
33
+ this._selectedElements = this._getSelectedItems();
34
+ this.value = this._selectedElements.every(element => !!element.getAttribute(attributeKey));
35
+ this.isEnabled = !!this._selectedElements.length;
36
+ }
37
+ /**
38
+ * Gets all to-do list items selected by the {@link module:engine/model/selection~Selection}.
39
+ */
40
+ _getSelectedItems() {
41
+ const model = this.editor.model;
42
+ const schema = model.schema;
43
+ const selectionRange = model.document.selection.getFirstRange();
44
+ const startElement = selectionRange.start.parent;
45
+ const elements = [];
46
+ if (schema.checkAttribute(startElement, attributeKey)) {
47
+ elements.push(startElement);
48
+ }
49
+ for (const item of selectionRange.getItems()) {
50
+ if (schema.checkAttribute(item, attributeKey) && !elements.includes(item)) {
51
+ elements.push(item);
52
+ }
53
+ }
54
+ return elements;
55
+ }
56
+ /**
57
+ * Executes the command.
58
+ *
59
+ * @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply
60
+ * the attribute. Otherwise, the command will remove the attribute. If not set, the command will look for its current
61
+ * value to decide what it should do.
62
+ */
63
+ execute(options = {}) {
64
+ this.editor.model.change(writer => {
65
+ for (const element of this._selectedElements) {
66
+ const value = (options.forceValue === undefined) ? !this.value : options.forceValue;
67
+ if (value) {
68
+ writer.setAttribute(attributeKey, true, element);
69
+ }
70
+ else {
71
+ writer.removeAttribute(attributeKey, element);
72
+ }
73
+ }
74
+ });
75
+ }
118
76
  }