@ckeditor/ckeditor5-clipboard 41.2.0 → 41.3.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/content-index.css +4 -0
- package/dist/editor-index.css +23 -0
- package/dist/index.css +42 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +2175 -0
- package/dist/index.js.map +1 -0
- package/dist/types/augmentation.d.ts +16 -0
- package/dist/types/clipboard.d.ts +36 -0
- package/dist/types/clipboardmarkersutils.d.ts +186 -0
- package/dist/types/clipboardobserver.d.ts +312 -0
- package/dist/types/clipboardpipeline.d.ts +265 -0
- package/dist/types/dragdrop.d.ts +102 -0
- package/dist/types/dragdropblocktoolbar.d.ts +47 -0
- package/dist/types/dragdroptarget.d.ts +94 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/lineview.d.ts +45 -0
- package/dist/types/pasteplaintext.d.ts +28 -0
- package/dist/types/utils/normalizeclipboarddata.d.ts +15 -0
- package/dist/types/utils/plaintexttohtml.d.ts +14 -0
- package/dist/types/utils/viewtoplaintext.d.ts +15 -0
- package/package.json +7 -6
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 type { Clipboard, ClipboardPipeline, PastePlainText, DragDrop, DragDropTarget, DragDropBlockToolbar, ClipboardMarkersUtils } from './index.js';
|
|
6
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
7
|
+
interface PluginsMap {
|
|
8
|
+
[Clipboard.pluginName]: Clipboard;
|
|
9
|
+
[ClipboardPipeline.pluginName]: ClipboardPipeline;
|
|
10
|
+
[ClipboardMarkersUtils.pluginName]: ClipboardMarkersUtils;
|
|
11
|
+
[PastePlainText.pluginName]: PastePlainText;
|
|
12
|
+
[DragDrop.pluginName]: DragDrop;
|
|
13
|
+
[DragDropTarget.pluginName]: DragDropTarget;
|
|
14
|
+
[DragDropBlockToolbar.pluginName]: DragDropBlockToolbar;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 } 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';
|
|
13
|
+
/**
|
|
14
|
+
* The clipboard feature.
|
|
15
|
+
*
|
|
16
|
+
* Read more about the clipboard integration in the {@glink framework/deep-dive/clipboard clipboard deep-dive} guide.
|
|
17
|
+
*
|
|
18
|
+
* This is a "glue" plugin which loads the following plugins:
|
|
19
|
+
* * {@link module:clipboard/clipboardpipeline~ClipboardPipeline}
|
|
20
|
+
* * {@link module:clipboard/dragdrop~DragDrop}
|
|
21
|
+
* * {@link module:clipboard/pasteplaintext~PastePlainText}
|
|
22
|
+
*/
|
|
23
|
+
export default class Clipboard extends Plugin {
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get pluginName(): "Clipboard";
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
static get requires(): readonly [typeof ClipboardMarkersUtils, typeof ClipboardPipeline, typeof DragDrop, typeof PastePlainText];
|
|
32
|
+
/**
|
|
33
|
+
* @inheritDoc
|
|
34
|
+
*/
|
|
35
|
+
init(): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 { Plugin } from '@ckeditor/ckeditor5-core';
|
|
6
|
+
import { Range, type Element, type DocumentFragment, type DocumentSelection, type Selection, type Writer } from '@ckeditor/ckeditor5-engine';
|
|
7
|
+
/**
|
|
8
|
+
* Part of the clipboard logic. Responsible for collecting markers from selected fragments
|
|
9
|
+
* and restoring them with proper positions in pasted elements.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export default class ClipboardMarkersUtils extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* Map of marker names that can be copied.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
private _markersToCopy;
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get pluginName(): "ClipboardMarkersUtils";
|
|
24
|
+
/**
|
|
25
|
+
* Registers marker name as copyable in clipboard pipeline.
|
|
26
|
+
*
|
|
27
|
+
* @param markerName Name of marker that can be copied.
|
|
28
|
+
* @param restrictions Preset or specified array of actions that can be performed on specified marker name.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
_registerMarkerToCopy(markerName: string, restrictions: ClipboardMarkerRestrictionsPreset | Array<ClipboardMarkerRestrictedAction>): void;
|
|
32
|
+
/**
|
|
33
|
+
* Maps preset into array of clipboard operations to be allowed on marker.
|
|
34
|
+
*
|
|
35
|
+
* @param preset Restrictions preset to be mapped to actions
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
private _mapRestrictionPresetToActions;
|
|
39
|
+
/**
|
|
40
|
+
* Performs copy markers on provided selection and paste it to fragment returned from `getCopiedFragment`.
|
|
41
|
+
*
|
|
42
|
+
* 1. Picks all markers in provided selection.
|
|
43
|
+
* 2. Inserts fake markers to document.
|
|
44
|
+
* 3. Gets copied selection fragment from document.
|
|
45
|
+
* 4. Removes fake elements from fragment and document.
|
|
46
|
+
* 5. Inserts markers in the place of removed fake markers.
|
|
47
|
+
*
|
|
48
|
+
* Due to selection modification, when inserting items, `getCopiedFragment` must *always* operate on `writer.model.document.selection'.
|
|
49
|
+
* Do not use any other custom selection object within callback, as this will lead to out-of-bounds exceptions in rare scenarios.
|
|
50
|
+
*
|
|
51
|
+
* @param action Type of clipboard action.
|
|
52
|
+
* @param writer An instance of the model writer.
|
|
53
|
+
* @param selection Selection to be checked.
|
|
54
|
+
* @param getCopiedFragment Callback that performs copy of selection and returns it as fragment.
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
_copySelectedFragmentWithMarkers(action: ClipboardMarkerRestrictedAction, selection: Selection | DocumentSelection, getCopiedFragment?: (writer: Writer) => DocumentFragment): DocumentFragment;
|
|
58
|
+
/**
|
|
59
|
+
* Performs paste of markers on already pasted element.
|
|
60
|
+
*
|
|
61
|
+
* 1. Inserts fake markers that are present in fragment element (such fragment will be processed in `getPastedDocumentElement`).
|
|
62
|
+
* 2. Calls `getPastedDocumentElement` and gets element that is inserted into root model.
|
|
63
|
+
* 3. Removes all fake markers present in transformed element.
|
|
64
|
+
* 4. Inserts new markers with removed fake markers ranges into pasted fragment.
|
|
65
|
+
*
|
|
66
|
+
* There are multiple edge cases that have to be considered before calling this function:
|
|
67
|
+
*
|
|
68
|
+
* * `markers` are inserted into the same element that must be later transformed inside `getPastedDocumentElement`.
|
|
69
|
+
* * Fake marker elements inside `getPastedDocumentElement` can be cloned, but their ranges cannot overlap.
|
|
70
|
+
*
|
|
71
|
+
* @param action Type of clipboard action.
|
|
72
|
+
* @param markers Object that maps marker name to corresponding range.
|
|
73
|
+
* @param getPastedDocumentElement Getter used to get target markers element.
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
_pasteMarkersIntoTransformedElement(markers: Record<string, Range> | Map<string, Range>, getPastedDocumentElement: (writer: Writer) => Element): Element;
|
|
77
|
+
/**
|
|
78
|
+
* In some situations we have to perform copy on selected fragment with certain markers. This function allows to temporarily bypass
|
|
79
|
+
* restrictions on markers that we want to copy.
|
|
80
|
+
*
|
|
81
|
+
* This function executes `executor()` callback. For the duration of the callback, if the clipboard pipeline is used to copy
|
|
82
|
+
* content, markers with the specified name will be copied to the clipboard as well.
|
|
83
|
+
*
|
|
84
|
+
* @param markerName Which markers should be copied.
|
|
85
|
+
* @param executor Callback executed.
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
_forceMarkersCopy(markerName: string, executor: VoidFunction): void;
|
|
89
|
+
/**
|
|
90
|
+
* Checks if marker can be copied.
|
|
91
|
+
*
|
|
92
|
+
* @param markerName Name of checked marker.
|
|
93
|
+
* @param action Type of clipboard action. If null then checks only if marker is registered as copyable.
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
_canPerformMarkerClipboardAction(markerName: string, action: ClipboardMarkerRestrictedAction | null): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Changes marker names for markers stored in given document fragment so that they are unique.
|
|
99
|
+
*
|
|
100
|
+
* @param fragment
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
_setUniqueMarkerNamesInFragment(fragment: DocumentFragment): void;
|
|
104
|
+
/**
|
|
105
|
+
* First step of copying markers. It looks for markers intersecting with given selection and inserts `$marker` elements
|
|
106
|
+
* at positions where document markers start or end. This way `$marker` elements can be easily copied together with
|
|
107
|
+
* the rest of the content of the selection.
|
|
108
|
+
*
|
|
109
|
+
* @param writer An instance of the model writer.
|
|
110
|
+
* @param selection Selection to be checked.
|
|
111
|
+
* @param action Type of clipboard action.
|
|
112
|
+
*/
|
|
113
|
+
private _insertFakeMarkersIntoSelection;
|
|
114
|
+
/**
|
|
115
|
+
* Returns array of markers that can be copied in specified selection.
|
|
116
|
+
*
|
|
117
|
+
* @param writer An instance of the model writer.
|
|
118
|
+
* @param selection Selection which will be checked.
|
|
119
|
+
* @param action Type of clipboard action. If null then checks only if marker is registered as copyable.
|
|
120
|
+
*/
|
|
121
|
+
private _getCopyableMarkersFromSelection;
|
|
122
|
+
/**
|
|
123
|
+
* Picks all markers from markers map that can be copied.
|
|
124
|
+
*
|
|
125
|
+
* @param markers Object that maps marker name to corresponding range.
|
|
126
|
+
* @param action Type of clipboard action. If null then checks only if marker is registered as copyable.
|
|
127
|
+
*/
|
|
128
|
+
private _getCopyableMarkersFromRangeMap;
|
|
129
|
+
/**
|
|
130
|
+
* Inserts specified array of fake markers elements to document and assigns them `type` and `name` attributes.
|
|
131
|
+
* Fake markers elements are used to calculate position of markers on pasted fragment that were transformed during
|
|
132
|
+
* steps between copy and paste.
|
|
133
|
+
*
|
|
134
|
+
* @param writer An instance of the model writer.
|
|
135
|
+
* @param markers Array of markers that will be inserted.
|
|
136
|
+
*/
|
|
137
|
+
private _insertFakeMarkersElements;
|
|
138
|
+
/**
|
|
139
|
+
* Removes all `$marker` elements from the given document fragment.
|
|
140
|
+
*
|
|
141
|
+
* Returns an object where keys are marker names, and values are ranges corresponding to positions
|
|
142
|
+
* where `$marker` elements were inserted.
|
|
143
|
+
*
|
|
144
|
+
* If the document fragment had only one `$marker` element for given marker (start or end) the other boundary is set automatically
|
|
145
|
+
* (to the end or start of the document fragment, respectively).
|
|
146
|
+
*
|
|
147
|
+
* @param writer An instance of the model writer.
|
|
148
|
+
* @param rootElement The element to be checked.
|
|
149
|
+
*/
|
|
150
|
+
private _removeFakeMarkersInsideElement;
|
|
151
|
+
/**
|
|
152
|
+
* Returns array that contains list of fake markers with corresponding `$marker` elements.
|
|
153
|
+
*
|
|
154
|
+
* For each marker, there can be two `$marker` elements or only one (if the document fragment contained
|
|
155
|
+
* only the beginning or only the end of a marker).
|
|
156
|
+
*
|
|
157
|
+
* @param writer An instance of the model writer.
|
|
158
|
+
* @param rootElement The element to be checked.
|
|
159
|
+
*/
|
|
160
|
+
private _getAllFakeMarkersFromElement;
|
|
161
|
+
/**
|
|
162
|
+
* When copy of markers occurs we have to make sure that pasted markers have different names
|
|
163
|
+
* than source markers. This functions helps with assigning unique part to marker name to
|
|
164
|
+
* prevent duplicated markers error.
|
|
165
|
+
*
|
|
166
|
+
* @param name Name of marker
|
|
167
|
+
*/
|
|
168
|
+
private _getUniqueMarkerName;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Specifies which action is performed during clipboard event.
|
|
172
|
+
*
|
|
173
|
+
* @internal
|
|
174
|
+
*/
|
|
175
|
+
export type ClipboardMarkerRestrictedAction = 'copy' | 'cut' | 'dragstart';
|
|
176
|
+
/**
|
|
177
|
+
* Specifies copy, paste or move marker restrictions in clipboard. Depending on specified mode
|
|
178
|
+
* it will disallow copy, cut or paste of marker in clipboard.
|
|
179
|
+
*
|
|
180
|
+
* * `'default'` - the markers will be preserved on cut-paste and drag and drop actions only.
|
|
181
|
+
* * `'always'` - the markers will be preserved on all clipboard actions (cut, copy, drag and drop).
|
|
182
|
+
* * `'never'` - the markers will be ignored by clipboard.
|
|
183
|
+
*
|
|
184
|
+
* @internal
|
|
185
|
+
*/
|
|
186
|
+
export type ClipboardMarkerRestrictionsPreset = 'default' | 'always' | 'never';
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 EditingView, 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: EditingView);
|
|
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 module:engine/view/document~Document#event:paste} and
|
|
48
|
+
* {@link module:engine/view/document~Document#event:drop} events.
|
|
49
|
+
*
|
|
50
|
+
* It is a part of the {@glink framework/deep-dive/clipboard#input-pipeline clipboard input pipeline}.
|
|
51
|
+
*
|
|
52
|
+
* This event carries a `dataTransfer` object which comes from the clipboard and whose content should be processed
|
|
53
|
+
* and inserted into the editor.
|
|
54
|
+
*
|
|
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~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
57
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
58
|
+
* the observer must be added manually.
|
|
59
|
+
*
|
|
60
|
+
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
61
|
+
* @see module:clipboard/clipboard~Clipboard
|
|
62
|
+
*
|
|
63
|
+
* @eventName module:engine/view/document~Document#clipboardInput
|
|
64
|
+
* @param data The event data.
|
|
65
|
+
*/
|
|
66
|
+
export type ViewDocumentClipboardInputEvent = {
|
|
67
|
+
name: 'clipboardInput';
|
|
68
|
+
args: [data: DomEventData<ClipboardEvent | DragEvent> & ClipboardInputEventData];
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The value of the {@link module:engine/view/document~Document#event:paste},
|
|
72
|
+
* {@link module:engine/view/document~Document#event:copy} and {@link module:engine/view/document~Document#event:cut} events.
|
|
73
|
+
*
|
|
74
|
+
* In order to access the clipboard data, use the `dataTransfer` property.
|
|
75
|
+
*/
|
|
76
|
+
export interface ClipboardInputEventData {
|
|
77
|
+
/**
|
|
78
|
+
* Data transfer instance.
|
|
79
|
+
*/
|
|
80
|
+
dataTransfer: DataTransfer;
|
|
81
|
+
/**
|
|
82
|
+
* Whether the event was triggered by a paste or a drop operation.
|
|
83
|
+
*/
|
|
84
|
+
method: 'paste' | 'drop';
|
|
85
|
+
/**
|
|
86
|
+
* The tree view element representing the target.
|
|
87
|
+
*/
|
|
88
|
+
target: ViewElement;
|
|
89
|
+
/**
|
|
90
|
+
* The ranges which are the target of the operation (usually – into which the content should be inserted).
|
|
91
|
+
* If the clipboard input was triggered by a paste operation, this property is not set. If by a drop operation,
|
|
92
|
+
* then it is the drop position (which can be different than the selection at the moment of the drop).
|
|
93
|
+
*/
|
|
94
|
+
targetRanges: Array<ViewRange> | null;
|
|
95
|
+
/**
|
|
96
|
+
* The content of clipboard input.
|
|
97
|
+
*/
|
|
98
|
+
content?: ViewDocumentFragment;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Fired when the user drags the content over one of the editing roots of the editor.
|
|
102
|
+
*
|
|
103
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
104
|
+
*
|
|
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~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
107
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
108
|
+
* the observer must be added manually.
|
|
109
|
+
*
|
|
110
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
111
|
+
*
|
|
112
|
+
* @eventName module:engine/view/document~Document#dragover
|
|
113
|
+
* @param data The event data.
|
|
114
|
+
*/
|
|
115
|
+
export type ViewDocumentDragOverEvent = {
|
|
116
|
+
name: 'dragover';
|
|
117
|
+
args: [data: DomEventData<DragEvent> & ClipboardEventData];
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Fired when the user dropped the content into one of the editing roots of the editor.
|
|
121
|
+
*
|
|
122
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
123
|
+
*
|
|
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~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
126
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
127
|
+
* the observer must be added manually.
|
|
128
|
+
*
|
|
129
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
130
|
+
*
|
|
131
|
+
* @eventName module:engine/view/document~Document#drop
|
|
132
|
+
* @param data The event data.
|
|
133
|
+
*/
|
|
134
|
+
export type ViewDocumentDropEvent = {
|
|
135
|
+
name: 'drop';
|
|
136
|
+
args: [data: DomEventData<DragEvent> & ClipboardEventData];
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Fired when the user pasted the content into one of the editing roots of the editor.
|
|
140
|
+
*
|
|
141
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
142
|
+
*
|
|
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~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
145
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
146
|
+
* the observer must be added manually.
|
|
147
|
+
*
|
|
148
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
149
|
+
*
|
|
150
|
+
* @eventName module:engine/view/document~Document#paste
|
|
151
|
+
* @param {module:clipboard/clipboardobserver~ClipboardEventData} data The event data.
|
|
152
|
+
*/
|
|
153
|
+
export type ViewDocumentPasteEvent = {
|
|
154
|
+
name: 'paste';
|
|
155
|
+
args: [data: DomEventData<ClipboardEvent> & ClipboardEventData];
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Fired when the user copied the content from one of the editing roots of the editor.
|
|
159
|
+
*
|
|
160
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
161
|
+
*
|
|
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~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
164
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
165
|
+
* the observer must be added manually.
|
|
166
|
+
*
|
|
167
|
+
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
168
|
+
*
|
|
169
|
+
* @eventName module:engine/view/document~Document#copy
|
|
170
|
+
* @param data The event data.
|
|
171
|
+
*/
|
|
172
|
+
export type ViewDocumentCopyEvent = {
|
|
173
|
+
name: 'copy';
|
|
174
|
+
args: [data: DomEventData<ClipboardEvent> & ClipboardEventData];
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Fired when the user cut the content from one of the editing roots of the editor.
|
|
178
|
+
*
|
|
179
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
180
|
+
*
|
|
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~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
183
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
184
|
+
* the observer must be added manually.
|
|
185
|
+
*
|
|
186
|
+
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
187
|
+
*
|
|
188
|
+
* @eventName module:engine/view/document~Document#cut
|
|
189
|
+
* @param data The event data.
|
|
190
|
+
*/
|
|
191
|
+
export type ViewDocumentCutEvent = {
|
|
192
|
+
name: 'cut';
|
|
193
|
+
args: [data: DomEventData<ClipboardEvent> & ClipboardEventData];
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Fired as a continuation of the {@link module:engine/view/document~Document#event:dragover} event.
|
|
197
|
+
*
|
|
198
|
+
* It is a part of the {@glink framework/deep-dive/clipboard#input-pipeline clipboard input pipeline}.
|
|
199
|
+
*
|
|
200
|
+
* This event carries a `dataTransfer` object which comes from the clipboard and whose content should be processed
|
|
201
|
+
* and inserted into the editor.
|
|
202
|
+
*
|
|
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~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
205
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
206
|
+
* the observer must be added manually.
|
|
207
|
+
*
|
|
208
|
+
* @see module:clipboard/clipboardobserver~ClipboardObserver
|
|
209
|
+
* @see module:clipboard/clipboard~Clipboard
|
|
210
|
+
*
|
|
211
|
+
* @eventName module:engine/view/document~Document#dragging
|
|
212
|
+
* @param data The event data.
|
|
213
|
+
*/
|
|
214
|
+
export type ViewDocumentDraggingEvent = {
|
|
215
|
+
name: 'dragging';
|
|
216
|
+
args: [data: DomEventData<DragEvent> & DraggingEventData];
|
|
217
|
+
};
|
|
218
|
+
export interface DraggingEventData {
|
|
219
|
+
/**
|
|
220
|
+
* The data transfer instance.
|
|
221
|
+
*/
|
|
222
|
+
dataTransfer: DataTransfer;
|
|
223
|
+
/**
|
|
224
|
+
* Whether the event was triggered by a paste or a drop operation.
|
|
225
|
+
*/
|
|
226
|
+
method: 'dragover';
|
|
227
|
+
/**
|
|
228
|
+
* The tree view element representing the target.
|
|
229
|
+
*/
|
|
230
|
+
target: Element;
|
|
231
|
+
/**
|
|
232
|
+
* Ranges which are the target of the operation (usually – into which the content should be inserted).
|
|
233
|
+
* It is the drop position (which can be different than the selection at the moment of drop).
|
|
234
|
+
*/
|
|
235
|
+
targetRanges: Array<ViewRange> | null;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Fired when the user starts dragging the content in one of the editing roots of the editor.
|
|
239
|
+
*
|
|
240
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
241
|
+
*
|
|
242
|
+
* **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~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
244
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
245
|
+
* the observer must be added manually.
|
|
246
|
+
*
|
|
247
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
248
|
+
*
|
|
249
|
+
* @eventName module:engine/view/document~Document#dragstart
|
|
250
|
+
* @param data The event data.
|
|
251
|
+
*/
|
|
252
|
+
export type ViewDocumentDragStartEvent = {
|
|
253
|
+
name: 'dragstart';
|
|
254
|
+
args: [data: DomEventData<DragEvent> & ClipboardEventData];
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Fired when the user ended dragging the content.
|
|
258
|
+
*
|
|
259
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
260
|
+
*
|
|
261
|
+
* **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~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
263
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
264
|
+
* the observer must be added manually.
|
|
265
|
+
*
|
|
266
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
267
|
+
*
|
|
268
|
+
* @eventName module:engine/view/document~Document#dragend
|
|
269
|
+
* @param data The event data.
|
|
270
|
+
*/
|
|
271
|
+
export type ViewDocumentDragEndEvent = {
|
|
272
|
+
name: 'dragend';
|
|
273
|
+
args: [data: DomEventData<DragEvent> & ClipboardEventData];
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Fired when the user drags the content into one of the editing roots of the editor.
|
|
277
|
+
*
|
|
278
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
279
|
+
*
|
|
280
|
+
* **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~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
282
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
283
|
+
* the observer must be added manually.
|
|
284
|
+
*
|
|
285
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
286
|
+
*
|
|
287
|
+
* @eventName module:engine/view/document~Document#dragenter
|
|
288
|
+
* @param data The event data.
|
|
289
|
+
*/
|
|
290
|
+
export type ViewDocumentDragEnterEvent = {
|
|
291
|
+
name: 'dragenter';
|
|
292
|
+
args: [data: DomEventData<DragEvent> & ClipboardEventData];
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Fired when the user drags the content out of one of the editing roots of the editor.
|
|
296
|
+
*
|
|
297
|
+
* Introduced by {@link module:clipboard/clipboardobserver~ClipboardObserver}.
|
|
298
|
+
*
|
|
299
|
+
* **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~Document} by using the {@link module:engine/view/view~View#addObserver}
|
|
301
|
+
* method. This is usually done by the {@link module:clipboard/clipboard~Clipboard} plugin, but if for some reason it is not loaded,
|
|
302
|
+
* the observer must be added manually.
|
|
303
|
+
*
|
|
304
|
+
* @see module:engine/view/document~Document#event:clipboardInput
|
|
305
|
+
*
|
|
306
|
+
* @eventName module:engine/view/document~Document#dragleave
|
|
307
|
+
* @param data The event data.
|
|
308
|
+
*/
|
|
309
|
+
export type ViewDocumentDragLeaveEvent = {
|
|
310
|
+
name: 'dragleave';
|
|
311
|
+
args: [data: DomEventData<DragEvent> & ClipboardEventData];
|
|
312
|
+
};
|