@atlaskit/editor-plugin-media 1.44.9 → 1.44.10
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,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 1.44.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#107786](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/107786)
|
|
8
|
+
[`cbb228ee58b88`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cbb228ee58b88) -
|
|
9
|
+
[ux] ED-26403 remove added paragraphs when adding media to document
|
|
10
|
+
|
|
3
11
|
## 1.44.9
|
|
4
12
|
|
|
5
13
|
### 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)(
|
|
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
|
-
|
|
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
|
-
|
|
82
|
+
updatedTr.setSelection(new _state.TextSelection(updatedTr.doc.resolve(endPos), updatedTr.doc.resolve(endPos)));
|
|
77
83
|
}
|
|
78
84
|
} else {
|
|
79
|
-
|
|
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))(
|
|
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)))(
|
|
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(
|
|
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)(
|
|
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
|
-
|
|
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
|
-
|
|
74
|
+
updatedTr.setSelection(new TextSelection(updatedTr.doc.resolve(endPos), updatedTr.doc.resolve(endPos)));
|
|
69
75
|
}
|
|
70
76
|
} else {
|
|
71
|
-
|
|
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))(
|
|
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)))(
|
|
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(
|
|
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)(
|
|
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
|
-
|
|
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
|
-
|
|
75
|
+
updatedTr.setSelection(new TextSelection(updatedTr.doc.resolve(endPos), updatedTr.doc.resolve(endPos)));
|
|
70
76
|
}
|
|
71
77
|
} else {
|
|
72
|
-
|
|
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))(
|
|
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)))(
|
|
84
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getChangeMediaAnalytics(previousType, newType, findChangeFromLocation(state.selection)))(updatedTr);
|
|
79
85
|
}
|
|
80
86
|
if (dispatch) {
|
|
81
|
-
dispatch(
|
|
87
|
+
dispatch(updatedTr);
|
|
82
88
|
}
|
|
83
89
|
return true;
|
|
84
90
|
};
|