@ckeditor/ckeditor5-clipboard 46.0.3 → 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 +26 -17
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/dragdrop.js +29 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-clipboard",
|
|
3
|
-
"version": "46.0.
|
|
3
|
+
"version": "46.1.0-alpha.0",
|
|
4
4
|
"description": "Clipboard integration feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "src/index.js",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@ckeditor/ckeditor5-core": "46.0.
|
|
17
|
-
"@ckeditor/ckeditor5-engine": "46.0.
|
|
18
|
-
"@ckeditor/ckeditor5-ui": "46.0.
|
|
19
|
-
"@ckeditor/ckeditor5-utils": "46.0.
|
|
20
|
-
"@ckeditor/ckeditor5-widget": "46.0.
|
|
16
|
+
"@ckeditor/ckeditor5-core": "46.1.0-alpha.0",
|
|
17
|
+
"@ckeditor/ckeditor5-engine": "46.1.0-alpha.0",
|
|
18
|
+
"@ckeditor/ckeditor5-ui": "46.1.0-alpha.0",
|
|
19
|
+
"@ckeditor/ckeditor5-utils": "46.1.0-alpha.0",
|
|
20
|
+
"@ckeditor/ckeditor5-widget": "46.1.0-alpha.0",
|
|
21
21
|
"es-toolkit": "1.39.5"
|
|
22
22
|
},
|
|
23
23
|
"author": "CKSource (http://cksource.com/)",
|
package/src/dragdrop.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module clipboard/dragdrop
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import { ModelLiveRange,
|
|
9
|
+
import { ModelLiveRange, PointerObserver } from '@ckeditor/ckeditor5-engine';
|
|
10
10
|
import { Widget, isWidget } from '@ckeditor/ckeditor5-widget';
|
|
11
11
|
import { env, uid, global, createElement, DomEmitterMixin, delay, Rect } from '@ckeditor/ckeditor5-utils';
|
|
12
12
|
import { ClipboardPipeline } from './clipboardpipeline.js';
|
|
@@ -159,7 +159,7 @@ export class DragDrop extends Plugin {
|
|
|
159
159
|
this._draggingUid = '';
|
|
160
160
|
this._draggableElement = null;
|
|
161
161
|
view.addObserver(ClipboardObserver);
|
|
162
|
-
view.addObserver(
|
|
162
|
+
view.addObserver(PointerObserver);
|
|
163
163
|
this._setupDragging();
|
|
164
164
|
this._setupContentInsertionIntegration();
|
|
165
165
|
this._setupClipboardInputIntegration();
|
|
@@ -355,7 +355,7 @@ export class DragDrop extends Plugin {
|
|
|
355
355
|
const viewDocument = view.document;
|
|
356
356
|
// Add the 'draggable' attribute to the widget while pressing the selection handle.
|
|
357
357
|
// This is required for widgets to be draggable. In Chrome it will enable dragging text nodes.
|
|
358
|
-
this.listenTo(viewDocument, '
|
|
358
|
+
this.listenTo(viewDocument, 'pointerdown', (evt, data) => {
|
|
359
359
|
// The lack of data can be caused by editor tests firing fake mouse events. This should not occur
|
|
360
360
|
// in real-life scenarios but this greatly simplifies editor tests that would otherwise fail a lot.
|
|
361
361
|
if (env.isAndroid || !data) {
|
|
@@ -386,7 +386,7 @@ export class DragDrop extends Plugin {
|
|
|
386
386
|
}
|
|
387
387
|
});
|
|
388
388
|
// Remove the draggable attribute in case no dragging started (only mousedown + mouseup).
|
|
389
|
-
this.listenTo(viewDocument, '
|
|
389
|
+
this.listenTo(viewDocument, 'pointerup', () => {
|
|
390
390
|
if (!env.isAndroid) {
|
|
391
391
|
this._clearDraggableAttributesDelayed();
|
|
392
392
|
}
|
|
@@ -506,22 +506,33 @@ export class DragDrop extends Plugin {
|
|
|
506
506
|
else if (this._previewContainer.firstElementChild) {
|
|
507
507
|
this._previewContainer.removeChild(this._previewContainer.firstElementChild);
|
|
508
508
|
}
|
|
509
|
+
const preview = createElement(global.document, 'div');
|
|
510
|
+
preview.className = 'ck ck-content ck-clipboard-preview';
|
|
509
511
|
const domRect = new Rect(domEditable);
|
|
510
|
-
// If domTarget is inside the editable root, browsers will display the preview correctly by themselves.
|
|
511
|
-
if (domEditable.contains(domTarget)) {
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
512
|
const domEditablePaddingLeft = parseFloat(computedStyle.paddingLeft);
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
513
|
+
const domEditablePaddingRight = parseFloat(computedStyle.paddingRight);
|
|
514
|
+
const editableWidth = parseFloat(computedStyle.width) - domEditablePaddingLeft - domEditablePaddingRight;
|
|
515
|
+
// Dragging by the drag handle outside editable element.
|
|
516
|
+
if (!domEditable.contains(domTarget)) {
|
|
517
|
+
if (!env.isiOS) {
|
|
518
|
+
const offsetLeft = domRect.left - clientX + domEditablePaddingLeft;
|
|
519
|
+
preview.style.width = `${editableWidth + offsetLeft}px`;
|
|
520
|
+
preview.style.paddingLeft = `${offsetLeft}px`;
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
// Without a padding as on iOS preview have a background and padding would be visible.
|
|
524
|
+
preview.style.width = `${editableWidth}px`;
|
|
525
|
+
preview.style.backgroundColor = 'var(--ck-color-base-background)';
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
else if (env.isiOS) {
|
|
529
|
+
// Custom preview for iOS.
|
|
530
|
+
preview.style.maxWidth = `${editableWidth}px`;
|
|
531
|
+
preview.style.backgroundColor = 'var(--ck-color-base-background)';
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
// If domTarget is inside the editable root, browsers will display the preview correctly by themselves.
|
|
535
|
+
return;
|
|
525
536
|
}
|
|
526
537
|
view.domConverter.setContentOf(preview, dataTransfer.getData('text/html'));
|
|
527
538
|
dataTransfer.setDragImage(preview, 0, 0);
|