@atlaskit/editor-plugin-paste 7.1.0 → 7.3.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 +23 -0
- package/dist/cjs/pastePlugin.js +3 -2
- package/dist/cjs/pm-plugins/clipboard-text-serializer.js +45 -0
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/cjs/pm-plugins/util/handlers.js +8 -8
- package/dist/es2019/pastePlugin.js +3 -2
- package/dist/es2019/pm-plugins/clipboard-text-serializer.js +44 -0
- package/dist/es2019/pm-plugins/main.js +3 -3
- package/dist/es2019/pm-plugins/util/handlers.js +1 -1
- package/dist/esm/pastePlugin.js +3 -2
- package/dist/esm/pm-plugins/clipboard-text-serializer.js +44 -0
- package/dist/esm/pm-plugins/main.js +3 -3
- package/dist/esm/pm-plugins/util/handlers.js +1 -1
- package/dist/types/pm-plugins/clipboard-text-serializer.d.ts +15 -0
- package/dist/types/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/clipboard-text-serializer.d.ts +15 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -1
- package/package.json +12 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 7.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`0ac75e0d28c72`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0ac75e0d28c72) -
|
|
8
|
+
Migrate @atlaskit/editor-prosemirror/history to @atlaskit/prosemirror-history package
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 7.2.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [`801013048753f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/801013048753f) -
|
|
19
|
+
[https://product-fabric.atlassian.net/browse/ED-20833](ED-20833) - added serialization of the date
|
|
20
|
+
into text when copying in the editor
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
3
26
|
## 7.1.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/dist/cjs/pastePlugin.js
CHANGED
|
@@ -26,8 +26,9 @@ var pastePlugin = exports.pastePlugin = function pastePlugin(_ref) {
|
|
|
26
26
|
var schema = _ref3.schema,
|
|
27
27
|
providerFactory = _ref3.providerFactory,
|
|
28
28
|
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent,
|
|
29
|
-
dispatch = _ref3.dispatch
|
|
30
|
-
|
|
29
|
+
dispatch = _ref3.dispatch,
|
|
30
|
+
getIntl = _ref3.getIntl;
|
|
31
|
+
return (0, _main.createPlugin)(schema, dispatchAnalyticsEvent, dispatch, featureFlags, api, getIntl, cardOptions, sanitizePrivateContent, providerFactory);
|
|
31
32
|
}
|
|
32
33
|
}, {
|
|
33
34
|
name: 'moveAnalyticsPlugin',
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.clipboardTextSerializer = clipboardTextSerializer;
|
|
7
|
+
exports.createClipboardTextSerializer = createClipboardTextSerializer;
|
|
8
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
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.
|
|
@@ -13,6 +15,9 @@ exports.clipboardTextSerializer = clipboardTextSerializer;
|
|
|
13
15
|
* By default (without this function passed to the editor), the editor uses
|
|
14
16
|
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
15
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`.
|
|
16
21
|
*/
|
|
17
22
|
function clipboardTextSerializer(slice) {
|
|
18
23
|
var blockSeparator = '\n\n';
|
|
@@ -38,4 +43,44 @@ function clipboardTextSerializer(slice) {
|
|
|
38
43
|
return (_leafNode$text = leafNode.text) !== null && _leafNode$text !== void 0 ? _leafNode$text : '';
|
|
39
44
|
}
|
|
40
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
|
+
};
|
|
41
86
|
}
|
|
@@ -66,7 +66,7 @@ function isSharePointUrl(url) {
|
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
69
|
+
function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, getIntl, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
70
70
|
var _pluginInjectionApi$a;
|
|
71
71
|
var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
72
72
|
var atlassianMarkDownParser = new _editorMarkdownTransformer.MarkdownTransformer(schema, _paste.md);
|
|
@@ -126,7 +126,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
126
126
|
}),
|
|
127
127
|
props: {
|
|
128
128
|
// For serialising to plain text
|
|
129
|
-
clipboardTextSerializer: _clipboardTextSerializer.clipboardTextSerializer,
|
|
129
|
+
clipboardTextSerializer: (0, _platformFeatureFlags.fg)('platform_editor_date_to_text') ? (0, _clipboardTextSerializer.createClipboardTextSerializer)(getIntl()) : _clipboardTextSerializer.clipboardTextSerializer,
|
|
130
130
|
handleDOMEvents: {
|
|
131
131
|
// note
|
|
132
132
|
paste: function paste(view, event) {
|
|
@@ -36,12 +36,12 @@ var _mark = require("@atlaskit/editor-common/mark");
|
|
|
36
36
|
var _nesting = require("@atlaskit/editor-common/nesting");
|
|
37
37
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
38
38
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
39
|
-
var _history = require("@atlaskit/editor-prosemirror/history");
|
|
40
39
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
41
40
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
42
41
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
43
42
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
44
43
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
44
|
+
var _prosemirrorHistory = require("@atlaskit/prosemirror-history");
|
|
45
45
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
46
46
|
var _commands = require("../../editor-commands/commands");
|
|
47
47
|
var _pluginFactory = require("../plugin-factory");
|
|
@@ -163,7 +163,7 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
|
|
|
163
163
|
}
|
|
164
164
|
var transformedSlice = compose.apply(null, filters)(slice);
|
|
165
165
|
var isFirstChildTaskNode = transformedSlice.content.firstChild.type === taskList || transformedSlice.content.firstChild.type === taskItem;
|
|
166
|
-
var tr = (0,
|
|
166
|
+
var tr = (0, _prosemirrorHistory.closeHistory)(state.tr);
|
|
167
167
|
if (panelNode && sliceHasTask && ((_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 ? void 0 : _slice$content$firstC2.type) === panel && (0, _index.isEmptyNode)(panelNode) && selection.$from.node() === selection.$to.node()) {
|
|
168
168
|
return Boolean((0, _lists.insertSliceInsideOfPanelNodeSelected)(panelNode)({
|
|
169
169
|
tr: tr,
|
|
@@ -500,7 +500,7 @@ function handlePasteAsPlainText(slice, _event, editorAnalyticsAPI) {
|
|
|
500
500
|
// @see prosemirror-view/src/clipboard.js:parseFromClipboard()).
|
|
501
501
|
// @see prosemirror-view/src/input.js:doPaste().
|
|
502
502
|
if (isShiftKeyPressed) {
|
|
503
|
-
var tr = (0,
|
|
503
|
+
var tr = (0, _prosemirrorHistory.closeHistory)(state.tr);
|
|
504
504
|
var _tr = tr,
|
|
505
505
|
selection = _tr.selection;
|
|
506
506
|
|
|
@@ -562,7 +562,7 @@ function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
562
562
|
// we apply current selection marks to the pasted slice
|
|
563
563
|
if ((0, _index.hasOnlyNodesOfType)(bulletList, hardBreak, heading, listItem, text, emoji, mention, orderedList)(slice) || selectionIsHeading || hasActiveCodeMark || hasAnnotationMark) {
|
|
564
564
|
var transformedSlice = (0, _index.applyTextMarksToSlice)(schema, selectionMarks)(slice);
|
|
565
|
-
var tr = (0,
|
|
565
|
+
var tr = (0, _prosemirrorHistory.closeHistory)(state.tr).replaceSelection(transformedSlice).setStoredMarks(selectionMarks).scrollIntoView();
|
|
566
566
|
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, _analytics.INPUT_METHOD.CLIPBOARD);
|
|
567
567
|
if (dispatch) {
|
|
568
568
|
dispatch(tr);
|
|
@@ -620,7 +620,7 @@ function insertAutoMacro(slice, macro, view, from, to) {
|
|
|
620
620
|
|
|
621
621
|
// replace the text with the macro as a separate transaction
|
|
622
622
|
// so the autoconversion generates 2 undo steps
|
|
623
|
-
view.dispatch((0,
|
|
623
|
+
view.dispatch((0, _prosemirrorHistory.closeHistory)(view.state.tr).replaceRangeWith(before, before + slice.size, macro).scrollIntoView());
|
|
624
624
|
return true;
|
|
625
625
|
}
|
|
626
626
|
return false;
|
|
@@ -683,7 +683,7 @@ function handleCodeBlock(text) {
|
|
|
683
683
|
return function (state, dispatch) {
|
|
684
684
|
var codeBlock = state.schema.nodes.codeBlock;
|
|
685
685
|
if (text && (0, _utils2.hasParentNodeOfType)(codeBlock)(state.selection)) {
|
|
686
|
-
var tr = (0,
|
|
686
|
+
var tr = (0, _prosemirrorHistory.closeHistory)(state.tr);
|
|
687
687
|
tr.scrollIntoView();
|
|
688
688
|
if (dispatch) {
|
|
689
689
|
dispatch(tr.insertText(text));
|
|
@@ -847,7 +847,7 @@ function handleExpandPaste(slice) {
|
|
|
847
847
|
}
|
|
848
848
|
function handleMarkdown(markdownSlice, queueCardsFromChangedTr, from, to) {
|
|
849
849
|
return function (state, dispatch) {
|
|
850
|
-
var tr = (0,
|
|
850
|
+
var tr = (0, _prosemirrorHistory.closeHistory)(state.tr);
|
|
851
851
|
var pastesFrom = typeof from === 'number' ? from : tr.selection.from;
|
|
852
852
|
if (typeof from === 'number' && typeof to === 'number') {
|
|
853
853
|
tr.replaceRange(from, to, markdownSlice);
|
|
@@ -1037,7 +1037,7 @@ function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
1037
1037
|
if (shouldFlattenList(state, slice)) {
|
|
1038
1038
|
slice = flattenNestedListInSlice(slice);
|
|
1039
1039
|
}
|
|
1040
|
-
(0,
|
|
1040
|
+
(0, _prosemirrorHistory.closeHistory)(tr);
|
|
1041
1041
|
var isFirstChildListNode = (0, _utils.isListNode)(firstChildOfSlice);
|
|
1042
1042
|
var isLastChildListNode = (0, _utils.isListNode)(lastChildOfSlice);
|
|
1043
1043
|
var isSliceContentListNodes = isFirstChildListNode || isLastChildListNode;
|
|
@@ -22,8 +22,9 @@ export const pastePlugin = ({
|
|
|
22
22
|
schema,
|
|
23
23
|
providerFactory,
|
|
24
24
|
dispatchAnalyticsEvent,
|
|
25
|
-
dispatch
|
|
26
|
-
|
|
25
|
+
dispatch,
|
|
26
|
+
getIntl
|
|
27
|
+
}) => createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, api, getIntl, cardOptions, sanitizePrivateContent, providerFactory)
|
|
27
28
|
}, {
|
|
28
29
|
name: 'moveAnalyticsPlugin',
|
|
29
30
|
plugin: ({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
1
2
|
/**
|
|
2
3
|
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
3
4
|
* section of the clipboard on copy.
|
|
@@ -7,6 +8,9 @@
|
|
|
7
8
|
* By default (without this function passed to the editor), the editor uses
|
|
8
9
|
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
9
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`.
|
|
10
14
|
*/
|
|
11
15
|
export function clipboardTextSerializer(slice) {
|
|
12
16
|
const blockSeparator = '\n\n';
|
|
@@ -32,4 +36,44 @@ export function clipboardTextSerializer(slice) {
|
|
|
32
36
|
return (_leafNode$text = leafNode.text) !== null && _leafNode$text !== void 0 ? _leafNode$text : '';
|
|
33
37
|
}
|
|
34
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
|
+
};
|
|
35
79
|
}
|
|
@@ -20,7 +20,7 @@ import { PastePluginActionTypes } from '../editor-actions/actions';
|
|
|
20
20
|
import { splitParagraphs, upgradeTextToLists } from '../editor-commands/commands';
|
|
21
21
|
import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, transformSliceToMediaSingleWithNewExperience, unwrapNestedMediaElements } from '../pm-plugins/media';
|
|
22
22
|
import { createPasteMeasurePayload, getContentNodeTypes, handleCodeBlockWithAnalytics, handleExpandWithAnalytics, handleMarkdownWithAnalytics, handleMediaSingleWithAnalytics, handleNestedTablePasteWithAnalytics, handlePasteAsPlainTextWithAnalytics, handlePasteIntoCaptionWithAnalytics, handlePasteIntoTaskAndDecisionWithAnalytics, handlePasteLinkOnSelectedTextWithAnalytics, handlePasteNonNestableBlockNodesIntoListWithAnalytics, handlePastePanelOrDecisionIntoListWithAnalytics, handlePastePreservingMarksWithAnalytics, handleRichTextWithAnalytics, handleSelectedTableWithAnalytics, sendPasteAnalyticsEvent } from './analytics';
|
|
23
|
-
import { clipboardTextSerializer } from './clipboard-text-serializer';
|
|
23
|
+
import { createClipboardTextSerializer, clipboardTextSerializer } from './clipboard-text-serializer';
|
|
24
24
|
import { createPluginState, pluginKey as stateKey } from './plugin-factory';
|
|
25
25
|
import { escapeBackslashAndLinksExceptCodeBlock, getPasteSource, htmlContainsSingleFile, htmlHasInvalidLinkTags, isPastedFromExcel, isPastedFromWord, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from './util';
|
|
26
26
|
import { handleVSCodeBlock } from './util/edge-cases/handleVSCodeBlock';
|
|
@@ -54,7 +54,7 @@ export function isSharePointUrl(url) {
|
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
57
|
+
export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, getIntl, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
58
58
|
var _pluginInjectionApi$a;
|
|
59
59
|
const editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
60
60
|
const atlassianMarkDownParser = new MarkdownTransformer(schema, md);
|
|
@@ -91,7 +91,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
91
91
|
}),
|
|
92
92
|
props: {
|
|
93
93
|
// For serialising to plain text
|
|
94
|
-
clipboardTextSerializer,
|
|
94
|
+
clipboardTextSerializer: fg('platform_editor_date_to_text') ? createClipboardTextSerializer(getIntl()) : clipboardTextSerializer,
|
|
95
95
|
handleDOMEvents: {
|
|
96
96
|
// note
|
|
97
97
|
paste: (view, event) => {
|
|
@@ -5,12 +5,12 @@ import { anyMarkActive } from '@atlaskit/editor-common/mark';
|
|
|
5
5
|
import { getParentOfTypeCount, getPositionAfterTopParentNodeOfType } from '@atlaskit/editor-common/nesting';
|
|
6
6
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
7
7
|
import { canLinkBeCreatedInRange, insideTableCell, isInListItem, isLinkMark, isListItemNode, isListNode, isNodeEmpty, isParagraph, isText, linkifyContent, mapSlice } from '@atlaskit/editor-common/utils';
|
|
8
|
-
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
9
8
|
import { Fragment, Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
10
9
|
import { AllSelection, NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
10
|
import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNode, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
12
11
|
import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
|
|
13
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
|
+
import { closeHistory } from '@atlaskit/prosemirror-history';
|
|
14
14
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
15
15
|
// TODO: ED-20519 - Needs Macro extraction
|
|
16
16
|
|
package/dist/esm/pastePlugin.js
CHANGED
|
@@ -20,8 +20,9 @@ export var pastePlugin = function pastePlugin(_ref) {
|
|
|
20
20
|
var schema = _ref3.schema,
|
|
21
21
|
providerFactory = _ref3.providerFactory,
|
|
22
22
|
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent,
|
|
23
|
-
dispatch = _ref3.dispatch
|
|
24
|
-
|
|
23
|
+
dispatch = _ref3.dispatch,
|
|
24
|
+
getIntl = _ref3.getIntl;
|
|
25
|
+
return createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, api, getIntl, cardOptions, sanitizePrivateContent, providerFactory);
|
|
25
26
|
}
|
|
26
27
|
}, {
|
|
27
28
|
name: 'moveAnalyticsPlugin',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
1
2
|
/**
|
|
2
3
|
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
3
4
|
* section of the clipboard on copy.
|
|
@@ -7,6 +8,9 @@
|
|
|
7
8
|
* By default (without this function passed to the editor), the editor uses
|
|
8
9
|
* `slice.content.textBetween(0, slice.content.size, "\n\n")`
|
|
9
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`.
|
|
10
14
|
*/
|
|
11
15
|
export function clipboardTextSerializer(slice) {
|
|
12
16
|
var blockSeparator = '\n\n';
|
|
@@ -32,4 +36,44 @@ export function clipboardTextSerializer(slice) {
|
|
|
32
36
|
return (_leafNode$text = leafNode.text) !== null && _leafNode$text !== void 0 ? _leafNode$text : '';
|
|
33
37
|
}
|
|
34
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
|
+
};
|
|
35
79
|
}
|
|
@@ -25,7 +25,7 @@ import { PastePluginActionTypes } from '../editor-actions/actions';
|
|
|
25
25
|
import { splitParagraphs, upgradeTextToLists } from '../editor-commands/commands';
|
|
26
26
|
import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, transformSliceToMediaSingleWithNewExperience, unwrapNestedMediaElements } from '../pm-plugins/media';
|
|
27
27
|
import { createPasteMeasurePayload, getContentNodeTypes, handleCodeBlockWithAnalytics, handleExpandWithAnalytics, handleMarkdownWithAnalytics, handleMediaSingleWithAnalytics, handleNestedTablePasteWithAnalytics, handlePasteAsPlainTextWithAnalytics, handlePasteIntoCaptionWithAnalytics, handlePasteIntoTaskAndDecisionWithAnalytics, handlePasteLinkOnSelectedTextWithAnalytics, handlePasteNonNestableBlockNodesIntoListWithAnalytics, handlePastePanelOrDecisionIntoListWithAnalytics, handlePastePreservingMarksWithAnalytics, handleRichTextWithAnalytics, handleSelectedTableWithAnalytics, sendPasteAnalyticsEvent } from './analytics';
|
|
28
|
-
import { clipboardTextSerializer } from './clipboard-text-serializer';
|
|
28
|
+
import { createClipboardTextSerializer, clipboardTextSerializer } from './clipboard-text-serializer';
|
|
29
29
|
import { createPluginState, pluginKey as stateKey } from './plugin-factory';
|
|
30
30
|
import { escapeBackslashAndLinksExceptCodeBlock, getPasteSource, htmlContainsSingleFile, htmlHasInvalidLinkTags, isPastedFromExcel, isPastedFromWord, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from './util';
|
|
31
31
|
import { handleVSCodeBlock } from './util/edge-cases/handleVSCodeBlock';
|
|
@@ -57,7 +57,7 @@ export function isSharePointUrl(url) {
|
|
|
57
57
|
return false;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
60
|
+
export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, getIntl, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
61
61
|
var _pluginInjectionApi$a;
|
|
62
62
|
var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
63
63
|
var atlassianMarkDownParser = new MarkdownTransformer(schema, md);
|
|
@@ -117,7 +117,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
117
117
|
}),
|
|
118
118
|
props: {
|
|
119
119
|
// For serialising to plain text
|
|
120
|
-
clipboardTextSerializer: clipboardTextSerializer,
|
|
120
|
+
clipboardTextSerializer: fg('platform_editor_date_to_text') ? createClipboardTextSerializer(getIntl()) : clipboardTextSerializer,
|
|
121
121
|
handleDOMEvents: {
|
|
122
122
|
// note
|
|
123
123
|
paste: function paste(view, event) {
|
|
@@ -13,12 +13,12 @@ import { anyMarkActive } from '@atlaskit/editor-common/mark';
|
|
|
13
13
|
import { getParentOfTypeCount, getPositionAfterTopParentNodeOfType } from '@atlaskit/editor-common/nesting';
|
|
14
14
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
15
15
|
import { canLinkBeCreatedInRange, insideTableCell, isInListItem, isLinkMark, isListItemNode, isListNode, isNodeEmpty, isParagraph, isText, linkifyContent, mapSlice } from '@atlaskit/editor-common/utils';
|
|
16
|
-
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
17
16
|
import { Fragment, Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
18
17
|
import { AllSelection, NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
19
18
|
import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNode, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
20
19
|
import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
|
|
21
20
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
21
|
+
import { closeHistory } from '@atlaskit/prosemirror-history';
|
|
22
22
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
23
23
|
// TODO: ED-20519 - Needs Macro extraction
|
|
24
24
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
1
2
|
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
/**
|
|
3
4
|
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
@@ -8,5 +9,19 @@ import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
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)
|
|
12
|
+
*
|
|
13
|
+
* @todo Remove when `platform_editor_date_to_text` FF is removed.
|
|
14
|
+
* Also, rename the file to `create-clipboard-text-serializer.ts`.
|
|
11
15
|
*/
|
|
12
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,3 +1,4 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
1
2
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
3
4
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
@@ -9,4 +10,4 @@ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
|
9
10
|
import type { PastePlugin } from '../index';
|
|
10
11
|
export declare const isInsideBlockQuote: (state: EditorState) => boolean;
|
|
11
12
|
export declare function isSharePointUrl(url: string | undefined): boolean;
|
|
12
|
-
export declare function createPlugin(schema: Schema, dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, featureFlags: FeatureFlags, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, cardOptions?: CardOptions, sanitizePrivateContent?: boolean, providerFactory?: ProviderFactory): SafePlugin<import("../pastePluginType").PastePluginState>;
|
|
13
|
+
export declare function createPlugin(schema: Schema, dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, featureFlags: FeatureFlags, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, getIntl: () => IntlShape, cardOptions?: CardOptions, sanitizePrivateContent?: boolean, providerFactory?: ProviderFactory): SafePlugin<import("../pastePluginType").PastePluginState>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
1
2
|
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
/**
|
|
3
4
|
* Returns a plain text serialization of a given slice. This is used for populating the plain text
|
|
@@ -8,5 +9,19 @@ import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
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)
|
|
12
|
+
*
|
|
13
|
+
* @todo Remove when `platform_editor_date_to_text` FF is removed.
|
|
14
|
+
* Also, rename the file to `create-clipboard-text-serializer.ts`.
|
|
11
15
|
*/
|
|
12
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,3 +1,4 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
1
2
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
3
4
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
@@ -9,4 +10,4 @@ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
|
9
10
|
import type { PastePlugin } from '../index';
|
|
10
11
|
export declare const isInsideBlockQuote: (state: EditorState) => boolean;
|
|
11
12
|
export declare function isSharePointUrl(url: string | undefined): boolean;
|
|
12
|
-
export declare function createPlugin(schema: Schema, dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, featureFlags: FeatureFlags, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, cardOptions?: CardOptions, sanitizePrivateContent?: boolean, providerFactory?: ProviderFactory): SafePlugin<import("../pastePluginType").PastePluginState>;
|
|
13
|
+
export declare function createPlugin(schema: Schema, dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, featureFlags: FeatureFlags, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, getIntl: () => IntlShape, cardOptions?: CardOptions, sanitizePrivateContent?: boolean, providerFactory?: ProviderFactory): SafePlugin<import("../pastePluginType").PastePluginState>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"@atlaskit/editor-markdown-transformer": "^5.19.0",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^6.1.0",
|
|
34
34
|
"@atlaskit/editor-plugin-annotation": "^6.1.0",
|
|
35
|
-
"@atlaskit/editor-plugin-better-type-history": "^6.
|
|
36
|
-
"@atlaskit/editor-plugin-card": "^11.
|
|
35
|
+
"@atlaskit/editor-plugin-better-type-history": "^6.1.0",
|
|
36
|
+
"@atlaskit/editor-plugin-card": "^11.3.0",
|
|
37
37
|
"@atlaskit/editor-plugin-feature-flags": "^5.0.0",
|
|
38
|
-
"@atlaskit/editor-plugin-list": "^8.
|
|
38
|
+
"@atlaskit/editor-plugin-list": "^8.1.0",
|
|
39
39
|
"@atlaskit/editor-plugin-media": "^8.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-mentions": "^8.0.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
@@ -47,18 +47,20 @@
|
|
|
47
47
|
"@atlaskit/tmp-editor-statsig": "^13.6.0",
|
|
48
48
|
"@babel/runtime": "^7.0.0",
|
|
49
49
|
"lodash": "^4.17.21",
|
|
50
|
+
"react-intl-next": "npm:react-intl@^5.18.1",
|
|
50
51
|
"uuid": "^3.1.0"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|
|
53
|
-
"@atlaskit/editor-common": "^110.
|
|
54
|
+
"@atlaskit/editor-common": "^110.10.0",
|
|
54
55
|
"react": "^18.2.0",
|
|
55
56
|
"react-dom": "^18.2.0"
|
|
56
57
|
},
|
|
57
58
|
"devDependencies": {
|
|
58
59
|
"@af/visual-regression": "workspace:^",
|
|
59
|
-
"@atlaskit/editor-plugin-block-type": "^
|
|
60
|
+
"@atlaskit/editor-plugin-block-type": "^10.1.0",
|
|
60
61
|
"@atlaskit/editor-plugin-history": "^6.0.0",
|
|
61
|
-
"@atlaskit/editor-plugin-type-ahead": "^6.
|
|
62
|
+
"@atlaskit/editor-plugin-type-ahead": "^6.4.0",
|
|
63
|
+
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
62
64
|
"@atlaskit/ssr": "workspace:^",
|
|
63
65
|
"@testing-library/react": "^13.4.0",
|
|
64
66
|
"wait-for-expect": "^1.2.0"
|
|
@@ -126,6 +128,9 @@
|
|
|
126
128
|
},
|
|
127
129
|
"platform_editor_paste_code_fence_spaces": {
|
|
128
130
|
"type": "boolean"
|
|
131
|
+
},
|
|
132
|
+
"platform_editor_date_to_text": {
|
|
133
|
+
"type": "boolean"
|
|
129
134
|
}
|
|
130
135
|
}
|
|
131
136
|
}
|