@atlaskit/editor-plugin-paste 8.3.0 → 8.4.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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 8.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b47da2946160e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b47da2946160e) -
8
+ [FFCLEANUP-79685] clean up missed references to platform_editor_fix_captions_on_copy
9
+ - Updated dependencies
10
+
11
+ ## 8.4.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`342dd44a8575e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/342dd44a8575e) -
16
+ [ux] EDITOR-4609 Add prop to disable pasting expands
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 8.3.0
4
23
 
5
24
  ### Minor Changes
@@ -539,6 +539,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
539
539
  return false;
540
540
  },
541
541
  transformPasted: function transformPasted(slice) {
542
+ var _pluginInjectionApi$e3;
542
543
  if (sanitizePrivateContent) {
543
544
  slice = (0, _handlers.handleMention)(slice, schema);
544
545
  }
@@ -548,6 +549,10 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
548
549
  if (pastedFromBitBucket) {
549
550
  slice = (0, _transforms.transformSliceToJoinAdjacentCodeBlocks)(slice);
550
551
  }
552
+ // Filter out expand nodes if allowExpand is false
553
+ if (!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && (_pluginInjectionApi$e3 = pluginInjectionApi.expand) !== null && _pluginInjectionApi$e3 !== void 0 && (_pluginInjectionApi$e3 = _pluginInjectionApi$e3.sharedState) !== null && _pluginInjectionApi$e3 !== void 0 && (_pluginInjectionApi$e3 = _pluginInjectionApi$e3.currentState()) !== null && _pluginInjectionApi$e3 !== void 0 && _pluginInjectionApi$e3.allowInsertion) && (0, _expValEquals.expValEquals)('platform_editor_expand_paste_in_comment_editor', 'isEnabled', true)) {
554
+ slice = (0, _handlers.handlePasteExpand)(slice);
555
+ }
551
556
  slice = (0, _transforms.transformSingleLineCodeBlockToCodeMark)(slice, schema);
552
557
  slice = (0, _media.transformSliceToCorrectMediaWrapper)(slice, schema);
553
558
  slice = (0, _media.transformSliceToMediaSingleWithNewExperience)(slice, schema, pluginInjectionApi);
@@ -17,6 +17,7 @@ exports.handleMention = handleMention;
17
17
  exports.handleNestedTablePaste = handleNestedTablePaste;
18
18
  exports.handleParagraphBlockMarks = handleParagraphBlockMarks;
19
19
  exports.handlePasteAsPlainText = handlePasteAsPlainText;
20
+ exports.handlePasteExpand = handlePasteExpand;
20
21
  exports.handlePasteIntoCaption = handlePasteIntoCaption;
21
22
  exports.handlePasteIntoTaskOrDecisionOrPanel = handlePasteIntoTaskOrDecisionOrPanel;
22
23
  exports.handlePasteLinkOnSelectedText = handlePasteLinkOnSelectedText;
@@ -1204,4 +1205,21 @@ function checkIfSelectionInNestedList(state) {
1204
1205
  }
1205
1206
  });
1206
1207
  return selectedListItemHasNestedList || selectionIsInNestedList;
1208
+ }
1209
+
1210
+ // Helper function to filter expand nodes from slice when not allowed
1211
+ function handlePasteExpand(slice) {
1212
+ return (0, _utils.mapSlice)(slice, function (node) {
1213
+ if (node.type.name === 'expand' || node.type.name === 'nestedExpand') {
1214
+ var children = [];
1215
+ if (node.attrs.title) {
1216
+ children.push(node.type.schema.nodes.paragraph.createChecked(undefined, _model.Fragment.from(node.type.schema.text(node.attrs.title))));
1217
+ }
1218
+ node.content.forEach(function (inner) {
1219
+ return children.push(inner);
1220
+ });
1221
+ return children;
1222
+ }
1223
+ return node;
1224
+ });
1207
1225
  }
@@ -28,7 +28,7 @@ import { createClipboardTextSerializer, clipboardTextSerializer } from './clipbo
28
28
  import { createPluginState, pluginKey as stateKey } from './plugin-factory';
