@atlaskit/editor-plugin-card 11.5.11 → 11.5.13

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,21 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 11.5.13
4
+
5
+ ### Patch Changes
6
+
7
+ - [`722f272e8b78f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/722f272e8b78f) -
8
+ Editor-2778: Smartlink card and embed transform
9
+ - Updated dependencies
10
+
11
+ ## 11.5.12
12
+
13
+ ### Patch Changes
14
+
15
+ - [`90abe9b926a6f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/90abe9b926a6f) -
16
+ Icon entrypoint migration
17
+ - Updated dependencies
18
+
3
19
  ## 11.5.11
4
20
 
5
21
  ### 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
  };
@@ -16,7 +16,7 @@ var _debounce = _interopRequireDefault(require("lodash/debounce"));
16
16
  var _reactIntlNext = require("react-intl-next");
17
17
  var _messages = require("@atlaskit/editor-common/messages");
18
18
  var _whitespace = require("@atlaskit/editor-common/whitespace");
19
- var _customizePreferences = _interopRequireDefault(require("@atlaskit/icon/core/migration/customize--preferences"));
19
+ var _customize = _interopRequireDefault(require("@atlaskit/icon/core/customize"));
20
20
  var _colors = require("@atlaskit/theme/colors");
21
21
  var _utils = require("./utils");
22
22
  var _excluded = ["children", "isSelected", "isVisible", "testId", "url"];
@@ -257,7 +257,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
257
257
  className: ICON_AND_LABEL_CLASSNAME
