@ckeditor/ckeditor5-clipboard 41.3.0-alpha.1 → 41.3.0-alpha.2

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.
Files changed (101) hide show
  1. package/dist/translations/ar.d.ts +8 -0
  2. package/dist/translations/ar.js +5 -0
  3. package/dist/translations/bg.d.ts +8 -0
  4. package/dist/translations/bg.js +5 -0
  5. package/dist/translations/bn.d.ts +8 -0
  6. package/dist/translations/bn.js +5 -0
  7. package/dist/translations/ca.d.ts +8 -0
  8. package/dist/translations/ca.js +5 -0
  9. package/dist/translations/cs.d.ts +8 -0
  10. package/dist/translations/cs.js +5 -0
  11. package/dist/translations/da.d.ts +8 -0
  12. package/dist/translations/da.js +5 -0
  13. package/dist/translations/de.d.ts +8 -0
  14. package/dist/translations/de.js +5 -0
  15. package/dist/translations/el.d.ts +8 -0
  16. package/dist/translations/el.js +5 -0
  17. package/dist/translations/en.d.ts +8 -0
  18. package/dist/translations/en.js +5 -0
  19. package/dist/translations/es.d.ts +8 -0
  20. package/dist/translations/es.js +5 -0
  21. package/dist/translations/et.d.ts +8 -0
  22. package/dist/translations/et.js +5 -0
  23. package/dist/translations/fi.d.ts +8 -0
  24. package/dist/translations/fi.js +5 -0
  25. package/dist/translations/fr.d.ts +8 -0
  26. package/dist/translations/fr.js +5 -0
  27. package/dist/translations/he.d.ts +8 -0
  28. package/dist/translations/he.js +5 -0
  29. package/dist/translations/hi.d.ts +8 -0
  30. package/dist/translations/hi.js +5 -0
  31. package/dist/translations/hr.d.ts +8 -0
  32. package/dist/translations/hr.js +5 -0
  33. package/dist/translations/hu.d.ts +8 -0
  34. package/dist/translations/hu.js +5 -0
  35. package/dist/translations/id.d.ts +8 -0
  36. package/dist/translations/id.js +5 -0
  37. package/dist/translations/it.d.ts +8 -0
  38. package/dist/translations/it.js +5 -0
  39. package/dist/translations/ja.d.ts +8 -0
  40. package/dist/translations/ja.js +5 -0
  41. package/dist/translations/ko.d.ts +8 -0
  42. package/dist/translations/ko.js +5 -0
  43. package/dist/translations/lt.d.ts +8 -0
  44. package/dist/translations/lt.js +5 -0
  45. package/dist/translations/lv.d.ts +8 -0
  46. package/dist/translations/lv.js +5 -0
  47. package/dist/translations/ms.d.ts +8 -0
  48. package/dist/translations/ms.js +5 -0
  49. package/dist/translations/nl.d.ts +8 -0
  50. package/dist/translations/nl.js +5 -0
  51. package/dist/translations/no.d.ts +8 -0
  52. package/dist/translations/no.js +5 -0
  53. package/dist/translations/pl.d.ts +8 -0
  54. package/dist/translations/pl.js +5 -0
  55. package/dist/translations/pt-br.d.ts +8 -0
  56. package/dist/translations/pt-br.js +5 -0
  57. package/dist/translations/pt.d.ts +8 -0
  58. package/dist/translations/pt.js +5 -0
  59. package/dist/translations/ro.d.ts +8 -0
  60. package/dist/translations/ro.js +5 -0
  61. package/dist/translations/ru.d.ts +8 -0
  62. package/dist/translations/ru.js +5 -0
  63. package/dist/translations/sk.d.ts +8 -0
  64. package/dist/translations/sk.js +5 -0
  65. package/dist/translations/sr.d.ts +8 -0
  66. package/dist/translations/sr.js +5 -0
  67. package/dist/translations/sv.d.ts +8 -0
  68. package/dist/translations/sv.js +5 -0
  69. package/dist/translations/th.d.ts +8 -0
  70. package/dist/translations/th.js +5 -0
  71. package/dist/translations/tr.d.ts +8 -0
  72. package/dist/translations/tr.js +5 -0
  73. package/dist/translations/uk.d.ts +8 -0
  74. package/dist/translations/uk.js +5 -0
  75. package/dist/translations/vi.d.ts +8 -0
  76. package/dist/translations/vi.js +5 -0
  77. package/dist/translations/zh-cn.d.ts +8 -0
  78. package/dist/translations/zh-cn.js +5 -0
  79. package/dist/translations/zh.d.ts +8 -0
  80. package/dist/translations/zh.js +5 -0
  81. package/dist/types/augmentation.d.ts +4 -0
  82. package/dist/types/clipboard.d.ts +4 -0
  83. package/dist/types/clipboardmarkersutils.d.ts +43 -25
  84. package/dist/types/clipboardobserver.d.ts +4 -0
  85. package/dist/types/clipboardpipeline.d.ts +4 -0
  86. package/dist/types/dragdrop.d.ts +4 -0
  87. package/dist/types/dragdropblocktoolbar.d.ts +4 -0
  88. package/dist/types/dragdroptarget.d.ts +4 -0
  89. package/dist/types/index.d.ts +5 -1
  90. package/dist/types/lineview.d.ts +4 -0
  91. package/dist/types/pasteplaintext.d.ts +4 -0
  92. package/dist/types/utils/normalizeclipboarddata.d.ts +4 -0
  93. package/dist/types/utils/plaintexttohtml.d.ts +4 -0
  94. package/dist/types/utils/viewtoplaintext.d.ts +4 -0
  95. package/package.json +6 -6
  96. package/src/clipboardmarkersutils.d.ts +39 -25
  97. package/src/clipboardmarkersutils.js +147 -72
  98. package/src/clipboardpipeline.js +8 -9
  99. package/src/index.d.ts +1 -1
  100. package/dist/index.js +0 -2175
  101. package/dist/index.js.map +0 -1
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"tr":{"dictionary":{"Copy selected content":"Seçilen içeriği kopyala","Paste content":"İçeriği yapıştır","Paste content as plain text":"İçeriği düz metin olarak yapıştır"},getPluralForm(n){return (n > 1);}}}
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"uk":{"dictionary":{"Copy selected content":"Копіювати вибраний вміст","Paste content":"Вставити вміст","Paste content as plain text":"Вставити вміст як простий текст"},getPluralForm(n){return (n % 1 == 0 && n % 10 == 1 && n % 100 != 11 ? 0 : n % 1 == 0 && n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14) ? 1 : n % 1 == 0 && (n % 10 ==0 || (n % 10 >=5 && n % 10 <=9) || (n % 100 >=11 && n % 100 <=14 )) ? 2: 3);}}}
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"vi":{"dictionary":{"Copy selected content":"Sao chép nội dung đã chọn","Paste content":"Dán nội dung","Paste content as plain text":"Dán nội dung dưới dạng văn bản thuần túy"},getPluralForm(n){return 0;}}}
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"zh-cn":{"dictionary":{"Copy selected content":"复制选定的内容","Paste content":"粘贴内容","Paste content as plain text":"将内容粘贴为纯文本"},getPluralForm(n){return 0;}}}
@@ -0,0 +1,8 @@
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
+ import type { Translations } from 'ckeditor5';
7
+ declare const translations: Translations;
8
+ export default translations;
@@ -0,0 +1,5 @@
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
+ export default {"zh":{"dictionary":{"Copy selected content":"複製所選內容","Paste content":"貼上內容","Paste content as plain text":"將內容貼上為純文字"},getPluralForm(n){return 0;}}}
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -2,8 +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 { Plugin } from '@ckeditor/ckeditor5-core';
6
- import { Range, type Element, type DocumentFragment, type DocumentSelection, type Selection, type Writer } from '@ckeditor/ckeditor5-engine';
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ import { Plugin, type NonEmptyArray } from '@ckeditor/ckeditor5-core';
10
+ import { Range, type DocumentFragment, type Element, type DocumentSelection, type Selection, type Writer } from '@ckeditor/ckeditor5-engine';
7
11
  /**
8
12
  * Part of the clipboard logic. Responsible for collecting markers from selected fragments
9
13
  * and restoring them with proper positions in pasted elements.
@@ -25,17 +29,10 @@ export default class ClipboardMarkersUtils extends Plugin {
25
29
  * Registers marker name as copyable in clipboard pipeline.
26
30
  *
27
31
  * @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.
32
+ * @param config Configuration that describes what can be performed on specified marker.
29
33
  * @internal
30
34
  */
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;
35
+ _registerMarkerToCopy(markerName: string, config: ClipboardMarkerConfiguration): void;
39
36
  /**
40
37
  * Performs copy markers on provided selection and paste it to fragment returned from `getCopiedFragment`.
41
38
  *
@@ -67,6 +64,7 @@ export default class ClipboardMarkersUtils extends Plugin {
67
64
  *
68
65
  * * `markers` are inserted into the same element that must be later transformed inside `getPastedDocumentElement`.
69
66
  * * Fake marker elements inside `getPastedDocumentElement` can be cloned, but their ranges cannot overlap.
67
+ * * If `duplicateOnPaste` is `true` in marker config then associated marker ID is regenerated before pasting.
70
68
  *
71
69
  * @param action Type of clipboard action.
72
70
  * @param markers Object that maps marker name to corresponding range.
@@ -74,6 +72,15 @@ export default class ClipboardMarkersUtils extends Plugin {
74
72
  * @internal
75
73
  */