29
29
  import { escapeBackslashAndLinksExceptCodeBlock, getPasteSource, htmlContainsSingleFile, htmlHasInvalidLinkTags, isPastedFromExcel, isPastedFromWord, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from './util';
30
30
  import { handleVSCodeBlock } from './util/edge-cases/handleVSCodeBlock';
31
- import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks, handleTableContentPasteInBodiedExtension } from './util/handlers';
31
+ import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks, handleTableContentPasteInBodiedExtension, handlePasteExpand } from './util/handlers';
32
32
  import { handleSyncBlocksPaste } from './util/sync-block';
33
33
  import { htmlHasIncompleteTable, isPastedFromTinyMCEConfluence, tryRebuildCompleteTableHtml } from './util/tinyMCE';
34
34
  export const isInsideBlockQuote = state => {
@@ -501,6 +501,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
501
501
  return false;
502
502
  },
503
503
  transformPasted(slice) {
504
+ var _pluginInjectionApi$e5, _pluginInjectionApi$e6, _pluginInjectionApi$e7;
504
505
  if (sanitizePrivateContent) {
505
506
  slice = handleMention(slice, schema);
506
507
  }
@@ -510,6 +511,10 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
510
511
  if (pastedFromBitBucket) {
511
512
  slice = transformSliceToJoinAdjacentCodeBlocks(slice);
512
513
  }
514
+ // Filter out expand nodes if allowExpand is false
515
+ if (!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && (_pluginInjectionApi$e5 = pluginInjectionApi.expand) !== null && _pluginInjectionApi$e5 !== void 0 && (_pluginInjectionApi$e6 = _pluginInjectionApi$e5.sharedState) !== null && _pluginInjectionApi$e6 !== void 0 && (_pluginInjectionApi$e7 = _pluginInjectionApi$e6.currentState()) !== null && _pluginInjectionApi$e7 !== void 0 && _pluginInjectionApi$e7.allowInsertion) && expValEquals('platform_editor_expand_paste_in_comment_editor', 'isEnabled', true)) {
516
+ slice = handlePasteExpand(slice);
517
+ }
513
518
  slice = transformSingleLineCodeBlockToCodeMark(slice, schema);
514
519
  slice = transformSliceToCorrectMediaWrapper(slice, schema);
515
520
  slice = transformSliceToMediaSingleWithNewExperience(slice, schema, pluginInjectionApi);
@@ -1184,4 +1184,19 @@ export function checkIfSelectionInNestedList(state) {
1184
1184
  }
1185
1185
  });
1186
1186
  return selectedListItemHasNestedList || selectionIsInNestedList;
1187
+ }
1188
+
1189
+ // Helper function to filter expand nodes from slice when not allowed
1190
+ export function handlePasteExpand(slice) {
1191
+ return mapSlice(slice, node => {
1192
+ if (node.type.name === 'expand' || node.type.name === 'nestedExpand') {
1193
+ const children = [];
1194
+ if (node.attrs.title) {
1195
+ children.push(node.type.schema.nodes.paragraph.createChecked(undefined, Fragment.from(node.type.schema.text(node.attrs.title))));
1196
+ }
1197
+ node.content.forEach(inner => children.push(inner));
1198
+ return children;
1199
+ }
1200
+ return node;
1201
+ });
1187
1202
  }
@@ -33,7 +33,7 @@ import { createClipboardTextSerializer, clipboardTextSerializer } from './clipbo
33
33
  import { createPluginState, pluginKey as stateKey } from './plugin-factory';
34
34
  import { escapeBackslashAndLinksExceptCodeBlock, getPasteSource, htmlContainsSingleFile, htmlHasInvalidLinkTags, isPastedFromExcel, isPastedFromWord, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from './util';
35
35
  import { handleVSCodeBlock } from './util/edge-cases/handleVSCodeBlock';
36
- import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks, handleTableContentPasteInBodiedExtension } from './util/handlers';
36
+ import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks, handleTableContentPasteInBodiedExtension, handlePasteExpand } from './util/handlers';
37
37
  import { handleSyncBlocksPaste } from './util/sync-block';
