@ckeditor/ckeditor5-clipboard 38.1.0 → 38.1.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/package.json +6 -6
- package/src/augmentation.d.ts +16 -16
- package/src/augmentation.js +5 -5
- package/src/clipboard.d.ts +31 -31
- package/src/clipboard.js +35 -35
- package/src/clipboardobserver.d.ts +312 -312
- package/src/clipboardobserver.js +94 -94
- package/src/clipboardpipeline.d.ts +221 -221
- package/src/clipboardpipeline.js +245 -245
- package/src/dragdrop.d.ts +100 -100
- package/src/dragdrop.js +655 -655
- package/src/dragdropblocktoolbar.d.ts +47 -47
- package/src/dragdropblocktoolbar.js +114 -114
- package/src/dragdropexperimental.d.ts +101 -101
- package/src/dragdropexperimental.js +522 -522
- package/src/dragdroptarget.d.ts +94 -94
- package/src/dragdroptarget.js +362 -362
- package/src/index.d.ts +17 -17
- package/src/index.js +15 -15
- package/src/lineview.d.ts +45 -45
- package/src/lineview.js +44 -44
- package/src/pasteplaintext.d.ts +28 -28
- package/src/pasteplaintext.js +82 -82
- package/src/utils/normalizeclipboarddata.d.ts +15 -15
- package/src/utils/normalizeclipboarddata.js +27 -27
- package/src/utils/plaintexttohtml.d.ts +14 -14
- package/src/utils/plaintexttohtml.js +37 -37
- package/src/utils/viewtoplaintext.d.ts +15 -15
- package/src/utils/viewtoplaintext.js +50 -50
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module clipboard/dragdropblocktoolbar
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
/**
|
|
10
|
-
* Integration of an experimental block Drag and drop support with the block toolbar.
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export default class DragDropBlockToolbar extends Plugin {
|
|
15
|
-
/**
|
|
16
|
-
* Whether current dragging is started by block toolbar button dragging.
|
|
17
|
-
*/
|
|
18
|
-
private _isBlockDragging;
|
|
19
|
-
/**
|
|
20
|
-
* DOM Emitter.
|
|
21
|
-
*/
|
|
22
|
-
private _domEmitter;
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get pluginName(): "DragDropBlockToolbar";
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
init(): void;
|
|
31
|
-
/**
|
|
32
|
-
* @inheritDoc
|
|
33
|
-
*/
|
|
34
|
-
destroy(): void;
|
|
35
|
-
/**
|
|
36
|
-
* The `dragstart` event handler.
|
|
37
|
-
*/
|
|
38
|
-
private _handleBlockDragStart;
|
|
39
|
-
/**
|
|
40
|
-
* The `dragover` and `drop` event handler.
|
|
41
|
-
*/
|
|
42
|
-
private _handleBlockDragging;
|
|
43
|
-
/**
|
|
44
|
-
* The `dragend` event handler.
|
|
45
|
-
*/
|
|
46
|
-
private _handleBlockDragEnd;
|
|
47
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module clipboard/dragdropblocktoolbar
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
+
/**
|
|
10
|
+
* Integration of an experimental block Drag and drop support with the block toolbar.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export default class DragDropBlockToolbar extends Plugin {
|
|
15
|
+
/**
|
|
16
|
+
* Whether current dragging is started by block toolbar button dragging.
|
|
17
|
+
*/
|
|
18
|
+
private _isBlockDragging;
|
|
19
|
+
/**
|
|
20
|
+
* DOM Emitter.
|
|
21
|
+
*/
|
|
22
|
+
private _domEmitter;
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get pluginName(): "DragDropBlockToolbar";
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
init(): void;
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
destroy(): void;
|
|
35
|
+
/**
|
|
36
|
+
* The `dragstart` event handler.
|
|
37
|
+
*/
|
|
38
|
+
private _handleBlockDragStart;
|
|
39
|
+
/**
|
|
40
|
+
* The `dragover` and `drop` event handler.
|
|
41
|
+
*/
|
|
42
|
+
private _handleBlockDragging;
|
|
43
|
+
/**
|
|
44
|
+
* The `dragend` event handler.
|
|
45
|
+
*/
|
|
46
|
+
private _handleBlockDragEnd;
|
|
47
|
+
}
|
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module clipboard/dragdropblocktoolbar
|
|
7
|
-
*/
|
|
8
|
-
/* istanbul ignore file -- @preserve */
|
|
9
|
-
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
10
|
-
import { env, global, DomEmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
11
|
-
import ClipboardObserver from './clipboardobserver';
|
|
12
|
-
/**
|
|
13
|
-
* Integration of an experimental block Drag and drop support with the block toolbar.
|
|
14
|
-
*
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
export default class DragDropBlockToolbar extends Plugin {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
/**
|
|
21
|
-
* Whether current dragging is started by block toolbar button dragging.
|
|
22
|
-
*/
|
|
23
|
-
this._isBlockDragging = false;
|
|
24
|
-
/**
|
|
25
|
-
* DOM Emitter.
|
|
26
|
-
*/
|
|
27
|
-
this._domEmitter = new (DomEmitterMixin())();
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @inheritDoc
|
|
31
|
-
*/
|
|
32
|
-
static get pluginName() {
|
|
33
|
-
return 'DragDropBlockToolbar';
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @inheritDoc
|
|
37
|
-
*/
|
|
38
|
-
init() {
|
|
39
|
-
const editor = this.editor;
|
|
40
|
-
this.listenTo(editor, 'change:isReadOnly', (evt, name, isReadOnly) => {
|
|
41
|
-
if (isReadOnly) {
|
|
42
|
-
this.forceDisabled('readOnlyMode');
|
|
43
|
-
this._isBlockDragging = false;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
this.clearForceDisabled('readOnlyMode');
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
if (env.isAndroid) {
|
|
50
|
-
this.forceDisabled('noAndroidSupport');
|
|
51
|
-
}
|
|
52
|
-
if (editor.plugins.has('BlockToolbar')) {
|
|
53
|
-
const blockToolbar = editor.plugins.get('BlockToolbar');
|
|
54
|
-
const element = blockToolbar.buttonView.element;
|
|
55
|
-
element.setAttribute('draggable', 'true');
|
|
56
|
-
this._domEmitter.listenTo(element, 'dragstart', (evt, data) => this._handleBlockDragStart(data));
|
|
57
|
-
this._domEmitter.listenTo(global.document, 'dragover', (evt, data) => this._handleBlockDragging(data));
|
|
58
|
-
this._domEmitter.listenTo(global.document, 'drop', (evt, data) => this._handleBlockDragging(data));
|
|
59
|
-
this._domEmitter.listenTo(global.document, 'dragend', () => this._handleBlockDragEnd(), { useCapture: true });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* @inheritDoc
|
|
64
|
-
*/
|
|
65
|
-
destroy() {
|
|
66
|
-
this._domEmitter.stopListening();
|
|
67
|
-
return super.destroy();
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* The `dragstart` event handler.
|
|
71
|
-
*/
|
|
72
|
-
_handleBlockDragStart(domEvent) {
|
|
73
|
-
if (!this.isEnabled) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const model = this.editor.model;
|
|
77
|
-
const selection = model.document.selection;
|
|
78
|
-
const blocks = Array.from(selection.getSelectedBlocks());
|
|
79
|
-
const draggedRange = model.createRange(model.createPositionBefore(blocks[0]), model.createPositionAfter(blocks[blocks.length - 1]));
|
|
80
|
-
model.change(writer => writer.setSelection(draggedRange));
|
|
81
|
-
this._isBlockDragging = true;
|
|
82
|
-
this.editor.editing.view.getObserver(ClipboardObserver).onDomEvent(domEvent);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* The `dragover` and `drop` event handler.
|
|
86
|
-
*/
|
|
87
|
-
_handleBlockDragging(domEvent) {
|
|
88
|
-
if (!this.isEnabled || !this._isBlockDragging) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const clientX = domEvent.clientX + 100;
|
|
92
|
-
const clientY = domEvent.clientY;
|
|
93
|
-
const target = document.elementFromPoint(clientX, clientY);
|
|
94
|
-
if (!target || !target.closest('.ck-editor__editable')) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
this.editor.editing.view.getObserver(ClipboardObserver).onDomEvent({
|
|
98
|
-
...domEvent,
|
|
99
|
-
type: domEvent.type,
|
|
100
|
-
dataTransfer: domEvent.dataTransfer,
|
|
101
|
-
target,
|
|
102
|
-
clientX,
|
|
103
|
-
clientY,
|
|
104
|
-
preventDefault: () => domEvent.preventDefault(),
|
|
105
|
-
stopPropagation: () => domEvent.stopPropagation()
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* The `dragend` event handler.
|
|
110
|
-
*/
|
|
111
|
-
_handleBlockDragEnd() {
|
|
112
|
-
this._isBlockDragging = false;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module clipboard/dragdropblocktoolbar
|
|
7
|
+
*/
|
|
8
|
+
/* istanbul ignore file -- @preserve */
|
|
9
|
+
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
10
|
+
import { env, global, DomEmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
11
|
+
import ClipboardObserver from './clipboardobserver';
|
|
12
|
+
/**
|
|
13
|
+
* Integration of an experimental block Drag and drop support with the block toolbar.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export default class DragDropBlockToolbar extends Plugin {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
/**
|
|
21
|
+
* Whether current dragging is started by block toolbar button dragging.
|
|
22
|
+
*/
|
|
23
|
+
this._isBlockDragging = false;
|
|
24
|
+
/**
|
|
25
|
+
* DOM Emitter.
|
|
26
|
+
*/
|
|
27
|
+
this._domEmitter = new (DomEmitterMixin())();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
static get pluginName() {
|
|
33
|
+
return 'DragDropBlockToolbar';
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @inheritDoc
|
|
37
|
+
*/
|
|
38
|
+
init() {
|
|
39
|
+
const editor = this.editor;
|
|
40
|
+
this.listenTo(editor, 'change:isReadOnly', (evt, name, isReadOnly) => {
|
|
41
|
+
if (isReadOnly) {
|
|
42
|
+
this.forceDisabled('readOnlyMode');
|
|
43
|
+
this._isBlockDragging = false;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.clearForceDisabled('readOnlyMode');
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (env.isAndroid) {
|
|
50
|
+
this.forceDisabled('noAndroidSupport');
|
|
51
|
+
}
|
|
52
|
+
if (editor.plugins.has('BlockToolbar')) {
|
|
53
|
+
const blockToolbar = editor.plugins.get('BlockToolbar');
|
|
54
|
+
const element = blockToolbar.buttonView.element;
|
|
55
|
+
element.setAttribute('draggable', 'true');
|
|
56
|
+
this._domEmitter.listenTo(element, 'dragstart', (evt, data) => this._handleBlockDragStart(data));
|
|
57
|
+
this._domEmitter.listenTo(global.document, 'dragover', (evt, data) => this._handleBlockDragging(data));
|
|
58
|
+
this._domEmitter.listenTo(global.document, 'drop', (evt, data) => this._handleBlockDragging(data));
|
|
59
|
+
this._domEmitter.listenTo(global.document, 'dragend', () => this._handleBlockDragEnd(), { useCapture: true });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @inheritDoc
|
|
64
|
+
*/
|
|
65
|
+
destroy() {
|
|
66
|
+
this._domEmitter.stopListening();
|
|
67
|
+
return super.destroy();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The `dragstart` event handler.
|
|
71
|
+
*/
|
|
72
|
+
_handleBlockDragStart(domEvent) {
|
|
73
|
+
if (!this.isEnabled) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const model = this.editor.model;
|
|
77
|
+
const selection = model.document.selection;
|
|
78
|
+
const blocks = Array.from(selection.getSelectedBlocks());
|
|
79
|
+
const draggedRange = model.createRange(model.createPositionBefore(blocks[0]), model.createPositionAfter(blocks[blocks.length - 1]));
|
|
80
|
+
model.change(writer => writer.setSelection(draggedRange));
|
|
81
|
+
this._isBlockDragging = true;
|
|
82
|
+
this.editor.editing.view.getObserver(ClipboardObserver).onDomEvent(domEvent);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The `dragover` and `drop` event handler.
|
|
86
|
+
*/
|
|
87
|
+
_handleBlockDragging(domEvent) {
|
|
88
|
+
if (!this.isEnabled || !this._isBlockDragging) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const clientX = domEvent.clientX + 100;
|
|
92
|
+
const clientY = domEvent.clientY;
|
|
93
|
+
const target = document.elementFromPoint(clientX, clientY);
|
|
94
|
+
if (!target || !target.closest('.ck-editor__editable')) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.editor.editing.view.getObserver(ClipboardObserver).onDomEvent({
|
|
98
|
+
...domEvent,
|
|
99
|
+
type: domEvent.type,
|
|
100
|
+
dataTransfer: domEvent.dataTransfer,
|
|
101
|
+
target,
|
|
102
|
+
clientX,
|
|
103
|
+
clientY,
|
|
104
|
+
preventDefault: () => domEvent.preventDefault(),
|
|
105
|
+
stopPropagation: () => domEvent.stopPropagation()
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The `dragend` event handler.
|
|
110
|
+
*/
|
|
111
|
+
_handleBlockDragEnd() {
|
|
112
|
+
this._isBlockDragging = false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module clipboard/dragdropexperimental
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import { Widget } from '@ckeditor/ckeditor5-widget';
|
|
10
|
-
import ClipboardPipeline from './clipboardpipeline';
|
|
11
|
-
import DragDropTarget from './dragdroptarget';
|
|
12
|
-
import '../theme/clipboard.css';
|
|
13
|
-
/**
|
|
14
|
-
* The drag and drop feature. It works on top of the {@link module:clipboard/clipboardpipeline~ClipboardPipeline}.
|
|
15
|
-
*
|
|
16
|
-
* Read more about the clipboard integration in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
17
|
-
*
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
export default class DragDropExperimental extends Plugin {
|
|
21
|
-
/**
|
|
22
|
-
* The live range over the original content that is being dragged.
|
|
23
|
-
*/
|
|
24
|
-
private _draggedRange;
|
|
25
|
-
/**
|
|
26
|
-
* The UID of current dragging that is used to verify if the drop started in the same editor as the drag start.
|
|
27
|
-
*
|
|
28
|
-
* **Note**: This is a workaround for broken 'dragend' events (they are not fired if the source text node got removed).
|
|
29
|
-
*/
|
|
30
|
-
private _draggingUid;
|
|
31
|
-
/**
|
|
32
|
-
* The reference to the model element that currently has a `draggable` attribute set (it is set while dragging).
|
|
33
|
-
*/
|
|
34
|
-
private _draggableElement;
|
|
35
|
-
/**
|
|
36
|
-
* A delayed callback removing draggable attributes.
|
|
37
|
-
*/
|
|
38
|
-
private _clearDraggableAttributesDelayed;
|
|
39
|
-
/**
|
|
40
|
-
* Whether the dragged content can be dropped only in block context.
|
|
41
|
-
*/
|
|
42
|
-
private _blockMode;
|
|
43
|
-
/**
|
|
44
|
-
* DOM Emitter.
|
|
45
|
-
*/
|
|
46
|
-
private _domEmitter;
|
|
47
|
-
/**
|
|
48
|
-
* The DOM element used to generate dragged preview image.
|
|
49
|
-
*/
|
|
50
|
-
private _previewContainer?;
|
|
51
|
-
/**
|
|
52
|
-
* @inheritDoc
|
|
53
|
-
*/
|
|
54
|
-
static get pluginName(): "DragDropExperimental";
|
|
55
|
-
/**
|
|
56
|
-
* @inheritDoc
|
|
57
|
-
*/
|
|
58
|
-
static get requires(): readonly [typeof ClipboardPipeline, typeof Widget, typeof DragDropTarget];
|
|
59
|
-
/**
|
|
60
|
-
* @inheritDoc
|
|
61
|
-
*/
|
|
62
|
-
init(): void;
|
|
63
|
-
/**
|
|
64
|
-
* @inheritDoc
|
|
65
|
-
*/
|
|
66
|
-
destroy(): void;
|
|
67
|
-
/**
|
|
68
|
-
* Drag and drop events handling.
|
|
69
|
-
*/
|
|
70
|
-
private _setupDragging;
|
|
71
|
-
/**
|
|
72
|
-
* Integration with the `clipboardInput` event.
|
|
73
|
-
*/
|
|
74
|
-
private _setupClipboardInputIntegration;
|
|
75
|
-
/**
|
|
76
|
-
* Integration with the `contentInsertion` event of the clipboard pipeline.
|
|
77
|
-
*/
|
|
78
|
-
private _setupContentInsertionIntegration;
|
|
79
|
-
/**
|
|
80
|
-
* Adds listeners that add the `draggable` attribute to the elements while the mouse button is down so the dragging could start.
|
|
81
|
-
*/
|
|
82
|
-
private _setupDraggableAttributeHandling;
|
|
83
|
-
/**
|
|
84
|
-
* Removes the `draggable` attribute from the element that was used for dragging.
|
|
85
|
-
*/
|
|
86
|
-
private _clearDraggableAttributes;
|
|
87
|
-
/**
|
|
88
|
-
* Deletes the dragged content from its original range and clears the dragging state.
|
|
89
|
-
*
|
|
90
|
-
* @param moved Whether the move succeeded.
|
|
91
|
-
*/
|
|
92
|
-
private _finalizeDragging;
|
|
93
|
-
/**
|
|
94
|
-
* Sets the dragged source range based on event target and document selection.
|
|
95
|
-
*/
|
|
96
|
-
private _prepareDraggedRange;
|
|
97
|
-
/**
|
|
98
|
-
* Updates the dragged preview image.
|
|
99
|
-
*/
|
|
100
|
-
private _updatePreview;
|
|
101
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module clipboard/dragdropexperimental
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
+
import { Widget } from '@ckeditor/ckeditor5-widget';
|
|
10
|
+
import ClipboardPipeline from './clipboardpipeline';
|
|
11
|
+
import DragDropTarget from './dragdroptarget';
|
|
12
|
+
import '../theme/clipboard.css';
|
|
13
|
+
/**
|
|
14
|
+
* The drag and drop feature. It works on top of the {@link module:clipboard/clipboardpipeline~ClipboardPipeline}.
|
|
15
|
+
*
|
|
16
|
+
* Read more about the clipboard integration in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export default class DragDropExperimental extends Plugin {
|
|
21
|
+
/**
|
|
22
|
+
* The live range over the original content that is being dragged.
|
|
23
|
+
*/
|
|
24
|
+
private _draggedRange;
|
|
25
|
+
/**
|
|
26
|
+
* The UID of current dragging that is used to verify if the drop started in the same editor as the drag start.
|
|
27
|
+
*
|
|
28
|
+
* **Note**: This is a workaround for broken 'dragend' events (they are not fired if the source text node got removed).
|
|
29
|
+
*/
|
|
30
|
+
private _draggingUid;
|
|
31
|
+
/**
|
|
32
|
+
* The reference to the model element that currently has a `draggable` attribute set (it is set while dragging).
|
|
33
|
+
*/
|
|
34
|
+
private _draggableElement;
|
|
35
|
+
/**
|
|
36
|
+
* A delayed callback removing draggable attributes.
|
|
37
|
+
*/
|
|
38
|
+
private _clearDraggableAttributesDelayed;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the dragged content can be dropped only in block context.
|
|
41
|
+
*/
|
|
42
|
+
private _blockMode;
|
|
43
|
+
/**
|
|
44
|
+
* DOM Emitter.
|
|
45
|
+
*/
|
|
46
|
+
private _domEmitter;
|
|
47
|
+
/**
|
|
48
|
+
* The DOM element used to generate dragged preview image.
|
|
49
|
+
*/
|
|
50
|
+
private _previewContainer?;
|
|
51
|
+
/**
|
|
52
|
+
* @inheritDoc
|
|
53
|
+
*/
|
|
54
|
+
static get pluginName(): "DragDropExperimental";
|
|
55
|
+
/**
|
|
56
|
+
* @inheritDoc
|
|
57
|
+
*/
|
|
58
|
+
static get requires(): readonly [typeof ClipboardPipeline, typeof Widget, typeof DragDropTarget];
|
|
59
|
+
/**
|
|
60
|
+
* @inheritDoc
|
|
61
|
+
*/
|
|
62
|
+
init(): void;
|
|
63
|
+
/**
|
|
64
|
+
* @inheritDoc
|
|
65
|
+
*/
|
|
66
|
+
destroy(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Drag and drop events handling.
|
|
69
|
+
*/
|
|
70
|
+
private _setupDragging;
|
|
71
|
+
/**
|
|
72
|
+
* Integration with the `clipboardInput` event.
|
|
73
|
+
*/
|
|
74
|
+
private _setupClipboardInputIntegration;
|
|
75
|
+
/**
|
|
76
|
+
* Integration with the `contentInsertion` event of the clipboard pipeline.
|
|
77
|
+
*/
|
|
78
|
+
private _setupContentInsertionIntegration;
|
|
79
|
+
/**
|
|
80
|
+
* Adds listeners that add the `draggable` attribute to the elements while the mouse button is down so the dragging could start.
|
|
81
|
+
*/
|
|
82
|
+
private _setupDraggableAttributeHandling;
|
|
83
|
+
/**
|
|
84
|
+
* Removes the `draggable` attribute from the element that was used for dragging.
|
|
85
|
+
*/
|
|
86
|
+
private _clearDraggableAttributes;
|
|
87
|
+
/**
|
|
88
|
+
* Deletes the dragged content from its original range and clears the dragging state.
|
|
89
|
+
*
|
|
90
|
+
* @param moved Whether the move succeeded.
|
|
91
|
+
*/
|
|
92
|
+
private _finalizeDragging;
|
|
93
|
+
/**
|
|
94
|
+
* Sets the dragged source range based on event target and document selection.
|
|
95
|
+
*/
|
|
96
|
+
private _prepareDraggedRange;
|
|
97
|
+
/**
|
|
98
|
+
* Updates the dragged preview image.
|
|
99
|
+
*/
|
|
100
|
+
private _updatePreview;
|
|
101
|
+
}
|