@ckeditor/ckeditor5-widget 0.0.0-nightly-20240506.0 → 0.0.0-nightly-20240508.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.

Potentially problematic release.


This version of @ckeditor/ckeditor5-widget might be problematic. Click here for more details.

@@ -204,7 +204,7 @@ export declare function viewToModelPositionOutsideModelElement(model: Model, vie
204
204
  * Starting from a DOM resize host element (an element that receives dimensions as a result of resizing),
205
205
  * this helper returns the width of the found ancestor element.
206
206
  *
207
- * **Note**: This helper searches up to 5 levels of ancestors only.
207
+ * * It searches up to 5 levels of ancestors only.
208
208
  *
209
209
  * @param domResizeHost Resize host DOM element that receives dimensions as a result of resizing.
210
210
  * @returns Width of ancestor element in pixels or 0 if no ancestor with a computed width has been found.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-widget",
3
- "version": "0.0.0-nightly-20240506.0",
3
+ "version": "0.0.0-nightly-20240508.0",
4
4
  "description": "Widget API for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,12 +12,12 @@
12
12
  "type": "module",
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "@ckeditor/ckeditor5-core": "0.0.0-nightly-20240506.0",
16
- "@ckeditor/ckeditor5-engine": "0.0.0-nightly-20240506.0",
17
- "@ckeditor/ckeditor5-enter": "0.0.0-nightly-20240506.0",
18
- "@ckeditor/ckeditor5-ui": "0.0.0-nightly-20240506.0",
19
- "@ckeditor/ckeditor5-utils": "0.0.0-nightly-20240506.0",
20
- "@ckeditor/ckeditor5-typing": "0.0.0-nightly-20240506.0",
15
+ "@ckeditor/ckeditor5-core": "0.0.0-nightly-20240508.0",
16
+ "@ckeditor/ckeditor5-engine": "0.0.0-nightly-20240508.0",
17
+ "@ckeditor/ckeditor5-enter": "0.0.0-nightly-20240508.0",
18
+ "@ckeditor/ckeditor5-ui": "0.0.0-nightly-20240508.0",
19
+ "@ckeditor/ckeditor5-utils": "0.0.0-nightly-20240508.0",
20
+ "@ckeditor/ckeditor5-typing": "0.0.0-nightly-20240508.0",
21
21
  "lodash-es": "4.17.21"
22
22
  },
23
23
  "author": "CKSource (http://cksource.com/)",
package/src/utils.d.ts CHANGED
@@ -200,7 +200,7 @@ export declare function viewToModelPositionOutsideModelElement(model: Model, vie
200
200
  * Starting from a DOM resize host element (an element that receives dimensions as a result of resizing),
201
201
  * this helper returns the width of the found ancestor element.
202
202
  *
203
- * **Note**: This helper searches up to 5 levels of ancestors only.
203
+ * * It searches up to 5 levels of ancestors only.
204
204
  *
205
205
  * @param domResizeHost Resize host DOM element that receives dimensions as a result of resizing.
206
206
  * @returns Width of ancestor element in pixels or 0 if no ancestor with a computed width has been found.
package/src/utils.js CHANGED
@@ -350,18 +350,22 @@ function addSelectionHandle(widgetElement, writer) {
350
350
  * Starting from a DOM resize host element (an element that receives dimensions as a result of resizing),
351
351
  * this helper returns the width of the found ancestor element.
352
352
  *
353
- * **Note**: This helper searches up to 5 levels of ancestors only.
353
+ * * It searches up to 5 levels of ancestors only.
354
354
  *
355
355
  * @param domResizeHost Resize host DOM element that receives dimensions as a result of resizing.
356
356
  * @returns Width of ancestor element in pixels or 0 if no ancestor with a computed width has been found.
357
357
  */
358
358
  export function calculateResizeHostAncestorWidth(domResizeHost) {
359
+ const getElementComputedWidth = (element) => {
360
+ const { width, paddingLeft, paddingRight } = element.ownerDocument.defaultView.getComputedStyle(element);
361
+ return parseFloat(width) - (parseFloat(paddingLeft) || 0) - (parseFloat(paddingRight) || 0);
362
+ };
359
363
  const domResizeHostParent = domResizeHost.parentElement;
360
364
  if (!domResizeHostParent) {
361
365
  return 0;
362
366
  }
363
367
  // Need to use computed style as it properly excludes parent's paddings from the returned value.
364
- let parentWidth = parseFloat(domResizeHostParent.ownerDocument.defaultView.getComputedStyle(domResizeHostParent).width);
368
+ let parentWidth = getElementComputedWidth(domResizeHostParent);
365
369
  // Sometimes parent width cannot be accessed. If that happens we should go up in the elements tree
366
370
  // and try to get width from next ancestor.
367
371
  // https://github.com/ckeditor/ckeditor5/issues/10776
@@ -373,7 +377,7 @@ export function calculateResizeHostAncestorWidth(domResizeHost) {
373
377
  if (++currentLevel > ancestorLevelLimit) {
374
378
  return 0;
375
379
  }
376
- parentWidth = parseFloat(domResizeHostParent.ownerDocument.defaultView.getComputedStyle(checkedElement).width);
380
+ parentWidth = getElementComputedWidth(checkedElement);
377
381
  }
378
382
  return parentWidth;
379
383
  }