@ckeditor/ckeditor5-clipboard 46.0.3 → 46.1.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 +26 -17
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/dragdrop.js +29 -18
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Plugin } from '@ckeditor/ckeditor5-core/dist/index.js';
|
|
6
6
|
import { EventInfo, getRangeFromMouseEvent, uid, toUnit, delay, DomEmitterMixin, global, Rect, ResizeObserver, env, createElement } from '@ckeditor/ckeditor5-utils/dist/index.js';
|
|
7
|
-
import { DomEventObserver, ViewDataTransfer, ModelRange,
|
|
7
|
+
import { DomEventObserver, ViewDataTransfer, ModelRange, PointerObserver, ModelLiveRange } from '@ckeditor/ckeditor5-engine/dist/index.js';
|
|
8
8
|
import { mapValues, throttle } from 'es-toolkit/compat';
|
|
9
9
|
import { Widget, isWidget } from '@ckeditor/ckeditor5-widget/dist/index.js';
|
|
10
10
|
import { View } from '@ckeditor/ckeditor5-ui/dist/index.js';
|
|
@@ -1619,7 +1619,7 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
1619
1619
|
this._draggingUid = '';
|
|
1620
1620
|
this._draggableElement = null;
|
|
1621
1621
|
view.addObserver(ClipboardObserver);
|
|
1622
|
-
view.addObserver(
|
|
1622
|
+
view.addObserver(PointerObserver);
|
|
1623
1623
|
this._setupDragging();
|
|
1624
1624
|
this._setupContentInsertionIntegration();
|
|
1625
1625
|
this._setupClipboardInputIntegration();
|
|
@@ -1831,7 +1831,7 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
1831
1831
|
const viewDocument = view.document;
|
|
1832
1832
|
// Add the 'draggable' attribute to the widget while pressing the selection handle.
|
|
1833
1833
|
// This is required for widgets to be draggable. In Chrome it will enable dragging text nodes.
|
|
1834
|
-
this.listenTo(viewDocument, '
|
|
1834
|
+
this.listenTo(viewDocument, 'pointerdown', (evt, data)=>{
|
|
1835
1835
|
// The lack of data can be caused by editor tests firing fake mouse events. This should not occur
|
|
1836
1836
|
// in real-life scenarios but this greatly simplifies editor tests that would otherwise fail a lot.
|
|
1837
1837
|
if (env.isAndroid || !data) {
|
|
@@ -1862,7 +1862,7 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
1862
1862
|
}
|
|
1863
1863
|
});
|
|
1864
1864
|
// Remove the draggable attribute in case no dragging started (only mousedown + mouseup).
|
|
1865
|
-
this.listenTo(viewDocument, '
|
|
1865
|
+
this.listenTo(viewDocument, 'pointerup', ()=>{
|
|
1866
1866
|
if (!env.isAndroid) {
|
|
1867
1867
|
this._clearDraggableAttributesDelayed();
|
|
1868
1868
|
}
|
|
@@ -1975,21 +1975,30 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
1975
1975
|
} else if (this._previewContainer.firstElementChild) {
|
|
1976
1976
|
this._previewContainer.removeChild(this._previewContainer.firstElementChild);
|
|
1977
1977
|
}
|
|
1978
|
+
const preview = createElement(global.document, 'div');
|
|
1979
|
+
preview.className = 'ck ck-content ck-clipboard-preview';
|
|
1978
1980
|
const domRect = new Rect(domEditable);
|
|
1979
|
-
// If domTarget is inside the editable root, browsers will display the preview correctly by themselves.
|
|
1980
|
-
if (domEditable.contains(domTarget)) {
|
|
1981
|
-
return;
|
|
1982
|
-
}
|
|
1983
1981
|
const domEditablePaddingLeft = parseFloat(computedStyle.paddingLeft);
|
|
1984
|
-
const
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1982
|
+
const domEditablePaddingRight = parseFloat(computedStyle.paddingRight);
|
|
1983
|
+
const editableWidth = parseFloat(computedStyle.width) - domEditablePaddingLeft - domEditablePaddingRight;
|
|
1984
|
+
// Dragging by the drag handle outside editable element.
|
|
1985
|
+
if (!domEditable.contains(domTarget)) {
|
|
1986
|
+
if (!env.isiOS) {
|
|
1987
|
+
const offsetLeft = domRect.left - clientX + domEditablePaddingLeft;
|
|
1988
|
+
preview.style.width = `${editableWidth + offsetLeft}px`;
|
|
1989
|
+
preview.style.paddingLeft = `${offsetLeft}px`;
|
|
1990
|
+
} else {
|
|
1991
|
+
// Without a padding as on iOS preview have a background and padding would be visible.
|
|
1992
|
+
preview.style.width = `${editableWidth}px`;
|
|
1993
|
+
preview.style.backgroundColor = 'var(--ck-color-base-background)';
|
|
1994
|
+
}
|
|
1995
|
+
} else if (env.isiOS) {
|
|
1996
|
+
// Custom preview for iOS.
|
|
1997
|
+
preview.style.maxWidth = `${editableWidth}px`;
|
|
1998
|
+
preview.style.backgroundColor = 'var(--ck-color-base-background)';
|
|
1999
|
+
} else {
|
|
2000
|
+
// If domTarget is inside the editable root, browsers will display the preview correctly by themselves.
|
|
2001
|
+
return;
|
|
1993
2002
|
}
|
|
1994
2003
|
view.domConverter.setContentOf(preview, dataTransfer.getData('text/html'));
|
|
1995
2004
|
dataTransfer.setDragImage(preview, 0, 0);
|