@ckeditor/ckeditor5-clipboard 45.2.1 → 46.0.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-editor.css +1 -0
- package/dist/index.css +1 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +33 -30
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/clipboard.d.ts +5 -5
- package/src/clipboard.js +5 -5
- package/src/clipboardmarkersutils.d.ts +5 -5
- package/src/clipboardmarkersutils.js +3 -3
- package/src/clipboardobserver.d.ts +85 -84
- package/src/clipboardobserver.js +16 -16
- package/src/clipboardpipeline.d.ts +22 -22
- package/src/clipboardpipeline.js +14 -14
- package/src/dragdrop.d.ts +4 -4
- package/src/dragdrop.js +10 -10
- package/src/dragdropblocktoolbar.d.ts +1 -1
- package/src/dragdropblocktoolbar.js +2 -2
- package/src/dragdroptarget.d.ts +4 -4
- package/src/dragdroptarget.js +2 -2
- package/src/index.d.ts +15 -10
- package/src/index.js +15 -10
- package/src/lineview.d.ts +3 -1
- package/src/lineview.js +3 -1
- package/src/pasteplaintext.d.ts +2 -2
- package/src/pasteplaintext.js +3 -3
- package/src/utils/normalizeclipboarddata.d.ts +2 -1
- package/src/utils/normalizeclipboarddata.js +2 -1
- package/src/utils/plaintexttohtml.d.ts +1 -1
- package/src/utils/plaintexttohtml.js +1 -1
- package/src/utils/viewtoplaintext.d.ts +3 -3
- package/src/utils/viewtoplaintext.js +3 -3
- package/theme/clipboard.css +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-clipboard",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "46.0.0-alpha.1",
|
|
4
4
|
"description": "Clipboard integration feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "src/index.js",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@ckeditor/ckeditor5-core": "
|
|
17
|
-
"@ckeditor/ckeditor5-engine": "
|
|
18
|
-
"@ckeditor/ckeditor5-ui": "
|
|
19
|
-
"@ckeditor/ckeditor5-utils": "
|
|
20
|
-
"@ckeditor/ckeditor5-widget": "
|
|
21
|
-
"es-toolkit": "1.
|
|
16
|
+
"@ckeditor/ckeditor5-core": "46.0.0-alpha.1",
|
|
17
|
+
"@ckeditor/ckeditor5-engine": "46.0.0-alpha.1",
|
|
18
|
+
"@ckeditor/ckeditor5-ui": "46.0.0-alpha.1",
|
|
19
|
+
"@ckeditor/ckeditor5-utils": "46.0.0-alpha.1",
|
|
20
|
+
"@ckeditor/ckeditor5-widget": "46.0.0-alpha.1",
|
|
21
|
+
"es-toolkit": "1.39.5"
|
|
22
22
|
},
|
|
23
23
|
"author": "CKSource (http://cksource.com/)",
|
|
24
24
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/src/clipboard.d.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* @module clipboard/clipboard
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import ClipboardPipeline from './clipboardpipeline.js';
|
|
10
|
-
import DragDrop from './dragdrop.js';
|
|
11
|
-
import PastePlainText from './pasteplaintext.js';
|
|
12
|
-
import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
9
|
+
import { ClipboardPipeline } from './clipboardpipeline.js';
|
|
10
|
+
import { DragDrop } from './dragdrop.js';
|
|
11
|
+
import { PastePlainText } from './pasteplaintext.js';
|
|
12
|
+
import { ClipboardMarkersUtils } from './clipboardmarkersutils.js';
|
|
13
13
|
/**
|
|
14
14
|
* The clipboard feature.
|
|
15
15
|
*
|
|
@@ -20,7 +20,7 @@ import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
|
20
20
|
* * {@link module:clipboard/dragdrop~DragDrop}
|
|
21
21
|
* * {@link module:clipboard/pasteplaintext~PastePlainText}
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export declare class Clipboard extends Plugin {
|
|
24
24
|
/**
|
|
25
25
|
* @inheritDoc
|
|
26
26
|
*/
|
package/src/clipboard.js
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* @module clipboard/clipboard
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import ClipboardPipeline from './clipboardpipeline.js';
|
|
10
|
-
import DragDrop from './dragdrop.js';
|
|
11
|
-
import PastePlainText from './pasteplaintext.js';
|
|
12
|
-
import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
9
|
+
import { ClipboardPipeline } from './clipboardpipeline.js';
|
|
10
|
+
import { DragDrop } from './dragdrop.js';
|
|
11
|
+
import { PastePlainText } from './pasteplaintext.js';
|
|
12
|
+
import { ClipboardMarkersUtils } from './clipboardmarkersutils.js';
|
|
13
13
|
/**
|
|
14
14
|
* The clipboard feature.
|
|
15
15
|
*
|
|
@@ -20,7 +20,7 @@ import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
|
20
20
|
* * {@link module:clipboard/dragdrop~DragDrop}
|
|
21
21
|
* * {@link module:clipboard/pasteplaintext~PastePlainText}
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export class Clipboard extends Plugin {
|
|
24
24
|
/**
|
|
25
25
|
* @inheritDoc
|
|
26
26
|
*/
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
import { Plugin, type NonEmptyArray } from '@ckeditor/ckeditor5-core';
|
|
6
|
-
import {
|
|
6
|
+
import { ModelRange, type ModelDocumentFragment, type ModelElement, type ModelDocumentSelection, type ModelSelection, type ModelWriter } from '@ckeditor/ckeditor5-engine';
|
|
7
7
|
/**
|
|
8
8
|
* Part of the clipboard logic. Responsible for collecting markers from selected fragments
|
|
9
9
|
* and restoring them with proper positions in pasted elements.
|
|
10
10
|
*
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export declare class ClipboardMarkersUtils extends Plugin {
|
|
14
14
|
/**
|
|
15
15
|
* Map of marker names that can be copied.
|
|
16
16
|
*
|
|
@@ -50,7 +50,7 @@ export default class ClipboardMarkersUtils extends Plugin {
|
|
|
50
50
|
* @param getCopiedFragment Callback that performs copy of selection and returns it as fragment.
|
|
51
51
|
* @internal
|
|
52
52
|
*/
|
|
53
|
-
_copySelectedFragmentWithMarkers(action: ClipboardMarkerRestrictedAction, selection:
|
|
53
|
+
_copySelectedFragmentWithMarkers(action: ClipboardMarkerRestrictedAction, selection: ModelSelection | ModelDocumentSelection, getCopiedFragment?: (writer: ModelWriter) => ModelDocumentFragment): ModelDocumentFragment;
|
|
54
54
|
/**
|
|
55
55
|
* Performs paste of markers on already pasted element.
|
|
56
56
|
*
|
|
@@ -69,7 +69,7 @@ export default class ClipboardMarkersUtils extends Plugin {
|
|
|
69
69
|
* @param getPastedDocumentElement Getter used to get target markers element.
|
|
70
70
|
* @internal
|
|
71
71
|
*/
|
|
72
|
-
_pasteMarkersIntoTransformedElement(markers: Record<string,
|
|
72
|
+
_pasteMarkersIntoTransformedElement(markers: Record<string, ModelRange> | Map<string, ModelRange>, getPastedDocumentElement: (writer: ModelWriter) => ModelElement): ModelElement;
|
|
73
73
|
/**
|
|
74
74
|
* Pastes document fragment with markers to document.
|
|
75
75
|
* If `duplicateOnPaste` is `true` in marker config then associated markers IDs
|
|
@@ -78,7 +78,7 @@ export default class ClipboardMarkersUtils extends Plugin {
|
|
|
78
78
|
* @param fragment Document fragment that should contain already processed by pipeline markers.
|
|
79
79
|
* @internal
|
|
80
80
|
*/
|
|
81
|
-
_pasteFragmentWithMarkers(fragment:
|
|
81
|
+
_pasteFragmentWithMarkers(fragment: ModelDocumentFragment): ModelRange;
|
|
82
82
|
/**
|
|
83
83
|
* In some situations we have to perform copy on selected fragment with certain markers. This function allows to temporarily bypass
|
|
84
84
|
* restrictions on markers that we want to copy.
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
import { mapValues } from 'es-toolkit/compat';
|
|
9
9
|
import { uid } from '@ckeditor/ckeditor5-utils';
|
|
10
10
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
11
|
-
import {
|
|
11
|
+
import { ModelRange } from '@ckeditor/ckeditor5-engine';
|
|
12
12
|
/**
|
|
13
13
|
* Part of the clipboard logic. Responsible for collecting markers from selected fragments
|
|
14
14
|
* and restoring them with proper positions in pasted elements.
|
|
15
15
|
*
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export class ClipboardMarkersUtils extends Plugin {
|
|
19
19
|
/**
|
|
20
20
|
* Map of marker names that can be copied.
|
|
21
21
|
*
|
|
@@ -409,7 +409,7 @@ export default class ClipboardMarkersUtils extends Plugin {
|
|
|
409
409
|
// We have to remove `fake-marker-start` firstly and then remove `fake-marker-2-start`.
|
|
410
410
|
// Removal of `fake-marker-2-start` affects `fake-marker-end` position so we cannot create
|
|
411
411
|
// connection between `fake-marker-start` and `fake-marker-end` without iterating whole set firstly.
|
|
412
|
-
return mapValues(fakeMarkersRanges, range => new
|
|
412
|
+
return mapValues(fakeMarkersRanges, range => new ModelRange(range.start || writer.createPositionFromPath(rootElement, [0]), range.end || writer.createPositionAt(rootElement, 'end')));
|
|
413
413
|
}
|
|
414
414
|
/**
|
|
415
415
|
* Returns array that contains list of fake markers with corresponding `$marker` elements.
|
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { ViewDataTransfer, DomEventObserver, type ViewDocumentDomEventData, type EditingView, type ViewDocumentFragment, type ViewElement, type ViewRange } from '@ckeditor/ckeditor5-engine';
|
|
6
6
|
/**
|
|
7
7
|
* Clipboard events observer.
|
|
8
8
|
*
|
|
9
9
|
* Fires the following events:
|
|
10
10
|
*
|
|
11
|
-
* * {@link module:engine/view/document~
|
|
12
|
-
* * {@link module:engine/view/document~
|
|
13
|
-
* * {@link module:engine/view/document~
|
|
14
|
-
* * {@link module:engine/view/document~
|
|
15
|
-
* * {@link module:engine/view/document~
|
|
16
|
-
* * {@link module:engine/view/document~
|
|
17
|
-
* * {@link module:engine/view/document~
|
|
18
|
-
* * {@link module:engine/view/document~
|
|
19
|
-
* * {@link module:engine/view/document~
|
|
20
|
-
* * {@link module:engine/view/document~
|
|
21
|
-
* * {@link module:engine/view/document~
|
|
11
|
+
* * {@link module:engine/view/document~ViewDocument#event:clipboardInput},
|
|
12
|
+
* * {@link module:engine/view/document~ViewDocument#event:paste},
|
|
13
|
+
* * {@link module:engine/view/document~ViewDocument#event:copy},
|
|
14
|
+
* * {@link module:engine/view/document~ViewDocument#event:cut},
|
|
15
|
+
* * {@link module:engine/view/document~ViewDocument#event:drop},
|
|
16
|
+
* * {@link module:engine/view/document~ViewDocument#event:dragover},
|
|
17
|
+
* * {@link module:engine/view/document~ViewDocument#event:dragging},
|
|
18
|
+
* * {@link module:engine/view/document~ViewDocument#event:dragstart},
|
|
19
|
+
* * {@link module:engine/view/document~ViewDocument#event:dragend},
|
|
20
|
+
* * {@link module:engine/view/document~ViewDocument#event:dragenter},
|
|
21
|
+
* * {@link module:engine/view/document~ViewDocument#event:dragleave}.
|
|
22
22
|
*
|
|
23
23
|
* **Note**: This observer is not available by default (ckeditor5-engine does not add it on its own).
|
|
24
|
-
* To make it available, it needs to be added to {@link module:engine/view/document~
|
|
25
|
-
* the {@link module:engine/view/view~
|
|
24
|
+
* To make it available, it needs to be added to {@link module:engine/view/document~ViewDocument} by using
|
|
25
|
+
* the {@link module:engine/view/view~EditingView#addObserver `View#addObserver()`} method. Alternatively, you can load the
|
|
26
26
|
* {@link module:clipboard/clipboard~Clipboard} plugin which adds this observer automatically (because it uses it).
|
|
27
27
|
*/
|
|
28
|
-
export
|
|
28
|
+
export declare class ClipboardObserver extends DomEventObserver<'paste' | 'copy' | 'cut' | 'drop' | 'dragover' | 'dragstart' | 'dragend' | 'dragenter' | 'dragleave', ClipboardEventData> {
|
|
29
29
|
readonly domEventType: readonly ["paste", "copy", "cut", "drop", "dragover", "dragstart", "dragend", "dragenter", "dragleave"];
|
|
30
30
|
constructor(view: EditingView);
|
|
31
31
|
onDomEvent(domEvent: ClipboardEvent | DragEvent): void;
|
|
@@ -37,15 +37,15 @@ export interface ClipboardEventData {
|
|
|
37
37
|
/**
|
|
38
38
|
* The data transfer instance.
|
|
39
39
|
*/
|
|
40
|
-
dataTransfer:
|
|
40
|
+
dataTransfer: ViewDataTransfer;
|
|
41
41
|
/**
|
|
42
42
|
* The position into which the content is dropped.
|
|
43
43
|
*/
|
|
44
44
|
dropRange?: ViewRange | null;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
* Fired as a continuation of the {@link module:engine/view/document~
|
|
48
|
-
* {@link module:engine/view/document~
|
|
47
|
+
* Fired as a continuation of the {@link module:engine/view/document~ViewDocument#event:paste} and
|
|
48
|
+
* {@link module:engine/view/document~ViewDocument#event:drop} events.
|
|
49
49
|
*
|
|
50
50
|
* It is a part of the {@glink framework/deep-dive/clipboard#input-pipeline clipboard input pipeline}.
|
|
51
51
|
*
|
|
@@ -53,23 +53,23 @@ export interface ClipboardEventData {
|
|
|
53
53
|
* and inserted into the editor.
|
|
54
54
|
*
|
|
55
55
|
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
56
|
-
* needs to be added to the {@link module:engine/view/document~
|
|
57
|
-
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
58
|
-
* the observer must be added manually.
|
|
56
|
+
* needs to be added to the {@link module:engine/view/document~ViewDocument} by using the
|
|
57
|
+
* {@link module:engine/view/view~EditingView#addObserver} method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
58
|
+
* plugin, but if for some reason it is not loaded, the observer must be added manually.
|
|
59
59
|
*
|
|
60
60
|
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
61
61
|
* @see module:clipboard/clipboard~Clipboard
|
|
62
62
|
*
|
|
63
|
-
* @eventName module:engine/view/document~
|
|
63
|
+
* @eventName module:engine/view/document~ViewDocument#clipboardInput
|
|
64
64
|
* @param data The event data.
|
|
65
65
|
*/
|
|
66
66
|
export type ViewDocumentClipboardInputEvent = {
|
|
67
67
|
name: 'clipboardInput';
|
|
68
|
-
args: [data:
|
|
68
|
+
args: [data: ViewDocumentDomEventData<ClipboardEvent | DragEvent> & ClipboardInputEventData];
|
|
69
69
|
};
|
|
70
70
|
/**
|
|
71
|
-
* The value of the {@link module:engine/view/document~
|
|
72
|
-
* {@link module:engine/view/document~
|
|
71
|
+
* The value of the {@link module:engine/view/document~ViewDocument#event:paste},
|
|
72
|
+
* {@link module:engine/view/document~ViewDocument#event:copy} and {@link module:engine/view/document~ViewDocument#event:cut} events.
|
|
73
73
|
*
|
|
74
74
|
* In order to access the clipboard data, use the `dataTransfer` property.
|
|
75
75
|
*/
|
|
@@ -77,7 +77,7 @@ export interface ClipboardInputEventData {
|
|
|
77
77
|
/**
|
|
78
78
|
* Data transfer instance.
|
|
79
79
|
*/
|
|
80
|
-
dataTransfer:
|
|
80
|
+
dataTransfer: ViewDataTransfer;
|
|
81
81
|
/**
|
|
82
82
|
* Whether the event was triggered by a paste or a drop operation.
|
|
83
83
|
*/
|
|
@@ -103,18 +103,18 @@ export interface ClipboardInputEventData {
|
|
|
103
103
|
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
104
104
|
*
|
|
105
105
|
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
106
|
-
* needs to be added to the {@link module:engine/view/document~
|
|
107
|
-
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
108
|
-
* the observer must be added manually.
|
|
106
|
+
* needs to be added to the {@link module:engine/view/document~ViewDocument} by using the
|
|
107
|
+
* {@link module:engine/view/view~EditingView#addObserver} method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
108
|
+
* plugin, but if for some reason it is not loaded, the observer must be added manually.
|
|
109
109
|
*
|
|
110
|
-
* @see module:engine/view/document~
|
|
110
|
+
* @see module:engine/view/document~ViewDocument#event:clipboardInput
|
|
111
111
|
*
|
|
112
|
-
* @eventName module:engine/view/document~
|
|
112
|
+
* @eventName module:engine/view/document~ViewDocument#dragover
|
|
113
113
|
* @param data The event data.
|
|
114
114
|
*/
|
|
115
115
|
export type ViewDocumentDragOverEvent = {
|
|
116
116
|
name: 'dragover';
|
|
117
|
-
args: [data:
|
|
117
|
+
args: [data: ViewDocumentDomEventData<DragEvent> & ClipboardEventData];
|
|
118
118
|
};
|
|
119
119
|
/**
|
|
120
120
|
* Fired when the user dropped the content into one of the editing roots of the editor.
|
|
@@ -122,18 +122,18 @@ export type ViewDocumentDragOverEvent = {
|
|
|
122
122
|
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
123
123
|
*
|
|
124
124
|
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
125
|
-
* needs to be added to the {@link module:engine/view/document~
|
|
126
|
-
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
127
|
-
* the observer must be added manually.
|
|
125
|
+
* needs to be added to the {@link module:engine/view/document~ViewDocument} by using the
|
|
126
|
+
* {@link module:engine/view/view~EditingView#addObserver} method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
127
|
+
* plugin, but if for some reason it is not loaded, the observer must be added manually.
|
|
128
128
|
*
|
|
129
|
-
* @see module:engine/view/document~
|
|
129
|
+
* @see module:engine/view/document~ViewDocument#event:clipboardInput
|
|
130
130
|
*
|
|
131
|
-
* @eventName module:engine/view/document~
|
|
131
|
+
* @eventName module:engine/view/document~ViewDocument#drop
|
|
132
132
|
* @param data The event data.
|
|
133
133
|
*/
|
|
134
134
|
export type ViewDocumentDropEvent = {
|
|
135
135
|
name: 'drop';
|
|
136
|
-
args: [data:
|
|
136
|
+
args: [data: ViewDocumentDomEventData<DragEvent> & ClipboardEventData];
|
|
137
137
|
};
|
|
138
138
|
/**
|
|
139
139
|
* Fired when the user pasted the content into one of the editing roots of the editor.
|
|
@@ -141,18 +141,18 @@ export type ViewDocumentDropEvent = {
|
|
|
141
141
|
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
142
142
|
*
|
|
143
143
|
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
144
|
-
* needs to be added to the {@link module:engine/view/document~
|
|
145
|
-
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
146
|
-
* the observer must be added manually.
|
|
144
|
+
* needs to be added to the {@link module:engine/view/document~ViewDocument} by using the
|
|
145
|
+
* {@link module:engine/view/view~EditingView#addObserver} method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
146
|
+
* plugin, but if for some reason it is not loaded, the observer must be added manually.
|
|
147
147
|
*
|
|
148
|
-
* @see module:engine/view/document~
|
|
148
|
+
* @see module:engine/view/document~ViewDocument#event:clipboardInput
|
|
149
149
|
*
|
|
150
|
-
* @eventName module:engine/view/document~
|
|
150
|
+
* @eventName module:engine/view/document~ViewDocument#paste
|
|
151
151
|
* @param {module:clipboard/clipboardobserver~ClipboardEventData} data The event data.
|
|
152
152
|
*/
|
|
153
153
|
export type ViewDocumentPasteEvent = {
|
|
154
154
|
name: 'paste';
|
|
155
|
-
args: [data:
|
|
155
|
+
args: [data: ViewDocumentDomEventData<ClipboardEvent> & ClipboardEventData];
|
|
156
156
|
};
|
|
157
157
|
/**
|
|
158
158
|
* Fired when the user copied the content from one of the editing roots of the editor.
|
|
@@ -160,18 +160,18 @@ export type ViewDocumentPasteEvent = {
|
|
|
160
160
|
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
161
161
|
*
|
|
162
162
|
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
163
|
-
* needs to be added to the {@link module:engine/view/document~
|
|
164
|
-
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
165
|
-
* the observer must be added manually.
|
|
163
|
+
* needs to be added to the {@link module:engine/view/document~ViewDocument} by using the
|
|
164
|
+
* {@link module:engine/view/view~EditingView#addObserver} method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
165
|
+
* plugin, but if for some reason it is not loaded, the observer must be added manually.
|
|
166
166
|
*
|
|
167
167
|
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
168
168
|
*
|
|
169
|
-
* @eventName module:engine/view/document~
|
|
169
|
+
* @eventName module:engine/view/document~ViewDocument#copy
|
|
170
170
|
* @param data The event data.
|
|
171
171
|
*/
|
|
172
172
|
export type ViewDocumentCopyEvent = {
|
|
173
173
|
name: 'copy';
|
|
174
|
-
args: [data:
|
|
174
|
+
args: [data: ViewDocumentDomEventData<ClipboardEvent> & ClipboardEventData];
|
|
175
175
|
};
|
|
176
176
|
/**
|
|
177
177
|
* Fired when the user cut the content from one of the editing roots of the editor.
|
|
@@ -179,21 +179,21 @@ export type ViewDocumentCopyEvent = {
|
|
|
179
179
|
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
180
180
|
*
|
|
181
181
|
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
182
|
-
* needs to be added to the {@link module:engine/view/document~
|
|
183
|
-
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
184
|
-
* the observer must be added manually.
|
|
182
|
+
* needs to be added to the {@link module:engine/view/document~ViewDocument} by using the
|
|
183
|
+
* {@link module:engine/view/view~EditingView#addObserver} method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
184
|
+
* plugin, but if for some reason it is not loaded, the observer must be added manually.
|
|
185
185
|
*
|
|
186
186
|
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
187
187
|
*
|
|
188
|
-
* @eventName module:engine/view/document~
|
|
188
|
+
* @eventName module:engine/view/document~ViewDocument#cut
|
|
189
189
|
* @param data The event data.
|
|
190
190
|
*/
|
|
191
191
|
export type ViewDocumentCutEvent = {
|
|
192
192
|
name: 'cut';
|
|
193
|
-
args: [data:
|
|
193
|
+
args: [data: ViewDocumentDomEventData<ClipboardEvent> & ClipboardEventData];
|
|
194
194
|
};
|
|
195
195
|
/**
|
|
196
|
-
* Fired as a continuation of the {@link module:engine/view/document~
|
|
196
|
+
* Fired as a continuation of the {@link module:engine/view/document~ViewDocument#event:dragover} event.
|
|
197
197
|
*
|
|
198
198
|
* It is a part of the {@glink framework/deep-dive/clipboard#input-pipeline clipboard input pipeline}.
|
|
199
199
|
*
|
|
@@ -201,25 +201,26 @@ export type ViewDocumentCutEvent = {
|
|
|
201
201
|
* and inserted into the editor.
|
|
202
202
|
*
|
|
203
203
|
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
204
|
-
* needs to be added to the {@link module:engine/view/document~
|
|
205
|
-
*
|
|
204
|
+
* needs to be added to the {@link module:engine/view/document~ViewDocument} by using the
|
|
205
|
+
* {@link module:engine/view/view~EditingView#addObserver} method. This is usually done by the
|
|
206
|
+
* {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
206
207
|
* the observer must be added manually.
|
|
207
208
|
*
|
|
208
209
|
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
209
210
|
* @see module:clipboard/clipboard~Clipboard
|
|
210
211
|
*
|
|
211
|
-
* @eventName module:engine/view/document~
|
|
212
|
+
* @eventName module:engine/view/document~ViewDocument#dragging
|
|
212
213
|
* @param data The event data.
|
|
213
214
|
*/
|
|
214
215
|
export type ViewDocumentDraggingEvent = {
|
|
215
216
|
name: 'dragging';
|
|
216
|
-
args: [data:
|
|
217
|
+
args: [data: ViewDocumentDomEventData<DragEvent> & DraggingEventData];
|
|
217
218
|
};
|
|
218
219
|
export interface DraggingEventData {
|
|
219
220
|
/**
|
|
220
221
|
* The data transfer instance.
|
|
221
222
|
*/
|
|
222
|
-
dataTransfer:
|
|
223
|
+
dataTransfer: ViewDataTransfer;
|
|
223
224
|
/**
|
|
224
225
|
* Whether the event was triggered by a paste or a drop operation.
|
|
225
226
|
*/
|
|
@@ -240,18 +241,18 @@ export interface DraggingEventData {
|
|
|
240
241
|
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
241
242
|
*
|
|
242
243
|
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
243
|
-
* needs to be added to the {@link module:engine/view/document~
|
|
244
|
-
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
245
|
-
* the observer must be added manually.
|
|
244
|
+
* needs to be added to the {@link module:engine/view/document~ViewDocument} by using the
|
|
245
|
+
* {@link module:engine/view/view~EditingView#addObserver} method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
246
|
+
* plugin, but if for some reason it is not loaded, the observer must be added manually.
|
|
246
247
|
*
|
|
247
|
-
* @see module:engine/view/document~
|
|
248
|
+
* @see module:engine/view/document~ViewDocument#event:clipboardInput
|
|
248
249
|
*
|
|
249
|
-
* @eventName module:engine/view/document~
|
|
250
|
+
* @eventName module:engine/view/document~ViewDocument#dragstart
|
|
250
251
|
* @param data The event data.
|
|
251
252
|
*/
|
|
252
253
|
export type ViewDocumentDragStartEvent = {
|
|
253
254
|
name: 'dragstart';
|
|
254
|
-
args: [data:
|
|
255
|
+
args: [data: ViewDocumentDomEventData<DragEvent> & ClipboardEventData];
|
|
255
256
|
};
|
|
256
257
|
/**
|
|
257
258
|
* Fired when the user ended dragging the content.
|
|
@@ -259,18 +260,18 @@ export type ViewDocumentDragStartEvent = {
|
|
|
259
260
|
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
260
261
|
*
|
|
261
262
|
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
262
|
-
* needs to be added to the {@link module:engine/view/document~
|
|
263
|
-
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
264
|
-
* the observer must be added manually.
|
|
263
|
+
* needs to be added to the {@link module:engine/view/document~ViewDocument} by using the
|
|
264
|
+
* {@link module:engine/view/view~EditingView#addObserver} method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
265
|
+
* plugin, but if for some reason it is not loaded, the observer must be added manually.
|
|
265
266
|
*
|
|
266
|
-
* @see module:engine/view/document~
|
|
267
|
+
* @see module:engine/view/document~ViewDocument#event:clipboardInput
|
|
267
268
|
*
|
|
268
|
-
* @eventName module:engine/view/document~
|
|
269
|
+
* @eventName module:engine/view/document~ViewDocument#dragend
|
|
269
270
|
* @param data The event data.
|
|
270
271
|
*/
|
|
271
272
|
export type ViewDocumentDragEndEvent = {
|
|
272
273
|
name: 'dragend';
|
|
273
|
-
args: [data:
|
|
274
|
+
args: [data: ViewDocumentDomEventData<DragEvent> & ClipboardEventData];
|
|
274
275
|
};
|
|
275
276
|
/**
|
|
276
277
|
* Fired when the user drags the content into one of the editing roots of the editor.
|
|
@@ -278,18 +279,18 @@ export type ViewDocumentDragEndEvent = {
|
|
|
278
279
|
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
279
280
|
*
|
|
280
281
|
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
281
|
-
* needs to be added to the {@link module:engine/view/document~
|
|
282
|
-
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
283
|
-
* the observer must be added manually.
|
|
282
|
+
* needs to be added to the {@link module:engine/view/document~ViewDocument} by using the
|
|
283
|
+
* {@link module:engine/view/view~EditingView#addObserver} method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
284
|
+
* plugin, but if for some reason it is not loaded, the observer must be added manually.
|
|
284
285
|
*
|
|
285
|
-
* @see module:engine/view/document~
|
|
286
|
+
* @see module:engine/view/document~ViewDocument#event:clipboardInput
|
|
286
287
|
*
|
|
287
|
-
* @eventName module:engine/view/document~
|
|
288
|
+
* @eventName module:engine/view/document~ViewDocument#dragenter
|
|
288
289
|
* @param data The event data.
|
|
289
290
|
*/
|
|
290
291
|
export type ViewDocumentDragEnterEvent = {
|
|
291
292
|
name: 'dragenter';
|
|
292
|
-
args: [data:
|
|
293
|
+
args: [data: ViewDocumentDomEventData<DragEvent> & ClipboardEventData];
|
|
293
294
|
};
|
|
294
295
|
/**
|
|
295
296
|
* Fired when the user drags the content out of one of the editing roots of the editor.
|
|
@@ -297,16 +298,16 @@ export type ViewDocumentDragEnterEvent = {
|
|
|
297
298
|
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
298
299
|
*
|
|
299
300
|
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
300
|
-
* needs to be added to the {@link module:engine/view/document~
|
|
301
|
-
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
302
|
-
* the observer must be added manually.
|
|
301
|
+
* needs to be added to the {@link module:engine/view/document~ViewDocument} by using the
|
|
302
|
+
* {@link module:engine/view/view~EditingView#addObserver} method. This is usually done by the {@link module:clipboard/clipboard~Clipboard}
|
|
303
|
+
* plugin, but if for some reason it is not loaded, the observer must be added manually.
|
|
303
304
|
*
|
|
304
|
-
* @see module:engine/view/document~
|
|
305
|
+
* @see module:engine/view/document~ViewDocument#event:clipboardInput
|
|
305
306
|
*
|
|
306
|
-
* @eventName module:engine/view/document~
|
|
307
|
+
* @eventName module:engine/view/document~ViewDocument#dragleave
|
|
307
308
|
* @param data The event data.
|
|
308
309
|
*/
|
|
309
310
|
export type ViewDocumentDragLeaveEvent = {
|
|
310
311
|
name: 'dragleave';
|
|
311
|
-
args: [data:
|
|
312
|
+
args: [data: ViewDocumentDomEventData<DragEvent> & ClipboardEventData];
|
|
312
313
|
};
|
package/src/clipboardobserver.js
CHANGED
|
@@ -6,30 +6,30 @@
|
|
|
6
6
|
* @module clipboard/clipboardobserver
|
|
7
7
|
*/
|
|
8
8
|
import { EventInfo, getRangeFromMouseEvent } from '@ckeditor/ckeditor5-utils';
|
|
9
|
-
import {
|
|
9
|
+
import { ViewDataTransfer, DomEventObserver } from '@ckeditor/ckeditor5-engine';
|
|
10
10
|
/**
|
|
11
11
|
* Clipboard events observer.
|
|
12
12
|
*
|
|
13
13
|
* Fires the following events:
|
|
14
14
|
*
|
|
15
|
-
* * {@link module:engine/view/document~
|
|
16
|
-
* * {@link module:engine/view/document~
|
|
17
|
-
* * {@link module:engine/view/document~
|
|
18
|
-
* * {@link module:engine/view/document~
|
|
19
|
-
* * {@link module:engine/view/document~
|
|
20
|
-
* * {@link module:engine/view/document~
|
|
21
|
-
* * {@link module:engine/view/document~
|
|
22
|
-
* * {@link module:engine/view/document~
|
|
23
|
-
* * {@link module:engine/view/document~
|
|
24
|
-
* * {@link module:engine/view/document~
|
|
25
|
-
* * {@link module:engine/view/document~
|
|
15
|
+
* * {@link module:engine/view/document~ViewDocument#event:clipboardInput},
|
|
16
|
+
* * {@link module:engine/view/document~ViewDocument#event:paste},
|
|
17
|
+
* * {@link module:engine/view/document~ViewDocument#event:copy},
|
|
18
|
+
* * {@link module:engine/view/document~ViewDocument#event:cut},
|
|
19
|
+
* * {@link module:engine/view/document~ViewDocument#event:drop},
|
|
20
|
+
* * {@link module:engine/view/document~ViewDocument#event:dragover},
|
|
21
|
+
* * {@link module:engine/view/document~ViewDocument#event:dragging},
|
|
22
|
+
* * {@link module:engine/view/document~ViewDocument#event:dragstart},
|
|
23
|
+
* * {@link module:engine/view/document~ViewDocument#event:dragend},
|
|
24
|
+
* * {@link module:engine/view/document~ViewDocument#event:dragenter},
|
|
25
|
+
* * {@link module:engine/view/document~ViewDocument#event:dragleave}.
|
|
26
26
|
*
|
|
27
27
|
* **Note**: This observer is not available by default (ckeditor5-engine does not add it on its own).
|
|
28
|
-
* To make it available, it needs to be added to {@link module:engine/view/document~
|
|
29
|
-
* the {@link module:engine/view/view~
|
|
28
|
+
* To make it available, it needs to be added to {@link module:engine/view/document~ViewDocument} by using
|
|
29
|
+
* the {@link module:engine/view/view~EditingView#addObserver `View#addObserver()`} method. Alternatively, you can load the
|
|
30
30
|
* {@link module:clipboard/clipboard~Clipboard} plugin which adds this observer automatically (because it uses it).
|
|
31
31
|
*/
|
|
32
|
-
export
|
|
32
|
+
export class ClipboardObserver extends DomEventObserver {
|
|
33
33
|
domEventType = [
|
|
34
34
|
'paste', 'copy', 'cut', 'drop', 'dragover', 'dragstart', 'dragend', 'dragenter', 'dragleave'
|
|
35
35
|
];
|
|
@@ -64,7 +64,7 @@ export default class ClipboardObserver extends DomEventObserver {
|
|
|
64
64
|
const nativeDataTransfer = 'clipboardData' in domEvent ? domEvent.clipboardData : domEvent.dataTransfer;
|
|
65
65
|
const cacheFiles = domEvent.type == 'drop' || domEvent.type == 'paste';
|
|
66
66
|
const evtData = {
|
|
67
|
-
dataTransfer: new
|
|
67
|
+
dataTransfer: new ViewDataTransfer(nativeDataTransfer, { cacheFiles })
|
|
68
68
|
};
|
|
69
69
|
if (domEvent.type == 'drop' || domEvent.type == 'dragover') {
|
|
70
70
|
const domRange = getRangeFromMouseEvent(domEvent);
|