@ckeditor/ckeditor5-clipboard 41.1.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/lang/contexts.json +5 -0
- package/lang/translations/ar.po +30 -0
- package/lang/translations/bg.po +30 -0
- package/lang/translations/bn.po +30 -0
- package/lang/translations/ca.po +30 -0
- package/lang/translations/cs.po +30 -0
- package/lang/translations/da.po +30 -0
- package/lang/translations/de.po +30 -0
- package/lang/translations/el.po +30 -0
- package/lang/translations/en.po +30 -0
- package/lang/translations/es.po +30 -0
- package/lang/translations/et.po +30 -0
- package/lang/translations/fi.po +30 -0
- package/lang/translations/fr.po +30 -0
- package/lang/translations/he.po +30 -0
- package/lang/translations/hi.po +30 -0
- package/lang/translations/hr.po +30 -0
- package/lang/translations/hu.po +30 -0
- package/lang/translations/id.po +30 -0
- package/lang/translations/it.po +30 -0
- package/lang/translations/ja.po +30 -0
- package/lang/translations/ko.po +30 -0
- package/lang/translations/lt.po +30 -0
- package/lang/translations/lv.po +30 -0
- package/lang/translations/ms.po +30 -0
- package/lang/translations/nl.po +30 -0
- package/lang/translations/no.po +30 -0
- package/lang/translations/pl.po +30 -0
- package/lang/translations/pt-br.po +30 -0
- package/lang/translations/pt.po +30 -0
- package/lang/translations/ro.po +30 -0
- package/lang/translations/ru.po +30 -0
- package/lang/translations/sk.po +30 -0
- package/lang/translations/sr.po +30 -0
- package/lang/translations/sv.po +30 -0
- package/lang/translations/th.po +30 -0
- package/lang/translations/tr.po +30 -0
- package/lang/translations/uk.po +30 -0
- package/lang/translations/vi.po +30 -0
- package/lang/translations/zh-cn.po +30 -0
- package/lang/translations/zh.po +30 -0
- package/package.json +7 -6
- package/src/augmentation.d.ts +2 -1
- package/src/clipboard.d.ts +6 -1
- package/src/clipboard.js +26 -1
- package/src/clipboardmarkersutils.d.ts +186 -0
- package/src/clipboardmarkersutils.js +424 -0
- package/src/clipboardpipeline.d.ts +5 -0
- package/src/clipboardpipeline.js +14 -2
- package/src/index.d.ts +2 -1
- package/src/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-clipboard",
|
|
3
|
-
"version": "41.
|
|
3
|
+
"version": "41.3.0-alpha.0",
|
|
4
4
|
"description": "Clipboard integration feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "src/index.js",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@ckeditor/ckeditor5-core": "41.
|
|
17
|
-
"@ckeditor/ckeditor5-engine": "41.
|
|
18
|
-
"@ckeditor/ckeditor5-ui": "41.
|
|
19
|
-
"@ckeditor/ckeditor5-utils": "41.
|
|
20
|
-
"@ckeditor/ckeditor5-widget": "41.
|
|
16
|
+
"@ckeditor/ckeditor5-core": "41.3.0-alpha.0",
|
|
17
|
+
"@ckeditor/ckeditor5-engine": "41.3.0-alpha.0",
|
|
18
|
+
"@ckeditor/ckeditor5-ui": "41.3.0-alpha.0",
|
|
19
|
+
"@ckeditor/ckeditor5-utils": "41.3.0-alpha.0",
|
|
20
|
+
"@ckeditor/ckeditor5-widget": "41.3.0-alpha.0",
|
|
21
21
|
"lodash-es": "4.17.21"
|
|
22
22
|
},
|
|
23
23
|
"author": "CKSource (http://cksource.com/)",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"directory": "packages/ckeditor5-clipboard"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
|
+
"dist",
|
|
33
34
|
"lang",
|
|
34
35
|
"src/**/*.js",
|
|
35
36
|
"src/**/*.d.ts",
|
package/src/augmentation.d.ts
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
import type { Clipboard, ClipboardPipeline, PastePlainText, DragDrop, DragDropTarget, DragDropBlockToolbar } from './index.js';
|
|
5
|
+
import type { Clipboard, ClipboardPipeline, PastePlainText, DragDrop, DragDropTarget, DragDropBlockToolbar, ClipboardMarkersUtils } from './index.js';
|
|
6
6
|
declare module '@ckeditor/ckeditor5-core' {
|
|
7
7
|
interface PluginsMap {
|
|
8
8
|
[Clipboard.pluginName]: Clipboard;
|
|
9
9
|
[ClipboardPipeline.pluginName]: ClipboardPipeline;
|
|
10
|
+
[ClipboardMarkersUtils.pluginName]: ClipboardMarkersUtils;
|
|
10
11
|
[PastePlainText.pluginName]: PastePlainText;
|
|
11
12
|
[DragDrop.pluginName]: DragDrop;
|
|
12
13
|
[DragDropTarget.pluginName]: DragDropTarget;
|
package/src/clipboard.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
|
9
9
|
import ClipboardPipeline from './clipboardpipeline.js';
|
|
10
10
|
import DragDrop from './dragdrop.js';
|
|
11
11
|
import PastePlainText from './pasteplaintext.js';
|
|
12
|
+
import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
12
13
|
/**
|
|
13
14
|
* The clipboard feature.
|
|
14
15
|
*
|
|
@@ -27,5 +28,9 @@ export default class Clipboard extends Plugin {
|
|
|
27
28
|
/**
|
|
28
29
|
* @inheritDoc
|
|
29
30
|
*/
|
|
30
|
-
static get requires(): readonly [typeof ClipboardPipeline, typeof DragDrop, typeof PastePlainText];
|
|
31
|
+
static get requires(): readonly [typeof ClipboardMarkersUtils, typeof ClipboardPipeline, typeof DragDrop, typeof PastePlainText];
|
|
32
|
+
/**
|
|
33
|
+
* @inheritDoc
|
|
34
|
+
*/
|
|
35
|
+
init(): void;
|
|
31
36
|
}
|
package/src/clipboard.js
CHANGED
|
@@ -9,6 +9,7 @@ import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
|
9
9
|
import ClipboardPipeline from './clipboardpipeline.js';
|
|
10
10
|
import DragDrop from './dragdrop.js';
|
|
11
11
|
import PastePlainText from './pasteplaintext.js';
|
|
12
|
+
import ClipboardMarkersUtils from './clipboardmarkersutils.js';
|
|
12
13
|
/**
|
|
13
14
|
* The clipboard feature.
|
|
14
15
|
*
|
|
@@ -30,6 +31,30 @@ export default class Clipboard extends Plugin {
|
|
|
30
31
|
* @inheritDoc
|
|
31
32
|
*/
|
|
32
33
|
static get requires() {
|
|
33
|
-
return [ClipboardPipeline, DragDrop, PastePlainText];
|
|
34
|
+
return [ClipboardMarkersUtils, ClipboardPipeline, DragDrop, PastePlainText];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
init() {
|
|
40
|
+
const editor = this.editor;
|
|
41
|
+
const t = this.editor.t;
|
|
42
|
+
// Add the information about the keystrokes to the accessibility database.
|
|
43
|
+
editor.accessibility.addKeystrokeInfos({
|
|
44
|
+
keystrokes: [
|
|
45
|
+
{
|
|
46
|
+
label: t('Copy selected content'),
|
|
47
|
+
keystroke: 'CTRL+C'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: t('Paste content'),
|
|
51
|
+
keystroke: 'CTRL+V'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: t('Paste content as plain text'),
|
|
55
|
+
keystroke: 'CTRL+SHIFT+V'
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
});
|
|
34
59
|
}
|
|
35
60
|
}
|
|
@@ -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';
|