@ckeditor/ckeditor5-clipboard 42.0.2 → 43.0.0-alpha.1
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/CHANGELOG.md +1 -177
- package/dist/index.js +36 -18
- package/dist/index.js.map +1 -1
- package/dist/translations/sr-latn.d.ts +8 -0
- package/dist/translations/sr-latn.js +5 -0
- package/dist/translations/sr-latn.umd.js +11 -0
- package/lang/translations/sr-latn.po +30 -0
- package/package.json +6 -6
- package/src/pasteplaintext.js +32 -18
- package/src/utils/viewtoplaintext.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,180 +1,4 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
-
All changes in the package are documented in
|
|
5
|
-
|
|
6
|
-
Changes for the past releases are available below.
|
|
7
|
-
|
|
8
|
-
## [19.0.0](https://github.com/ckeditor/ckeditor5-clipboard/compare/v18.0.0...v19.0.0) (April 29, 2020)
|
|
9
|
-
|
|
10
|
-
### Other changes
|
|
11
|
-
|
|
12
|
-
* Handled `paste` and `drop` events no longer propagate up the DOM tree. Closes [ckeditor/ckeditor5#6464](https://github.com/ckeditor/ckeditor5/issues/6464). ([70aa7ba](https://github.com/ckeditor/ckeditor5-clipboard/commit/70aa7ba))
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## [18.0.0](https://github.com/ckeditor/ckeditor5-clipboard/compare/v17.0.0...v18.0.0) (March 19, 2020)
|
|
16
|
-
|
|
17
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## [17.0.0](https://github.com/ckeditor/ckeditor5-clipboard/compare/v16.0.0...v17.0.0) (February 19, 2020)
|
|
21
|
-
|
|
22
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
## [16.0.0](https://github.com/ckeditor/ckeditor5-clipboard/compare/v15.0.0...v16.0.0) (December 4, 2019)
|
|
26
|
-
|
|
27
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## [15.0.0](https://github.com/ckeditor/ckeditor5-clipboard/compare/v12.0.2...v15.0.0) (October 23, 2019)
|
|
31
|
-
|
|
32
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
## [12.0.2](https://github.com/ckeditor/ckeditor5-clipboard/compare/v12.0.1...v12.0.2) (August 26, 2019)
|
|
36
|
-
|
|
37
|
-
### Other changes
|
|
38
|
-
|
|
39
|
-
* The issue tracker for this package was moved to https://github.com/ckeditor/ckeditor5/issues. See [ckeditor/ckeditor5#1988](https://github.com/ckeditor/ckeditor5/issues/1988). ([b1782bb](https://github.com/ckeditor/ckeditor5-clipboard/commit/b1782bb))
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
## [12.0.1](https://github.com/ckeditor/ckeditor5-clipboard/compare/v12.0.0...v12.0.1) (July 10, 2019)
|
|
43
|
-
|
|
44
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
## [12.0.0](https://github.com/ckeditor/ckeditor5-clipboard/compare/v11.0.2...v12.0.0) (July 4, 2019)
|
|
48
|
-
|
|
49
|
-
### Other changes
|
|
50
|
-
|
|
51
|
-
* New lines pasted as a plain text will always create a new paragraph. Closes [ckeditor/ckeditor5#1727](https://github.com/ckeditor/ckeditor5/issues/1727). ([f0eb3a0](https://github.com/ckeditor/ckeditor5-clipboard/commit/f0eb3a0))
|
|
52
|
-
|
|
53
|
-
### BREAKING CHANGES
|
|
54
|
-
|
|
55
|
-
* From now on, every new line pasted in the editor as a plain text, will create a new paragraph. Read more at [ckeditor/ckeditor5#1727](https://github.com/ckeditor/ckeditor5/issues/1727).
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## [11.0.2](https://github.com/ckeditor/ckeditor5-clipboard/compare/v11.0.1...v11.0.2) (June 6, 2019)
|
|
59
|
-
|
|
60
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## [11.0.1](https://github.com/ckeditor/ckeditor5-clipboard/compare/v11.0.0...v11.0.1) (April 4, 2019)
|
|
64
|
-
|
|
65
|
-
### Bug fixes
|
|
66
|
-
|
|
67
|
-
* The DOM `drop` event will not bubble up if the `clipboardInput` event was handled. Closes [ckeditor/ckeditor5-upload#92](https://github.com/ckeditor/ckeditor5-upload/issues/92). ([5d14697](https://github.com/ckeditor/ckeditor5-clipboard/commit/5d14697))
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
## [11.0.0](https://github.com/ckeditor/ckeditor5-clipboard/compare/v10.0.4...v11.0.0) (February 28, 2019)
|
|
71
|
-
|
|
72
|
-
### BREAKING CHANGES
|
|
73
|
-
|
|
74
|
-
* Upgraded minimal versions of Node to `8.0.0` and npm to `5.7.1`. See: [ckeditor/ckeditor5#1507](https://github.com/ckeditor/ckeditor5/issues/1507). ([612ea3c](https://github.com/ckeditor/ckeditor5-cloud-services/commit/612ea3c))
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
## [10.0.4](https://github.com/ckeditor/ckeditor5-clipboard/compare/v10.0.3...v10.0.4) (December 5, 2018)
|
|
78
|
-
|
|
79
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
## [10.0.3](https://github.com/ckeditor/ckeditor5-clipboard/compare/v10.0.2...v10.0.3) (October 8, 2018)
|
|
83
|
-
|
|
84
|
-
### Other changes
|
|
85
|
-
|
|
86
|
-
* The `Clipboard#inputTransformation` event is now emitted with an additional `dataTransfer` object. Closes [#54](https://github.com/ckeditor/ckeditor5-clipboard/issues/54) . ([f3589b4](https://github.com/ckeditor/ckeditor5-clipboard/commit/f3589b4))
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
## [10.0.2](https://github.com/ckeditor/ckeditor5-clipboard/compare/v10.0.1...v10.0.2) (July 18, 2018)
|
|
90
|
-
|
|
91
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
## [10.0.1](https://github.com/ckeditor/ckeditor5-clipboard/compare/v10.0.0...v10.0.1) (June 21, 2018)
|
|
95
|
-
|
|
96
|
-
### Bug fixes
|
|
97
|
-
|
|
98
|
-
* Disabled the entire clipboard input pipeline when the editor is read-only. Closes [#48](https://github.com/ckeditor/ckeditor5-clipboard/issues/48). ([b40ec4b](https://github.com/ckeditor/ckeditor5-clipboard/commit/b40ec4b))
|
|
99
|
-
* When pasting a plain text, single new line characters should be converted to `<br>`s. Closes [ckeditor/ckeditor5#766](https://github.com/ckeditor/ckeditor5/issues/766). ([be21676](https://github.com/ckeditor/ckeditor5-clipboard/commit/be21676))
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
## [10.0.0](https://github.com/ckeditor/ckeditor5-clipboard/compare/v1.0.0-beta.4...v10.0.0) (April 25, 2018)
|
|
103
|
-
|
|
104
|
-
### Other changes
|
|
105
|
-
|
|
106
|
-
* Changed the license to GPL2+ only. See [ckeditor/ckeditor5#991](https://github.com/ckeditor/ckeditor5/issues/991). ([8c092af](https://github.com/ckeditor/ckeditor5-clipboard/commit/8c092af))
|
|
107
|
-
|
|
108
|
-
### BREAKING CHANGES
|
|
109
|
-
|
|
110
|
-
* The license under which CKEditor 5 is released has been changed from a triple GPL, LGPL and MPL license to a GPL2+ only. See [ckeditor/ckeditor5#991](https://github.com/ckeditor/ckeditor5/issues/991) for more information.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-clipboard/compare/v1.0.0-beta.2...v1.0.0-beta.4) (April 19, 2018)
|
|
114
|
-
|
|
115
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-clipboard/compare/v1.0.0-beta.1...v1.0.0-beta.2) (April 10, 2018)
|
|
119
|
-
|
|
120
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-clipboard/compare/v1.0.0-alpha.2...v1.0.0-beta.1) (March 15, 2018)
|
|
124
|
-
|
|
125
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-clipboard/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (November 14, 2017)
|
|
129
|
-
|
|
130
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-clipboard/compare/v0.7.0...v1.0.0-alpha.1) (October 3, 2017)
|
|
134
|
-
|
|
135
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
## [0.7.0](https://github.com/ckeditor/ckeditor5-clipboard/compare/v0.6.0...v0.7.0) (September 3, 2017)
|
|
139
|
-
|
|
140
|
-
### Bug fixes
|
|
141
|
-
|
|
142
|
-
* Whitespaces around inline elements will not be lost upon pasting. Closes [#24](https://github.com/ckeditor/ckeditor5-clipboard/issues/24). ([5888743](https://github.com/ckeditor/ckeditor5-clipboard/commit/5888743))
|
|
143
|
-
|
|
144
|
-
### Features
|
|
145
|
-
|
|
146
|
-
* Added the `'dragover'` event to ClipboardObserver. ([00c7567](https://github.com/ckeditor/ckeditor5-clipboard/commit/00c7567))
|
|
147
|
-
* Added `dropRange` to the `drop` event and `targetRanges` to the `clipboardInput` event. Closes [#29](https://github.com/ckeditor/ckeditor5-clipboard/issues/29). ([86daed9](https://github.com/ckeditor/ckeditor5-clipboard/commit/86daed9))
|
|
148
|
-
* Disable pasting and cutting when the editor is read-only. Closes [#26](https://github.com/ckeditor/ckeditor5-clipboard/issues/26). ([0ba74d5](https://github.com/ckeditor/ckeditor5-clipboard/commit/0ba74d5))
|
|
149
|
-
* The viewport will be scrolled to the selection on paste. See ckeditor/ckeditor5-engine#660. ([9a0e20f](https://github.com/ckeditor/ckeditor5-clipboard/commit/9a0e20f))
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
## [0.6.0](https://github.com/ckeditor/ckeditor5-clipboard/compare/v0.5.0...v0.6.0) (May 7, 2017)
|
|
153
|
-
|
|
154
|
-
### Bug fixes
|
|
155
|
-
|
|
156
|
-
* Plain text data is now available in the clipboard when copying or cutting the editor contents. Closes [#11](https://github.com/ckeditor/ckeditor5-clipboard/issues/11). ([8a01e0f](https://github.com/ckeditor/ckeditor5-clipboard/commit/8a01e0f))
|
|
157
|
-
|
|
158
|
-
### Features
|
|
159
|
-
|
|
160
|
-
* Introduced `DataTransfer#files` property. Change the clipboard input pipeline. Closes [#16](https://github.com/ckeditor/ckeditor5-clipboard/issues/16). ([e4e7e10](https://github.com/ckeditor/ckeditor5-clipboard/commit/e4e7e10))
|
|
161
|
-
|
|
162
|
-
### BREAKING CHANGES
|
|
163
|
-
|
|
164
|
-
* The `clipboardInput` event now contains only the `dataTransfer` property (`content` was removed). The separate `inputTransformation` event was introduced for the content transformations.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
## [0.5.0](https://github.com/ckeditor/ckeditor5-clipboard/compare/v0.4.1...v0.5.0) (April 5, 2017)
|
|
168
|
-
|
|
169
|
-
### Other changes
|
|
170
|
-
|
|
171
|
-
* Aligned use of the `DataController` to the latest API. Closes [#14](https://github.com/ckeditor/ckeditor5-clipboard/issues/14). ([8f98e2b](https://github.com/ckeditor/ckeditor5-clipboard/commit/8f98e2b))
|
|
172
|
-
|
|
173
|
-
### Features
|
|
174
|
-
|
|
175
|
-
* Named existing plugin(s). ([3d37f53](https://github.com/ckeditor/ckeditor5-clipboard/commit/3d37f53))
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
## [0.4.1](https://github.com/ckeditor/ckeditor5-clipboard/compare/v0.4.0...v0.4.1) (March 6, 2017)
|
|
179
|
-
|
|
180
|
-
Internal changes only (updated dependencies, documentation, etc.).
|
|
4
|
+
All changes in the package are documented in https://github.com/ckeditor/ckeditor5/blob/master/CHANGELOG.md.
|
package/dist/index.js
CHANGED
|
@@ -228,6 +228,10 @@ const listElements = [
|
|
|
228
228
|
// Add small padding between selected container elements.
|
|
229
229
|
return '\n';
|
|
230
230
|
}
|
|
231
|
+
// Do not add padding around the elements that won't be rendered.
|
|
232
|
+
if (element.is('element') && element.getCustomProperty('dataPipeline:transparentRendering') || previous.is('element') && previous.getCustomProperty('dataPipeline:transparentRendering')) {
|
|
233
|
+
return '';
|
|
234
|
+
}
|
|
231
235
|
// Add empty lines between container elements.
|
|
232
236
|
return '\n\n';
|
|
233
237
|
}
|
|
@@ -2045,17 +2049,10 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
2045
2049
|
const editor = this.editor;
|
|
2046
2050
|
const model = editor.model;
|
|
2047
2051
|
const view = editor.editing.view;
|
|
2048
|
-
const viewDocument = view.document;
|
|
2049
2052
|
const selection = model.document.selection;
|
|
2050
|
-
let shiftPressed = false;
|
|
2051
2053
|
view.addObserver(ClipboardObserver);
|
|
2052
|
-
this.listenTo(viewDocument, 'keydown', (evt, data)=>{
|
|
2053
|
-
shiftPressed = data.shiftKey;
|
|
2054
|
-
});
|
|
2055
2054
|
editor.plugins.get(ClipboardPipeline).on('contentInsertion', (evt, data)=>{
|
|
2056
|
-
|
|
2057
|
-
// preserve selection attributes on pasted items.
|
|
2058
|
-
if (!shiftPressed && !isPlainTextFragment(data.content, model.schema)) {
|
|
2055
|
+
if (!isUnformattedInlineContent(data.content, model)) {
|
|
2059
2056
|
return;
|
|
2060
2057
|
}
|
|
2061
2058
|
model.change((writer)=>{
|
|
@@ -2072,8 +2069,10 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
2072
2069
|
textAttributes.push(...selection.getAttributes());
|
|
2073
2070
|
const range = writer.createRangeIn(data.content);
|
|
2074
2071
|
for (const item of range.getItems()){
|
|
2075
|
-
|
|
2076
|
-
|
|
2072
|
+
for (const attribute of textAttributes){
|
|
2073
|
+
if (model.schema.checkAttribute(item, attribute[0])) {
|
|
2074
|
+
writer.setAttribute(attribute[0], attribute[1], item);
|
|
2075
|
+
}
|
|
2077
2076
|
}
|
|
2078
2077
|
}
|
|
2079
2078
|
});
|
|
@@ -2081,16 +2080,35 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
2081
2080
|
}
|
|
2082
2081
|
}
|
|
2083
2082
|
/**
|
|
2084
|
-
* Returns true if specified `documentFragment` represents
|
|
2085
|
-
*/ function
|
|
2086
|
-
|
|
2087
|
-
|
|
2083
|
+
* Returns true if specified `documentFragment` represents the unformatted inline content.
|
|
2084
|
+
*/ function isUnformattedInlineContent(documentFragment, model) {
|
|
2085
|
+
let range = model.createRangeIn(documentFragment);
|
|
2086
|
+
// We consider three scenarios here. The document fragment may include:
|
|
2087
|
+
//
|
|
2088
|
+
// 1. Only text and inline objects. Then it could be unformatted inline content.
|
|
2089
|
+
// 2. Exactly one block element on top-level, eg. <p>Foobar</p> or <h2>Title</h2>.
|
|
2090
|
+
// In this case, check this element content, it could be treated as unformatted inline content.
|
|
2091
|
+
// 3. More block elements or block objects, then it is not unformatted inline content.
|
|
2092
|
+
//
|
|
2093
|
+
// We will check for scenario 2. specifically, and if it happens, we will unwrap it and follow with the regular algorithm.
|
|
2094
|
+
//
|
|
2095
|
+
if (documentFragment.childCount == 1) {
|
|
2096
|
+
const child = documentFragment.getChild(0);
|
|
2097
|
+
if (child.is('element') && model.schema.isBlock(child) && !model.schema.isObject(child) && !model.schema.isLimit(child)) {
|
|
2098
|
+
// Scenario 2. as described above.
|
|
2099
|
+
range = model.createRangeIn(child);
|
|
2100
|
+
}
|
|
2088
2101
|
}
|
|
2089
|
-
const child
|
|
2090
|
-
|
|
2091
|
-
|
|
2102
|
+
for (const child of range.getItems()){
|
|
2103
|
+
if (!model.schema.isInline(child)) {
|
|
2104
|
+
return false;
|
|
2105
|
+
}
|
|
2106
|
+
const attributeKeys = Array.from(child.getAttributeKeys());
|
|
2107
|
+
if (attributeKeys.find((key)=>model.schema.getAttributeProperties(key).isFormatting)) {
|
|
2108
|
+
return false;
|
|
2109
|
+
}
|
|
2092
2110
|
}
|
|
2093
|
-
return
|
|
2111
|
+
return true;
|
|
2094
2112
|
}
|
|
2095
2113
|
|
|
2096
2114
|
/**
|