258
258
  }, (0, _react2.jsx)("span", {
259
259
  css: iconStyles
260
- }, (0, _react2.jsx)(_customizePreferences.default, {
260
+ }, (0, _react2.jsx)(_customize.default, {
261
261
  label: label,
262
262
  LEGACY_size: iconSize.current,
263
263
  testId: "".concat(testId, "-icon")
@@ -13,8 +13,8 @@ var _hooks = require("@atlaskit/editor-common/hooks");
13
13
  var _ui = require("@atlaskit/editor-common/ui");
14
14
  var _uiMenu = require("@atlaskit/editor-common/ui-menu");
15
15
  var _utils = require("@atlaskit/editor-common/utils");
16
- var _growHorizontalEditorExpand = _interopRequireDefault(require("@atlaskit/icon/core/migration/grow-horizontal--editor-expand"));
17
- var _shrinkHorizontalEditorCollapse = _interopRequireDefault(require("@atlaskit/icon/core/migration/shrink-horizontal--editor-collapse"));
16
+ var _growHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/grow-horizontal"));
17
+ var _shrinkHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/shrink-horizontal"));
18
18
  var _linkingCommon = require("@atlaskit/linking-common");
19
19
  var _colors = require("@atlaskit/theme/colors");
20
20
  var _actions = require("../../pm-plugins/actions");
@@ -70,9 +70,9 @@ var LayoutButton = exports.LayoutButton = function LayoutButton(_ref) {
70
70
  css: toolbarButtonWrapperStyles,
71
71
  title: title,
72
72
  onClick: handleClick,
73
- iconBefore: layout === 'full-width' ? (0, _react2.jsx)(_shrinkHorizontalEditorCollapse.default, {
73
+ iconBefore: layout === 'full-width' ? (0, _react2.jsx)(_shrinkHorizontal.default, {
74
74
  label: title
75
- }) : (0, _react2.jsx)(_growHorizontalEditorExpand.default, {
75
+ }) : (0, _react2.jsx)(_growHorizontal.default, {
76
76
  label: title
77
77
  })
78
78
  }));
@@ -27,10 +27,6 @@ var _edit = _interopRequireDefault(require("@atlaskit/icon/core/edit"));
27
27
  var _linkBroken = _interopRequireDefault(require("@atlaskit/icon/core/link-broken"));
28
28
  var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
29
29
  var _comment2 = _interopRequireDefault(require("@atlaskit/icon/core/migration/comment"));
30
- var _deleteEditorRemove = _interopRequireDefault(require("@atlaskit/icon/core/migration/delete--editor-remove"));
31
- var _linkBrokenEditorUnlink = _interopRequireDefault(require("@atlaskit/icon/core/migration/link-broken--editor-unlink"));
32
- var _linkExternalShortcut = _interopRequireDefault(require("@atlaskit/icon/core/migration/link-external--shortcut"));
33
- var _settingsEditorSettings = _interopRequireDefault(require("@atlaskit/icon/core/migration/settings--editor-settings"));
34
30
  var _settings = _interopRequireDefault(require("@atlaskit/icon/core/settings"));
35
31
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
36
32
  var _doc = require("../pm-plugins/doc");
@@ -351,7 +347,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
351
347
  id: 'editor.link.openLink',
352
348
  type: 'button',
353
349
  icon: _linkExternal.default,
354
- iconFallback: _linkExternalShortcut.default,
350
+ iconFallback: _linkExternal.default,
355
351
  metadata: metadata,
356
352
  className: 'hyperlink-open-link',
357
353
  title: intl.formatMessage(_messages.linkMessages.openLink),
@@ -377,7 +373,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
377
373
  type: 'button',
378
374
  appearance: 'danger',
379
375
  icon: _delete.default,
380
- iconFallback: _deleteEditorRemove.default,
376
+ iconFallback: _delete.default,
381
377
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
382
378
  onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
383
379
  onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
@@ -391,7 +387,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
391
387
  id: 'editor.link.openLink',
392
388
  type: 'button',
393
389
  icon: _linkExternal.default,
394
- iconFallback: _linkExternalShortcut.default,
390
+ iconFallback: _linkExternal.default,
395
391
  metadata: metadata,
396
392
  className: 'hyperlink-open-link',
397
393
  title: intl.formatMessage(_messages.linkMessages.openLink),
@@ -519,7 +515,7 @@ var getUnlinkButtonGroup = function getUnlinkButtonGroup(state, intl, node, inli
519
515
  type: 'button',
520
516
  title: intl.formatMessage(_messages.linkToolbarMessages.unlink),
521
517
  icon: _linkBroken.default,
522
- iconFallback: _linkBrokenEditorUnlink.default,
518
+ iconFallback: _linkBroken.default,
523
519
  onClick: withToolbarMetadata(unlinkCard(node, state, editorAnalyticsApi))
524
520
  }].concat((0, _toConsumableArray2.default)(areAnyNewToolbarFlagsEnabled ? [] : [{
525
521
  type: 'separator'
@@ -530,7 +526,7 @@ var getSettingsButton = exports.getSettingsButton = function getSettingsButton(i
530
526
  id: 'editor.link.settings',
531
527
  type: 'button',
532
528
  icon: _settings.default,
533
- iconFallback: _settingsEditorSettings.default,
529
+ iconFallback: _settings.default,
534
530
  title: intl.formatMessage(_messages.linkToolbarMessages.settingsLink),
535
531
  onClick: openLinkSettings(editorAnalyticsApi),
536
532
  href: userPreferencesLink || (0, _link.getLinkPreferencesURLFromENV)(),
@@ -634,7 +630,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
634
630
  id: 'editor.link.openLink',
635
631
  type: 'button',
636
632
  icon: _linkExternal.default,
637
- iconFallback: _linkExternalShortcut.default,
633
+ iconFallback: _linkExternal.default,
638
634
  metadata: metadata,
639
635
  className: 'hyperlink-open-link',
640
636
  title: intl.formatMessage(_messages.linkMessages.openLink),
@@ -667,7 +663,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
667
663
  type: 'button',
668
664
  appearance: 'danger',
669
665
  icon: _delete.default,
670
- iconFallback: _deleteEditorRemove.default,
666
+ iconFallback: _delete.default,
671
667
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
672
668
  onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
673
669
  onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
@@ -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
  };
@@ -13,7 +13,7 @@ import debounce from 'lodash/debounce';
13
13
  import { useIntl } from 'react-intl-next';
14
14
  import { cardMessages as messages } from '@atlaskit/editor-common/messages';
15
15
  import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace';
16
- import CustomizeIcon from '@atlaskit/icon/core/migration/customize--preferences';
16
+ import CustomizeIcon from '@atlaskit/icon/core/customize';
17
17
  import { B100, N0, N700 } from '@atlaskit/theme/colors';
18
18
  import { getChildElement, getIconSize, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
19
19
  const DEBOUNCE_IN_MS = 5;
@@ -11,8 +11,8 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
11
11
  import { Popup } from '@atlaskit/editor-common/ui';
12
12
  import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
13
13
  import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
14
- import GrowHorizontalIcon from '@atlaskit/icon/core/migration/grow-horizontal--editor-expand';
15
- import ShrinkHorizontalIcon from '@atlaskit/icon/core/migration/shrink-horizontal--editor-collapse';
14
+ import GrowHorizontalIcon from '@atlaskit/icon/core/grow-horizontal';
15
+ import ShrinkHorizontalIcon from '@atlaskit/icon/core/shrink-horizontal';
16
16
  import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
17
17
  import { B300, N20A, N300 } from '@atlaskit/theme/colors';
18
18
  import { setCardLayout } from '../../pm-plugins/actions';
@@ -17,11 +17,7 @@ import EditIcon from '@atlaskit/icon/core/edit';
17
17
  import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
18
18
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
19
19
  import LegacyCommentIcon from '@atlaskit/icon/core/migration/comment';
20
- import RemoveIcon from '@atlaskit/icon/core/migration/delete--editor-remove';
21
- import UnlinkIcon from '@atlaskit/icon/core/migration/link-broken--editor-unlink';
22
- import OpenIcon from '@atlaskit/icon/core/migration/link-external--shortcut';
23
- import CogIcon from '@atlaskit/icon/core/migration/settings--editor-settings';
24
- import SettingsIcon from '@atlaskit/icon/core/settings';
20
+ import CogIcon from '@atlaskit/icon/core/settings';
25
21
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
26
22
  import { changeSelectedCardToText } from '../pm-plugins/doc';
27
23
  import { pluginKey } from '../pm-plugins/plugin-key';
@@ -339,7 +335,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
339
335
  id: 'editor.link.openLink',
340
336
  type: 'button',
341
337
  icon: LinkExternalIcon,
342
- iconFallback: OpenIcon,
338
+ iconFallback: LinkExternalIcon,
343
339
  metadata: metadata,
344
340
  className: 'hyperlink-open-link',
345
341
  title: intl.formatMessage(linkMessages.openLink),
@@ -365,7 +361,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
365
361
  type: 'button',
366
362
  appearance: 'danger',
367
363
  icon: DeleteIcon,
368
- iconFallback: RemoveIcon,
364
+ iconFallback: DeleteIcon,
369
365
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
370
366
  onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
371
367
  onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
@@ -379,7 +375,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
379
375
  id: 'editor.link.openLink',
380
376
  type: 'button',
381
377
  icon: LinkExternalIcon,
382
- iconFallback: OpenIcon,
378
+ iconFallback: LinkExternalIcon,
383
379
  metadata: metadata,
384
380
  className: 'hyperlink-open-link',
385
381
  title: intl.formatMessage(linkMessages.openLink),
@@ -504,7 +500,7 @@ const getUnlinkButtonGroup = (state, intl, node, inlineCard, editorAnalyticsApi,
504
500
  type: 'button',
505
501
  title: intl.formatMessage(linkToolbarMessages.unlink),
506
502
  icon: LinkBrokenIcon,
507
- iconFallback: UnlinkIcon,
503
+ iconFallback: LinkBrokenIcon,
508
504
  onClick: withToolbarMetadata(unlinkCard(node, state, editorAnalyticsApi))
509
505
  }, ...(areAnyNewToolbarFlagsEnabled ? [] : [{
510
506
  type: 'separator'
@@ -514,7 +510,7 @@ export const getSettingsButton = (intl, editorAnalyticsApi, userPreferencesLink)
514
510
  return {
515
511
  id: 'editor.link.settings',
516
512
  type: 'button',
517
- icon: SettingsIcon,
513
+ icon: CogIcon,
518
514
  iconFallback: CogIcon,
519
515
  title: intl.formatMessage(linkToolbarMessages.settingsLink),
520
516
  onClick: openLinkSettings(editorAnalyticsApi),
@@ -619,7 +615,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
619
615
  id: 'editor.link.openLink',
620
616
  type: 'button',
621
617
  icon: LinkExternalIcon,
622
- iconFallback: OpenIcon,
618
+ iconFallback: LinkExternalIcon,
623
619
  metadata: metadata,
624
620
  className: 'hyperlink-open-link',
625
621
  title: intl.formatMessage(linkMessages.openLink),
@@ -652,7 +648,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
652
648
  type: 'button',
653
649
  appearance: 'danger',
654
650
  icon: DeleteIcon,
655
- iconFallback: RemoveIcon,
651
+ iconFallback: DeleteIcon,
656
652
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
657
653
  onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
658
654
  onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
@@ -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
  };
@@ -17,7 +17,7 @@ import debounce from 'lodash/debounce';
17
17
  import { useIntl } from 'react-intl-next';
18
18
  import { cardMessages as messages } from '@atlaskit/editor-common/messages';
19
19
  import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace';
20
- import CustomizeIcon from '@atlaskit/icon/core/migration/customize--preferences';
20
+ import CustomizeIcon from '@atlaskit/icon/core/customize';
21
21
  import { B100, N0, N700 } from '@atlaskit/theme/colors';
22
22
  import { getChildElement, getIconSize, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
23
23
  var DEBOUNCE_IN_MS = 5;
@@ -14,8 +14,8 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
14
14
  import { Popup } from '@atlaskit/editor-common/ui';
15
15
  import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
16
16
  import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
17
- import GrowHorizontalIcon from '@atlaskit/icon/core/migration/grow-horizontal--editor-expand';
18
- import ShrinkHorizontalIcon from '@atlaskit/icon/core/migration/shrink-horizontal--editor-collapse';
17
+ import GrowHorizontalIcon from '@atlaskit/icon/core/grow-horizontal';
18
+ import ShrinkHorizontalIcon from '@atlaskit/icon/core/shrink-horizontal';
19
19
  import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
20
20
  import { B300, N20A, N300 } from '@atlaskit/theme/colors';
21
21
  import { setCardLayout } from '../../pm-plugins/actions';
@@ -21,11 +21,7 @@ import EditIcon from '@atlaskit/icon/core/edit';
21
21
  import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
22
22
  import LinkExternalIcon from '@atlaskit/icon/core/link-external';
23
23
  import LegacyCommentIcon from '@atlaskit/icon/core/migration/comment';
24
- import RemoveIcon from '@atlaskit/icon/core/migration/delete--editor-remove';
25
- import UnlinkIcon from '@atlaskit/icon/core/migration/link-broken--editor-unlink';
26
- import OpenIcon from '@atlaskit/icon/core/migration/link-external--shortcut';
27
- import CogIcon from '@atlaskit/icon/core/migration/settings--editor-settings';
28
- import SettingsIcon from '@atlaskit/icon/core/settings';
24
+ import CogIcon from '@atlaskit/icon/core/settings';
29
25
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
30
26
  import { changeSelectedCardToText } from '../pm-plugins/doc';
31
27
  import { pluginKey } from '../pm-plugins/plugin-key';
@@ -342,7 +338,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
342
338
  id: 'editor.link.openLink',
343
339
  type: 'button',
344
340
  icon: LinkExternalIcon,
345
- iconFallback: OpenIcon,
341
+ iconFallback: LinkExternalIcon,
346
342
  metadata: metadata,
347
343
  className: 'hyperlink-open-link',
348
344
  title: intl.formatMessage(linkMessages.openLink),
@@ -368,7 +364,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
368
364
  type: 'button',
369
365
  appearance: 'danger',
370
366
  icon: DeleteIcon,
371
- iconFallback: RemoveIcon,
367
+ iconFallback: DeleteIcon,
372
368
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
373
369
  onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
374
370
  onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
@@ -382,7 +378,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
382
378
  id: 'editor.link.openLink',
383
379
  type: 'button',
384
380
  icon: LinkExternalIcon,
385
- iconFallback: OpenIcon,
381
+ iconFallback: LinkExternalIcon,
386
382
  metadata: metadata,
387
383
  className: 'hyperlink-open-link',
388
384
  title: intl.formatMessage(linkMessages.openLink),
@@ -510,7 +506,7 @@ var getUnlinkButtonGroup = function getUnlinkButtonGroup(state, intl, node, inli
510
506
  type: 'button',
511
507
  title: intl.formatMessage(linkToolbarMessages.unlink),
512
508
  icon: LinkBrokenIcon,
513
- iconFallback: UnlinkIcon,
509
+ iconFallback: LinkBrokenIcon,
514
510
  onClick: withToolbarMetadata(unlinkCard(node, state, editorAnalyticsApi))
515
511
  }].concat(_toConsumableArray(areAnyNewToolbarFlagsEnabled ? [] : [{
516
512
  type: 'separator'
@@ -520,7 +516,7 @@ export var getSettingsButton = function getSettingsButton(intl, editorAnalyticsA
520
516
  return {
521
517
  id: 'editor.link.settings',
522
518
  type: 'button',
523
- icon: SettingsIcon,
519
+ icon: CogIcon,
524
520
  iconFallback: CogIcon,
525
521
  title: intl.formatMessage(linkToolbarMessages.settingsLink),
526
522
  onClick: openLinkSettings(editorAnalyticsApi),
@@ -625,7 +621,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
625
621
  id: 'editor.link.openLink',
626
622
  type: 'button',
627
623
  icon: LinkExternalIcon,
628
- iconFallback: OpenIcon,
624
+ iconFallback: LinkExternalIcon,
629
625
  metadata: metadata,
630
626
  className: 'hyperlink-open-link',
631
627
  title: intl.formatMessage(linkMessages.openLink),
@@ -658,7 +654,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
658
654
  type: 'button',
659
655
  appearance: 'danger',
660
656
  icon: DeleteIcon,
661
- iconFallback: RemoveIcon,
657
+ iconFallback: DeleteIcon,
662
658
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
663
659
  onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
664
660
  onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
@@ -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
@@ -8,5 +8,5 @@ type PreviewInvokerProps = {
8
8
  }) => ReactNode;
9
9
  url: string;
10
10
  };
11
- export declare const PreviewInvoker: ({ url, appearance, children }: PreviewInvokerProps) => React.JSX.Element;
11
+ export declare const PreviewInvoker: ({ url, appearance, children, }: PreviewInvokerProps) => React.JSX.Element;
12
12
  export {};
@@ -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
@@ -8,5 +8,5 @@ type PreviewInvokerProps = {
8
8
  }) => ReactNode;
9
9
  url: string;
10
10
  };
11
- export declare const PreviewInvoker: ({ url, appearance, children }: PreviewInvokerProps) => React.JSX.Element;
11
+ export declare const PreviewInvoker: ({ url, appearance, children, }: PreviewInvokerProps) => React.JSX.Element;
12
12
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "11.5.11",
3
+ "version": "11.5.13",
4
4
  "description": "Card 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.5.1",
32
+ "@atlaskit/adf-schema": "^51.5.0",
33
33
  "@atlaskit/analytics-next": "^11.1.0",
34
34
  "@atlaskit/custom-steps": "^0.16.0",
35
35
  "@atlaskit/editor-plugin-analytics": "^6.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
- "@atlaskit/editor-prosemirror": "7.0.0",
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.0.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.14.0",
62
+ "@atlaskit/smart-card": "^43.17.0",
63
63
  "@atlaskit/theme": "^21.0.0",
64
- "@atlaskit/tmp-editor-statsig": "^15.0.0",
65
- "@atlaskit/tokens": "^8.4.0",
64
+ "@atlaskit/tmp-editor-statsig": "^15.16.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.40.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"