@ckeditor/ckeditor5-clipboard 46.0.2 → 46.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/dist/index.js +28 -18
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/dragdrop.js +29 -18
- package/src/utils/viewtoplaintext.js +2 -1
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';
|
|
@@ -188,7 +188,8 @@ const listElements = [
|
|
|
188
188
|
}
|
|
189
189
|
// If item is a raw element, the only way to get its content is to render it and read the text directly from DOM.
|
|
190
190
|
if (viewItem.is('rawElement')) {
|
|
191
|
-
const
|
|
191
|
+
const doc = document.implementation.createHTMLDocument('');
|
|
192
|
+
const tempElement = doc.createElement('div');
|
|
192
193
|
viewItem.render(tempElement, converter);
|
|
193
194
|
text += domElementToPlainText(tempElement);
|
|
194
195
|
}
|
|
@@ -1618,7 +1619,7 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
1618
1619
|
this._draggingUid = '';
|
|
1619
1620
|
this._draggableElement = null;
|
|
1620
1621
|
view.addObserver(ClipboardObserver);
|
|
1621
|
-
view.addObserver(
|
|
1622
|
+
view.addObserver(PointerObserver);
|
|
1622
1623
|
this._setupDragging();
|
|
1623
1624
|
this._setupContentInsertionIntegration();
|
|
1624
1625
|
this._setupClipboardInputIntegration();
|
|
@@ -1830,7 +1831,7 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
1830
1831
|
const viewDocument = view.document;
|
|
1831
1832
|
// Add the 'draggable' attribute to the widget while pressing the selection handle.
|
|
1832
1833
|
// This is required for widgets to be draggable. In Chrome it will enable dragging text nodes.
|
|
1833
|
-
this.listenTo(viewDocument, '
|
|
1834
|
+
this.listenTo(viewDocument, 'pointerdown', (evt, data)=>{
|
|
1834
1835
|
// The lack of data can be caused by editor tests firing fake mouse events. This should not occur
|
|
1835
1836
|
// in real-life scenarios but this greatly simplifies editor tests that would otherwise fail a lot.
|
|
1836
1837
|
if (env.isAndroid || !data) {
|
|
@@ -1861,7 +1862,7 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
1861
1862
|
}
|
|
1862
1863
|
});
|
|
1863
1864
|
// Remove the draggable attribute in case no dragging started (only mousedown + mouseup).
|
|
1864
|
-
this.listenTo(viewDocument, '
|
|
1865
|
+
this.listenTo(viewDocument, 'pointerup', ()=>{
|
|
1865
1866
|
if (!env.isAndroid) {
|
|
1866
1867
|
this._clearDraggableAttributesDelayed();
|
|
1867
1868
|
}
|
|
@@ -1974,21 +1975,30 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
1974
1975
|
} else if (this._previewContainer.firstElementChild) {
|
|
1975
1976
|
this._previewContainer.removeChild(this._previewContainer.firstElementChild);
|
|
1976
1977
|
}
|
|
1978
|
+
const preview = createElement(global.document, 'div');
|
|
1979
|
+
preview.className = 'ck ck-content ck-clipboard-preview';
|
|
1977
1980
|
const domRect = new Rect(domEditable);
|
|
1978
|
-
// If domTarget is inside the editable root, browsers will display the preview correctly by themselves.
|
|
1979
|
-
if (domEditable.contains(domTarget)) {
|
|
1980
|
-
return;
|
|
1981
|
-
}
|
|
1982
1981
|
const domEditablePaddingLeft = parseFloat(computedStyle.paddingLeft);
|
|
1983
|
-
const
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
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;
|
|
1992
2002
|
}
|
|
1993
2003
|
view.domConverter.setContentOf(preview, dataTransfer.getData('text/html'));
|
|
1994
2004
|
dataTransfer.setDragImage(preview, 0, 0);
|