38
38
  import { htmlHasIncompleteTable, isPastedFromTinyMCEConfluence, tryRebuildCompleteTableHtml } from './util/tinyMCE';
39
39
  export var isInsideBlockQuote = function isInsideBlockQuote(state) {
@@ -531,6 +531,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
531
531
  return false;
532
532
  },
533
533
  transformPasted: function transformPasted(slice) {
534
+ var _pluginInjectionApi$e3;
534
535
  if (sanitizePrivateContent) {
535
536
  slice = handleMention(slice, schema);
536
537
  }
@@ -540,6 +541,10 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
540
541
  if (pastedFromBitBucket) {
541
542
  slice = transformSliceToJoinAdjacentCodeBlocks(slice);
542
543
  }
544
+ // Filter out expand nodes if allowExpand is false
545
+ if (!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && (_pluginInjectionApi$e3 = pluginInjectionApi.expand) !== null && _pluginInjectionApi$e3 !== void 0 && (_pluginInjectionApi$e3 = _pluginInjectionApi$e3.sharedState) !== null && _pluginInjectionApi$e3 !== void 0 && (_pluginInjectionApi$e3 = _pluginInjectionApi$e3.currentState()) !== null && _pluginInjectionApi$e3 !== void 0 && _pluginInjectionApi$e3.allowInsertion) && expValEquals('platform_editor_expand_paste_in_comment_editor', 'isEnabled', true)) {
546
+ slice = handlePasteExpand(slice);
547
+ }
543
548
  slice = transformSingleLineCodeBlockToCodeMark(slice, schema);
544
549
  slice = transformSliceToCorrectMediaWrapper(slice, schema);
545
550
  slice = transformSliceToMediaSingleWithNewExperience(slice, schema, pluginInjectionApi);
@@ -1178,4 +1178,21 @@ export function checkIfSelectionInNestedList(state) {
1178
1178
  }
1179
1179
  });
1180
1180
  return selectedListItemHasNestedList || selectionIsInNestedList;
1181
+ }
1182
+
1183
+ // Helper function to filter expand nodes from slice when not allowed
1184
+ export function handlePasteExpand(slice) {
1185
+ return mapSlice(slice, function (node) {
1186
+ if (node.type.name === 'expand' || node.type.name === 'nestedExpand') {
1187
+ var children = [];
1188
+ if (node.attrs.title) {
1189
+ children.push(node.type.schema.nodes.paragraph.createChecked(undefined, Fragment.from(node.type.schema.text(node.attrs.title))));
1190
+ }
1191
+ node.content.forEach(function (inner) {
1192
+ return children.push(inner);
1193
+ });
1194
+ return children;
1195
+ }
1196
+ return node;
1197
+ });
1181
1198
  }
@@ -6,6 +6,7 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
6
  import type { AnnotationPlugin } from '@atlaskit/editor-plugin-annotation';
7
7
  import type { BetterTypeHistoryPlugin } from '@atlaskit/editor-plugin-better-type-history';
8
8
  import type { CardPlugin } from '@atlaskit/editor-plugin-card';
9
+ import type { ExpandPlugin } from '@atlaskit/editor-plugin-expand';
9
10
  import type { ExtensionPlugin } from '@atlaskit/editor-plugin-extension';
10
11
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
11
12
  import type { ListPlugin } from '@atlaskit/editor-plugin-list';
@@ -62,7 +63,8 @@ export type PastePluginDependencies = [
62
63
  OptionalPlugin<MediaPlugin>,
63
64
  OptionalPlugin<ExtensionPlugin>,
64
65
  OptionalPlugin<AnnotationPlugin>,
65
- OptionalPlugin<MentionsPlugin>
66
+ OptionalPlugin<MentionsPlugin>,
67
+ OptionalPlugin<ExpandPlugin>
66
68
  ];