76
74
  _pasteMarkersIntoTransformedElement(markers: Record<string, Range> | Map<string, Range>, getPastedDocumentElement: (writer: Writer) => Element): Element;
75
+ /**
76
+ * Pastes document fragment with markers to document.
77
+ * If `duplicateOnPaste` is `true` in marker config then associated markers IDs
78
+ * are regenerated before pasting to avoid markers duplications in content.
79
+ *
80
+ * @param fragment Document fragment that should contain already processed by pipeline markers.
81
+ * @internal
82
+ */
83
+ _pasteFragmentWithMarkers(fragment: DocumentFragment): Range;
77
84
  /**
78
85
  * In some situations we have to perform copy on selected fragment with certain markers. This function allows to temporarily bypass
79
86
  * restrictions on markers that we want to copy.
@@ -83,9 +90,10 @@ export default class ClipboardMarkersUtils extends Plugin {
83
90
  *
84
91
  * @param markerName Which markers should be copied.
85
92
  * @param executor Callback executed.
93
+ * @param config Optional configuration flags used to copy (such like partial copy flag).
86
94
  * @internal
87
95
  */
88
- _forceMarkersCopy(markerName: string, executor: VoidFunction): void;
96
+ _forceMarkersCopy(markerName: string, executor: VoidFunction, config?: ClipboardMarkerConfiguration): void;
89
97
  /**
90
98
  * Checks if marker can be copied.
91
99
  *
@@ -93,14 +101,20 @@ export default class ClipboardMarkersUtils extends Plugin {
93
101
  * @param action Type of clipboard action. If null then checks only if marker is registered as copyable.
94
102
  * @internal
95
103
  */
