@atlaskit/editor-plugin-paste 2.0.20 → 2.1.1
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 +21 -0
- package/dist/cjs/pm-plugins/analytics.js +28 -68
- package/dist/cjs/pm-plugins/main.js +0 -3
- package/dist/cjs/pm-plugins/util/edge-cases/index.js +10 -3
- package/dist/cjs/pm-plugins/util/handlers.js +46 -18
- package/dist/es2019/pm-plugins/analytics.js +10 -46
- package/dist/es2019/pm-plugins/main.js +0 -3
- package/dist/es2019/pm-plugins/util/edge-cases/index.js +10 -3
- package/dist/es2019/pm-plugins/util/handlers.js +48 -20
- package/dist/esm/pm-plugins/analytics.js +28 -68
- package/dist/esm/pm-plugins/main.js +0 -3
- package/dist/esm/pm-plugins/util/edge-cases/index.js +10 -3
- package/dist/esm/pm-plugins/util/handlers.js +46 -19
- package/dist/types/pm-plugins/util/handlers.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/util/handlers.d.ts +1 -0
- package/package.json +15 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 2.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#103729](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103729)
|
|
8
|
+
[`3188f307d178a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3188f307d178a) -
|
|
9
|
+
ED-25321: fixes issue where pasting action/task item into the middle of a list item will paste in
|
|
10
|
+
the wrong location and create an extra empty task item
|
|
11
|
+
|
|
12
|
+
## 2.1.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#109060](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109060)
|
|
17
|
+
[`4660ec858a305`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4660ec858a305) -
|
|
18
|
+
Update `React` from v16 to v18
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 2.0.20
|
|
4
25
|
|
|
5
26
|
### 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;
|
|
@@ -12,6 +12,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
13
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
14
14
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _index = require("../index");
|
|
16
17
|
var _lists = require("./lists");
|
|
17
18
|
function insertSliceForLists(_ref) {
|
|
@@ -105,9 +106,15 @@ function insertSliceForTaskInsideList(_ref5) {
|
|
|
105
106
|
slice = _ref5.slice;
|
|
106
107
|
var schema = tr.doc.type.schema;
|
|
107
108
|
//To avoid the list being replaced with the tasklist, enclose the slice within a taskItem.
|
|
109
|
+
var selectionBeforeReplace = tr.selection.from;
|
|
108
110
|
tr.replaceSelection(new _model.Slice(_model.Fragment.from(schema.nodes.taskItem.createAndFill()), 0, 0));
|
|
109
|
-
|
|
110
|
-
tr
|
|
111
|
-
|
|
111
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_paste_action_item_in_list')) {
|
|
112
|
+
var nextSelection = _state.Selection.near(tr.doc.resolve(selectionBeforeReplace + 1));
|
|
113
|
+
tr.setSelection(nextSelection);
|
|
114
|
+
} else {
|
|
115
|
+
updateSelectionAfterReplace({
|
|
116
|
+
tr: tr
|
|
117
|
+
});
|
|
118
|
+
}
|
|
112
119
|
tr.replaceSelection(slice);
|
|
113
120
|
}
|
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.checkIfSelectionInNestedList = checkIfSelectionInNestedList;
|
|
7
8
|
exports.checkTaskListInList = checkTaskListInList;
|
|
8
9
|
exports.doesSelectionWhichStartsOrEndsInListContainEntireList = void 0;
|
|
9
10
|
exports.flattenNestedListInSlice = flattenNestedListInSlice;
|
|
@@ -40,6 +41,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
40
41
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
41
42
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
42
43
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
44
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
43
45
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
44
46
|
var _commands = require("../../editor-commands/commands");
|
|
45
47
|
var _main = require("../main");
|
|
@@ -265,16 +267,22 @@ function handlePasteNonNestableBlockNodesIntoList(slice) {
|
|
|
265
267
|
var listItemWrappingOffset = $to.depth - selectionParentListNodeWithPos.depth; // difference in depth between to position and list item node
|
|
266
268
|
|
|
267
269
|
// Anything to do with nested lists should safeInsert and not be handled here
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
270
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_paste_action_item_in_list')) {
|
|
271
|
+
if (checkIfSelectionInNestedList(state)) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
} else {
|
|
275
|
+
var grandParentListNode = (0, _utils2.findParentNodeOfTypeClosestToPos)(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
|
|
276
|
+
var selectionIsInNestedList = !!grandParentListNode;
|
|
277
|
+
var selectedListItemHasNestedList = false;
|
|
278
|
+
selectionParentListItemNode.node.content.forEach(function (child) {
|
|
279
|
+
if ((0, _utils.isListNode)(child)) {
|
|
280
|
+
selectedListItemHasNestedList = true;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
if (selectedListItemHasNestedList || selectionIsInNestedList) {
|
|
284
|
+
return false;
|
|
274
285
|
}
|
|
275
|
-
});
|
|
276
|
-
if (selectedListItemHasNestedList || selectionIsInNestedList) {
|
|
277
|
-
return false;
|
|
278
286
|
}
|
|
279
287
|
|
|
280
288
|
// Node after the insert position
|
|
@@ -522,8 +530,7 @@ function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
522
530
|
}
|
|
523
531
|
function getSmartLinkAdf(_x, _x2, _x3) {
|
|
524
532
|
return _getSmartLinkAdf.apply(this, arguments);
|
|
525
|
-
}
|
|
526
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
533
|
+
}
|
|
527
534
|
function _getSmartLinkAdf() {
|
|
528
535
|
_getSmartLinkAdf = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(text, type, cardOptions) {
|
|
529
536
|
var provider;
|
|
@@ -574,9 +581,6 @@ function insertAutoMacro(slice, macro, view, from, to) {
|
|
|
574
581
|
}
|
|
575
582
|
return false;
|
|
576
583
|
}
|
|
577
|
-
|
|
578
|
-
// Ignored via go/ees005
|
|
579
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
580
584
|
function handleMacroAutoConvert(text, slice, queueCardsFromChangedTr, runMacroAutoConvert, cardsOptions, extensionAutoConverter) {
|
|
581
585
|
return function (state, dispatch, view) {
|
|
582
586
|
var macro = null;
|
|
@@ -797,9 +801,6 @@ function handleExpandPaste(slice, isNestingExpandsSupported) {
|
|
|
797
801
|
return false;
|
|
798
802
|
};
|
|
799
803
|
}
|
|
800
|
-
|
|
801
|
-
// Ignored via go/ees005
|
|
802
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
803
804
|
function handleMarkdown(markdownSlice, queueCardsFromChangedTr, from, to) {
|
|
804
805
|
return function (state, dispatch) {
|
|
805
806
|
var tr = (0, _history.closeHistory)(state.tr);
|
|
@@ -1064,7 +1065,7 @@ function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrCodebloc
|
|
|
1064
1065
|
});
|
|
1065
1066
|
if ((0, _utils.insideTableCell)(state) && (0, _utils.isInListItem)(state) && (0, _utils2.canInsert)(selection.$from, slice.content) && (0, _utils2.canInsert)(selection.$to, slice.content) || sliceHasList) {
|
|
1066
1067
|
tr.replaceSelection(slice);
|
|
1067
|
-
} else if (checkTaskListInList(state, slice)) {
|
|
1068
|
+
} else if (checkTaskListInList(state, slice) && (!(0, _platformFeatureFlags.fg)('platform_editor_fix_paste_action_item_in_list') || !checkIfSelectionInNestedList(state))) {
|
|
1068
1069
|
(0, _edgeCases.insertSliceForTaskInsideList)({
|
|
1069
1070
|
tr: tr,
|
|
1070
1071
|
slice: slice
|
|
@@ -1073,6 +1074,11 @@ function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrCodebloc
|
|
|
1073
1074
|
// need safeInsert rather than replaceSelection, so that nodes aren't split in half
|
|
1074
1075
|
// e.g. when pasting a layout into a table, replaceSelection splits the table in half and adds the layout in the middle
|
|
1075
1076
|
tr = (0, _utils2.safeInsert)(slice.content, tr.selection.$to.pos)(tr);
|
|
1077
|
+
if (checkTaskListInList(state, slice) && (0, _platformFeatureFlags.fg)('platform_editor_fix_paste_action_item_in_list')) {
|
|
1078
|
+
(0, _edgeCases.updateSelectionAfterReplace)({
|
|
1079
|
+
tr: tr
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1076
1082
|
}
|
|
1077
1083
|
}
|
|
1078
1084
|
tr.setStoredMarks([]);
|
|
@@ -1126,4 +1132,26 @@ var handleSelectedTable = exports.handleSelectedTable = function handleSelectedT
|
|
|
1126
1132
|
function checkTaskListInList(state, slice) {
|
|
1127
1133
|
var _slice$content$firstC4;
|
|
1128
1134
|
return Boolean((0, _utils.isInListItem)(state) && ['taskList', 'taskItem'].includes(((_slice$content$firstC4 = slice.content.firstChild) === null || _slice$content$firstC4 === void 0 || (_slice$content$firstC4 = _slice$content$firstC4.type) === null || _slice$content$firstC4 === void 0 ? void 0 : _slice$content$firstC4.name) || ''));
|
|
1135
|
+
}
|
|
1136
|
+
function checkIfSelectionInNestedList(state) {
|
|
1137
|
+
var selection = state.selection,
|
|
1138
|
+
tr = state.tr;
|
|
1139
|
+
var _state$schema$nodes5 = state.schema.nodes,
|
|
1140
|
+
orderedList = _state$schema$nodes5.orderedList,
|
|
1141
|
+
bulletList = _state$schema$nodes5.bulletList,
|
|
1142
|
+
listItem = _state$schema$nodes5.listItem;
|
|
1143
|
+
var selectionParentListItemNode = (0, _utils2.findParentNodeOfType)(listItem)(selection);
|
|
1144
|
+
var selectionParentListNodeWithPos = (0, _utils2.findParentNodeOfType)([bulletList, orderedList])(selection);
|
|
1145
|
+
if (!selectionParentListItemNode || !selectionParentListNodeWithPos) {
|
|
1146
|
+
return false;
|
|
1147
|
+
}
|
|
1148
|
+
var grandParentListNode = (0, _utils2.findParentNodeOfTypeClosestToPos)(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
|
|
1149
|
+
var selectionIsInNestedList = !!grandParentListNode;
|
|
1150
|
+
var selectedListItemHasNestedList = false;
|
|
1151
|
+
selectionParentListItemNode.node.content.forEach(function (child) {
|
|
1152
|
+
if ((0, _utils.isListNode)(child)) {
|
|
1153
|
+
selectedListItemHasNestedList = true;
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1156
|
+
return selectedListItemHasNestedList || selectionIsInNestedList;
|
|
1129
1157
|
}
|
|
@@ -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;
|
|
@@ -3,6 +3,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
5
5
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { isCursorSelectionAtTextStartOrEnd, isEmptyNode, isSelectionInsidePanel } from '../index';
|
|
7
8
|
import { insertSliceAtNodeEdge, insertSliceInsideOfPanelNodeSelected, insertSliceIntoEmptyNode, insertSliceIntoRangeSelectionInsideList } from './lists';
|
|
8
9
|
export function insertSliceForLists({
|
|
@@ -108,9 +109,15 @@ export function insertSliceForTaskInsideList({
|
|
|
108
109
|
schema
|
|
109
110
|
} = tr.doc.type;
|
|
110
111
|
//To avoid the list being replaced with the tasklist, enclose the slice within a taskItem.
|
|
112
|
+
const selectionBeforeReplace = tr.selection.from;
|
|
111
113
|
tr.replaceSelection(new Slice(Fragment.from(schema.nodes.taskItem.createAndFill()), 0, 0));
|
|
112
|
-
|
|
113
|
-
tr
|
|
114
|
-
|
|
114
|
+
if (fg('platform_editor_fix_paste_action_item_in_list')) {
|
|
115
|
+
const nextSelection = Selection.near(tr.doc.resolve(selectionBeforeReplace + 1));
|
|
116
|
+
tr.setSelection(nextSelection);
|
|
117
|
+
} else {
|
|
118
|
+
updateSelectionAfterReplace({
|
|
119
|
+
tr
|
|
120
|
+
});
|
|
121
|
+
}
|
|
115
122
|
tr.replaceSelection(slice);
|
|
116
123
|
}
|
|
@@ -10,13 +10,14 @@ import { Fragment, Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/mo
|
|
|
10
10
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
11
|
import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNode, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
12
12
|
import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
15
|
// TODO: ED-20519 Needs Macro extraction
|
|
15
16
|
|
|
16
17
|
import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from '../../editor-commands/commands';
|
|
17
18
|
import { isInsideBlockQuote } from '../main';
|
|
18
19
|
import { getPluginState as getPastePluginState } from '../plugin-factory';
|
|
19
|
-
import { insertSliceForLists, insertSliceForTaskInsideList, insertSliceInsideBlockquote } from './edge-cases';
|
|
20
|
+
import { insertSliceForLists, insertSliceForTaskInsideList, insertSliceInsideBlockquote, updateSelectionAfterReplace } from './edge-cases';
|
|
20
21
|
import { insertSliceInsideOfPanelNodeSelected } from './edge-cases/lists';
|
|
21
22
|
import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType, isEmptyNode, isSelectionInsidePanel } from './index';
|
|
22
23
|
const insideExpand = state => {
|
|
@@ -243,16 +244,22 @@ export function handlePasteNonNestableBlockNodesIntoList(slice) {
|
|
|
243
244
|
const listItemWrappingOffset = $to.depth - selectionParentListNodeWithPos.depth; // difference in depth between to position and list item node
|
|
244
245
|
|
|
245
246
|
// Anything to do with nested lists should safeInsert and not be handled here
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
if (fg('platform_editor_fix_paste_action_item_in_list')) {
|
|
248
|
+
if (checkIfSelectionInNestedList(state)) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
const grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
|
|
253
|
+
const selectionIsInNestedList = !!grandParentListNode;
|
|
254
|
+
let selectedListItemHasNestedList = false;
|
|
255
|
+
selectionParentListItemNode.node.content.forEach(child => {
|
|
256
|
+
if (isListNode(child)) {
|
|
257
|
+
selectedListItemHasNestedList = true;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
if (selectedListItemHasNestedList || selectionIsInNestedList) {
|
|
261
|
+
return false;
|
|
252
262
|
}
|
|
253
|
-
});
|
|
254
|
-
if (selectedListItemHasNestedList || selectionIsInNestedList) {
|
|
255
|
-
return false;
|
|
256
263
|
}
|
|
257
264
|
|
|
258
265
|
// Node after the insert position
|
|
@@ -522,9 +529,6 @@ async function getSmartLinkAdf(text, type, cardOptions) {
|
|
|
522
529
|
const provider = await cardOptions.provider;
|
|
523
530
|
return await provider.resolve(text, type);
|
|
524
531
|
}
|
|
525
|
-
|
|
526
|
-
// Ignored via go/ees005
|
|
527
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
528
532
|
function insertAutoMacro(slice, macro, view, from, to) {
|
|
529
533
|
if (view) {
|
|
530
534
|
// insert the text or linkified/md-converted clipboard data
|
|
@@ -547,9 +551,6 @@ function insertAutoMacro(slice, macro, view, from, to) {
|
|
|
547
551
|
}
|
|
548
552
|
return false;
|
|
549
553
|
}
|
|
550
|
-
|
|
551
|
-
// Ignored via go/ees005
|
|
552
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
553
554
|
export function handleMacroAutoConvert(text, slice, queueCardsFromChangedTr, runMacroAutoConvert, cardsOptions, extensionAutoConverter) {
|
|
554
555
|
return (state, dispatch, view) => {
|
|
555
556
|
let macro = null;
|
|
@@ -792,9 +793,6 @@ export function handleExpandPaste(slice, isNestingExpandsSupported) {
|
|
|
792
793
|
return false;
|
|
793
794
|
};
|
|
794
795
|
}
|
|
795
|
-
|
|
796
|
-
// Ignored via go/ees005
|
|
797
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
798
796
|
export function handleMarkdown(markdownSlice, queueCardsFromChangedTr, from, to) {
|
|
799
797
|
return (state, dispatch) => {
|
|
800
798
|
const tr = closeHistory(state.tr);
|
|
@@ -1050,7 +1048,7 @@ export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrC
|
|
|
1050
1048
|
});
|
|
1051
1049
|
if (insideTableCell(state) && isInListItem(state) && canInsert(selection.$from, slice.content) && canInsert(selection.$to, slice.content) || sliceHasList) {
|
|
1052
1050
|
tr.replaceSelection(slice);
|
|
1053
|
-
} else if (checkTaskListInList(state, slice)) {
|
|
1051
|
+
} else if (checkTaskListInList(state, slice) && (!fg('platform_editor_fix_paste_action_item_in_list') || !checkIfSelectionInNestedList(state))) {
|
|
1054
1052
|
insertSliceForTaskInsideList({
|
|
1055
1053
|
tr,
|
|
1056
1054
|
slice
|
|
@@ -1059,6 +1057,11 @@ export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrC
|
|
|
1059
1057
|
// need safeInsert rather than replaceSelection, so that nodes aren't split in half
|
|
1060
1058
|
// e.g. when pasting a layout into a table, replaceSelection splits the table in half and adds the layout in the middle
|
|
1061
1059
|
tr = safeInsert(slice.content, tr.selection.$to.pos)(tr);
|
|
1060
|
+
if (checkTaskListInList(state, slice) && fg('platform_editor_fix_paste_action_item_in_list')) {
|
|
1061
|
+
updateSelectionAfterReplace({
|
|
1062
|
+
tr
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1062
1065
|
}
|
|
1063
1066
|
}
|
|
1064
1067
|
tr.setStoredMarks([]);
|
|
@@ -1110,4 +1113,29 @@ export const handleSelectedTable = editorAnalyticsAPI => slice => (state, dispat
|
|
|
1110
1113
|
export function checkTaskListInList(state, slice) {
|
|
1111
1114
|
var _slice$content$firstC4, _slice$content$firstC5;
|
|
1112
1115
|
return Boolean(isInListItem(state) && ['taskList', 'taskItem'].includes(((_slice$content$firstC4 = slice.content.firstChild) === null || _slice$content$firstC4 === void 0 ? void 0 : (_slice$content$firstC5 = _slice$content$firstC4.type) === null || _slice$content$firstC5 === void 0 ? void 0 : _slice$content$firstC5.name) || ''));
|
|
1116
|
+
}
|
|
1117
|
+
export function checkIfSelectionInNestedList(state) {
|
|
1118
|
+
const {
|
|
1119
|
+
selection,
|
|
1120
|
+
tr
|
|
1121
|
+
} = state;
|
|
1122
|
+
const {
|
|
1123
|
+
orderedList,
|
|
1124
|
+
bulletList,
|
|
1125
|
+
listItem
|
|
1126
|
+
} = state.schema.nodes;
|
|
1127
|
+
const selectionParentListItemNode = findParentNodeOfType(listItem)(selection);
|
|
1128
|
+
const selectionParentListNodeWithPos = findParentNodeOfType([bulletList, orderedList])(selection);
|
|
1129
|
+
if (!selectionParentListItemNode || !selectionParentListNodeWithPos) {
|
|
1130
|
+
return false;
|
|
1131
|
+
}
|
|
1132
|
+
const grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
|
|
1133
|
+
const selectionIsInNestedList = !!grandParentListNode;
|
|
1134
|
+
let selectedListItemHasNestedList = false;
|
|
1135
|
+
selectionParentListItemNode.node.content.forEach(child => {
|
|
1136
|
+
if (isListNode(child)) {
|
|
1137
|
+
selectedListItemHasNestedList = true;
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
return selectedListItemHasNestedList || selectionIsInNestedList;
|
|
1113
1141
|
}
|
|
@@ -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;
|
|
@@ -3,6 +3,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
5
5
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { isCursorSelectionAtTextStartOrEnd, isEmptyNode, isSelectionInsidePanel } from '../index';
|
|
7
8
|
import { insertSliceAtNodeEdge, insertSliceInsideOfPanelNodeSelected, insertSliceIntoEmptyNode, insertSliceIntoRangeSelectionInsideList } from './lists';
|
|
8
9
|
export function insertSliceForLists(_ref) {
|
|
@@ -96,9 +97,15 @@ export function insertSliceForTaskInsideList(_ref5) {
|
|
|
96
97
|
slice = _ref5.slice;
|
|
97
98
|
var schema = tr.doc.type.schema;
|
|
98
99
|
//To avoid the list being replaced with the tasklist, enclose the slice within a taskItem.
|
|
100
|
+
var selectionBeforeReplace = tr.selection.from;
|
|
99
101
|
tr.replaceSelection(new Slice(Fragment.from(schema.nodes.taskItem.createAndFill()), 0, 0));
|
|
100
|
-
|
|
101
|
-
tr
|
|
102
|
-
|
|
102
|
+
if (fg('platform_editor_fix_paste_action_item_in_list')) {
|
|
103
|
+
var nextSelection = Selection.near(tr.doc.resolve(selectionBeforeReplace + 1));
|
|
104
|
+
tr.setSelection(nextSelection);
|
|
105
|
+
} else {
|
|
106
|
+
updateSelectionAfterReplace({
|
|
107
|
+
tr: tr
|
|
108
|
+
});
|
|
109
|
+
}
|
|
103
110
|
tr.replaceSelection(slice);
|
|
104
111
|
}
|
|
@@ -18,13 +18,14 @@ import { Fragment, Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/mo
|
|
|
18
18
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
19
19
|
import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNode, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
20
20
|
import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
|
|
21
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
21
22
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
22
23
|
// TODO: ED-20519 Needs Macro extraction
|
|
23
24
|
|
|
24
25
|
import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from '../../editor-commands/commands';
|
|
25
26
|
import { isInsideBlockQuote } from '../main';
|
|
26
27
|
import { getPluginState as getPastePluginState } from '../plugin-factory';
|
|
27
|
-
import { insertSliceForLists, insertSliceForTaskInsideList, insertSliceInsideBlockquote } from './edge-cases';
|
|
28
|
+
import { insertSliceForLists, insertSliceForTaskInsideList, insertSliceInsideBlockquote, updateSelectionAfterReplace } from './edge-cases';
|
|
28
29
|
import { insertSliceInsideOfPanelNodeSelected } from './edge-cases/lists';
|
|
29
30
|
import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType, isEmptyNode, isSelectionInsidePanel } from './index';
|
|
30
31
|
var insideExpand = function insideExpand(state) {
|
|
@@ -240,16 +241,22 @@ export function handlePasteNonNestableBlockNodesIntoList(slice) {
|
|
|
240
241
|
var listItemWrappingOffset = $to.depth - selectionParentListNodeWithPos.depth; // difference in depth between to position and list item node
|
|
241
242
|
|
|
242
243
|
// Anything to do with nested lists should safeInsert and not be handled here
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
244
|
+
if (fg('platform_editor_fix_paste_action_item_in_list')) {
|
|
245
|
+
if (checkIfSelectionInNestedList(state)) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
var grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
|
|
250
|
+
var selectionIsInNestedList = !!grandParentListNode;
|
|
251
|
+
var selectedListItemHasNestedList = false;
|
|
252
|
+
selectionParentListItemNode.node.content.forEach(function (child) {
|
|
253
|
+
if (isListNode(child)) {
|
|
254
|
+
selectedListItemHasNestedList = true;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
if (selectedListItemHasNestedList || selectionIsInNestedList) {
|
|
258
|
+
return false;
|
|
249
259
|
}
|
|
250
|
-
});
|
|
251
|
-
if (selectedListItemHasNestedList || selectionIsInNestedList) {
|
|
252
|
-
return false;
|
|
253
260
|
}
|
|
254
261
|
|
|
255
262
|
// Node after the insert position
|
|
@@ -497,8 +504,7 @@ export function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
497
504
|
}
|
|
498
505
|
function getSmartLinkAdf(_x, _x2, _x3) {
|
|
499
506
|
return _getSmartLinkAdf.apply(this, arguments);
|
|
500
|
-
}
|
|
501
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
507
|
+
}
|
|
502
508
|
function _getSmartLinkAdf() {
|
|
503
509
|
_getSmartLinkAdf = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(text, type, cardOptions) {
|
|
504
510
|
var provider;
|
|
@@ -549,9 +555,6 @@ function insertAutoMacro(slice, macro, view, from, to) {
|
|
|
549
555
|
}
|
|
550
556
|
return false;
|
|
551
557
|
}
|
|
552
|
-
|
|
553
|
-
// Ignored via go/ees005
|
|
554
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
555
558
|
export function handleMacroAutoConvert(text, slice, queueCardsFromChangedTr, runMacroAutoConvert, cardsOptions, extensionAutoConverter) {
|
|
556
559
|
return function (state, dispatch, view) {
|
|
557
560
|
var macro = null;
|
|
@@ -772,9 +775,6 @@ export function handleExpandPaste(slice, isNestingExpandsSupported) {
|
|
|
772
775
|
return false;
|
|
773
776
|
};
|
|
774
777
|
}
|
|
775
|
-
|
|
776
|
-
// Ignored via go/ees005
|
|
777
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
778
778
|
export function handleMarkdown(markdownSlice, queueCardsFromChangedTr, from, to) {
|
|
779
779
|
return function (state, dispatch) {
|
|
780
780
|
var tr = closeHistory(state.tr);
|
|
@@ -1039,7 +1039,7 @@ export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrC
|
|
|
1039
1039
|
});
|
|
1040
1040
|
if (insideTableCell(state) && isInListItem(state) && canInsert(selection.$from, slice.content) && canInsert(selection.$to, slice.content) || sliceHasList) {
|
|
1041
1041
|
tr.replaceSelection(slice);
|
|
1042
|
-
} else if (checkTaskListInList(state, slice)) {
|
|
1042
|
+
} else if (checkTaskListInList(state, slice) && (!fg('platform_editor_fix_paste_action_item_in_list') || !checkIfSelectionInNestedList(state))) {
|
|
1043
1043
|
insertSliceForTaskInsideList({
|
|
1044
1044
|
tr: tr,
|
|
1045
1045
|
slice: slice
|
|
@@ -1048,6 +1048,11 @@ export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrC
|
|
|
1048
1048
|
// need safeInsert rather than replaceSelection, so that nodes aren't split in half
|
|
1049
1049
|
// e.g. when pasting a layout into a table, replaceSelection splits the table in half and adds the layout in the middle
|
|
1050
1050
|
tr = safeInsert(slice.content, tr.selection.$to.pos)(tr);
|
|
1051
|
+
if (checkTaskListInList(state, slice) && fg('platform_editor_fix_paste_action_item_in_list')) {
|
|
1052
|
+
updateSelectionAfterReplace({
|
|
1053
|
+
tr: tr
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1051
1056
|
}
|
|
1052
1057
|
}
|
|
1053
1058
|
tr.setStoredMarks([]);
|
|
@@ -1101,4 +1106,26 @@ export var handleSelectedTable = function handleSelectedTable(editorAnalyticsAPI
|
|
|
1101
1106
|
export function checkTaskListInList(state, slice) {
|
|
1102
1107
|
var _slice$content$firstC4;
|
|
1103
1108
|
return Boolean(isInListItem(state) && ['taskList', 'taskItem'].includes(((_slice$content$firstC4 = slice.content.firstChild) === null || _slice$content$firstC4 === void 0 || (_slice$content$firstC4 = _slice$content$firstC4.type) === null || _slice$content$firstC4 === void 0 ? void 0 : _slice$content$firstC4.name) || ''));
|
|
1109
|
+
}
|
|
1110
|
+
export function checkIfSelectionInNestedList(state) {
|
|
1111
|
+
var selection = state.selection,
|
|
1112
|
+
tr = state.tr;
|
|
1113
|
+
var _state$schema$nodes5 = state.schema.nodes,
|
|
1114
|
+
orderedList = _state$schema$nodes5.orderedList,
|
|
1115
|
+
bulletList = _state$schema$nodes5.bulletList,
|
|
1116
|
+
listItem = _state$schema$nodes5.listItem;
|
|
1117
|
+
var selectionParentListItemNode = findParentNodeOfType(listItem)(selection);
|
|
1118
|
+
var selectionParentListNodeWithPos = findParentNodeOfType([bulletList, orderedList])(selection);
|
|
1119
|
+
if (!selectionParentListItemNode || !selectionParentListNodeWithPos) {
|
|
1120
|
+
return false;
|
|
1121
|
+
}
|
|
1122
|
+
var grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
|
|
1123
|
+
var selectionIsInNestedList = !!grandParentListNode;
|
|
1124
|
+
var selectedListItemHasNestedList = false;
|
|
1125
|
+
selectionParentListItemNode.node.content.forEach(function (child) {
|
|
1126
|
+
if (isListNode(child)) {
|
|
1127
|
+
selectedListItemHasNestedList = true;
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
return selectedListItemHasNestedList || selectionIsInNestedList;
|
|
1104
1131
|
}
|
|
@@ -56,3 +56,4 @@ export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: Qu
|
|
|
56
56
|
export declare function handlePasteIntoCaption(slice: Slice): Command;
|
|
57
57
|
export declare const handleSelectedTable: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (slice: Slice) => Command;
|
|
58
58
|
export declare function checkTaskListInList(state: EditorState, slice: Slice): boolean;
|
|
59
|
+
export declare function checkIfSelectionInNestedList(state: EditorState): boolean;
|
|
@@ -56,3 +56,4 @@ export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: Qu
|
|
|
56
56
|
export declare function handlePasteIntoCaption(slice: Slice): Command;
|
|
57
57
|
export declare const handleSelectedTable: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (slice: Slice) => Command;
|
|
58
58
|
export declare function checkTaskListInList(state: EditorState, slice: Slice): boolean;
|
|
59
|
+
export declare function checkIfSelectionInNestedList(state: EditorState): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
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.
|
|
35
|
+
"@atlaskit/editor-common": "^99.6.0",
|
|
36
|
+
"@atlaskit/editor-markdown-transformer": "^5.14.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.11.0",
|
|
38
|
-
"@atlaskit/editor-plugin-annotation": "^1.
|
|
39
|
-
"@atlaskit/editor-plugin-better-type-history": "^1.
|
|
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": "^31.
|
|
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
|
},
|
|
@@ -124,6 +124,9 @@
|
|
|
124
124
|
},
|
|
125
125
|
"platform_editor_fix_captions_on_copy": {
|
|
126
126
|
"type": "boolean"
|
|
127
|
+
},
|
|
128
|
+
"platform_editor_fix_paste_action_item_in_list": {
|
|
129
|
+
"type": "boolean"
|
|
127
130
|
}
|
|
128
131
|
}
|
|
129
132
|
}
|