@ckeditor/ckeditor5-utils 47.4.0 → 47.5.0-alpha.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.
- package/dist/index.js +42 -47
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/dom/rect.js +27 -45
- package/src/dom/scroll.d.ts +7 -1
- package/src/dom/scroll.js +10 -2
- package/src/version.d.ts +1 -1
- package/src/version.js +2 -2
package/dist/index.js
CHANGED
|
@@ -987,9 +987,9 @@ function isObject(structure) {
|
|
|
987
987
|
];
|
|
988
988
|
}
|
|
989
989
|
|
|
990
|
-
const version = '47.
|
|
990
|
+
const version = '47.5.0-alpha.1';
|
|
991
991
|
// The second argument is not a month. It is `monthIndex` and starts from `0`.
|
|
992
|
-
const releaseDate = new Date(2026,
|
|
992
|
+
const releaseDate = new Date(2026, 1, 5);
|
|
993
993
|
/* istanbul ignore next -- @preserve */ if (globalThis.CKEDITOR_VERSION) {
|
|
994
994
|
/**
|
|
995
995
|
* This error is thrown when, due to a mistake in the way CKEditor 5 was installed,
|
|
@@ -2877,7 +2877,7 @@ function DomEmitterMixin(base) {
|
|
|
2877
2877
|
return Object.prototype.toString.apply(obj) == '[object Range]';
|
|
2878
2878
|
}
|
|
2879
2879
|
|
|
2880
|
-
const
|
|
2880
|
+
const RECT_PROPERTIES = [
|
|
2881
2881
|
'top',
|
|
2882
2882
|
'right',
|
|
2883
2883
|
'bottom',
|
|
@@ -2885,6 +2885,12 @@ const rectProperties = [
|
|
|
2885
2885
|
'width',
|
|
2886
2886
|
'height'
|
|
2887
2887
|
];
|
|
2888
|
+
const POSITIONING_VALUES = new Set([
|
|
2889
|
+
'relative',
|
|
2890
|
+
'absolute',
|
|
2891
|
+
'fixed',
|
|
2892
|
+
'sticky'
|
|
2893
|
+
]);
|
|
2888
2894
|
/**
|
|
2889
2895
|
* A helper class representing a `ClientRect` object, e.g. value returned by
|
|
2890
2896
|
* the native `object.getBoundingClientRect()` method. Provides a set of methods
|
|
@@ -3088,48 +3094,20 @@ const rectProperties = [
|
|
|
3088
3094
|
}
|
|
3089
3095
|
let child = source;
|
|
3090
3096
|
let parent = source.parentNode || source.commonAncestorContainer;
|
|
3091
|
-
let
|
|
3097
|
+
let lastPositionedChildElement;
|
|
3092
3098
|
// Check the ancestors all the way up to the <body>.
|
|
3093
3099
|
while(parent && !isBody(parent)){
|
|
3094
|
-
const
|
|
3095
|
-
if (
|
|
3096
|
-
|
|
3100
|
+
const isNonClippingParent = getElementOverflow(parent) === 'visible';
|
|
3101
|
+
if (isPositioned(child)) {
|
|
3102
|
+
lastPositionedChildElement = child;
|
|
3097
3103
|
}
|
|
3098
|
-
|
|
3099
|
-
//
|
|
3100
|
-
//
|
|
3101
|
-
//
|
|
3102
|
-
//
|
|
3103
|
-
// condition: isParentOverflowVisible
|
|
3104
|
-
// +---------------------------+
|
|
3105
|
-
// | #parent |
|
|
3106
|
-
// | (overflow: visible) |
|
|
3107
|
-
// | +-----------+---------------+
|
|
3108
|
-
// | | child |
|
|
3109
|
-
// | +-----------+---------------+
|
|
3110
|
-
// +---------------------------+
|
|
3104
|
+
// 1. If a parent has overflow: visible, it can be safely skipped in consideration for any parent-child configuration.
|
|
3105
|
+
// 2. If a parent has any other overflow (it clips), for the actual clipping to happen the following must be true:
|
|
3106
|
+
// * the last positioned child must have `position: absolute`,
|
|
3107
|
+
// * the parent must have a position other than `position: static`.
|
|
3111
3108
|
//
|
|
3112
|
-
//
|
|
3113
|
-
|
|
3114
|
-
// | parent |
|
|
3115
|
-
// | (position: relative;) |
|
|
3116
|
-
// | (overflow: visible;) |
|
|
3117
|
-
// | +-----------+---------------+
|
|
3118
|
-
// | | child |
|
|
3119
|
-
// | | (position: absolute;) |
|
|
3120
|
-
// | +-----------+---------------+
|
|
3121
|
-
// +---------------------------+
|
|
3122
|
-
//
|
|
3123
|
-
// condition: absolutelyPositionedChildElement && parentElementPosition !== 'relative'
|
|
3124
|
-
// +---------------------------+
|
|
3125
|
-
// | parent |
|
|
3126
|
-
// | (position: static;) |
|
|
3127
|
-
// | +-----------+---------------+
|
|
3128
|
-
// | | child |
|
|
3129
|
-
// | | (position: absolute;) |
|
|
3130
|
-
// | +-----------+---------------+
|
|
3131
|
-
// +---------------------------+
|
|
3132
|
-
if (isParentOverflowVisible || absolutelyPositionedChildElement && (parentElementPosition === 'relative' && isParentOverflowVisible || parentElementPosition !== 'relative')) {
|
|
3109
|
+
// https://github.com/ckeditor/ckeditor5/issues/14107.
|
|
3110
|
+
if (isNonClippingParent || lastPositionedChildElement && getElementPosition(lastPositionedChildElement) === 'absolute' && !isPositioned(parent)) {
|
|
3133
3111
|
child = parent;
|
|
3134
3112
|
parent = parent.parentNode;
|
|
3135
3113
|
continue;
|
|
@@ -3158,7 +3136,7 @@ const rectProperties = [
|
|
|
3158
3136
|
* @param anotherRect A rect instance to compare with.
|
|
3159
3137
|
* @returns `true` when Rects are equal. `false` otherwise.
|
|
3160
3138
|
*/ isEqual(anotherRect) {
|
|
3161
|
-
for (const prop of
|
|
3139
|
+
for (const prop of RECT_PROPERTIES){
|
|
3162
3140
|
if (this[prop] !== anotherRect[prop]) {
|
|
3163
3141
|
return false;
|
|
3164
3142
|
}
|
|
@@ -3234,7 +3212,11 @@ const rectProperties = [
|
|
|
3234
3212
|
const clientRects = Array.from(range.getClientRects());
|
|
3235
3213
|
if (clientRects.length) {
|
|
3236
3214
|
for (const rect of clientRects){
|
|
3237
|
-
|
|
3215
|
+
const r = new Rect(rect);
|
|
3216
|
+
// Point the rect source to the DOM range instead of of the DOM client rect to allow proper clipping,
|
|
3217
|
+
// in `Rect#getVisible()` method.
|
|
3218
|
+
r._source = range;
|
|
3219
|
+
rects.push(r);
|
|
3238
3220
|
}
|
|
3239
3221
|
} else {
|
|
3240
3222
|
let startContainer = range.startContainer;
|
|
@@ -3281,7 +3263,7 @@ const rectProperties = [
|
|
|
3281
3263
|
/**
|
|
3282
3264
|
* Acquires all the rect properties from the passed source.
|
|
3283
3265
|
*/ function copyRectProperties(rect, source) {
|
|
3284
|
-
for (const p of
|
|
3266
|
+
for (const p of RECT_PROPERTIES){
|
|
3285
3267
|
rect[p] = source[p];
|
|
3286
3268
|
}
|
|
3287
3269
|
}
|
|
@@ -3303,13 +3285,18 @@ const rectProperties = [
|
|
|
3303
3285
|
/**
|
|
3304
3286
|
* Returns the value of the `position` style of an `HTMLElement`.
|
|
3305
3287
|
*/ function getElementPosition(element) {
|
|
3306
|
-
return element
|
|
3288
|
+
return element.ownerDocument.defaultView.getComputedStyle(element).position;
|
|
3307
3289
|
}
|
|
3308
3290
|
/**
|
|
3309
3291
|
* Returns the value of the `overflow` style of an `HTMLElement` or a `Range`.
|
|
3310
3292
|
*/ function getElementOverflow(element) {
|
|
3311
3293
|
return element instanceof HTMLElement ? element.ownerDocument.defaultView.getComputedStyle(element).overflow : 'visible';
|
|
3312
3294
|
}
|
|
3295
|
+
/**
|
|
3296
|
+
* Checks if the given node is positioned in any other way than `position: static`.
|
|
3297
|
+
*/ function isPositioned(node) {
|
|
3298
|
+
return node instanceof HTMLElement && POSITIONING_VALUES.has(getElementPosition(node));
|
|
3299
|
+
}
|
|
3313
3300
|
/**
|
|
3314
3301
|
* For a given absolute Rect coordinates object and a positioned element ancestor, it updates its
|
|
3315
3302
|
* coordinates that make up for the position and the scroll of the ancestor.
|
|
@@ -4040,13 +4027,21 @@ const rectProperties = [
|
|
|
4040
4027
|
* to be maintained while scrolling.
|
|
4041
4028
|
* @param limiterElement The outermost ancestor that should be scrolled. If specified, it can prevent
|
|
4042
4029
|
* scrolling the whole page.
|
|
4043
|
-
|
|
4030
|
+
* @param alignToTop When set `true`, the function will make sure the `target` is scrolled up
|
|
4031
|
+
* to the top boundary of the scrollable ancestors if scrolled up. When not set (default), the `target`
|
|
4032
|
+
* will be revealed by scrolling as little as possible. This option will not affect target elements that must be
|
|
4033
|
+
* scrolled down because they will appear at the top of the boundary anyway.
|
|
4034
|
+
* @param forceScroll When set `true`, the `target` will be aligned to the top of scrollable ancestors
|
|
4035
|
+
* whether it is already visible or not. This option will only work when `alignToTop` is `true`
|
|
4036
|
+
*/ function scrollAncestorsToShowTarget(target, ancestorOffset, limiterElement, alignToTop, forceScroll) {
|
|
4044
4037
|
const targetParent = getParentElement(target);
|
|
4045
4038
|
scrollAncestorsToShowRect({
|
|
4046
4039
|
parent: targetParent,
|
|
4047
4040
|
getRect: ()=>new Rect(target),
|
|
4048
4041
|
ancestorOffset,
|
|
4049
|
-
limiterElement
|
|
4042
|
+
limiterElement,
|
|
4043
|
+
alignToTop,
|
|
4044
|
+
forceScroll
|
|
4050
4045
|
});
|
|
4051
4046
|
}
|
|
4052
4047
|
/**
|