96
- _canPerformMarkerClipboardAction(markerName: string, action: ClipboardMarkerRestrictedAction | null): boolean;
104
+ _isMarkerCopyable(markerName: string, action: ClipboardMarkerRestrictedAction | null): boolean;
97
105
  /**
98
- * Changes marker names for markers stored in given document fragment so that they are unique.
106
+ * Checks if marker has any clipboard copy behavior configuration.
99
107
  *
100
- * @param fragment
108
+ * @param markerName Name of checked marker.
109
+ */
110
+ _hasMarkerConfiguration(markerName: string): boolean;
111
+ /**
112
+ * Returns marker's configuration flags passed during registration.
113
+ *
114
+ * @param markerName Name of marker that should be returned.
101
115
  * @internal
102
116
  */
103
- _setUniqueMarkerNamesInFragment(fragment: DocumentFragment): void;
117
+ _getMarkerClipboardConfig(markerName: string): ClipboardMarkerConfiguration | null;
104
118
  /**
105
119
  * First step of copying markers. It looks for markers intersecting with given selection and inserts `$marker` elements
106
120
  * at positions where document markers start or end. This way `$marker` elements can be easily copied together with
@@ -114,18 +128,23 @@ export default class ClipboardMarkersUtils extends Plugin {
114
128
  /**
115
129
  * Returns array of markers that can be copied in specified selection.
116
130
  *
131
+ * If marker cannot be copied partially (according to `copyPartiallySelected` configuration flag) and
132
+ * is not present entirely in any selection range then it will be skipped.
133
+ *
117
134
  * @param writer An instance of the model writer.
118
135
  * @param selection Selection which will be checked.
119
136
  * @param action Type of clipboard action. If null then checks only if marker is registered as copyable.
120
137
  */
