@ckeditor/ckeditor5-clipboard 36.0.1 → 37.0.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/package.json +25 -24
- package/src/clipboard.d.ts +33 -0
- package/src/clipboard.js +1 -1
- package/src/clipboardobserver.d.ts +311 -0
- package/src/clipboardobserver.js +3 -1
- package/src/clipboardpipeline.d.ts +226 -0
- package/src/clipboardpipeline.js +1 -1
- package/src/dragdrop.d.ts +103 -0
- package/src/dragdrop.js +5 -3
- package/src/index.d.ts +13 -0
- package/src/pasteplaintext.d.ts +32 -0
- package/src/utils/normalizeclipboarddata.d.ts +15 -0
- package/src/utils/plaintexttohtml.d.ts +14 -0
- package/src/utils/viewtoplaintext.d.ts +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-clipboard",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.0.0-alpha.0",
|
|
4
4
|
"description": "Clipboard integration feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,30 +12,30 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@ckeditor/ckeditor5-core": "^
|
|
16
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
17
|
-
"@ckeditor/ckeditor5-utils": "^
|
|
18
|
-
"@ckeditor/ckeditor5-widget": "^
|
|
19
|
-
"lodash-es": "^4.17.
|
|
15
|
+
"@ckeditor/ckeditor5-core": "^37.0.0-alpha.0",
|
|
16
|
+
"@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
|
|
17
|
+
"@ckeditor/ckeditor5-utils": "^37.0.0-alpha.0",
|
|
18
|
+
"@ckeditor/ckeditor5-widget": "^37.0.0-alpha.0",
|
|
19
|
+
"lodash-es": "^4.17.15"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@ckeditor/ckeditor5-alignment": "^
|
|
23
|
-
"@ckeditor/ckeditor5-basic-styles": "^
|
|
24
|
-
"@ckeditor/ckeditor5-block-quote": "^
|
|
25
|
-
"@ckeditor/ckeditor5-cloud-services": "^
|
|
26
|
-
"@ckeditor/ckeditor5-code-block": "^
|
|
27
|
-
"@ckeditor/ckeditor5-easy-image": "^
|
|
28
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
29
|
-
"@ckeditor/ckeditor5-enter": "^
|
|
30
|
-
"@ckeditor/ckeditor5-horizontal-line": "^
|
|
31
|
-
"@ckeditor/ckeditor5-image": "^
|
|
32
|
-
"@ckeditor/ckeditor5-link": "^
|
|
33
|
-
"@ckeditor/ckeditor5-page-break": "^
|
|
34
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
35
|
-
"@ckeditor/ckeditor5-paste-from-office": "^
|
|
36
|
-
"@ckeditor/ckeditor5-remove-format": "^
|
|
37
|
-
"@ckeditor/ckeditor5-table": "^
|
|
38
|
-
"@ckeditor/ckeditor5-typing": "^
|
|
22
|
+
"@ckeditor/ckeditor5-alignment": "^37.0.0-alpha.0",
|
|
23
|
+
"@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.0",
|
|
24
|
+
"@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.0",
|
|
25
|
+
"@ckeditor/ckeditor5-cloud-services": "^37.0.0-alpha.0",
|
|
26
|
+
"@ckeditor/ckeditor5-code-block": "^37.0.0-alpha.0",
|
|
27
|
+
"@ckeditor/ckeditor5-easy-image": "^37.0.0-alpha.0",
|
|
28
|
+
"@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.0",
|
|
29
|
+
"@ckeditor/ckeditor5-enter": "^37.0.0-alpha.0",
|
|
30
|
+
"@ckeditor/ckeditor5-horizontal-line": "^37.0.0-alpha.0",
|
|
31
|
+
"@ckeditor/ckeditor5-image": "^37.0.0-alpha.0",
|
|
32
|
+
"@ckeditor/ckeditor5-link": "^37.0.0-alpha.0",
|
|
33
|
+
"@ckeditor/ckeditor5-page-break": "^37.0.0-alpha.0",
|
|
34
|
+
"@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.0",
|
|
35
|
+
"@ckeditor/ckeditor5-paste-from-office": "^37.0.0-alpha.0",
|
|
36
|
+
"@ckeditor/ckeditor5-remove-format": "^37.0.0-alpha.0",
|
|
37
|
+
"@ckeditor/ckeditor5-table": "^37.0.0-alpha.0",
|
|
38
|
+
"@ckeditor/ckeditor5-typing": "^37.0.0-alpha.0",
|
|
39
39
|
"typescript": "^4.8.4",
|
|
40
40
|
"webpack": "^5.58.1",
|
|
41
41
|
"webpack-cli": "^4.9.0"
|
|
@@ -64,5 +64,6 @@
|
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "tsc -p ./tsconfig.release.json",
|
|
66
66
|
"postversion": "npm run build"
|
|
67
|
-
}
|
|
67
|
+
},
|
|
68
|
+
"types": "src/index.d.ts"
|
|
68
69
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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/clipboard
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from '@ckeditor/ckeditor5-core';
|
|
9
|
+
/**
|
|
10
|
+
* The clipboard feature.
|
|
11
|
+
*
|
|
12
|
+
* Read more about the clipboard integration in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
13
|
+
*
|
|
14
|
+
* This is a "glue" plugin which loads the following plugins:
|
|
15
|
+
* * {@link module:clipboard/clipboardpipeline~ClipboardPipeline}
|
|
16
|
+
* * {@link module:clipboard/dragdrop~DragDrop}
|
|
17
|
+
* * {@link module:clipboard/pasteplaintext~PastePlainText}
|
|
18
|
+
*/
|
|
19
|
+
export default class Clipboard extends Plugin {
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get pluginName(): 'Clipboard';
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get requires(): PluginDependencies;
|
|
28
|
+
}
|
|
29
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
30
|
+
interface PluginsMap {
|
|
31
|
+
[Clipboard.pluginName]: Clipboard;
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/clipboard.js
CHANGED
|
@@ -12,7 +12,7 @@ import PastePlainText from './pasteplaintext';
|
|
|
12
12
|
/**
|
|
13
13
|
* The clipboard feature.
|
|
14
14
|
*
|
|
15
|
-
* Read more about the clipboard integration in the {@glink framework/
|
|
15
|
+
* Read more about the clipboard integration in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
16
16
|
*
|
|
17
17
|
* This is a "glue" plugin which loads the following plugins:
|
|
18
18
|
* * {@link module:clipboard/clipboardpipeline~ClipboardPipeline}
|
|
@@ -0,0 +1,311 @@
|
|
|
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
|
+
import { DataTransfer, DomEventObserver, type DomEventData, type View, type ViewDocumentFragment, type ViewElement, type ViewRange } from '@ckeditor/ckeditor5-engine';
|
|
6
|
+
/**
|
|
7
|
+
* Clipboard events observer.
|
|
8
|
+
*
|
|
9
|
+
* Fires the following events:
|
|
10
|
+
*
|
|
11
|
+
* * {@link module:engine/view/document~Document#event:clipboardInput},
|
|
12
|
+
* * {@link module:engine/view/document~Document#event:paste},
|
|
13
|
+
* * {@link module:engine/view/document~Document#event:copy},
|
|
14
|
+
* * {@link module:engine/view/document~Document#event:cut},
|
|
15
|
+
* * {@link module:engine/view/document~Document#event:drop},
|
|
16
|
+
* * {@link module:engine/view/document~Document#event:dragover},
|
|
17
|
+
* * {@link module:engine/view/document~Document#event:dragging},
|
|
18
|
+
* * {@link module:engine/view/document~Document#event:dragstart},
|
|
19
|
+
* * {@link module:engine/view/document~Document#event:dragend},
|
|
20
|
+
* * {@link module:engine/view/document~Document#event:dragenter},
|
|
21
|
+
* * {@link module:engine/view/document~Document#event:dragleave}.
|
|
22
|
+
*
|
|
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~Document} by using
|
|
25
|
+
* the {@link module:engine/view/view~View#addObserver `View#addObserver()`} method. Alternatively, you can load the
|
|
26
|
+
* {@link module:clipboard/clipboard~Clipboard} plugin which adds this observer automatically (because it uses it).
|
|
27
|
+
*/
|
|
28
|
+
export default class ClipboardObserver extends DomEventObserver<'paste' | 'copy' | 'cut' | 'drop' | 'dragover' | 'dragstart' | 'dragend' | 'dragenter' | 'dragleave', ClipboardEventData> {
|
|
29
|
+
readonly domEventType: readonly ["paste", "copy", "cut", "drop", "dragover", "dragstart", "dragend", "dragenter", "dragleave"];
|
|
30
|
+
constructor(view: View);
|
|
31
|
+
onDomEvent(domEvent: ClipboardEvent | DragEvent): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The data of 'paste', 'copy', 'cut', 'drop', 'dragover', 'dragstart', 'dragend', 'dragenter' and 'dragleave' events.
|
|
35
|
+
*/
|
|
36
|
+
export interface ClipboardEventData {
|
|
37
|
+
/**
|
|
38
|
+
* The data transfer instance.
|
|
39
|
+
*/
|
|
40
|
+
dataTransfer: DataTransfer;
|
|
41
|
+
/**
|
|
42
|
+
* The position into which the content is dropped.
|
|
43
|
+
*/
|
|
44
|
+
dropRange?: ViewRange | null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Fired as a continuation of the {@link #event:paste} and {@link #event:drop} events.
|
|
48
|
+
*
|
|
49
|
+
* It is a part of the {@glink framework/deep-dive/clipboard#input-pipeline clipboard input pipeline}.
|
|
50
|
+
*
|
|
51
|
+
* This event carries a `dataTransfer` object which comes from the clipboard and whose content should be processed
|
|
52
|
+
* and inserted into the editor.
|
|
53
|
+
*
|
|
54
|
+
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
55
|
+
* needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
56
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
57
|
+
* the observer must be added manually.
|
|
58
|
+
*
|
|
59
|
+
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
60
|
+
* @see module:clipboard/clipboard~Clipboard
|
|
61
|
+
*
|
|
62
|
+
* @eventName clipboardInput
|
|
63
|
+
* @param data The event data.
|
|
64
|
+
*/
|
|
65
|
+
export type ViewDocumentClipboardInputEvent = {
|
|
66
|
+
name: 'clipboardInput';
|
|
67
|
+
args: [data: DomEventData<ClipboardEvent | DragEvent> & ClipboardInputEventData];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The value of the {@link module:engine/view/document~Document#event:paste},
|
|
71
|
+
* {@link module:engine/view/document~Document#event:copy} and {@link module:engine/view/document~Document#event:cut} events.
|
|
72
|
+
*
|
|
73
|
+
* In order to access the clipboard data, use the `dataTransfer` property.
|
|
74
|
+
*/
|
|
75
|
+
export interface ClipboardInputEventData {
|
|
76
|
+
/**
|
|
77
|
+
* Data transfer instance.
|
|
78
|
+
*/
|
|
79
|
+
dataTransfer: DataTransfer;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the event was triggered by a paste or a drop operation.
|
|
82
|
+
*/
|
|
83
|
+
method: 'paste' | 'drop';
|
|
84
|
+
/**
|
|
85
|
+
* The tree view element representing the target.
|
|
86
|
+
*/
|
|
87
|
+
target: ViewElement;
|
|
88
|
+
/**
|
|
89
|
+
* The ranges which are the target of the operation (usually – into which the content should be inserted).
|
|
90
|
+
* If the clipboard input was triggered by a paste operation, this property is not set. If by a drop operation,
|
|
91
|
+
* then it is the drop position (which can be different than the selection at the moment of the drop).
|
|
92
|
+
*/
|
|
93
|
+
targetRanges: Array<ViewRange> | null;
|
|
94
|
+
/**
|
|
95
|
+
* The content of clipboard input.
|
|
96
|
+
*/
|
|
97
|
+
content?: ViewDocumentFragment;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Fired when the user drags the content over one of the editing roots of the editor.
|
|
101
|
+
*
|
|
102
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
103
|
+
*
|
|
104
|
+
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
105
|
+
* needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
106
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
107
|
+
* the observer must be added manually.
|
|
108
|
+
*
|
|
109
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
110
|
+
*
|
|
111
|
+
* @eventName dragover
|
|
112
|
+
* @param data The event data.
|
|
113
|
+
*/
|
|
114
|
+
export type ViewDocumentDragOverEvent = {
|
|
115
|
+
name: 'dragover';
|
|
116
|
+
args: [data: DomEventData<DragEvent> & ClipboardEventData];
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Fired when the user dropped the content into one of the editing roots of the editor.
|
|
120
|
+
*
|
|
121
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
122
|
+
*
|
|
123
|
+
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
124
|
+
* needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
125
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
126
|
+
* the observer must be added manually.
|
|
127
|
+
*
|
|
128
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
129
|
+
*
|
|
130
|
+
* @eventName drop
|
|
131
|
+
* @param data The event data.
|
|
132
|
+
*/
|
|
133
|
+
export type ViewDocumentDropEvent = {
|
|
134
|
+
name: 'drop';
|
|
135
|
+
args: [data: DomEventData<DragEvent> & ClipboardEventData];
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Fired when the user pasted the content into one of the editing roots of the editor.
|
|
139
|
+
*
|
|
140
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
141
|
+
*
|
|
142
|
+
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
143
|
+
* needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
144
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
145
|
+
* the observer must be added manually.
|
|
146
|
+
*
|
|
147
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
148
|
+
*
|
|
149
|
+
* @eventName paste
|
|
150
|
+
* @param {module:clipboard/clipboardobserver~ClipboardEventData} data The event data.
|
|
151
|
+
*/
|
|
152
|
+
export type ViewDocumentPasteEvent = {
|
|
153
|
+
name: 'paste';
|
|
154
|
+
args: [data: DomEventData<ClipboardEvent> & ClipboardEventData];
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Fired when the user copied the content from one of the editing roots of the editor.
|
|
158
|
+
*
|
|
159
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
160
|
+
*
|
|
161
|
+
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
162
|
+
* needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
163
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
164
|
+
* the observer must be added manually.
|
|
165
|
+
*
|
|
166
|
+
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
167
|
+
*
|
|
168
|
+
* @eventName copy
|
|
169
|
+
* @param data The event data.
|
|
170
|
+
*/
|
|
171
|
+
export type ViewDocumentCopyEvent = {
|
|
172
|
+
name: 'copy';
|
|
173
|
+
args: [data: DomEventData<ClipboardEvent> & ClipboardEventData];
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Fired when the user cut the content from one of the editing roots of the editor.
|
|
177
|
+
*
|
|
178
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
179
|
+
*
|
|
180
|
+
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
181
|
+
* needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
182
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
183
|
+
* the observer must be added manually.
|
|
184
|
+
*
|
|
185
|
+
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
186
|
+
*
|
|
187
|
+
* @eventName cut
|
|
188
|
+
* @param data The event data.
|
|
189
|
+
*/
|
|
190
|
+
export type ViewDocumentCutEvent = {
|
|
191
|
+
name: 'cut';
|
|
192
|
+
args: [data: DomEventData<ClipboardEvent> & ClipboardEventData];
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Fired as a continuation of the {@link #event:dragover} event.
|
|
196
|
+
*
|
|
197
|
+
* It is a part of the {@glink framework/deep-dive/clipboard#input-pipeline clipboard input pipeline}.
|
|
198
|
+
*
|
|
199
|
+
* This event carries a `dataTransfer` object which comes from the clipboard and whose content should be processed
|
|
200
|
+
* and inserted into the editor.
|
|
201
|
+
*
|
|
202
|
+
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
203
|
+
* needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
204
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
205
|
+
* the observer must be added manually.
|
|
206
|
+
*
|
|
207
|
+
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
208
|
+
* @see module:clipboard/clipboard~Clipboard
|
|
209
|
+
*
|
|
210
|
+
* @eventName dragging
|
|
211
|
+
* @param data The event data.
|
|
212
|
+
*/
|
|
213
|
+
export type ViewDocumentDraggingEvent = {
|
|
214
|
+
name: 'dragging';
|
|
215
|
+
args: [data: DomEventData<DragEvent> & DraggingEventData];
|
|
216
|
+
};
|
|
217
|
+
export interface DraggingEventData {
|
|
218
|
+
/**
|
|
219
|
+
* The data transfer instance.
|
|
220
|
+
*/
|
|
221
|
+
dataTransfer: DataTransfer;
|
|
222
|
+
/**
|
|
223
|
+
* Whether the event was triggered by a paste or a drop operation.
|
|
224
|
+
*/
|
|
225
|
+
method: 'dragover';
|
|
226
|
+
/**
|
|
227
|
+
* The tree view element representing the target.
|
|
228
|
+
*/
|
|
229
|
+
target: Element;
|
|
230
|
+
/**
|
|
231
|
+
* Ranges which are the target of the operation (usually – into which the content should be inserted).
|
|
232
|
+
* It is the drop position (which can be different than the selection at the moment of drop).
|
|
233
|
+
*/
|
|
234
|
+
targetRanges: Array<ViewRange> | null;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Fired when the user starts dragging the content in one of the editing roots of the editor.
|
|
238
|
+
*
|
|
239
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
240
|
+
*
|
|
241
|
+
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
242
|
+
* needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
243
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
244
|
+
* the observer must be added manually.
|
|
245
|
+
*
|
|
246
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
247
|
+
*
|
|
248
|
+
* @eventName dragstart
|
|
249
|
+
* @param data The event data.
|
|
250
|
+
*/
|
|
251
|
+
export type ViewDocumentDragStartEvent = {
|
|
252
|
+
name: 'dragstart';
|
|
253
|
+
args: [data: DomEventData<DragEvent> & ClipboardEventData];
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Fired when the user ended dragging the content.
|
|
257
|
+
*
|
|
258
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
259
|
+
*
|
|
260
|
+
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
261
|
+
* needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
262
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
263
|
+
* the observer must be added manually.
|
|
264
|
+
*
|
|
265
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
266
|
+
*
|
|
267
|
+
* @eventName dragend
|
|
268
|
+
* @param data The event data.
|
|
269
|
+
*/
|
|
270
|
+
export type ViewDocumentDragEndEvent = {
|
|
271
|
+
name: 'dragend';
|
|
272
|
+
args: [data: DomEventData<DragEvent> & ClipboardEventData];
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Fired when the user drags the content into one of the editing roots of the editor.
|
|
276
|
+
*
|
|
277
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
278
|
+
*
|
|
279
|
+
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
280
|
+
* needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
281
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
282
|
+
* the observer must be added manually.
|
|
283
|
+
*
|
|
284
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
285
|
+
*
|
|
286
|
+
* @eventName dragenter
|
|
287
|
+
* @param data The event data.
|
|
288
|
+
*/
|
|
289
|
+
export type ViewDocumentDragEnterEvent = {
|
|
290
|
+
name: 'dragenter';
|
|
291
|
+
args: [data: DomEventData<DragEvent> & ClipboardEventData];
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Fired when the user drags the content out of one of the editing roots of the editor.
|
|
295
|
+
*
|
|
296
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
297
|
+
*
|
|
298
|
+
* **Note**: This event is not available by default. To make it available, {@link module:clipboard/clipboardobserver~ClipboardObserver}
|
|
299
|
+
* needs to be added to the {@link module:engine/view/document~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
300
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
301
|
+
* the observer must be added manually.
|
|
302
|
+
*
|
|
303
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
304
|
+
*
|
|
305
|
+
* @eventName dragleave
|
|
306
|
+
* @param data The event data.
|
|
307
|
+
*/
|
|
308
|
+
export type ViewDocumentDragLeaveEvent = {
|
|
309
|
+
name: 'dragleave';
|
|
310
|
+
args: [data: DomEventData<DragEvent> & ClipboardEventData];
|
|
311
|
+
};
|
package/src/clipboardobserver.js
CHANGED
|
@@ -32,8 +32,10 @@ import { DataTransfer, DomEventObserver } from '@ckeditor/ckeditor5-engine';
|
|
|
32
32
|
export default class ClipboardObserver extends DomEventObserver {
|
|
33
33
|
constructor(view) {
|
|
34
34
|
super(view);
|
|
35
|
+
this.domEventType = [
|
|
36
|
+
'paste', 'copy', 'cut', 'drop', 'dragover', 'dragstart', 'dragend', 'dragenter', 'dragleave'
|
|
37
|
+
];
|
|
35
38
|
const viewDocument = this.document;
|
|
36
|
-
this.domEventType = ['paste', 'copy', 'cut', 'drop', 'dragover', 'dragstart', 'dragend', 'dragenter', 'dragleave'];
|
|
37
39
|
this.listenTo(viewDocument, 'paste', handleInput('clipboardInput'), { priority: 'low' });
|
|
38
40
|
this.listenTo(viewDocument, 'drop', handleInput('clipboardInput'), { priority: 'low' });
|
|
39
41
|
this.listenTo(viewDocument, 'dragover', handleInput('dragging'), { priority: 'low' });
|
|
@@ -0,0 +1,226 @@
|
|
|
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/clipboardpipeline
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
+
import type { DataTransfer, DocumentFragment, Range, ViewDocumentFragment, ViewRange } from '@ckeditor/ckeditor5-engine';
|
|
10
|
+
/**
|
|
11
|
+
* The clipboard pipeline feature. It is responsible for intercepting the `paste` and `drop` events and
|
|
12
|
+
* passing the pasted content through a series of events in order to insert it into the editor's content.
|
|
13
|
+
* It also handles the `cut` and `copy` events to fill the native clipboard with the serialized editor's data.
|
|
14
|
+
*
|
|
15
|
+
* # Input pipeline
|
|
16
|
+
*
|
|
17
|
+
* The behavior of the default handlers (all at a `low` priority):
|
|
18
|
+
*
|
|
19
|
+
* ## Event: `paste` or `drop`
|
|
20
|
+
*
|
|
21
|
+
* 1. Translates the event data.
|
|
22
|
+
* 2. Fires the {@link module:engine/view/document~Document#event:clipboardInput `view.Document#clipboardInput`} event.
|
|
23
|
+
*
|
|
24
|
+
* ## Event: `view.Document#clipboardInput`
|
|
25
|
+
*
|
|
26
|
+
* 1. If the `data.content` event field is already set (by some listener on a higher priority), it takes this content and fires the event
|
|
27
|
+
* from the last point.
|
|
28
|
+
* 2. Otherwise, it retrieves `text/html` or `text/plain` from `data.dataTransfer`.
|
|
29
|
+
* 3. Normalizes the raw data by applying simple filters on string data.
|
|
30
|
+
* 4. Processes the raw data to {@link module:engine/view/documentfragment~DocumentFragment `view.DocumentFragment`} with the
|
|
31
|
+
* {@link module:engine/controller/datacontroller~DataController#htmlProcessor `DataController#htmlProcessor`}.
|
|
32
|
+
* 5. Fires the {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation
|
|
33
|
+
* `ClipboardPipeline#inputTransformation`} event with the view document fragment in the `data.content` event field.
|
|
34
|
+
*
|
|
35
|
+
* ## Event: `ClipboardPipeline#inputTransformation`
|
|
36
|
+
*
|
|
37
|
+
* 1. Converts {@link module:engine/view/documentfragment~DocumentFragment `view.DocumentFragment`} from the `data.content` field to
|
|
38
|
+
* {@link module:engine/model/documentfragment~DocumentFragment `model.DocumentFragment`}.
|
|
39
|
+
* 2. Fires the {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:contentInsertion `ClipboardPipeline#contentInsertion`}
|
|
40
|
+
* event with the model document fragment in the `data.content` event field.
|
|
41
|
+
* **Note**: The `ClipboardPipeline#contentInsertion` event is fired within a model change block to allow other handlers
|
|
42
|
+
* to run in the same block without post-fixers called in between (i.e., the selection post-fixer).
|
|
43
|
+
*
|
|
44
|
+
* ## Event: `ClipboardPipeline#contentInsertion`
|
|
45
|
+
*
|
|
46
|
+
* 1. Calls {@link module:engine/model/model~Model#insertContent `model.insertContent()`} to insert `data.content`
|
|
47
|
+
* at the current selection position.
|
|
48
|
+
*
|
|
49
|
+
* # Output pipeline
|
|
50
|
+
*
|
|
51
|
+
* The behavior of the default handlers (all at a `low` priority):
|
|
52
|
+
*
|
|
53
|
+
* ## Event: `copy`, `cut` or `dragstart`
|
|
54
|
+
*
|
|
55
|
+
* 1. Retrieves the selected {@link module:engine/model/documentfragment~DocumentFragment `model.DocumentFragment`} by calling
|
|
56
|
+
* {@link module:engine/model/model~Model#getSelectedContent `model#getSelectedContent()`}.
|
|
57
|
+
* 2. Converts the model document fragment to {@link module:engine/view/documentfragment~DocumentFragment `view.DocumentFragment`}.
|
|
58
|
+
* 3. Fires the {@link module:engine/view/document~Document#event:clipboardOutput `view.Document#clipboardOutput`} event
|
|
59
|
+
* with the view document fragment in the `data.content` event field.
|
|
60
|
+
*
|
|
61
|
+
* ## Event: `view.Document#clipboardOutput`
|
|
62
|
+
*
|
|
63
|
+
* 1. Processes `data.content` to HTML and plain text with the
|
|
64
|
+
* {@link module:engine/controller/datacontroller~DataController#htmlProcessor `DataController#htmlProcessor`}.
|
|
65
|
+
* 2. Updates the `data.dataTransfer` data for `text/html` and `text/plain` with the processed data.
|
|
66
|
+
* 3. For the `cut` method, calls {@link module:engine/model/model~Model#deleteContent `model.deleteContent()`}
|
|
67
|
+
* on the current selection.
|
|
68
|
+
*
|
|
69
|
+
* Read more about the clipboard integration in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
70
|
+
*/
|
|
71
|
+
export default class ClipboardPipeline extends Plugin {
|
|
72
|
+
/**
|
|
73
|
+
* @inheritDoc
|
|
74
|
+
*/
|
|
75
|
+
static get pluginName(): 'ClipboardPipeline';
|
|
76
|
+
/**
|
|
77
|
+
* @inheritDoc
|
|
78
|
+
*/
|
|
79
|
+
init(): void;
|
|
80
|
+
/**
|
|
81
|
+
* The clipboard paste pipeline.
|
|
82
|
+
*/
|
|
83
|
+
private _setupPasteDrop;
|
|
84
|
+
/**
|
|
85
|
+
* The clipboard copy/cut pipeline.
|
|
86
|
+
*/
|
|
87
|
+
private _setupCopyCut;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Fired with the `content`, `dataTransfer`, `method`, and `targetRanges` properties:
|
|
91
|
+
*
|
|
92
|
+
* * The `content` which comes from the clipboard (it was pasted or dropped) should be processed in order to be inserted into the editor.
|
|
93
|
+
* * The `dataTransfer` object is available in case the transformation functions need access to the raw clipboard data.
|
|
94
|
+
* * The `method` indicates the original DOM event (for example `'drop'` or `'paste'`).
|
|
95
|
+
* * The `targetRanges` property is an array of view ranges (it is available only for `'drop'`).
|
|
96
|
+
*
|
|
97
|
+
* It is a part of the {@glink framework/deep-dive/clipboard#input-pipeline clipboard input pipeline}.
|
|
98
|
+
*
|
|
99
|
+
* **Note**: You should not stop this event if you want to change the input data. You should modify the `content` property instead.
|
|
100
|
+
*
|
|
101
|
+
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
102
|
+
* @see module:clipboard/clipboardpipeline~ClipboardPipeline
|
|
103
|
+
*
|
|
104
|
+
* @eventName inputTransformation
|
|
105
|
+
* @param data The event data.
|
|
106
|
+
*/
|
|
107
|
+
export type ClipboardInputTransformationEvent = {
|
|
108
|
+
name: 'inputTransformation';
|
|
109
|
+
args: [data: ClipboardInputTransformationData];
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* The data of 'inputTransformation' event.
|
|
113
|
+
*/
|
|
114
|
+
export interface ClipboardInputTransformationData {
|
|
115
|
+
/**
|
|
116
|
+
* The event data.
|
|
117
|
+
* The content to be inserted into the editor. It can be modified by event listeners. Read more about the clipboard pipelines in
|
|
118
|
+
* the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
119
|
+
*/
|
|
120
|
+
content: ViewDocumentFragment;
|
|
121
|
+
/**
|
|
122
|
+
* The data transfer instance.
|
|
123
|
+
*/
|
|
124
|
+
dataTransfer: DataTransfer;
|
|
125
|
+
/**
|
|
126
|
+
* The target drop ranges.
|
|
127
|
+
*/
|
|
128
|
+
targetRanges: Array<ViewRange> | null;
|
|
129
|
+
/**
|
|
130
|
+
* Whether the event was triggered by a paste or a drop operation.
|
|
131
|
+
*/
|
|
132
|
+
method: 'paste' | 'drop';
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Fired with the `content`, `dataTransfer`, `method`, and `targetRanges` properties:
|
|
136
|
+
*
|
|
137
|
+
* * The `content` which comes from the clipboard (was pasted or dropped) should be processed in order to be inserted into the editor.
|
|
138
|
+
* * The `dataTransfer` object is available in case the transformation functions need access to the raw clipboard data.
|
|
139
|
+
* * The `method` indicates the original DOM event (for example `'drop'` or `'paste'`).
|
|
140
|
+
* * The `targetRanges` property is an array of view ranges (it is available only for `'drop'`).
|
|
141
|
+
*
|
|
142
|
+
* Event handlers can modify the content according to the final insertion position.
|
|
143
|
+
*
|
|
144
|
+
* It is a part of the {@glink framework/deep-dive/clipboard#input-pipeline clipboard input pipeline}.
|
|
145
|
+
*
|
|
146
|
+
* **Note**: You should not stop this event if you want to change the input data. You should modify the `content` property instead.
|
|
147
|
+
*
|
|
148
|
+
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
149
|
+
* @see module:clipboard/clipboardpipeline~ClipboardPipeline
|
|
150
|
+
* @see module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation
|
|
151
|
+
*
|
|
152
|
+
* @eventName contentInsertion
|
|
153
|
+
* @param data The event data.
|
|
154
|
+
*/
|
|
155
|
+
export type ClipboardContentInsertionEvent = {
|
|
156
|
+
name: 'contentInsertion';
|
|
157
|
+
args: [data: ClipboardContentInsertionData];
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* The data of 'contentInsertion' event.
|
|
161
|
+
*/
|
|
162
|
+
export interface ClipboardContentInsertionData {
|
|
163
|
+
/**
|
|
164
|
+
* The content to be inserted into the editor.
|
|
165
|
+
* Read more about the clipboard pipelines in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
166
|
+
*/
|
|
167
|
+
content: DocumentFragment;
|
|
168
|
+
/**
|
|
169
|
+
* Whether the event was triggered by a paste or a drop operation.
|
|
170
|
+
*/
|
|
171
|
+
method: 'paste' | 'drop';
|
|
172
|
+
/**
|
|
173
|
+
* The data transfer instance.
|
|
174
|
+
*/
|
|
175
|
+
dataTransfer: DataTransfer;
|
|
176
|
+
/**
|
|
177
|
+
* The target drop ranges.
|
|
178
|
+
*/
|
|
179
|
+
targetRanges: Array<ViewRange> | null;
|
|
180
|
+
/**
|
|
181
|
+
* The result of the `model.insertContent()` call
|
|
182
|
+
* (inserted by the event handler at a low priority).
|
|
183
|
+
*/
|
|
184
|
+
resultRange?: Range;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Fired on {@link module:engine/view/document~Document#event:copy} and {@link module:engine/view/document~Document#event:cut}
|
|
188
|
+
* with a copy of the selected content. The content can be processed before it ends up in the clipboard.
|
|
189
|
+
*
|
|
190
|
+
* It is a part of the {@glink framework/deep-dive/clipboard#output-pipeline clipboard output pipeline}.
|
|
191
|
+
*
|
|
192
|
+
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
193
|
+
* @see module:clipboard/clipboardpipeline~ClipboardPipeline
|
|
194
|
+
*
|
|
195
|
+
* @eventName clipboardOutput
|
|
196
|
+
* @param data The event data.
|
|
197
|
+
*/
|
|
198
|
+
export type ClipboardOutputEvent = {
|
|
199
|
+
name: 'clipboardOutput';
|
|
200
|
+
args: [data: ClipboardOutputEventData];
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* The value of the 'clipboardOutput' event.
|
|
204
|
+
*/
|
|
205
|
+
export interface ClipboardOutputEventData {
|
|
206
|
+
/**
|
|
207
|
+
* The data transfer instance.
|
|
208
|
+
*
|
|
209
|
+
* @readonly
|
|
210
|
+
*/
|
|
211
|
+
dataTransfer: DataTransfer;
|
|
212
|
+
/**
|
|
213
|
+
* Content to be put into the clipboard. It can be modified by the event listeners.
|
|
214
|
+
* Read more about the clipboard pipelines in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
215
|
+
*/
|
|
216
|
+
content: ViewDocumentFragment;
|
|
217
|
+
/**
|
|
218
|
+
* Whether the event was triggered by a copy or cut operation.
|
|
219
|
+
*/
|
|
220
|
+
method: 'copy' | 'cut' | 'dragstart';
|
|
221
|
+
}
|
|
222
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
223
|
+
interface PluginsMap {
|
|
224
|
+
[ClipboardPipeline.pluginName]: ClipboardPipeline;
|
|
225
|
+
}
|
|
226
|
+
}
|
package/src/clipboardpipeline.js
CHANGED
|
@@ -109,7 +109,7 @@ import viewToPlainText from './utils/viewtoplaintext';
|
|
|
109
109
|
* 3. For the `cut` method, calls {@link module:engine/model/model~Model#deleteContent `model.deleteContent()`}
|
|
110
110
|
* on the current selection.
|
|
111
111
|
*
|
|
112
|
-
* Read more about the clipboard integration in the {@glink framework/
|
|
112
|
+
* Read more about the clipboard integration in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
113
113
|
*/
|
|
114
114
|
export default class ClipboardPipeline extends Plugin {
|
|
115
115
|
/**
|
|
@@ -0,0 +1,103 @@
|
|
|
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/dragdrop
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from '@ckeditor/ckeditor5-core';
|
|
9
|
+
import '../theme/clipboard.css';
|
|
10
|
+
/**
|
|
11
|
+
* The drag and drop feature. It works on top of the {@link module:clipboard/clipboardpipeline~ClipboardPipeline}.
|
|
12
|
+
*
|
|
13
|
+
* Read more about the clipboard integration in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
14
|
+
*/
|
|
15
|
+
export default class DragDrop extends Plugin {
|
|
16
|
+
/**
|
|
17
|
+
* The live range over the original content that is being dragged.
|
|
18
|
+
*/
|
|
19
|
+
private _draggedRange;
|
|
20
|
+
/**
|
|
21
|
+
* The UID of current dragging that is used to verify if the drop started in the same editor as the drag start.
|
|
22
|
+
*
|
|
23
|
+
* **Note**: This is a workaround for broken 'dragend' events (they are not fired if the source text node got removed).
|
|
24
|
+
*/
|
|
25
|
+
private _draggingUid;
|
|
26
|
+
/**
|
|
27
|
+
* The reference to the model element that currently has a `draggable` attribute set (it is set while dragging).
|
|
28
|
+
*/
|
|
29
|
+
private _draggableElement;
|
|
30
|
+
/**
|
|
31
|
+
* A throttled callback updating the drop marker.
|
|
32
|
+
*/
|
|
33
|
+
private _updateDropMarkerThrottled;
|
|
34
|
+
/**
|
|
35
|
+
* A delayed callback removing the drop marker.
|
|
36
|
+
*/
|
|
37
|
+
private _removeDropMarkerDelayed;
|
|
38
|
+
/**
|
|
39
|
+
* A delayed callback removing draggable attributes.
|
|
40
|
+
*/
|
|
41
|
+
private _clearDraggableAttributesDelayed;
|
|
42
|
+
/**
|
|
43
|
+
* @inheritDoc
|
|
44
|
+
*/
|
|
45
|
+
static get pluginName(): 'DragDrop';
|
|
46
|
+
/**
|
|
47
|
+
* @inheritDoc
|
|
48
|
+
*/
|
|
49
|
+
static get requires(): PluginDependencies;
|
|
50
|
+
/**
|
|
51
|
+
* @inheritDoc
|
|
52
|
+
*/
|
|
53
|
+
init(): void;
|
|
54
|
+
/**
|
|
55
|
+
* @inheritDoc
|
|
56
|
+
*/
|
|
57
|
+
destroy(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Drag and drop events handling.
|
|
60
|
+
*/
|
|
61
|
+
private _setupDragging;
|
|
62
|
+
/**
|
|
63
|
+
* Integration with the `clipboardInput` event.
|
|
64
|
+
*/
|
|
65
|
+
private _setupClipboardInputIntegration;
|
|
66
|
+
/**
|
|
67
|
+
* Integration with the `contentInsertion` event of the clipboard pipeline.
|
|
68
|
+
*/
|
|
69
|
+
private _setupContentInsertionIntegration;
|
|
70
|
+
/**
|
|
71
|
+
* Adds listeners that add the `draggable` attribute to the elements while the mouse button is down so the dragging could start.
|
|
72
|
+
*/
|
|
73
|
+
private _setupDraggableAttributeHandling;
|
|
74
|
+
/**
|
|
75
|
+
* Removes the `draggable` attribute from the element that was used for dragging.
|
|
76
|
+
*/
|
|
77
|
+
private _clearDraggableAttributes;
|
|
78
|
+
/**
|
|
79
|
+
* Creates downcast conversion for the drop target marker.
|
|
80
|
+
*/
|
|
81
|
+
private _setupDropMarker;
|
|
82
|
+
/**
|
|
83
|
+
* Updates the drop target marker to the provided range.
|
|
84
|
+
*
|
|
85
|
+
* @param targetRange The range to set the marker to.
|
|
86
|
+
*/
|
|
87
|
+
private _updateDropMarker;
|
|
88
|
+
/**
|
|
89
|
+
* Removes the drop target marker.
|
|
90
|
+
*/
|
|
91
|
+
private _removeDropMarker;
|
|
92
|
+
/**
|
|
93
|
+
* Deletes the dragged content from its original range and clears the dragging state.
|
|
94
|
+
*
|
|
95
|
+
* @param moved Whether the move succeeded.
|
|
96
|
+
*/
|
|
97
|
+
private _finalizeDragging;
|
|
98
|
+
}
|
|
99
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
100
|
+
interface PluginsMap {
|
|
101
|
+
[DragDrop.pluginName]: DragDrop;
|
|
102
|
+
}
|
|
103
|
+
}
|
package/src/dragdrop.js
CHANGED
|
@@ -94,7 +94,7 @@ import '../theme/clipboard.css';
|
|
|
94
94
|
/**
|
|
95
95
|
* The drag and drop feature. It works on top of the {@link module:clipboard/clipboardpipeline~ClipboardPipeline}.
|
|
96
96
|
*
|
|
97
|
-
* Read more about the clipboard integration in the {@glink framework/
|
|
97
|
+
* Read more about the clipboard integration in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
98
98
|
*/
|
|
99
99
|
export default class DragDrop extends Plugin {
|
|
100
100
|
/**
|
|
@@ -185,7 +185,8 @@ export default class DragDrop extends Plugin {
|
|
|
185
185
|
this._draggedRange = LiveRange.fromRange(model.createRangeOn(modelElement));
|
|
186
186
|
// Disable toolbars so they won't obscure the drop area.
|
|
187
187
|
if (editor.plugins.has('WidgetToolbarRepository')) {
|
|
188
|
-
editor.plugins.get('WidgetToolbarRepository')
|
|
188
|
+
const widgetToolbarRepository = editor.plugins.get('WidgetToolbarRepository');
|
|
189
|
+
widgetToolbarRepository.forceDisabled('dragDrop');
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
// If this was not a widget we should check if we need to drag some text content.
|
|
@@ -464,7 +465,8 @@ export default class DragDrop extends Plugin {
|
|
|
464
465
|
this._removeDropMarker();
|
|
465
466
|
this._clearDraggableAttributes();
|
|
466
467
|
if (editor.plugins.has('WidgetToolbarRepository')) {
|
|
467
|
-
editor.plugins.get('WidgetToolbarRepository')
|
|
468
|
+
const widgetToolbarRepository = editor.plugins.get('WidgetToolbarRepository');
|
|
469
|
+
widgetToolbarRepository.clearForceDisabled('dragDrop');
|
|
468
470
|
}
|
|
469
471
|
this._draggingUid = '';
|
|
470
472
|
if (!this._draggedRange) {
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
7
|
+
*/
|
|
8
|
+
export { default as Clipboard } from './clipboard';
|
|
9
|
+
export { default as ClipboardPipeline, type ClipboardContentInsertionEvent, type ClipboardInputTransformationEvent, type ClipboardInputTransformationData, type ClipboardOutputEvent } from './clipboardpipeline';
|
|
10
|
+
export type { ClipboardEventData } from './clipboardobserver';
|
|
11
|
+
export { default as DragDrop } from './dragdrop';
|
|
12
|
+
export { default as PastePlainText } from './pasteplaintext';
|
|
13
|
+
export type { ViewDocumentClipboardInputEvent, ViewDocumentCopyEvent, ViewDocumentCutEvent } from './clipboardobserver';
|
|
@@ -0,0 +1,32 @@
|
|
|
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/pasteplaintext
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from '@ckeditor/ckeditor5-core';
|
|
9
|
+
/**
|
|
10
|
+
* The plugin detects the user's intention to paste plain text.
|
|
11
|
+
*
|
|
12
|
+
* For example, it detects the <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>V</kbd> keystroke.
|
|
13
|
+
*/
|
|
14
|
+
export default class PastePlainText extends Plugin {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get pluginName(): 'PastePlainText';
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get requires(): PluginDependencies;
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
init(): void;
|
|
27
|
+
}
|
|
28
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
29
|
+
interface PluginsMap {
|
|
30
|
+
[PastePlainText.pluginName]: PastePlainText;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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/utils/normalizeclipboarddata
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Removes some popular browser quirks out of the clipboard data (HTML).
|
|
10
|
+
* Removes all HTML comments. These are considered an internal thing and it makes little sense if they leak into the editor data.
|
|
11
|
+
*
|
|
12
|
+
* @param data The HTML data to normalize.
|
|
13
|
+
* @returns Normalized HTML.
|
|
14
|
+
*/
|
|
15
|
+
export default function normalizeClipboardData(data: string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
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/utils/plaintexttohtml
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Converts plain text to its HTML-ized version.
|
|
10
|
+
*
|
|
11
|
+
* @param text The plain text to convert.
|
|
12
|
+
* @returns HTML generated from the plain text.
|
|
13
|
+
*/
|
|
14
|
+
export default function plainTextToHtml(text: string): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
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/utils/viewtoplaintext
|
|
7
|
+
*/
|
|
8
|
+
import type { ViewDocumentFragment, ViewItem } from '@ckeditor/ckeditor5-engine';
|
|
9
|
+
/**
|
|
10
|
+
* Converts {@link module:engine/view/item~Item view item} and all of its children to plain text.
|
|
11
|
+
*
|
|
12
|
+
* @param viewItem View item to convert.
|
|
13
|
+
* @returns Plain text representation of `viewItem`.
|
|
14
|
+
*/
|
|
15
|
+
export default function viewToPlainText(viewItem: ViewItem | ViewDocumentFragment): string;
|