@atlaskit/editor-plugin-paste 2.0.16 → 2.0.18

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,25 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 2.0.18
4
+
5
+ ### Patch Changes
6
+
7
+ - [#102971](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102971)
8
+ [`a87c6952a44b1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a87c6952a44b1) -
9
+ ED-25451 Support copy of media caption and fix range error when pasting a caption into another
10
+ caption
11
+ - Updated dependencies
12
+
13
+ ## 2.0.17
14
+
15
+ ### Patch Changes
16
+
17
+ - [#102478](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102478)
18
+ [`e14c5f9596217`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e14c5f9596217) -
19
+ Calling media trackMediaPaste command to enable the tracking of out of editor media paste to
20
+ enable deep copy when media copy scope is set to "editor"
21
+ - Updated dependencies
22
+
3
23
  ## 2.0.16
4
24
 
5
25
  ### Patch Changes
@@ -282,6 +282,18 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
282
282
  if ((0, _analytics2.handlePasteAsPlainTextWithAnalytics)(editorAnalyticsAPI)(view, event, plainTextPasteSlice)(state, dispatch, view)) {
283
283
  return true;
284
284
  }
285
+ if ((0, _platformFeatureFlags.fg)('platform_editor_fix_captions_on_copy')) {
286
+ if ((0, _analytics2.handlePasteIntoCaptionWithAnalytics)(editorAnalyticsAPI)(view, event, slice, _analytics.PasteTypes.richText)(state, dispatch)) {
287
+ // Create a custom handler to avoid handling with handleRichText method
288
+ // As SafeInsert is used inside handleRichText which caused some bad UX like this:
289
+ // https://product-fabric.atlassian.net/browse/MEX-1520
290
+
291
+ // Converting caption to plain text needs to be handled before transformSliceForMedia
292
+ // as createChecked will fail when trying to create a mediaSingle node with a caption
293
+ // that is not plain text.
294
+ return true;
295
+ }
296
+ }
285
297
 
286
298
  // transform slices based on destination
287
299
  slice = (0, _media.transformSliceForMedia)(slice, schema)(state.selection);
@@ -445,12 +457,13 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
445
457
  if (!(0, _coreUtils.insideTable)(state)) {
446
458
  slice = (0, _transforms.transformSliceNestedExpandToExpand)(slice, state.schema);
447
459
  }
448
-
449
- // Create a custom handler to avoid handling with handleRichText method
450
- // As SafeInsert is used inside handleRichText which caused some bad UX like this:
451
- // https://product-fabric.atlassian.net/browse/MEX-1520
452
- if ((0, _analytics2.handlePasteIntoCaptionWithAnalytics)(editorAnalyticsAPI)(view, event, slice, _analytics.PasteTypes.richText)(state, dispatch)) {
453
- return true;
460
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_fix_captions_on_copy')) {
461
+ if ((0, _analytics2.handlePasteIntoCaptionWithAnalytics)(editorAnalyticsAPI)(view, event, slice, _analytics.PasteTypes.richText)(state, dispatch)) {
462
+ // Create a custom handler to avoid handling with handleRichText method
463
+ // As SafeInsert is used inside handleRichText which caused some bad UX like this:
464
+ // https://product-fabric.atlassian.net/browse/MEX-1520
465
+ return true;
466
+ }
454
467
  }
455
468
  if ((0, _analytics2.handlePastePanelOrDecisionIntoListWithAnalytics)(editorAnalyticsAPI)(view, event, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.findRootParentListNode)(state, dispatch)) {
456
469
  return true;
@@ -475,7 +488,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
475
488
  }
476
489
  slice = (0, _transforms.transformSingleLineCodeBlockToCodeMark)(slice, schema);
477
490
  slice = (0, _media.transformSliceToCorrectMediaWrapper)(slice, schema);
478
- slice = (0, _media.transformSliceToMediaSingleWithNewExperience)(slice, schema);
491
+ slice = (0, _media.transformSliceToMediaSingleWithNewExperience)(slice, schema, pluginInjectionApi);
479
492
  slice = (0, _transforms.transformSliceToDecisionList)(slice, schema);
480
493
 
481
494
  // splitting linebreaks into paragraphs must happen before upgrading text to lists
@@ -83,7 +83,7 @@ var transformSliceToCorrectMediaWrapper = exports.transformSliceToCorrectMediaWr
83
83
  * Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
84
84
  *
85
85
  */
86
- var transformSliceToMediaSingleWithNewExperience = exports.transformSliceToMediaSingleWithNewExperience = function transformSliceToMediaSingleWithNewExperience(slice, schema) {
86
+ var transformSliceToMediaSingleWithNewExperience = exports.transformSliceToMediaSingleWithNewExperience = function transformSliceToMediaSingleWithNewExperience(slice, schema, api) {
87
87
  var _schema$nodes3 = schema.nodes,
88
88
  mediaInline = _schema$nodes3.mediaInline,
89
89
  mediaSingle = _schema$nodes3.mediaSingle,
@@ -107,12 +107,16 @@ var transformSliceToMediaSingleWithNewExperience = exports.transformSliceToMedia
107
107
  return (0, _utils.mapSlice)(newSlice, function (node) {
108
108
  var __mediaTraceId = (0, _mediaCommon.getRandomHex)(8);
109
109
  if (node.type === media) {
110
+ var _api$media;
111
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media = api.media) === null || _api$media === void 0 ? void 0 : _api$media.commands.trackMediaPaste(node.attrs));
110
112
  return media.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
111
113
  __external: node.attrs.type === 'external',
112
114
  __mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
113
115
  }), node.content, node.marks);
114
116
  }
115
117
  if (node.type.name === 'mediaInline') {
118
+ var _api$media2;
119
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media2 = api.media) === null || _api$media2 === void 0 ? void 0 : _api$media2.commands.trackMediaPaste(node.attrs));
116
120
  return mediaInline.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
117
121
  __mediaTraceId: __mediaTraceId
118
122
  }), node.content, node.marks);
@@ -256,6 +256,18 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
256
256
  if (handlePasteAsPlainTextWithAnalytics(editorAnalyticsAPI)(view, event, plainTextPasteSlice)(state, dispatch, view)) {
257
257
  return true;
258
258
  }
259
+ if (fg('platform_editor_fix_captions_on_copy')) {
260
+ if (handlePasteIntoCaptionWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
261
+ // Create a custom handler to avoid handling with handleRichText method
262
+ // As SafeInsert is used inside handleRichText which caused some bad UX like this:
263
+ // https://product-fabric.atlassian.net/browse/MEX-1520
264
+
265
+ // Converting caption to plain text needs to be handled before transformSliceForMedia
266
+ // as createChecked will fail when trying to create a mediaSingle node with a caption
267
+ // that is not plain text.
268
+ return true;
269
+ }
270
+ }
259
271
 
260
272
  // transform slices based on destination
261
273
  slice = transformSliceForMedia(slice, schema)(state.selection);
@@ -419,12 +431,13 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
419
431
  if (!insideTable(state)) {
420
432
  slice = transformSliceNestedExpandToExpand(slice, state.schema);
421
433
  }
422
-
423
- // Create a custom handler to avoid handling with handleRichText method
424
- // As SafeInsert is used inside handleRichText which caused some bad UX like this:
425
- // https://product-fabric.atlassian.net/browse/MEX-1520
426
- if (handlePasteIntoCaptionWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
427
- return true;
434
+ if (!fg('platform_editor_fix_captions_on_copy')) {
435
+ if (handlePasteIntoCaptionWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
436
+ // Create a custom handler to avoid handling with handleRichText method
437
+ // As SafeInsert is used inside handleRichText which caused some bad UX like this:
438
+ // https://product-fabric.atlassian.net/browse/MEX-1520
439
+ return true;
440
+ }
428
441
  }
429
442
  if (handlePastePanelOrDecisionIntoListWithAnalytics(editorAnalyticsAPI)(view, event, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.findRootParentListNode)(state, dispatch)) {
430
443
  return true;
@@ -449,7 +462,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
449
462
  }
450
463
  slice = transformSingleLineCodeBlockToCodeMark(slice, schema);
451
464
  slice = transformSliceToCorrectMediaWrapper(slice, schema);
452
- slice = transformSliceToMediaSingleWithNewExperience(slice, schema);
465
+ slice = transformSliceToMediaSingleWithNewExperience(slice, schema, pluginInjectionApi);
453
466
  slice = transformSliceToDecisionList(slice, schema);
454
467
 
455
468
  // splitting linebreaks into paragraphs must happen before upgrading text to lists
@@ -3,7 +3,6 @@ import { mapSlice, removeNestedEmptyEls, unwrap, walkUpTreeUntil } from '@atlask
3
3
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
4
4
  import { getRandomHex } from '@atlaskit/media-common';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
-
7
6
  /**
8
7
  * Ensure correct layout in nested mode
9
8
  *
@@ -77,7 +76,7 @@ export const transformSliceToCorrectMediaWrapper = (slice, schema) => {
77
76
  * Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
78
77
  *
79
78
  */
80
- export const transformSliceToMediaSingleWithNewExperience = (slice, schema) => {
79
+ export const transformSliceToMediaSingleWithNewExperience = (slice, schema, api) => {
81
80
  const {
82
81
  mediaInline,
83
82
  mediaSingle,
@@ -102,6 +101,8 @@ export const transformSliceToMediaSingleWithNewExperience = (slice, schema) => {
102
101
  return mapSlice(newSlice, node => {
103
102
  const __mediaTraceId = getRandomHex(8);
104
103
  if (node.type === media) {
104
+ var _api$media;
105
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$media = api.media) === null || _api$media === void 0 ? void 0 : _api$media.commands.trackMediaPaste(node.attrs));
105
106
  return media.createChecked({
106
107
  ...node.attrs,
107
108
  __external: node.attrs.type === 'external',
@@ -109,6 +110,8 @@ export const transformSliceToMediaSingleWithNewExperience = (slice, schema) => {
109
110
  }, node.content, node.marks);
110
111
  }
111
112
  if (node.type.name === 'mediaInline') {
113
+ var _api$media2;
114
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$media2 = api.media) === null || _api$media2 === void 0 ? void 0 : _api$media2.commands.trackMediaPaste(node.attrs));
112
115
  return mediaInline.createChecked({
113
116
  ...node.attrs,
114
117
  __mediaTraceId
@@ -274,6 +274,18 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
274
274
  if (handlePasteAsPlainTextWithAnalytics(editorAnalyticsAPI)(view, event, plainTextPasteSlice)(state, dispatch, view)) {
275
275
  return true;
276
276
  }
277
+ if (fg('platform_editor_fix_captions_on_copy')) {
278
+ if (handlePasteIntoCaptionWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
279
+ // Create a custom handler to avoid handling with handleRichText method
280
+ // As SafeInsert is used inside handleRichText which caused some bad UX like this:
281
+ // https://product-fabric.atlassian.net/browse/MEX-1520
282
+
283
+ // Converting caption to plain text needs to be handled before transformSliceForMedia
284
+ // as createChecked will fail when trying to create a mediaSingle node with a caption
285
+ // that is not plain text.
286
+ return true;
287
+ }
288
+ }
277
289
 
278
290
  // transform slices based on destination
279
291
  slice = transformSliceForMedia(slice, schema)(state.selection);
@@ -437,12 +449,13 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
437
449
  if (!insideTable(state)) {
438
450
  slice = transformSliceNestedExpandToExpand(slice, state.schema);
439
451
  }
440
-
441
- // Create a custom handler to avoid handling with handleRichText method
442
- // As SafeInsert is used inside handleRichText which caused some bad UX like this:
443
- // https://product-fabric.atlassian.net/browse/MEX-1520
444
- if (handlePasteIntoCaptionWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
445
- return true;
452
+ if (!fg('platform_editor_fix_captions_on_copy')) {
453
+ if (handlePasteIntoCaptionWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
454
+ // Create a custom handler to avoid handling with handleRichText method
455
+ // As SafeInsert is used inside handleRichText which caused some bad UX like this:
456
+ // https://product-fabric.atlassian.net/browse/MEX-1520
457
+ return true;
458
+ }
446
459
  }
447
460
  if (handlePastePanelOrDecisionIntoListWithAnalytics(editorAnalyticsAPI)(view, event, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.findRootParentListNode)(state, dispatch)) {
448
461
  return true;
@@ -467,7 +480,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
467
480
  }
468
481
  slice = transformSingleLineCodeBlockToCodeMark(slice, schema);
469
482
  slice = transformSliceToCorrectMediaWrapper(slice, schema);
470
- slice = transformSliceToMediaSingleWithNewExperience(slice, schema);
483
+ slice = transformSliceToMediaSingleWithNewExperience(slice, schema, pluginInjectionApi);
471
484
  slice = transformSliceToDecisionList(slice, schema);
472
485
 
473
486
  // splitting linebreaks into paragraphs must happen before upgrading text to lists
@@ -6,7 +6,6 @@ import { mapSlice, removeNestedEmptyEls, unwrap, walkUpTreeUntil } from '@atlask
6
6
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { getRandomHex } from '@atlaskit/media-common';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
-
10
9
  /**
11
10
  * Ensure correct layout in nested mode
12
11
  *
@@ -75,7 +74,7 @@ export var transformSliceToCorrectMediaWrapper = function transformSliceToCorrec
75
74
  * Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
76
75
  *
77
76
  */
78
- export var transformSliceToMediaSingleWithNewExperience = function transformSliceToMediaSingleWithNewExperience(slice, schema) {
77
+ export var transformSliceToMediaSingleWithNewExperience = function transformSliceToMediaSingleWithNewExperience(slice, schema, api) {
79
78
  var _schema$nodes3 = schema.nodes,
80
79
  mediaInline = _schema$nodes3.mediaInline,
81
80
  mediaSingle = _schema$nodes3.mediaSingle,
@@ -99,12 +98,16 @@ export var transformSliceToMediaSingleWithNewExperience = function transformSlic
99
98
  return mapSlice(newSlice, function (node) {
100
99
  var __mediaTraceId = getRandomHex(8);
101
100
  if (node.type === media) {
101
+ var _api$media;
102
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media = api.media) === null || _api$media === void 0 ? void 0 : _api$media.commands.trackMediaPaste(node.attrs));
102
103
  return media.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
103
104
  __external: node.attrs.type === 'external',
104
105
  __mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
105
106
  }), node.content, node.marks);
106
107
  }
107
108
  if (node.type.name === 'mediaInline') {
109
+ var _api$media2;
110
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media2 = api.media) === null || _api$media2 === void 0 ? void 0 : _api$media2.commands.trackMediaPaste(node.attrs));
108
111
  return mediaInline.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
109
112
  __mediaTraceId: __mediaTraceId
110
113
  }), node.content, node.marks);
@@ -1,5 +1,7 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
2
  import type { Schema, Slice } from '@atlaskit/editor-prosemirror/model';
2
3
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
+ import type { PastePlugin } from '../pastePluginType';
3
5
  /**
4
6
  * Ensure correct layout in nested mode
5
7
  *
@@ -13,7 +15,7 @@ export declare const transformSliceToCorrectMediaWrapper: (slice: Slice, schema:
13
15
  * Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
14
16
  *
15
17
  */
16
- export declare const transformSliceToMediaSingleWithNewExperience: (slice: Slice, schema: Schema) => Slice;
18
+ export declare const transformSliceToMediaSingleWithNewExperience: (slice: Slice, schema: Schema, api: ExtractInjectionAPI<PastePlugin> | undefined) => Slice;
17
19
  /**
18
20
  * Given a html string, we attempt to hoist any nested `<img>` tags,
19
21
  * not directly wrapped by a `<div>` as ProseMirror no-op's
@@ -1,5 +1,7 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
2
  import type { Schema, Slice } from '@atlaskit/editor-prosemirror/model';
2
3
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
+ import type { PastePlugin } from '../pastePluginType';
3
5
  /**
4
6
  * Ensure correct layout in nested mode
5
7
  *
@@ -13,7 +15,7 @@ export declare const transformSliceToCorrectMediaWrapper: (slice: Slice, schema:
13
15
  * Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
14
16
  *
15
17
  */
16
- export declare const transformSliceToMediaSingleWithNewExperience: (slice: Slice, schema: Schema) => Slice;
18
+ export declare const transformSliceToMediaSingleWithNewExperience: (slice: Slice, schema: Schema, api: ExtractInjectionAPI<PastePlugin> | undefined) => Slice;
17
19
  /**
18
20
  * Given a html string, we attempt to hoist any nested `<img>` tags,
19
21
  * not directly wrapped by a `<div>` as ProseMirror no-op's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "2.0.16",
3
+ "version": "2.0.18",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,8 @@
31
31
  ".": "./src/index.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@atlaskit/editor-common": "^99.1.0",
34
+ "@atlaskit/adf-schema": "^46.1.0",
35
+ "@atlaskit/editor-common": "^99.3.0",
35
36
  "@atlaskit/editor-markdown-transformer": "^5.13.0",
36
37
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
37
38
  "@atlaskit/editor-plugin-annotation": "^1.26.0",
@@ -40,13 +41,13 @@
40
41
  "@atlaskit/editor-plugin-feature-flags": "^1.2.0",
41
42
  "@atlaskit/editor-plugin-list": "^3.9.0",
42
43
  "@atlaskit/editor-plugin-media": "^1.44.0",
43
- "@atlaskit/editor-plugin-mentions": "^2.11.0",
44
+ "@atlaskit/editor-plugin-mentions": "^2.13.0",
44
45
  "@atlaskit/editor-prosemirror": "6.2.1",
45
46
  "@atlaskit/editor-tables": "^2.8.0",
46
- "@atlaskit/media-client": "^29.0.0",
47
+ "@atlaskit/media-client": "^29.1.0",
47
48
  "@atlaskit/media-common": "^11.7.0",
48
49
  "@atlaskit/platform-feature-flags": "^0.3.0",
49
- "@atlaskit/tmp-editor-statsig": "^2.34.0",
50
+ "@atlaskit/tmp-editor-statsig": "^2.37.0",
50
51
  "@babel/runtime": "^7.0.0",
51
52
  "lodash": "^4.17.21",
52
53
  "uuid": "^3.1.0"
@@ -57,7 +58,6 @@
57
58
  },
58
59
  "devDependencies": {
59
60
  "@af/visual-regression": "*",
60
- "@atlaskit/adf-schema": "^46.1.0",
61
61
  "@atlaskit/editor-plugin-block-type": "^4.1.0",
62
62
  "@atlaskit/editor-plugin-history": "^1.3.0",
63
63
  "@atlaskit/editor-plugin-type-ahead": "^1.11.0",
@@ -121,6 +121,9 @@
121
121
  },
122
122
  "platform_editor_advanced_layouts_post_fix_patch_2": {
123
123
  "type": "boolean"
124
+ },
125
+ "platform_editor_fix_captions_on_copy": {
126
+ "type": "boolean"
124
127
  }
125
128
  }
126
129
  }