@ckeditor/ckeditor5-list 47.2.0 → 47.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-list",
3
- "version": "47.2.0",
3
+ "version": "47.3.0-alpha.0",
4
4
  "description": "Ordered and unordered lists feature to CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,16 +13,16 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-clipboard": "47.2.0",
17
- "@ckeditor/ckeditor5-core": "47.2.0",
18
- "@ckeditor/ckeditor5-engine": "47.2.0",
19
- "@ckeditor/ckeditor5-enter": "47.2.0",
20
- "@ckeditor/ckeditor5-font": "47.2.0",
21
- "@ckeditor/ckeditor5-icons": "47.2.0",
22
- "@ckeditor/ckeditor5-typing": "47.2.0",
23
- "@ckeditor/ckeditor5-ui": "47.2.0",
24
- "@ckeditor/ckeditor5-utils": "47.2.0",
25
- "ckeditor5": "47.2.0"
16
+ "@ckeditor/ckeditor5-clipboard": "47.3.0-alpha.0",
17
+ "@ckeditor/ckeditor5-core": "47.3.0-alpha.0",
18
+ "@ckeditor/ckeditor5-engine": "47.3.0-alpha.0",
19
+ "@ckeditor/ckeditor5-enter": "47.3.0-alpha.0",
20
+ "@ckeditor/ckeditor5-font": "47.3.0-alpha.0",
21
+ "@ckeditor/ckeditor5-icons": "47.3.0-alpha.0",
22
+ "@ckeditor/ckeditor5-typing": "47.3.0-alpha.0",
23
+ "@ckeditor/ckeditor5-ui": "47.3.0-alpha.0",
24
+ "@ckeditor/ckeditor5-utils": "47.3.0-alpha.0",
25
+ "ckeditor5": "47.3.0-alpha.0"
26
26
  },
27
27
  "author": "CKSource (http://cksource.com/)",
28
28
  "license": "SEE LICENSE IN LICENSE.md",
@@ -239,7 +239,7 @@ export function reconvertItemsOnDataChange(model, editing, attributeNames, listE
239
239
  * @param model The model.
240
240
  */
241
241
  export function listItemDowncastConverter(attributeNames, strategies, model, { dataPipeline } = {}) {
242
- const consumer = createAttributesConsumer(attributeNames);
242
+ const consumer = createAttributesConsumer(attributeNames, strategies);
243
243
  return (evt, data, conversionApi) => {
244
244
  const { writer, mapper, consumable } = conversionApi;
245
245
  const listItem = data.item;
@@ -478,7 +478,7 @@ function wrapListItemBlock(listItem, viewRange, strategies, writer, options) {
478
478
  for (const strategy of strategies) {
479
479
  if ((strategy.scope == 'list' || strategy.scope == 'item') &&
480
480
  currentListItem.hasAttribute(strategy.attributeName)) {
481
- strategy.setAttributeOnDowncast(writer, currentListItem.getAttribute(strategy.attributeName), strategy.scope == 'list' ? listViewElement : listItemViewElement, options);
481
+ strategy.setAttributeOnDowncast(writer, currentListItem.getAttribute(strategy.attributeName), strategy.scope == 'list' ? listViewElement : listItemViewElement, options, currentListItem);
482
482
  }
483
483
  }
484
484
  viewRange = writer.wrap(viewRange, listItemViewElement);
@@ -495,12 +495,15 @@ function wrapListItemBlock(listItem, viewRange, strategies, writer, options) {
495
495
  }
496
496
  }
497
497
  // Returns the function that is responsible for consuming attributes that are set on the model node.
498
- function createAttributesConsumer(attributeNames) {
498
+ function createAttributesConsumer(attributeNames, strategies) {
499
+ const nonConsumingAttributes = strategies
500
+ .filter(strategy => strategy.consume === false)
501
+ .map(strategy => strategy.attributeName);
499
502
  return (node, consumable) => {
500
503
  const events = [];
501
504
  // Collect all set attributes that are triggering conversion.
502
505
  for (const attributeName of attributeNames) {
503
- if (node.hasAttribute(attributeName)) {
506
+ if (node.hasAttribute(attributeName) && !nonConsumingAttributes.includes(attributeName)) {
504
507
  events.push(`attribute:${attributeName}`);
505
508
  }
506
509
  }
@@ -119,10 +119,16 @@ export interface ListAttributeDowncastStrategy {
119
119
  * The model attribute name.
120
120
  */
121
121
  attributeName: string;
122
+ /**
123
+ * Whether the attribute should be consumed or this strategy is a side effect.
124
+ *
125
+ * @default true
126
+ */
127
+ consume?: boolean;
122
128
  /**
123
129
  * Sets the property on the view element.
124
130
  */
125
- setAttributeOnDowncast(writer: ViewDowncastWriter, value: unknown, element: ViewElement, options?: Record<string, unknown>): void;
131
+ setAttributeOnDowncast(writer: ViewDowncastWriter, value: unknown, element: ViewElement, options: Record<string, unknown>, modelElement: ModelElement): void;
126
132
  }
127
133
  /**
128
134
  * The custom marker downcast strategy.
@@ -136,6 +142,12 @@ export interface ListItemMarkerDowncastStrategy {
136
142
  * The model attribute name.
137
143
  */
138
144
  attributeName: string;
145
+ /**
146
+ * Whether the attribute should be consumed or this strategy is a side effect.
147
+ *
148
+ * @default true
149
+ */
150
+ consume?: boolean;
139
151
  /**
140
152
  * Creates a view element for a custom item marker.
141
153
  */