@ckeditor/ckeditor5-clipboard 45.2.1-alpha.9 → 46.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/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
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* @module clipboard/clipboardpipeline
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import type {
|
|
10
|
-
import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
9
|
+
import type { ViewDataTransfer, ModelDocumentFragment, ModelRange, ViewDocumentFragment, ViewRange, ModelSelection, ModelDocumentSelection } from '@ckeditor/ckeditor5-engine';
|
|
10
|
+
import { ClipboardMarkersUtils } from './clipboardmarkersutils.js';
|
|
11
11
|
/**
|
|
12
12
|
* The clipboard pipeline feature. It is responsible for intercepting the `paste` and `drop` events and
|
|
13
13
|
* passing the pasted content through a series of events in order to insert it into the editor's content.
|
|
@@ -20,7 +20,7 @@ import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
|
20
20
|
* ## Event: `paste` or `drop`
|
|
21
21
|
*
|
|
22
22
|
* 1. Translates the event data.
|
|
23
|
-
* 2. Fires the {@link module:engine/view/document~
|
|
23
|
+
* 2. Fires the {@link module:engine/view/document~ViewDocument#event:clipboardInput `view.Document#clipboardInput`} event.
|
|
24
24
|
*
|
|
25
25
|
* ## Event: `view.Document#clipboardInput`
|
|
26
26
|
*
|
|
@@ -28,15 +28,15 @@ import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
|
28
28
|
* from the last point.
|
|
29
29
|
* 2. Otherwise, it retrieves `text/html` or `text/plain` from `data.dataTransfer`.
|
|
30
30
|
* 3. Normalizes the raw data by applying simple filters on string data.
|
|
31
|
-
* 4. Processes the raw data to {@link module:engine/view/documentfragment~
|
|
31
|
+
* 4. Processes the raw data to {@link module:engine/view/documentfragment~ViewDocumentFragment `view.DocumentFragment`} with the
|
|
32
32
|
* {@link module:engine/controller/datacontroller~DataController#htmlProcessor `DataController#htmlProcessor`}.
|
|
33
33
|
* 5. Fires the {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation
|
|
34
34
|
* `ClipboardPipeline#inputTransformation`} event with the view document fragment in the `data.content` event field.
|
|
35
35
|
*
|
|
36
36
|
* ## Event: `ClipboardPipeline#inputTransformation`
|
|
37
37
|
*
|
|
38
|
-
* 1. Converts {@link module:engine/view/documentfragment~
|
|
39
|
-
* {@link module:engine/model/documentfragment~
|
|
38
|
+
* 1. Converts {@link module:engine/view/documentfragment~ViewDocumentFragment `view.DocumentFragment`} from the `data.content` field to
|
|
39
|
+
* {@link module:engine/model/documentfragment~ModelDocumentFragment `model.DocumentFragment`}.
|
|
40
40
|
* 2. Fires the {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:contentInsertion `ClipboardPipeline#contentInsertion`}
|
|
41
41
|
* event with the model document fragment in the `data.content` event field.
|
|
42
42
|
* **Note**: The `ClipboardPipeline#contentInsertion` event is fired within a model change block to allow other handlers
|
|
@@ -53,10 +53,10 @@ import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
|
53
53
|
*
|
|
54
54
|
* ## Event: `copy`, `cut` or `dragstart`
|
|
55
55
|
*
|
|
56
|
-
* 1. Retrieves the selected {@link module:engine/model/documentfragment~
|
|
56
|
+
* 1. Retrieves the selected {@link module:engine/model/documentfragment~ModelDocumentFragment `model.DocumentFragment`} by calling
|
|
57
57
|
* {@link module:engine/model/model~Model#getSelectedContent `model#getSelectedContent()`}.
|
|
58
|
-
* 2. Converts the model document fragment to {@link module:engine/view/documentfragment~
|
|
59
|
-
* 3. Fires the {@link module:engine/view/document~
|
|
58
|
+
* 2. Converts the model document fragment to {@link module:engine/view/documentfragment~ViewDocumentFragment `view.DocumentFragment`}.
|
|
59
|
+
* 3. Fires the {@link module:engine/view/document~ViewDocument#event:clipboardOutput `view.Document#clipboardOutput`} event
|
|
60
60
|
* with the view document fragment in the `data.content` event field.
|
|
61
61
|
*
|
|
62
62
|
* ## Event: `view.Document#clipboardOutput`
|
|
@@ -69,7 +69,7 @@ import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
|
69
69
|
*
|
|
70
70
|
* Read more about the clipboard integration in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
71
71
|
*/
|
|
72
|
-
export
|
|
72
|
+
export declare class ClipboardPipeline extends Plugin {
|
|
73
73
|
/**
|
|
74
74
|
* @inheritDoc
|
|
75
75
|
*/
|
|
@@ -91,7 +91,7 @@ export default class ClipboardPipeline extends Plugin {
|
|
|
91
91
|
*
|
|
92
92
|
* @internal
|
|
93
93
|
*/
|
|
94
|
-
_fireOutputTransformationEvent(dataTransfer:
|
|
94
|
+
_fireOutputTransformationEvent(dataTransfer: ViewDataTransfer, selection: ModelSelection | ModelDocumentSelection, method: 'copy' | 'cut' | 'dragstart'): void;
|
|
95
95
|
/**
|
|
96
96
|
* The clipboard paste pipeline.
|
|
97
97
|
*/
|
|
@@ -136,7 +136,7 @@ export interface ClipboardInputTransformationData {
|
|
|
136
136
|
/**
|
|
137
137
|
* The data transfer instance.
|
|
138
138
|
*/
|
|
139
|
-
dataTransfer:
|
|
139
|
+
dataTransfer: ViewDataTransfer;
|
|
140
140
|
/**
|
|
141
141
|
* The target drop ranges.
|
|
142
142
|
*/
|
|
@@ -183,7 +183,7 @@ export interface ClipboardContentInsertionData {
|
|
|
183
183
|
* The content to be inserted into the editor.
|
|
184
184
|
* Read more about the clipboard pipelines in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
185
185
|
*/
|
|
186
|
-
content:
|
|
186
|
+
content: ModelDocumentFragment;
|
|
187
187
|
/**
|
|
188
188
|
* Whether the event was triggered by a paste or a drop operation.
|
|
189
189
|
*/
|
|
@@ -195,7 +195,7 @@ export interface ClipboardContentInsertionData {
|
|
|
195
195
|
/**
|
|
196
196
|
* The data transfer instance.
|
|
197
197
|
*/
|
|
198
|
-
dataTransfer:
|
|
198
|
+
dataTransfer: ViewDataTransfer;
|
|
199
199
|
/**
|
|
200
200
|
* The target drop ranges.
|
|
201
201
|
*/
|
|
@@ -204,10 +204,10 @@ export interface ClipboardContentInsertionData {
|
|
|
204
204
|
* The result of the `model.insertContent()` call
|
|
205
205
|
* (inserted by the event handler at a low priority).
|
|
206
206
|
*/
|
|
207
|
-
resultRange?:
|
|
207
|
+
resultRange?: ModelRange;
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
210
|
-
* Fired on {@link module:engine/view/document~
|
|
210
|
+
* Fired on {@link module:engine/view/document~ViewDocument#event:copy} and {@link module:engine/view/document~ViewDocument#event:cut}
|
|
211
211
|
* with a copy of the selected content. The content can be processed before it ends up in the clipboard.
|
|
212
212
|
*
|
|
213
213
|
* It is a part of the {@glink framework/deep-dive/clipboard#output-pipeline clipboard output pipeline}.
|
|
@@ -215,7 +215,7 @@ export interface ClipboardContentInsertionData {
|
|
|
215
215
|
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
216
216
|
* @see module:clipboard/clipboardpipeline~ClipboardPipeline
|
|
217
217
|
*
|
|
218
|
-
* @eventName module:engine/view/document~
|
|
218
|
+
* @eventName module:engine/view/document~ViewDocument#clipboardOutput
|
|
219
219
|
* @param data The event data.
|
|
220
220
|
*/
|
|
221
221
|
export type ViewDocumentClipboardOutputEvent = {
|
|
@@ -231,7 +231,7 @@ export interface ViewDocumentClipboardOutputEventData {
|
|
|
231
231
|
*
|
|
232
232
|
* @readonly
|
|
233
233
|
*/
|
|
234
|
-
dataTransfer:
|
|
234
|
+
dataTransfer: ViewDataTransfer;
|
|
235
235
|
/**
|
|
236
236
|
* Content to be put into the clipboard. It can be modified by the event listeners.
|
|
237
237
|
* Read more about the clipboard pipelines in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
@@ -243,8 +243,8 @@ export interface ViewDocumentClipboardOutputEventData {
|
|
|
243
243
|
method: 'copy' | 'cut' | 'dragstart';
|
|
244
244
|
}
|
|
245
245
|
/**
|
|
246
|
-
* Fired on {@link module:engine/view/document~
|
|
247
|
-
* and {@link module:engine/view/document~
|
|
246
|
+
* Fired on {@link module:engine/view/document~ViewDocument#event:copy}, {@link module:engine/view/document~ViewDocument#event:cut}
|
|
247
|
+
* and {@link module:engine/view/document~ViewDocument#event:dragstart}. The content can be processed before it ends up in the clipboard.
|
|
248
248
|
*
|
|
249
249
|
* It is a part of the {@glink framework/deep-dive/clipboard#output-pipeline clipboard output pipeline}.
|
|
250
250
|
*
|
|
@@ -264,12 +264,12 @@ export interface ClipboardOutputTransformationData {
|
|
|
264
264
|
*
|
|
265
265
|
* @readonly
|
|
266
266
|
*/
|
|
267
|
-
dataTransfer:
|
|
267
|
+
dataTransfer: ViewDataTransfer;
|
|
268
268
|
/**
|
|
269
269
|
* Content to be put into the clipboard. It can be modified by the event listeners.
|
|
270
270
|
* Read more about the clipboard pipelines in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
271
271
|
*/
|
|
272
|
-
content:
|
|
272
|
+
content: ModelDocumentFragment;
|
|
273
273
|
/**
|
|
274
274
|
* Whether the event was triggered by a copy or cut operation.
|
|
275
275
|
*/
|
package/src/clipboardpipeline.js
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
9
|
import { EventInfo } from '@ckeditor/ckeditor5-utils';
|
|
10
|
-
import ClipboardObserver from './clipboardobserver.js';
|
|
11
|
-
import plainTextToHtml from './utils/plaintexttohtml.js';
|
|
12
|
-
import
|
|
13
|
-
import viewToPlainText from './utils/viewtoplaintext.js';
|
|
14
|
-
import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
10
|
+
import { ClipboardObserver } from './clipboardobserver.js';
|
|
11
|
+
import { plainTextToHtml } from './utils/plaintexttohtml.js';
|
|
12
|
+
import { normalizeClipboardData } from './utils/normalizeclipboarddata.js';
|
|
13
|
+
import { viewToPlainText } from './utils/viewtoplaintext.js';
|
|
14
|
+
import { ClipboardMarkersUtils } from './clipboardmarkersutils.js';
|
|
15
15
|
// Input pipeline events overview:
|
|
16
16
|
//
|
|
17
17
|
// ┌──────────────────────┐ ┌──────────────────────┐
|
|
@@ -68,7 +68,7 @@ import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
|
68
68
|
* ## Event: `paste` or `drop`
|
|
69
69
|
*
|
|
70
70
|
* 1. Translates the event data.
|
|
71
|
-
* 2. Fires the {@link module:engine/view/document~
|
|
71
|
+
* 2. Fires the {@link module:engine/view/document~ViewDocument#event:clipboardInput `view.Document#clipboardInput`} event.
|
|
72
72
|
*
|
|
73
73
|
* ## Event: `view.Document#clipboardInput`
|
|
74
74
|
*
|
|
@@ -76,15 +76,15 @@ import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
|
76
76
|
* from the last point.
|
|
77
77
|
* 2. Otherwise, it retrieves `text/html` or `text/plain` from `data.dataTransfer`.
|
|
78
78
|
* 3. Normalizes the raw data by applying simple filters on string data.
|
|
79
|
-
* 4. Processes the raw data to {@link module:engine/view/documentfragment~
|
|
79
|
+
* 4. Processes the raw data to {@link module:engine/view/documentfragment~ViewDocumentFragment `view.DocumentFragment`} with the
|
|
80
80
|
* {@link module:engine/controller/datacontroller~DataController#htmlProcessor `DataController#htmlProcessor`}.
|
|
81
81
|
* 5. Fires the {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation
|
|
82
82
|
* `ClipboardPipeline#inputTransformation`} event with the view document fragment in the `data.content` event field.
|
|
83
83
|
*
|
|
84
84
|
* ## Event: `ClipboardPipeline#inputTransformation`
|
|
85
85
|
*
|
|
86
|
-
* 1. Converts {@link module:engine/view/documentfragment~
|
|
87
|
-
* {@link module:engine/model/documentfragment~
|
|
86
|
+
* 1. Converts {@link module:engine/view/documentfragment~ViewDocumentFragment `view.DocumentFragment`} from the `data.content` field to
|
|
87
|
+
* {@link module:engine/model/documentfragment~ModelDocumentFragment `model.DocumentFragment`}.
|
|
88
88
|
* 2. Fires the {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:contentInsertion `ClipboardPipeline#contentInsertion`}
|
|
89
89
|
* event with the model document fragment in the `data.content` event field.
|
|
90
90
|
* **Note**: The `ClipboardPipeline#contentInsertion` event is fired within a model change block to allow other handlers
|
|
@@ -101,10 +101,10 @@ import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
|
101
101
|
*
|
|
102
102
|
* ## Event: `copy`, `cut` or `dragstart`
|
|
103
103
|
*
|
|
104
|
-
* 1. Retrieves the selected {@link module:engine/model/documentfragment~
|
|
104
|
+
* 1. Retrieves the selected {@link module:engine/model/documentfragment~ModelDocumentFragment `model.DocumentFragment`} by calling
|
|
105
105
|
* {@link module:engine/model/model~Model#getSelectedContent `model#getSelectedContent()`}.
|
|
106
|
-
* 2. Converts the model document fragment to {@link module:engine/view/documentfragment~
|
|
107
|
-
* 3. Fires the {@link module:engine/view/document~
|
|
106
|
+
* 2. Converts the model document fragment to {@link module:engine/view/documentfragment~ViewDocumentFragment `view.DocumentFragment`}.
|
|
107
|
+
* 3. Fires the {@link module:engine/view/document~ViewDocument#event:clipboardOutput `view.Document#clipboardOutput`} event
|
|
108
108
|
* with the view document fragment in the `data.content` event field.
|
|
109
109
|
*
|
|
110
110
|
* ## Event: `view.Document#clipboardOutput`
|
|
@@ -117,7 +117,7 @@ import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
|
117
117
|
*
|
|
118
118
|
* Read more about the clipboard integration in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
119
119
|
*/
|
|
120
|
-
export
|
|
120
|
+
export class ClipboardPipeline extends Plugin {
|
|
121
121
|
/**
|
|
122
122
|
* @inheritDoc
|
|
123
123
|
*/
|
|
@@ -188,7 +188,7 @@ export default class ClipboardPipeline extends Plugin {
|
|
|
188
188
|
else {
|
|
189
189
|
let contentData = '';
|
|
190
190
|
if (dataTransfer.getData('text/html')) {
|
|
191
|
-
contentData =
|
|
191
|
+
contentData = normalizeClipboardData(dataTransfer.getData('text/html'));
|
|
192
192
|
}
|
|
193
193
|
else if (dataTransfer.getData('text/plain')) {
|
|
194
194
|
contentData = plainTextToHtml(dataTransfer.getData('text/plain'));
|
package/src/dragdrop.d.ts
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
9
|
import { Widget } from '@ckeditor/ckeditor5-widget';
|
|
10
|
-
import ClipboardPipeline from './clipboardpipeline.js';
|
|
11
|
-
import DragDropTarget from './dragdroptarget.js';
|
|
12
|
-
import DragDropBlockToolbar from './dragdropblocktoolbar.js';
|
|
10
|
+
import { ClipboardPipeline } from './clipboardpipeline.js';
|
|
11
|
+
import { DragDropTarget } from './dragdroptarget.js';
|
|
12
|
+
import { DragDropBlockToolbar } from './dragdropblocktoolbar.js';
|
|
13
13
|
import '../theme/clipboard.css';
|
|
14
14
|
/**
|
|
15
15
|
* The drag and drop feature. It works on top of the {@link module:clipboard/clipboardpipeline~ClipboardPipeline}.
|
|
@@ -18,7 +18,7 @@ import '../theme/clipboard.css';
|
|
|
18
18
|
*
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
|
-
export
|
|
21
|
+
export declare class DragDrop extends Plugin {
|
|
22
22
|
/**
|
|
23
23
|
* The live range over the original content that is being dragged.
|
|
24
24
|
*/
|
package/src/dragdrop.js
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* @module clipboard/dragdrop
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import {
|
|
9
|
+
import { ModelLiveRange, MouseObserver } from '@ckeditor/ckeditor5-engine';
|
|
10
10
|
import { Widget, isWidget } from '@ckeditor/ckeditor5-widget';
|
|
11
11
|
import { env, uid, global, createElement, DomEmitterMixin, delay, Rect } from '@ckeditor/ckeditor5-utils';
|
|
12
|
-
import ClipboardPipeline from './clipboardpipeline.js';
|
|
13
|
-
import ClipboardObserver from './clipboardobserver.js';
|
|
14
|
-
import DragDropTarget from './dragdroptarget.js';
|
|
15
|
-
import DragDropBlockToolbar from './dragdropblocktoolbar.js';
|
|
12
|
+
import { ClipboardPipeline } from './clipboardpipeline.js';
|
|
13
|
+
import { ClipboardObserver } from './clipboardobserver.js';
|
|
14
|
+
import { DragDropTarget } from './dragdroptarget.js';
|
|
15
|
+
import { DragDropBlockToolbar } from './dragdropblocktoolbar.js';
|
|
16
16
|
import '../theme/clipboard.css';
|
|
17
17
|
// Drag and drop events overview:
|
|
18
18
|
//
|
|
@@ -98,7 +98,7 @@ import '../theme/clipboard.css';
|
|
|
98
98
|
*
|
|
99
99
|
* @internal
|
|
100
100
|
*/
|
|
101
|
-
export
|
|
101
|
+
export class DragDrop extends Plugin {
|
|
102
102
|
/**
|
|
103
103
|
* The live range over the original content that is being dragged.
|
|
104
104
|
*/
|
|
@@ -456,7 +456,7 @@ export default class DragDrop extends Plugin {
|
|
|
456
456
|
const draggableWidget = target ? findDraggableWidget(target) : null;
|
|
457
457
|
if (draggableWidget) {
|
|
458
458
|
const modelElement = editor.editing.mapper.toModelElement(draggableWidget);
|
|
459
|
-
this._draggedRange =
|
|
459
|
+
this._draggedRange = ModelLiveRange.fromRange(model.createRangeOn(modelElement));
|
|
460
460
|
this._blockMode = model.schema.isBlock(modelElement);
|
|
461
461
|
// Disable toolbars so they won't obscure the drop area.
|
|
462
462
|
if (editor.plugins.has('WidgetToolbarRepository')) {
|
|
@@ -472,19 +472,19 @@ export default class DragDrop extends Plugin {
|
|
|
472
472
|
const blocks = Array.from(selection.getSelectedBlocks());
|
|
473
473
|
const draggedRange = selection.getFirstRange();
|
|
474
474
|
if (blocks.length == 0) {
|
|
475
|
-
this._draggedRange =
|
|
475
|
+
this._draggedRange = ModelLiveRange.fromRange(draggedRange);
|
|
476
476
|
return;
|
|
477
477
|
}
|
|
478
478
|
const blockRange = getRangeIncludingFullySelectedParents(model, blocks);
|
|
479
479
|
if (blocks.length > 1) {
|
|
480
|
-
this._draggedRange =
|
|
480
|
+
this._draggedRange = ModelLiveRange.fromRange(blockRange);
|
|
481
481
|
this._blockMode = true;
|
|
482
482
|
// TODO block mode for dragging from outside editor? or inline? or both?
|
|
483
483
|
}
|
|
484
484
|
else if (blocks.length == 1) {
|
|
485
485
|
const touchesBlockEdges = draggedRange.start.isTouching(blockRange.start) &&
|
|
486
486
|
draggedRange.end.isTouching(blockRange.end);
|
|
487
|
-
this._draggedRange =
|
|
487
|
+
this._draggedRange = ModelLiveRange.fromRange(touchesBlockEdges ? blockRange : draggedRange);
|
|
488
488
|
this._blockMode = touchesBlockEdges;
|
|
489
489
|
}
|
|
490
490
|
model.change(writer => writer.setSelection(this._draggedRange.toRange()));
|
|
@@ -11,7 +11,7 @@ import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
|
11
11
|
*
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export declare class DragDropBlockToolbar extends Plugin {
|
|
15
15
|
/**
|
|
16
16
|
* Whether current dragging is started by block toolbar button dragging.
|
|
17
17
|
*/
|
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
9
|
import { env, global, DomEmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
10
|
-
import ClipboardObserver from './clipboardobserver.js';
|
|
10
|
+
import { ClipboardObserver } from './clipboardobserver.js';
|
|
11
11
|
/**
|
|
12
12
|
* Integration of a block Drag and Drop support with the block toolbar.
|
|
13
13
|
*
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export class DragDropBlockToolbar extends Plugin {
|
|
17
17
|
/**
|
|
18
18
|
* Whether current dragging is started by block toolbar button dragging.
|
|
19
19
|
*/
|
package/src/dragdroptarget.d.ts
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* @module clipboard/dragdroptarget
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import { type
|
|
9
|
+
import { type ModelRange, type ModelLiveRange, type ViewElement, type ViewRange } from '@ckeditor/ckeditor5-engine';
|
|
10
10
|
/**
|
|
11
11
|
* Part of the Drag and Drop handling. Responsible for finding and displaying the drop target.
|
|
12
12
|
*
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export declare class DragDropTarget extends Plugin {
|
|
16
16
|
/**
|
|
17
17
|
* A delayed callback removing the drop marker.
|
|
18
18
|
*
|
|
@@ -60,13 +60,13 @@ export default class DragDropTarget extends Plugin {
|
|
|
60
60
|
*
|
|
61
61
|
* @internal
|
|
62
62
|
*/
|
|
63
|
-
updateDropMarker(targetViewElement: ViewElement, targetViewRanges: Array<ViewRange> | null, clientX: number, clientY: number, blockMode: boolean, draggedRange:
|
|
63
|
+
updateDropMarker(targetViewElement: ViewElement, targetViewRanges: Array<ViewRange> | null, clientX: number, clientY: number, blockMode: boolean, draggedRange: ModelLiveRange | null): void;
|
|
64
64
|
/**
|
|
65
65
|
* Finds the final drop target range.
|
|
66
66
|
*
|
|
67
67
|
* @internal
|
|
68
68
|
*/
|
|
69
|
-
getFinalDropRange(targetViewElement: ViewElement, targetViewRanges: Array<ViewRange> | null, clientX: number, clientY: number, blockMode: boolean, draggedRange:
|
|
69
|
+
getFinalDropRange(targetViewElement: ViewElement, targetViewRanges: Array<ViewRange> | null, clientX: number, clientY: number, blockMode: boolean, draggedRange: ModelLiveRange | null): ModelRange | null;
|
|
70
70
|
/**
|
|
71
71
|
* Removes the drop target marker.
|
|
72
72
|
*
|
package/src/dragdroptarget.js
CHANGED
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
9
|
import { global, Rect, DomEmitterMixin, delay, ResizeObserver } from '@ckeditor/ckeditor5-utils';
|
|
10
|
-
import LineView from './lineview.js';
|
|
10
|
+
import { LineView } from './lineview.js';
|
|
11
11
|
import { throttle } from 'es-toolkit/compat';
|
|
12
12
|
/**
|
|
13
13
|
* Part of the Drag and Drop handling. Responsible for finding and displaying the drop target.
|
|
14
14
|
*
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export class DragDropTarget extends Plugin {
|
|
18
18
|
/**
|
|
19
19
|
* A delayed callback removing the drop marker.
|
|
20
20
|
*
|
package/src/index.d.ts
CHANGED
|
@@ -5,14 +5,19 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module clipboard
|
|
7
7
|
*/
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
8
|
+
export { Clipboard } from './clipboard.js';
|
|
9
|
+
export { ClipboardPipeline, type ClipboardContentInsertionEvent, type ClipboardContentInsertionData, type ClipboardInputTransformationEvent, type ClipboardInputTransformationData, type ClipboardOutputTransformationEvent, type ClipboardOutputTransformationData, type ViewDocumentClipboardOutputEvent, type ViewDocumentClipboardOutputEventData } from './clipboardpipeline.js';
|
|
10
|
+
export { ClipboardMarkersUtils, type ClipboardMarkerRestrictedAction, type ClipboardMarkerConfiguration } from './clipboardmarkersutils.js';
|
|
11
|
+
export { plainTextToHtml } from './utils/plaintexttohtml.js';
|
|
12
|
+
export { viewToPlainText } from './utils/viewtoplaintext.js';
|
|
13
|
+
export { DragDrop } from './dragdrop.js';
|
|
14
|
+
export { PastePlainText } from './pasteplaintext.js';
|
|
15
|
+
export { DragDropTarget } from './dragdroptarget.js';
|
|
16
|
+
export { DragDropBlockToolbar } from './dragdropblocktoolbar.js';
|
|
17
|
+
export { ClipboardObserver, type ClipboardEventData, type ClipboardInputEventData, type DraggingEventData, type ViewDocumentClipboardInputEvent, type ViewDocumentCopyEvent, type ViewDocumentPasteEvent, type ViewDocumentCutEvent, type ViewDocumentDragOverEvent, type ViewDocumentDropEvent, type ViewDocumentDraggingEvent, type ViewDocumentDragStartEvent, type ViewDocumentDragEndEvent, type ViewDocumentDragEnterEvent, type ViewDocumentDragLeaveEvent } from './clipboardobserver.js';
|
|
18
|
+
export { DragDrop as _DragDrop } from './dragdrop.js';
|
|
19
|
+
export { DragDropBlockToolbar as _DragDropBlockToolbar } from './dragdropblocktoolbar.js';
|
|
20
|
+
export { DragDropTarget as _DragDropTarget } from './dragdroptarget.js';
|
|
21
|
+
export { LineView as _ClipboardLineView } from './lineview.js';
|
|
22
|
+
export { normalizeClipboardData as _normalizeClipboardData } from './utils/normalizeclipboarddata.js';
|
|
18
23
|
import './augmentation.js';
|
package/src/index.js
CHANGED
|
@@ -5,14 +5,19 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module clipboard
|
|
7
7
|
*/
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
8
|
+
export { Clipboard } from './clipboard.js';
|
|
9
|
+
export { ClipboardPipeline } from './clipboardpipeline.js';
|
|
10
|
+
export { ClipboardMarkersUtils } from './clipboardmarkersutils.js';
|
|
11
|
+
export { plainTextToHtml } from './utils/plaintexttohtml.js';
|
|
12
|
+
export { viewToPlainText } from './utils/viewtoplaintext.js';
|
|
13
|
+
export { DragDrop } from './dragdrop.js';
|
|
14
|
+
export { PastePlainText } from './pasteplaintext.js';
|
|
15
|
+
export { DragDropTarget } from './dragdroptarget.js';
|
|
16
|
+
export { DragDropBlockToolbar } from './dragdropblocktoolbar.js';
|
|
17
|
+
export { ClipboardObserver } from './clipboardobserver.js';
|
|
18
|
+
export { DragDrop as _DragDrop } from './dragdrop.js';
|
|
19
|
+
export { DragDropBlockToolbar as _DragDropBlockToolbar } from './dragdropblocktoolbar.js';
|
|
20
|
+
export { DragDropTarget as _DragDropTarget } from './dragdroptarget.js';
|
|
21
|
+
export { LineView as _ClipboardLineView } from './lineview.js';
|
|
22
|
+
export { normalizeClipboardData as _normalizeClipboardData } from './utils/normalizeclipboarddata.js';
|
|
18
23
|
import './augmentation.js';
|
package/src/lineview.d.ts
CHANGED
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
import { View } from '@ckeditor/ckeditor5-ui';
|
|
9
9
|
/**
|
|
10
10
|
* The horizontal drop target line view.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
11
13
|
*/
|
|
12
|
-
export
|
|
14
|
+
export declare class LineView extends View {
|
|
13
15
|
/**
|
|
14
16
|
* Controls whether the line is visible.
|
|
15
17
|
*
|
package/src/lineview.js
CHANGED
|
@@ -11,8 +11,10 @@ import { toUnit } from '@ckeditor/ckeditor5-utils';
|
|
|
11
11
|
const toPx = /* #__PURE__ */ toUnit('px');
|
|
12
12
|
/**
|
|
13
13
|
* The horizontal drop target line view.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
14
16
|
*/
|
|
15
|
-
export
|
|
17
|
+
export class LineView extends View {
|
|
16
18
|
/**
|
|
17
19
|
* @inheritDoc
|
|
18
20
|
*/
|
package/src/pasteplaintext.d.ts
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* @module clipboard/pasteplaintext
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import ClipboardPipeline from './clipboardpipeline.js';
|
|
9
|
+
import { ClipboardPipeline } from './clipboardpipeline.js';
|
|
10
10
|
/**
|
|
11
11
|
* The plugin detects the user's intention to paste plain text.
|
|
12
12
|
*
|
|
13
13
|
* For example, it detects the <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>V</kbd> keystroke.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export declare class PastePlainText extends Plugin {
|
|
16
16
|
/**
|
|
17
17
|
* @inheritDoc
|
|
18
18
|
*/
|
package/src/pasteplaintext.js
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
* @module clipboard/pasteplaintext
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import ClipboardObserver from './clipboardobserver.js';
|
|
10
|
-
import ClipboardPipeline from './clipboardpipeline.js';
|
|
9
|
+
import { ClipboardObserver } from './clipboardobserver.js';
|
|
10
|
+
import { ClipboardPipeline } from './clipboardpipeline.js';
|
|
11
11
|
/**
|
|
12
12
|
* The plugin detects the user's intention to paste plain text.
|
|
13
13
|
*
|
|
14
14
|
* For example, it detects the <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>V</kbd> keystroke.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export class PastePlainText extends Plugin {
|
|
17
17
|
/**
|
|
18
18
|
* @inheritDoc
|
|
19
19
|
*/
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @param data The HTML data to normalize.
|
|
13
13
|
* @returns Normalized HTML.
|
|
14
|
+
* @internal
|
|
14
15
|
*/
|
|
15
|
-
export
|
|
16
|
+
export function normalizeClipboardData(data) {
|
|
16
17
|
return data
|
|
17
18
|
.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g, (fullMatch, spaces) => {
|
|
18
19
|
// Handle the most popular and problematic case when even a single space becomes an nbsp;.
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module clipboard/utils/viewtoplaintext
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
8
|
+
import type { ViewDomConverter, ViewDocumentFragment, ViewItem } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
/**
|
|
10
|
-
* Converts {@link module:engine/view/item~
|
|
10
|
+
* Converts {@link module:engine/view/item~ViewItem view item} and all of its children to plain text.
|
|
11
11
|
*
|
|
12
12
|
* @param converter The converter instance.
|
|
13
13
|
* @param viewItem View item to convert.
|
|
14
14
|
* @returns Plain text representation of `viewItem`.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export declare function viewToPlainText(converter: ViewDomConverter, viewItem: ViewItem | ViewDocumentFragment): string;
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
const smallPaddingElements = ['figcaption', 'li'];
|
|
9
9
|
const listElements = ['ol', 'ul'];
|
|
10
10
|
/**
|
|
11
|
-
* Converts {@link module:engine/view/item~
|
|
11
|
+
* Converts {@link module:engine/view/item~ViewItem view item} and all of its children to plain text.
|
|
12
12
|
*
|
|
13
13
|
* @param converter The converter instance.
|
|
14
14
|
* @param viewItem View item to convert.
|
|
15
15
|
* @returns Plain text representation of `viewItem`.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export function viewToPlainText(converter, viewItem) {
|
|
18
18
|
if (viewItem.is('$text') || viewItem.is('$textProxy')) {
|
|
19
19
|
return viewItem.data;
|
|
20
20
|
}
|
|
@@ -72,7 +72,7 @@ function newLinePadding(element, previous) {
|
|
|
72
72
|
}
|
|
73
73
|
if (listElements.includes(element.name) && listElements.includes(previous.name)) {
|
|
74
74
|
/**
|
|
75
|
-
* Because `<ul>` and `<ol>` are
|
|
75
|
+
* Because `<ul>` and `<ol>` are ViewAttributeElements, two consecutive lists will not have any padding between
|
|
76
76
|
* them (see the `if` statement below). To fix this, we need to make an exception for this case.
|
|
77
77
|
*/
|
|
78
78
|
return '\n\n';
|