@atlaskit/editor-plugin-media 8.4.15 → 8.4.16

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,15 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 8.4.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1344d6deac8a3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1344d6deac8a3) -
8
+ provide better max dimensions to media to fix blurry image on load
9
+ - [`e3779b75fdeca`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e3779b75fdeca) -
10
+ EDITOR-1643 Promote syncBlock and bodiedSyncBlock to full schema
11
+ - Updated dependencies
12
+
3
13
  ## 8.4.15
4
14
 
5
15
  ### 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');
@@ -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) {
@@ -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');
@@ -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.15",
3
+ "version": "8.4.16",
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.4.0",
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.4.0",
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.2.0",
69
+ "@atlaskit/tmp-editor-statsig": "^14.5.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.36.0",
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",