@atlaskit/editor-plugin-paste 1.0.16 → 1.0.17
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 +6 -0
- package/dist/cjs/pm-plugins/clipboard-text-serializer.js +36 -1
- package/dist/es2019/pm-plugins/clipboard-text-serializer.js +36 -1
- package/dist/esm/pm-plugins/clipboard-text-serializer.js +36 -1
- package/dist/types/pm-plugins/clipboard-text-serializer.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/clipboard-text-serializer.d.ts +1 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 1.0.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#92373](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92373) [`6a480276c9b0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6a480276c9b0) - [ux] [ED-23043] Plain text content leading and trailing whitespace is now preserved on paste behind FF (`platform.editor.preserve-whitespace-clipboard-text-serialization`)
|
|
8
|
+
|
|
3
9
|
## 1.0.16
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -4,18 +4,53 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.clipboardTextSerializer = clipboardTextSerializer;
|
|
7
|
+
exports.clipboardTextSerializerSimplified = clipboardTextSerializerSimplified;
|
|
8
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
7
9
|
/**
|
|
8
10
|
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
9
11
|
* section of the clipboard on copy.
|
|
10
12
|
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
11
13
|
* previously were empty on plain text copy).
|
|
12
|
-
* Unknown nodes are passed to node.textBetween().
|
|
13
14
|
*
|
|
14
15
|
* By default (without this function passed to the editor), the editor uses
|
|
15
16
|
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
16
17
|
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
17
18
|
*/
|
|
18
19
|
function clipboardTextSerializer(slice) {
|
|
20
|
+
if (
|
|
21
|
+
// Enables bugfix - https://product-fabric.atlassian.net/browse/ED-23043
|
|
22
|
+
(0, _platformFeatureFlags.getBooleanFF)('platform.editor.preserve-whitespace-clipboard-text-serialization')) {
|
|
23
|
+
return clipboardTextSerializerSimplified(slice);
|
|
24
|
+
} else {
|
|
25
|
+
return clipboardTextSerializerLegacy(slice);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function clipboardTextSerializerSimplified(slice) {
|
|
29
|
+
var blockSeparator = '\n\n';
|
|
30
|
+
return slice.content.textBetween(0, slice.content.size, blockSeparator, function (leafNode) {
|
|
31
|
+
var _leafNode$text;
|
|
32
|
+
switch (leafNode.type.name) {
|
|
33
|
+
case 'hardBreak':
|
|
34
|
+
return '\n';
|
|
35
|
+
case 'text':
|
|
36
|
+
return leafNode.text;
|
|
37
|
+
case 'inlineCard':
|
|
38
|
+
return leafNode.attrs.url;
|
|
39
|
+
case 'blockCard':
|
|
40
|
+
return leafNode.attrs.url;
|
|
41
|
+
// Note: Due to relying on an async fetch of the Mention name by the Node's React component,
|
|
42
|
+
// pasting a mention does not actually work for the in-product Mention implementation.
|
|
43
|
+
// However, this is also true of the previous implementation.
|
|
44
|
+
// Bug ticket: https://product-fabric.atlassian.net/browse/ED-23076
|
|
45
|
+
case 'mention':
|
|
46
|
+
return leafNode.attrs.text;
|
|
47
|
+
default:
|
|
48
|
+
// Unsupported node
|
|
49
|
+
return (_leafNode$text = leafNode.text) !== null && _leafNode$text !== void 0 ? _leafNode$text : '';
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function clipboardTextSerializerLegacy(slice) {
|
|
19
54
|
var text = '';
|
|
20
55
|
var blockSeparater = '\n\n';
|
|
21
56
|
slice.content.nodesBetween(0, slice.content.size, function (node) {
|
|
@@ -1,15 +1,50 @@
|
|
|
1
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
3
5
|
* section of the clipboard on copy.
|
|
4
6
|
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
5
7
|
* previously were empty on plain text copy).
|
|
6
|
-
* Unknown nodes are passed to node.textBetween().
|
|
7
8
|
*
|
|
8
9
|
* By default (without this function passed to the editor), the editor uses
|
|
9
10
|
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
10
11
|
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
11
12
|
*/
|
|
12
13
|
export function clipboardTextSerializer(slice) {
|
|
14
|
+
if (
|
|
15
|
+
// Enables bugfix - https://product-fabric.atlassian.net/browse/ED-23043
|
|
16
|
+
getBooleanFF('platform.editor.preserve-whitespace-clipboard-text-serialization')) {
|
|
17
|
+
return clipboardTextSerializerSimplified(slice);
|
|
18
|
+
} else {
|
|
19
|
+
return clipboardTextSerializerLegacy(slice);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function clipboardTextSerializerSimplified(slice) {
|
|
23
|
+
const blockSeparator = '\n\n';
|
|
24
|
+
return slice.content.textBetween(0, slice.content.size, blockSeparator, leafNode => {
|
|
25
|
+
var _leafNode$text;
|
|
26
|
+
switch (leafNode.type.name) {
|
|
27
|
+
case 'hardBreak':
|
|
28
|
+
return '\n';
|
|
29
|
+
case 'text':
|
|
30
|
+
return leafNode.text;
|
|
31
|
+
case 'inlineCard':
|
|
32
|
+
return leafNode.attrs.url;
|
|
33
|
+
case 'blockCard':
|
|
34
|
+
return leafNode.attrs.url;
|
|
35
|
+
// Note: Due to relying on an async fetch of the Mention name by the Node's React component,
|
|
36
|
+
// pasting a mention does not actually work for the in-product Mention implementation.
|
|
37
|
+
// However, this is also true of the previous implementation.
|
|
38
|
+
// Bug ticket: https://product-fabric.atlassian.net/browse/ED-23076
|
|
39
|
+
case 'mention':
|
|
40
|
+
return leafNode.attrs.text;
|
|
41
|
+
default:
|
|
42
|
+
// Unsupported node
|
|
43
|
+
return (_leafNode$text = leafNode.text) !== null && _leafNode$text !== void 0 ? _leafNode$text : '';
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function clipboardTextSerializerLegacy(slice) {
|
|
13
48
|
let text = '';
|
|
14
49
|
const blockSeparater = '\n\n';
|
|
15
50
|
slice.content.nodesBetween(0, slice.content.size, node => {
|
|
@@ -1,15 +1,50 @@
|
|
|
1
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
3
5
|
* section of the clipboard on copy.
|
|
4
6
|
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
5
7
|
* previously were empty on plain text copy).
|
|
6
|
-
* Unknown nodes are passed to node.textBetween().
|
|
7
8
|
*
|
|
8
9
|
* By default (without this function passed to the editor), the editor uses
|
|
9
10
|
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
10
11
|
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
11
12
|
*/
|
|
12
13
|
export function clipboardTextSerializer(slice) {
|
|
14
|
+
if (
|
|
15
|
+
// Enables bugfix - https://product-fabric.atlassian.net/browse/ED-23043
|
|
16
|
+
getBooleanFF('platform.editor.preserve-whitespace-clipboard-text-serialization')) {
|
|
17
|
+
return clipboardTextSerializerSimplified(slice);
|
|
18
|
+
} else {
|
|
19
|
+
return clipboardTextSerializerLegacy(slice);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function clipboardTextSerializerSimplified(slice) {
|
|
23
|
+
var blockSeparator = '\n\n';
|
|
24
|
+
return slice.content.textBetween(0, slice.content.size, blockSeparator, function (leafNode) {
|
|
25
|
+
var _leafNode$text;
|
|
26
|
+
switch (leafNode.type.name) {
|
|
27
|
+
case 'hardBreak':
|
|
28
|
+
return '\n';
|
|
29
|
+
case 'text':
|
|
30
|
+
return leafNode.text;
|
|
31
|
+
case 'inlineCard':
|
|
32
|
+
return leafNode.attrs.url;
|
|
33
|
+
case 'blockCard':
|
|
34
|
+
return leafNode.attrs.url;
|
|
35
|
+
// Note: Due to relying on an async fetch of the Mention name by the Node's React component,
|
|
36
|
+
// pasting a mention does not actually work for the in-product Mention implementation.
|
|
37
|
+
// However, this is also true of the previous implementation.
|
|
38
|
+
// Bug ticket: https://product-fabric.atlassian.net/browse/ED-23076
|
|
39
|
+
case 'mention':
|
|
40
|
+
return leafNode.attrs.text;
|
|
41
|
+
default:
|
|
42
|
+
// Unsupported node
|
|
43
|
+
return (_leafNode$text = leafNode.text) !== null && _leafNode$text !== void 0 ? _leafNode$text : '';
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function clipboardTextSerializerLegacy(slice) {
|
|
13
48
|
var text = '';
|
|
14
49
|
var blockSeparater = '\n\n';
|
|
15
50
|
slice.content.nodesBetween(0, slice.content.size, function (node) {
|
|
@@ -4,10 +4,10 @@ import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
* section of the clipboard on copy.
|
|
5
5
|
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
6
6
|
* previously were empty on plain text copy).
|
|
7
|
-
* Unknown nodes are passed to node.textBetween().
|
|
8
7
|
*
|
|
9
8
|
* By default (without this function passed to the editor), the editor uses
|
|
10
9
|
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
11
10
|
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
12
11
|
*/
|
|
13
12
|
export declare function clipboardTextSerializer(slice: Slice): string;
|
|
13
|
+
export declare function clipboardTextSerializerSimplified(slice: Slice): string;
|
|
@@ -4,10 +4,10 @@ import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
* section of the clipboard on copy.
|
|
5
5
|
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
6
6
|
* previously were empty on plain text copy).
|
|
7
|
-
* Unknown nodes are passed to node.textBetween().
|
|
8
7
|
*
|
|
9
8
|
* By default (without this function passed to the editor), the editor uses
|
|
10
9
|
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
11
10
|
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
12
11
|
*/
|
|
13
12
|
export declare function clipboardTextSerializer(slice: Slice): string;
|
|
13
|
+
export declare function clipboardTextSerializerSimplified(slice: Slice): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/editor-common": "^78.
|
|
36
|
+
"@atlaskit/editor-common": "^78.30.0",
|
|
37
37
|
"@atlaskit/editor-markdown-transformer": "^5.4.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-annotation": "^1.5.0",
|
|
@@ -141,6 +141,9 @@
|
|
|
141
141
|
},
|
|
142
142
|
"platform.editor.extractlistfromparagraphv2": {
|
|
143
143
|
"type": "boolean"
|
|
144
|
+
},
|
|
145
|
+
"platform.editor.preserve-whitespace-clipboard-text-serialization": {
|
|
146
|
+
"type": "boolean"
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
}
|