121
138
  private _getCopyableMarkersFromSelection;
122
139
  /**
123
- * Picks all markers from markers map that can be copied.
140
+ * Picks all markers from markers map that can be pasted.
141
+ * If `duplicateOnPaste` is `true`, it regenerates their IDs to ensure uniqueness.
142
+ * If marker is not registered, it will be kept in the array anyway.
124
143
  *
125
144
  * @param markers Object that maps marker name to corresponding range.
126
145
  * @param action Type of clipboard action. If null then checks only if marker is registered as copyable.
127
146
  */
128
- private _getCopyableMarkersFromRangeMap;
147
+ private _getPasteMarkersFromRangeMap;
129
148
  /**
130
149
  * Inserts specified array of fake markers elements to document and assigns them `type` and `name` attributes.
131
150
  * Fake markers elements are used to calculate position of markers on pasted fragment that were transformed during
@@ -174,13 +193,12 @@ export default class ClipboardMarkersUtils extends Plugin {
174
193
  */
175
194
  export type ClipboardMarkerRestrictedAction = 'copy' | 'cut' | 'dragstart';
176
195
  /**
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.
196
+ * Specifies behavior of markers during clipboard actions.
183
197
  *
184
198
  * @internal
185
199
  */
186
- export type ClipboardMarkerRestrictionsPreset = 'default' | 'always' | 'never';
200
+ export type ClipboardMarkerConfiguration = {
201
+ allowedActions: NonEmptyArray<ClipboardMarkerRestrictedAction> | 'all';
202
+ copyPartiallySelected?: boolean;
203
+ duplicateOnPaste?: boolean;
204
+ };
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -7,7 +11,7 @@
7
11
  */
8
12
  export { default as Clipboard } from './clipboard.js';
9
13
  export { default as ClipboardPipeline, type ClipboardContentInsertionEvent, type ClipboardContentInsertionData, type ClipboardInputTransformationEvent, type ClipboardInputTransformationData, type ClipboardOutputTransformationEvent, type ClipboardOutputTransformationData, type ViewDocumentClipboardOutputEvent } from './clipboardpipeline.js';
10
- export { default as ClipboardMarkersUtils, type ClipboardMarkerRestrictionsPreset, type ClipboardMarkerRestrictedAction } from './clipboardmarkersutils.js';
14
+ export { default as ClipboardMarkersUtils, type ClipboardMarkerRestrictedAction, type ClipboardMarkerConfiguration } from './clipboardmarkersutils.js';
11
15
  export type { ClipboardEventData } from './clipboardobserver.js';
12
16
  export { default as DragDrop } from './dragdrop.js';
