@atlaskit/editor-plugin-media 1.44.9 → 1.44.11

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,19 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 1.44.11
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 1.44.10
10
+
11
+ ### Patch Changes
12
+
13
+ - [#107786](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/107786)
14
+ [`cbb228ee58b88`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cbb228ee58b88) -
15
+ [ux] ED-26403 remove added paragraphs when adding media to document
16
+
3
17
  ## 1.44.9
4
18
 
5
19
  ### Patch Changes
@@ -54,6 +54,7 @@ function insertNodesWithOptionalParagraph(_ref) {
54
54
  fileExtension = analyticsAttributes.fileExtension,
55
55
  newType = analyticsAttributes.newType,
56
56
  previousType = analyticsAttributes.previousType;
57
+ var updatedTr = tr;
57
58
  var openEnd = 0;
58
59
  if (shouldAddParagraph(state) && !(0, _platformFeatureFlags.fg)('platform_editor_axe_leading_paragraph_from_media')) {
59
60
  nodes.push(paragraph.create());
@@ -65,27 +66,32 @@ function insertNodesWithOptionalParagraph(_ref) {
65
66
  var grandParentNodeType = grandParentNode === null || grandParentNode === void 0 ? void 0 : grandParentNode.type.name;
66
67
  if (grandParentNodeType === 'blockquote' && !isNestingInQuoteSupported) {
67
68
  var grandparentEndPos = state.selection.$from.start(-1) + grandParentNode.nodeSize - 1;
68
- (0, _utils2.safeInsert)(nodes[0], grandparentEndPos)(tr).scrollIntoView();
69
+ (0, _utils2.safeInsert)(nodes[0], grandparentEndPos)(updatedTr).scrollIntoView();
69
70
  } else if (state.selection.empty) {
70
71
  var insertFrom = (0, _selection.atTheBeginningOfBlock)(state) && (0, _platformFeatureFlags.fg)('platform_editor_axe_leading_paragraph_from_media') ? state.selection.$from.before() : state.selection.from;
71
- tr.insert(insertFrom, nodes);
72
+ if ((0, _platformFeatureFlags.fg)('platform_editor_axe_leading_paragraph_from_media')) {
73
+ var shouldInsertFrom = !(0, _mediaCommon.isInsidePotentialEmptyParagraph)(state);
74
+ updatedTr = (0, _selection.atTheBeginningOfBlock)(state) ? (0, _utils2.safeInsert)(nodes[0], shouldInsertFrom ? insertFrom : undefined, false)(updatedTr) : updatedTr.insert(insertFrom, nodes);
75
+ } else {
76
+ updatedTr.insert(insertFrom, nodes);
77
+ }
72
78
  var endPos = state.selection.from + nodes.reduce(function (totalSize, currNode) {
73
79
  return totalSize + currNode.nodeSize;
74
80
  }, 0);
75
81
  if (!(0, _platformFeatureFlags.fg)('platform_editor_axe_leading_paragraph_from_media')) {
76
- tr.setSelection(new _state.TextSelection(tr.doc.resolve(endPos), tr.doc.resolve(endPos)));
82
+ updatedTr.setSelection(new _state.TextSelection(updatedTr.doc.resolve(endPos), updatedTr.doc.resolve(endPos)));
77
83
  }
78
84
  } else {
79
- tr.replaceSelection(new _model.Slice(_model.Fragment.from(nodes), 0, openEnd));
85
+ updatedTr.replaceSelection(new _model.Slice(_model.Fragment.from(nodes), 0, openEnd));
80
86
  }
81
87
  if (inputMethod) {
82
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension, insertMediaVia))(tr);
88
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension, insertMediaVia))(updatedTr);
83
89
  }
84
90
  if (newType && previousType) {
85
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent((0, _analytics2.getChangeMediaAnalytics)(previousType, newType, (0, _analytics2.findChangeFromLocation)(state.selection)))(tr);
91
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent((0, _analytics2.getChangeMediaAnalytics)(previousType, newType, (0, _analytics2.findChangeFromLocation)(state.selection)))(updatedTr);
86
92
  }
