@atlaskit/editor-plugin-paste 1.11.0 → 1.11.2
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 +17 -0
- package/dist/cjs/handlers.js +27 -18
- package/dist/cjs/pm-plugins/analytics.js +2 -2
- package/dist/cjs/pm-plugins/main.js +4 -2
- package/dist/es2019/handlers.js +14 -5
- package/dist/es2019/pm-plugins/analytics.js +3 -3
- package/dist/es2019/pm-plugins/main.js +4 -2
- package/dist/esm/handlers.js +25 -17
- package/dist/esm/pm-plugins/analytics.js +3 -3
- package/dist/esm/pm-plugins/main.js +4 -2
- package/dist/types/handlers.d.ts +1 -1
- package/dist/types/pm-plugins/analytics.d.ts +1 -1
- package/dist/types-ts4.5/handlers.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/analytics.d.ts +1 -1
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 1.11.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#134213](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/134213)
|
|
8
|
+
[`93bd7032842ec`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/93bd7032842ec) -
|
|
9
|
+
[ux] [ED-24636] Bump ADF Schema package
|
|
10
|
+
|
|
11
|
+
## 1.11.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#130811](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/130811)
|
|
16
|
+
[`541a703405a7d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/541a703405a7d) -
|
|
17
|
+
[ux] [ED-24431] Ability to paste an expand into another expand
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 1.11.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/dist/cjs/handlers.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.checkTaskListInList = checkTaskListInList;
|
|
|
8
8
|
exports.doesSelectionWhichStartsOrEndsInListContainEntireList = void 0;
|
|
9
9
|
exports.flattenNestedListInSlice = flattenNestedListInSlice;
|
|
10
10
|
exports.handleCodeBlock = handleCodeBlock;
|
|
11
|
-
exports.
|
|
11
|
+
exports.handleExpandPaste = handleExpandPaste;
|
|
12
12
|
exports.handleMacroAutoConvert = handleMacroAutoConvert;
|
|
13
13
|
exports.handleMarkdown = handleMarkdown;
|
|
14
14
|
exports.handleMediaSingle = handleMediaSingle;
|
|
@@ -48,6 +48,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
48
48
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
49
49
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
50
50
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // TODO: ED-20519 Needs Macro extraction
|
|
51
|
+
var insideExpand = function insideExpand(state) {
|
|
52
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
53
|
+
expand = _state$schema$nodes.expand,
|
|
54
|
+
nestedExpand = _state$schema$nodes.nestedExpand;
|
|
55
|
+
return (0, _utils2.hasParentNodeOfType)([expand, nestedExpand])(state.selection);
|
|
56
|
+
};
|
|
57
|
+
|
|
51
58
|
/** Helper type for single arg function */
|
|
52
59
|
|
|
53
60
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -219,10 +226,10 @@ function handlePasteNonNestableBlockNodesIntoList(slice) {
|
|
|
219
226
|
$to = selection.$to,
|
|
220
227
|
from = selection.from,
|
|
221
228
|
to = selection.to;
|
|
222
|
-
var _state$schema$
|
|
223
|
-
orderedList = _state$schema$
|
|
224
|
-
bulletList = _state$schema$
|
|
225
|
-
listItem = _state$schema$
|
|
229
|
+
var _state$schema$nodes2 = state.schema.nodes,
|
|
230
|
+
orderedList = _state$schema$nodes2.orderedList,
|
|
231
|
+
bulletList = _state$schema$nodes2.bulletList,
|
|
232
|
+
listItem = _state$schema$nodes2.listItem;
|
|
226
233
|
|
|
227
234
|
// Selected nodes
|
|
228
235
|
var selectionParentListItemNode = (0, _utils2.findParentNodeOfType)(listItem)(selection);
|
|
@@ -660,7 +667,7 @@ function handleMediaSingle(inputMethod, insertMediaAsMediaSingle) {
|
|
|
660
667
|
};
|
|
661
668
|
};
|
|
662
669
|
}
|
|
663
|
-
var
|
|
670
|
+
var hasTopLevelExpand = function hasTopLevelExpand(slice) {
|
|
664
671
|
var hasExpand = false;
|
|
665
672
|
slice.content.forEach(function (node) {
|
|
666
673
|
if (node.type.name === 'expand' || node.type.name === 'nestedExpand') {
|
|
@@ -689,16 +696,18 @@ function handleTableContentPasteInBodiedExtension(slice) {
|
|
|
689
696
|
return false;
|
|
690
697
|
};
|
|
691
698
|
}
|
|
692
|
-
function
|
|
699
|
+
function handleExpandPaste(slice, isNestingExpandsSupported) {
|
|
693
700
|
return function (state, dispatch) {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
if
|
|
701
|
+
var isInsideNestableExpand = isNestingExpandsSupported && !!insideExpand(state);
|
|
702
|
+
|
|
703
|
+
// Do not handle expand if it's not being pasted into a table or expand
|
|
704
|
+
// OR if it's nested within another node when being pasted into a table/expand
|
|
705
|
+
if (!(0, _coreUtils.insideTable)(state) && !isInsideNestableExpand || !hasTopLevelExpand(slice)) {
|
|
697
706
|
return false;
|
|
698
707
|
}
|
|
699
|
-
var _state$schema$
|
|
700
|
-
expand = _state$schema$
|
|
701
|
-
nestedExpand = _state$schema$
|
|
708
|
+
var _state$schema$nodes3 = state.schema.nodes,
|
|
709
|
+
expand = _state$schema$nodes3.expand,
|
|
710
|
+
nestedExpand = _state$schema$nodes3.nestedExpand;
|
|
702
711
|
var tr = state.tr;
|
|
703
712
|
var hasExpand = false;
|
|
704
713
|
var newSlice = (0, _utils.mapSlice)(slice, function (maybeNode) {
|
|
@@ -899,11 +908,11 @@ function flattenNestedListInSlice(slice) {
|
|
|
899
908
|
function handleRichText(slice, queueCardsFromChangedTr) {
|
|
900
909
|
return function (state, dispatch) {
|
|
901
910
|
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
|
|
902
|
-
var _state$schema$
|
|
903
|
-
codeBlock = _state$schema$
|
|
904
|
-
heading = _state$schema$
|
|
905
|
-
paragraph = _state$schema$
|
|
906
|
-
panel = _state$schema$
|
|
911
|
+
var _state$schema$nodes4 = state.schema.nodes,
|
|
912
|
+
codeBlock = _state$schema$nodes4.codeBlock,
|
|
913
|
+
heading = _state$schema$nodes4.heading,
|
|
914
|
+
paragraph = _state$schema$nodes4.paragraph,
|
|
915
|
+
panel = _state$schema$nodes4.panel;
|
|
907
916
|
var selection = state.selection,
|
|
908
917
|
schema = state.schema;
|
|
909
918
|
var firstChildOfSlice = (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.firstChild;
|
|
@@ -338,12 +338,12 @@ var handlePasteNonNestableBlockNodesIntoListWithAnalytics = exports.handlePasteN
|
|
|
338
338
|
}))((0, _handlers.handlePasteNonNestableBlockNodesIntoList)(slice));
|
|
339
339
|
};
|
|
340
340
|
};
|
|
341
|
-
var handleExpandWithAnalytics = exports.handleExpandWithAnalytics = function handleExpandWithAnalytics(editorAnalyticsAPI) {
|
|
341
|
+
var handleExpandWithAnalytics = exports.handleExpandWithAnalytics = function handleExpandWithAnalytics(editorAnalyticsAPI, isNestingExpandsSupported) {
|
|
342
342
|
return function (view, event, slice) {
|
|
343
343
|
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
344
344
|
type: _analytics.PasteTypes.richText,
|
|
345
345
|
pasteSplitList: true
|
|
346
|
-
}))((0, _handlers.
|
|
346
|
+
}))((0, _handlers.handleExpandPaste)(slice, isNestingExpandsSupported));
|
|
347
347
|
};
|
|
348
348
|
};
|
|
349
349
|
var handleSelectedTableWithAnalytics = exports.handleSelectedTableWithAnalytics = function handleSelectedTableWithAnalytics(editorAnalyticsAPI) {
|
|
@@ -27,6 +27,7 @@ var _editorMarkdownTransformer = require("@atlaskit/editor-markdown-transformer"
|
|
|
27
27
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
28
28
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
29
29
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
30
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
30
31
|
var _actions = require("../actions");
|
|
31
32
|
var _commands = require("../commands");
|
|
32
33
|
var _handlers = require("../handlers");
|
|
@@ -368,7 +369,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
368
369
|
|
|
369
370
|
// finally, handle rich-text copy-paste
|
|
370
371
|
if (isRichText || isNestedMarkdownTable) {
|
|
371
|
-
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$l;
|
|
372
|
+
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$f, _pluginInjectionApi$l;
|
|
372
373
|
// linkify the text where possible
|
|
373
374
|
slice = (0, _utils.linkifyContent)(state.schema)(slice);
|
|
374
375
|
if ((0, _analytics2.handlePasteLinkOnSelectedTextWithAnalytics)(editorAnalyticsAPI)(view, event, slice, _analytics.PasteTypes.richText)(state, dispatch)) {
|
|
@@ -425,7 +426,8 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
425
426
|
});
|
|
426
427
|
slice = sliceCopy;
|
|
427
428
|
}
|
|
428
|
-
|
|
429
|
+
var isNestingExpandsSupported = (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f === void 0 || (_pluginInjectionApi$f = _pluginInjectionApi$f.sharedState.currentState()) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.nestedExpandInExpandEx) || (0, _platformFeatureFlags.fg)('platform_editor_nest_nested_expand_in_expand_jira');
|
|
430
|
+
if ((0, _analytics2.handleExpandWithAnalytics)(editorAnalyticsAPI, isNestingExpandsSupported)(view, event, slice)(state, dispatch)) {
|
|
429
431
|
return true;
|
|
430
432
|
}
|
|
431
433
|
if (!(0, _coreUtils.insideTable)(state)) {
|
package/dist/es2019/handlers.js
CHANGED
|
@@ -16,6 +16,13 @@ import { insertSliceForLists, insertSliceForListsInsideBlockquote, insertSliceFo
|
|
|
16
16
|
import { insertSliceInsideOfPanelNodeSelected } from './edge-cases/lists';
|
|
17
17
|
import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
|
|
18
18
|
import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType, isEmptyNode, isSelectionInsidePanel } from './util';
|
|
19
|
+
const insideExpand = state => {
|
|
20
|
+
const {
|
|
21
|
+
expand,
|
|
22
|
+
nestedExpand
|
|
23
|
+
} = state.schema.nodes;
|
|
24
|
+
return hasParentNodeOfType([expand, nestedExpand])(state.selection);
|
|
25
|
+
};
|
|
19
26
|
|
|
20
27
|
/** Helper type for single arg function */
|
|
21
28
|
|
|
@@ -642,7 +649,7 @@ export function handleMediaSingle(inputMethod, insertMediaAsMediaSingle) {
|
|
|
642
649
|
};
|
|
643
650
|
};
|
|
644
651
|
}
|
|
645
|
-
const
|
|
652
|
+
const hasTopLevelExpand = slice => {
|
|
646
653
|
let hasExpand = false;
|
|
647
654
|
slice.content.forEach(node => {
|
|
648
655
|
if (node.type.name === 'expand' || node.type.name === 'nestedExpand') {
|
|
@@ -673,11 +680,13 @@ export function handleTableContentPasteInBodiedExtension(slice) {
|
|
|
673
680
|
return false;
|
|
674
681
|
};
|
|
675
682
|
}
|
|
676
|
-
export function
|
|
683
|
+
export function handleExpandPaste(slice, isNestingExpandsSupported) {
|
|
677
684
|
return (state, dispatch) => {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
if
|
|
685
|
+
const isInsideNestableExpand = isNestingExpandsSupported && !!insideExpand(state);
|
|
686
|
+
|
|
687
|
+
// Do not handle expand if it's not being pasted into a table or expand
|
|
688
|
+
// OR if it's nested within another node when being pasted into a table/expand
|
|
689
|
+
if (!insideTable(state) && !isInsideNestableExpand || !hasTopLevelExpand(slice)) {
|
|
681
690
|
return false;
|
|
682
691
|
}
|
|
683
692
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, PasteContents, PasteTypes } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { getLinkDomain, mapSlice } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
-
import { handleCodeBlock,
|
|
4
|
+
import { handleCodeBlock, handleExpandPaste, handleMarkdown, handleMediaSingle, handlePasteAsPlainText, handlePasteIntoCaption, handlePasteIntoTaskOrDecisionOrPanel, handlePasteLinkOnSelectedText, handlePasteNonNestableBlockNodesIntoList, handlePastePanelOrDecisionContentIntoList, handlePastePreservingMarks, handleRichText, handleSelectedTable } from '../handlers';
|
|
5
5
|
import { getPasteSource } from '../util';
|
|
6
6
|
const contentToPasteContent = {
|
|
7
7
|
url: PasteContents.url,
|
|
@@ -305,10 +305,10 @@ export const handlePasteNonNestableBlockNodesIntoListWithAnalytics = editorAnaly
|
|
|
305
305
|
type: PasteTypes.richText,
|
|
306
306
|
pasteSplitList: true
|
|
307
307
|
}))(handlePasteNonNestableBlockNodesIntoList(slice));
|
|
308
|
-
export const handleExpandWithAnalytics = editorAnalyticsAPI => (view, event, slice) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
308
|
+
export const handleExpandWithAnalytics = (editorAnalyticsAPI, isNestingExpandsSupported) => (view, event, slice) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
309
309
|
type: PasteTypes.richText,
|
|
310
310
|
pasteSplitList: true
|
|
311
|
-
}))(
|
|
311
|
+
}))(handleExpandPaste(slice, isNestingExpandsSupported));
|
|
312
312
|
export const handleSelectedTableWithAnalytics = editorAnalyticsAPI => (view, event, slice) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
313
313
|
type: PasteTypes.richText
|
|
314
314
|
}))(handleSelectedTable(editorAnalyticsAPI)(slice));
|
|
@@ -11,6 +11,7 @@ import { MarkdownTransformer } from '@atlaskit/editor-markdown-transformer';
|
|
|
11
11
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
12
12
|
import { contains, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
13
13
|
import { handlePaste as handlePasteTable } from '@atlaskit/editor-tables/utils';
|
|
14
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
15
|
import { PastePluginActionTypes } from '../actions';
|
|
15
16
|
import { splitParagraphs, upgradeTextToLists } from '../commands';
|
|
16
17
|
import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks, handleTableContentPasteInBodiedExtension } from '../handlers';
|
|
@@ -339,7 +340,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
339
340
|
|
|
340
341
|
// finally, handle rich-text copy-paste
|
|
341
342
|
if (isRichText || isNestedMarkdownTable) {
|
|
342
|
-
var _pluginInjectionApi$c3, _pluginInjectionApi$c4, _pluginInjectionApi$e3, _pluginInjectionApi$e4, _pluginInjectionApi$l;
|
|
343
|
+
var _pluginInjectionApi$c3, _pluginInjectionApi$c4, _pluginInjectionApi$e3, _pluginInjectionApi$e4, _pluginInjectionApi$f, _pluginInjectionApi$f2, _pluginInjectionApi$l;
|
|
343
344
|
// linkify the text where possible
|
|
344
345
|
slice = linkifyContent(state.schema)(slice);
|
|
345
346
|
if (handlePasteLinkOnSelectedTextWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
@@ -394,7 +395,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
394
395
|
});
|
|
395
396
|
slice = sliceCopy;
|
|
396
397
|
}
|
|
397
|
-
|
|
398
|
+
const isNestingExpandsSupported = (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f === void 0 ? void 0 : (_pluginInjectionApi$f2 = _pluginInjectionApi$f.sharedState.currentState()) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.nestedExpandInExpandEx) || fg('platform_editor_nest_nested_expand_in_expand_jira');
|
|
399
|
+
if (handleExpandWithAnalytics(editorAnalyticsAPI, isNestingExpandsSupported)(view, event, slice)(state, dispatch)) {
|
|
398
400
|
return true;
|
|
399
401
|
}
|
|
400
402
|
if (!insideTable(state)) {
|
package/dist/esm/handlers.js
CHANGED
|
@@ -24,6 +24,12 @@ import { insertSliceForLists, insertSliceForListsInsideBlockquote, insertSliceFo
|
|
|
24
24
|
import { insertSliceInsideOfPanelNodeSelected } from './edge-cases/lists';
|
|
25
25
|
import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
|
|
26
26
|
import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType, isEmptyNode, isSelectionInsidePanel } from './util';
|
|
27
|
+
var insideExpand = function insideExpand(state) {
|
|
28
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
29
|
+
expand = _state$schema$nodes.expand,
|
|
30
|
+
nestedExpand = _state$schema$nodes.nestedExpand;
|
|
31
|
+
return hasParentNodeOfType([expand, nestedExpand])(state.selection);
|
|
32
|
+
};
|
|
27
33
|
|
|
28
34
|
/** Helper type for single arg function */
|
|
29
35
|
|
|
@@ -196,10 +202,10 @@ export function handlePasteNonNestableBlockNodesIntoList(slice) {
|
|
|
196
202
|
$to = selection.$to,
|
|
197
203
|
from = selection.from,
|
|
198
204
|
to = selection.to;
|
|
199
|
-
var _state$schema$
|
|
200
|
-
orderedList = _state$schema$
|
|
201
|
-
bulletList = _state$schema$
|
|
202
|
-
listItem = _state$schema$
|
|
205
|
+
var _state$schema$nodes2 = state.schema.nodes,
|
|
206
|
+
orderedList = _state$schema$nodes2.orderedList,
|
|
207
|
+
bulletList = _state$schema$nodes2.bulletList,
|
|
208
|
+
listItem = _state$schema$nodes2.listItem;
|
|
203
209
|
|
|
204
210
|
// Selected nodes
|
|
205
211
|
var selectionParentListItemNode = findParentNodeOfType(listItem)(selection);
|
|
@@ -637,7 +643,7 @@ export function handleMediaSingle(inputMethod, insertMediaAsMediaSingle) {
|
|
|
637
643
|
};
|
|
638
644
|
};
|
|
639
645
|
}
|
|
640
|
-
var
|
|
646
|
+
var hasTopLevelExpand = function hasTopLevelExpand(slice) {
|
|
641
647
|
var hasExpand = false;
|
|
642
648
|
slice.content.forEach(function (node) {
|
|
643
649
|
if (node.type.name === 'expand' || node.type.name === 'nestedExpand') {
|
|
@@ -666,16 +672,18 @@ export function handleTableContentPasteInBodiedExtension(slice) {
|
|
|
666
672
|
return false;
|
|
667
673
|
};
|
|
668
674
|
}
|
|
669
|
-
export function
|
|
675
|
+
export function handleExpandPaste(slice, isNestingExpandsSupported) {
|
|
670
676
|
return function (state, dispatch) {
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
if
|
|
677
|
+
var isInsideNestableExpand = isNestingExpandsSupported && !!insideExpand(state);
|
|
678
|
+
|
|
679
|
+
// Do not handle expand if it's not being pasted into a table or expand
|
|
680
|
+
// OR if it's nested within another node when being pasted into a table/expand
|
|
681
|
+
if (!insideTable(state) && !isInsideNestableExpand || !hasTopLevelExpand(slice)) {
|
|
674
682
|
return false;
|
|
675
683
|
}
|
|
676
|
-
var _state$schema$
|
|
677
|
-
expand = _state$schema$
|
|
678
|
-
nestedExpand = _state$schema$
|
|
684
|
+
var _state$schema$nodes3 = state.schema.nodes,
|
|
685
|
+
expand = _state$schema$nodes3.expand,
|
|
686
|
+
nestedExpand = _state$schema$nodes3.nestedExpand;
|
|
679
687
|
var tr = state.tr;
|
|
680
688
|
var hasExpand = false;
|
|
681
689
|
var newSlice = mapSlice(slice, function (maybeNode) {
|
|
@@ -876,11 +884,11 @@ export function flattenNestedListInSlice(slice) {
|
|
|
876
884
|
export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
877
885
|
return function (state, dispatch) {
|
|
878
886
|
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
|
|
879
|
-
var _state$schema$
|
|
880
|
-
codeBlock = _state$schema$
|
|
881
|
-
heading = _state$schema$
|
|
882
|
-
paragraph = _state$schema$
|
|
883
|
-
panel = _state$schema$
|
|
887
|
+
var _state$schema$nodes4 = state.schema.nodes,
|
|
888
|
+
codeBlock = _state$schema$nodes4.codeBlock,
|
|
889
|
+
heading = _state$schema$nodes4.heading,
|
|
890
|
+
paragraph = _state$schema$nodes4.paragraph,
|
|
891
|
+
panel = _state$schema$nodes4.panel;
|
|
884
892
|
var selection = state.selection,
|
|
885
893
|
schema = state.schema;
|
|
886
894
|
var firstChildOfSlice = (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.firstChild;
|
|
@@ -5,7 +5,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, PasteContents, PasteTypes } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { getLinkDomain, mapSlice } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
8
|
-
import { handleCodeBlock,
|
|
8
|
+
import { handleCodeBlock, handleExpandPaste, handleMarkdown, handleMediaSingle, handlePasteAsPlainText, handlePasteIntoCaption, handlePasteIntoTaskOrDecisionOrPanel, handlePasteLinkOnSelectedText, handlePasteNonNestableBlockNodesIntoList, handlePastePanelOrDecisionContentIntoList, handlePastePreservingMarks, handleRichText, handleSelectedTable } from '../handlers';
|
|
9
9
|
import { getPasteSource } from '../util';
|
|
10
10
|
var contentToPasteContent = {
|
|
11
11
|
url: PasteContents.url,
|
|
@@ -326,12 +326,12 @@ export var handlePasteNonNestableBlockNodesIntoListWithAnalytics = function hand
|
|
|
326
326
|
}))(handlePasteNonNestableBlockNodesIntoList(slice));
|
|
327
327
|
};
|
|
328
328
|
};
|
|
329
|
-
export var handleExpandWithAnalytics = function handleExpandWithAnalytics(editorAnalyticsAPI) {
|
|
329
|
+
export var handleExpandWithAnalytics = function handleExpandWithAnalytics(editorAnalyticsAPI, isNestingExpandsSupported) {
|
|
330
330
|
return function (view, event, slice) {
|
|
331
331
|
return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
332
332
|
type: PasteTypes.richText,
|
|
333
333
|
pasteSplitList: true
|
|
334
|
-
}))(
|
|
334
|
+
}))(handleExpandPaste(slice, isNestingExpandsSupported));
|
|
335
335
|
};
|
|
336
336
|
};
|
|
337
337
|
export var handleSelectedTableWithAnalytics = function handleSelectedTableWithAnalytics(editorAnalyticsAPI) {
|
|
@@ -13,6 +13,7 @@ import { MarkdownTransformer } from '@atlaskit/editor-markdown-transformer';
|
|
|
13
13
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
14
14
|
import { contains, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
15
15
|
import { handlePaste as handlePasteTable } from '@atlaskit/editor-tables/utils';
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
17
|
import { PastePluginActionTypes } from '../actions';
|
|
17
18
|
import { splitParagraphs, upgradeTextToLists } from '../commands';
|
|
18
19
|
import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks, handleTableContentPasteInBodiedExtension } from '../handlers';
|
|
@@ -355,7 +356,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
355
356
|
|
|
356
357
|
// finally, handle rich-text copy-paste
|
|
357
358
|
if (isRichText || isNestedMarkdownTable) {
|
|
358
|
-
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$l;
|
|
359
|
+
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$f, _pluginInjectionApi$l;
|
|
359
360
|
// linkify the text where possible
|
|
360
361
|
slice = linkifyContent(state.schema)(slice);
|
|
361
362
|
if (handlePasteLinkOnSelectedTextWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
@@ -412,7 +413,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
412
413
|
});
|
|
413
414
|
slice = sliceCopy;
|
|
414
415
|
}
|
|
415
|
-
|
|
416
|
+
var isNestingExpandsSupported = (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f === void 0 || (_pluginInjectionApi$f = _pluginInjectionApi$f.sharedState.currentState()) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.nestedExpandInExpandEx) || fg('platform_editor_nest_nested_expand_in_expand_jira');
|
|
417
|
+
if (handleExpandWithAnalytics(editorAnalyticsAPI, isNestingExpandsSupported)(view, event, slice)(state, dispatch)) {
|
|
416
418
|
return true;
|
|
417
419
|
}
|
|
418
420
|
if (!insideTable(state)) {
|
package/dist/types/handlers.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare function handleMacroAutoConvert(text: string, slice: Slice, queue
|
|
|
20
20
|
export declare function handleCodeBlock(text: string): Command;
|
|
21
21
|
export declare function handleMediaSingle(inputMethod: InputMethodInsertMedia, insertMediaAsMediaSingle: InsertMediaAsMediaSingle | undefined): (slice: Slice) => Command;
|
|
22
22
|
export declare function handleTableContentPasteInBodiedExtension(slice: Slice): Command;
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function handleExpandPaste(slice: Slice, isNestingExpandsSupported?: boolean): Command;
|
|
24
24
|
export declare function handleMarkdown(markdownSlice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined, from?: number, to?: number): Command;
|
|
25
25
|
export declare function handleParagraphBlockMarks(state: EditorState, slice: Slice): Slice;
|
|
26
26
|
/**
|
|
@@ -31,7 +31,7 @@ export declare const handleMarkdownWithAnalytics: (view: EditorView, event: Clip
|
|
|
31
31
|
export declare const handleRichTextWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
|
|
32
32
|
export declare const handlePastePanelOrDecisionIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, findRootParentListNode: FindRootParentListNode | undefined) => Command;
|
|
33
33
|
export declare const handlePasteNonNestableBlockNodesIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
34
|
-
export declare const handleExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
34
|
+
export declare const handleExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported: boolean) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
35
35
|
export declare const handleSelectedTableWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
36
36
|
export declare const handlePasteLinkOnSelectedTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType) => Command;
|
|
37
37
|
export declare const createPasteMeasurePayload: ({ view, duration, content, distortedDuration, }: {
|
|
@@ -20,7 +20,7 @@ export declare function handleMacroAutoConvert(text: string, slice: Slice, queue
|
|
|
20
20
|
export declare function handleCodeBlock(text: string): Command;
|
|
21
21
|
export declare function handleMediaSingle(inputMethod: InputMethodInsertMedia, insertMediaAsMediaSingle: InsertMediaAsMediaSingle | undefined): (slice: Slice) => Command;
|
|
22
22
|
export declare function handleTableContentPasteInBodiedExtension(slice: Slice): Command;
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function handleExpandPaste(slice: Slice, isNestingExpandsSupported?: boolean): Command;
|
|
24
24
|
export declare function handleMarkdown(markdownSlice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined, from?: number, to?: number): Command;
|
|
25
25
|
export declare function handleParagraphBlockMarks(state: EditorState, slice: Slice): Slice;
|
|
26
26
|
/**
|
|
@@ -31,7 +31,7 @@ export declare const handleMarkdownWithAnalytics: (view: EditorView, event: Clip
|
|
|
31
31
|
export declare const handleRichTextWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
|
|
32
32
|
export declare const handlePastePanelOrDecisionIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, findRootParentListNode: FindRootParentListNode | undefined) => Command;
|
|
33
33
|
export declare const handlePasteNonNestableBlockNodesIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
34
|
-
export declare const handleExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
34
|
+
export declare const handleExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported: boolean) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
35
35
|
export declare const handleSelectedTableWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
36
36
|
export declare const handlePasteLinkOnSelectedTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType) => Command;
|
|
37
37
|
export declare const createPasteMeasurePayload: ({ view, duration, content, distortedDuration, }: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/editor-common": "^88.
|
|
36
|
+
"@atlaskit/editor-common": "^88.2.0",
|
|
37
37
|
"@atlaskit/editor-markdown-transformer": "^5.11.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^1.8.0",
|
|
39
39
|
"@atlaskit/editor-plugin-annotation": "^1.19.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@af/visual-regression": "*",
|
|
60
|
-
"@atlaskit/adf-schema": "^40.
|
|
60
|
+
"@atlaskit/adf-schema": "^40.9.0",
|
|
61
61
|
"@atlaskit/editor-plugin-block-type": "^3.14.0",
|
|
62
62
|
"@atlaskit/editor-plugin-history": "^1.3.0",
|
|
63
63
|
"@atlaskit/editor-plugin-type-ahead": "^1.8.0",
|
|
@@ -118,6 +118,9 @@
|
|
|
118
118
|
},
|
|
119
119
|
"editor_inline_comments_paste_insert_nodes": {
|
|
120
120
|
"type": "boolean"
|
|
121
|
+
},
|
|
122
|
+
"platform_editor_nest_nested_expand_in_expand_jira": {
|
|
123
|
+
"type": "boolean"
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
126
|
}
|