13
17
  export { default as PastePlainText } from './pasteplaintext.js';
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
@@ -1,3 +1,7 @@
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
+ */
1
5
  /**
2
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-clipboard",
3
- "version": "41.3.0-alpha.1",
3
+ "version": "41.3.0-alpha.2",
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.3.0-alpha.1",
17
- "@ckeditor/ckeditor5-engine": "41.3.0-alpha.1",
18
- "@ckeditor/ckeditor5-ui": "41.3.0-alpha.1",
19
- "@ckeditor/ckeditor5-utils": "41.3.0-alpha.1",
20
- "@ckeditor/ckeditor5-widget": "41.3.0-alpha.1",
16
+ "@ckeditor/ckeditor5-core": "41.3.0-alpha.2",
17
+ "@ckeditor/ckeditor5-engine": "41.3.0-alpha.2",
18
+ "@ckeditor/ckeditor5-ui": "41.3.0-alpha.2",
19
+ "@ckeditor/ckeditor5-utils": "41.3.0-alpha.2",
20
+ "@ckeditor/ckeditor5-widget": "41.3.0-alpha.2",
21
21
  "lodash-es": "4.17.21"
22
22
  },
23
23
  "author": "CKSource (http://cksource.com/)",
@@ -2,8 +2,8 @@
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 { Plugin } from '@ckeditor/ckeditor5-core';
6
- import { Range, type Element, type DocumentFragment, type DocumentSelection, type Selection, type Writer } from '@ckeditor/ckeditor5-engine';
5
+ import { Plugin, type NonEmptyArray } from '@ckeditor/ckeditor5-core';
6
+ import { Range, type DocumentFragment, type Element, type DocumentSelection, type Selection, type Writer } from '@ckeditor/ckeditor5-engine';
7
7
  /**
8
8
  * Part of the clipboard logic. Responsible for collecting markers from selected fragments
9
9
  * and restoring them with proper positions in pasted elements.
@@ -25,17 +25,10 @@ export default class ClipboardMarkersUtils extends Plugin {
25
25
  * Registers marker name as copyable in clipboard pipeline.
26
26
  *
27
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.
28
+ * @param config Configuration that describes what can be performed on specified marker.
29
29
  * @internal
30
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;
31
+ _registerMarkerToCopy(markerName: string, config: ClipboardMarkerConfiguration): void;
39
32
  /**
40
33
  * Performs copy markers on provided selection and paste it to fragment returned from `getCopiedFragment`.
41
34
  *
@@ -67,6 +60,7 @@ export default class ClipboardMarkersUtils extends Plugin {
67
60
  *
68
61
  * * `markers` are inserted into the same element that must be later transformed inside `getPastedDocumentElement`.
69
62
  * * Fake marker elements inside `getPastedDocumentElement` can be cloned, but their ranges cannot overlap.
63
+ * * If `duplicateOnPaste` is `true` in marker config then associated marker ID is regenerated before pasting.
70
64
  *
71
65
  * @param action Type of clipboard action.
72
66
  * @param markers Object that maps marker name to corresponding range.
@@ -74,6 +68,15 @@ export default class ClipboardMarkersUtils extends Plugin {
74
68
  * @internal
75
69
  */
76
70
  _pasteMarkersIntoTransformedElement(markers: Record<string, Range> | Map<string, Range>, getPastedDocumentElement: (writer: Writer) => Element): Element;
71
+ /**
72
+ * Pastes document fragment with markers to document.
73
+ * If `duplicateOnPaste` is `true` in marker config then associated markers IDs
74
+ * are regenerated before pasting to avoid markers duplications in content.
75
+ *
76
+ * @param fragment Document fragment that should contain already processed by pipeline markers.
77
+ * @internal
78
+ */
79
+ _pasteFragmentWithMarkers(fragment: DocumentFragment): Range;
77
80
  /**
78
81
  * In some situations we have to perform copy on selected fragment with certain markers. This function allows to temporarily bypass
79
82
  * restrictions on markers that we want to copy.
@@ -83,9 +86,10 @@ export default class ClipboardMarkersUtils extends Plugin {
83
86
  *
84
87
  * @param markerName Which markers should be copied.
85
88
  * @param executor Callback executed.
89
+ * @param config Optional configuration flags used to copy (such like partial copy flag).
86
90
  * @internal
87
91
  */
