@atlaskit/editor-plugin-paste 2.0.19 → 2.1.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 +22 -0
- package/dist/cjs/pm-plugins/analytics.js +28 -68
- package/dist/cjs/pm-plugins/main.js +17 -20
- package/dist/cjs/pm-plugins/util/handlers.js +1 -8
- package/dist/es2019/pm-plugins/analytics.js +10 -46
- package/dist/es2019/pm-plugins/main.js +17 -20
- package/dist/es2019/pm-plugins/util/handlers.js +0 -9
- package/dist/esm/pm-plugins/analytics.js +28 -68
- package/dist/esm/pm-plugins/main.js +17 -20
- package/dist/esm/pm-plugins/util/handlers.js +1 -8
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#109060](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109060)
|
|
8
|
+
[`4660ec858a305`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4660ec858a305) -
|
|
9
|
+
Update `React` from v16 to v18
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 2.0.20
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#104508](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/104508)
|
|
20
|
+
[`8fb009b2b619c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8fb009b2b619c) -
|
|
21
|
+
[ux] [ED-26221] Fix pasting order for tables, nested tables and tasks and decisions (panels). This
|
|
22
|
+
ensures when pasting a table inside a panel inside a table replaces the panel with the table.
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 2.0.19
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -156,9 +156,6 @@ function createPastePayload(actionSubjectId, attributes, linkDomain) {
|
|
|
156
156
|
}
|
|
157
157
|
} : {});
|
|
158
158
|
}
|
|
159
|
-
|
|
160
|
-
// Ignored via go/ees005
|
|
161
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
162
159
|
function createPasteAnalyticsPayloadBySelection(event, slice, pasteContext, pluginInjectionApi) {
|
|
163
160
|
return function (selection) {
|
|
164
161
|
var _pluginInjectionApi$m;
|
|
@@ -255,9 +252,6 @@ function createPasteAnalyticsPayloadBySelection(event, slice, pasteContext, plug
|
|
|
255
252
|
}, linkDomains);
|
|
256
253
|
};
|
|
257
254
|
}
|
|
258
|
-
|
|
259
|
-
// Ignored via go/ees005
|
|
260
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
261
255
|
function createPasteAnalyticsPayload(view, event, slice, pasteContext) {
|
|
262
256
|
return createPasteAnalyticsPayloadBySelection(event, slice, pasteContext)(view.state.selection);
|
|
263
257
|
}
|
|
@@ -266,16 +260,12 @@ function createPasteAnalyticsPayload(view, event, slice, pasteContext) {
|
|
|
266
260
|
// However, handlers like handleMacroAutoConvert dispatch multiple time,
|
|
267
261
|
// so pasteCommandWithAnalytics is useless in this case.
|
|
268
262
|
var sendPasteAnalyticsEvent = exports.sendPasteAnalyticsEvent = function sendPasteAnalyticsEvent(editorAnalyticsAPI) {
|
|
269
|
-
return (
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
276
|
-
view.dispatch(tr);
|
|
277
|
-
}
|
|
278
|
-
);
|
|
263
|
+
return function (view, event, slice, pasteContext) {
|
|
264
|
+
var tr = view.state.tr;
|
|
265
|
+
var payload = createPasteAnalyticsPayload(view, event, slice, pasteContext);
|
|
266
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
267
|
+
view.dispatch(tr);
|
|
268
|
+
};
|
|
279
269
|
};
|
|
280
270
|
var handlePasteAsPlainTextWithAnalytics = exports.handlePasteAsPlainTextWithAnalytics = function handlePasteAsPlainTextWithAnalytics(editorAnalyticsAPI) {
|
|
281
271
|
return function (view, event, slice) {
|
|
@@ -285,69 +275,46 @@ var handlePasteAsPlainTextWithAnalytics = exports.handlePasteAsPlainTextWithAnal
|
|
|
285
275
|
}))((0, _handlers.handlePasteAsPlainText)(slice, event, editorAnalyticsAPI));
|
|
286
276
|
};
|
|
287
277
|
};
|
|
288
|
-
var handlePasteIntoTaskAndDecisionWithAnalytics = exports.handlePasteIntoTaskAndDecisionWithAnalytics = function handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, type, pluginInjectionApi
|
|
289
|
-
// Ignored via go/ees005
|
|
290
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
291
|
-
) {
|
|
278
|
+
var handlePasteIntoTaskAndDecisionWithAnalytics = exports.handlePasteIntoTaskAndDecisionWithAnalytics = function handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, type, pluginInjectionApi) {
|
|
292
279
|
var _pluginInjectionApi$a, _pluginInjectionApi$c;
|
|
293
280
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
294
281
|
type: type
|
|
295
282
|
}))((0, _handlers.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));
|
|
296
283
|
};
|
|
297
284
|
var handlePasteIntoCaptionWithAnalytics = exports.handlePasteIntoCaptionWithAnalytics = function handlePasteIntoCaptionWithAnalytics(editorAnalyticsAPI) {
|
|
298
|
-
return (
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
type: type
|
|
304
|
-
}))((0, _handlers.handlePasteIntoCaption)(slice));
|
|
305
|
-
}
|
|
306
|
-
);
|
|
285
|
+
return function (view, event, slice, type) {
|
|
286
|
+
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
287
|
+
type: type
|
|
288
|
+
}))((0, _handlers.handlePasteIntoCaption)(slice));
|
|
289
|
+
};
|
|
307
290
|
};
|
|
308
291
|
var handleCodeBlockWithAnalytics = exports.handleCodeBlockWithAnalytics = function handleCodeBlockWithAnalytics(editorAnalyticsAPI) {
|
|
309
|
-
return (
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
type: _analytics.PasteTypes.plain
|
|
315
|
-
}))((0, _handlers.handleCodeBlock)(text));
|
|
316
|
-
}
|
|
317
|
-
);
|
|
292
|
+
return function (view, event, slice, text) {
|
|
293
|
+
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
294
|
+
type: _analytics.PasteTypes.plain
|
|
295
|
+
}))((0, _handlers.handleCodeBlock)(text));
|
|
296
|
+
};
|
|
318
297
|
};
|
|
319
298
|
var handleMediaSingleWithAnalytics = exports.handleMediaSingleWithAnalytics = function handleMediaSingleWithAnalytics(editorAnalyticsAPI) {
|
|
320
|
-
return function (view, event, slice, type, insertMediaAsMediaSingle
|
|
321
|
-
// Ignored via go/ees005
|
|
322
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
323
|
-
) {
|
|
299
|
+
return function (view, event, slice, type, insertMediaAsMediaSingle) {
|
|
324
300
|
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
325
301
|
type: type
|
|
326
302
|
}))((0, _handlers.handleMediaSingle)(_analytics.INPUT_METHOD.CLIPBOARD, insertMediaAsMediaSingle)(slice));
|
|
327
303
|
};
|
|
328
304
|
};
|
|
329
|
-
var handlePastePreservingMarksWithAnalytics = exports.handlePastePreservingMarksWithAnalytics = function handlePastePreservingMarksWithAnalytics(view, event, slice, type, pluginInjectionApi
|
|
330
|
-
// Ignored via go/ees005
|
|
331
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
332
|
-
) {
|
|
305
|
+
var handlePastePreservingMarksWithAnalytics = exports.handlePastePreservingMarksWithAnalytics = function handlePastePreservingMarksWithAnalytics(view, event, slice, type, pluginInjectionApi) {
|
|
333
306
|
var _pluginInjectionApi$a2, _pluginInjectionApi$c2;
|
|
334
307
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
335
308
|
type: type
|
|
336
309
|
}))((0, _handlers.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));
|
|
337
310
|
};
|
|
338
|
-
var handleMarkdownWithAnalytics = exports.handleMarkdownWithAnalytics = function handleMarkdownWithAnalytics(view, event, slice, pluginInjectionApi
|
|
339
|
-
// Ignored via go/ees005
|
|
340
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
341
|
-
) {
|
|
311
|
+
var handleMarkdownWithAnalytics = exports.handleMarkdownWithAnalytics = function handleMarkdownWithAnalytics(view, event, slice, pluginInjectionApi) {
|
|
342
312
|
var _pluginInjectionApi$a3, _pluginInjectionApi$c3;
|
|
343
313
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
344
314
|
type: _analytics.PasteTypes.markdown
|
|
345
315
|
}))((0, _handlers.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));
|
|
346
316
|
};
|
|
347
|
-
var handleRichTextWithAnalytics = exports.handleRichTextWithAnalytics = function handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported
|
|
348
|
-
// Ignored via go/ees005
|
|
349
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
350
|
-
) {
|
|
317
|
+
var handleRichTextWithAnalytics = exports.handleRichTextWithAnalytics = function handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported) {
|
|
351
318
|
var _pluginInjectionApi$a4, _pluginInjectionApi$c4;
|
|
352
319
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
353
320
|
type: _analytics.PasteTypes.richText
|
|
@@ -377,10 +344,7 @@ var injectAnalyticsPayloadBeforeCommand = function injectAnalyticsPayloadBeforeC
|
|
|
377
344
|
};
|
|
378
345
|
};
|
|
379
346
|
var handlePastePanelOrDecisionIntoListWithAnalytics = exports.handlePastePanelOrDecisionIntoListWithAnalytics = function handlePastePanelOrDecisionIntoListWithAnalytics(editorAnalyticsAPI) {
|
|
380
|
-
return function (view, event, slice, findRootParentListNode
|
|
381
|
-
// Ignored via go/ees005
|
|
382
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
383
|
-
) {
|
|
347
|
+
return function (view, event, slice, findRootParentListNode) {
|
|
384
348
|
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
385
349
|
type: _analytics.PasteTypes.richText
|
|
386
350
|
}))((0, _handlers.handlePastePanelOrDecisionContentIntoList)(slice, findRootParentListNode));
|
|
@@ -418,16 +382,12 @@ var handleSelectedTableWithAnalytics = exports.handleSelectedTableWithAnalytics
|
|
|
418
382
|
};
|
|
419
383
|
};
|
|
420
384
|
var handlePasteLinkOnSelectedTextWithAnalytics = exports.handlePasteLinkOnSelectedTextWithAnalytics = function handlePasteLinkOnSelectedTextWithAnalytics(editorAnalyticsAPI) {
|
|
421
|
-
return (
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
hyperlinkPasteOnText: true
|
|
428
|
-
}))((0, _handlers.handlePasteLinkOnSelectedText)(slice));
|
|
429
|
-
}
|
|
430
|
-
);
|
|
385
|
+
return function (view, event, slice, type) {
|
|
386
|
+
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
387
|
+
type: type,
|
|
388
|
+
hyperlinkPasteOnText: true
|
|
389
|
+
}))((0, _handlers.handlePasteLinkOnSelectedText)(slice));
|
|
390
|
+
};
|
|
431
391
|
};
|
|
432
392
|
var createPasteMeasurePayload = exports.createPasteMeasurePayload = function createPasteMeasurePayload(_ref3) {
|
|
433
393
|
var view = _ref3.view,
|
|
@@ -37,9 +37,6 @@ var isInsideBlockQuote = exports.isInsideBlockQuote = function isInsideBlockQuot
|
|
|
37
37
|
return (0, _utils2.hasParentNodeOfType)(blockquote)(state.selection);
|
|
38
38
|
};
|
|
39
39
|
var PASTE = 'Editor Paste Plugin Paste Duration';
|
|
40
|
-
|
|
41
|
-
// Ignored via go/ees005
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
43
40
|
function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
44
41
|
var _pluginInjectionApi$a;
|
|
45
42
|
var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
@@ -340,9 +337,6 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
340
337
|
// @ts-ignore - [unblock prosemirror bump] assigning to readonly prop
|
|
341
338
|
slice.openStart = 1;
|
|
342
339
|
}
|
|
343
|
-
if ((0, _analytics2.handlePasteIntoTaskAndDecisionWithAnalytics)(view, event, slice, isPlainText ? _analytics.PasteTypes.plain : _analytics.PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
|
|
344
|
-
return true;
|
|
345
|
-
}
|
|
346
340
|
|
|
347
341
|
// If we're in a code block, append the text contents of clipboard inside it
|
|
348
342
|
if ((0, _analytics2.handleCodeBlockWithAnalytics)(editorAnalyticsAPI)(view, event, slice, text)(state, dispatch)) {
|
|
@@ -361,6 +355,23 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
361
355
|
isNestedMarkdownTable = !!(markdownSlice && isPlainText && isParentNodeTdOrTh && (0, _analytics2.getContentNodeTypes)(markdownSlice.content).includes((_schema$nodes$table = schema.nodes.table) === null || _schema$nodes$table === void 0 ? void 0 : _schema$nodes$table.name));
|
|
362
356
|
slice = isNestedMarkdownTable ? markdownSlice : slice;
|
|
363
357
|
|
|
358
|
+
// get editor-tables to handle pasting tables if it can
|
|
359
|
+
// otherwise, just the replace the selection with the content
|
|
360
|
+
if ((0, _utils3.handlePaste)(view, null, slice)) {
|
|
361
|
+
(0, _analytics2.sendPasteAnalyticsEvent)(editorAnalyticsAPI)(view, event, slice, {
|
|
362
|
+
type: _analytics.PasteTypes.richText
|
|
363
|
+
});
|
|
364
|
+
return true;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// handle paste of nested tables to ensure nesting limits are respected
|
|
368
|
+
if ((0, _analytics2.handleNestedTablePasteWithAnalytics)(editorAnalyticsAPI, (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes'))(view, event, slice)(state, dispatch)) {
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
if ((0, _analytics2.handlePasteIntoTaskAndDecisionWithAnalytics)(view, event, slice, isPlainText ? _analytics.PasteTypes.plain : _analytics.PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
|
|
364
375
|
// If the clipboard only contains plain text, attempt to parse it as Markdown
|
|
365
376
|
if (isPlainText && markdownSlice && !isNestedMarkdownTable) {
|
|
366
377
|
if ((0, _analytics2.handlePastePreservingMarksWithAnalytics)(view, event, markdownSlice, _analytics.PasteTypes.markdown, pluginInjectionApi)(state, dispatch)) {
|
|
@@ -404,20 +415,6 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
404
415
|
return true;
|
|
405
416
|
}
|
|
406
417
|
|
|
407
|
-
// get editor-tables to handle pasting tables if it can
|
|
408
|
-
// otherwise, just the replace the selection with the content
|
|
409
|
-
if ((0, _utils3.handlePaste)(view, null, slice)) {
|
|
410
|
-
(0, _analytics2.sendPasteAnalyticsEvent)(editorAnalyticsAPI)(view, event, slice, {
|
|
411
|
-
type: _analytics.PasteTypes.richText
|
|
412
|
-
});
|
|
413
|
-
return true;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
// handle paste of nested tables to ensure nesting limits are respected
|
|
417
|
-
if ((0, _analytics2.handleNestedTablePasteWithAnalytics)(editorAnalyticsAPI, (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes'))(view, event, slice)(state, dispatch)) {
|
|
418
|
-
return true;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
418
|
// handle the case when copy content from a table cell inside bodied extension
|
|
422
419
|
if ((0, _handlers.handleTableContentPasteInBodiedExtension)(slice)(state, dispatch)) {
|
|
423
420
|
return true;
|
|
@@ -522,8 +522,7 @@ function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
522
522
|
}
|
|
523
523
|
function getSmartLinkAdf(_x, _x2, _x3) {
|
|
524
524
|
return _getSmartLinkAdf.apply(this, arguments);
|
|
525
|
-
}
|
|
526
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
525
|
+
}
|
|
527
526
|
function _getSmartLinkAdf() {
|
|
528
527
|
_getSmartLinkAdf = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(text, type, cardOptions) {
|
|
529
528
|
var provider;
|
|
@@ -574,9 +573,6 @@ function insertAutoMacro(slice, macro, view, from, to) {
|
|
|
574
573
|
}
|
|
575
574
|
return false;
|
|
576
575
|
}
|
|
577
|
-
|
|
578
|
-
// Ignored via go/ees005
|
|
579
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
580
576
|
function handleMacroAutoConvert(text, slice, queueCardsFromChangedTr, runMacroAutoConvert, cardsOptions, extensionAutoConverter) {
|
|
581
577
|
return function (state, dispatch, view) {
|
|
582
578
|
var macro = null;
|
|
@@ -797,9 +793,6 @@ function handleExpandPaste(slice, isNestingExpandsSupported) {
|
|
|
797
793
|
return false;
|
|
798
794
|
};
|
|
799
795
|
}
|
|
800
|
-
|
|
801
|
-
// Ignored via go/ees005
|
|
802
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
803
796
|
function handleMarkdown(markdownSlice, queueCardsFromChangedTr, from, to) {
|
|
804
797
|
return function (state, dispatch) {
|
|
805
798
|
var tr = (0, _history.closeHistory)(state.tr);
|
|
@@ -153,9 +153,6 @@ function createPastePayload(actionSubjectId, attributes, linkDomain) {
|
|
|
153
153
|
} : {})
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
-
|
|
157
|
-
// Ignored via go/ees005
|
|
158
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
159
156
|
function createPasteAnalyticsPayloadBySelection(event, slice, pasteContext, pluginInjectionApi) {
|
|
160
157
|
return selection => {
|
|
161
158
|
var _pluginInjectionApi$m, _pluginInjectionApi$m2;
|
|
@@ -250,9 +247,6 @@ function createPasteAnalyticsPayloadBySelection(event, slice, pasteContext, plug
|
|
|
250
247
|
}, linkDomains);
|
|
251
248
|
};
|
|
252
249
|
}
|
|
253
|
-
|
|
254
|
-
// Ignored via go/ees005
|
|
255
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
256
250
|
export function createPasteAnalyticsPayload(view, event, slice, pasteContext) {
|
|
257
251
|
return createPasteAnalyticsPayloadBySelection(event, slice, pasteContext)(view.state.selection);
|
|
258
252
|
}
|
|
@@ -260,10 +254,7 @@ export function createPasteAnalyticsPayload(view, event, slice, pasteContext) {
|
|
|
260
254
|
// TODO: ED-6612 We should not dispatch only analytics, it's preferred to wrap each command with his own analytics.
|
|
261
255
|
// However, handlers like handleMacroAutoConvert dispatch multiple time,
|
|
262
256
|
// so pasteCommandWithAnalytics is useless in this case.
|
|
263
|
-
export const sendPasteAnalyticsEvent = editorAnalyticsAPI =>
|
|
264
|
-
// Ignored via go/ees005
|
|
265
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
266
|
-
(view, event, slice, pasteContext) => {
|
|
257
|
+
export const sendPasteAnalyticsEvent = editorAnalyticsAPI => (view, event, slice, pasteContext) => {
|
|
267
258
|
const tr = view.state.tr;
|
|
268
259
|
const payload = createPasteAnalyticsPayload(view, event, slice, pasteContext);
|
|
269
260
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
@@ -273,55 +264,34 @@ export const handlePasteAsPlainTextWithAnalytics = editorAnalyticsAPI => (view,
|
|
|
273
264
|
type: PasteTypes.plain,
|
|
274
265
|
asPlain: true
|
|
275
266
|
}))(handlePasteAsPlainText(slice, event, editorAnalyticsAPI));
|
|
276
|
-
export const handlePasteIntoTaskAndDecisionWithAnalytics = (view, event, slice, type, pluginInjectionApi
|
|
277
|
-
// Ignored via go/ees005
|
|
278
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
279
|
-
) => {
|
|
267
|
+
export const handlePasteIntoTaskAndDecisionWithAnalytics = (view, event, slice, type, pluginInjectionApi) => {
|
|
280
268
|
var _pluginInjectionApi$a, _pluginInjectionApi$c, _pluginInjectionApi$c2;
|
|
281
269
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
282
270
|
type
|
|
283
271
|
}))(handlePasteIntoTaskOrDecisionOrPanel(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.card) === null || _pluginInjectionApi$c === void 0 ? void 0 : (_pluginInjectionApi$c2 = _pluginInjectionApi$c.actions) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.queueCardsFromChangedTr));
|
|
284
272
|
};
|
|
285
|
-
export const handlePasteIntoCaptionWithAnalytics = editorAnalyticsAPI =>
|
|
286
|
-
// Ignored via go/ees005
|
|
287
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
288
|
-
(view, event, slice, type) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
273
|
+
export const handlePasteIntoCaptionWithAnalytics = editorAnalyticsAPI => (view, event, slice, type) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
289
274
|
type
|
|
290
275
|
}))(handlePasteIntoCaption(slice));
|
|
291
|
-
export const handleCodeBlockWithAnalytics = editorAnalyticsAPI =>
|
|
292
|
-
// Ignored via go/ees005
|
|
293
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
294
|
-
(view, event, slice, text) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
276
|
+
export const handleCodeBlockWithAnalytics = editorAnalyticsAPI => (view, event, slice, text) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
295
277
|
type: PasteTypes.plain
|
|
296
278
|
}))(handleCodeBlock(text));
|
|
297
|
-
export const handleMediaSingleWithAnalytics = editorAnalyticsAPI => (view, event, slice, type, insertMediaAsMediaSingle
|
|
298
|
-
// Ignored via go/ees005
|
|
299
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
300
|
-
) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
279
|
+
export const handleMediaSingleWithAnalytics = editorAnalyticsAPI => (view, event, slice, type, insertMediaAsMediaSingle) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
301
280
|
type
|
|
302
281
|
}))(handleMediaSingle(INPUT_METHOD.CLIPBOARD, insertMediaAsMediaSingle)(slice));
|
|
303
|
-
export const handlePastePreservingMarksWithAnalytics = (view, event, slice, type, pluginInjectionApi
|
|
304
|
-
// Ignored via go/ees005
|
|
305
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
306
|
-
) => {
|
|
282
|
+
export const handlePastePreservingMarksWithAnalytics = (view, event, slice, type, pluginInjectionApi) => {
|
|
307
283
|
var _pluginInjectionApi$a2, _pluginInjectionApi$c3, _pluginInjectionApi$c4;
|
|
308
284
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
309
285
|
type
|
|
310
286
|
}))(handlePastePreservingMarks(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c3 = pluginInjectionApi.card) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : (_pluginInjectionApi$c4 = _pluginInjectionApi$c3.actions) === null || _pluginInjectionApi$c4 === void 0 ? void 0 : _pluginInjectionApi$c4.queueCardsFromChangedTr));
|
|
311
287
|
};
|
|
312
|
-
export const handleMarkdownWithAnalytics = (view, event, slice, pluginInjectionApi
|
|
313
|
-
// Ignored via go/ees005
|
|
314
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
315
|
-
) => {
|
|
288
|
+
export const handleMarkdownWithAnalytics = (view, event, slice, pluginInjectionApi) => {
|
|
316
289
|
var _pluginInjectionApi$a3, _pluginInjectionApi$c5, _pluginInjectionApi$c6;
|
|
317
290
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
318
291
|
type: PasteTypes.markdown
|
|
319
292
|
}))(handleMarkdown(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c5 = pluginInjectionApi.card) === null || _pluginInjectionApi$c5 === void 0 ? void 0 : (_pluginInjectionApi$c6 = _pluginInjectionApi$c5.actions) === null || _pluginInjectionApi$c6 === void 0 ? void 0 : _pluginInjectionApi$c6.queueCardsFromChangedTr));
|
|
320
293
|
};
|
|
321
|
-
export const handleRichTextWithAnalytics = (view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported
|
|
322
|
-
// Ignored via go/ees005
|
|
323
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
324
|
-
) => {
|
|
294
|
+
export const handleRichTextWithAnalytics = (view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported) => {
|
|
325
295
|
var _pluginInjectionApi$a4, _pluginInjectionApi$c7, _pluginInjectionApi$c8;
|
|
326
296
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
327
297
|
type: PasteTypes.richText
|
|
@@ -348,10 +318,7 @@ const injectAnalyticsPayloadBeforeCommand = editorAnalyticsAPI => createPayloadB
|
|
|
348
318
|
};
|
|
349
319
|
};
|
|
350
320
|
};
|
|
351
|
-
export const handlePastePanelOrDecisionIntoListWithAnalytics = editorAnalyticsAPI => (view, event, slice, findRootParentListNode
|
|
352
|
-
// Ignored via go/ees005
|
|
353
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
354
|
-
) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
321
|
+
export const handlePastePanelOrDecisionIntoListWithAnalytics = editorAnalyticsAPI => (view, event, slice, findRootParentListNode) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
355
322
|
type: PasteTypes.richText
|
|
356
323
|
}))(handlePastePanelOrDecisionContentIntoList(slice, findRootParentListNode));
|
|
357
324
|
export const handlePasteNonNestableBlockNodesIntoListWithAnalytics = editorAnalyticsAPI => (view, event, slice) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
@@ -369,10 +336,7 @@ export const handleNestedTablePasteWithAnalytics = (editorAnalyticsAPI, isNestin
|
|
|
369
336
|
export const handleSelectedTableWithAnalytics = editorAnalyticsAPI => (view, event, slice) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
370
337
|
type: PasteTypes.richText
|
|
371
338
|
}))(handleSelectedTable(editorAnalyticsAPI)(slice));
|
|
372
|
-
export const handlePasteLinkOnSelectedTextWithAnalytics = editorAnalyticsAPI =>
|
|
373
|
-
// Ignored via go/ees005
|
|
374
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
375
|
-
(view, event, slice, type) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
339
|
+
export const handlePasteLinkOnSelectedTextWithAnalytics = editorAnalyticsAPI => (view, event, slice, type) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
376
340
|
type,
|
|
377
341
|
hyperlinkPasteOnText: true
|
|
378
342
|
}))(handlePasteLinkOnSelectedText(slice));
|
|
@@ -29,9 +29,6 @@ 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
|
|
35
32
|
export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
36
33
|
var _pluginInjectionApi$a;
|
|
37
34
|
const editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
@@ -314,9 +311,6 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
314
311
|
// @ts-ignore - [unblock prosemirror bump] assigning to readonly prop
|
|
315
312
|
slice.openStart = 1;
|
|
316
313
|
}
|
|
317
|
-
if (handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, isPlainText ? PasteTypes.plain : PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
|
|
318
|
-
return true;
|
|
319
|
-
}
|
|
320
314
|
|
|
321
315
|
// If we're in a code block, append the text contents of clipboard inside it
|
|
322
316
|
if (handleCodeBlockWithAnalytics(editorAnalyticsAPI)(view, event, slice, text)(state, dispatch)) {
|
|
@@ -335,6 +329,23 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
335
329
|
isNestedMarkdownTable = !!(markdownSlice && isPlainText && isParentNodeTdOrTh && getContentNodeTypes(markdownSlice.content).includes((_schema$nodes$table = schema.nodes.table) === null || _schema$nodes$table === void 0 ? void 0 : _schema$nodes$table.name));
|
|
336
330
|
slice = isNestedMarkdownTable ? markdownSlice : slice;
|
|
337
331
|
|
|
332
|
+
// get editor-tables to handle pasting tables if it can
|
|
333
|
+
// otherwise, just the replace the selection with the content
|
|
334
|
+
if (handlePasteTable(view, null, slice)) {
|
|
335
|
+
sendPasteAnalyticsEvent(editorAnalyticsAPI)(view, event, slice, {
|
|
336
|
+
type: PasteTypes.richText
|
|
337
|
+
});
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// handle paste of nested tables to ensure nesting limits are respected
|
|
342
|
+
if (handleNestedTablePasteWithAnalytics(editorAnalyticsAPI, fg('platform_editor_use_nested_table_pm_nodes'))(view, event, slice)(state, dispatch)) {
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
if (handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, isPlainText ? PasteTypes.plain : PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
|
|
338
349
|
// If the clipboard only contains plain text, attempt to parse it as Markdown
|
|
339
350
|
if (isPlainText && markdownSlice && !isNestedMarkdownTable) {
|
|
340
351
|
if (handlePastePreservingMarksWithAnalytics(view, event, markdownSlice, PasteTypes.markdown, pluginInjectionApi)(state, dispatch)) {
|
|
@@ -380,20 +391,6 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
380
391
|
return true;
|
|
381
392
|
}
|
|
382
393
|
|
|
383
|
-
// get editor-tables to handle pasting tables if it can
|
|
384
|
-
// otherwise, just the replace the selection with the content
|
|
385
|
-
if (handlePasteTable(view, null, slice)) {
|
|
386
|
-
sendPasteAnalyticsEvent(editorAnalyticsAPI)(view, event, slice, {
|
|
387
|
-
type: PasteTypes.richText
|
|
388
|
-
});
|
|
389
|
-
return true;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// handle paste of nested tables to ensure nesting limits are respected
|
|
393
|
-
if (handleNestedTablePasteWithAnalytics(editorAnalyticsAPI, fg('platform_editor_use_nested_table_pm_nodes'))(view, event, slice)(state, dispatch)) {
|
|
394
|
-
return true;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
394
|
// handle the case when copy content from a table cell inside bodied extension
|
|
398
395
|
if (handleTableContentPasteInBodiedExtension(slice)(state, dispatch)) {
|
|
399
396
|
return true;
|
|
@@ -522,9 +522,6 @@ 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
|
|
528
525
|
function insertAutoMacro(slice, macro, view, from, to) {
|
|
529
526
|
if (view) {
|
|
530
527
|
// insert the text or linkified/md-converted clipboard data
|
|
@@ -547,9 +544,6 @@ function insertAutoMacro(slice, macro, view, from, to) {
|
|
|
547
544
|
}
|
|
548
545
|
return false;
|
|
549
546
|
}
|
|
550
|
-
|
|
551
|
-
// Ignored via go/ees005
|
|
552
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
553
547
|
export function handleMacroAutoConvert(text, slice, queueCardsFromChangedTr, runMacroAutoConvert, cardsOptions, extensionAutoConverter) {
|
|
554
548
|
return (state, dispatch, view) => {
|
|
555
549
|
let macro = null;
|
|
@@ -792,9 +786,6 @@ export function handleExpandPaste(slice, isNestingExpandsSupported) {
|
|
|
792
786
|
return false;
|
|
793
787
|
};
|
|
794
788
|
}
|
|
795
|
-
|
|
796
|
-
// Ignored via go/ees005
|
|
797
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
798
789
|
export function handleMarkdown(markdownSlice, queueCardsFromChangedTr, from, to) {
|
|
799
790
|
return (state, dispatch) => {
|
|
800
791
|
const tr = closeHistory(state.tr);
|
|
@@ -144,9 +144,6 @@ 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
|
|
150
147
|
function createPasteAnalyticsPayloadBySelection(event, slice, pasteContext, pluginInjectionApi) {
|
|
151
148
|
return function (selection) {
|
|
152
149
|
var _pluginInjectionApi$m;
|
|
@@ -243,9 +240,6 @@ function createPasteAnalyticsPayloadBySelection(event, slice, pasteContext, plug
|
|
|
243
240
|
}, linkDomains);
|
|
244
241
|
};
|
|
245
242
|
}
|
|
246
|
-
|
|
247
|
-
// Ignored via go/ees005
|
|
248
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
249
243
|
export function createPasteAnalyticsPayload(view, event, slice, pasteContext) {
|
|
250
244
|
return createPasteAnalyticsPayloadBySelection(event, slice, pasteContext)(view.state.selection);
|
|
251
245
|
}
|
|
@@ -254,16 +248,12 @@ export function createPasteAnalyticsPayload(view, event, slice, pasteContext) {
|
|
|
254
248
|
// However, handlers like handleMacroAutoConvert dispatch multiple time,
|
|
255
249
|
// so pasteCommandWithAnalytics is useless in this case.
|
|
256
250
|
export var sendPasteAnalyticsEvent = function sendPasteAnalyticsEvent(editorAnalyticsAPI) {
|
|
257
|
-
return (
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
264
|
-
view.dispatch(tr);
|
|
265
|
-
}
|
|
266
|
-
);
|
|
251
|
+
return function (view, event, slice, pasteContext) {
|
|
252
|
+
var tr = view.state.tr;
|
|
253
|
+
var payload = createPasteAnalyticsPayload(view, event, slice, pasteContext);
|
|
254
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
255
|
+
view.dispatch(tr);
|
|
256
|
+
};
|
|
267
257
|
};
|
|
268
258
|
export var handlePasteAsPlainTextWithAnalytics = function handlePasteAsPlainTextWithAnalytics(editorAnalyticsAPI) {
|
|
269
259
|
return function (view, event, slice) {
|
|
@@ -273,69 +263,46 @@ export var handlePasteAsPlainTextWithAnalytics = function handlePasteAsPlainText
|
|
|
273
263
|
}))(handlePasteAsPlainText(slice, event, editorAnalyticsAPI));
|
|
274
264
|
};
|
|
275
265
|
};
|
|
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
|
-
) {
|
|
266
|
+
export var handlePasteIntoTaskAndDecisionWithAnalytics = function handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, type, pluginInjectionApi) {
|
|
280
267
|
var _pluginInjectionApi$a, _pluginInjectionApi$c;
|
|
281
268
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
282
269
|
type: type
|
|
283
270
|
}))(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));
|
|
284
271
|
};
|
|
285
272
|
export var handlePasteIntoCaptionWithAnalytics = function handlePasteIntoCaptionWithAnalytics(editorAnalyticsAPI) {
|
|
286
|
-
return (
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
type: type
|
|
292
|
-
}))(handlePasteIntoCaption(slice));
|
|
293
|
-
}
|
|
294
|
-
);
|
|
273
|
+
return function (view, event, slice, type) {
|
|
274
|
+
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
275
|
+
type: type
|
|
276
|
+
}))(handlePasteIntoCaption(slice));
|
|
277
|
+
};
|
|
295
278
|
};
|
|
296
279
|
export var handleCodeBlockWithAnalytics = function handleCodeBlockWithAnalytics(editorAnalyticsAPI) {
|
|
297
|
-
return (
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
type: PasteTypes.plain
|
|
303
|
-
}))(handleCodeBlock(text));
|
|
304
|
-
}
|
|
305
|
-
);
|
|
280
|
+
return function (view, event, slice, text) {
|
|
281
|
+
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
282
|
+
type: PasteTypes.plain
|
|
283
|
+
}))(handleCodeBlock(text));
|
|
284
|
+
};
|
|
306
285
|
};
|
|
307
286
|
export var handleMediaSingleWithAnalytics = function handleMediaSingleWithAnalytics(editorAnalyticsAPI) {
|
|
308
|
-
return function (view, event, slice, type, insertMediaAsMediaSingle
|
|
309
|
-
// Ignored via go/ees005
|
|
310
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
311
|
-
) {
|
|
287
|
+
return function (view, event, slice, type, insertMediaAsMediaSingle) {
|
|
312
288
|
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
313
289
|
type: type
|
|
314
290
|
}))(handleMediaSingle(INPUT_METHOD.CLIPBOARD, insertMediaAsMediaSingle)(slice));
|
|
315
291
|
};
|
|
316
292
|
};
|
|
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
|
-
) {
|
|
293
|
+
export var handlePastePreservingMarksWithAnalytics = function handlePastePreservingMarksWithAnalytics(view, event, slice, type, pluginInjectionApi) {
|
|
321
294
|
var _pluginInjectionApi$a2, _pluginInjectionApi$c2;
|
|
322
295
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
323
296
|
type: type
|
|
324
297
|
}))(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));
|
|
325
298
|
};
|
|
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
|
-
) {
|
|
299
|
+
export var handleMarkdownWithAnalytics = function handleMarkdownWithAnalytics(view, event, slice, pluginInjectionApi) {
|
|
330
300
|
var _pluginInjectionApi$a3, _pluginInjectionApi$c3;
|
|
331
301
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
332
302
|
type: PasteTypes.markdown
|
|
333
303
|
}))(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));
|
|
334
304
|
};
|
|
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
|
-
) {
|
|
305
|
+
export var handleRichTextWithAnalytics = function handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported) {
|
|
339
306
|
var _pluginInjectionApi$a4, _pluginInjectionApi$c4;
|
|
340
307
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
341
308
|
type: PasteTypes.richText
|
|
@@ -365,10 +332,7 @@ var injectAnalyticsPayloadBeforeCommand = function injectAnalyticsPayloadBeforeC
|
|
|
365
332
|
};
|
|
366
333
|
};
|
|
367
334
|
export var handlePastePanelOrDecisionIntoListWithAnalytics = function handlePastePanelOrDecisionIntoListWithAnalytics(editorAnalyticsAPI) {
|
|
368
|
-
return function (view, event, slice, findRootParentListNode
|
|
369
|
-
// Ignored via go/ees005
|
|
370
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
371
|
-
) {
|
|
335
|
+
return function (view, event, slice, findRootParentListNode) {
|
|
372
336
|
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
373
337
|
type: PasteTypes.richText
|
|
374
338
|
}))(handlePastePanelOrDecisionContentIntoList(slice, findRootParentListNode));
|
|
@@ -406,16 +370,12 @@ export var handleSelectedTableWithAnalytics = function handleSelectedTableWithAn
|
|
|
406
370
|
};
|
|
407
371
|
};
|
|
408
372
|
export var handlePasteLinkOnSelectedTextWithAnalytics = function handlePasteLinkOnSelectedTextWithAnalytics(editorAnalyticsAPI) {
|
|
409
|
-
return (
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
hyperlinkPasteOnText: true
|
|
416
|
-
}))(handlePasteLinkOnSelectedText(slice));
|
|
417
|
-
}
|
|
418
|
-
);
|
|
373
|
+
return function (view, event, slice, type) {
|
|
374
|
+
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
375
|
+
type: type,
|
|
376
|
+
hyperlinkPasteOnText: true
|
|
377
|
+
}))(handlePasteLinkOnSelectedText(slice));
|
|
378
|
+
};
|
|
419
379
|
};
|
|
420
380
|
export var createPasteMeasurePayload = function createPasteMeasurePayload(_ref3) {
|
|
421
381
|
var view = _ref3.view,
|
|
@@ -29,9 +29,6 @@ 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
|
|
35
32
|
export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
36
33
|
var _pluginInjectionApi$a;
|
|
37
34
|
var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
@@ -332,9 +329,6 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
332
329
|
// @ts-ignore - [unblock prosemirror bump] assigning to readonly prop
|
|
333
330
|
slice.openStart = 1;
|
|
334
331
|
}
|
|
335
|
-
if (handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, isPlainText ? PasteTypes.plain : PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
|
|
336
|
-
return true;
|
|
337
|
-
}
|
|
338
332
|
|
|
339
333
|
// If we're in a code block, append the text contents of clipboard inside it
|
|
340
334
|
if (handleCodeBlockWithAnalytics(editorAnalyticsAPI)(view, event, slice, text)(state, dispatch)) {
|
|
@@ -353,6 +347,23 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
353
347
|
isNestedMarkdownTable = !!(markdownSlice && isPlainText && isParentNodeTdOrTh && getContentNodeTypes(markdownSlice.content).includes((_schema$nodes$table = schema.nodes.table) === null || _schema$nodes$table === void 0 ? void 0 : _schema$nodes$table.name));
|
|
354
348
|
slice = isNestedMarkdownTable ? markdownSlice : slice;
|
|
355
349
|
|
|
350
|
+
// get editor-tables to handle pasting tables if it can
|
|
351
|
+
// otherwise, just the replace the selection with the content
|
|
352
|
+
if (handlePasteTable(view, null, slice)) {
|
|
353
|
+
sendPasteAnalyticsEvent(editorAnalyticsAPI)(view, event, slice, {
|
|
354
|
+
type: PasteTypes.richText
|
|
355
|
+
});
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// handle paste of nested tables to ensure nesting limits are respected
|
|
360
|
+
if (handleNestedTablePasteWithAnalytics(editorAnalyticsAPI, fg('platform_editor_use_nested_table_pm_nodes'))(view, event, slice)(state, dispatch)) {
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
if (handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, isPlainText ? PasteTypes.plain : PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
|
|
364
|
+
return true;
|
|
365
|
+
}
|
|
366
|
+
|
|
356
367
|
// If the clipboard only contains plain text, attempt to parse it as Markdown
|
|
357
368
|
if (isPlainText && markdownSlice && !isNestedMarkdownTable) {
|
|
358
369
|
if (handlePastePreservingMarksWithAnalytics(view, event, markdownSlice, PasteTypes.markdown, pluginInjectionApi)(state, dispatch)) {
|
|
@@ -396,20 +407,6 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
396
407
|
return true;
|
|
397
408
|
}
|
|
398
409
|
|
|
399
|
-
// get editor-tables to handle pasting tables if it can
|
|
400
|
-
// otherwise, just the replace the selection with the content
|
|
401
|
-
if (handlePasteTable(view, null, slice)) {
|
|
402
|
-
sendPasteAnalyticsEvent(editorAnalyticsAPI)(view, event, slice, {
|
|
403
|
-
type: PasteTypes.richText
|
|
404
|
-
});
|
|
405
|
-
return true;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// handle paste of nested tables to ensure nesting limits are respected
|
|
409
|
-
if (handleNestedTablePasteWithAnalytics(editorAnalyticsAPI, fg('platform_editor_use_nested_table_pm_nodes'))(view, event, slice)(state, dispatch)) {
|
|
410
|
-
return true;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
410
|
// handle the case when copy content from a table cell inside bodied extension
|
|
414
411
|
if (handleTableContentPasteInBodiedExtension(slice)(state, dispatch)) {
|
|
415
412
|
return true;
|
|
@@ -497,8 +497,7 @@ export function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
497
497
|
}
|
|
498
498
|
function getSmartLinkAdf(_x, _x2, _x3) {
|
|
499
499
|
return _getSmartLinkAdf.apply(this, arguments);
|
|
500
|
-
}
|
|
501
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
500
|
+
}
|
|
502
501
|
function _getSmartLinkAdf() {
|
|
503
502
|
_getSmartLinkAdf = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(text, type, cardOptions) {
|
|
504
503
|
var provider;
|
|
@@ -549,9 +548,6 @@ function insertAutoMacro(slice, macro, view, from, to) {
|
|
|
549
548
|
}
|
|
550
549
|
return false;
|
|
551
550
|
}
|
|
552
|
-
|
|
553
|
-
// Ignored via go/ees005
|
|
554
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
555
551
|
export function handleMacroAutoConvert(text, slice, queueCardsFromChangedTr, runMacroAutoConvert, cardsOptions, extensionAutoConverter) {
|
|
556
552
|
return function (state, dispatch, view) {
|
|
557
553
|
var macro = null;
|
|
@@ -772,9 +768,6 @@ export function handleExpandPaste(slice, isNestingExpandsSupported) {
|
|
|
772
768
|
return false;
|
|
773
769
|
};
|
|
774
770
|
}
|
|
775
|
-
|
|
776
|
-
// Ignored via go/ees005
|
|
777
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
778
771
|
export function handleMarkdown(markdownSlice, queueCardsFromChangedTr, from, to) {
|
|
779
772
|
return function (state, dispatch) {
|
|
780
773
|
var tr = closeHistory(state.tr);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,22 +32,22 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
|
-
"@atlaskit/editor-common": "^99.
|
|
36
|
-
"@atlaskit/editor-markdown-transformer": "^5.
|
|
37
|
-
"@atlaskit/editor-plugin-analytics": "^1.
|
|
38
|
-
"@atlaskit/editor-plugin-annotation": "^1.
|
|
39
|
-
"@atlaskit/editor-plugin-better-type-history": "^1.
|
|
35
|
+
"@atlaskit/editor-common": "^99.6.0",
|
|
36
|
+
"@atlaskit/editor-markdown-transformer": "^5.14.0",
|
|
37
|
+
"@atlaskit/editor-plugin-analytics": "^1.11.0",
|
|
38
|
+
"@atlaskit/editor-plugin-annotation": "^1.27.0",
|
|
39
|
+
"@atlaskit/editor-plugin-better-type-history": "^1.10.0",
|
|
40
40
|
"@atlaskit/editor-plugin-card": "^4.5.0",
|
|
41
41
|
"@atlaskit/editor-plugin-feature-flags": "^1.2.0",
|
|
42
42
|
"@atlaskit/editor-plugin-list": "^3.9.0",
|
|
43
43
|
"@atlaskit/editor-plugin-media": "^1.44.0",
|
|
44
|
-
"@atlaskit/editor-plugin-mentions": "^2.
|
|
44
|
+
"@atlaskit/editor-plugin-mentions": "^2.14.0",
|
|
45
45
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
46
46
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
47
|
-
"@atlaskit/media-client": "^
|
|
48
|
-
"@atlaskit/media-common": "^11.
|
|
47
|
+
"@atlaskit/media-client": "^31.1.0",
|
|
48
|
+
"@atlaskit/media-common": "^11.8.0",
|
|
49
49
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
50
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
50
|
+
"@atlaskit/tmp-editor-statsig": "^2.41.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0",
|
|
52
52
|
"lodash": "^4.17.21",
|
|
53
53
|
"uuid": "^3.1.0"
|
|
@@ -58,12 +58,12 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@af/visual-regression": "*",
|
|
61
|
-
"@atlaskit/editor-plugin-block-type": "^4.
|
|
61
|
+
"@atlaskit/editor-plugin-block-type": "^4.2.0",
|
|
62
62
|
"@atlaskit/editor-plugin-history": "^1.3.0",
|
|
63
|
-
"@atlaskit/editor-plugin-type-ahead": "^1.
|
|
63
|
+
"@atlaskit/editor-plugin-type-ahead": "^1.12.0",
|
|
64
64
|
"@atlaskit/ssr": "*",
|
|
65
65
|
"@atlaskit/visual-regression": "*",
|
|
66
|
-
"@testing-library/react": "^
|
|
66
|
+
"@testing-library/react": "^13.4.0",
|
|
67
67
|
"typescript": "~5.4.2",
|
|
68
68
|
"wait-for-expect": "^1.2.0"
|
|
69
69
|
},
|