87
93
  if (dispatch) {
88
- dispatch(tr);
94
+ dispatch(updatedTr);
89
95
  }
90
96
  return true;
91
97
  };
@@ -9,7 +9,7 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
9
9
  import { safeInsert as pmSafeInsert, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
- import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
12
+ import { copyOptionalAttrsFromMediaState, isInsidePotentialEmptyParagraph } from '../utils/media-common';
13
13
  import { findChangeFromLocation, getChangeMediaAnalytics } from './analytics';
14
14
  import { isImage } from './is-type';
15
15
  const getInsertMediaAnalytics = (inputMethod, fileExtension, insertMediaVia) => ({
@@ -48,6 +48,7 @@ function insertNodesWithOptionalParagraph({
48
48
  newType,
49
49
  previousType
50
50
  } = analyticsAttributes;
51
+ let updatedTr = tr;
51
52
  let openEnd = 0;
52
53
  if (shouldAddParagraph(state) && !fg('platform_editor_axe_leading_paragraph_from_media')) {
53
54
  nodes.push(paragraph.create());
@@ -59,25 +60,30 @@ function insertNodesWithOptionalParagraph({
59
60
  const grandParentNodeType = grandParentNode === null || grandParentNode === void 0 ? void 0 : grandParentNode.type.name;
60
61
  if (grandParentNodeType === 'blockquote' && !isNestingInQuoteSupported) {
61
62
  const grandparentEndPos = state.selection.$from.start(-1) + grandParentNode.nodeSize - 1;
62
- pmSafeInsert(nodes[0], grandparentEndPos)(tr).scrollIntoView();
63
+ pmSafeInsert(nodes[0], grandparentEndPos)(updatedTr).scrollIntoView();
63
64
  } else if (state.selection.empty) {
64
65
  const insertFrom = atTheBeginningOfBlock(state) && fg('platform_editor_axe_leading_paragraph_from_media') ? state.selection.$from.before() : state.selection.from;
65
- tr.insert(insertFrom, nodes);
66
+ if (fg('platform_editor_axe_leading_paragraph_from_media')) {
67
+ const shouldInsertFrom = !isInsidePotentialEmptyParagraph(state);
68
+ updatedTr = atTheBeginningOfBlock(state) ? pmSafeInsert(nodes[0], shouldInsertFrom ? insertFrom : undefined, false)(updatedTr) : updatedTr.insert(insertFrom, nodes);
69
+ } else {
70
+ updatedTr.insert(insertFrom, nodes);
71
+ }
66
72
  const endPos = state.selection.from + nodes.reduce((totalSize, currNode) => totalSize + currNode.nodeSize, 0);
67
73
  if (!fg('platform_editor_axe_leading_paragraph_from_media')) {
68
- tr.setSelection(new TextSelection(tr.doc.resolve(endPos), tr.doc.resolve(endPos)));
74
+ updatedTr.setSelection(new TextSelection(updatedTr.doc.resolve(endPos), updatedTr.doc.resolve(endPos)));
69
75
  }
70
76
  } else {
71
- tr.replaceSelection(new Slice(Fragment.from(nodes), 0, openEnd));
77
+ updatedTr.replaceSelection(new Slice(Fragment.from(nodes), 0, openEnd));
72
78
  }
73
79
  if (inputMethod) {
74
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension, insertMediaVia))(tr);
80
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension, insertMediaVia))(updatedTr);
75
81
  }
76
82
  if (newType && previousType) {
77
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getChangeMediaAnalytics(previousType, newType, findChangeFromLocation(state.selection)))(tr);
83
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getChangeMediaAnalytics(previousType, newType, findChangeFromLocation(state.selection)))(updatedTr);
78
84
  }
79
85
  if (dispatch) {
80
- dispatch(tr);
86
+ dispatch(updatedTr);
81
87
  }
82
88
  return true;
83
89
  };
