@ckeditor/ckeditor5-widget 37.0.0-alpha.1 → 37.0.0-alpha.2

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-widget",
3
- "version": "37.0.0-alpha.1",
3
+ "version": "37.0.0-alpha.2",
4
4
  "description": "Widget API for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -11,29 +11,29 @@
11
11
  ],
12
12
  "main": "src/index.js",
13
13
  "dependencies": {
14
- "@ckeditor/ckeditor5-core": "^37.0.0-alpha.1",
15
- "@ckeditor/ckeditor5-engine": "^37.0.0-alpha.1",
16
- "@ckeditor/ckeditor5-enter": "^37.0.0-alpha.1",
17
- "@ckeditor/ckeditor5-ui": "^37.0.0-alpha.1",
18
- "@ckeditor/ckeditor5-utils": "^37.0.0-alpha.1",
19
- "@ckeditor/ckeditor5-typing": "^37.0.0-alpha.1",
14
+ "@ckeditor/ckeditor5-core": "^37.0.0-alpha.2",
15
+ "@ckeditor/ckeditor5-engine": "^37.0.0-alpha.2",
16
+ "@ckeditor/ckeditor5-enter": "^37.0.0-alpha.2",
17
+ "@ckeditor/ckeditor5-ui": "^37.0.0-alpha.2",
18
+ "@ckeditor/ckeditor5-utils": "^37.0.0-alpha.2",
19
+ "@ckeditor/ckeditor5-typing": "^37.0.0-alpha.2",
20
20
  "lodash-es": "^4.17.15"
21
21
  },
22
22
  "devDependencies": {
23
- "@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.1",
24
- "@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.1",
25
- "@ckeditor/ckeditor5-clipboard": "^37.0.0-alpha.1",
26
- "@ckeditor/ckeditor5-editor-balloon": "^37.0.0-alpha.1",
27
- "@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.1",
28
- "@ckeditor/ckeditor5-essentials": "^37.0.0-alpha.1",
29
- "@ckeditor/ckeditor5-heading": "^37.0.0-alpha.1",
30
- "@ckeditor/ckeditor5-horizontal-line": "^37.0.0-alpha.1",
31
- "@ckeditor/ckeditor5-image": "^37.0.0-alpha.1",
32
- "@ckeditor/ckeditor5-link": "^37.0.0-alpha.1",
33
- "@ckeditor/ckeditor5-media-embed": "^37.0.0-alpha.1",
34
- "@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.1",
35
- "@ckeditor/ckeditor5-table": "^37.0.0-alpha.1",
36
- "@ckeditor/ckeditor5-undo": "^37.0.0-alpha.1",
23
+ "@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.2",
24
+ "@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.2",
25
+ "@ckeditor/ckeditor5-clipboard": "^37.0.0-alpha.2",
26
+ "@ckeditor/ckeditor5-editor-balloon": "^37.0.0-alpha.2",
27
+ "@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.2",
28
+ "@ckeditor/ckeditor5-essentials": "^37.0.0-alpha.2",
29
+ "@ckeditor/ckeditor5-heading": "^37.0.0-alpha.2",
30
+ "@ckeditor/ckeditor5-horizontal-line": "^37.0.0-alpha.2",
31
+ "@ckeditor/ckeditor5-image": "^37.0.0-alpha.2",
32
+ "@ckeditor/ckeditor5-link": "^37.0.0-alpha.2",
33
+ "@ckeditor/ckeditor5-media-embed": "^37.0.0-alpha.2",
34
+ "@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.2",
35
+ "@ckeditor/ckeditor5-table": "^37.0.0-alpha.2",
36
+ "@ckeditor/ckeditor5-undo": "^37.0.0-alpha.2",
37
37
  "typescript": "^4.8.4",
38
38
  "webpack": "^5.58.1",
39
39
  "webpack-cli": "^4.9.0"
@@ -76,12 +76,25 @@ export default class ResizeState extends ObservableMixin() {
76
76
  }
77
77
  }
78
78
  /**
79
- * Calculates a relative width of a `domResizeHost` compared to it's parent in percents.
79
+ * Calculates a relative width of a `domResizeHost` compared to its ancestor in percents.
80
80
  */
81
81
  function calculateHostPercentageWidth(domResizeHost, resizeHostRect) {
82
82
  const domResizeHostParent = domResizeHost.parentElement;
83
83
  // Need to use computed style as it properly excludes parent's paddings from the returned value.
84
- const parentWidth = parseFloat(domResizeHostParent.ownerDocument.defaultView.getComputedStyle(domResizeHostParent).width);
84
+ let parentWidth = parseFloat(domResizeHostParent.ownerDocument.defaultView.getComputedStyle(domResizeHostParent).width);
85
+ // Sometimes parent width cannot be accessed. If that happens we should go up in the elements tree
86
+ // and try to get width from next ancestor.
87
+ // https://github.com/ckeditor/ckeditor5/issues/10776
88
+ const ancestorLevelLimit = 5;
89
+ let currentLevel = 0;
90
+ let checkedElement = domResizeHostParent;
91
+ while (isNaN(parentWidth)) {
92
+ checkedElement = checkedElement.parentElement;
93
+ if (++currentLevel > ancestorLevelLimit) {
94
+ return 0;
95
+ }
96
+ parentWidth = parseFloat(domResizeHostParent.ownerDocument.defaultView.getComputedStyle(checkedElement).width);
97
+ }
85
98
  return resizeHostRect.width / parentWidth * 100;
86
99
  }
87
100
  /**