@atlaskit/editor-plugin-paste 8.5.1 → 8.6.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/CHANGELOG.md +8 -0
- package/dist/cjs/pm-plugins/create-clipboard-text-serializer.js +46 -0
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/es2019/pm-plugins/create-clipboard-text-serializer.js +40 -0
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/esm/pm-plugins/create-clipboard-text-serializer.js +40 -0
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/types/pm-plugins/create-clipboard-text-serializer.d.ts +13 -0
- package/dist/types-ts4.5/pm-plugins/create-clipboard-text-serializer.d.ts +13 -0
- package/package.json +1 -4
- package/dist/cjs/pm-plugins/clipboard-text-serializer.js +0 -86
- package/dist/es2019/pm-plugins/clipboard-text-serializer.js +0 -79
- package/dist/esm/pm-plugins/clipboard-text-serializer.js +0 -79
- package/dist/types/pm-plugins/clipboard-text-serializer.d.ts +0 -27
- package/dist/types-ts4.5/pm-plugins/clipboard-text-serializer.d.ts +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 8.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`ad3f33096c4c2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ad3f33096c4c2) -
|
|
8
|
+
[[EDITOR-5761](https://hello.jira.atlassian.cloud/browse/EDITOR-5761) - clean up
|
|
9
|
+
platform_editor_date_to_text feature flag
|
|
10
|
+
|
|
3
11
|
## 8.5.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createClipboardTextSerializer = createClipboardTextSerializer;
|
|
7
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
+
/**
|
|
9
|
+
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
10
|
+
* section of the clipboard on copy.
|
|
11
|
+
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
12
|
+
* previously were empty on plain text copy).
|
|
13
|
+
*
|
|
14
|
+
* By default (without this function passed to the editor), the editor uses
|
|
15
|
+
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
16
|
+
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
17
|
+
*/
|
|
18
|
+
function createClipboardTextSerializer(intl) {
|
|
19
|
+
return function (slice) {
|
|
20
|
+
var blockSeparator = '\n\n';
|
|
21
|
+
return slice.content.textBetween(0, slice.content.size, blockSeparator, function (leafNode) {
|
|
22
|
+
var _leafNode$text;
|
|
23
|
+
switch (leafNode.type.name) {
|
|
24
|
+
case 'hardBreak':
|
|
25
|
+
return '\n';
|
|
26
|
+
case 'text':
|
|
27
|
+
return leafNode.text;
|
|
28
|
+
case 'inlineCard':
|
|
29
|
+
return leafNode.attrs.url;
|
|
30
|
+
case 'blockCard':
|
|
31
|
+
return leafNode.attrs.url;
|
|
32
|
+
// Note: Due to relying on an async fetch of the Mention name by the Node's React component,
|
|
33
|
+
// pasting a mention does not actually work for the in-product Mention implementation.
|
|
34
|
+
// However, this is also true of the previous implementation.
|
|
35
|
+
// Bug ticket: https://product-fabric.atlassian.net/browse/ED-23076
|
|
36
|
+
case 'mention':
|
|
37
|
+
return leafNode.attrs.text;
|
|
38
|
+
case 'date':
|
|
39
|
+
return (0, _utils.timestampToString)(leafNode.attrs.timestamp, intl);
|
|
40
|
+
default:
|
|
41
|
+
// Unsupported node
|
|
42
|
+
return (_leafNode$text = leafNode.text) !== null && _leafNode$text !== void 0 ? _leafNode$text : '';
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -34,7 +34,7 @@ var _actions = require("../editor-actions/actions");
|
|
|
34
34
|
var _commands = require("../editor-commands/commands");
|
|
35
35
|
var _media = require("../pm-plugins/media");
|
|
36
36
|
var _analytics2 = require("./analytics");
|
|
37
|
-
var
|
|
37
|
+
var _createClipboardTextSerializer = require("./create-clipboard-text-serializer");
|
|
38
38
|
var _pluginFactory = require("./plugin-factory");
|
|
39
39
|
var _util = require("./util");
|
|
40
40
|
var _handleVSCodeBlock = require("./util/edge-cases/handleVSCodeBlock");
|
|
@@ -131,7 +131,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
131
131
|
}),
|
|
132
132
|
props: {
|
|
133
133
|
// For serialising to plain text
|
|
134
|
-
clipboardTextSerializer: (0,
|
|
134
|
+
clipboardTextSerializer: (0, _createClipboardTextSerializer.createClipboardTextSerializer)(getIntl()),
|
|
135
135
|
handleDOMEvents: {
|
|
136
136
|
// note
|
|
137
137
|
paste: function paste(view, event) {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
4
|
+
* section of the clipboard on copy.
|
|
5
|
+
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
6
|
+
* previously were empty on plain text copy).
|
|
7
|
+
*
|
|
8
|
+
* By default (without this function passed to the editor), the editor uses
|
|
9
|
+
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
10
|
+
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
11
|
+
*/
|
|
12
|
+
export function createClipboardTextSerializer(intl) {
|
|
13
|
+
return slice => {
|
|
14
|
+
const blockSeparator = '\n\n';
|
|
15
|
+
return slice.content.textBetween(0, slice.content.size, blockSeparator, leafNode => {
|
|
16
|
+
var _leafNode$text;
|
|
17
|
+
switch (leafNode.type.name) {
|
|
18
|
+
case 'hardBreak':
|
|
19
|
+
return '\n';
|
|
20
|
+
case 'text':
|
|
21
|
+
return leafNode.text;
|
|
22
|
+
case 'inlineCard':
|
|
23
|
+
return leafNode.attrs.url;
|
|
24
|
+
case 'blockCard':
|
|
25
|
+
return leafNode.attrs.url;
|
|
26
|
+
// Note: Due to relying on an async fetch of the Mention name by the Node's React component,
|
|
27
|
+
// pasting a mention does not actually work for the in-product Mention implementation.
|
|
28
|
+
// However, this is also true of the previous implementation.
|
|
29
|
+
// Bug ticket: https://product-fabric.atlassian.net/browse/ED-23076
|
|
30
|
+
case 'mention':
|
|
31
|
+
return leafNode.attrs.text;
|
|
32
|
+
case 'date':
|
|
33
|
+
return timestampToString(leafNode.attrs.timestamp, intl);
|
|
34
|
+
default:
|
|
35
|
+
// Unsupported node
|
|
36
|
+
return (_leafNode$text = leafNode.text) !== null && _leafNode$text !== void 0 ? _leafNode$text : '';
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -24,7 +24,7 @@ import { PastePluginActionTypes } from '../editor-actions/actions';
|
|
|
24
24
|
import { splitParagraphs, upgradeTextToLists } from '../editor-commands/commands';
|
|
25
25
|
import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, transformSliceToMediaSingleWithNewExperience, unwrapNestedMediaElements } from '../pm-plugins/media';
|
|
26
26
|
import { createPasteMeasurePayload, getContentNodeTypes, handleCodeBlockWithAnalytics, handleExpandWithAnalytics, handleMarkdownWithAnalytics, handleMediaSingleWithAnalytics, handleNestedTablePasteWithAnalytics, handlePasteAsPlainTextWithAnalytics, handlePasteIntoCaptionWithAnalytics, handlePasteIntoTaskAndDecisionWithAnalytics, handlePasteLinkOnSelectedTextWithAnalytics, handlePasteNonNestableBlockNodesIntoListWithAnalytics, handlePastePanelOrDecisionIntoListWithAnalytics, handlePastePreservingMarksWithAnalytics, handleRichTextWithAnalytics, handleSelectedTableWithAnalytics, sendPasteAnalyticsEvent } from './analytics';
|
|
27
|
-
import { createClipboardTextSerializer
|
|
27
|
+
import { createClipboardTextSerializer } from './create-clipboard-text-serializer';
|
|
28
28
|
import { createPluginState, pluginKey as stateKey } from './plugin-factory';
|
|
29
29
|
import { escapeBackslashAndLinksExceptCodeBlock, getPasteSource, htmlContainsSingleFile, htmlHasInvalidLinkTags, isPastedFromExcel, isPastedFromWord, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from './util';
|
|
30
30
|
import { handleVSCodeBlock } from './util/edge-cases/handleVSCodeBlock';
|
|
@@ -97,7 +97,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
97
97
|
}),
|
|
98
98
|
props: {
|
|
99
99
|
// For serialising to plain text
|
|
100
|
-
clipboardTextSerializer:
|
|
100
|
+
clipboardTextSerializer: createClipboardTextSerializer(getIntl()),
|
|
101
101
|
handleDOMEvents: {
|
|
102
102
|
// note
|
|
103
103
|
paste: (view, event) => {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
4
|
+
* section of the clipboard on copy.
|
|
5
|
+
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
6
|
+
* previously were empty on plain text copy).
|
|
7
|
+
*
|
|
8
|
+
* By default (without this function passed to the editor), the editor uses
|
|
9
|
+
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
10
|
+
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
11
|
+
*/
|
|
12
|
+
export function createClipboardTextSerializer(intl) {
|
|
13
|
+
return function (slice) {
|
|
14
|
+
var blockSeparator = '\n\n';
|
|
15
|
+
return slice.content.textBetween(0, slice.content.size, blockSeparator, function (leafNode) {
|
|
16
|
+
var _leafNode$text;
|
|
17
|
+
switch (leafNode.type.name) {
|
|
18
|
+
case 'hardBreak':
|
|
19
|
+
return '\n';
|
|
20
|
+
case 'text':
|
|
21
|
+
return leafNode.text;
|
|
22
|
+
case 'inlineCard':
|
|
23
|
+
return leafNode.attrs.url;
|
|
24
|
+
case 'blockCard':
|
|
25
|
+
return leafNode.attrs.url;
|
|
26
|
+
// Note: Due to relying on an async fetch of the Mention name by the Node's React component,
|
|
27
|
+
// pasting a mention does not actually work for the in-product Mention implementation.
|
|
28
|
+
// However, this is also true of the previous implementation.
|
|
29
|
+
// Bug ticket: https://product-fabric.atlassian.net/browse/ED-23076
|
|
30
|
+
case 'mention':
|
|
31
|
+
return leafNode.attrs.text;
|
|
32
|
+
case 'date':
|
|
33
|
+
return timestampToString(leafNode.attrs.timestamp, intl);
|
|
34
|
+
default:
|
|
35
|
+
// Unsupported node
|
|
36
|
+
return (_leafNode$text = leafNode.text) !== null && _leafNode$text !== void 0 ? _leafNode$text : '';
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -29,7 +29,7 @@ import { PastePluginActionTypes } from '../editor-actions/actions';
|
|
|
29
29
|
import { splitParagraphs, upgradeTextToLists } from '../editor-commands/commands';
|
|
30
30
|
import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, transformSliceToMediaSingleWithNewExperience, unwrapNestedMediaElements } from '../pm-plugins/media';
|
|
31
31
|
import { createPasteMeasurePayload, getContentNodeTypes, handleCodeBlockWithAnalytics, handleExpandWithAnalytics, handleMarkdownWithAnalytics, handleMediaSingleWithAnalytics, handleNestedTablePasteWithAnalytics, handlePasteAsPlainTextWithAnalytics, handlePasteIntoCaptionWithAnalytics, handlePasteIntoTaskAndDecisionWithAnalytics, handlePasteLinkOnSelectedTextWithAnalytics, handlePasteNonNestableBlockNodesIntoListWithAnalytics, handlePastePanelOrDecisionIntoListWithAnalytics, handlePastePreservingMarksWithAnalytics, handleRichTextWithAnalytics, handleSelectedTableWithAnalytics, sendPasteAnalyticsEvent } from './analytics';
|
|
32
|
-
import { createClipboardTextSerializer
|
|
32
|
+
import { createClipboardTextSerializer } from './create-clipboard-text-serializer';
|
|
33
33
|
import { createPluginState, pluginKey as stateKey } from './plugin-factory';
|
|
34
34
|
import { escapeBackslashAndLinksExceptCodeBlock, getPasteSource, htmlContainsSingleFile, htmlHasInvalidLinkTags, isPastedFromExcel, isPastedFromWord, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from './util';
|
|
35
35
|
import { handleVSCodeBlock } from './util/edge-cases/handleVSCodeBlock';
|
|
@@ -123,7 +123,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
123
123
|
}),
|
|
124
124
|
props: {
|
|
125
125
|
// For serialising to plain text
|
|
126
|
-
clipboardTextSerializer:
|
|
126
|
+
clipboardTextSerializer: createClipboardTextSerializer(getIntl()),
|
|
127
127
|
handleDOMEvents: {
|
|
128
128
|
// note
|
|
129
129
|
paste: function paste(view, event) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
/**
|
|
4
|
+
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
5
|
+
* section of the clipboard on copy.
|
|
6
|
+
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
7
|
+
* previously were empty on plain text copy).
|
|
8
|
+
*
|
|
9
|
+
* By default (without this function passed to the editor), the editor uses
|
|
10
|
+
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
11
|
+
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
12
|
+
*/
|
|
13
|
+
export declare function createClipboardTextSerializer(intl: IntlShape): (slice: Slice) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
/**
|
|
4
|
+
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
5
|
+
* section of the clipboard on copy.
|
|
6
|
+
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
7
|
+
* previously were empty on plain text copy).
|
|
8
|
+
*
|
|
9
|
+
* By default (without this function passed to the editor), the editor uses
|
|
10
|
+
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
11
|
+
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
12
|
+
*/
|
|
13
|
+
export declare function createClipboardTextSerializer(intl: IntlShape): (slice: Slice) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.0",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -116,9 +116,6 @@
|
|
|
116
116
|
"platform_editor_link_paste_select_all": {
|
|
117
117
|
"type": "boolean"
|
|
118
118
|
},
|
|
119
|
-
"platform_editor_date_to_text": {
|
|
120
|
-
"type": "boolean"
|
|
121
|
-
},
|
|
122
119
|
"platform_media_cross_client_copy_with_auth": {
|
|
123
120
|
"type": "boolean"
|
|
124
121
|
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.clipboardTextSerializer = clipboardTextSerializer;
|
|
7
|
-
exports.createClipboardTextSerializer = createClipboardTextSerializer;
|
|
8
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
|
-
/**
|
|
10
|
-
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
11
|
-
* section of the clipboard on copy.
|
|
12
|
-
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
13
|
-
* previously were empty on plain text copy).
|
|
14
|
-
*
|
|
15
|
-
* By default (without this function passed to the editor), the editor uses
|
|
16
|
-
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
17
|
-
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
18
|
-
*
|
|
19
|
-
* @todo Remove when `platform_editor_date_to_text` FF is removed.
|
|
20
|
-
* Also, rename the file to `create-clipboard-text-serializer.ts`.
|
|
21
|
-
*/
|
|
22
|
-
function clipboardTextSerializer(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
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
50
|
-
* section of the clipboard on copy.
|
|
51
|
-
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
52
|
-
* previously were empty on plain text copy).
|
|
53
|
-
*
|
|
54
|
-
* By default (without this function passed to the editor), the editor uses
|
|
55
|
-
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
56
|
-
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
57
|
-
*/
|
|
58
|
-
function createClipboardTextSerializer(intl) {
|
|
59
|
-
return function (slice) {
|
|
60
|
-
var blockSeparator = '\n\n';
|
|
61
|
-
return slice.content.textBetween(0, slice.content.size, blockSeparator, function (leafNode) {
|
|
62
|
-
var _leafNode$text2;
|
|
63
|
-
switch (leafNode.type.name) {
|
|
64
|
-
case 'hardBreak':
|
|
65
|
-
return '\n';
|
|
66
|
-
case 'text':
|
|
67
|
-
return leafNode.text;
|
|
68
|
-
case 'inlineCard':
|
|
69
|
-
return leafNode.attrs.url;
|
|
70
|
-
case 'blockCard':
|
|
71
|
-
return leafNode.attrs.url;
|
|
72
|
-
// Note: Due to relying on an async fetch of the Mention name by the Node's React component,
|
|
73
|
-
// pasting a mention does not actually work for the in-product Mention implementation.
|
|
74
|
-
// However, this is also true of the previous implementation.
|
|
75
|
-
// Bug ticket: https://product-fabric.atlassian.net/browse/ED-23076
|
|
76
|
-
case 'mention':
|
|
77
|
-
return leafNode.attrs.text;
|
|
78
|
-
case 'date':
|
|
79
|
-
return (0, _utils.timestampToString)(leafNode.attrs.timestamp, intl);
|
|
80
|
-
default:
|
|
81
|
-
// Unsupported node
|
|
82
|
-
return (_leafNode$text2 = leafNode.text) !== null && _leafNode$text2 !== void 0 ? _leafNode$text2 : '';
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
2
|
-
/**
|
|
3
|
-
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
4
|
-
* section of the clipboard on copy.
|
|
5
|
-
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
6
|
-
* previously were empty on plain text copy).
|
|
7
|
-
*
|
|
8
|
-
* By default (without this function passed to the editor), the editor uses
|
|
9
|
-
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
10
|
-
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
11
|
-
*
|
|
12
|
-
* @todo Remove when `platform_editor_date_to_text` FF is removed.
|
|
13
|
-
* Also, rename the file to `create-clipboard-text-serializer.ts`.
|
|
14
|
-
*/
|
|
15
|
-
export function clipboardTextSerializer(slice) {
|
|
16
|
-
const blockSeparator = '\n\n';
|
|
17
|
-
return slice.content.textBetween(0, slice.content.size, blockSeparator, leafNode => {
|
|
18
|
-
var _leafNode$text;
|
|
19
|
-
switch (leafNode.type.name) {
|
|
20
|
-
case 'hardBreak':
|
|
21
|
-
return '\n';
|
|
22
|
-
case 'text':
|
|
23
|
-
return leafNode.text;
|
|
24
|
-
case 'inlineCard':
|
|
25
|
-
return leafNode.attrs.url;
|
|
26
|
-
case 'blockCard':
|
|
27
|
-
return leafNode.attrs.url;
|
|
28
|
-
// Note: Due to relying on an async fetch of the Mention name by the Node's React component,
|
|
29
|
-
// pasting a mention does not actually work for the in-product Mention implementation.
|
|
30
|
-
// However, this is also true of the previous implementation.
|
|
31
|
-
// Bug ticket: https://product-fabric.atlassian.net/browse/ED-23076
|
|
32
|
-
case 'mention':
|
|
33
|
-
return leafNode.attrs.text;
|
|
34
|
-
default:
|
|
35
|
-
// Unsupported node
|
|
36
|
-
return (_leafNode$text = leafNode.text) !== null && _leafNode$text !== void 0 ? _leafNode$text : '';
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
43
|
-
* section of the clipboard on copy.
|
|
44
|
-
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
45
|
-
* previously were empty on plain text copy).
|
|
46
|
-
*
|
|
47
|
-
* By default (without this function passed to the editor), the editor uses
|
|
48
|
-
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
49
|
-
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
50
|
-
*/
|
|
51
|
-
export function createClipboardTextSerializer(intl) {
|
|
52
|
-
return slice => {
|
|
53
|
-
const blockSeparator = '\n\n';
|
|
54
|
-
return slice.content.textBetween(0, slice.content.size, blockSeparator, leafNode => {
|
|
55
|
-
var _leafNode$text2;
|
|
56
|
-
switch (leafNode.type.name) {
|
|
57
|
-
case 'hardBreak':
|
|
58
|
-
return '\n';
|
|
59
|
-
case 'text':
|
|
60
|
-
return leafNode.text;
|
|
61
|
-
case 'inlineCard':
|
|
62
|
-
return leafNode.attrs.url;
|
|
63
|
-
case 'blockCard':
|
|
64
|
-
return leafNode.attrs.url;
|
|
65
|
-
// Note: Due to relying on an async fetch of the Mention name by the Node's React component,
|
|
66
|
-
// pasting a mention does not actually work for the in-product Mention implementation.
|
|
67
|
-
// However, this is also true of the previous implementation.
|
|
68
|
-
// Bug ticket: https://product-fabric.atlassian.net/browse/ED-23076
|
|
69
|
-
case 'mention':
|
|
70
|
-
return leafNode.attrs.text;
|
|
71
|
-
case 'date':
|
|
72
|
-
return timestampToString(leafNode.attrs.timestamp, intl);
|
|
73
|
-
default:
|
|
74
|
-
// Unsupported node
|
|
75
|
-
return (_leafNode$text2 = leafNode.text) !== null && _leafNode$text2 !== void 0 ? _leafNode$text2 : '';
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
2
|
-
/**
|
|
3
|
-
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
4
|
-
* section of the clipboard on copy.
|
|
5
|
-
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
6
|
-
* previously were empty on plain text copy).
|
|
7
|
-
*
|
|
8
|
-
* By default (without this function passed to the editor), the editor uses
|
|
9
|
-
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
10
|
-
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
11
|
-
*
|
|
12
|
-
* @todo Remove when `platform_editor_date_to_text` FF is removed.
|
|
13
|
-
* Also, rename the file to `create-clipboard-text-serializer.ts`.
|
|
14
|
-
*/
|
|
15
|
-
export function clipboardTextSerializer(slice) {
|
|
16
|
-
var blockSeparator = '\n\n';
|
|
17
|
-
return slice.content.textBetween(0, slice.content.size, blockSeparator, function (leafNode) {
|
|
18
|
-
var _leafNode$text;
|
|
19
|
-
switch (leafNode.type.name) {
|
|
20
|
-
case 'hardBreak':
|
|
21
|
-
return '\n';
|
|
22
|
-
case 'text':
|
|
23
|
-
return leafNode.text;
|
|
24
|
-
case 'inlineCard':
|
|
25
|
-
return leafNode.attrs.url;
|
|
26
|
-
case 'blockCard':
|
|
27
|
-
return leafNode.attrs.url;
|
|
28
|
-
// Note: Due to relying on an async fetch of the Mention name by the Node's React component,
|
|
29
|
-
// pasting a mention does not actually work for the in-product Mention implementation.
|
|
30
|
-
// However, this is also true of the previous implementation.
|
|
31
|
-
// Bug ticket: https://product-fabric.atlassian.net/browse/ED-23076
|
|
32
|
-
case 'mention':
|
|
33
|
-
return leafNode.attrs.text;
|
|
34
|
-
default:
|
|
35
|
-
// Unsupported node
|
|
36
|
-
return (_leafNode$text = leafNode.text) !== null && _leafNode$text !== void 0 ? _leafNode$text : '';
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
43
|
-
* section of the clipboard on copy.
|
|
44
|
-
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
45
|
-
* previously were empty on plain text copy).
|
|
46
|
-
*
|
|
47
|
-
* By default (without this function passed to the editor), the editor uses
|
|
48
|
-
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
49
|
-
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
50
|
-
*/
|
|
51
|
-
export function createClipboardTextSerializer(intl) {
|
|
52
|
-
return function (slice) {
|
|
53
|
-
var blockSeparator = '\n\n';
|
|
54
|
-
return slice.content.textBetween(0, slice.content.size, blockSeparator, function (leafNode) {
|
|
55
|
-
var _leafNode$text2;
|
|
56
|
-
switch (leafNode.type.name) {
|
|
57
|
-
case 'hardBreak':
|
|
58
|
-
return '\n';
|
|
59
|
-
case 'text':
|
|
60
|
-
return leafNode.text;
|
|
61
|
-
case 'inlineCard':
|
|
62
|
-
return leafNode.attrs.url;
|
|
63
|
-
case 'blockCard':
|
|
64
|
-
return leafNode.attrs.url;
|
|
65
|
-
// Note: Due to relying on an async fetch of the Mention name by the Node's React component,
|
|
66
|
-
// pasting a mention does not actually work for the in-product Mention implementation.
|
|
67
|
-
// However, this is also true of the previous implementation.
|
|
68
|
-
// Bug ticket: https://product-fabric.atlassian.net/browse/ED-23076
|
|
69
|
-
case 'mention':
|
|
70
|
-
return leafNode.attrs.text;
|
|
71
|
-
case 'date':
|
|
72
|
-
return timestampToString(leafNode.attrs.timestamp, intl);
|
|
73
|
-
default:
|
|
74
|
-
// Unsupported node
|
|
75
|
-
return (_leafNode$text2 = leafNode.text) !== null && _leafNode$text2 !== void 0 ? _leafNode$text2 : '';
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { IntlShape } from 'react-intl-next';
|
|
2
|
-
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
/**
|
|
4
|
-
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
5
|
-
* section of the clipboard on copy.
|
|
6
|
-
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
7
|
-
* previously were empty on plain text copy).
|
|
8
|
-
*
|
|
9
|
-
* By default (without this function passed to the editor), the editor uses
|
|
10
|
-
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
11
|
-
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
12
|
-
*
|
|
13
|
-
* @todo Remove when `platform_editor_date_to_text` FF is removed.
|
|
14
|
-
* Also, rename the file to `create-clipboard-text-serializer.ts`.
|
|
15
|
-
*/
|
|
16
|
-
export declare function clipboardTextSerializer(slice: Slice): string;
|
|
17
|
-
/**
|
|
18
|
-
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
19
|
-
* section of the clipboard on copy.
|
|
20
|
-
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
21
|
-
* previously were empty on plain text copy).
|
|
22
|
-
*
|
|
23
|
-
* By default (without this function passed to the editor), the editor uses
|
|
24
|
-
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
25
|
-
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
26
|
-
*/
|
|
27
|
-
export declare function createClipboardTextSerializer(intl: IntlShape): (slice: Slice) => string;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { IntlShape } from 'react-intl-next';
|
|
2
|
-
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
/**
|
|
4
|
-
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
5
|
-
* section of the clipboard on copy.
|
|
6
|
-
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
7
|
-
* previously were empty on plain text copy).
|
|
8
|
-
*
|
|
9
|
-
* By default (without this function passed to the editor), the editor uses
|
|
10
|
-
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
11
|
-
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
12
|
-
*
|
|
13
|
-
* @todo Remove when `platform_editor_date_to_text` FF is removed.
|
|
14
|
-
* Also, rename the file to `create-clipboard-text-serializer.ts`.
|
|
15
|
-
*/
|
|
16
|
-
export declare function clipboardTextSerializer(slice: Slice): string;
|
|
17
|
-
/**
|
|
18
|
-
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
19
|
-
* section of the clipboard on copy.
|
|
20
|
-
* The current implementation is bare bones - only inlineCards, blockCards and mentions are tested (they
|
|
21
|
-
* previously were empty on plain text copy).
|
|
22
|
-
*
|
|
23
|
-
* By default (without this function passed to the editor), the editor uses
|
|
24
|
-
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
25
|
-
* (see https://prosemirror.net/docs/ref/#view.EditorProps.clipboardTextSerializer)
|
|
26
|
-
*/
|
|
27
|
-
export declare function createClipboardTextSerializer(intl: IntlShape): (slice: Slice) => string;
|