88
- _forceMarkersCopy(markerName: string, executor: VoidFunction): void;
92
+ _forceMarkersCopy(markerName: string, executor: VoidFunction, config?: ClipboardMarkerConfiguration): void;
89
93
  /**
90
94
  * Checks if marker can be copied.
91
95
  *
@@ -93,14 +97,20 @@ export default class ClipboardMarkersUtils extends Plugin {
93
97
  * @param action Type of clipboard action. If null then checks only if marker is registered as copyable.
94
98
  * @internal
95
99
  */
96
- _canPerformMarkerClipboardAction(markerName: string, action: ClipboardMarkerRestrictedAction | null): boolean;
100
+ _isMarkerCopyable(markerName: string, action: ClipboardMarkerRestrictedAction | null): boolean;
97
101
  /**
98
- * Changes marker names for markers stored in given document fragment so that they are unique.
102
+ * Checks if marker has any clipboard copy behavior configuration.
99
103
  *
100
- * @param fragment
104
+ * @param markerName Name of checked marker.
105
+ */
106
+ _hasMarkerConfiguration(markerName: string): boolean;
107
+ /**
108
+ * Returns marker's configuration flags passed during registration.
109
+ *
110
+ * @param markerName Name of marker that should be returned.
101
111
  * @internal
102
112
  */
103
- _setUniqueMarkerNamesInFragment(fragment: DocumentFragment): void;
113
+ _getMarkerClipboardConfig(markerName: string): ClipboardMarkerConfiguration | null;
104
114
  /**
105
115
  * First step of copying markers. It looks for markers intersecting with given selection and inserts `$marker` elements
106
116
  * at positions where document markers start or end. This way `$marker` elements can be easily copied together with
@@ -114,18 +124,23 @@ export default class ClipboardMarkersUtils extends Plugin {
114
124
  /**
115
125
  * Returns array of markers that can be copied in specified selection.
116
126
  *
127
+ * If marker cannot be copied partially (according to `copyPartiallySelected` configuration flag) and
128
+ * is not present entirely in any selection range then it will be skipped.
129
+ *
117
130
  * @param writer An instance of the model writer.
118
131
  * @param selection Selection which will be checked.
119
132
  * @param action Type of clipboard action. If null then checks only if marker is registered as copyable.
120
133
  */
121
134
  private _getCopyableMarkersFromSelection;
122
135
  /**
123
- * Picks all markers from markers map that can be copied.
136
+ * Picks all markers from markers map that can be pasted.
137
+ * If `duplicateOnPaste` is `true`, it regenerates their IDs to ensure uniqueness.
138
+ * If marker is not registered, it will be kept in the array anyway.
124
139
  *
125
140
  * @param markers Object that maps marker name to corresponding range.
126
141
  * @param action Type of clipboard action. If null then checks only if marker is registered as copyable.
127
142
  */
128
- private _getCopyableMarkersFromRangeMap;
143
+ private _getPasteMarkersFromRangeMap;
129
144
  /**
130
145
  * Inserts specified array of fake markers elements to document and assigns them `type` and `name` attributes.
131
146
  * Fake markers elements are used to calculate position of markers on pasted fragment that were transformed during
@@ -174,13 +189,12 @@ export default class ClipboardMarkersUtils extends Plugin {
174
189
  */
175
190
  export type ClipboardMarkerRestrictedAction = 'copy' | 'cut' | 'dragstart';
176
191
  /**
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.
192
+ * Specifies behavior of markers during clipboard actions.
183
193
  *
184
194
  * @internal
185
195
  */
186
- export type ClipboardMarkerRestrictionsPreset = 'default' | 'always' | 'never';
196
+ export type ClipboardMarkerConfiguration = {
197
+ allowedActions: NonEmptyArray<ClipboardMarkerRestrictedAction> | 'all';
198
+ copyPartiallySelected?: boolean;
199
+ duplicateOnPaste?: boolean;
200
+ };