67
69
  export type PastePlugin = NextEditorPlugin<'paste', {
68
70
  dependencies: PastePluginDependencies;
@@ -57,3 +57,4 @@ 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
59
  export declare function checkIfSelectionInNestedList(state: EditorState): boolean;
60
+ export declare function handlePasteExpand(slice: Slice): Slice;
@@ -6,6 +6,7 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
6
  import type { AnnotationPlugin } from '@atlaskit/editor-plugin-annotation';
7
7
  import type { BetterTypeHistoryPlugin } from '@atlaskit/editor-plugin-better-type-history';
8
8
  import type { CardPlugin } from '@atlaskit/editor-plugin-card';
9
+ import type { ExpandPlugin } from '@atlaskit/editor-plugin-expand';
9
10
  import type { ExtensionPlugin } from '@atlaskit/editor-plugin-extension';
10
11
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
11
12
  import type { ListPlugin } from '@atlaskit/editor-plugin-list';
@@ -62,7 +63,8 @@ export type PastePluginDependencies = [
62
63
  OptionalPlugin<MediaPlugin>,
63
64
  OptionalPlugin<ExtensionPlugin>,
64
65
  OptionalPlugin<AnnotationPlugin>,
65
- OptionalPlugin<MentionsPlugin>
66
+ OptionalPlugin<MentionsPlugin>,
67
+ OptionalPlugin<ExpandPlugin>
66
68
  ];
67
69
  export type PastePlugin = NextEditorPlugin<'paste', {
68
70
  dependencies: PastePluginDependencies;
@@ -57,3 +57,4 @@ 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
59
  export declare function checkIfSelectionInNestedList(state: EditorState): boolean;
60
+ export declare function handlePasteExpand(slice: Slice): Slice;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "8.3.0",
3
+ "version": "8.4.1",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,10 +34,11 @@
34
34
  "@atlaskit/editor-plugin-annotation": "^7.1.0",
35
35
  "@atlaskit/editor-plugin-better-type-history": "^7.0.0",
36
36
  "@atlaskit/editor-plugin-card": "^12.3.0",
37
+ "@atlaskit/editor-plugin-expand": "^8.4.0",
37
38
  "@atlaskit/editor-plugin-feature-flags": "^6.0.0",
38
39
  "@atlaskit/editor-plugin-list": "^9.0.0",
39
- "@atlaskit/editor-plugin-media": "^9.6.0",
40
- "@atlaskit/editor-plugin-mentions": "^9.3.0",
40
+ "@atlaskit/editor-plugin-media": "^9.7.0",
41
+ "@atlaskit/editor-plugin-mentions": "^9.4.0",
41
42
  "@atlaskit/editor-prosemirror": "^7.3.0",
42
43
  "@atlaskit/editor-tables": "^2.9.0",
43
44
  "@atlaskit/flag": "^17.8.0",
@@ -47,7 +48,7 @@
47
48
  "@atlaskit/media-common": "^13.0.0",
48
49
  "@atlaskit/platform-feature-flags": "^1.1.0",
49
50
  "@atlaskit/prosemirror-history": "^0.2.0",
50
- "@atlaskit/tmp-editor-statsig": "^32.4.0",
51
+ "@atlaskit/tmp-editor-statsig": "^32.10.0",
51
52
  "@atlaskit/tokens": "^11.0.0",
52
53
  "@babel/runtime": "^7.0.0",
53
54
  "lodash": "^4.17.21",
@@ -55,7 +56,7 @@
55
56
  "uuid": "^3.1.0"
56
57
  },
57
58
  "peerDependencies": {
58
- "@atlaskit/editor-common": "^111.21.0",
59
+ "@atlaskit/editor-common": "^111.24.0",
59
60
  "react": "^18.2.0",
60
61
  "react-dom": "^18.2.0"
61
62
  },
@@ -100,9 +101,6 @@
100
101
  }
101
102
  },
102
103
  "platform-feature-flags": {
103
- "platform_editor_fix_captions_on_copy": {
104
- "type": "boolean"
105
- },
106
104
  "platform_editor_legacy_content_macro_insert": {
107
105
  "type": "boolean"
108
106
  },