@atlaskit/editor-plugin-media 1.15.1 → 1.15.2
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 +8 -0
- package/dist/cjs/nodeviews/mediaSingle.js +6 -3
- package/dist/cjs/plugin.js +1 -0
- package/dist/cjs/toolbar/comments.js +2 -1
- package/dist/cjs/toolbar/index.js +2 -1
- package/dist/cjs/ui/CommentBadge/index.js +6 -4
- package/dist/es2019/nodeviews/mediaSingle.js +6 -3
- package/dist/es2019/plugin.js +1 -0
- package/dist/es2019/toolbar/comments.js +2 -1
- package/dist/es2019/toolbar/index.js +2 -1
- package/dist/es2019/ui/CommentBadge/index.js +5 -3
- package/dist/esm/nodeviews/mediaSingle.js +6 -3
- package/dist/esm/plugin.js +1 -0
- package/dist/esm/toolbar/comments.js +2 -1
- package/dist/esm/toolbar/index.js +2 -1
- package/dist/esm/ui/CommentBadge/index.js +6 -4
- package/dist/types/types.d.ts +2 -0
- package/dist/types/ui/CommentBadge/index.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +2 -0
- package/dist/types-ts4.5/ui/CommentBadge/index.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 1.15.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#91808](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91808) [`00e5dcfdf240`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/00e5dcfdf240) - Adds allowCommentsOnMedia in media plugin options to check the appearance of the renderer
|
|
8
|
+
- [#91808](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91808) [`00e5dcfdf240`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/00e5dcfdf240) - [ux] Do not add comments button on the media toolbar when media is not inside full page editor.
|
|
9
|
+
- [#91594](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91594) [`26b59de564d9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/26b59de564d9) - [ED-23025] Check for undefined in the status utility for the comment badge of media nodes
|
|
10
|
+
|
|
3
11
|
## 1.15.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -329,7 +329,7 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
329
329
|
}, {
|
|
330
330
|
key: "render",
|
|
331
331
|
value: function render() {
|
|
332
|
-
var _mediaOptions$getEdit, _pluginInjectionApi$m;
|
|
332
|
+
var _mediaOptions$getEdit, _pluginInjectionApi$m, _node$firstChild;
|
|
333
333
|
var _this$props2 = this.props,
|
|
334
334
|
selected = _this$props2.selected,
|
|
335
335
|
getPos = _this$props2.getPos,
|
|
@@ -344,7 +344,8 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
344
344
|
dispatchAnalyticsEvent = _this$props2.dispatchAnalyticsEvent,
|
|
345
345
|
editorViewMode = _this$props2.editorViewMode,
|
|
346
346
|
mediaPluginState = _this$props2.mediaPluginState,
|
|
347
|
-
editorDisabled = _this$props2.editorDisabled
|
|
347
|
+
editorDisabled = _this$props2.editorDisabled,
|
|
348
|
+
annotationPluginState = _this$props2.annotationPluginState;
|
|
348
349
|
var _ref4 = (mediaOptions === null || mediaOptions === void 0 || (_mediaOptions$getEdit = mediaOptions.getEditorFeatureFlags) === null || _mediaOptions$getEdit === void 0 ? void 0 : _mediaOptions$getEdit.call(mediaOptions)) || {},
|
|
349
350
|
_ref4$commentsOnMedia = _ref4.commentsOnMedia,
|
|
350
351
|
commentsOnMedia = _ref4$commentsOnMedia === void 0 ? false : _ref4$commentsOnMedia;
|
|
@@ -430,6 +431,7 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
430
431
|
}
|
|
431
432
|
}
|
|
432
433
|
var shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof _state.NodeSelection;
|
|
434
|
+
var isCurrentNodeDrafting = (annotationPluginState === null || annotationPluginState === void 0 ? void 0 : annotationPluginState.isDrafting) && (annotationPluginState === null || annotationPluginState === void 0 ? void 0 : annotationPluginState.targetNodeId) === (node === null || node === void 0 || (_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.attrs.id);
|
|
433
435
|
var MediaChildren = (0, _react2.jsx)("figure", {
|
|
434
436
|
ref: this.mediaSingleWrapperRef,
|
|
435
437
|
css: figureWrapperStyles,
|
|
@@ -439,7 +441,8 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
439
441
|
view: view,
|
|
440
442
|
api: pluginInjectionApi,
|
|
441
443
|
mediaNode: node === null || node === void 0 ? void 0 : node.firstChild,
|
|
442
|
-
getPos: getPos
|
|
444
|
+
getPos: getPos,
|
|
445
|
+
isDrafting: isCurrentNodeDrafting
|
|
443
446
|
}), (0, _react2.jsx)("div", {
|
|
444
447
|
ref: this.props.forwardRef
|
|
445
448
|
}), shouldShowPlaceholder && (0, _react2.jsx)(_CaptionPlaceholder.default, {
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -274,6 +274,7 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
274
274
|
allowMediaInline: options && (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', options.featureFlags),
|
|
275
275
|
allowResizing: options && options.allowResizing,
|
|
276
276
|
allowResizingInTables: options && options.allowResizingInTables,
|
|
277
|
+
allowCommentsOnMedia: options && options.allowCommentsOnMedia,
|
|
277
278
|
allowLinking: options && options.allowLinking,
|
|
278
279
|
allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
|
|
279
280
|
allowAltTextOnImages: options && options.allowAltTextOnImages,
|
|
@@ -29,9 +29,10 @@ var commentButton = exports.commentButton = function commentButton(intl, state,
|
|
|
29
29
|
showCommentForBlockNode = _api$annotation$actio.showCommentForBlockNode,
|
|
30
30
|
setInlineCommentDraftState = _api$annotation$actio.setInlineCommentDraftState;
|
|
31
31
|
if (!showCommentForBlockNode(selectMediaNode)(state, dispatch)) {
|
|
32
|
+
var _selectMediaNode$attr;
|
|
32
33
|
setInlineCommentDraftState(true,
|
|
33
34
|
// TODO: might need to update to reflect it's from media floating toolbar
|
|
34
|
-
_analytics.INPUT_METHOD.FLOATING_TB, 'block', true)(state, dispatch);
|
|
35
|
+
_analytics.INPUT_METHOD.FLOATING_TB, 'block', true, (_selectMediaNode$attr = selectMediaNode.attrs) === null || _selectMediaNode$attr === void 0 ? void 0 : _selectMediaNode$attr.id)(state, dispatch);
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
return true;
|
|
@@ -176,6 +176,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
176
176
|
var allowResizing = options.allowResizing,
|
|
177
177
|
allowLinking = options.allowLinking,
|
|
178
178
|
allowAdvancedToolBarOptions = options.allowAdvancedToolBarOptions,
|
|
179
|
+
allowCommentsOnMedia = options.allowCommentsOnMedia,
|
|
179
180
|
allowResizingInTables = options.allowResizingInTables,
|
|
180
181
|
allowAltTextOnImages = options.allowAltTextOnImages,
|
|
181
182
|
allowMediaInline = options.allowMediaInline,
|
|
@@ -405,7 +406,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
405
406
|
type: 'separator'
|
|
406
407
|
});
|
|
407
408
|
}
|
|
408
|
-
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia) {
|
|
409
|
+
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia) {
|
|
409
410
|
toolbarButtons.push((0, _comments.commentButton)(intl, state, pluginInjectionApi), {
|
|
410
411
|
type: 'separator'
|
|
411
412
|
});
|
|
@@ -18,7 +18,8 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
|
|
|
18
18
|
mediaNode = _ref.mediaNode,
|
|
19
19
|
view = _ref.view,
|
|
20
20
|
getPos = _ref.getPos,
|
|
21
|
-
intl = _ref.intl
|
|
21
|
+
intl = _ref.intl,
|
|
22
|
+
isDrafting = _ref.isDrafting;
|
|
22
23
|
var _useState = (0, _react.useState)(false),
|
|
23
24
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
24
25
|
entered = _useState2[0],
|
|
@@ -31,7 +32,7 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
|
|
|
31
32
|
state = view.state,
|
|
32
33
|
dispatch = view.dispatch;
|
|
33
34
|
var status = (0, _react.useMemo)(function () {
|
|
34
|
-
if (!annotationState || !mediaNode) {
|
|
35
|
+
if (!(annotationState !== null && annotationState !== void 0 && annotationState.selectedAnnotations) || !mediaNode) {
|
|
35
36
|
return 'default';
|
|
36
37
|
}
|
|
37
38
|
return annotationState.selectedAnnotations.some(function (annotation) {
|
|
@@ -47,9 +48,10 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
|
|
|
47
48
|
}
|
|
48
49
|
}, [api.annotation, dispatch, mediaNode, state]);
|
|
49
50
|
var pos = getPos();
|
|
50
|
-
|
|
51
|
+
var hasNoComments = !Number.isFinite(pos) || !(annotationState !== null && annotationState !== void 0 && annotationState.annotations) || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(function (maybeAnnotation) {
|
|
51
52
|
return maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotationState.annotations) || annotationState.annotations[maybeAnnotation.attrs.id];
|
|
52
|
-
})
|
|
53
|
+
});
|
|
54
|
+
if (!isDrafting && hasNoComments || !mediaNode) {
|
|
53
55
|
return null;
|
|
54
56
|
}
|
|
55
57
|
var mediaElement = view.domAtPos(pos + 1).node;
|
|
@@ -230,7 +230,7 @@ export default class MediaSingleNode extends Component {
|
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
render() {
|
|
233
|
-
var _mediaOptions$getEdit, _pluginInjectionApi$m, _pluginInjectionApi$m2;
|
|
233
|
+
var _mediaOptions$getEdit, _pluginInjectionApi$m, _pluginInjectionApi$m2, _node$firstChild;
|
|
234
234
|
const {
|
|
235
235
|
selected,
|
|
236
236
|
getPos,
|
|
@@ -247,7 +247,8 @@ export default class MediaSingleNode extends Component {
|
|
|
247
247
|
dispatchAnalyticsEvent,
|
|
248
248
|
editorViewMode,
|
|
249
249
|
mediaPluginState,
|
|
250
|
-
editorDisabled
|
|
250
|
+
editorDisabled,
|
|
251
|
+
annotationPluginState
|
|
251
252
|
} = this.props;
|
|
252
253
|
const {
|
|
253
254
|
commentsOnMedia = false
|
|
@@ -343,6 +344,7 @@ export default class MediaSingleNode extends Component {
|
|
|
343
344
|
}
|
|
344
345
|
}
|
|
345
346
|
const shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
|
|
347
|
+
const isCurrentNodeDrafting = (annotationPluginState === null || annotationPluginState === void 0 ? void 0 : annotationPluginState.isDrafting) && (annotationPluginState === null || annotationPluginState === void 0 ? void 0 : annotationPluginState.targetNodeId) === (node === null || node === void 0 ? void 0 : (_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.attrs.id);
|
|
346
348
|
const MediaChildren = jsx("figure", {
|
|
347
349
|
ref: this.mediaSingleWrapperRef,
|
|
348
350
|
css: figureWrapperStyles,
|
|
@@ -352,7 +354,8 @@ export default class MediaSingleNode extends Component {
|
|
|
352
354
|
view: view,
|
|
353
355
|
api: pluginInjectionApi,
|
|
354
356
|
mediaNode: node === null || node === void 0 ? void 0 : node.firstChild,
|
|
355
|
-
getPos: getPos
|
|
357
|
+
getPos: getPos,
|
|
358
|
+
isDrafting: isCurrentNodeDrafting
|
|
356
359
|
}), jsx("div", {
|
|
357
360
|
ref: this.props.forwardRef
|
|
358
361
|
}), shouldShowPlaceholder && jsx(CaptionPlaceholder, {
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -267,6 +267,7 @@ export const mediaPlugin = ({
|
|
|
267
267
|
allowMediaInline: options && getMediaFeatureFlag('mediaInline', options.featureFlags),
|
|
268
268
|
allowResizing: options && options.allowResizing,
|
|
269
269
|
allowResizingInTables: options && options.allowResizingInTables,
|
|
270
|
+
allowCommentsOnMedia: options && options.allowCommentsOnMedia,
|
|
270
271
|
allowLinking: options && options.allowLinking,
|
|
271
272
|
allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
|
|
272
273
|
allowAltTextOnImages: options && options.allowAltTextOnImages,
|
|
@@ -21,9 +21,10 @@ export const commentButton = (intl, state, api) => {
|
|
|
21
21
|
setInlineCommentDraftState
|
|
22
22
|
} = api.annotation.actions;
|
|
23
23
|
if (!showCommentForBlockNode(selectMediaNode)(state, dispatch)) {
|
|
24
|
+
var _selectMediaNode$attr;
|
|
24
25
|
setInlineCommentDraftState(true,
|
|
25
26
|
// TODO: might need to update to reflect it's from media floating toolbar
|
|
26
|
-
INPUT_METHOD.FLOATING_TB, 'block', true)(state, dispatch);
|
|
27
|
+
INPUT_METHOD.FLOATING_TB, 'block', true, (_selectMediaNode$attr = selectMediaNode.attrs) === null || _selectMediaNode$attr === void 0 ? void 0 : _selectMediaNode$attr.id)(state, dispatch);
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
return true;
|
|
@@ -165,6 +165,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
165
165
|
allowResizing,
|
|
166
166
|
allowLinking,
|
|
167
167
|
allowAdvancedToolBarOptions,
|
|
168
|
+
allowCommentsOnMedia,
|
|
168
169
|
allowResizingInTables,
|
|
169
170
|
allowAltTextOnImages,
|
|
170
171
|
allowMediaInline,
|
|
@@ -402,7 +403,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
402
403
|
type: 'separator'
|
|
403
404
|
});
|
|
404
405
|
}
|
|
405
|
-
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia) {
|
|
406
|
+
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia) {
|
|
406
407
|
toolbarButtons.push(commentButton(intl, state, pluginInjectionApi), {
|
|
407
408
|
type: 'separator'
|
|
408
409
|
});
|
|
@@ -7,7 +7,8 @@ const CommentBadgeWrapper = ({
|
|
|
7
7
|
mediaNode,
|
|
8
8
|
view,
|
|
9
9
|
getPos,
|
|
10
|
-
intl
|
|
10
|
+
intl,
|
|
11
|
+
isDrafting
|
|
11
12
|
}) => {
|
|
12
13
|
const [entered, setEntered] = useState(false);
|
|
13
14
|
const {
|
|
@@ -28,7 +29,7 @@ const CommentBadgeWrapper = ({
|
|
|
28
29
|
dispatch
|
|
29
30
|
} = view;
|
|
30
31
|
const status = useMemo(() => {
|
|
31
|
-
if (!annotationState || !mediaNode) {
|
|
32
|
+
if (!(annotationState !== null && annotationState !== void 0 && annotationState.selectedAnnotations) || !mediaNode) {
|
|
32
33
|
return 'default';
|
|
33
34
|
}
|
|
34
35
|
return annotationState.selectedAnnotations.some(annotation => !!mediaNode.marks.find(mark => mark.attrs.id === annotation.id)) && !annotationState.isInlineCommentViewClosed ? 'active' : 'default';
|
|
@@ -42,7 +43,8 @@ const CommentBadgeWrapper = ({
|
|
|
42
43
|
}
|
|
43
44
|
}, [api.annotation, dispatch, mediaNode, state]);
|
|
44
45
|
const pos = getPos();
|
|
45
|
-
|
|
46
|
+
const hasNoComments = !Number.isFinite(pos) || !(annotationState !== null && annotationState !== void 0 && annotationState.annotations) || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(maybeAnnotation => maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotationState.annotations) || annotationState.annotations[maybeAnnotation.attrs.id]);
|
|
47
|
+
if (!isDrafting && hasNoComments || !mediaNode) {
|
|
46
48
|
return null;
|
|
47
49
|
}
|
|
48
50
|
const mediaElement = view.domAtPos(pos + 1).node;
|
|
@@ -321,7 +321,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
321
321
|
}, {
|
|
322
322
|
key: "render",
|
|
323
323
|
value: function render() {
|
|
324
|
-
var _mediaOptions$getEdit, _pluginInjectionApi$m;
|
|
324
|
+
var _mediaOptions$getEdit, _pluginInjectionApi$m, _node$firstChild;
|
|
325
325
|
var _this$props2 = this.props,
|
|
326
326
|
selected = _this$props2.selected,
|
|
327
327
|
getPos = _this$props2.getPos,
|
|
@@ -336,7 +336,8 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
336
336
|
dispatchAnalyticsEvent = _this$props2.dispatchAnalyticsEvent,
|
|
337
337
|
editorViewMode = _this$props2.editorViewMode,
|
|
338
338
|
mediaPluginState = _this$props2.mediaPluginState,
|
|
339
|
-
editorDisabled = _this$props2.editorDisabled
|
|
339
|
+
editorDisabled = _this$props2.editorDisabled,
|
|
340
|
+
annotationPluginState = _this$props2.annotationPluginState;
|
|
340
341
|
var _ref4 = (mediaOptions === null || mediaOptions === void 0 || (_mediaOptions$getEdit = mediaOptions.getEditorFeatureFlags) === null || _mediaOptions$getEdit === void 0 ? void 0 : _mediaOptions$getEdit.call(mediaOptions)) || {},
|
|
341
342
|
_ref4$commentsOnMedia = _ref4.commentsOnMedia,
|
|
342
343
|
commentsOnMedia = _ref4$commentsOnMedia === void 0 ? false : _ref4$commentsOnMedia;
|
|
@@ -422,6 +423,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
422
423
|
}
|
|
423
424
|
}
|
|
424
425
|
var shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
|
|
426
|
+
var isCurrentNodeDrafting = (annotationPluginState === null || annotationPluginState === void 0 ? void 0 : annotationPluginState.isDrafting) && (annotationPluginState === null || annotationPluginState === void 0 ? void 0 : annotationPluginState.targetNodeId) === (node === null || node === void 0 || (_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.attrs.id);
|
|
425
427
|
var MediaChildren = jsx("figure", {
|
|
426
428
|
ref: this.mediaSingleWrapperRef,
|
|
427
429
|
css: figureWrapperStyles,
|
|
@@ -431,7 +433,8 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
431
433
|
view: view,
|
|
432
434
|
api: pluginInjectionApi,
|
|
433
435
|
mediaNode: node === null || node === void 0 ? void 0 : node.firstChild,
|
|
434
|
-
getPos: getPos
|
|
436
|
+
getPos: getPos,
|
|
437
|
+
isDrafting: isCurrentNodeDrafting
|
|
435
438
|
}), jsx("div", {
|
|
436
439
|
ref: this.props.forwardRef
|
|
437
440
|
}), shouldShowPlaceholder && jsx(CaptionPlaceholder, {
|
package/dist/esm/plugin.js
CHANGED
|
@@ -263,6 +263,7 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
263
263
|
allowMediaInline: options && getMediaFeatureFlag('mediaInline', options.featureFlags),
|
|
264
264
|
allowResizing: options && options.allowResizing,
|
|
265
265
|
allowResizingInTables: options && options.allowResizingInTables,
|
|
266
|
+
allowCommentsOnMedia: options && options.allowCommentsOnMedia,
|
|
266
267
|
allowLinking: options && options.allowLinking,
|
|
267
268
|
allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
|
|
268
269
|
allowAltTextOnImages: options && options.allowAltTextOnImages,
|
|
@@ -22,9 +22,10 @@ export var commentButton = function commentButton(intl, state, api) {
|
|
|
22
22
|
showCommentForBlockNode = _api$annotation$actio.showCommentForBlockNode,
|
|
23
23
|
setInlineCommentDraftState = _api$annotation$actio.setInlineCommentDraftState;
|
|
24
24
|
if (!showCommentForBlockNode(selectMediaNode)(state, dispatch)) {
|
|
25
|
+
var _selectMediaNode$attr;
|
|
25
26
|
setInlineCommentDraftState(true,
|
|
26
27
|
// TODO: might need to update to reflect it's from media floating toolbar
|
|
27
|
-
INPUT_METHOD.FLOATING_TB, 'block', true)(state, dispatch);
|
|
28
|
+
INPUT_METHOD.FLOATING_TB, 'block', true, (_selectMediaNode$attr = selectMediaNode.attrs) === null || _selectMediaNode$attr === void 0 ? void 0 : _selectMediaNode$attr.id)(state, dispatch);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
return true;
|
|
@@ -166,6 +166,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
166
166
|
var allowResizing = options.allowResizing,
|
|
167
167
|
allowLinking = options.allowLinking,
|
|
168
168
|
allowAdvancedToolBarOptions = options.allowAdvancedToolBarOptions,
|
|
169
|
+
allowCommentsOnMedia = options.allowCommentsOnMedia,
|
|
169
170
|
allowResizingInTables = options.allowResizingInTables,
|
|
170
171
|
allowAltTextOnImages = options.allowAltTextOnImages,
|
|
171
172
|
allowMediaInline = options.allowMediaInline,
|
|
@@ -395,7 +396,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
395
396
|
type: 'separator'
|
|
396
397
|
});
|
|
397
398
|
}
|
|
398
|
-
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia) {
|
|
399
|
+
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia) {
|
|
399
400
|
toolbarButtons.push(commentButton(intl, state, pluginInjectionApi), {
|
|
400
401
|
type: 'separator'
|
|
401
402
|
});
|
|
@@ -8,7 +8,8 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
|
|
|
8
8
|
mediaNode = _ref.mediaNode,
|
|
9
9
|
view = _ref.view,
|
|
10
10
|
getPos = _ref.getPos,
|
|
11
|
-
intl = _ref.intl
|
|
11
|
+
intl = _ref.intl,
|
|
12
|
+
isDrafting = _ref.isDrafting;
|
|
12
13
|
var _useState = useState(false),
|
|
13
14
|
_useState2 = _slicedToArray(_useState, 2),
|
|
14
15
|
entered = _useState2[0],
|
|
@@ -21,7 +22,7 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
|
|
|
21
22
|
state = view.state,
|
|
22
23
|
dispatch = view.dispatch;
|
|
23
24
|
var status = useMemo(function () {
|
|
24
|
-
if (!annotationState || !mediaNode) {
|
|
25
|
+
if (!(annotationState !== null && annotationState !== void 0 && annotationState.selectedAnnotations) || !mediaNode) {
|
|
25
26
|
return 'default';
|
|
26
27
|
}
|
|
27
28
|
return annotationState.selectedAnnotations.some(function (annotation) {
|
|
@@ -37,9 +38,10 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
|
|
|
37
38
|
}
|
|
38
39
|
}, [api.annotation, dispatch, mediaNode, state]);
|
|
39
40
|
var pos = getPos();
|
|
40
|
-
|
|
41
|
+
var hasNoComments = !Number.isFinite(pos) || !(annotationState !== null && annotationState !== void 0 && annotationState.annotations) || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(function (maybeAnnotation) {
|
|
41
42
|
return maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotationState.annotations) || annotationState.annotations[maybeAnnotation.attrs.id];
|
|
42
|
-
})
|
|
43
|
+
});
|
|
44
|
+
if (!isDrafting && hasNoComments || !mediaNode) {
|
|
43
45
|
return null;
|
|
44
46
|
}
|
|
45
47
|
var mediaElement = view.domAtPos(pos + 1).node;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export interface MediaOptions {
|
|
|
49
49
|
featureFlags?: MediaFeatureFlags;
|
|
50
50
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
51
51
|
allowCaptions?: boolean;
|
|
52
|
+
allowCommentsOnMedia?: boolean;
|
|
52
53
|
}
|
|
53
54
|
export interface MediaSingleOptions {
|
|
54
55
|
disableLayout?: boolean;
|
|
@@ -112,6 +113,7 @@ export type MediaFloatingToolbarOptions = {
|
|
|
112
113
|
altTextValidator?: (value: string) => string[];
|
|
113
114
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
114
115
|
fullWidthEnabled?: boolean;
|
|
116
|
+
allowCommentsOnMedia?: boolean;
|
|
115
117
|
};
|
|
116
118
|
export type MediaDecorationSpec = {
|
|
117
119
|
type: 'media';
|
|
@@ -11,6 +11,7 @@ type CommentBadgeProps = {
|
|
|
11
11
|
mediaNode: PMNode | null;
|
|
12
12
|
view: EditorView;
|
|
13
13
|
getPos: getPosHandler;
|
|
14
|
+
isDrafting: boolean;
|
|
14
15
|
};
|
|
15
16
|
export declare const CommentBadge: React.FC<import("react-intl-next").WithIntlProps<CommentBadgeProps>> & {
|
|
16
17
|
WrappedComponent: React.ComponentType<CommentBadgeProps>;
|
|
@@ -49,6 +49,7 @@ export interface MediaOptions {
|
|
|
49
49
|
featureFlags?: MediaFeatureFlags;
|
|
50
50
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
51
51
|
allowCaptions?: boolean;
|
|
52
|
+
allowCommentsOnMedia?: boolean;
|
|
52
53
|
}
|
|
53
54
|
export interface MediaSingleOptions {
|
|
54
55
|
disableLayout?: boolean;
|
|
@@ -112,6 +113,7 @@ export type MediaFloatingToolbarOptions = {
|
|
|
112
113
|
altTextValidator?: (value: string) => string[];
|
|
113
114
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
114
115
|
fullWidthEnabled?: boolean;
|
|
116
|
+
allowCommentsOnMedia?: boolean;
|
|
115
117
|
};
|
|
116
118
|
export type MediaDecorationSpec = {
|
|
117
119
|
type: 'media';
|
|
@@ -11,6 +11,7 @@ type CommentBadgeProps = {
|
|
|
11
11
|
mediaNode: PMNode | null;
|
|
12
12
|
view: EditorView;
|
|
13
13
|
getPos: getPosHandler;
|
|
14
|
+
isDrafting: boolean;
|
|
14
15
|
};
|
|
15
16
|
export declare const CommentBadge: React.FC<import("react-intl-next").WithIntlProps<CommentBadgeProps>> & {
|
|
16
17
|
WrappedComponent: React.ComponentType<CommentBadgeProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.2",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@atlaskit/analytics-namespaced-context": "^6.9.0",
|
|
38
38
|
"@atlaskit/analytics-next": "^9.2.0",
|
|
39
39
|
"@atlaskit/button": "^17.12.0",
|
|
40
|
-
"@atlaskit/editor-common": "^78.
|
|
40
|
+
"@atlaskit/editor-common": "^78.29.0",
|
|
41
41
|
"@atlaskit/editor-palette": "1.5.3",
|
|
42
42
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
43
43
|
"@atlaskit/editor-plugin-annotation": "1.5.9",
|