@atlaskit/editor-plugin-media 8.4.15 → 8.4.17
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 +18 -0
- package/dist/cjs/nodeviews/mediaNodeView/index.js +58 -5
- package/dist/cjs/pm-plugins/main.js +19 -3
- package/dist/es2019/nodeviews/mediaNodeView/index.js +57 -7
- package/dist/es2019/pm-plugins/main.js +18 -1
- package/dist/esm/nodeviews/mediaNodeView/index.js +58 -5
- package/dist/esm/pm-plugins/main.js +19 -3
- package/dist/types/nodeviews/mediaNodeView/index.d.ts +7 -1
- package/dist/types-ts4.5/nodeviews/mediaNodeView/index.d.ts +7 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 8.4.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`1083b6f1f8eb2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1083b6f1f8eb2) -
|
|
8
|
+
[ux] Fix issues where media is selected when a parent node is selected
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 8.4.16
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`1344d6deac8a3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1344d6deac8a3) -
|
|
16
|
+
provide better max dimensions to media to fix blurry image on load
|
|
17
|
+
- [`e3779b75fdeca`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e3779b75fdeca) -
|
|
18
|
+
EDITOR-1643 Promote syncBlock and bodiedSyncBlock to full schema
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 8.4.15
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -19,7 +19,9 @@ var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
|
19
19
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
20
20
|
var _selectionBasedNodeView = require("@atlaskit/editor-common/selection-based-node-view");
|
|
21
21
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
22
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
22
23
|
var _mediaClient = require("@atlaskit/media-client");
|
|
24
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
23
25
|
var _helpers = require("../../pm-plugins/commands/helpers");
|
|
24
26
|
var _mediaCommon = require("../../pm-plugins/utils/media-common");
|
|
25
27
|
var _media = _interopRequireDefault(require("./media"));
|
|
@@ -75,6 +77,22 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
75
77
|
}, true)(_this.view.state, _this.view.dispatch);
|
|
76
78
|
}
|
|
77
79
|
});
|
|
80
|
+
(0, _defineProperty2.default)(_this, "getMaxCardDimensions", function (editorWidth) {
|
|
81
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_media_vc_fixes', 'isEnabled', true)) {
|
|
82
|
+
var mediaSingleNodeParent = _this.getMediaSingleNode(_this.getPos);
|
|
83
|
+
if (mediaSingleNodeParent) {
|
|
84
|
+
var maxWidth = _this.getMaxWidthFromMediaSingleNode(mediaSingleNodeParent, editorWidth === null || editorWidth === void 0 ? void 0 : editorWidth.width);
|
|
85
|
+
return {
|
|
86
|
+
width: "".concat(maxWidth, "px"),
|
|
87
|
+
height: '100%'
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
width: '100%',
|
|
93
|
+
height: '100%'
|
|
94
|
+
};
|
|
95
|
+
});
|
|
78
96
|
(0, _defineProperty2.default)(_this, "renderMediaNodeWithState", function (contextIdentifierProvider) {
|
|
79
97
|
return function (_ref2) {
|
|
80
98
|
var _this$reactComponentP;
|
|
@@ -98,18 +116,15 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
98
116
|
}
|
|
99
117
|
width = width || _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
100
118
|
height = height || _mediaSingle.DEFAULT_IMAGE_HEIGHT;
|
|
119
|
+
var pluginInjectionApi = _this.reactComponentProps.pluginInjectionApi;
|
|
101
120
|
|
|
102
121
|
// mediaSingle defines the max dimensions, so we don't need to constrain twice.
|
|
103
|
-
var maxDimensions =
|
|
104
|
-
width: "100%",
|
|
105
|
-
height: "100%"
|
|
106
|
-
};
|
|
122
|
+
var maxDimensions = _this.getMaxCardDimensions(editorWidth);
|
|
107
123
|
var originalDimensions = {
|
|
108
124
|
width: width,
|
|
109
125
|
height: height
|
|
110
126
|
};
|
|
111
127
|
var isSelectedAndInteracted = _this.nodeInsideSelection() && interactionState !== 'hasNotHadInteraction';
|
|
112
|
-
var pluginInjectionApi = _this.reactComponentProps.pluginInjectionApi;
|
|
113
128
|
return /*#__PURE__*/_react.default.createElement(_media.default, {
|
|
114
129
|
api: pluginInjectionApi,
|
|
115
130
|
view: _this.view,
|
|
@@ -140,6 +155,44 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
140
155
|
}
|
|
141
156
|
(0, _inherits2.default)(MediaNodeView, _SelectionBasedNodeVi);
|
|
142
157
|
return (0, _createClass2.default)(MediaNodeView, [{
|
|
158
|
+
key: "getMediaSingleNode",
|
|
159
|
+
value: function getMediaSingleNode(getPos) {
|
|
160
|
+
var pos = getPos();
|
|
161
|
+
if (typeof pos !== 'number') {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
var $pos = this.view.state.doc.resolve(pos);
|
|
165
|
+
|
|
166
|
+
// The parent of the media node should be mediaSingle
|
|
167
|
+
if ($pos.parent && $pos.parent.type.name === 'mediaSingle') {
|
|
168
|
+
return $pos.parent;
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}, {
|
|
173
|
+
key: "getMaxWidthFromMediaSingleNode",
|
|
174
|
+
value: function getMaxWidthFromMediaSingleNode(mediaSingleNode, containerWidth) {
|
|
175
|
+
var _mediaSingleNode$attr = mediaSingleNode.attrs,
|
|
176
|
+
widthAttr = _mediaSingleNode$attr.width,
|
|
177
|
+
widthTypeAttr = _mediaSingleNode$attr.widthType,
|
|
178
|
+
layoutAttr = _mediaSingleNode$attr.layout;
|
|
179
|
+
if (widthAttr && widthTypeAttr === 'pixel') {
|
|
180
|
+
return widthAttr;
|
|
181
|
+
}
|
|
182
|
+
// on SSR mode, containerWidth from widthPluginState can be 0
|
|
183
|
+
if (!containerWidth) {
|
|
184
|
+
switch (layoutAttr) {
|
|
185
|
+
case 'full-width':
|
|
186
|
+
return _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
187
|
+
case 'wide':
|
|
188
|
+
return _editorSharedStyles.akEditorCalculatedWideLayoutWidth;
|
|
189
|
+
default:
|
|
190
|
+
return _editorSharedStyles.akEditorDefaultLayoutWidth;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return containerWidth;
|
|
194
|
+
}
|
|
195
|
+
}, {
|
|
143
196
|
key: "createDomRef",
|
|
144
197
|
value: function createDomRef() {
|
|
145
198
|
var domRef = document.createElement('div');
|
|
@@ -936,7 +936,7 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
936
936
|
doc = state.doc;
|
|
937
937
|
|
|
938
938
|
// Find any media nodes in the current selection
|
|
939
|
-
if (state.selection instanceof _state2.TextSelection || state.selection instanceof _state2.AllSelection || state.selection instanceof _state2.NodeSelection || state.selection instanceof _cellSelection.CellSelection) {
|
|
939
|
+
if (state.selection instanceof _state2.TextSelection || state.selection instanceof _state2.AllSelection || !(0, _expValEquals.expValEquals)('platform_editor_nested_media_selection_fix', 'isEnabled', true) && state.selection instanceof _state2.NodeSelection || state.selection instanceof _cellSelection.CellSelection) {
|
|
940
940
|
doc.nodesBetween(state.selection.from, state.selection.to, function (node, pos) {
|
|
941
941
|
if (node.type === schema.nodes.media) {
|
|
942
942
|
mediaNodes.push(_view2.Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
@@ -947,6 +947,22 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
947
947
|
}
|
|
948
948
|
return true;
|
|
949
949
|
});
|
|
950
|
+
} else if ((0, _expValEquals.expValEquals)('platform_editor_nested_media_selection_fix', 'isEnabled', true) && state.selection instanceof _state2.NodeSelection) {
|
|
951
|
+
var _state$selection = state.selection,
|
|
952
|
+
node = _state$selection.node,
|
|
953
|
+
$from = _state$selection.$from;
|
|
954
|
+
if (node.type === schema.nodes.mediaSingle || node.type === schema.nodes.mediaGroup) {
|
|
955
|
+
doc.nodesBetween($from.pos, $from.pos + node.nodeSize, function (mediaNode, mediaPos) {
|
|
956
|
+
if (mediaNode.type === schema.nodes.media) {
|
|
957
|
+
mediaNodes.push(_view2.Decoration.node(mediaPos, mediaPos + mediaNode.nodeSize, {}, {
|
|
958
|
+
type: 'media',
|
|
959
|
+
selected: true
|
|
960
|
+
}));
|
|
961
|
+
return false;
|
|
962
|
+
}
|
|
963
|
+
return true;
|
|
964
|
+
});
|
|
965
|
+
}
|
|
950
966
|
}
|
|
951
967
|
var pluginState = getMediaPluginState(state);
|
|
952
968
|
if (!pluginState.showDropzone) {
|
|
@@ -955,8 +971,8 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
955
971
|
|
|
956
972
|
// When a media is already selected
|
|
957
973
|
if (state.selection instanceof _state2.NodeSelection) {
|
|
958
|
-
var
|
|
959
|
-
if (
|
|
974
|
+
var _node = state.selection.node;
|
|
975
|
+
if (_node.type === schema.nodes.mediaSingle) {
|
|
960
976
|
var deco = _view2.Decoration.node(state.selection.from, state.selection.to, {
|
|
961
977
|
class: 'richMedia-selected'
|
|
962
978
|
});
|
|
@@ -5,7 +5,9 @@ import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-comm
|
|
|
5
5
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
6
6
|
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
7
7
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
8
|
+
import { akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
8
9
|
import { getAttrsFromUrl } from '@atlaskit/media-client';
|
|
10
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
11
|
import { updateCurrentMediaNodeAttrs } from '../../pm-plugins/commands/helpers';
|
|
10
12
|
import { isMediaBlobUrlFromAttrs } from '../../pm-plugins/utils/media-common';
|
|
11
13
|
// Ignored via go/ees005
|
|
@@ -55,6 +57,22 @@ class MediaNodeView extends SelectionBasedNodeView {
|
|
|
55
57
|
}, true)(this.view.state, this.view.dispatch);
|
|
56
58
|
}
|
|
57
59
|
});
|
|
60
|
+
_defineProperty(this, "getMaxCardDimensions", editorWidth => {
|
|
61
|
+
if (expValEquals('platform_editor_media_vc_fixes', 'isEnabled', true)) {
|
|
62
|
+
const mediaSingleNodeParent = this.getMediaSingleNode(this.getPos);
|
|
63
|
+
if (mediaSingleNodeParent) {
|
|
64
|
+
const maxWidth = this.getMaxWidthFromMediaSingleNode(mediaSingleNodeParent, editorWidth === null || editorWidth === void 0 ? void 0 : editorWidth.width);
|
|
65
|
+
return {
|
|
66
|
+
width: `${maxWidth}px`,
|
|
67
|
+
height: '100%'
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
width: '100%',
|
|
73
|
+
height: '100%'
|
|
74
|
+
};
|
|
75
|
+
});
|
|
58
76
|
_defineProperty(this, "renderMediaNodeWithState", contextIdentifierProvider => {
|
|
59
77
|
return ({
|
|
60
78
|
width: editorWidth,
|
|
@@ -85,20 +103,17 @@ class MediaNodeView extends SelectionBasedNodeView {
|
|
|
85
103
|
}
|
|
86
104
|
width = width || DEFAULT_IMAGE_WIDTH;
|
|
87
105
|
height = height || DEFAULT_IMAGE_HEIGHT;
|
|
106
|
+
const {
|
|
107
|
+
pluginInjectionApi
|
|
108
|
+
} = this.reactComponentProps;
|
|
88
109
|
|
|
89
110
|
// mediaSingle defines the max dimensions, so we don't need to constrain twice.
|
|
90
|
-
const maxDimensions =
|
|
91
|
-
width: `100%`,
|
|
92
|
-
height: `100%`
|
|
93
|
-
};
|
|
111
|
+
const maxDimensions = this.getMaxCardDimensions(editorWidth);
|
|
94
112
|
const originalDimensions = {
|
|
95
113
|
width,
|
|
96
114
|
height
|
|
97
115
|
};
|
|
98
116
|
const isSelectedAndInteracted = this.nodeInsideSelection() && interactionState !== 'hasNotHadInteraction';
|
|
99
|
-
const {
|
|
100
|
-
pluginInjectionApi
|
|
101
|
-
} = this.reactComponentProps;
|
|
102
117
|
return /*#__PURE__*/React.createElement(MediaNode, {
|
|
103
118
|
api: pluginInjectionApi,
|
|
104
119
|
view: this.view,
|
|
@@ -129,6 +144,41 @@ class MediaNodeView extends SelectionBasedNodeView {
|
|
|
129
144
|
});
|
|
130
145
|
});
|
|
131
146
|
}
|
|
147
|
+
getMediaSingleNode(getPos) {
|
|
148
|
+
const pos = getPos();
|
|
149
|
+
if (typeof pos !== 'number') {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const $pos = this.view.state.doc.resolve(pos);
|
|
153
|
+
|
|
154
|
+
// The parent of the media node should be mediaSingle
|
|
155
|
+
if ($pos.parent && $pos.parent.type.name === 'mediaSingle') {
|
|
156
|
+
return $pos.parent;
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
getMaxWidthFromMediaSingleNode(mediaSingleNode, containerWidth) {
|
|
161
|
+
const {
|
|
162
|
+
width: widthAttr,
|
|
163
|
+
widthType: widthTypeAttr,
|
|
164
|
+
layout: layoutAttr
|
|
165
|
+
} = mediaSingleNode.attrs;
|
|
166
|
+
if (widthAttr && widthTypeAttr === 'pixel') {
|
|
167
|
+
return widthAttr;
|
|
168
|
+
}
|
|
169
|
+
// on SSR mode, containerWidth from widthPluginState can be 0
|
|
170
|
+
if (!containerWidth) {
|
|
171
|
+
switch (layoutAttr) {
|
|
172
|
+
case 'full-width':
|
|
173
|
+
return akEditorFullWidthLayoutWidth;
|
|
174
|
+
case 'wide':
|
|
175
|
+
return akEditorCalculatedWideLayoutWidth;
|
|
176
|
+
default:
|
|
177
|
+
return akEditorDefaultLayoutWidth;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return containerWidth;
|
|
181
|
+
}
|
|
132
182
|
createDomRef() {
|
|
133
183
|
const domRef = document.createElement('div');
|
|
134
184
|
if (this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
|
|
@@ -824,7 +824,7 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
824
824
|
} = state;
|
|
825
825
|
|
|
826
826
|
// Find any media nodes in the current selection
|
|
827
|
-
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection || state.selection instanceof NodeSelection || state.selection instanceof CellSelection) {
|
|
827
|
+
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection || !expValEquals('platform_editor_nested_media_selection_fix', 'isEnabled', true) && state.selection instanceof NodeSelection || state.selection instanceof CellSelection) {
|
|
828
828
|
doc.nodesBetween(state.selection.from, state.selection.to, (node, pos) => {
|
|
829
829
|
if (node.type === schema.nodes.media) {
|
|
830
830
|
mediaNodes.push(Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
@@ -835,6 +835,23 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
835
835
|
}
|
|
836
836
|
return true;
|
|
837
837
|
});
|
|
838
|
+
} else if (expValEquals('platform_editor_nested_media_selection_fix', 'isEnabled', true) && state.selection instanceof NodeSelection) {
|
|
839
|
+
const {
|
|
840
|
+
node,
|
|
841
|
+
$from
|
|
842
|
+
} = state.selection;
|
|
843
|
+
if (node.type === schema.nodes.mediaSingle || node.type === schema.nodes.mediaGroup) {
|
|
844
|
+
doc.nodesBetween($from.pos, $from.pos + node.nodeSize, (mediaNode, mediaPos) => {
|
|
845
|
+
if (mediaNode.type === schema.nodes.media) {
|
|
846
|
+
mediaNodes.push(Decoration.node(mediaPos, mediaPos + mediaNode.nodeSize, {}, {
|
|
847
|
+
type: 'media',
|
|
848
|
+
selected: true
|
|
849
|
+
}));
|
|
850
|
+
return false;
|
|
851
|
+
}
|
|
852
|
+
return true;
|
|
853
|
+
});
|
|
854
|
+
}
|
|
838
855
|
}
|
|
839
856
|
const pluginState = getMediaPluginState(state);
|
|
840
857
|
if (!pluginState.showDropzone) {
|
|
@@ -18,7 +18,9 @@ import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-comm
|
|
|
18
18
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
19
19
|
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
20
20
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
21
|
+
import { akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
21
22
|
import { getAttrsFromUrl } from '@atlaskit/media-client';
|
|
23
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
22
24
|
import { updateCurrentMediaNodeAttrs } from '../../pm-plugins/commands/helpers';
|
|
23
25
|
import { isMediaBlobUrlFromAttrs } from '../../pm-plugins/utils/media-common';
|
|
24
26
|
// Ignored via go/ees005
|
|
@@ -69,6 +71,22 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
69
71
|
}, true)(_this.view.state, _this.view.dispatch);
|
|
70
72
|
}
|
|
71
73
|
});
|
|
74
|
+
_defineProperty(_this, "getMaxCardDimensions", function (editorWidth) {
|
|
75
|
+
if (expValEquals('platform_editor_media_vc_fixes', 'isEnabled', true)) {
|
|
76
|
+
var mediaSingleNodeParent = _this.getMediaSingleNode(_this.getPos);
|
|
77
|
+
if (mediaSingleNodeParent) {
|
|
78
|
+
var maxWidth = _this.getMaxWidthFromMediaSingleNode(mediaSingleNodeParent, editorWidth === null || editorWidth === void 0 ? void 0 : editorWidth.width);
|
|
79
|
+
return {
|
|
80
|
+
width: "".concat(maxWidth, "px"),
|
|
81
|
+
height: '100%'
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
width: '100%',
|
|
87
|
+
height: '100%'
|
|
88
|
+
};
|
|
89
|
+
});
|
|
72
90
|
_defineProperty(_this, "renderMediaNodeWithState", function (contextIdentifierProvider) {
|
|
73
91
|
return function (_ref2) {
|
|
74
92
|
var _this$reactComponentP;
|
|
@@ -92,18 +110,15 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
92
110
|
}
|
|
93
111
|
width = width || DEFAULT_IMAGE_WIDTH;
|
|
94
112
|
height = height || DEFAULT_IMAGE_HEIGHT;
|
|
113
|
+
var pluginInjectionApi = _this.reactComponentProps.pluginInjectionApi;
|
|
95
114
|
|
|
96
115
|
// mediaSingle defines the max dimensions, so we don't need to constrain twice.
|
|
97
|
-
var maxDimensions =
|
|
98
|
-
width: "100%",
|
|
99
|
-
height: "100%"
|
|
100
|
-
};
|
|
116
|
+
var maxDimensions = _this.getMaxCardDimensions(editorWidth);
|
|
101
117
|
var originalDimensions = {
|
|
102
118
|
width: width,
|
|
103
119
|
height: height
|
|
104
120
|
};
|
|
105
121
|
var isSelectedAndInteracted = _this.nodeInsideSelection() && interactionState !== 'hasNotHadInteraction';
|
|
106
|
-
var pluginInjectionApi = _this.reactComponentProps.pluginInjectionApi;
|
|
107
122
|
return /*#__PURE__*/React.createElement(MediaNode, {
|
|
108
123
|
api: pluginInjectionApi,
|
|
109
124
|
view: _this.view,
|
|
@@ -134,6 +149,44 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
134
149
|
}
|
|
135
150
|
_inherits(MediaNodeView, _SelectionBasedNodeVi);
|
|
136
151
|
return _createClass(MediaNodeView, [{
|
|
152
|
+
key: "getMediaSingleNode",
|
|
153
|
+
value: function getMediaSingleNode(getPos) {
|
|
154
|
+
var pos = getPos();
|
|
155
|
+
if (typeof pos !== 'number') {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
var $pos = this.view.state.doc.resolve(pos);
|
|
159
|
+
|
|
160
|
+
// The parent of the media node should be mediaSingle
|
|
161
|
+
if ($pos.parent && $pos.parent.type.name === 'mediaSingle') {
|
|
162
|
+
return $pos.parent;
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}, {
|
|
167
|
+
key: "getMaxWidthFromMediaSingleNode",
|
|
168
|
+
value: function getMaxWidthFromMediaSingleNode(mediaSingleNode, containerWidth) {
|
|
169
|
+
var _mediaSingleNode$attr = mediaSingleNode.attrs,
|
|
170
|
+
widthAttr = _mediaSingleNode$attr.width,
|
|
171
|
+
widthTypeAttr = _mediaSingleNode$attr.widthType,
|
|
172
|
+
layoutAttr = _mediaSingleNode$attr.layout;
|
|
173
|
+
if (widthAttr && widthTypeAttr === 'pixel') {
|
|
174
|
+
return widthAttr;
|
|
175
|
+
}
|
|
176
|
+
// on SSR mode, containerWidth from widthPluginState can be 0
|
|
177
|
+
if (!containerWidth) {
|
|
178
|
+
switch (layoutAttr) {
|
|
179
|
+
case 'full-width':
|
|
180
|
+
return akEditorFullWidthLayoutWidth;
|
|
181
|
+
case 'wide':
|
|
182
|
+
return akEditorCalculatedWideLayoutWidth;
|
|
183
|
+
default:
|
|
184
|
+
return akEditorDefaultLayoutWidth;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return containerWidth;
|
|
188
|
+
}
|
|
189
|
+
}, {
|
|
137
190
|
key: "createDomRef",
|
|
138
191
|
value: function createDomRef() {
|
|
139
192
|
var domRef = document.createElement('div');
|
|
@@ -928,7 +928,7 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
928
928
|
doc = state.doc;
|
|
929
929
|
|
|
930
930
|
// Find any media nodes in the current selection
|
|
931
|
-
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection || state.selection instanceof NodeSelection || state.selection instanceof CellSelection) {
|
|
931
|
+
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection || !expValEquals('platform_editor_nested_media_selection_fix', 'isEnabled', true) && state.selection instanceof NodeSelection || state.selection instanceof CellSelection) {
|
|
932
932
|
doc.nodesBetween(state.selection.from, state.selection.to, function (node, pos) {
|
|
933
933
|
if (node.type === schema.nodes.media) {
|
|
934
934
|
mediaNodes.push(Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
@@ -939,6 +939,22 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
939
939
|
}
|
|
940
940
|
return true;
|
|
941
941
|
});
|
|
942
|
+
} else if (expValEquals('platform_editor_nested_media_selection_fix', 'isEnabled', true) && state.selection instanceof NodeSelection) {
|
|
943
|
+
var _state$selection = state.selection,
|
|
944
|
+
node = _state$selection.node,
|
|
945
|
+
$from = _state$selection.$from;
|
|
946
|
+
if (node.type === schema.nodes.mediaSingle || node.type === schema.nodes.mediaGroup) {
|
|
947
|
+
doc.nodesBetween($from.pos, $from.pos + node.nodeSize, function (mediaNode, mediaPos) {
|
|
948
|
+
if (mediaNode.type === schema.nodes.media) {
|
|
949
|
+
mediaNodes.push(Decoration.node(mediaPos, mediaPos + mediaNode.nodeSize, {}, {
|
|
950
|
+
type: 'media',
|
|
951
|
+
selected: true
|
|
952
|
+
}));
|
|
953
|
+
return false;
|
|
954
|
+
}
|
|
955
|
+
return true;
|
|
956
|
+
});
|
|
957
|
+
}
|
|
942
958
|
}
|
|
943
959
|
var pluginState = getMediaPluginState(state);
|
|
944
960
|
if (!pluginState.showDropzone) {
|
|
@@ -947,8 +963,8 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
947
963
|
|
|
948
964
|
// When a media is already selected
|
|
949
965
|
if (state.selection instanceof NodeSelection) {
|
|
950
|
-
var
|
|
951
|
-
if (
|
|
966
|
+
var _node = state.selection.node;
|
|
967
|
+
if (_node.type === schema.nodes.mediaSingle) {
|
|
952
968
|
var deco = Decoration.node(state.selection.from, state.selection.to, {
|
|
953
969
|
class: 'richMedia-selected'
|
|
954
970
|
});
|
|
@@ -9,7 +9,7 @@ import type { SharedInteractionState } from '@atlaskit/editor-plugin-interaction
|
|
|
9
9
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
10
10
|
import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
11
11
|
import type { MediaNextEditorPluginType } from '../../mediaPluginType';
|
|
12
|
-
import type { getPosHandler, MediaOptions } from '../../types';
|
|
12
|
+
import type { getPosHandler, getPosHandlerNode, MediaOptions } from '../../types';
|
|
13
13
|
import type { MediaNodeViewProps } from '../types';
|
|
14
14
|
interface MediaNodeWithPluginStateComponentProps {
|
|
15
15
|
interactionState?: SharedInteractionState['interactionState'];
|
|
@@ -18,6 +18,8 @@ interface MediaNodeWithPluginStateComponentProps {
|
|
|
18
18
|
}
|
|
19
19
|
declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
|
|
20
20
|
private isSelected;
|
|
21
|
+
getMediaSingleNode(getPos: getPosHandlerNode): PMNode | null;
|
|
22
|
+
getMaxWidthFromMediaSingleNode(mediaSingleNode: PMNode, containerWidth?: number): number;
|
|
21
23
|
createDomRef(): HTMLElement;
|
|
22
24
|
viewShouldUpdate(nextNode: PMNode, decorations: Decoration[]): boolean;
|
|
23
25
|
stopEvent(event: Event): boolean;
|
|
@@ -27,6 +29,10 @@ declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
|
|
|
27
29
|
height: number;
|
|
28
30
|
width: number;
|
|
29
31
|
}) => void;
|
|
32
|
+
getMaxCardDimensions: (editorWidth?: WidthPluginState) => {
|
|
33
|
+
width: string;
|
|
34
|
+
height: string;
|
|
35
|
+
};
|
|
30
36
|
renderMediaNodeWithState: (contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ width: editorWidth, mediaProvider, interactionState, }: MediaNodeWithPluginStateComponentProps) => React.JSX.Element;
|
|
31
37
|
renderMediaNodeWithProviders: ({ contextIdentifierProvider }: Providers) => React.JSX.Element;
|
|
32
38
|
render(): React.JSX.Element;
|
|
@@ -9,7 +9,7 @@ import type { SharedInteractionState } from '@atlaskit/editor-plugin-interaction
|
|
|
9
9
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
10
10
|
import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
11
11
|
import type { MediaNextEditorPluginType } from '../../mediaPluginType';
|
|
12
|
-
import type { getPosHandler, MediaOptions } from '../../types';
|
|
12
|
+
import type { getPosHandler, getPosHandlerNode, MediaOptions } from '../../types';
|
|
13
13
|
import type { MediaNodeViewProps } from '../types';
|
|
14
14
|
interface MediaNodeWithPluginStateComponentProps {
|
|
15
15
|
interactionState?: SharedInteractionState['interactionState'];
|
|
@@ -18,6 +18,8 @@ interface MediaNodeWithPluginStateComponentProps {
|
|
|
18
18
|
}
|
|
19
19
|
declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
|
|
20
20
|
private isSelected;
|
|
21
|
+
getMediaSingleNode(getPos: getPosHandlerNode): PMNode | null;
|
|
22
|
+
getMaxWidthFromMediaSingleNode(mediaSingleNode: PMNode, containerWidth?: number): number;
|
|
21
23
|
createDomRef(): HTMLElement;
|
|
22
24
|
viewShouldUpdate(nextNode: PMNode, decorations: Decoration[]): boolean;
|
|
23
25
|
stopEvent(event: Event): boolean;
|
|
@@ -27,6 +29,10 @@ declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
|
|
|
27
29
|
height: number;
|
|
28
30
|
width: number;
|
|
29
31
|
}) => void;
|
|
32
|
+
getMaxCardDimensions: (editorWidth?: WidthPluginState) => {
|
|
33
|
+
width: string;
|
|
34
|
+
height: string;
|
|
35
|
+
};
|
|
30
36
|
renderMediaNodeWithState: (contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ width: editorWidth, mediaProvider, interactionState, }: MediaNodeWithPluginStateComponentProps) => React.JSX.Element;
|
|
31
37
|
renderMediaNodeWithProviders: ({ contextIdentifierProvider }: Providers) => React.JSX.Element;
|
|
32
38
|
render(): React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.17",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"atlaskit:src": "src/index.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@atlaskit/adf-schema": "^51.
|
|
32
|
+
"@atlaskit/adf-schema": "^51.5.1",
|
|
33
33
|
"@atlaskit/analytics-namespaced-context": "^7.2.0",
|
|
34
34
|
"@atlaskit/analytics-next": "^11.1.0",
|
|
35
35
|
"@atlaskit/button": "^23.6.0",
|
|
@@ -61,12 +61,12 @@
|
|
|
61
61
|
"@atlaskit/media-filmstrip": "^51.1.0",
|
|
62
62
|
"@atlaskit/media-picker": "^70.1.0",
|
|
63
63
|
"@atlaskit/media-ui": "^28.7.0",
|
|
64
|
-
"@atlaskit/media-viewer": "^52.
|
|
64
|
+
"@atlaskit/media-viewer": "^52.5.0",
|
|
65
65
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
66
66
|
"@atlaskit/primitives": "^16.4.0",
|
|
67
67
|
"@atlaskit/textfield": "^8.1.0",
|
|
68
68
|
"@atlaskit/theme": "^21.0.0",
|
|
69
|
-
"@atlaskit/tmp-editor-statsig": "^14.
|
|
69
|
+
"@atlaskit/tmp-editor-statsig": "^14.6.0",
|
|
70
70
|
"@atlaskit/tokens": "^8.4.0",
|
|
71
71
|
"@atlaskit/tooltip": "^20.10.0",
|
|
72
72
|
"@babel/runtime": "^7.0.0",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"uuid": "^3.1.0"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"@atlaskit/editor-common": "^110.
|
|
81
|
+
"@atlaskit/editor-common": "^110.38.0",
|
|
82
82
|
"@atlaskit/media-core": "^37.0.0",
|
|
83
83
|
"react": "^18.2.0",
|
|
84
84
|
"react-dom": "^18.2.0",
|