@atlaskit/editor-plugin-card 2.4.1 → 2.5.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 CHANGED
@@ -1,5 +1,38 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 2.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#119135](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/119135)
8
+ [`a4a41c5e54071`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a4a41c5e54071) -
9
+ Allow smart links to navigate in live pages edit view
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 2.4.4
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
21
+ ## 2.4.3
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies
26
+
27
+ ## 2.4.2
28
+
29
+ ### Patch Changes
30
+
31
+ - [#117973](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117973)
32
+ [`6e37bac62083f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6e37bac62083f) -
33
+ moved one const, added new entry point for other and deprecated
34
+ - Updated dependencies
35
+
3
36
  ## 2.4.1
4
37
 
5
38
  ### Patch Changes
@@ -45,6 +45,19 @@ var WithClickHandler = function WithClickHandler(_ref) {
45
45
  } catch (_unused) {}
46
46
  }
47
47
  }, [url, onClickCallback]);
48
+ if ((0, _platformFeatureFlags.fg)('platform.linking-platform.smart-links-in-live-pages')) {
49
+ /**
50
+ * @todo: Add a check to determine if we're currently in a live page once ED-23920 and plugin
51
+ * is complete. The logic for which should allow navigation if we're in a live page and no callback
52
+ * has been provided. E.g.
53
+ *
54
+ * const allowNavigation = isLivePage && !onClickCallback;
55
+ */
56
+ var _allowNavigation = !onClickCallback;
57
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children({
58
+ onClick: _allowNavigation ? undefined : onClick
59
+ }));
60
+ }
48
61
 
49
62
  // Setting `onClick` to `undefined` ensures clicks on smartcards navigate to the URL.
50
63
  // If in view mode and not overriding with onClickCallback option, then allow smartlinks to navigate on click.
@@ -68,7 +81,6 @@ function Card(SmartCardComponent, UnsupportedComponent) {
68
81
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
69
82
  isError: false
70
83
  });
71
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClick", function () {});
72
84
  return _this;
73
85
  }
74
86
  (0, _createClass2.default)(_class, [{
@@ -107,7 +119,7 @@ function Card(SmartCardComponent, UnsupportedComponent) {
107
119
  // Below is added for the future implementation of Linking Platform namespaced analytics context
108
120
  location: analyticsEditorAppearance
109
121
  }
110
- }, (0, _platformFeatureFlags.fg)('platform.linking-platform.smart-card.on-click-callback') ? /*#__PURE__*/_react.default.createElement(WithClickHandler, {
122
+ }, /*#__PURE__*/_react.default.createElement(WithClickHandler, {
111
123
  pluginInjectionApi: pluginInjectionApi,
112
124
  onClickCallback: onClickCallback,
113
125
  url: url
@@ -119,12 +131,7 @@ function Card(SmartCardComponent, UnsupportedComponent) {
119
131
  }, _this2.props, {
120
132
  onClick: onClick
121
133
  }));
122
- }) : /*#__PURE__*/_react.default.createElement(SmartCardComponent, (0, _extends2.default)({
123
- key: url,
124
- cardContext: cardContext
125
- }, this.props, {
126
- onClick: this.onClick
127
- })));
134
+ }));
128
135
  }
129
136
  }, {
130
137
  key: "componentDidCatch",
@@ -15,10 +15,10 @@ var _react2 = require("@emotion/react");
15
15
  var _debounce = _interopRequireDefault(require("lodash/debounce"));
16
16
  var _reactIntlNext = require("react-intl-next");
17
17
  var _messages = require("@atlaskit/editor-common/messages");
18
- var _utils = require("@atlaskit/editor-common/utils");
18
+ var _whitespace = require("@atlaskit/editor-common/whitespace");
19
19
  var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferences"));
20
20
  var _colors = require("@atlaskit/theme/colors");
21
- var _utils2 = require("./utils");
21
+ var _utils = require("./utils");
22
22
  var _excluded = ["children", "isSelected", "isVisible", "testId", "url"];
23
23
  var _active;
24
24
  /* eslint-disable @atlaskit/design-system/no-nested-styles */
@@ -140,17 +140,17 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
140
140
  if (!containerRef.current || !maxOverlayWidth.current) {
141
141
  return;
142
142
  }
143
- var marker = (0, _utils2.getChildElement)(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
143
+ var marker = (0, _utils.getChildElement)(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
144
144
  if (!marker) {
145
145
  return;
146
146
  }
147
147
  try {
148
- var oneLine = (0, _utils2.isOneLine)(containerRef.current, marker);
148
+ var oneLine = (0, _utils.isOneLine)(containerRef.current, marker);
149
149
 
150
150
  // Get the width of the available space to display overlay.
151
151
  // This is the width of the inline link itself. If the inline
152
152
  // is wrapped to the next line, this is width of the last line.
153
- var _availableWidth = (0, _utils2.getInlineCardAvailableWidth)(containerRef.current, marker) - PADDING_IN_PX - (
153
+ var _availableWidth = (0, _utils.getInlineCardAvailableWidth)(containerRef.current, marker) - PADDING_IN_PX - (
154
154
  // Always leave at least the icon visible
155
155
  oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
156
156
  setAvailableWidth(_availableWidth);
@@ -175,16 +175,16 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
175
175
 
176
176
  // This should run only once
177
177
  if (!maxOverlayWidth.current) {
178
- var iconAndLabel = (0, _utils2.getChildElement)(containerRef, ".".concat(ICON_AND_LABEL_CLASSNAME));
179
- var _label = (0, _utils2.getChildElement)(containerRef, ".".concat(OVERLAY_LABEL_CLASSNAME));
178
+ var iconAndLabel = (0, _utils.getChildElement)(containerRef, ".".concat(ICON_AND_LABEL_CLASSNAME));
179
+ var _label = (0, _utils.getChildElement)(containerRef, ".".concat(OVERLAY_LABEL_CLASSNAME));
180
180
  if (iconAndLabel && _label) {
181
181
  // Set overlay max (label + icon) and min (icon only) width.
182
- var _getOverlayWidths = (0, _utils2.getOverlayWidths)(iconAndLabel, _label),
182
+ var _getOverlayWidths = (0, _utils.getOverlayWidths)(iconAndLabel, _label),
183
183
  max = _getOverlayWidths.max,
184
184
  min = _getOverlayWidths.min;
185
185
  maxOverlayWidth.current = max;
186
186
  minOverlayWidth.current = min;
187
- iconSize.current = (0, _utils2.getIconSize)(_label);
187
+ iconSize.current = (0, _utils.getIconSize)(_label);
188
188
  }
189
189
  }
190
190
  if (isVisible) {
@@ -230,7 +230,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
230
230
  }), children, isVisible && (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("span", {
231
231
  "aria-hidden": "true",
232
232
  className: OVERLAY_MARKER_CLASSNAME
233
- }, _utils.ZERO_WIDTH_JOINER), (0, _react2.jsx)("a", {
233
+ }, _whitespace.ZERO_WIDTH_JOINER), (0, _react2.jsx)("a", {
234
234
  css: [overlayStyles, showOverlay && showOverlayStyles],
235
235
  style: {
236
236
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
@@ -14,11 +14,11 @@ var _react2 = require("@emotion/react");
14
14
  var _debounce = _interopRequireDefault(require("lodash/debounce"));
15
15
  var _reactIntlNext = require("react-intl-next");
16
16
  var _messages = require("@atlaskit/editor-common/messages");
17
- var _utils = require("@atlaskit/editor-common/utils");
17
+ var _whitespace = require("@atlaskit/editor-common/whitespace");
18
18
  var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferences"));
19
19
  var _colors = require("@atlaskit/theme/colors");
20
20
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
21
- var _utils2 = require("../InlineCardOverlay/utils");
21
+ var _utils = require("../InlineCardOverlay/utils");
22
22
  var _excluded = ["children", "isSelected", "isVisible", "testId"];
23
23
  /* eslint-disable @atlaskit/design-system/no-nested-styles */
24
24
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
@@ -114,17 +114,17 @@ var LeftIconOverlay = function LeftIconOverlay(_ref) {
114
114
  if (!containerRef.current) {
115
115
  return;
116
116
  }
117
- var marker = (0, _utils2.getChildElement)(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
117
+ var marker = (0, _utils.getChildElement)(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
118
118
  if (!marker) {
119
119
  return;
120
120
  }
121
121
  try {
122
- var oneLine = (0, _utils2.isOneLine)(containerRef.current, marker);
122
+ var oneLine = (0, _utils.isOneLine)(containerRef.current, marker);
123
123
 
124
124
  // Get the width of the available space to display overlay.
125
125
  // This is the width of the inline link itself. If the inline
126
126
  // is wrapped to the next line, this is width of the last line.
127
- var _availableWidth = (0, _utils2.getInlineCardAvailableWidth)(containerRef.current, marker) - PADDING_IN_PX - (
127
+ var _availableWidth = (0, _utils.getInlineCardAvailableWidth)(containerRef.current, marker) - PADDING_IN_PX - (
128
128
  // Always leave at least the icon visible
129
129
  oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
130
130
  setAvailableWidth(_availableWidth);
@@ -178,7 +178,7 @@ var LeftIconOverlay = function LeftIconOverlay(_ref) {
178
178
  return (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("span", {
179
179
  "aria-hidden": "true",
180
180
  className: OVERLAY_MARKER_CLASSNAME
181
- }, _utils.ZERO_WIDTH_JOINER), (0, _react2.jsx)("span", {
181
+ }, _whitespace.ZERO_WIDTH_JOINER), (0, _react2.jsx)("span", {
182
182
  css: [overlayStyles, showOverlay && showOverlayStyles],
183
183
  tabIndex: -1,
184
184
  "data-testid": testId
@@ -29,6 +29,19 @@ const WithClickHandler = ({
29
29
  } catch {}
30
30
  }
31
31
  }, [url, onClickCallback]);
32
+ if (fg('platform.linking-platform.smart-links-in-live-pages')) {
33
+ /**
34
+ * @todo: Add a check to determine if we're currently in a live page once ED-23920 and plugin
35
+ * is complete. The logic for which should allow navigation if we're in a live page and no callback
36
+ * has been provided. E.g.
37
+ *
38
+ * const allowNavigation = isLivePage && !onClickCallback;
39
+ */
40
+ const allowNavigation = !onClickCallback;
41
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children({
42
+ onClick: allowNavigation ? undefined : onClick
43
+ }));
44
+ }
32
45
 
33
46
  // Setting `onClick` to `undefined` ensures clicks on smartcards navigate to the URL.
34
47
  // If in view mode and not overriding with onClickCallback option, then allow smartlinks to navigate on click.
@@ -45,7 +58,6 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
45
58
  _defineProperty(this, "state", {
46
59
  isError: false
47
60
  });
48
- _defineProperty(this, "onClick", () => {});
49
61
  }
50
62
  render() {
51
63
  var _getPluginState;
@@ -82,7 +94,7 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
82
94
  // Below is added for the future implementation of Linking Platform namespaced analytics context
83
95
  location: analyticsEditorAppearance
84
96
  }
85
- }, fg('platform.linking-platform.smart-card.on-click-callback') ? /*#__PURE__*/React.createElement(WithClickHandler, {
97
+ }, /*#__PURE__*/React.createElement(WithClickHandler, {
86
98
  pluginInjectionApi: pluginInjectionApi,
87
99
  onClickCallback: onClickCallback,
88
100
  url: url
@@ -93,12 +105,7 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
93
105
  cardContext: cardContext
94
106
  }, this.props, {
95
107
  onClick: onClick
96
- }))) : /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
97
- key: url,
98
- cardContext: cardContext
99
- }, this.props, {
100
- onClick: this.onClick
101
- })));
108
+ }))));
102
109
  }
103
110
  componentDidCatch(error) {
104
111
  const maybeAPIError = error;
@@ -9,7 +9,7 @@ import { css, jsx } from '@emotion/react';
9
9
  import debounce from 'lodash/debounce';
10
10
  import { useIntl } from 'react-intl-next';
11
11
  import { cardMessages as messages } from '@atlaskit/editor-common/messages';
12
- import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/utils';
12
+ import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace';
13
13
  import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
14
14
  import { B100, N0, N700 } from '@atlaskit/theme/colors';
15
15
  import { getChildElement, getIconSize, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
@@ -9,7 +9,7 @@ import { css, jsx } from '@emotion/react';
9
9
  import debounce from 'lodash/debounce';
10
10
  import { useIntl } from 'react-intl-next';
11
11
  import { cardMessages as messages } from '@atlaskit/editor-common/messages';
12
- import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/utils';
12
+ import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace';
13
13
  import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
14
14
  import { N0, N30A, N40A, N60A, N700 } from '@atlaskit/theme/colors';
15
15
  import Tooltip from '@atlaskit/tooltip';
@@ -35,6 +35,19 @@ var WithClickHandler = function WithClickHandler(_ref) {
35
35
  } catch (_unused) {}
36
36
  }
37
37
  }, [url, onClickCallback]);
38
+ if (fg('platform.linking-platform.smart-links-in-live-pages')) {
39
+ /**
40
+ * @todo: Add a check to determine if we're currently in a live page once ED-23920 and plugin
41
+ * is complete. The logic for which should allow navigation if we're in a live page and no callback
42
+ * has been provided. E.g.
43
+ *
44
+ * const allowNavigation = isLivePage && !onClickCallback;
45
+ */
46
+ var _allowNavigation = !onClickCallback;
47
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children({
48
+ onClick: _allowNavigation ? undefined : onClick
49
+ }));
50
+ }
38
51
 
39
52
  // Setting `onClick` to `undefined` ensures clicks on smartcards navigate to the URL.
40
53
  // If in view mode and not overriding with onClickCallback option, then allow smartlinks to navigate on click.
@@ -58,7 +71,6 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
58
71
  _defineProperty(_assertThisInitialized(_this), "state", {
59
72
  isError: false
60
73
  });
61
- _defineProperty(_assertThisInitialized(_this), "onClick", function () {});
62
74
  return _this;
63
75
  }
64
76
  _createClass(_class, [{
@@ -97,7 +109,7 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
97
109
  // Below is added for the future implementation of Linking Platform namespaced analytics context
98
110
  location: analyticsEditorAppearance
99
111
  }
100
- }, fg('platform.linking-platform.smart-card.on-click-callback') ? /*#__PURE__*/React.createElement(WithClickHandler, {
112
+ }, /*#__PURE__*/React.createElement(WithClickHandler, {
101
113
  pluginInjectionApi: pluginInjectionApi,
102
114
  onClickCallback: onClickCallback,
103
115
  url: url
@@ -109,12 +121,7 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
109
121
  }, _this2.props, {
110
122
  onClick: onClick
111
123
  }));
112
- }) : /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
113
- key: url,
114
- cardContext: cardContext
115
- }, this.props, {
116
- onClick: this.onClick
117
- })));
124
+ }));
118
125
  }
119
126
  }, {
120
127
  key: "componentDidCatch",
@@ -14,7 +14,7 @@ import { css, jsx } from '@emotion/react';
14
14
  import debounce from 'lodash/debounce';
15
15
  import { useIntl } from 'react-intl-next';
16
16
  import { cardMessages as messages } from '@atlaskit/editor-common/messages';
17
- import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/utils';
17
+ import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace';
18
18
  import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
19
19
  import { B100, N0, N700 } from '@atlaskit/theme/colors';
20
20
  import { getChildElement, getIconSize, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
@@ -12,7 +12,7 @@ import { css, jsx } from '@emotion/react';
12
12
  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
- import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/utils';
15
+ import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace';
16
16
  import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
17
17
  import { N0, N30A, N40A, N60A, N700 } from '@atlaskit/theme/colors';
18
18
  import Tooltip from '@atlaskit/tooltip';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,10 +34,10 @@
34
34
  "dependencies": {
35
35
  "@atlaskit/adf-schema": "^39.0.3",
36
36
  "@atlaskit/analytics-next": "^9.3.0",
37
- "@atlaskit/button": "^18.1.0",
37
+ "@atlaskit/button": "^18.3.0",
38
38
  "@atlaskit/custom-steps": "^0.4.0",
39
39
  "@atlaskit/dropdown-menu": "^12.14.0",
40
- "@atlaskit/editor-common": "^84.0.0",
40
+ "@atlaskit/editor-common": "^84.4.0",
41
41
  "@atlaskit/editor-plugin-analytics": "^1.4.0",
42
42
  "@atlaskit/editor-plugin-decorations": "^1.1.0",
43
43
  "@atlaskit/editor-plugin-editor-disabled": "^1.1.0",
@@ -47,17 +47,17 @@
47
47
  "@atlaskit/editor-plugin-grid": "^1.1.0",
48
48
  "@atlaskit/editor-plugin-width": "^1.1.0",
49
49
  "@atlaskit/editor-prosemirror": "4.0.1",
50
- "@atlaskit/editor-shared-styles": "^2.12.0",
50
+ "@atlaskit/editor-shared-styles": "^2.13.0",
51
51
  "@atlaskit/frontend-utilities": "^2.7.0",
52
- "@atlaskit/icon": "^22.5.0",
52
+ "@atlaskit/icon": "^22.6.0",
53
53
  "@atlaskit/link-analytics": "^8.3.0",
54
54
  "@atlaskit/link-client-extension": "^1.9.0",
55
55
  "@atlaskit/link-datasource": "^2.5.0",
56
56
  "@atlaskit/linking-common": "^5.7.0",
57
57
  "@atlaskit/linking-types": "^8.9.0",
58
- "@atlaskit/menu": "2.7.1",
58
+ "@atlaskit/menu": "2.7.4",
59
59
  "@atlaskit/platform-feature-flags": "^0.3.0",
60
- "@atlaskit/primitives": "^10.0.0",
60
+ "@atlaskit/primitives": "^11.0.0",
61
61
  "@atlaskit/smart-card": "^27.9.0",
62
62
  "@atlaskit/theme": "^12.11.0",
63
63
  "@atlaskit/tokens": "^1.53.0",
@@ -131,9 +131,6 @@
131
131
  "platform.editor.card.inject-settings-button": {
132
132
  "type": "boolean"
133
133
  },
134
- "platform.linking-platform.smart-card.on-click-callback": {
135
- "type": "boolean"
136
- },
137
134
  "platform.linking-platform.editor-datasource-typeguards": {
138
135
  "type": "boolean"
139
136
  },