@@ -12,7 +12,7 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
12
12
  import { safeInsert as pmSafeInsert, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
13
13
  import { fg } from '@atlaskit/platform-feature-flags';
14
14
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
- import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
15
+ import { copyOptionalAttrsFromMediaState, isInsidePotentialEmptyParagraph } from '../utils/media-common';
16
16
  import { findChangeFromLocation, getChangeMediaAnalytics } from './analytics';
17
17
  import { isImage } from './is-type';
18
18
  var getInsertMediaAnalytics = function getInsertMediaAnalytics(inputMethod, fileExtension, insertMediaVia) {
@@ -47,6 +47,7 @@ function insertNodesWithOptionalParagraph(_ref) {
47
47
  fileExtension = analyticsAttributes.fileExtension,
48
48
  newType = analyticsAttributes.newType,
49
49
  previousType = analyticsAttributes.previousType;
50
+ var updatedTr = tr;
50
51
  var openEnd = 0;
51
52
  if (shouldAddParagraph(state) && !fg('platform_editor_axe_leading_paragraph_from_media')) {
52
53
  nodes.push(paragraph.create());
@@ -58,27 +59,32 @@ function insertNodesWithOptionalParagraph(_ref) {
58
59
  var grandParentNodeType = grandParentNode === null || grandParentNode === void 0 ? void 0 : grandParentNode.type.name;
59
60
  if (grandParentNodeType === 'blockquote' && !isNestingInQuoteSupported) {
60
61
  var grandparentEndPos = state.selection.$from.start(-1) + grandParentNode.nodeSize - 1;
61
- pmSafeInsert(nodes[0], grandparentEndPos)(tr).scrollIntoView();
62
+ pmSafeInsert(nodes[0], grandparentEndPos)(updatedTr).scrollIntoView();
62
63
  } else if (state.selection.empty) {
63
64
  var insertFrom = atTheBeginningOfBlock(state) && fg('platform_editor_axe_leading_paragraph_from_media') ? state.selection.$from.before() : state.selection.from;
64
- tr.insert(insertFrom, nodes);
65
+ if (fg('platform_editor_axe_leading_paragraph_from_media')) {
66
+ var shouldInsertFrom = !isInsidePotentialEmptyParagraph(state);
67
+ updatedTr = atTheBeginningOfBlock(state) ? pmSafeInsert(nodes[0], shouldInsertFrom ? insertFrom : undefined, false)(updatedTr) : updatedTr.insert(insertFrom, nodes);
68
+ } else {
69
+ updatedTr.insert(insertFrom, nodes);
70
+ }
65
71
  var endPos = state.selection.from + nodes.reduce(function (totalSize, currNode) {
66
72
  return totalSize + currNode.nodeSize;
67
73
  }, 0);
68
74
  if (!fg('platform_editor_axe_leading_paragraph_from_media')) {
69
- tr.setSelection(new TextSelection(tr.doc.resolve(endPos), tr.doc.resolve(endPos)));
75
+ updatedTr.setSelection(new TextSelection(updatedTr.doc.resolve(endPos), updatedTr.doc.resolve(endPos)));
70
76
  }
71
77
  } else {
72
- tr.replaceSelection(new Slice(Fragment.from(nodes), 0, openEnd));
78
+ updatedTr.replaceSelection(new Slice(Fragment.from(nodes), 0, openEnd));
73
79
  }
74
80
  if (inputMethod) {
75
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension, insertMediaVia))(tr);
81
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension, insertMediaVia))(updatedTr);
76
82
  }
77
83
  if (newType && previousType) {
78
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getChangeMediaAnalytics(previousType, newType, findChangeFromLocation(state.selection)))(tr);
84
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getChangeMediaAnalytics(previousType, newType, findChangeFromLocation(state.selection)))(updatedTr);
79
85
  }
80
86
  if (dispatch) {
81
- dispatch(tr);
87
+ dispatch(updatedTr);
82
88
  }
83
89
  return true;
84
90
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "1.44.9",
3
+ "version": "1.44.11",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,43 +33,43 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@atlaskit/adf-schema": "^46.1.0",
36
- "@atlaskit/analytics-namespaced-context": "^6.12.0",
37
- "@atlaskit/analytics-next": "^10.2.0",
38
- "@atlaskit/button": "^20.3.0",
39
- "@atlaskit/editor-common": "^99.5.0",
40
- "@atlaskit/editor-palette": "1.6.4",
36
+ "@atlaskit/analytics-namespaced-context": "^6.13.0",
37
+ "@atlaskit/analytics-next": "^10.3.0",
38
+ "@atlaskit/button": "^20.4.0",
39
+ "@atlaskit/editor-common": "^99.6.0",
40
+ "@atlaskit/editor-palette": "1.7.0",
41
41
  "@atlaskit/editor-plugin-analytics": "^1.11.0",
