@atlaskit/editor-plugin-paste 2.0.11 → 2.0.13
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 +12 -0
- package/dist/cjs/editor-commands/commands.js +18 -1
- package/dist/cjs/pm-plugins/analytics.js +68 -28
- package/dist/cjs/pm-plugins/main.js +16 -0
- package/dist/cjs/pm-plugins/util/edge-cases/lists.js +3 -0
- package/dist/cjs/pm-plugins/util/handlers.js +19 -2
- package/dist/cjs/pm-plugins/util/index.js +23 -1
- package/dist/cjs/pm-plugins/util/tinyMCE.js +6 -1
- package/dist/es2019/editor-commands/commands.js +18 -1
- package/dist/es2019/pm-plugins/analytics.js +46 -10
- package/dist/es2019/pm-plugins/main.js +17 -1
- package/dist/es2019/pm-plugins/media.js +1 -1
- package/dist/es2019/pm-plugins/util/edge-cases/lists.js +3 -0
- package/dist/es2019/pm-plugins/util/handlers.js +23 -4
- package/dist/es2019/pm-plugins/util/index.js +23 -1
- package/dist/es2019/pm-plugins/util/tinyMCE.js +6 -1
- package/dist/esm/editor-commands/commands.js +18 -1
- package/dist/esm/pm-plugins/analytics.js +68 -28
- package/dist/esm/pm-plugins/main.js +16 -0
- package/dist/esm/pm-plugins/util/edge-cases/lists.js +3 -0
- package/dist/esm/pm-plugins/util/handlers.js +19 -2
- package/dist/esm/pm-plugins/util/index.js +23 -1
- package/dist/esm/pm-plugins/util/tinyMCE.js +6 -1
- package/package.json +5 -5
|
@@ -29,12 +29,15 @@ export const isInsideBlockQuote = state => {
|
|
|
29
29
|
return hasParentNodeOfType(blockquote)(state.selection);
|
|
30
30
|
};
|
|
31
31
|
const PASTE = 'Editor Paste Plugin Paste Duration';
|
|
32
|
+
|
|
33
|
+
// Ignored via go/ees005
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
32
35
|
export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
33
36
|
var _pluginInjectionApi$a;
|
|
34
37
|
const editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
35
38
|
const atlassianMarkDownParser = new MarkdownTransformer(schema, md);
|
|
36
39
|
function getMarkdownSlice(text, openStart, openEnd) {
|
|
37
|
-
|
|
40
|
+
const textInput = escapeBackslashExceptCodeblock(text);
|
|
38
41
|
const doc = atlassianMarkDownParser.parse(escapeLinks(textInput));
|
|
39
42
|
if (doc && doc.content) {
|
|
40
43
|
return new Slice(doc.content, openStart, openEnd);
|
|
@@ -44,6 +47,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
44
47
|
function escapeBackslashExceptCodeblock(textInput) {
|
|
45
48
|
const codeToken = '```';
|
|
46
49
|
if (!textInput.includes(codeToken)) {
|
|
50
|
+
// Ignored via go/ees005
|
|
51
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
47
52
|
return textInput.replace(/\\/g, '\\\\');
|
|
48
53
|
}
|
|
49
54
|
let isInsideCodeblock = false;
|
|
@@ -58,6 +63,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
58
63
|
}
|
|
59
64
|
if (!isInsideCodeblock) {
|
|
60
65
|
// only escape text which is not inside a codeblock
|
|
66
|
+
// Ignored via go/ees005
|
|
67
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
61
68
|
text = text.replace(/\\/g, '\\\\');
|
|
62
69
|
}
|
|
63
70
|
return text;
|
|
@@ -114,6 +121,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
114
121
|
slice = new Slice(Fragment.from(schema.text(text)), 1, 1);
|
|
115
122
|
}
|
|
116
123
|
if ((_text = text) !== null && _text !== void 0 && _text.includes('\r')) {
|
|
124
|
+
// Ignored via go/ees005
|
|
125
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
117
126
|
text = text.replace(/\r/g, '');
|
|
118
127
|
}
|
|
119
128
|
const isPastedFile = isPastedFileFromEvent(event);
|
|
@@ -446,6 +455,9 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
446
455
|
// splitting linebreaks into paragraphs must happen before upgrading text to lists
|
|
447
456
|
slice = splitParagraphs(slice, schema);
|
|
448
457
|
slice = upgradeTextToLists(slice, schema);
|
|
458
|
+
|
|
459
|
+
// Ignored via go/ees005
|
|
460
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
449
461
|
if (slice.content.childCount && slice.content.lastChild.type === schema.nodes.codeBlock) {
|
|
450
462
|
slice = new Slice(slice.content, 0, 0);
|
|
451
463
|
}
|
|
@@ -458,7 +470,11 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
458
470
|
// Fix for issue ED-4438
|
|
459
471
|
// text from google docs should not be pasted as inline code
|
|
460
472
|
if (html.indexOf('id="docs-internal-guid-') >= 0) {
|
|
473
|
+
// Ignored via go/ees005
|
|
474
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
461
475
|
html = html.replace(/white-space:pre/g, '');
|
|
476
|
+
// Ignored via go/ees005
|
|
477
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
462
478
|
html = html.replace(/white-space:pre-wrap/g, '');
|
|
463
479
|
}
|
|
464
480
|
|
|
@@ -141,7 +141,7 @@ function canContainImage(element) {
|
|
|
141
141
|
*/
|
|
142
142
|
export const unwrapNestedMediaElements = html => {
|
|
143
143
|
const parser = new DOMParser();
|
|
144
|
-
|
|
144
|
+
const doc = parser.parseFromString(html, 'text/html');
|
|
145
145
|
const wrapper = doc.body;
|
|
146
146
|
|
|
147
147
|
// Remove Google Doc's wrapper <b> el
|
|
@@ -112,6 +112,9 @@ export function insertSliceInsideOfPanelNodeSelected(panelNode) {
|
|
|
112
112
|
tr.setSelection(TextSelection.near(tr.doc.resolve(insertPosition + slice.content.size - slice.openStart - slice.openEnd + 1)));
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
+
|
|
116
|
+
// Ignored via go/ees005
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
115
118
|
const temporaryDoc = new Transform(tr.doc.type.createAndFill());
|
|
116
119
|
temporaryDoc.replaceRange(0, temporaryDoc.doc.content.size, slice);
|
|
117
120
|
const sliceWithoutInvalidListSurrounding = temporaryDoc.doc.slice(0);
|
|
@@ -522,6 +522,9 @@ async function getSmartLinkAdf(text, type, cardOptions) {
|
|
|
522
522
|
const provider = await cardOptions.provider;
|
|
523
523
|
return await provider.resolve(text, type);
|
|
524
524
|
}
|
|
525
|
+
|
|
526
|
+
// Ignored via go/ees005
|
|
527
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
525
528
|
function insertAutoMacro(slice, macro, view, from, to) {
|
|
526
529
|
if (view) {
|
|
527
530
|
// insert the text or linkified/md-converted clipboard data
|
|
@@ -544,6 +547,9 @@ function insertAutoMacro(slice, macro, view, from, to) {
|
|
|
544
547
|
}
|
|
545
548
|
return false;
|
|
546
549
|
}
|
|
550
|
+
|
|
551
|
+
// Ignored via go/ees005
|
|
552
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
547
553
|
export function handleMacroAutoConvert(text, slice, queueCardsFromChangedTr, runMacroAutoConvert, cardsOptions, extensionAutoConverter) {
|
|
548
554
|
return (state, dispatch, view) => {
|
|
549
555
|
let macro = null;
|
|
@@ -623,13 +629,19 @@ function isOnlyMedia(state, slice) {
|
|
|
623
629
|
const {
|
|
624
630
|
media
|
|
625
631
|
} = state.schema.nodes;
|
|
632
|
+
// Ignored via go/ees005
|
|
633
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
626
634
|
return slice.content.childCount === 1 && slice.content.firstChild.type === media;
|
|
627
635
|
}
|
|
628
636
|
function isOnlyMediaSingle(state, slice) {
|
|
629
637
|
const {
|
|
630
638
|
mediaSingle
|
|
631
639
|
} = state.schema.nodes;
|
|
632
|
-
return
|
|
640
|
+
return (
|
|
641
|
+
// Ignored via go/ees005
|
|
642
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
643
|
+
mediaSingle && slice.content.childCount === 1 && slice.content.firstChild.type === mediaSingle
|
|
644
|
+
);
|
|
633
645
|
}
|
|
634
646
|
export function handleMediaSingle(inputMethod, insertMediaAsMediaSingle) {
|
|
635
647
|
return function (slice) {
|
|
@@ -637,6 +649,8 @@ export function handleMediaSingle(inputMethod, insertMediaAsMediaSingle) {
|
|
|
637
649
|
if (view) {
|
|
638
650
|
if (isOnlyMedia(state, slice)) {
|
|
639
651
|
var _insertMediaAsMediaSi;
|
|
652
|
+
// Ignored via go/ees005
|
|
653
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
640
654
|
return (_insertMediaAsMediaSi = insertMediaAsMediaSingle === null || insertMediaAsMediaSingle === void 0 ? void 0 : insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod)) !== null && _insertMediaAsMediaSi !== void 0 ? _insertMediaAsMediaSi : false;
|
|
641
655
|
}
|
|
642
656
|
if (insideTable(state) && isOnlyMediaSingle(state, slice)) {
|
|
@@ -778,6 +792,9 @@ export function handleExpandPaste(slice, isNestingExpandsSupported) {
|
|
|
778
792
|
return false;
|
|
779
793
|
};
|
|
780
794
|
}
|
|
795
|
+
|
|
796
|
+
// Ignored via go/ees005
|
|
797
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
781
798
|
export function handleMarkdown(markdownSlice, queueCardsFromChangedTr, from, to) {
|
|
782
799
|
return (state, dispatch) => {
|
|
783
800
|
const tr = closeHistory(state.tr);
|
|
@@ -803,6 +820,8 @@ function removePrecedingBackTick(tr) {
|
|
|
803
820
|
},
|
|
804
821
|
from
|
|
805
822
|
} = tr.selection;
|
|
823
|
+
// Ignored via go/ees005
|
|
824
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
806
825
|
if (nodeBefore && nodeBefore.isText && nodeBefore.text.endsWith('`')) {
|
|
807
826
|
tr.delete(from - 1, from);
|
|
808
827
|
}
|
|
@@ -868,8 +887,8 @@ export function handleParagraphBlockMarks(state, slice) {
|
|
|
868
887
|
// element around the paragraph node
|
|
869
888
|
const grandparent = $from.node(Math.max(0, $from.depth - 1));
|
|
870
889
|
const markTypesInSlice = getTopLevelMarkTypesInSlice(slice);
|
|
871
|
-
|
|
872
|
-
for (
|
|
890
|
+
const forbiddenMarkTypes = [];
|
|
891
|
+
for (const markType of markTypesInSlice) {
|
|
873
892
|
if (!grandparent.type.allowsMarkType(markType)) {
|
|
874
893
|
forbiddenMarkTypes.push(markType);
|
|
875
894
|
}
|
|
@@ -974,7 +993,7 @@ export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrC
|
|
|
974
993
|
const textNodes = [heading, paragraph];
|
|
975
994
|
const selectionParent = selection.$to.node(selection.$to.depth - 1);
|
|
976
995
|
const noNeedForSafeInsert = selection.$to.node().type.validContent(slice.content) || textNodes.includes(selection.$to.node().type) && selectionParent.type.validContent(slice.content);
|
|
977
|
-
|
|
996
|
+
const panelParentOverCurrentSelection = findParentNodeOfType(panel)(tr.selection);
|
|
978
997
|
const isTargetPanelEmpty = panelParentOverCurrentSelection && ((_panelParentOverCurre = panelParentOverCurrentSelection.node) === null || _panelParentOverCurre === void 0 ? void 0 : _panelParentOverCurre.content.size) === 2;
|
|
979
998
|
let sliceContainsCodeblockOrMedia = false;
|
|
980
999
|
const codeBlockAndMediaNodes = ['codeBlock', 'mediaSingle', 'mediaGroup'];
|
|
@@ -14,12 +14,18 @@ export function isPastedFromExcel(html) {
|
|
|
14
14
|
return !!html && html.indexOf('urn:schemas-microsoft-com:office:excel') >= 0;
|
|
15
15
|
}
|
|
16
16
|
function isPastedFromDropboxPaper(html) {
|
|
17
|
+
// Ignored via go/ees005
|
|
18
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
17
19
|
return !!html && !!html.match(/class=\"\s?author-d-.+"/gim);
|
|
18
20
|
}
|
|
19
21
|
function isPastedFromGoogleDocs(html) {
|
|
22
|
+
// Ignored via go/ees005
|
|
23
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
20
24
|
return !!html && !!html.match(/id=\"docs-internal-guid-.+"/gim);
|
|
21
25
|
}
|
|
22
26
|
function isPastedFromGoogleSpreadSheets(html) {
|
|
27
|
+
// Ignored via go/ees005
|
|
28
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
23
29
|
return !!html && !!html.match(/data-sheets-.+=/gim);
|
|
24
30
|
}
|
|
25
31
|
function isPastedFromPages(html) {
|
|
@@ -32,9 +38,13 @@ export const isSingleLine = text => {
|
|
|
32
38
|
return !!text && text.trim().split('\n').length === 1;
|
|
33
39
|
};
|
|
34
40
|
export function htmlContainsSingleFile(html) {
|
|
41
|
+
// Ignored via go/ees005
|
|
42
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
35
43
|
return !!html.match(/<img .*>/) && !isMediaBlobUrl(html);
|
|
36
44
|
}
|
|
37
45
|
export function getPasteSource(event) {
|
|
46
|
+
// Ignored via go/ees005
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
38
48
|
const html = event.clipboardData.getData('text/html');
|
|
39
49
|
if (isPastedFromDropboxPaper(html)) {
|
|
40
50
|
return 'dropbox-paper';
|
|
@@ -70,7 +80,11 @@ export function getPasteSource(event) {
|
|
|
70
80
|
* check behaviour of double quotes in url strings
|
|
71
81
|
*/
|
|
72
82
|
export function escapeLinks(text) {
|
|
83
|
+
// Ignored via go/ees005
|
|
84
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
73
85
|
return text.replace(/(\[([^\]]+)\]\()?((https?|ftp|jamfselfservice):\/\/[^\s>"]+)/g, str => {
|
|
86
|
+
// Ignored via go/ees005
|
|
87
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
74
88
|
return str.match(/^(https?|ftp|jamfselfservice):\/\/[^\s>"]+$/) ? `<${str}>` : str;
|
|
75
89
|
});
|
|
76
90
|
}
|
|
@@ -172,11 +186,19 @@ export const htmlHasInvalidLinkTags = html => {
|
|
|
172
186
|
// <li><a href="http://www.atlassian.com\"<a> href="http://www.atlassian.com\"http://www.atlassian.com</a></a></li>">
|
|
173
187
|
export const removeDuplicateInvalidLinks = html => {
|
|
174
188
|
if (htmlHasInvalidLinkTags(html)) {
|
|
189
|
+
// Ignored via go/ees005
|
|
190
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
175
191
|
const htmlArray = html.split(/(?=<a)/);
|
|
176
192
|
const htmlArrayWithoutInvalidLinks = htmlArray.filter(item => {
|
|
177
193
|
return !(item.includes('<a') && item.includes('"></a>')) && !(item.includes('<a') && !item.includes('</a>'));
|
|
178
194
|
});
|
|
179
|
-
const fixedHtml = htmlArrayWithoutInvalidLinks.join('')
|
|
195
|
+
const fixedHtml = htmlArrayWithoutInvalidLinks.join('')
|
|
196
|
+
// Ignored via go/ees005
|
|
197
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
198
|
+
.replace(/<\/a><\/a>/gi, '</a>')
|
|
199
|
+
// Ignored via go/ees005
|
|
200
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
201
|
+
.replace(/<a>/gi, '<a');
|
|
180
202
|
return fixedHtml;
|
|
181
203
|
}
|
|
182
204
|
return html;
|
|
@@ -4,7 +4,10 @@ const isPastedFromTinyMCE = pasteEvent => {
|
|
|
4
4
|
return (_pasteEvent$clipboard = pasteEvent === null || pasteEvent === void 0 ? void 0 : (_pasteEvent$clipboard2 = pasteEvent.clipboardData) === null || _pasteEvent$clipboard2 === void 0 ? void 0 : (_pasteEvent$clipboard3 = _pasteEvent$clipboard2.types) === null || _pasteEvent$clipboard3 === void 0 ? void 0 : _pasteEvent$clipboard3.some(mimeType => mimeType === 'x-tinymce/html')) !== null && _pasteEvent$clipboard !== void 0 ? _pasteEvent$clipboard : false;
|
|
5
5
|
};
|
|
6
6
|
export const isPastedFromTinyMCEConfluence = (pasteEvent, html) => {
|
|
7
|
-
return isPastedFromTinyMCE(pasteEvent) && !!html &&
|
|
7
|
+
return isPastedFromTinyMCE(pasteEvent) && !!html &&
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
10
|
+
!!html.match(/class=\"\s?(confluenceTd|confluenceTh|confluenceTable).+"/gim);
|
|
8
11
|
};
|
|
9
12
|
|
|
10
13
|
/**
|
|
@@ -105,6 +108,8 @@ const fillIncompleteRowWithEmptyCells = (doc, thCount, cellCount) => {
|
|
|
105
108
|
* headers exist.
|
|
106
109
|
*/
|
|
107
110
|
export const tryReconstructTableRows = doc => {
|
|
111
|
+
// Ignored via go/ees005
|
|
112
|
+
// eslint-disable-next-line prefer-const
|
|
108
113
|
let {
|
|
109
114
|
cellCount,
|
|
110
115
|
thCount,
|
|
@@ -37,7 +37,11 @@ export var stopTrackingPastedMacroPositions = function stopTrackingPastedMacroPo
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
// matchers for text lists
|
|
40
|
+
// Ignored via go/ees005
|
|
41
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
40
42
|
var bullets = /^\s*[\*\-\u2022](\s+|\s+$)/;
|
|
43
|
+
// Ignored via go/ees005
|
|
44
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
41
45
|
var numbers = /^\s*\d[\.\)](\s+|$)/;
|
|
42
46
|
var isListItem = function isListItem(node, schema) {
|
|
43
47
|
return Boolean(node && node.type === schema.nodes.listItem);
|
|
@@ -59,6 +63,9 @@ var getListType = function getListType(node, schema) {
|
|
|
59
63
|
if (lastMatch) {
|
|
60
64
|
return lastMatch;
|
|
61
65
|
}
|
|
66
|
+
|
|
67
|
+
// Ignored via go/ees005
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
62
69
|
var match = node.text.match(listType.matcher);
|
|
63
70
|
return match ? [listType.node, match[0].length] : lastMatch;
|
|
64
71
|
}, null);
|
|
@@ -100,6 +107,9 @@ export var extractListFromParagraph = function extractListFromParagraph(node, pa
|
|
|
100
107
|
orderedList = _schema$nodes2.orderedList;
|
|
101
108
|
var splitListsAndParagraphs = [];
|
|
102
109
|
var paragraphParts = [];
|
|
110
|
+
|
|
111
|
+
// Ignored via go/ees005
|
|
112
|
+
// eslint-disable-next-line no-var
|
|
103
113
|
for (var index = 0; index < linesSplitByHardbreaks.length; index = index + 1) {
|
|
104
114
|
var _firstNonHardBreakNod;
|
|
105
115
|
var line = linesSplitByHardbreaks[index];
|
|
@@ -153,6 +163,10 @@ export var extractListFromParagraph = function extractListFromParagraph(node, pa
|
|
|
153
163
|
continue;
|
|
154
164
|
}
|
|
155
165
|
var attrs = nodeType === orderedList ? {
|
|
166
|
+
// Ignored via go/ees005
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
168
|
+
// Ignored via go/ees005
|
|
169
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
156
170
|
order: parseInt(firstNonHardBreakNode.text.split('.')[0])
|
|
157
171
|
} : undefined;
|
|
158
172
|
var newList = nodeType.createChecked(attrs, [listItemNode]);
|
|
@@ -286,5 +300,8 @@ export var splitIntoParagraphs = function splitIntoParagraphs(_ref) {
|
|
|
286
300
|
if (curChildren.length) {
|
|
287
301
|
paragraphs.push(paragraph.createChecked(undefined, curChildren, _toConsumableArray(blockMarks)));
|
|
288
302
|
}
|
|
289
|
-
return Fragment.from(paragraphs.length ? paragraphs :
|
|
303
|
+
return Fragment.from(paragraphs.length ? paragraphs :
|
|
304
|
+
// Ignored via go/ees005
|
|
305
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
306
|
+
[paragraph.createAndFill(undefined, undefined, _toConsumableArray(blockMarks))]);
|
|
290
307
|
};
|
|
@@ -144,6 +144,9 @@ function createPastePayload(actionSubjectId, attributes, linkDomain) {
|
|
|
144
144
|
}
|
|
145
145
|
} : {});
|
|
146
146
|
}
|
|
147
|
+
|
|
148
|
+
// Ignored via go/ees005
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
147
150
|
function createPasteAnalyticsPayloadBySelection(event, slice, pasteContext, pluginInjectionApi) {
|
|
148
151
|
return function (selection) {
|
|
149
152
|
var _pluginInjectionApi$m;
|
|
@@ -240,6 +243,9 @@ function createPasteAnalyticsPayloadBySelection(event, slice, pasteContext, plug
|
|
|
240
243
|
}, linkDomains);
|
|
241
244
|
};
|
|
242
245
|
}
|
|
246
|
+
|
|
247
|
+
// Ignored via go/ees005
|
|
248
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
243
249
|
export function createPasteAnalyticsPayload(view, event, slice, pasteContext) {
|
|
244
250
|
return createPasteAnalyticsPayloadBySelection(event, slice, pasteContext)(view.state.selection);
|
|
245
251
|
}
|
|
@@ -248,12 +254,16 @@ export function createPasteAnalyticsPayload(view, event, slice, pasteContext) {
|
|
|
248
254
|
// However, handlers like handleMacroAutoConvert dispatch multiple time,
|
|
249
255
|
// so pasteCommandWithAnalytics is useless in this case.
|
|
250
256
|
export var sendPasteAnalyticsEvent = function sendPasteAnalyticsEvent(editorAnalyticsAPI) {
|
|
251
|
-
return
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
+
return (
|
|
258
|
+
// Ignored via go/ees005
|
|
259
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
260
|
+
function (view, event, slice, pasteContext) {
|
|
261
|
+
var tr = view.state.tr;
|
|
262
|
+
var payload = createPasteAnalyticsPayload(view, event, slice, pasteContext);
|
|
263
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
264
|
+
view.dispatch(tr);
|
|
265
|
+
}
|
|
266
|
+
);
|
|
257
267
|
};
|
|
258
268
|
export var handlePasteAsPlainTextWithAnalytics = function handlePasteAsPlainTextWithAnalytics(editorAnalyticsAPI) {
|
|
259
269
|
return function (view, event, slice) {
|
|
@@ -263,46 +273,69 @@ export var handlePasteAsPlainTextWithAnalytics = function handlePasteAsPlainText
|
|
|
263
273
|
}))(handlePasteAsPlainText(slice, event, editorAnalyticsAPI));
|
|
264
274
|
};
|
|
265
275
|
};
|
|
266
|
-
export var handlePasteIntoTaskAndDecisionWithAnalytics = function handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, type, pluginInjectionApi
|
|
276
|
+
export var handlePasteIntoTaskAndDecisionWithAnalytics = function handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, type, pluginInjectionApi
|
|
277
|
+
// Ignored via go/ees005
|
|
278
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
279
|
+
) {
|
|
267
280
|
var _pluginInjectionApi$a, _pluginInjectionApi$c;
|
|
268
281
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
269
282
|
type: type
|
|
270
283
|
}))(handlePasteIntoTaskOrDecisionOrPanel(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.actions) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.queueCardsFromChangedTr));
|
|
271
284
|
};
|
|
272
285
|
export var handlePasteIntoCaptionWithAnalytics = function handlePasteIntoCaptionWithAnalytics(editorAnalyticsAPI) {
|
|
273
|
-
return
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
286
|
+
return (
|
|
287
|
+
// Ignored via go/ees005
|
|
288
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
289
|
+
function (view, event, slice, type) {
|
|
290
|
+
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
291
|
+
type: type
|
|
292
|
+
}))(handlePasteIntoCaption(slice));
|
|
293
|
+
}
|
|
294
|
+
);
|
|
278
295
|
};
|
|
279
296
|
export var handleCodeBlockWithAnalytics = function handleCodeBlockWithAnalytics(editorAnalyticsAPI) {
|
|
280
|
-
return
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
297
|
+
return (
|
|
298
|
+
// Ignored via go/ees005
|
|
299
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
300
|
+
function (view, event, slice, text) {
|
|
301
|
+
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
302
|
+
type: PasteTypes.plain
|
|
303
|
+
}))(handleCodeBlock(text));
|
|
304
|
+
}
|
|
305
|
+
);
|
|
285
306
|
};
|
|
286
307
|
export var handleMediaSingleWithAnalytics = function handleMediaSingleWithAnalytics(editorAnalyticsAPI) {
|
|
287
|
-
return function (view, event, slice, type, insertMediaAsMediaSingle
|
|
308
|
+
return function (view, event, slice, type, insertMediaAsMediaSingle
|
|
309
|
+
// Ignored via go/ees005
|
|
310
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
311
|
+
) {
|
|
288
312
|
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
289
313
|
type: type
|
|
290
314
|
}))(handleMediaSingle(INPUT_METHOD.CLIPBOARD, insertMediaAsMediaSingle)(slice));
|
|
291
315
|
};
|
|
292
316
|
};
|
|
293
|
-
export var handlePastePreservingMarksWithAnalytics = function handlePastePreservingMarksWithAnalytics(view, event, slice, type, pluginInjectionApi
|
|
317
|
+
export var handlePastePreservingMarksWithAnalytics = function handlePastePreservingMarksWithAnalytics(view, event, slice, type, pluginInjectionApi
|
|
318
|
+
// Ignored via go/ees005
|
|
319
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
320
|
+
) {
|
|
294
321
|
var _pluginInjectionApi$a2, _pluginInjectionApi$c2;
|
|
295
322
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
296
323
|
type: type
|
|
297
324
|
}))(handlePastePreservingMarks(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.actions) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.queueCardsFromChangedTr));
|
|
298
325
|
};
|
|
299
|
-
export var handleMarkdownWithAnalytics = function handleMarkdownWithAnalytics(view, event, slice, pluginInjectionApi
|
|
326
|
+
export var handleMarkdownWithAnalytics = function handleMarkdownWithAnalytics(view, event, slice, pluginInjectionApi
|
|
327
|
+
// Ignored via go/ees005
|
|
328
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
329
|
+
) {
|
|
300
330
|
var _pluginInjectionApi$a3, _pluginInjectionApi$c3;
|
|
301
331
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
302
332
|
type: PasteTypes.markdown
|
|
303
333
|
}))(handleMarkdown(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.card) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.actions) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.queueCardsFromChangedTr));
|
|
304
334
|
};
|
|
305
|
-
export var handleRichTextWithAnalytics = function handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported
|
|
335
|
+
export var handleRichTextWithAnalytics = function handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported
|
|
336
|
+
// Ignored via go/ees005
|
|
337
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
338
|
+
) {
|
|
306
339
|
var _pluginInjectionApi$a4, _pluginInjectionApi$c4;
|
|
307
340
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
308
341
|
type: PasteTypes.richText
|
|
@@ -332,7 +365,10 @@ var injectAnalyticsPayloadBeforeCommand = function injectAnalyticsPayloadBeforeC
|
|
|
332
365
|
};
|
|
333
366
|
};
|
|
334
367
|
export var handlePastePanelOrDecisionIntoListWithAnalytics = function handlePastePanelOrDecisionIntoListWithAnalytics(editorAnalyticsAPI) {
|
|
335
|
-
return function (view, event, slice, findRootParentListNode
|
|
368
|
+
return function (view, event, slice, findRootParentListNode
|
|
369
|
+
// Ignored via go/ees005
|
|
370
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
371
|
+
) {
|
|
336
372
|
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
337
373
|
type: PasteTypes.richText
|
|
338
374
|
}))(handlePastePanelOrDecisionContentIntoList(slice, findRootParentListNode));
|
|
@@ -370,12 +406,16 @@ export var handleSelectedTableWithAnalytics = function handleSelectedTableWithAn
|
|
|
370
406
|
};
|
|
371
407
|
};
|
|
372
408
|
export var handlePasteLinkOnSelectedTextWithAnalytics = function handlePasteLinkOnSelectedTextWithAnalytics(editorAnalyticsAPI) {
|
|
373
|
-
return
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
409
|
+
return (
|
|
410
|
+
// Ignored via go/ees005
|
|
411
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
412
|
+
function (view, event, slice, type) {
|
|
413
|
+
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
414
|
+
type: type,
|
|
415
|
+
hyperlinkPasteOnText: true
|
|
416
|
+
}))(handlePasteLinkOnSelectedText(slice));
|
|
417
|
+
}
|
|
418
|
+
);
|
|
379
419
|
};
|
|
380
420
|
export var createPasteMeasurePayload = function createPasteMeasurePayload(_ref3) {
|
|
381
421
|
var view = _ref3.view,
|
|
@@ -29,6 +29,9 @@ export var isInsideBlockQuote = function isInsideBlockQuote(state) {
|
|
|
29
29
|
return hasParentNodeOfType(blockquote)(state.selection);
|
|
30
30
|
};
|
|
31
31
|
var PASTE = 'Editor Paste Plugin Paste Duration';
|
|
32
|
+
|
|
33
|
+
// Ignored via go/ees005
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
32
35
|
export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
33
36
|
var _pluginInjectionApi$a;
|
|
34
37
|
var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
@@ -44,6 +47,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
44
47
|
function escapeBackslashExceptCodeblock(textInput) {
|
|
45
48
|
var codeToken = '```';
|
|
46
49
|
if (!textInput.includes(codeToken)) {
|
|
50
|
+
// Ignored via go/ees005
|
|
51
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
47
52
|
return textInput.replace(/\\/g, '\\\\');
|
|
48
53
|
}
|
|
49
54
|
var isInsideCodeblock = false;
|
|
@@ -58,6 +63,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
58
63
|
}
|
|
59
64
|
if (!isInsideCodeblock) {
|
|
60
65
|
// only escape text which is not inside a codeblock
|
|
66
|
+
// Ignored via go/ees005
|
|
67
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
61
68
|
text = text.replace(/\\/g, '\\\\');
|
|
62
69
|
}
|
|
63
70
|
return text;
|
|
@@ -137,6 +144,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
137
144
|
slice = new Slice(Fragment.from(schema.text(text)), 1, 1);
|
|
138
145
|
}
|
|
139
146
|
if ((_text = text) !== null && _text !== void 0 && _text.includes('\r')) {
|
|
147
|
+
// Ignored via go/ees005
|
|
148
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
140
149
|
text = text.replace(/\r/g, '');
|
|
141
150
|
}
|
|
142
151
|
var isPastedFile = isPastedFileFromEvent(event);
|
|
@@ -464,6 +473,9 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
464
473
|
// splitting linebreaks into paragraphs must happen before upgrading text to lists
|
|
465
474
|
slice = splitParagraphs(slice, schema);
|
|
466
475
|
slice = upgradeTextToLists(slice, schema);
|
|
476
|
+
|
|
477
|
+
// Ignored via go/ees005
|
|
478
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
467
479
|
if (slice.content.childCount && slice.content.lastChild.type === schema.nodes.codeBlock) {
|
|
468
480
|
slice = new Slice(slice.content, 0, 0);
|
|
469
481
|
}
|
|
@@ -476,7 +488,11 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
476
488
|
// Fix for issue ED-4438
|
|
477
489
|
// text from google docs should not be pasted as inline code
|
|
478
490
|
if (html.indexOf('id="docs-internal-guid-') >= 0) {
|
|
491
|
+
// Ignored via go/ees005
|
|
492
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
479
493
|
html = html.replace(/white-space:pre/g, '');
|
|
494
|
+
// Ignored via go/ees005
|
|
495
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
480
496
|
html = html.replace(/white-space:pre-wrap/g, '');
|
|
481
497
|
}
|
|
482
498
|
|
|
@@ -97,6 +97,9 @@ export function insertSliceInsideOfPanelNodeSelected(panelNode) {
|
|
|
97
97
|
tr.setSelection(TextSelection.near(tr.doc.resolve(insertPosition + slice.content.size - slice.openStart - slice.openEnd + 1)));
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
+
|
|
101
|
+
// Ignored via go/ees005
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
100
103
|
var temporaryDoc = new Transform(tr.doc.type.createAndFill());
|
|
101
104
|
temporaryDoc.replaceRange(0, temporaryDoc.doc.content.size, slice);
|
|
102
105
|
var sliceWithoutInvalidListSurrounding = temporaryDoc.doc.slice(0);
|
|
@@ -497,7 +497,8 @@ export function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
497
497
|
}
|
|
498
498
|
function getSmartLinkAdf(_x, _x2, _x3) {
|
|
499
499
|
return _getSmartLinkAdf.apply(this, arguments);
|
|
500
|
-
}
|
|
500
|
+
} // Ignored via go/ees005
|
|
501
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
501
502
|
function _getSmartLinkAdf() {
|
|
502
503
|
_getSmartLinkAdf = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(text, type, cardOptions) {
|
|
503
504
|
var provider;
|
|
@@ -548,6 +549,9 @@ function insertAutoMacro(slice, macro, view, from, to) {
|
|
|
548
549
|
}
|
|
549
550
|
return false;
|
|
550
551
|
}
|
|
552
|
+
|
|
553
|
+
// Ignored via go/ees005
|
|
554
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
551
555
|
export function handleMacroAutoConvert(text, slice, queueCardsFromChangedTr, runMacroAutoConvert, cardsOptions, extensionAutoConverter) {
|
|
552
556
|
return function (state, dispatch, view) {
|
|
553
557
|
var macro = null;
|
|
@@ -618,11 +622,17 @@ export function handleCodeBlock(text) {
|
|
|
618
622
|
}
|
|
619
623
|
function isOnlyMedia(state, slice) {
|
|
620
624
|
var media = state.schema.nodes.media;
|
|
625
|
+
// Ignored via go/ees005
|
|
626
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
621
627
|
return slice.content.childCount === 1 && slice.content.firstChild.type === media;
|
|
622
628
|
}
|
|
623
629
|
function isOnlyMediaSingle(state, slice) {
|
|
624
630
|
var mediaSingle = state.schema.nodes.mediaSingle;
|
|
625
|
-
return
|
|
631
|
+
return (
|
|
632
|
+
// Ignored via go/ees005
|
|
633
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
634
|
+
mediaSingle && slice.content.childCount === 1 && slice.content.firstChild.type === mediaSingle
|
|
635
|
+
);
|
|
626
636
|
}
|
|
627
637
|
export function handleMediaSingle(inputMethod, insertMediaAsMediaSingle) {
|
|
628
638
|
return function (slice) {
|
|
@@ -630,6 +640,8 @@ export function handleMediaSingle(inputMethod, insertMediaAsMediaSingle) {
|
|
|
630
640
|
if (view) {
|
|
631
641
|
if (isOnlyMedia(state, slice)) {
|
|
632
642
|
var _insertMediaAsMediaSi;
|
|
643
|
+
// Ignored via go/ees005
|
|
644
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
633
645
|
return (_insertMediaAsMediaSi = insertMediaAsMediaSingle === null || insertMediaAsMediaSingle === void 0 ? void 0 : insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod)) !== null && _insertMediaAsMediaSi !== void 0 ? _insertMediaAsMediaSi : false;
|
|
634
646
|
}
|
|
635
647
|
if (insideTable(state) && isOnlyMediaSingle(state, slice)) {
|
|
@@ -760,6 +772,9 @@ export function handleExpandPaste(slice, isNestingExpandsSupported) {
|
|
|
760
772
|
return false;
|
|
761
773
|
};
|
|
762
774
|
}
|
|
775
|
+
|
|
776
|
+
// Ignored via go/ees005
|
|
777
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
763
778
|
export function handleMarkdown(markdownSlice, queueCardsFromChangedTr, from, to) {
|
|
764
779
|
return function (state, dispatch) {
|
|
765
780
|
var tr = closeHistory(state.tr);
|
|
@@ -782,6 +797,8 @@ function removePrecedingBackTick(tr) {
|
|
|
782
797
|
var _tr$selection = tr.selection,
|
|
783
798
|
nodeBefore = _tr$selection.$from.nodeBefore,
|
|
784
799
|
from = _tr$selection.from;
|
|
800
|
+
// Ignored via go/ees005
|
|
801
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
785
802
|
if (nodeBefore && nodeBefore.isText && nodeBefore.text.endsWith('`')) {
|
|
786
803
|
tr.delete(from - 1, from);
|
|
787
804
|
}
|