@atlaskit/editor-plugin-media 1.40.0 → 1.41.0
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 +21 -0
- package/dist/cjs/nodeviews/mediaSingle.js +59 -18
- package/dist/cjs/toolbar/comments.js +4 -2
- package/dist/es2019/nodeviews/mediaSingle.js +38 -4
- package/dist/es2019/toolbar/comments.js +4 -2
- package/dist/esm/nodeviews/mediaSingle.js +59 -18
- package/dist/esm/toolbar/comments.js +4 -2
- package/dist/types/nodeviews/mediaSingle.d.ts +4 -0
- package/dist/types-ts4.5/nodeviews/mediaSingle.d.ts +4 -0
- package/package.json +15 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 1.41.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#161814](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/161814)
|
|
8
|
+
[`6ff956fe6b784`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6ff956fe6b784) -
|
|
9
|
+
[ux] Add a new property to annotation state to know whether or not we're opening the comment box
|
|
10
|
+
from the media toolbar so we can scroll it into view from Confluence side
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 1.40.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#163299](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/163299)
|
|
21
|
+
[`164ca5d30a1ca`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/164ca5d30a1ca) -
|
|
22
|
+
ED-25335-make-media-single-non-editable-in-live-view
|
|
23
|
+
|
|
3
24
|
## 1.40.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -648,10 +648,18 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
648
648
|
key: "createDomRef",
|
|
649
649
|
value: function createDomRef() {
|
|
650
650
|
var domRef = document.createElement('div');
|
|
651
|
-
if (
|
|
652
|
-
|
|
653
|
-
//
|
|
654
|
-
|
|
651
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_prevent_delete_image_in_view_mode')) {
|
|
652
|
+
var _this$reactComponentP;
|
|
653
|
+
// controll the domRef contentEditable attribute based on the editor view mode
|
|
654
|
+
this.unsubscribeToViewModeChange = this.subscribeToViewModeChange(domRef);
|
|
655
|
+
var initialViewMode = (_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.sharedState.currentState()) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.mode;
|
|
656
|
+
this.updateDomRefContentEditable(domRef, initialViewMode);
|
|
657
|
+
} else {
|
|
658
|
+
if (this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
|
|
659
|
+
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
660
|
+
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
661
|
+
domRef.contentEditable = 'true';
|
|
662
|
+
}
|
|
655
663
|
}
|
|
656
664
|
if ((0, _platformFeatureFlags.fg)('platform_editor_media_extended_resize_experience')) {
|
|
657
665
|
domRef.classList.add('media-extended-resize-experience');
|
|
@@ -685,6 +693,33 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
685
693
|
}
|
|
686
694
|
return (0, _get2.default)((0, _getPrototypeOf2.default)(MediaSingleNodeView.prototype), "viewShouldUpdate", this).call(this, nextNode);
|
|
687
695
|
}
|
|
696
|
+
}, {
|
|
697
|
+
key: "subscribeToViewModeChange",
|
|
698
|
+
value: function subscribeToViewModeChange(domRef) {
|
|
699
|
+
var _this$reactComponentP2,
|
|
700
|
+
_this3 = this;
|
|
701
|
+
return (_this$reactComponentP2 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP2 === void 0 || (_this$reactComponentP2 = _this$reactComponentP2.editorViewMode) === null || _this$reactComponentP2 === void 0 ? void 0 : _this$reactComponentP2.sharedState.onChange(function (viewModeState) {
|
|
702
|
+
var _viewModeState$nextSh;
|
|
703
|
+
_this3.updateDomRefContentEditable(domRef, (_viewModeState$nextSh = viewModeState.nextSharedState) === null || _viewModeState$nextSh === void 0 ? void 0 : _viewModeState$nextSh.mode);
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
}, {
|
|
707
|
+
key: "updateDomRefContentEditable",
|
|
708
|
+
value: function updateDomRefContentEditable(domRef, editorViewMode) {
|
|
709
|
+
var _this$reactComponentP3;
|
|
710
|
+
// if the editor is in view mode, we should not allow editing
|
|
711
|
+
if (editorViewMode === 'view') {
|
|
712
|
+
domRef.contentEditable = 'false';
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// if the editor is in edit mode, we should allow editing if the media options allow it
|
|
717
|
+
if ((_this$reactComponentP3 = this.reactComponentProps.mediaOptions) !== null && _this$reactComponentP3 !== void 0 && _this$reactComponentP3.allowMediaSingleEditable) {
|
|
718
|
+
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
719
|
+
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
720
|
+
domRef.contentEditable = 'true';
|
|
721
|
+
}
|
|
722
|
+
}
|
|
688
723
|
}, {
|
|
689
724
|
key: "getNodeMediaId",
|
|
690
725
|
value: function getNodeMediaId(node) {
|
|
@@ -707,10 +742,10 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
707
742
|
}, {
|
|
708
743
|
key: "update",
|
|
709
744
|
value: function update(node, decorations, _innerDecorations, isValidUpdate) {
|
|
710
|
-
var
|
|
745
|
+
var _this4 = this;
|
|
711
746
|
if (!isValidUpdate) {
|
|
712
747
|
isValidUpdate = function isValidUpdate(currentNode, newNode) {
|
|
713
|
-
return
|
|
748
|
+
return _this4.getNodeMediaId(currentNode) === _this4.getNodeMediaId(newNode);
|
|
714
749
|
};
|
|
715
750
|
}
|
|
716
751
|
return (0, _get2.default)((0, _getPrototypeOf2.default)(MediaSingleNodeView.prototype), "update", this).call(this, node, decorations, _innerDecorations, isValidUpdate);
|
|
@@ -718,15 +753,15 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
718
753
|
}, {
|
|
719
754
|
key: "render",
|
|
720
755
|
value: function render(props, forwardRef) {
|
|
721
|
-
var
|
|
722
|
-
var _this$
|
|
723
|
-
eventDispatcher = _this$
|
|
724
|
-
fullWidthMode = _this$
|
|
725
|
-
providerFactory = _this$
|
|
726
|
-
mediaOptions = _this$
|
|
727
|
-
dispatchAnalyticsEvent = _this$
|
|
728
|
-
pluginInjectionApi = _this$
|
|
729
|
-
editorAppearance = _this$
|
|
756
|
+
var _this5 = this;
|
|
757
|
+
var _this$reactComponentP4 = this.reactComponentProps,
|
|
758
|
+
eventDispatcher = _this$reactComponentP4.eventDispatcher,
|
|
759
|
+
fullWidthMode = _this$reactComponentP4.fullWidthMode,
|
|
760
|
+
providerFactory = _this$reactComponentP4.providerFactory,
|
|
761
|
+
mediaOptions = _this$reactComponentP4.mediaOptions,
|
|
762
|
+
dispatchAnalyticsEvent = _this$reactComponentP4.dispatchAnalyticsEvent,
|
|
763
|
+
pluginInjectionApi = _this$reactComponentP4.pluginInjectionApi,
|
|
764
|
+
editorAppearance = _this$reactComponentP4.editorAppearance;
|
|
730
765
|
|
|
731
766
|
// getPos is a boolean for marks, since this is a node we know it must be a function
|
|
732
767
|
var getPos = this.getPos;
|
|
@@ -738,12 +773,12 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
738
773
|
return (0, _react2.jsx)(MediaSingleNodeWrapper, {
|
|
739
774
|
pluginInjectionApi: pluginInjectionApi,
|
|
740
775
|
contextIdentifierProvider: contextIdentifierProvider,
|
|
741
|
-
node:
|
|
776
|
+
node: _this5.node,
|
|
742
777
|
getPos: getPos,
|
|
743
778
|
mediaOptions: mediaOptions,
|
|
744
|
-
view:
|
|
779
|
+
view: _this5.view,
|
|
745
780
|
fullWidthMode: fullWidthMode,
|
|
746
|
-
selected:
|
|
781
|
+
selected: _this5.isNodeSelected,
|
|
747
782
|
eventDispatcher: eventDispatcher,
|
|
748
783
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
749
784
|
forwardRef: forwardRef,
|
|
@@ -768,6 +803,12 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
768
803
|
}
|
|
769
804
|
return true;
|
|
770
805
|
}
|
|
806
|
+
}, {
|
|
807
|
+
key: "destroy",
|
|
808
|
+
value: function destroy() {
|
|
809
|
+
var _this$unsubscribeToVi;
|
|
810
|
+
(_this$unsubscribeToVi = this.unsubscribeToViewModeChange) === null || _this$unsubscribeToVi === void 0 || _this$unsubscribeToVi.call(this);
|
|
811
|
+
}
|
|
771
812
|
}]);
|
|
772
813
|
return MediaSingleNodeView;
|
|
773
814
|
}(_reactNodeView.default);
|
|
@@ -11,6 +11,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
|
11
11
|
var _media = require("@atlaskit/editor-common/media");
|
|
12
12
|
var _comment = _interopRequireDefault(require("@atlaskit/icon/core/comment"));
|
|
13
13
|
var _comment2 = _interopRequireDefault(require("@atlaskit/icon/glyph/comment"));
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
15
|
var _commentWithDotIcon = require("./assets/commentWithDotIcon");
|
|
15
16
|
var _utils = require("./utils");
|
|
16
17
|
var commentButton = exports.commentButton = function commentButton(intl, state, api) {
|
|
@@ -29,11 +30,12 @@ var commentButton = exports.commentButton = function commentButton(intl, state,
|
|
|
29
30
|
var _api$annotation$actio = api.annotation.actions,
|
|
30
31
|
showCommentForBlockNode = _api$annotation$actio.showCommentForBlockNode,
|
|
31
32
|
setInlineCommentDraftState = _api$annotation$actio.setInlineCommentDraftState;
|
|
32
|
-
|
|
33
|
+
var isOpeningMediaCommentFromToolbar = (0, _platformFeatureFlags.fg)('confluence_frontend_media_scroll_fix') ? true : false;
|
|
34
|
+
if (!showCommentForBlockNode(selectMediaNode, _analytics.VIEW_METHOD.COMMENT_BUTTON, isOpeningMediaCommentFromToolbar)(state, dispatch)) {
|
|
33
35
|
var _selectMediaNode$attr;
|
|
34
36
|
setInlineCommentDraftState(true,
|
|
35
37
|
// TODO: might need to update to reflect it's from media floating toolbar
|
|
36
|
-
_analytics.INPUT_METHOD.FLOATING_TB, 'block', (_selectMediaNode$attr = selectMediaNode.attrs) === null || _selectMediaNode$attr === void 0 ? void 0 : _selectMediaNode$attr.id)(state, dispatch);
|
|
38
|
+
_analytics.INPUT_METHOD.FLOATING_TB, 'block', (_selectMediaNode$attr = selectMediaNode.attrs) === null || _selectMediaNode$attr === void 0 ? void 0 : _selectMediaNode$attr.id, isOpeningMediaCommentFromToolbar)(state, dispatch);
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
return true;
|
|
@@ -555,10 +555,18 @@ class MediaSingleNodeView extends ReactNodeView {
|
|
|
555
555
|
}
|
|
556
556
|
createDomRef() {
|
|
557
557
|
const domRef = document.createElement('div');
|
|
558
|
-
if (
|
|
559
|
-
|
|
560
|
-
//
|
|
561
|
-
|
|
558
|
+
if (fg('platform_editor_prevent_delete_image_in_view_mode')) {
|
|
559
|
+
var _this$reactComponentP, _this$reactComponentP2, _this$reactComponentP3;
|
|
560
|
+
// controll the domRef contentEditable attribute based on the editor view mode
|
|
561
|
+
this.unsubscribeToViewModeChange = this.subscribeToViewModeChange(domRef);
|
|
562
|
+
const initialViewMode = (_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 ? void 0 : (_this$reactComponentP2 = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP2 === void 0 ? void 0 : (_this$reactComponentP3 = _this$reactComponentP2.sharedState.currentState()) === null || _this$reactComponentP3 === void 0 ? void 0 : _this$reactComponentP3.mode;
|
|
563
|
+
this.updateDomRefContentEditable(domRef, initialViewMode);
|
|
564
|
+
} else {
|
|
565
|
+
if (this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
|
|
566
|
+
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
567
|
+
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
568
|
+
domRef.contentEditable = 'true';
|
|
569
|
+
}
|
|
562
570
|
}
|
|
563
571
|
if (fg('platform_editor_media_extended_resize_experience')) {
|
|
564
572
|
domRef.classList.add('media-extended-resize-experience');
|
|
@@ -588,6 +596,28 @@ class MediaSingleNodeView extends ReactNodeView {
|
|
|
588
596
|
}
|
|
589
597
|
return super.viewShouldUpdate(nextNode);
|
|
590
598
|
}
|
|
599
|
+
subscribeToViewModeChange(domRef) {
|
|
600
|
+
var _this$reactComponentP4, _this$reactComponentP5;
|
|
601
|
+
return (_this$reactComponentP4 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP4 === void 0 ? void 0 : (_this$reactComponentP5 = _this$reactComponentP4.editorViewMode) === null || _this$reactComponentP5 === void 0 ? void 0 : _this$reactComponentP5.sharedState.onChange(viewModeState => {
|
|
602
|
+
var _viewModeState$nextSh;
|
|
603
|
+
this.updateDomRefContentEditable(domRef, (_viewModeState$nextSh = viewModeState.nextSharedState) === null || _viewModeState$nextSh === void 0 ? void 0 : _viewModeState$nextSh.mode);
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
updateDomRefContentEditable(domRef, editorViewMode) {
|
|
607
|
+
var _this$reactComponentP6;
|
|
608
|
+
// if the editor is in view mode, we should not allow editing
|
|
609
|
+
if (editorViewMode === 'view') {
|
|
610
|
+
domRef.contentEditable = 'false';
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// if the editor is in edit mode, we should allow editing if the media options allow it
|
|
615
|
+
if ((_this$reactComponentP6 = this.reactComponentProps.mediaOptions) !== null && _this$reactComponentP6 !== void 0 && _this$reactComponentP6.allowMediaSingleEditable) {
|
|
616
|
+
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
617
|
+
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
618
|
+
domRef.contentEditable = 'true';
|
|
619
|
+
}
|
|
620
|
+
}
|
|
591
621
|
getNodeMediaId(node) {
|
|
592
622
|
if (node.firstChild) {
|
|
593
623
|
return node.firstChild.attrs.id;
|
|
@@ -657,6 +687,10 @@ class MediaSingleNodeView extends ReactNodeView {
|
|
|
657
687
|
}
|
|
658
688
|
return true;
|
|
659
689
|
}
|
|
690
|
+
destroy() {
|
|
691
|
+
var _this$unsubscribeToVi;
|
|
692
|
+
(_this$unsubscribeToVi = this.unsubscribeToViewModeChange) === null || _this$unsubscribeToVi === void 0 ? void 0 : _this$unsubscribeToVi.call(this);
|
|
693
|
+
}
|
|
660
694
|
}
|
|
661
695
|
export const ReactMediaSingleNode = (portalProviderAPI, eventDispatcher, providerFactory, pluginInjectionApi, dispatchAnalyticsEvent, mediaOptions = {}) => (node, view, getPos) => {
|
|
662
696
|
return new MediaSingleNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
@@ -4,6 +4,7 @@ import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
|
4
4
|
import { commentMessages as messages } from '@atlaskit/editor-common/media';
|
|
5
5
|
import CommentIcon from '@atlaskit/icon/core/comment';
|
|
6
6
|
import LegacyCommentIcon from '@atlaskit/icon/glyph/comment';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { CommentWithDotIcon } from './assets/commentWithDotIcon';
|
|
8
9
|
import { getSelectedMediaSingle } from './utils';
|
|
9
10
|
export const commentButton = (intl, state, api) => {
|
|
@@ -21,11 +22,12 @@ export const commentButton = (intl, state, api) => {
|
|
|
21
22
|
showCommentForBlockNode,
|
|
22
23
|
setInlineCommentDraftState
|
|
23
24
|
} = api.annotation.actions;
|
|
24
|
-
|
|
25
|
+
const isOpeningMediaCommentFromToolbar = fg('confluence_frontend_media_scroll_fix') ? true : false;
|
|
26
|
+
if (!showCommentForBlockNode(selectMediaNode, VIEW_METHOD.COMMENT_BUTTON, isOpeningMediaCommentFromToolbar)(state, dispatch)) {
|
|
25
27
|
var _selectMediaNode$attr;
|
|
26
28
|
setInlineCommentDraftState(true,
|
|
27
29
|
// TODO: might need to update to reflect it's from media floating toolbar
|
|
28
|
-
INPUT_METHOD.FLOATING_TB, 'block', (_selectMediaNode$attr = selectMediaNode.attrs) === null || _selectMediaNode$attr === void 0 ? void 0 : _selectMediaNode$attr.id)(state, dispatch);
|
|
30
|
+
INPUT_METHOD.FLOATING_TB, 'block', (_selectMediaNode$attr = selectMediaNode.attrs) === null || _selectMediaNode$attr === void 0 ? void 0 : _selectMediaNode$attr.id, isOpeningMediaCommentFromToolbar)(state, dispatch);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
return true;
|
|
@@ -643,10 +643,18 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
643
643
|
key: "createDomRef",
|
|
644
644
|
value: function createDomRef() {
|
|
645
645
|
var domRef = document.createElement('div');
|
|
646
|
-
if (
|
|
647
|
-
|
|
648
|
-
//
|
|
649
|
-
|
|
646
|
+
if (fg('platform_editor_prevent_delete_image_in_view_mode')) {
|
|
647
|
+
var _this$reactComponentP;
|
|
648
|
+
// controll the domRef contentEditable attribute based on the editor view mode
|
|
649
|
+
this.unsubscribeToViewModeChange = this.subscribeToViewModeChange(domRef);
|
|
650
|
+
var initialViewMode = (_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.sharedState.currentState()) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.mode;
|
|
651
|
+
this.updateDomRefContentEditable(domRef, initialViewMode);
|
|
652
|
+
} else {
|
|
653
|
+
if (this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
|
|
654
|
+
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
655
|
+
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
656
|
+
domRef.contentEditable = 'true';
|
|
657
|
+
}
|
|
650
658
|
}
|
|
651
659
|
if (fg('platform_editor_media_extended_resize_experience')) {
|
|
652
660
|
domRef.classList.add('media-extended-resize-experience');
|
|
@@ -680,6 +688,33 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
680
688
|
}
|
|
681
689
|
return _get(_getPrototypeOf(MediaSingleNodeView.prototype), "viewShouldUpdate", this).call(this, nextNode);
|
|
682
690
|
}
|
|
691
|
+
}, {
|
|
692
|
+
key: "subscribeToViewModeChange",
|
|
693
|
+
value: function subscribeToViewModeChange(domRef) {
|
|
694
|
+
var _this$reactComponentP2,
|
|
695
|
+
_this3 = this;
|
|
696
|
+
return (_this$reactComponentP2 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP2 === void 0 || (_this$reactComponentP2 = _this$reactComponentP2.editorViewMode) === null || _this$reactComponentP2 === void 0 ? void 0 : _this$reactComponentP2.sharedState.onChange(function (viewModeState) {
|
|
697
|
+
var _viewModeState$nextSh;
|
|
698
|
+
_this3.updateDomRefContentEditable(domRef, (_viewModeState$nextSh = viewModeState.nextSharedState) === null || _viewModeState$nextSh === void 0 ? void 0 : _viewModeState$nextSh.mode);
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
}, {
|
|
702
|
+
key: "updateDomRefContentEditable",
|
|
703
|
+
value: function updateDomRefContentEditable(domRef, editorViewMode) {
|
|
704
|
+
var _this$reactComponentP3;
|
|
705
|
+
// if the editor is in view mode, we should not allow editing
|
|
706
|
+
if (editorViewMode === 'view') {
|
|
707
|
+
domRef.contentEditable = 'false';
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// if the editor is in edit mode, we should allow editing if the media options allow it
|
|
712
|
+
if ((_this$reactComponentP3 = this.reactComponentProps.mediaOptions) !== null && _this$reactComponentP3 !== void 0 && _this$reactComponentP3.allowMediaSingleEditable) {
|
|
713
|
+
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
714
|
+
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
715
|
+
domRef.contentEditable = 'true';
|
|
716
|
+
}
|
|
717
|
+
}
|
|
683
718
|
}, {
|
|
684
719
|
key: "getNodeMediaId",
|
|
685
720
|
value: function getNodeMediaId(node) {
|
|
@@ -702,10 +737,10 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
702
737
|
}, {
|
|
703
738
|
key: "update",
|
|
704
739
|
value: function update(node, decorations, _innerDecorations, isValidUpdate) {
|
|
705
|
-
var
|
|
740
|
+
var _this4 = this;
|
|
706
741
|
if (!isValidUpdate) {
|
|
707
742
|
isValidUpdate = function isValidUpdate(currentNode, newNode) {
|
|
708
|
-
return
|
|
743
|
+
return _this4.getNodeMediaId(currentNode) === _this4.getNodeMediaId(newNode);
|
|
709
744
|
};
|
|
710
745
|
}
|
|
711
746
|
return _get(_getPrototypeOf(MediaSingleNodeView.prototype), "update", this).call(this, node, decorations, _innerDecorations, isValidUpdate);
|
|
@@ -713,15 +748,15 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
713
748
|
}, {
|
|
714
749
|
key: "render",
|
|
715
750
|
value: function render(props, forwardRef) {
|
|
716
|
-
var
|
|
717
|
-
var _this$
|
|
718
|
-
eventDispatcher = _this$
|
|
719
|
-
fullWidthMode = _this$
|
|
720
|
-
providerFactory = _this$
|
|
721
|
-
mediaOptions = _this$
|
|
722
|
-
dispatchAnalyticsEvent = _this$
|
|
723
|
-
pluginInjectionApi = _this$
|
|
724
|
-
editorAppearance = _this$
|
|
751
|
+
var _this5 = this;
|
|
752
|
+
var _this$reactComponentP4 = this.reactComponentProps,
|
|
753
|
+
eventDispatcher = _this$reactComponentP4.eventDispatcher,
|
|
754
|
+
fullWidthMode = _this$reactComponentP4.fullWidthMode,
|
|
755
|
+
providerFactory = _this$reactComponentP4.providerFactory,
|
|
756
|
+
mediaOptions = _this$reactComponentP4.mediaOptions,
|
|
757
|
+
dispatchAnalyticsEvent = _this$reactComponentP4.dispatchAnalyticsEvent,
|
|
758
|
+
pluginInjectionApi = _this$reactComponentP4.pluginInjectionApi,
|
|
759
|
+
editorAppearance = _this$reactComponentP4.editorAppearance;
|
|
725
760
|
|
|
726
761
|
// getPos is a boolean for marks, since this is a node we know it must be a function
|
|
727
762
|
var getPos = this.getPos;
|
|
@@ -733,12 +768,12 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
733
768
|
return jsx(MediaSingleNodeWrapper, {
|
|
734
769
|
pluginInjectionApi: pluginInjectionApi,
|
|
735
770
|
contextIdentifierProvider: contextIdentifierProvider,
|
|
736
|
-
node:
|
|
771
|
+
node: _this5.node,
|
|
737
772
|
getPos: getPos,
|
|
738
773
|
mediaOptions: mediaOptions,
|
|
739
|
-
view:
|
|
774
|
+
view: _this5.view,
|
|
740
775
|
fullWidthMode: fullWidthMode,
|
|
741
|
-
selected:
|
|
776
|
+
selected: _this5.isNodeSelected,
|
|
742
777
|
eventDispatcher: eventDispatcher,
|
|
743
778
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
744
779
|
forwardRef: forwardRef,
|
|
@@ -763,6 +798,12 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
763
798
|
}
|
|
764
799
|
return true;
|
|
765
800
|
}
|
|
801
|
+
}, {
|
|
802
|
+
key: "destroy",
|
|
803
|
+
value: function destroy() {
|
|
804
|
+
var _this$unsubscribeToVi;
|
|
805
|
+
(_this$unsubscribeToVi = this.unsubscribeToViewModeChange) === null || _this$unsubscribeToVi === void 0 || _this$unsubscribeToVi.call(this);
|
|
806
|
+
}
|
|
766
807
|
}]);
|
|
767
808
|
return MediaSingleNodeView;
|
|
768
809
|
}(ReactNodeView);
|
|
@@ -4,6 +4,7 @@ import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
|
4
4
|
import { commentMessages as messages } from '@atlaskit/editor-common/media';
|
|
5
5
|
import CommentIcon from '@atlaskit/icon/core/comment';
|
|
6
6
|
import LegacyCommentIcon from '@atlaskit/icon/glyph/comment';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { CommentWithDotIcon } from './assets/commentWithDotIcon';
|
|
8
9
|
import { getSelectedMediaSingle } from './utils';
|
|
9
10
|
export var commentButton = function commentButton(intl, state, api) {
|
|
@@ -22,11 +23,12 @@ export var commentButton = function commentButton(intl, state, api) {
|
|
|
22
23
|
var _api$annotation$actio = api.annotation.actions,
|
|
23
24
|
showCommentForBlockNode = _api$annotation$actio.showCommentForBlockNode,
|
|
24
25
|
setInlineCommentDraftState = _api$annotation$actio.setInlineCommentDraftState;
|
|
25
|
-
|
|
26
|
+
var isOpeningMediaCommentFromToolbar = fg('confluence_frontend_media_scroll_fix') ? true : false;
|
|
27
|
+
if (!showCommentForBlockNode(selectMediaNode, VIEW_METHOD.COMMENT_BUTTON, isOpeningMediaCommentFromToolbar)(state, dispatch)) {
|
|
26
28
|
var _selectMediaNode$attr;
|
|
27
29
|
setInlineCommentDraftState(true,
|
|
28
30
|
// TODO: might need to update to reflect it's from media floating toolbar
|
|
29
|
-
INPUT_METHOD.FLOATING_TB, 'block', (_selectMediaNode$attr = selectMediaNode.attrs) === null || _selectMediaNode$attr === void 0 ? void 0 : _selectMediaNode$attr.id)(state, dispatch);
|
|
31
|
+
INPUT_METHOD.FLOATING_TB, 'block', (_selectMediaNode$attr = selectMediaNode.attrs) === null || _selectMediaNode$attr === void 0 ? void 0 : _selectMediaNode$attr.id, isOpeningMediaCommentFromToolbar)(state, dispatch);
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
return true;
|
|
@@ -50,11 +50,14 @@ declare class MediaSingleNodeView extends ReactNodeView<MediaSingleNodeViewProps
|
|
|
50
50
|
lastOffsetLeft: number;
|
|
51
51
|
forceViewUpdate: boolean;
|
|
52
52
|
selectionType: number | null;
|
|
53
|
+
unsubscribeToViewModeChange: (() => void) | undefined;
|
|
53
54
|
createDomRef(): HTMLElement;
|
|
54
55
|
getContentDOM(): {
|
|
55
56
|
dom: HTMLDivElement;
|
|
56
57
|
};
|
|
57
58
|
viewShouldUpdate(nextNode: PMNode): boolean;
|
|
59
|
+
subscribeToViewModeChange(domRef: HTMLElement): (() => void) | undefined;
|
|
60
|
+
updateDomRefContentEditable(domRef: HTMLElement, editorViewMode?: 'edit' | 'view'): void;
|
|
58
61
|
checkAndUpdateSelectionType: () => import("@atlaskit/editor-common/utils").SelectedState | null;
|
|
59
62
|
isNodeSelected: () => boolean;
|
|
60
63
|
getNodeMediaId(node: PMNode): string | undefined;
|
|
@@ -62,6 +65,7 @@ declare class MediaSingleNodeView extends ReactNodeView<MediaSingleNodeViewProps
|
|
|
62
65
|
update(node: PMNode, decorations: readonly Decoration[], _innerDecorations?: DecorationSource, isValidUpdate?: (currentNode: PMNode, newNode: PMNode) => boolean): boolean;
|
|
63
66
|
render(props: MediaSingleNodeViewProps, forwardRef?: ForwardRef): jsx.JSX.Element;
|
|
64
67
|
ignoreMutation(): boolean;
|
|
68
|
+
destroy(): void;
|
|
65
69
|
}
|
|
66
70
|
export declare const ReactMediaSingleNode: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined, dispatchAnalyticsEvent?: DispatchAnalyticsEvent, mediaOptions?: MediaOptions) => (node: PMNode, view: EditorView, getPos: getPosHandler) => MediaSingleNodeView;
|
|
67
71
|
export {};
|
|
@@ -50,11 +50,14 @@ declare class MediaSingleNodeView extends ReactNodeView<MediaSingleNodeViewProps
|
|
|
50
50
|
lastOffsetLeft: number;
|
|
51
51
|
forceViewUpdate: boolean;
|
|
52
52
|
selectionType: number | null;
|
|
53
|
+
unsubscribeToViewModeChange: (() => void) | undefined;
|
|
53
54
|
createDomRef(): HTMLElement;
|
|
54
55
|
getContentDOM(): {
|
|
55
56
|
dom: HTMLDivElement;
|
|
56
57
|
};
|
|
57
58
|
viewShouldUpdate(nextNode: PMNode): boolean;
|
|
59
|
+
subscribeToViewModeChange(domRef: HTMLElement): (() => void) | undefined;
|
|
60
|
+
updateDomRefContentEditable(domRef: HTMLElement, editorViewMode?: 'edit' | 'view'): void;
|
|
58
61
|
checkAndUpdateSelectionType: () => import("@atlaskit/editor-common/utils").SelectedState | null;
|
|
59
62
|
isNodeSelected: () => boolean;
|
|
60
63
|
getNodeMediaId(node: PMNode): string | undefined;
|
|
@@ -62,6 +65,7 @@ declare class MediaSingleNodeView extends ReactNodeView<MediaSingleNodeViewProps
|
|
|
62
65
|
update(node: PMNode, decorations: readonly Decoration[], _innerDecorations?: DecorationSource, isValidUpdate?: (currentNode: PMNode, newNode: PMNode) => boolean): boolean;
|
|
63
66
|
render(props: MediaSingleNodeViewProps, forwardRef?: ForwardRef): jsx.JSX.Element;
|
|
64
67
|
ignoreMutation(): boolean;
|
|
68
|
+
destroy(): void;
|
|
65
69
|
}
|
|
66
70
|
export declare const ReactMediaSingleNode: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined, dispatchAnalyticsEvent?: DispatchAnalyticsEvent, mediaOptions?: MediaOptions) => (node: PMNode, view: EditorView, getPos: getPosHandler) => MediaSingleNodeView;
|
|
67
71
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"@atlaskit/analytics-namespaced-context": "^6.12.0",
|
|
37
37
|
"@atlaskit/analytics-next": "^10.1.0",
|
|
38
38
|
"@atlaskit/button": "^20.3.0",
|
|
39
|
-
"@atlaskit/editor-common": "^94.
|
|
39
|
+
"@atlaskit/editor-common": "^94.21.0",
|
|
40
40
|
"@atlaskit/editor-palette": "1.6.3",
|
|
41
41
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
42
|
-
"@atlaskit/editor-plugin-annotation": "1.
|
|
42
|
+
"@atlaskit/editor-plugin-annotation": "1.24.0",
|
|
43
43
|
"@atlaskit/editor-plugin-decorations": "^1.3.0",
|
|
44
44
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|
|
45
45
|
"@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
|
|
@@ -54,19 +54,19 @@
|
|
|
54
54
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
55
55
|
"@atlaskit/form": "^10.5.0",
|
|
56
56
|
"@atlaskit/icon": "^22.24.0",
|
|
57
|
-
"@atlaskit/media-card": "^78.
|
|
58
|
-
"@atlaskit/media-client": "^28.
|
|
57
|
+
"@atlaskit/media-card": "^78.14.0",
|
|
58
|
+
"@atlaskit/media-client": "^28.3.0",
|
|
59
59
|
"@atlaskit/media-client-react": "^2.3.0",
|
|
60
60
|
"@atlaskit/media-common": "^11.7.0",
|
|
61
61
|
"@atlaskit/media-filmstrip": "^47.5.0",
|
|
62
62
|
"@atlaskit/media-picker": "^67.0.0",
|
|
63
|
-
"@atlaskit/media-ui": "^26.
|
|
64
|
-
"@atlaskit/media-viewer": "^49.
|
|
63
|
+
"@atlaskit/media-ui": "^26.2.0",
|
|
64
|
+
"@atlaskit/media-viewer": "^49.4.0",
|
|
65
65
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
66
|
-
"@atlaskit/primitives": "^13.
|
|
66
|
+
"@atlaskit/primitives": "^13.2.0",
|
|
67
67
|
"@atlaskit/textfield": "^6.5.0",
|
|
68
68
|
"@atlaskit/theme": "^14.0.0",
|
|
69
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
69
|
+
"@atlaskit/tmp-editor-statsig": "^2.16.0",
|
|
70
70
|
"@atlaskit/tokens": "^2.2.0",
|
|
71
71
|
"@atlaskit/tooltip": "^18.9.0",
|
|
72
72
|
"@babel/runtime": "^7.0.0",
|
|
@@ -144,8 +144,14 @@
|
|
|
144
144
|
"platform-visual-refresh-icons": {
|
|
145
145
|
"type": "boolean"
|
|
146
146
|
},
|
|
147
|
+
"platform_editor_prevent_delete_image_in_view_mode": {
|
|
148
|
+
"type": "boolean"
|
|
149
|
+
},
|
|
147
150
|
"platform_editor_inline_resize_media_to_edge": {
|
|
148
151
|
"type": "boolean"
|
|
152
|
+
},
|
|
153
|
+
"confluence_frontend_media_scroll_fix": {
|
|
154
|
+
"type": "boolean"
|
|
149
155
|
}
|
|
150
156
|
},
|
|
151
157
|
"stricter": {
|