42
- "@atlaskit/editor-plugin-annotation": "1.26.15",
42
+ "@atlaskit/editor-plugin-annotation": "1.27.0",
43
43
  "@atlaskit/editor-plugin-connectivity": "^1.1.0",
44
- "@atlaskit/editor-plugin-decorations": "^1.3.0",
45
- "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
44
+ "@atlaskit/editor-plugin-decorations": "^1.4.0",
45
+ "@atlaskit/editor-plugin-editor-disabled": "^1.4.0",
46
46
  "@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
47
- "@atlaskit/editor-plugin-floating-toolbar": "^1.15.0",
47
+ "@atlaskit/editor-plugin-floating-toolbar": "^1.16.0",
48
48
  "@atlaskit/editor-plugin-focus": "^1.4.0",
49
- "@atlaskit/editor-plugin-grid": "^1.2.0",
50
- "@atlaskit/editor-plugin-guideline": "^1.2.0",
49
+ "@atlaskit/editor-plugin-grid": "^1.3.0",
50
+ "@atlaskit/editor-plugin-guideline": "^1.3.0",
51
51
  "@atlaskit/editor-plugin-selection": "^1.6.0",
52
52
  "@atlaskit/editor-plugin-width": "^2.0.0",
53
53
  "@atlaskit/editor-prosemirror": "6.2.1",
54
54
  "@atlaskit/editor-shared-styles": "^3.2.0",
55
55
  "@atlaskit/editor-tables": "^2.8.0",
56
- "@atlaskit/form": "^11.0.0",
57
- "@atlaskit/icon": "^23.4.0",
58
- "@atlaskit/media-card": "^78.18.0",
59
- "@atlaskit/media-client": "^31.0.0",
60
- "@atlaskit/media-client-react": "^2.6.0",
61
- "@atlaskit/media-common": "^11.7.0",
62
- "@atlaskit/media-filmstrip": "^48.1.0",
63
- "@atlaskit/media-picker": "^67.0.0",
64
- "@atlaskit/media-ui": "^27.3.0",
65
- "@atlaskit/media-viewer": "^50.0.0",
56
+ "@atlaskit/form": "^11.1.0",
57
+ "@atlaskit/icon": "^23.5.0",
58
+ "@atlaskit/media-card": "^78.19.0",
59
+ "@atlaskit/media-client": "^31.1.0",
60
+ "@atlaskit/media-client-react": "^2.7.0",
61
+ "@atlaskit/media-common": "^11.8.0",
62
+ "@atlaskit/media-filmstrip": "^48.2.0",
63
+ "@atlaskit/media-picker": "^67.1.0",
64
+ "@atlaskit/media-ui": "^27.4.0",
65
+ "@atlaskit/media-viewer": "^50.1.0",
66
66
  "@atlaskit/platform-feature-flags": "^0.3.0",
67
- "@atlaskit/primitives": "^13.3.0",
68
- "@atlaskit/textfield": "^6.7.0",
69
- "@atlaskit/theme": "^14.0.0",
67
+ "@atlaskit/primitives": "^13.4.0",
68
+ "@atlaskit/textfield": "^6.8.0",
69
+ "@atlaskit/theme": "^14.1.0",
70
70
  "@atlaskit/tmp-editor-statsig": "^2.41.0",
71
- "@atlaskit/tokens": "^3.2.0",
72
- "@atlaskit/tooltip": "^19.0.0",
71
+ "@atlaskit/tokens": "^3.3.0",
72
+ "@atlaskit/tooltip": "^19.1.0",
73
73
  "@babel/runtime": "^7.0.0",
74
74
  "@emotion/react": "^11.7.1",
75
75
  "bind-event-listener": "^3.0.0",