@atlaskit/editor-plugin-card 11.5.12 → 11.5.14

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,19 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 11.5.14
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 11.5.13
10
+
11
+ ### Patch Changes
12
+
13
+ - [`722f272e8b78f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/722f272e8b78f) -
14
+ Editor-2778: Smartlink card and embed transform
15
+ - Updated dependencies
16
+
3
17
  ## 11.5.12
4
18
 
5
19
  ### Patch Changes
@@ -134,7 +134,7 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
134
134
  }
135
135
  try {
136
136
  return getPos();
137
- } catch (e) {
137
+ } catch (_unused) {
138
138
  // Can blow up in rare cases, when node has been removed.
139
139
  }
140
140
  });
@@ -180,7 +180,7 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
180
180
  hasPreview: false
181
181
  });
182
182
  }
183
- } catch (e) {}
183
+ } catch (_unused2) {}
184
184
  });
185
185
  (0, _defineProperty2.default)(_this, "updateSize", function (pctWidth, layout) {
186
186
  var _this$props$view = _this.props.view,
@@ -198,6 +198,21 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
198
198
  dispatch(tr);
199
199
  return true;
200
200
  });
201
+ /**
202
+ * Defers line-length measurement until the embed card DOM has fully rendered.
203
+ *
204
+ * When put embed in the expand, reload the page and open that expand, the embed was collapsed.
205
+ * Because the `.rich-media-item` can temporarily report `offsetWidth = 1`, as proportional width styles have not been applied yet.
206
+ * Measuring at that moment would cache the bogus width and break resize calculations.
207
+ * Scheduling a measurement on the next animation frame ensures layout has
208
+ * settled. We then force the node view to re-render so `getLineLength`
209
+ * re-runs and captures the correct width.
210
+ */
211
+ (0, _defineProperty2.default)(_this, "scheduleLineLengthRemeasureRaf", (0, _rafSchd.default)(function (view) {
212
+ if (view) {
213
+ _this.forceUpdate();
214
+ }
215
+ }));
201
216
  (0, _defineProperty2.default)(_this, "getLineLength", function (view, pos, originalLineLength) {
202
217
  if (typeof pos === 'number' && (0, _utils.isRichMediaInsideOfBlockNode)(view, pos)) {
203
218
  var $pos = view.state.doc.resolve(pos);
@@ -206,7 +221,12 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
206
221
  return domNode.parentElement.offsetWidth;
207
222
  }
208
223
  if (domNode instanceof HTMLElement) {
209
- return domNode.offsetWidth;
224
+ var measuredWidth = domNode.offsetWidth;
225
+ if (measuredWidth <= 1 && (0, _expValEquals.expValEquals)('editor_fix_embed_width_expand', 'isEnabled', true)) {
226
+ _this.scheduleLineLengthRemeasureRaf(view);
227
+ return originalLineLength;
228
+ }
229
+ return measuredWidth;
210
230
  }
211
231
  }
212
232
  return originalLineLength;
@@ -5,28 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.DatasourceIcon = void 0;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
8
  var _react = _interopRequireDefault(require("react"));
10
9
  var _smartLinkList = _interopRequireDefault(require("@atlaskit/icon/core/smart-link-list"));
11
10
  var _primitives = require("@atlaskit/primitives");
12
11
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
13
12
 
14
- var IconDatasourceGlyph = function IconDatasourceGlyph(props) {
15
- return /*#__PURE__*/_react.default.createElement("svg", (0, _extends2.default)({
16
- xmlns: "http://www.w3.org/2000/svg",
17
- width: "15",
18
- height: "15",
19
- viewBox: "0 0 15 15",
20
- fill: "none"
21
- // Ignored via go/ees005
22
- // eslint-disable-next-line react/jsx-props-no-spreading
23
- }, props), /*#__PURE__*/_react.default.createElement("path", {
24
- fillRule: "evenodd",
25
- clipRule: "evenodd",
26
- d: "M0 2C0 0.89543 0.895431 0 2 0H13C14.1046 0 15 0.895431 15 2V13C15 14.1046 14.1046 15 13 15H2C0.89543 15 0 14.1046 0 13V2ZM5 6C5 5.44772 5.44772 5 6 5L12 5C12.5523 5 13 5.44772 13 6C13 6.55229 12.5523 7 12 7L6 7C5.44772 7 5 6.55228 5 6ZM6 8C5.44772 8 5 8.44771 5 9C5 9.55228 5.44772 10 6 10L12 10C12.5523 10 13 9.55229 13 9C13 8.44772 12.5523 8 12 8L6 8ZM5 12C5 11.4477 5.44772 11 6 11L12 11C12.5523 11 13 11.4477 13 12C13 12.5523 12.5523 13 12 13L6 13C5.44772 13 5 12.5523 5 12ZM3 7C3.55228 7 4 6.55228 4 6C4 5.44772 3.55228 5 3 5C2.44772 5 2 5.44772 2 6C2 6.55228 2.44772 7 3 7ZM5 3C5 2.44772 5.44772 2 6 2L12 2C12.5523 2 13 2.44772 13 3C13 3.55229 12.5523 4 12 4L6 4C5.44772 4 5 3.55228 5 3ZM3 4C3.55228 4 4 3.55228 4 3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3C2 3.55228 2.44772 4 3 4ZM4 9C4 9.55229 3.55228 10 3 10C2.44772 10 2 9.55229 2 9C2 8.44771 2.44772 8 3 8C3.55228 8 4 8.44771 4 9ZM3 13C3.55228 13 4 12.5523 4 12C4 11.4477 3.55228 11 3 11C2.44772 11 2 11.4477 2 12C2 12.5523 2.44772 13 3 13Z",
27
- fill: 'currentColor'
28
- }));
29
- };
30
13
  var wrapperStyles = (0, _primitives.xcss)({
31
14
  padding: 'space.050',
32
15
  justifyContent: 'center',
@@ -38,7 +21,6 @@ var DatasourceIcon = exports.DatasourceIcon = function DatasourceIcon(props) {
38
21
  return /*#__PURE__*/_react.default.createElement(_primitives.Flex, {
39
22
  xcss: wrapperStyles
40
23
  }, /*#__PURE__*/_react.default.createElement(_smartLinkList.default, {
41
- LEGACY_fallbackIcon: IconDatasourceGlyph,
42
24
  label: props === null || props === void 0 ? void 0 : props.label
43
25
  }));
44
26
  };
@@ -119,7 +119,7 @@ export class EmbedCardComponent extends React.PureComponent {
119
119
  }
120
120
  try {
121
121
  return getPos();
122
- } catch (e) {
122
+ } catch {
123
123
  // Can blow up in rare cases, when node has been removed.
124
124
  }
125
125
  });
@@ -170,7 +170,7 @@ export class EmbedCardComponent extends React.PureComponent {
170
170
  hasPreview: false
171
171
  });
172
172
  }
173
- } catch (e) {}
173
+ } catch {}
174
174
  });
175
175
  _defineProperty(this, "updateSize", (pctWidth, layout) => {
176
176
  const {
@@ -190,6 +190,21 @@ export class EmbedCardComponent extends React.PureComponent {
190
190
  dispatch(tr);
191
191
  return true;
192
192
  });
193
+ /**
194
+ * Defers line-length measurement until the embed card DOM has fully rendered.
195
+ *
196
+ * When put embed in the expand, reload the page and open that expand, the embed was collapsed.
197
+ * Because the `.rich-media-item` can temporarily report `offsetWidth = 1`, as proportional width styles have not been applied yet.
198
+ * Measuring at that moment would cache the bogus width and break resize calculations.
199
+ * Scheduling a measurement on the next animation frame ensures layout has
200
+ * settled. We then force the node view to re-render so `getLineLength`
201
+ * re-runs and captures the correct width.
202
+ */
203
+ _defineProperty(this, "scheduleLineLengthRemeasureRaf", rafSchedule(view => {
204
+ if (view) {
205
+ this.forceUpdate();
206
+ }
207
+ }));
193
208
  _defineProperty(this, "getLineLength", (view, pos, originalLineLength) => {
194
209
  if (typeof pos === 'number' && isRichMediaInsideOfBlockNode(view, pos)) {
195
210
  const $pos = view.state.doc.resolve(pos);
@@ -198,7 +213,12 @@ export class EmbedCardComponent extends React.PureComponent {
198
213
  return domNode.parentElement.offsetWidth;
199
214
  }
200
215
  if (domNode instanceof HTMLElement) {
201
- return domNode.offsetWidth;
216
+ const measuredWidth = domNode.offsetWidth;
217
+ if (measuredWidth <= 1 && expValEquals('editor_fix_embed_width_expand', 'isEnabled', true)) {
218
+ this.scheduleLineLengthRemeasureRaf(view);
219
+ return originalLineLength;
220
+ }
221
+ return measuredWidth;
202
222
  }
203
223
  }
204
224
  return originalLineLength;
@@ -1,24 +1,7 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import React from 'react';
3
2
  import SmartLinkListIcon from '@atlaskit/icon/core/smart-link-list';
4
3
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
5
4
  import { Flex, xcss } from '@atlaskit/primitives';
6
- const IconDatasourceGlyph = props => {
7
- return /*#__PURE__*/React.createElement("svg", _extends({
8
- xmlns: "http://www.w3.org/2000/svg",
9
- width: "15",
10
- height: "15",
11
- viewBox: "0 0 15 15",
12
- fill: "none"
13
- // Ignored via go/ees005
14
- // eslint-disable-next-line react/jsx-props-no-spreading
15
- }, props), /*#__PURE__*/React.createElement("path", {
16
- fillRule: "evenodd",
17
- clipRule: "evenodd",
18
- d: "M0 2C0 0.89543 0.895431 0 2 0H13C14.1046 0 15 0.895431 15 2V13C15 14.1046 14.1046 15 13 15H2C0.89543 15 0 14.1046 0 13V2ZM5 6C5 5.44772 5.44772 5 6 5L12 5C12.5523 5 13 5.44772 13 6C13 6.55229 12.5523 7 12 7L6 7C5.44772 7 5 6.55228 5 6ZM6 8C5.44772 8 5 8.44771 5 9C5 9.55228 5.44772 10 6 10L12 10C12.5523 10 13 9.55229 13 9C13 8.44772 12.5523 8 12 8L6 8ZM5 12C5 11.4477 5.44772 11 6 11L12 11C12.5523 11 13 11.4477 13 12C13 12.5523 12.5523 13 12 13L6 13C5.44772 13 5 12.5523 5 12ZM3 7C3.55228 7 4 6.55228 4 6C4 5.44772 3.55228 5 3 5C2.44772 5 2 5.44772 2 6C2 6.55228 2.44772 7 3 7ZM5 3C5 2.44772 5.44772 2 6 2L12 2C12.5523 2 13 2.44772 13 3C13 3.55229 12.5523 4 12 4L6 4C5.44772 4 5 3.55228 5 3ZM3 4C3.55228 4 4 3.55228 4 3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3C2 3.55228 2.44772 4 3 4ZM4 9C4 9.55229 3.55228 10 3 10C2.44772 10 2 9.55229 2 9C2 8.44771 2.44772 8 3 8C3.55228 8 4 8.44771 4 9ZM3 13C3.55228 13 4 12.5523 4 12C4 11.4477 3.55228 11 3 11C2.44772 11 2 11.4477 2 12C2 12.5523 2.44772 13 3 13Z",
19
- fill: 'currentColor'
20
- }));
21
- };
22
5
  const wrapperStyles = xcss({
23
6
  padding: 'space.050',
24
7
  justifyContent: 'center',
@@ -30,7 +13,6 @@ export const DatasourceIcon = props => {
30
13
  return /*#__PURE__*/React.createElement(Flex, {
31
14
  xcss: wrapperStyles
32
15
  }, /*#__PURE__*/React.createElement(SmartLinkListIcon, {
33
- LEGACY_fallbackIcon: IconDatasourceGlyph,
34
16
  label: props === null || props === void 0 ? void 0 : props.label
35
17
  }));
36
18
  };
@@ -128,7 +128,7 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
128
128
  }
129
129
  try {
130
130
  return getPos();
131
- } catch (e) {
131
+ } catch (_unused) {
132
132
  // Can blow up in rare cases, when node has been removed.
133
133
  }
134
134
  });
@@ -174,7 +174,7 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
174
174
  hasPreview: false
175
175
  });
176
176
  }
177
- } catch (e) {}
177
+ } catch (_unused2) {}
178
178
  });
179
179
  _defineProperty(_this, "updateSize", function (pctWidth, layout) {
180
180
  var _this$props$view = _this.props.view,
@@ -192,6 +192,21 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
192
192
  dispatch(tr);
193
193
  return true;
194
194
  });
195
+ /**
196
+ * Defers line-length measurement until the embed card DOM has fully rendered.
197
+ *
198
+ * When put embed in the expand, reload the page and open that expand, the embed was collapsed.
199
+ * Because the `.rich-media-item` can temporarily report `offsetWidth = 1`, as proportional width styles have not been applied yet.
200
+ * Measuring at that moment would cache the bogus width and break resize calculations.
201
+ * Scheduling a measurement on the next animation frame ensures layout has
202
+ * settled. We then force the node view to re-render so `getLineLength`
203
+ * re-runs and captures the correct width.
204
+ */
205
+ _defineProperty(_this, "scheduleLineLengthRemeasureRaf", rafSchedule(function (view) {
206
+ if (view) {
207
+ _this.forceUpdate();
208
+ }
209
+ }));
195
210
  _defineProperty(_this, "getLineLength", function (view, pos, originalLineLength) {
196
211
  if (typeof pos === 'number' && isRichMediaInsideOfBlockNode(view, pos)) {
197
212
  var $pos = view.state.doc.resolve(pos);
@@ -200,7 +215,12 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
200
215
  return domNode.parentElement.offsetWidth;
201
216
  }
202
217
  if (domNode instanceof HTMLElement) {
203
- return domNode.offsetWidth;
218
+ var measuredWidth = domNode.offsetWidth;
219
+ if (measuredWidth <= 1 && expValEquals('editor_fix_embed_width_expand', 'isEnabled', true)) {
220
+ _this.scheduleLineLengthRemeasureRaf(view);
221
+ return originalLineLength;
222
+ }
223
+ return measuredWidth;
204
224
  }
205
225
  }
206
226
  return originalLineLength;
@@ -1,24 +1,7 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import React from 'react';
3
2
  import SmartLinkListIcon from '@atlaskit/icon/core/smart-link-list';
4
3
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
5
4
  import { Flex, xcss } from '@atlaskit/primitives';
6
- var IconDatasourceGlyph = function IconDatasourceGlyph(props) {
7
- return /*#__PURE__*/React.createElement("svg", _extends({
8
- xmlns: "http://www.w3.org/2000/svg",
9
- width: "15",
10
- height: "15",
11
- viewBox: "0 0 15 15",
12
- fill: "none"
13
- // Ignored via go/ees005
14
- // eslint-disable-next-line react/jsx-props-no-spreading
15
- }, props), /*#__PURE__*/React.createElement("path", {
16
- fillRule: "evenodd",
17
- clipRule: "evenodd",
18
- d: "M0 2C0 0.89543 0.895431 0 2 0H13C14.1046 0 15 0.895431 15 2V13C15 14.1046 14.1046 15 13 15H2C0.89543 15 0 14.1046 0 13V2ZM5 6C5 5.44772 5.44772 5 6 5L12 5C12.5523 5 13 5.44772 13 6C13 6.55229 12.5523 7 12 7L6 7C5.44772 7 5 6.55228 5 6ZM6 8C5.44772 8 5 8.44771 5 9C5 9.55228 5.44772 10 6 10L12 10C12.5523 10 13 9.55229 13 9C13 8.44772 12.5523 8 12 8L6 8ZM5 12C5 11.4477 5.44772 11 6 11L12 11C12.5523 11 13 11.4477 13 12C13 12.5523 12.5523 13 12 13L6 13C5.44772 13 5 12.5523 5 12ZM3 7C3.55228 7 4 6.55228 4 6C4 5.44772 3.55228 5 3 5C2.44772 5 2 5.44772 2 6C2 6.55228 2.44772 7 3 7ZM5 3C5 2.44772 5.44772 2 6 2L12 2C12.5523 2 13 2.44772 13 3C13 3.55229 12.5523 4 12 4L6 4C5.44772 4 5 3.55228 5 3ZM3 4C3.55228 4 4 3.55228 4 3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3C2 3.55228 2.44772 4 3 4ZM4 9C4 9.55229 3.55228 10 3 10C2.44772 10 2 9.55229 2 9C2 8.44771 2.44772 8 3 8C3.55228 8 4 8.44771 4 9ZM3 13C3.55228 13 4 12.5523 4 12C4 11.4477 3.55228 11 3 11C2.44772 11 2 11.4477 2 12C2 12.5523 2.44772 13 3 13Z",
19
- fill: 'currentColor'
20
- }));
21
- };
22
5
  var wrapperStyles = xcss({
23
6
  padding: 'space.050',
24
7
  justifyContent: 'center',
@@ -30,7 +13,6 @@ export var DatasourceIcon = function DatasourceIcon(props) {
30
13
  return /*#__PURE__*/React.createElement(Flex, {
31
14
  xcss: wrapperStyles
32
15
  }, /*#__PURE__*/React.createElement(SmartLinkListIcon, {
33
- LEGACY_fallbackIcon: IconDatasourceGlyph,
34
16
  label: props === null || props === void 0 ? void 0 : props.label
35
17
  }));
36
18
  };
@@ -27,6 +27,17 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
27
27
  url?: string;
28
28
  }) => void;
29
29
  updateSize: (pctWidth: number | null, layout: RichMediaLayout) => true | undefined;
30
+ /**
31
+ * Defers line-length measurement until the embed card DOM has fully rendered.
32
+ *
33
+ * When put embed in the expand, reload the page and open that expand, the embed was collapsed.
34
+ * Because the `.rich-media-item` can temporarily report `offsetWidth = 1`, as proportional width styles have not been applied yet.
35
+ * Measuring at that moment would cache the bogus width and break resize calculations.
36
+ * Scheduling a measurement on the next animation frame ensures layout has
37
+ * settled. We then force the node view to re-render so `getLineLength`
38
+ * re-runs and captures the correct width.
39
+ */
40
+ private scheduleLineLengthRemeasureRaf;
30
41
  private getLineLength;
31
42
  /**
32
43
  * Even though render is capable of listening and reacting to iframely wrapper iframe sent `resize` events
@@ -27,6 +27,17 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
27
27
  url?: string;
28
28
  }) => void;
29
29
  updateSize: (pctWidth: number | null, layout: RichMediaLayout) => true | undefined;
30
+ /**
31
+ * Defers line-length measurement until the embed card DOM has fully rendered.
32
+ *
33
+ * When put embed in the expand, reload the page and open that expand, the embed was collapsed.
34
+ * Because the `.rich-media-item` can temporarily report `offsetWidth = 1`, as proportional width styles have not been applied yet.
35
+ * Measuring at that moment would cache the bogus width and break resize calculations.
36
+ * Scheduling a measurement on the next animation frame ensures layout has
37
+ * settled. We then force the node view to re-render so `getLineLength`
38
+ * re-runs and captures the correct width.
39
+ */
40
+ private scheduleLineLengthRemeasureRaf;
30
41
  private getLineLength;
31
42
  /**
32
43
  * Even though render is capable of listening and reacting to iframely wrapper iframe sent `resize` events
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "11.5.12",
3
+ "version": "11.5.14",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -39,14 +39,14 @@
39
39
  "@atlaskit/editor-plugin-editor-disabled": "^6.1.0",
40
40
  "@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
41
41
  "@atlaskit/editor-plugin-feature-flags": "^5.0.0",
42
- "@atlaskit/editor-plugin-floating-toolbar": "^8.2.0",
42
+ "@atlaskit/editor-plugin-floating-toolbar": "^8.3.0",
43
43
  "@atlaskit/editor-plugin-grid": "^6.0.0",
44
44
  "@atlaskit/editor-plugin-toolbar": "^3.4.0",
45
45
  "@atlaskit/editor-plugin-width": "^7.0.0",
46
46
  "@atlaskit/editor-prosemirror": "^7.2.0",
47
47
  "@atlaskit/editor-shared-styles": "^3.10.0",
48
48
  "@atlaskit/frontend-utilities": "^3.2.0",
49
- "@atlaskit/icon": "^29.1.0",
49
+ "@atlaskit/icon": "^29.3.0",
50
50
  "@atlaskit/link": "^3.2.0",
51
51
  "@atlaskit/link-analytics": "^11.0.0",
52
52
  "@atlaskit/link-client-extension": "^6.0.0",
@@ -59,10 +59,10 @@
59
59
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
60
60
  "@atlaskit/primitives": "^16.4.0",
61
61
  "@atlaskit/prosemirror-history": "^0.2.0",
62
- "@atlaskit/smart-card": "^43.16.0",
62
+ "@atlaskit/smart-card": "^43.17.0",
63
63
  "@atlaskit/theme": "^21.0.0",
64
- "@atlaskit/tmp-editor-statsig": "^15.12.0",
65
- "@atlaskit/tokens": "^8.5.0",
64
+ "@atlaskit/tmp-editor-statsig": "^16.0.0",
65
+ "@atlaskit/tokens": "^8.6.0",
66
66
  "@babel/runtime": "^7.0.0",
67
67
  "@emotion/react": "^11.7.1",
68
68
  "lodash": "^4.17.21",
@@ -71,7 +71,7 @@
71
71
  "uuid": "^3.1.0"
72
72
  },
73
73
  "peerDependencies": {
74
- "@atlaskit/editor-common": "^110.44.0",
74
+ "@atlaskit/editor-common": "^110.46.0",
75
75
  "@atlaskit/link-provider": "^4.0.0",
76
76
  "react": "^18.2.0",
77
77
  "react-intl-next": "npm:react-intl@^5.18.1"