@atlaskit/editor-plugin-card 1.12.0 → 1.13.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,23 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 1.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#98528](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98528)
8
+ [`12181f0bfaed`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/12181f0bfaed) -
9
+ EDM-9252 Removal of platform.linking-platform.smart-card.inline-switcher
10
+
11
+ ## 1.12.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [#99590](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99590)
16
+ [`b0670c3f10e6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b0670c3f10e6) -
17
+ Remove the displayedColumnCount key-value pair from attributes object entirely if it doesn't
18
+ exist for analytics
19
+ - Updated dependencies
20
+
3
21
  ## 1.12.0
4
22
 
5
23
  ### Minor Changes
@@ -4,126 +4,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.InlineCardComponent = void 0;
8
7
  exports.InlineCardNodeView = InlineCardNodeView;
9
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
13
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
15
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
9
  var _react = _interopRequireDefault(require("react"));
18
- var _propTypes = _interopRequireDefault(require("prop-types"));
19
- var _rafSchd = _interopRequireDefault(require("raf-schd"));
20
10
  var _ui = require("@atlaskit/editor-common/ui");
21
11
  var _state = require("@atlaskit/editor-prosemirror/state");
22
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
23
- var _smartCard = require("@atlaskit/smart-card");
24
- var _actions = require("../pm-plugins/actions");
25
12
  var _utils = require("../utils");
26
13
  var _genericCard = require("./genericCard");
27
14
  var _inlineCardWithAwareness = require("./inlineCardWithAwareness");
28
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
29
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
30
- // eslint-disable-next-line @repo/internal/react/no-class-components
31
- var InlineCardComponent = exports.InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
32
- (0, _inherits2.default)(InlineCardComponent, _React$PureComponent);
33
- var _super = _createSuper(InlineCardComponent);
34
- function InlineCardComponent() {
35
- var _this;
36
- (0, _classCallCheck2.default)(this, InlineCardComponent);
37
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
38
- args[_key] = arguments[_key];
39
- }
40
- _this = _super.call.apply(_super, [this].concat(args));
41
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onResolve", function (data) {
42
- var _this$props = _this.props,
43
- getPos = _this$props.getPos,
44
- view = _this$props.view;
45
- if (!getPos || typeof getPos === 'boolean') {
46
- return;
47
- }
48
- var title = data.title,
49
- url = data.url;
50
- // don't dispatch immediately since we might be in the middle of
51
- // rendering a nodeview
52
- (0, _rafSchd.default)(function () {
53
- // prosemirror-bump-fix
54
- var pos = getPos();
55
- if (typeof pos !== 'number') {
56
- return;
57
- }
58
- var tr = view.state.tr;
59
- (0, _actions.registerCard)({
60
- title: title,
61
- url: url,
62
- pos: pos
63
- })(tr);
64
- view.dispatch(tr);
65
- })();
66
- });
67
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onError", function (data) {
68
- var url = data.url,
69
- err = data.err;
70
- if (err) {
71
- throw err;
72
- }
73
- _this.onResolve({
74
- url: url
75
- });
76
- });
77
- return _this;
78
- }
79
- (0, _createClass2.default)(InlineCardComponent, [{
80
- key: "UNSAFE_componentWillMount",
81
- value: function UNSAFE_componentWillMount() {
82
- var view = this.props.view;
83
- var scrollContainer = (0, _ui.findOverflowScrollParent)(view.dom);
84
- this.scrollContainer = scrollContainer || undefined;
85
- }
86
- }, {
87
- key: "render",
88
- value: function render() {
89
- var _this$props2 = this.props,
90
- node = _this$props2.node,
91
- cardContext = _this$props2.cardContext,
92
- actionOptions = _this$props2.actionOptions,
93
- showServerActions = _this$props2.showServerActions,
94
- useAlternativePreloader = _this$props2.useAlternativePreloader,
95
- onClick = _this$props2.onClick;
96
- var _node$attrs = node.attrs,
97
- url = _node$attrs.url,
98
- data = _node$attrs.data;
99
- var card = /*#__PURE__*/_react.default.createElement("span", {
100
- className: "card"
101
- }, /*#__PURE__*/_react.default.createElement(_smartCard.Card, {
102
- key: url,
103
- url: url,
104
- data: data,
105
- appearance: "inline",
106
- onClick: onClick,
107
- container: this.scrollContainer,
108
- onResolve: this.onResolve,
109
- onError: this.onError,
110
- inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
111
- actionOptions: actionOptions,
112
- showServerActions: showServerActions
113
- }));
114
- // [WS-2307]: we only render card wrapped into a Provider when the value is ready,
115
- // otherwise if we got data, we can render the card directly since it doesn't need the Provider
116
- return cardContext && cardContext.value ? /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
117
- value: cardContext.value
118
- }, card) : data ? card : null;
119
- }
120
- }]);
121
- return InlineCardComponent;
122
- }(_react.default.PureComponent);
123
- (0, _defineProperty2.default)(InlineCardComponent, "contextTypes", {
124
- contextAdapter: _propTypes.default.object
125
- });
126
- var WrappedInlineCard = (0, _genericCard.Card)(InlineCardComponent, _ui.UnsupportedInline);
127
15
  var WrappedInlineCardWithAwareness = (0, _genericCard.Card)(_inlineCardWithAwareness.InlineCardWithAwareness, _ui.UnsupportedInline);
128
16
  function InlineCardNodeView(props) {
129
17
  var useAlternativePreloader = props.useAlternativePreloader,
@@ -137,18 +25,6 @@ function InlineCardNodeView(props) {
137
25
  enableInlineUpgradeFeatures = props.enableInlineUpgradeFeatures,
138
26
  pluginInjectionApi = props.pluginInjectionApi,
139
27
  onClickCallback = props.onClickCallback;
140
- if (!(0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.inline-switcher')) {
141
- return /*#__PURE__*/_react.default.createElement(WrappedInlineCard, {
142
- node: node,
143
- view: view,
144
- getPos: getPos,
145
- actionOptions: actionOptions,
146
- showServerActions: showServerActions,
147
- useAlternativePreloader: useAlternativePreloader,
148
- pluginInjectionApi: pluginInjectionApi,
149
- onClickCallback: onClickCallback
150
- });
151
- }
152
28
  return /*#__PURE__*/_react.default.createElement(WrappedInlineCardWithAwareness, (0, _extends2.default)({
153
29
  node: node,
154
30
  view: view,
@@ -62,7 +62,6 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
62
62
  allowBlockCards = options.allowBlockCards,
63
63
  onClickCallback = options.onClickCallback;
64
64
  var enableInlineUpgradeFeatures = !!showUpgradeDiscoverability && platform !== 'mobile';
65
- var shouldUseUpgradeFeatures = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.inline-switcher') && enableInlineUpgradeFeatures;
66
65
  var inlineCardViewProducer = (0, _reactNodeView.getInlineNodeViewProducer)({
67
66
  pmPluginFactoryParams: pmPluginFactoryParams,
68
67
  Component: _inlineCard.InlineCardNodeView,
@@ -119,7 +118,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
119
118
  if (!meta) {
120
119
  return pluginStateWithUpdatedPos;
121
120
  }
122
- if (!shouldUseUpgradeFeatures) {
121
+ if (!enableInlineUpgradeFeatures) {
123
122
  return (0, _reducers.default)(pluginStateWithUpdatedPos, meta);
124
123
  }
125
124
  var newState = (0, _reducers.default)(pluginStateWithUpdatedPos, meta);
@@ -283,7 +282,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
283
282
  return new _embedCard.EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
284
283
  }
285
284
  }
286
- }, shouldUseUpgradeFeatures && {
285
+ }, enableInlineUpgradeFeatures && {
287
286
  handleKeyDown: function handleKeyDown(view) {
288
287
  handleAwarenessOverlay(view);
289
288
  return false;
@@ -494,5 +494,5 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
494
494
  return toolbarItems;
495
495
  };
496
496
  var shouldRenderToolbarPulse = exports.shouldRenderToolbarPulse = function shouldRenderToolbarPulse(embedEnabled, appearance, status, isDiscoverabilityEnabled) {
497
- return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.inline-switcher');
497
+ return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled;
498
498
  };
@@ -15,13 +15,15 @@ var _common = require("./common");
15
15
  var _excluded = ["node", "nodeContext"],
16
16
  _excluded2 = ["node", "nodeContext"],
17
17
  _excluded3 = ["node", "nodeContext"];
18
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
20
  function getDatasourceDisplay(datasourceAttrs) {
19
21
  var _datasourceAttrs$data;
20
22
  return (_datasourceAttrs$data = datasourceAttrs.datasource.views[0]) === null || _datasourceAttrs$data === void 0 ? void 0 : _datasourceAttrs$data.type;
21
23
  }
22
24
  function getDisplayedColumnCount(datasourceAttrs) {
23
25
  var _datasourceAttrs$data2, _datasourceAttrs$data3;
24
- return (_datasourceAttrs$data2 = (_datasourceAttrs$data3 = datasourceAttrs.datasource.views[0]) === null || _datasourceAttrs$data3 === void 0 || (_datasourceAttrs$data3 = _datasourceAttrs$data3.properties) === null || _datasourceAttrs$data3 === void 0 || (_datasourceAttrs$data3 = _datasourceAttrs$data3.columns) === null || _datasourceAttrs$data3 === void 0 ? void 0 : _datasourceAttrs$data3.length) !== null && _datasourceAttrs$data2 !== void 0 ? _datasourceAttrs$data2 : null;
26
+ return (_datasourceAttrs$data2 = (_datasourceAttrs$data3 = datasourceAttrs.datasource.views[0]) === null || _datasourceAttrs$data3 === void 0 || (_datasourceAttrs$data3 = _datasourceAttrs$data3.properties) === null || _datasourceAttrs$data3 === void 0 || (_datasourceAttrs$data3 = _datasourceAttrs$data3.columns) === null || _datasourceAttrs$data3 === void 0 ? void 0 : _datasourceAttrs$data3.length) !== null && _datasourceAttrs$data2 !== void 0 ? _datasourceAttrs$data2 : undefined;
25
27
  }
26
28
  function getSearchMethod(creationMethod, metadata) {
27
29
  if (creationMethod === 'editor_paste' || creationMethod === 'editor_type') {
@@ -94,14 +96,16 @@ var DatasourceEventsBinding = exports.DatasourceEventsBinding = function Datasou
94
96
  datasourceId: datasourceId,
95
97
  parameters: parameters,
96
98
  url: url
97
- }, null, {
99
+ }, null, _objectSpread(_objectSpread({
98
100
  actions: actions,
99
101
  creationMethod: inputMethod,
100
- display: display,
101
- displayedColumnCount: displayedColumnCount,
102
+ display: display
103
+ }, typeof displayedColumnCount === 'number' ? {
104
+ displayedColumnCount: displayedColumnCount
105
+ } : {}), {}, {
102
106
  nodeContext: nodeContext,
103
107
  searchMethod: searchMethod
104
- });
108
+ }));
105
109
  }), (0, _defineProperty2.default)(_ref5, _types.EVENT.UPDATED, function (_ref3) {
106
110
  var node = _ref3.node,
107
111
  nodeContext = _ref3.nodeContext,
@@ -1,109 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  import React from 'react';
4
- import PropTypes from 'prop-types';
5
- import rafSchedule from 'raf-schd';
6
- import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
3
+ import { UnsupportedInline } from '@atlaskit/editor-common/ui';
7
4
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
8
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
- import { Card as SmartCard } from '@atlaskit/smart-card';
10
- import { registerCard } from '../pm-plugins/actions';
11
5
  import { isBlockSupportedAtPosition, isEmbedSupportedAtPosition } from '../utils';
12
6
  import { Card } from './genericCard';
13
7
  import { InlineCardWithAwareness } from './inlineCardWithAwareness';
14
-
15
- // eslint-disable-next-line @repo/internal/react/no-class-components
16
- export class InlineCardComponent extends React.PureComponent {
17
- constructor(...args) {
18
- super(...args);
19
- _defineProperty(this, "onResolve", data => {
20
- const {
21
- getPos,
22
- view
23
- } = this.props;
24
- if (!getPos || typeof getPos === 'boolean') {
25
- return;
26
- }
27
- const {
28
- title,
29
- url
30
- } = data;
31
- // don't dispatch immediately since we might be in the middle of
32
- // rendering a nodeview
33
- rafSchedule(() => {
34
- // prosemirror-bump-fix
35
- const pos = getPos();
36
- if (typeof pos !== 'number') {
37
- return;
38
- }
39
- const tr = view.state.tr;
40
- registerCard({
41
- title,
42
- url,
43
- pos
44
- })(tr);
45
- view.dispatch(tr);
46
- })();
47
- });
48
- _defineProperty(this, "onError", data => {
49
- const {
50
- url,
51
- err
52
- } = data;
53
- if (err) {
54
- throw err;
55
- }
56
- this.onResolve({
57
- url
58
- });
59
- });
60
- }
61
- UNSAFE_componentWillMount() {
62
- const {
63
- view
64
- } = this.props;
65
- const scrollContainer = findOverflowScrollParent(view.dom);
66
- this.scrollContainer = scrollContainer || undefined;
67
- }
68
- render() {
69
- const {
70
- node,
71
- cardContext,
72
- actionOptions,
73
- showServerActions,
74
- useAlternativePreloader,
75
- onClick
76
- } = this.props;
77
- const {
78
- url,
79
- data
80
- } = node.attrs;
81
- const card = /*#__PURE__*/React.createElement("span", {
82
- className: "card"
83
- }, /*#__PURE__*/React.createElement(SmartCard, {
84
- key: url,
85
- url: url,
86
- data: data,
87
- appearance: "inline",
88
- onClick: onClick,
89
- container: this.scrollContainer,
90
- onResolve: this.onResolve,
91
- onError: this.onError,
92
- inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
93
- actionOptions: actionOptions,
94
- showServerActions: showServerActions
95
- }));
96
- // [WS-2307]: we only render card wrapped into a Provider when the value is ready,
97
- // otherwise if we got data, we can render the card directly since it doesn't need the Provider
98
- return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
99
- value: cardContext.value
100
- }, card) : data ? card : null;
101
- }
102
- }
103
- _defineProperty(InlineCardComponent, "contextTypes", {
104
- contextAdapter: PropTypes.object
105
- });
106
- const WrappedInlineCard = Card(InlineCardComponent, UnsupportedInline);
107
8
  const WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
108
9
  export function InlineCardNodeView(props) {
109
10
  const {
@@ -119,18 +20,6 @@ export function InlineCardNodeView(props) {
119
20
  pluginInjectionApi,
120
21
  onClickCallback
121
22
  } = props;
122
- if (!getBooleanFF('platform.linking-platform.smart-card.inline-switcher')) {
123
- return /*#__PURE__*/React.createElement(WrappedInlineCard, {
124
- node: node,
125
- view: view,
126
- getPos: getPos,
127
- actionOptions: actionOptions,
128
- showServerActions: showServerActions,
129
- useAlternativePreloader: useAlternativePreloader,
130
- pluginInjectionApi: pluginInjectionApi,
131
- onClickCallback: onClickCallback
132
- });
133
- }
134
23
  return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
135
24
  node: node,
136
25
  view: view,
@@ -47,7 +47,6 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
47
47
  onClickCallback
48
48
  } = options;
49
49
  const enableInlineUpgradeFeatures = !!showUpgradeDiscoverability && platform !== 'mobile';
50
- const shouldUseUpgradeFeatures = getBooleanFF('platform.linking-platform.smart-card.inline-switcher') && enableInlineUpgradeFeatures;
51
50
  const inlineCardViewProducer = getInlineNodeViewProducer({
52
51
  pmPluginFactoryParams,
53
52
  Component: InlineCardNodeView,
@@ -105,7 +104,7 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
105
104
  if (!meta) {
106
105
  return pluginStateWithUpdatedPos;
107
106
  }
108
- if (!shouldUseUpgradeFeatures) {
107
+ if (!enableInlineUpgradeFeatures) {
109
108
  return reducer(pluginStateWithUpdatedPos, meta);
110
109
  }
111
110
  const newState = reducer(pluginStateWithUpdatedPos, meta);
@@ -277,7 +276,7 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
277
276
  return new EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
278
277
  }
279
278
  },
280
- ...(shouldUseUpgradeFeatures && {
279
+ ...(enableInlineUpgradeFeatures && {
281
280
  handleKeyDown: view => {
282
281
  handleAwarenessOverlay(view);
283
282
  return false;
@@ -487,5 +487,5 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
487
487
  return toolbarItems;
488
488
  };
489
489
  export const shouldRenderToolbarPulse = (embedEnabled, appearance, status, isDiscoverabilityEnabled) => {
490
- return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled && getBooleanFF('platform.linking-platform.smart-card.inline-switcher');
490
+ return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled;
491
491
  };
@@ -9,7 +9,7 @@ function getDatasourceDisplay(datasourceAttrs) {
9
9
  }
10
10
  function getDisplayedColumnCount(datasourceAttrs) {
11
11
  var _datasourceAttrs$data2, _datasourceAttrs$data3, _datasourceAttrs$data4, _datasourceAttrs$data5;
12
- return (_datasourceAttrs$data2 = (_datasourceAttrs$data3 = datasourceAttrs.datasource.views[0]) === null || _datasourceAttrs$data3 === void 0 ? void 0 : (_datasourceAttrs$data4 = _datasourceAttrs$data3.properties) === null || _datasourceAttrs$data4 === void 0 ? void 0 : (_datasourceAttrs$data5 = _datasourceAttrs$data4.columns) === null || _datasourceAttrs$data5 === void 0 ? void 0 : _datasourceAttrs$data5.length) !== null && _datasourceAttrs$data2 !== void 0 ? _datasourceAttrs$data2 : null;
12
+ return (_datasourceAttrs$data2 = (_datasourceAttrs$data3 = datasourceAttrs.datasource.views[0]) === null || _datasourceAttrs$data3 === void 0 ? void 0 : (_datasourceAttrs$data4 = _datasourceAttrs$data3.properties) === null || _datasourceAttrs$data4 === void 0 ? void 0 : (_datasourceAttrs$data5 = _datasourceAttrs$data4.columns) === null || _datasourceAttrs$data5 === void 0 ? void 0 : _datasourceAttrs$data5.length) !== null && _datasourceAttrs$data2 !== void 0 ? _datasourceAttrs$data2 : undefined;
13
13
  }
14
14
  function getSearchMethod(creationMethod, metadata) {
15
15
  if (creationMethod === 'editor_paste' || creationMethod === 'editor_type') {
@@ -96,8 +96,10 @@ export const DatasourceEventsBinding = ({
96
96
  actions,
97
97
  creationMethod: inputMethod,
98
98
  display,
99
- displayedColumnCount,
100
- nodeContext: nodeContext,
99
+ ...(typeof displayedColumnCount === 'number' ? {
100
+ displayedColumnCount
101
+ } : {}),
102
+ nodeContext,
101
103
  searchMethod
102
104
  });
103
105
  },
@@ -125,7 +127,7 @@ export const DatasourceEventsBinding = ({
125
127
  actions,
126
128
  display,
127
129
  displayedColumnCount,
128
- nodeContext: nodeContext,
130
+ nodeContext,
129
131
  searchMethod,
130
132
  updateMethod: inputMethod
131
133
  });
@@ -153,7 +155,7 @@ export const DatasourceEventsBinding = ({
153
155
  deleteMethod: inputMethod,
154
156
  display,
155
157
  displayedColumnCount,
156
- nodeContext: nodeContext,
158
+ nodeContext,
157
159
  searchMethod
158
160
  });
159
161
  }
@@ -1,122 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
2
  import React from 'react';
12
- import PropTypes from 'prop-types';
13
- import rafSchedule from 'raf-schd';
14
- import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
3
+ import { UnsupportedInline } from '@atlaskit/editor-common/ui';
15
4
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
16
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
17
- import { Card as SmartCard } from '@atlaskit/smart-card';
18
- import { registerCard } from '../pm-plugins/actions';
19
5
  import { isBlockSupportedAtPosition, isEmbedSupportedAtPosition } from '../utils';
20
6
  import { Card } from './genericCard';
21
7
  import { InlineCardWithAwareness } from './inlineCardWithAwareness';
22
-
23
- // eslint-disable-next-line @repo/internal/react/no-class-components
24
- export var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
25
- _inherits(InlineCardComponent, _React$PureComponent);
26
- var _super = _createSuper(InlineCardComponent);
27
- function InlineCardComponent() {
28
- var _this;
29
- _classCallCheck(this, InlineCardComponent);
30
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
31
- args[_key] = arguments[_key];
32
- }
33
- _this = _super.call.apply(_super, [this].concat(args));
34
- _defineProperty(_assertThisInitialized(_this), "onResolve", function (data) {
35
- var _this$props = _this.props,
36
- getPos = _this$props.getPos,
37
- view = _this$props.view;
38
- if (!getPos || typeof getPos === 'boolean') {
39
- return;
40
- }
41
- var title = data.title,
42
- url = data.url;
43
- // don't dispatch immediately since we might be in the middle of
44
- // rendering a nodeview
45
- rafSchedule(function () {
46
- // prosemirror-bump-fix
47
- var pos = getPos();
48
- if (typeof pos !== 'number') {
49
- return;
50
- }
51
- var tr = view.state.tr;
52
- registerCard({
53
- title: title,
54
- url: url,
55
- pos: pos
56
- })(tr);
57
- view.dispatch(tr);
58
- })();
59
- });
60
- _defineProperty(_assertThisInitialized(_this), "onError", function (data) {
61
- var url = data.url,
62
- err = data.err;
63
- if (err) {
64
- throw err;
65
- }
66
- _this.onResolve({
67
- url: url
68
- });
69
- });
70
- return _this;
71
- }
72
- _createClass(InlineCardComponent, [{
73
- key: "UNSAFE_componentWillMount",
74
- value: function UNSAFE_componentWillMount() {
75
- var view = this.props.view;
76
- var scrollContainer = findOverflowScrollParent(view.dom);
77
- this.scrollContainer = scrollContainer || undefined;
78
- }
79
- }, {
80
- key: "render",
81
- value: function render() {
82
- var _this$props2 = this.props,
83
- node = _this$props2.node,
84
- cardContext = _this$props2.cardContext,
85
- actionOptions = _this$props2.actionOptions,
86
- showServerActions = _this$props2.showServerActions,
87
- useAlternativePreloader = _this$props2.useAlternativePreloader,
88
- onClick = _this$props2.onClick;
89
- var _node$attrs = node.attrs,
90
- url = _node$attrs.url,
91
- data = _node$attrs.data;
92
- var card = /*#__PURE__*/React.createElement("span", {
93
- className: "card"
94
- }, /*#__PURE__*/React.createElement(SmartCard, {
95
- key: url,
96
- url: url,
97
- data: data,
98
- appearance: "inline",
99
- onClick: onClick,
100
- container: this.scrollContainer,
101
- onResolve: this.onResolve,
102
- onError: this.onError,
103
- inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
104
- actionOptions: actionOptions,
105
- showServerActions: showServerActions
106
- }));
107
- // [WS-2307]: we only render card wrapped into a Provider when the value is ready,
108
- // otherwise if we got data, we can render the card directly since it doesn't need the Provider
109
- return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
110
- value: cardContext.value
111
- }, card) : data ? card : null;
112
- }
113
- }]);
114
- return InlineCardComponent;
115
- }(React.PureComponent);
116
- _defineProperty(InlineCardComponent, "contextTypes", {
117
- contextAdapter: PropTypes.object
118
- });
119
- var WrappedInlineCard = Card(InlineCardComponent, UnsupportedInline);
120
8
  var WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
121
9
  export function InlineCardNodeView(props) {
122
10
  var useAlternativePreloader = props.useAlternativePreloader,
@@ -130,18 +18,6 @@ export function InlineCardNodeView(props) {
130
18
  enableInlineUpgradeFeatures = props.enableInlineUpgradeFeatures,
131
19
  pluginInjectionApi = props.pluginInjectionApi,
132
20
  onClickCallback = props.onClickCallback;
133
- if (!getBooleanFF('platform.linking-platform.smart-card.inline-switcher')) {
134
- return /*#__PURE__*/React.createElement(WrappedInlineCard, {
135
- node: node,
136
- view: view,
137
- getPos: getPos,
138
- actionOptions: actionOptions,
139
- showServerActions: showServerActions,
140
- useAlternativePreloader: useAlternativePreloader,
141
- pluginInjectionApi: pluginInjectionApi,
142
- onClickCallback: onClickCallback
143
- });
144
- }
145
21
  return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
146
22
  node: node,
147
23
  view: view,
@@ -50,7 +50,6 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
50
50
  allowBlockCards = options.allowBlockCards,
51
51
  onClickCallback = options.onClickCallback;
52
52
  var enableInlineUpgradeFeatures = !!showUpgradeDiscoverability && platform !== 'mobile';
53
- var shouldUseUpgradeFeatures = getBooleanFF('platform.linking-platform.smart-card.inline-switcher') && enableInlineUpgradeFeatures;
54
53
  var inlineCardViewProducer = getInlineNodeViewProducer({
55
54
  pmPluginFactoryParams: pmPluginFactoryParams,
56
55
  Component: InlineCardNodeView,
@@ -107,7 +106,7 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
107
106
  if (!meta) {
108
107
  return pluginStateWithUpdatedPos;
109
108
  }
110
- if (!shouldUseUpgradeFeatures) {
109
+ if (!enableInlineUpgradeFeatures) {
111
110
  return reducer(pluginStateWithUpdatedPos, meta);
112
111
  }
113
112
  var newState = reducer(pluginStateWithUpdatedPos, meta);
@@ -271,7 +270,7 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
271
270
  return new EmbedCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
272
271
  }
273
272
  }
274
- }, shouldUseUpgradeFeatures && {
273
+ }, enableInlineUpgradeFeatures && {
275
274
  handleKeyDown: function handleKeyDown(view) {
276
275
  handleAwarenessOverlay(view);
277
276
  return false;
@@ -484,5 +484,5 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
484
484
  return toolbarItems;
485
485
  };
486
486
  export var shouldRenderToolbarPulse = function shouldRenderToolbarPulse(embedEnabled, appearance, status, isDiscoverabilityEnabled) {
487
- return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled && getBooleanFF('platform.linking-platform.smart-card.inline-switcher');
487
+ return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled;
488
488
  };
@@ -3,6 +3,8 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
  var _excluded = ["node", "nodeContext"],
4
4
  _excluded2 = ["node", "nodeContext"],
5
5
  _excluded3 = ["node", "nodeContext"];
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
8
  import { useEffect, useMemo } from 'react';
7
9
  import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
8
10
  import { useDatasourceLifecycleAnalytics } from '@atlaskit/link-analytics';
@@ -14,7 +16,7 @@ function getDatasourceDisplay(datasourceAttrs) {
14
16
  }
15
17
  function getDisplayedColumnCount(datasourceAttrs) {
16
18
  var _datasourceAttrs$data2, _datasourceAttrs$data3;
17
- return (_datasourceAttrs$data2 = (_datasourceAttrs$data3 = datasourceAttrs.datasource.views[0]) === null || _datasourceAttrs$data3 === void 0 || (_datasourceAttrs$data3 = _datasourceAttrs$data3.properties) === null || _datasourceAttrs$data3 === void 0 || (_datasourceAttrs$data3 = _datasourceAttrs$data3.columns) === null || _datasourceAttrs$data3 === void 0 ? void 0 : _datasourceAttrs$data3.length) !== null && _datasourceAttrs$data2 !== void 0 ? _datasourceAttrs$data2 : null;
19
+ return (_datasourceAttrs$data2 = (_datasourceAttrs$data3 = datasourceAttrs.datasource.views[0]) === null || _datasourceAttrs$data3 === void 0 || (_datasourceAttrs$data3 = _datasourceAttrs$data3.properties) === null || _datasourceAttrs$data3 === void 0 || (_datasourceAttrs$data3 = _datasourceAttrs$data3.columns) === null || _datasourceAttrs$data3 === void 0 ? void 0 : _datasourceAttrs$data3.length) !== null && _datasourceAttrs$data2 !== void 0 ? _datasourceAttrs$data2 : undefined;
18
20
  }
19
21
  function getSearchMethod(creationMethod, metadata) {
20
22
  if (creationMethod === 'editor_paste' || creationMethod === 'editor_type') {
@@ -87,14 +89,16 @@ export var DatasourceEventsBinding = function DatasourceEventsBinding(_ref) {
87
89
  datasourceId: datasourceId,
88
90
  parameters: parameters,
89
91
  url: url
90
- }, null, {
92
+ }, null, _objectSpread(_objectSpread({
91
93
  actions: actions,
92
94
  creationMethod: inputMethod,
93
- display: display,
94
- displayedColumnCount: displayedColumnCount,
95
+ display: display
96
+ }, typeof displayedColumnCount === 'number' ? {
97
+ displayedColumnCount: displayedColumnCount
98
+ } : {}), {}, {
95
99
  nodeContext: nodeContext,
96
100
  searchMethod: searchMethod
97
- });
101
+ }));
98
102
  }), _defineProperty(_ref5, EVENT.UPDATED, function (_ref3) {
99
103
  var node = _ref3.node,
100
104
  nodeContext = _ref3.nodeContext,
@@ -1,23 +1,6 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
1
+ /// <reference types="react" />
3
2
  import type { InlineNodeViewComponentProps } from '@atlaskit/editor-common/react-node-view';
4
3
  import type { SmartCardProps } from './genericCard';
5
- export declare class InlineCardComponent extends React.PureComponent<SmartCardProps> {
6
- private scrollContainer?;
7
- static contextTypes: {
8
- contextAdapter: PropTypes.Requireable<object>;
9
- };
10
- UNSAFE_componentWillMount(): void;
11
- onResolve: (data: {
12
- url?: string | undefined;
13
- title?: string | undefined;
14
- }) => void;
15
- onError: (data: {
16
- url?: string | undefined;
17
- err?: Error | undefined;
18
- }) => void;
19
- render(): JSX.Element | null;
20
- }
21
4
  export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'showServerActions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback'>;
22
5
  type InlineCardWithAwarenessProps = {
23
6
  allowEmbeds?: boolean;
@@ -1,23 +1,6 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
1
+ /// <reference types="react" />
3
2
  import type { InlineNodeViewComponentProps } from '@atlaskit/editor-common/react-node-view';
4
3
  import type { SmartCardProps } from './genericCard';
5
- export declare class InlineCardComponent extends React.PureComponent<SmartCardProps> {
6
- private scrollContainer?;
7
- static contextTypes: {
8
- contextAdapter: PropTypes.Requireable<object>;
9
- };
10
- UNSAFE_componentWillMount(): void;
11
- onResolve: (data: {
12
- url?: string | undefined;
13
- title?: string | undefined;
14
- }) => void;
15
- onError: (data: {
16
- url?: string | undefined;
17
- err?: Error | undefined;
18
- }) => void;
19
- render(): JSX.Element | null;
20
- }
21
4
  export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'showServerActions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback'>;
22
5
  type InlineCardWithAwarenessProps = {
23
6
  allowEmbeds?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  "@atlaskit/adf-schema": "^36.3.0",
36
36
  "@atlaskit/analytics-next": "^9.3.0",
37
37
  "@atlaskit/custom-steps": "^0.2.0",
38
- "@atlaskit/editor-common": "^80.1.0",
38
+ "@atlaskit/editor-common": "^80.3.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^1.2.0",
40
40
  "@atlaskit/editor-plugin-decorations": "^1.1.0",
41
41
  "@atlaskit/editor-plugin-editor-viewmode": "^1.1.0",
@@ -54,8 +54,8 @@
54
54
  "@atlaskit/linking-common": "^5.6.0",
55
55
  "@atlaskit/linking-types": "^8.8.0",
56
56
  "@atlaskit/platform-feature-flags": "^0.2.0",
57
- "@atlaskit/primitives": "^6.1.0",
58
- "@atlaskit/smart-card": "^26.67.0",
57
+ "@atlaskit/primitives": "^6.2.0",
58
+ "@atlaskit/smart-card": "^26.68.0",
59
59
  "@atlaskit/theme": "^12.8.0",
60
60
  "@atlaskit/tokens": "^1.48.0",
61
61
  "@babel/runtime": "^7.0.0",
@@ -105,9 +105,6 @@
105
105
  },
106
106
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
107
107
  "platform-feature-flags": {
108
- "platform.linking-platform.smart-card.inline-switcher": {
109
- "type": "boolean"
110
- },
111
108
  "platform.linking-platform.datasource-word_wrap": {
112
109
  "type": "boolean"
113
110
  },