@ckeditor/ckeditor5-ui 45.0.0-alpha.9 → 45.1.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/LICENSE.md +4 -0
- package/dist/index.js +244 -103
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/colorselector/colorgridsfragmentview.d.ts +9 -8
- package/src/colorselector/colorgridsfragmentview.js +9 -8
- package/src/colorselector/colorpickerfragmentview.d.ts +5 -4
- package/src/colorselector/colorpickerfragmentview.js +5 -4
- package/src/colorselector/colorselectorview.d.ts +8 -7
- package/src/colorselector/colorselectorview.js +9 -8
- package/src/componentfactory.js +1 -1
- package/src/dropdown/dropdownpanelview.js +2 -2
- package/src/dropdown/utils.d.ts +0 -2
- package/src/dropdown/utils.js +97 -20
- package/src/editorui/editorui.d.ts +29 -8
- package/src/editorui/editorui.js +56 -3
- package/src/menubar/menubarview.js +2 -2
- package/src/menubar/utils.js +7 -7
- package/src/panel/balloon/balloonpanelview.js +16 -8
- package/src/panel/balloon/contextualballoon.js +4 -1
- package/src/panel/sticky/stickypanelview.d.ts +0 -4
- package/src/panel/sticky/stickypanelview.js +35 -29
- package/src/textarea/textareaview.js +3 -3
- package/src/toolbar/toolbarview.d.ts +1 -1
- package/src/toolbar/toolbarview.js +1 -1
- package/src/tooltipmanager.d.ts +2 -0
- package/src/tooltipmanager.js +2 -0
- package/src/viewcollection.d.ts +1 -1
- package/src/viewcollection.js +1 -1
@@ -7,7 +7,11 @@
|
|
7
7
|
*/
|
8
8
|
import View from '../../view.js';
|
9
9
|
import Template from '../../template.js';
|
10
|
-
import { Rect, toUnit,
|
10
|
+
import { Rect, toUnit, getVisualViewportOffset, global } from '@ckeditor/ckeditor5-utils';
|
11
|
+
// @if CK_DEBUG_STICKYPANEL // const {
|
12
|
+
// @if CK_DEBUG_STICKYPANEL // default: RectDrawer,
|
13
|
+
// @if CK_DEBUG_STICKYPANEL // diagonalStylesBlack
|
14
|
+
// @if CK_DEBUG_STICKYPANEL // } = require( '@ckeditor/ckeditor5-utils/tests/_utils/rectdrawer' );
|
11
15
|
import '../../../theme/components/panel/stickypanel.css';
|
12
16
|
const toPx = /* #__PURE__ */ toUnit('px');
|
13
17
|
/**
|
@@ -109,7 +113,7 @@ export default class StickyPanelView extends View {
|
|
109
113
|
this.listenTo(this, 'change:isActive', () => {
|
110
114
|
this.checkIfShouldBeSticky();
|
111
115
|
});
|
112
|
-
if (
|
116
|
+
if (global.window.visualViewport) {
|
113
117
|
this.listenTo(global.window.visualViewport, 'scroll', () => {
|
114
118
|
this.checkIfShouldBeSticky();
|
115
119
|
});
|
@@ -123,24 +127,20 @@ export default class StickyPanelView extends View {
|
|
123
127
|
* Then handles the positioning of the panel.
|
124
128
|
*/
|
125
129
|
checkIfShouldBeSticky() {
|
130
|
+
// @if CK_DEBUG_STICKYPANEL // RectDrawer.clear();
|
126
131
|
if (!this.limiterElement || !this.isActive) {
|
127
132
|
this._unstick();
|
128
133
|
return;
|
129
134
|
}
|
130
|
-
const { left: visualViewportOffsetLeft, top: visualViewportOffsetTop } = this._getVisualViewportOffset();
|
131
135
|
const limiterRect = new Rect(this.limiterElement);
|
132
136
|
let visibleLimiterRect = limiterRect.getVisible();
|
133
137
|
if (visibleLimiterRect) {
|
134
138
|
const windowRect = new Rect(global.window);
|
135
|
-
|
136
|
-
|
137
|
-
// Adjust the viewport top offset to height visible in the visual viewport.
|
138
|
-
viewportTopOffset = visualViewportOffsetTop > this.viewportTopOffset ? 0 : this.viewportTopOffset - visualViewportOffsetTop;
|
139
|
-
}
|
140
|
-
windowRect.top += viewportTopOffset;
|
141
|
-
windowRect.height -= viewportTopOffset;
|
139
|
+
windowRect.top += this.viewportTopOffset;
|
140
|
+
windowRect.height -= this.viewportTopOffset;
|
142
141
|
visibleLimiterRect = visibleLimiterRect.getIntersection(windowRect);
|
143
142
|
}
|
143
|
+
const { left: visualViewportOffsetLeft, top: visualViewportOffsetTop } = getVisualViewportOffset();
|
144
144
|
limiterRect.moveBy(visualViewportOffsetLeft, visualViewportOffsetTop);
|
145
145
|
if (visibleLimiterRect) {
|
146
146
|
visibleLimiterRect.moveBy(visualViewportOffsetLeft, visualViewportOffsetTop);
|
@@ -149,14 +149,23 @@ export default class StickyPanelView extends View {
|
|
149
149
|
// * the limiter's ancestors are intersecting with each other so that some of their rects are visible,
|
150
150
|
// * and the limiter's top edge is above the visible ancestors' top edge.
|
151
151
|
if (visibleLimiterRect && limiterRect.top < visibleLimiterRect.top) {
|
152
|
-
const visibleLimiterTop = visibleLimiterRect.top;
|
153
152
|
// Check if there's a change the panel can be sticky to the bottom of the limiter.
|
154
|
-
if (
|
153
|
+
if (this._contentPanelRect.height + this.limiterBottomOffset > visibleLimiterRect.height) {
|
155
154
|
const stickyBottomOffset = Math.max(limiterRect.bottom - visibleLimiterRect.bottom, 0) + this.limiterBottomOffset;
|
155
|
+
// @if CK_DEBUG_STICKYPANEL // const stickyBottomOffsetRect = new Rect( {
|
156
|
+
// @if CK_DEBUG_STICKYPANEL // top: limiterRect.bottom - stickyBottomOffset, left: 0, right: 2000,
|
157
|
+
// @if CK_DEBUG_STICKYPANEL // bottom: limiterRect.bottom - stickyBottomOffset, width: 2000, height: 1
|
158
|
+
// @if CK_DEBUG_STICKYPANEL // } );
|
159
|
+
// @if CK_DEBUG_STICKYPANEL // RectDrawer.draw( stickyBottomOffsetRect,
|
160
|
+
// @if CK_DEBUG_STICKYPANEL // { outlineWidth: '1px', opacity: '.8', outlineColor: 'black' },
|
161
|
+
// @if CK_DEBUG_STICKYPANEL // 'Sticky bottom offset',
|
162
|
+
// @if CK_DEBUG_STICKYPANEL // { visualViewportOrigin: true }
|
163
|
+
// @if CK_DEBUG_STICKYPANEL // );
|
156
164
|
// Check if sticking the panel to the bottom of the limiter does not cause it to suddenly
|
157
165
|
// move upwards if there's not enough space for it.
|
158
|
-
//
|
159
|
-
|
166
|
+
// To avoid toolbar flickering we are adding 1 for potential style change (sticky has all borders set,
|
167
|
+
// non-sticky lacks bottom border).
|
168
|
+
if (this._contentPanelRect.height + stickyBottomOffset + 1 < limiterRect.height) {
|
160
169
|
this._stickToBottomOfLimiter(stickyBottomOffset);
|
161
170
|
}
|
162
171
|
else {
|
@@ -164,7 +173,7 @@ export default class StickyPanelView extends View {
|
|
164
173
|
}
|
165
174
|
}
|
166
175
|
else if (this._contentPanelRect.height + this.limiterBottomOffset < limiterRect.height) {
|
167
|
-
this._stickToTopOfAncestors(
|
176
|
+
this._stickToTopOfAncestors(visibleLimiterRect.top);
|
168
177
|
}
|
169
178
|
else {
|
170
179
|
this._unstick();
|
@@ -178,6 +187,15 @@ export default class StickyPanelView extends View {
|
|
178
187
|
// @if CK_DEBUG_STICKYPANEL // console.log( '_isStickyToTheBottomOfLimiter', this._isStickyToTheBottomOfLimiter );
|
179
188
|
// @if CK_DEBUG_STICKYPANEL // console.log( '_stickyTopOffset', this._stickyTopOffset );
|
180
189
|
// @if CK_DEBUG_STICKYPANEL // console.log( '_stickyBottomOffset', this._stickyBottomOffset );
|
190
|
+
// @if CK_DEBUG_STICKYPANEL // if ( visibleLimiterRect ) {
|
191
|
+
// @if CK_DEBUG_STICKYPANEL // RectDrawer.draw( visibleLimiterRect,
|
192
|
+
// @if CK_DEBUG_STICKYPANEL // { ...diagonalStylesBlack,
|
193
|
+
// @if CK_DEBUG_STICKYPANEL // outlineWidth: '3px', opacity: '.8', outlineColor: 'orange', outlineOffset: '-3px',
|
194
|
+
// @if CK_DEBUG_STICKYPANEL // backgroundColor: 'rgba(0, 0, 255, .2)', zIndex: 2000 },
|
195
|
+
// @if CK_DEBUG_STICKYPANEL // 'visibleLimiterRect',
|
196
|
+
// @if CK_DEBUG_STICKYPANEL // { visualViewportOrigin: true }
|
197
|
+
// @if CK_DEBUG_STICKYPANEL // );
|
198
|
+
// @if CK_DEBUG_STICKYPANEL // }
|
181
199
|
}
|
182
200
|
/**
|
183
201
|
* Sticks the panel at the given CSS `top` offset.
|
@@ -190,7 +208,7 @@ export default class StickyPanelView extends View {
|
|
190
208
|
this._isStickyToTheBottomOfLimiter = false;
|
191
209
|
this._stickyTopOffset = topOffset;
|
192
210
|
this._stickyBottomOffset = null;
|
193
|
-
this._marginLeft = toPx(-global.window.scrollX +
|
211
|
+
this._marginLeft = toPx(-global.window.scrollX + getVisualViewportOffset().left);
|
194
212
|
}
|
195
213
|
/**
|
196
214
|
* Sticks the panel at the bottom of the limiter with a given CSS `bottom` offset.
|
@@ -203,7 +221,7 @@ export default class StickyPanelView extends View {
|
|
203
221
|
this._isStickyToTheBottomOfLimiter = true;
|
204
222
|
this._stickyTopOffset = null;
|
205
223
|
this._stickyBottomOffset = stickyBottomOffset;
|
206
|
-
this._marginLeft = toPx(-global.window.scrollX +
|
224
|
+
this._marginLeft = toPx(-global.window.scrollX + getVisualViewportOffset().left);
|
207
225
|
}
|
208
226
|
/**
|
209
227
|
* Unsticks the panel putting it back to its original position.
|
@@ -225,16 +243,4 @@ export default class StickyPanelView extends View {
|
|
225
243
|
get _contentPanelRect() {
|
226
244
|
return new Rect(this.contentPanelElement);
|
227
245
|
}
|
228
|
-
/**
|
229
|
-
* Returns normalized visual viewport offsets (only for Safari and iOS).
|
230
|
-
*/
|
231
|
-
_getVisualViewportOffset() {
|
232
|
-
const visualViewport = global.window.visualViewport;
|
233
|
-
if (!(env.isiOS || env.isSafari) || !visualViewport) {
|
234
|
-
return { left: 0, top: 0 };
|
235
|
-
}
|
236
|
-
const left = Math.max(Math.round(visualViewport.offsetLeft), 0);
|
237
|
-
const top = Math.max(Math.round(visualViewport.offsetTop), 0);
|
238
|
-
return { left, top };
|
239
|
-
}
|
240
246
|
}
|
@@ -161,9 +161,9 @@ export default class TextareaView extends InputBase {
|
|
161
161
|
* The minimum number of rows is greater than the maximum number of rows.
|
162
162
|
*
|
163
163
|
* @error ui-textarea-view-min-rows-greater-than-max-rows
|
164
|
-
* @param textareaView The misconfigured textarea view instance.
|
165
|
-
* @param minRows The value of `minRows` property.
|
166
|
-
* @param maxRows The value of `maxRows` property.
|
164
|
+
* @param {module:ui/textarea/textareaview~TextareaView} textareaView The misconfigured textarea view instance.
|
165
|
+
* @param {number} minRows The value of `minRows` property.
|
166
|
+
* @param {number} maxRows The value of `maxRows` property.
|
167
167
|
*/
|
168
168
|
throw new CKEditorError('ui-textarea-view-min-rows-greater-than-max-rows', {
|
169
169
|
textareaView: this,
|
@@ -321,7 +321,7 @@ export default class ToolbarView extends View {
|
|
321
321
|
* ```
|
322
322
|
*
|
323
323
|
* @error toolbarview-item-unavailable
|
324
|
-
* @param item The name of the component or nested toolbar definition.
|
324
|
+
* @param {string} item The name of the component or nested toolbar definition.
|
325
325
|
*/
|
326
326
|
logWarning('toolbarview-item-unavailable', { item });
|
327
327
|
return false;
|
package/src/tooltipmanager.d.ts
CHANGED
@@ -176,6 +176,8 @@ export default class TooltipManager extends /* #__PURE__ */ TooltipManager_base
|
|
176
176
|
/**
|
177
177
|
* Pins the tooltip to a specific DOM element.
|
178
178
|
*
|
179
|
+
* @param targetDomElement Element to be pinned to.
|
180
|
+
* @param options Options for the tooltip.
|
179
181
|
* @param options.text Text of the tooltip to display.
|
180
182
|
* @param options.position The position of the tooltip.
|
181
183
|
* @param options.cssClass Additional CSS class of the balloon with the tooltip.
|
package/src/tooltipmanager.js
CHANGED
@@ -347,6 +347,8 @@ class TooltipManager extends /* #__PURE__ */ DomEmitterMixin() {
|
|
347
347
|
/**
|
348
348
|
* Pins the tooltip to a specific DOM element.
|
349
349
|
*
|
350
|
+
* @param targetDomElement Element to be pinned to.
|
351
|
+
* @param options Options for the tooltip.
|
350
352
|
* @param options.text Text of the tooltip to display.
|
351
353
|
* @param options.position The position of the tooltip.
|
352
354
|
* @param options.cssClass Additional CSS class of the balloon with the tooltip.
|
package/src/viewcollection.d.ts
CHANGED
@@ -69,7 +69,7 @@ export default class ViewCollection<TView extends View = View> extends Collectio
|
|
69
69
|
* {@link #remove removing} views in the collection synchronizes their
|
70
70
|
* {@link module:ui/view~View#element elements} in the parent element.
|
71
71
|
*
|
72
|
-
* @param
|
72
|
+
* @param elementOrDocFragment A new parent element or document fragment.
|
73
73
|
*/
|
74
74
|
setParent(elementOrDocFragment: DocumentFragment | HTMLElement): void;
|
75
75
|
/**
|
package/src/viewcollection.js
CHANGED
@@ -86,7 +86,7 @@ export default class ViewCollection extends Collection {
|
|
86
86
|
* {@link #remove removing} views in the collection synchronizes their
|
87
87
|
* {@link module:ui/view~View#element elements} in the parent element.
|
88
88
|
*
|
89
|
-
* @param
|
89
|
+
* @param elementOrDocFragment A new parent element or document fragment.
|
90
90
|
*/
|
91
91
|
setParent(elementOrDocFragment) {
|
92
92
|
this._parentElement = elementOrDocFragment;
|