@ckeditor/ckeditor5-list 47.1.0-alpha.2 → 47.2.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/README.md +1 -1
- package/build/list.js +1 -1
- package/dist/index.js +30 -3
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/list/converters.d.ts +3 -2
- package/src/list/converters.js +28 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-list",
|
|
3
|
-
"version": "47.
|
|
3
|
+
"version": "47.2.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.
|
|
17
|
-
"@ckeditor/ckeditor5-core": "47.
|
|
18
|
-
"@ckeditor/ckeditor5-engine": "47.
|
|
19
|
-
"@ckeditor/ckeditor5-enter": "47.
|
|
20
|
-
"@ckeditor/ckeditor5-font": "47.
|
|
21
|
-
"@ckeditor/ckeditor5-icons": "47.
|
|
22
|
-
"@ckeditor/ckeditor5-typing": "47.
|
|
23
|
-
"@ckeditor/ckeditor5-ui": "47.
|
|
24
|
-
"@ckeditor/ckeditor5-utils": "47.
|
|
25
|
-
"ckeditor5": "47.
|
|
16
|
+
"@ckeditor/ckeditor5-clipboard": "47.2.0-alpha.0",
|
|
17
|
+
"@ckeditor/ckeditor5-core": "47.2.0-alpha.0",
|
|
18
|
+
"@ckeditor/ckeditor5-engine": "47.2.0-alpha.0",
|
|
19
|
+
"@ckeditor/ckeditor5-enter": "47.2.0-alpha.0",
|
|
20
|
+
"@ckeditor/ckeditor5-font": "47.2.0-alpha.0",
|
|
21
|
+
"@ckeditor/ckeditor5-icons": "47.2.0-alpha.0",
|
|
22
|
+
"@ckeditor/ckeditor5-typing": "47.2.0-alpha.0",
|
|
23
|
+
"@ckeditor/ckeditor5-ui": "47.2.0-alpha.0",
|
|
24
|
+
"@ckeditor/ckeditor5-utils": "47.2.0-alpha.0",
|
|
25
|
+
"ckeditor5": "47.2.0-alpha.0"
|
|
26
26
|
},
|
|
27
27
|
"author": "CKSource (http://cksource.com/)",
|
|
28
28
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/src/list/converters.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module list/list/converters
|
|
7
7
|
*/
|
|
8
|
-
import { type DowncastAttributeEvent, type EditingController, type ModelElement, type DowncastElementCreatorFunction, type Mapper, type Model, type UpcastElementEvent, type ViewElement, type DowncastRemoveEvent, type EditingView, type MapperModelToViewPositionEvent, type ModelSchema } from 'ckeditor5/src/engine.js';
|
|
8
|
+
import { type DowncastAttributeEvent, type ViewDowncastWriter, type EditingController, type ModelElement, type DowncastElementCreatorFunction, type Mapper, type Model, type UpcastElementEvent, type ViewElement, type DowncastRemoveEvent, type EditingView, type MapperModelToViewPositionEvent, type ModelSchema } from 'ckeditor5/src/engine.js';
|
|
9
9
|
import type { GetCallback } from 'ckeditor5/src/utils.js';
|
|
10
10
|
import { type ListElement } from './utils/model.js';
|
|
11
11
|
import type { ListEditing, ListDowncastStrategy } from './listediting.js';
|
|
@@ -59,8 +59,9 @@ export declare function bogusParagraphCreator(attributeNames: Array<string>, { d
|
|
|
59
59
|
* @param element The model element.
|
|
60
60
|
* @param mapper The mapper instance.
|
|
61
61
|
* @param model The model.
|
|
62
|
+
* @param writer The view downcast writer.
|
|
62
63
|
*/
|
|
63
|
-
export declare function findMappedViewElement(element: ModelElement, mapper: Mapper, model: Model): ViewElement |
|
|
64
|
+
export declare function findMappedViewElement(element: ModelElement, mapper: Mapper, model: Model, writer: ViewDowncastWriter): ViewElement | undefined;
|
|
64
65
|
/**
|
|
65
66
|
* The model to view custom position mapping for cases when marker is injected at the beginning of a block.
|
|
66
67
|
*
|
package/src/list/converters.js
CHANGED
|
@@ -161,6 +161,9 @@ export function reconvertItemsOnDataChange(model, editing, attributeNames, listE
|
|
|
161
161
|
if (!viewElement) {
|
|
162
162
|
return false;
|
|
163
163
|
}
|
|
164
|
+
if (isItemBlockInsideStructureSlot(viewElement)) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
164
167
|
const needsRefresh = listEditing.fire('checkElement', {
|
|
165
168
|
modelElement: item,
|
|
166
169
|
viewElement
|
|
@@ -180,6 +183,19 @@ export function reconvertItemsOnDataChange(model, editing, attributeNames, listE
|
|
|
180
183
|
}
|
|
181
184
|
return false;
|
|
182
185
|
}
|
|
186
|
+
function isItemBlockInsideStructureSlot(viewElement) {
|
|
187
|
+
viewElement = viewElement.parent;
|
|
188
|
+
while (viewElement.is('attributeElement') && ['ol', 'ul', 'li'].includes(viewElement.name)) {
|
|
189
|
+
viewElement = viewElement.parent;
|
|
190
|
+
}
|
|
191
|
+
// List item inside elementToStructure slot parent without mapping then it requires refresh for correct positions
|
|
192
|
+
// as structure child elements does not have mapping from model and position would land in wrong place.
|
|
193
|
+
if (viewElement.getCustomProperty('$structureSlotParent') &&
|
|
194
|
+
!editing.mapper.toModelElement(viewElement)) {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
183
199
|
function doesItemWrappingRequiresRefresh(item, stack, changedItems) {
|
|
184
200
|
// Items directly affected by some "change" don't need a refresh, they will be converted by their own changes.
|
|
185
201
|
if (changedItems.has(item)) {
|
|
@@ -240,7 +256,7 @@ export function listItemDowncastConverter(attributeNames, strategies, model, { d
|
|
|
240
256
|
};
|
|
241
257
|
// Use positions mapping instead of mapper.toViewElement( listItem ) to find outermost view element.
|
|
242
258
|
// This is for cases when mapping is using inner view element like in the code blocks (pre > code).
|
|
243
|
-
const viewElement = findMappedViewElement(listItem, mapper, model);
|
|
259
|
+
const viewElement = findMappedViewElement(listItem, mapper, model, writer);
|
|
244
260
|
// Remove custom item marker.
|
|
245
261
|
removeCustomMarkerElements(viewElement, writer, mapper);
|
|
246
262
|
// Unwrap element from current list wrappers.
|
|
@@ -311,11 +327,20 @@ export function bogusParagraphCreator(attributeNames, { dataPipeline } = {}) {
|
|
|
311
327
|
* @param element The model element.
|
|
312
328
|
* @param mapper The mapper instance.
|
|
313
329
|
* @param model The model.
|
|
330
|
+
* @param writer The view downcast writer.
|
|
314
331
|
*/
|
|
315
|
-
export function findMappedViewElement(element, mapper, model) {
|
|
332
|
+
export function findMappedViewElement(element, mapper, model, writer) {
|
|
316
333
|
const modelRange = model.createRangeOn(element);
|
|
317
334
|
const viewRange = mapper.toViewRange(modelRange).getTrimmed();
|
|
318
|
-
|
|
335
|
+
const viewWalker = viewRange.getWalker();
|
|
336
|
+
for (const { item } of viewWalker) {
|
|
337
|
+
if (item.is('element') && item.getCustomProperty('listItemMarker')) {
|
|
338
|
+
viewWalker.jumpTo(writer.createPositionAfter(item));
|
|
339
|
+
}
|
|
340
|
+
else if (item.is('element') && !item.getCustomProperty('listItemWrapper')) {
|
|
341
|
+
return item;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
319
344
|
}
|
|
320
345
|
/**
|
|
321
346
|
* The model to view custom position mapping for cases when marker is injected at the beginning of a block.
|