@atlaskit/editor-plugin-card 2.15.0 → 2.15.2

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,18 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 2.15.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1269ffa635367`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1269ffa635367) -
8
+ Cleanup FF platform_editor_get_card_provider_from_config
9
+
10
+ ## 2.15.1
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
3
16
  ## 2.15.0
4
17
 
5
18
  ### Minor Changes
@@ -162,17 +162,10 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
162
162
  }
163
163
  },
164
164
  view: function view(_view) {
165
- var subscriptionHandler = function subscriptionHandler(name, provider) {
166
- return (0, _resolve.handleProvider)(name, provider, _view);
167
- };
168
165
  var domAtPos = _view.domAtPos.bind(_view);
169
166
  var rafCancellationCallbacks = [];
170
- if ((0, _platformFeatureFlags.fg)('platform_editor_get_card_provider_from_config')) {
171
- if (options.provider) {
172
- (0, _resolve.handleProvider)('cardProvider', options.provider, _view);
173
- }
174
- } else {
175
- pmPluginFactoryParams.providerFactory.subscribe('cardProvider', subscriptionHandler);
167
+ if (options.provider) {
168
+ (0, _resolve.handleProvider)('cardProvider', options.provider, _view);
176
169
  }
177
170
  return {
178
171
  update: function update(view, prevState) {
@@ -246,9 +239,6 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
246
239
  rafCancellationCallbacks.forEach(function (cancellationCallback) {
247
240
  return cancellationCallback();
248
241
  });
249
- if (!(0, _platformFeatureFlags.fg)('platform_editor_get_card_provider_from_config')) {
250
- pmPluginFactoryParams.providerFactory.unsubscribe('cardProvider', subscriptionHandler);
251
- }
252
242
  }
253
243
  };
254
244
  },
@@ -525,7 +525,7 @@ var shouldRenderToolbarPulse = exports.shouldRenderToolbarPulse = function shoul
525
525
  return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled;
526
526
  };
527
527
  var getStartingToolbarItems = exports.getStartingToolbarItems = function getStartingToolbarItems(options, api) {
528
- return function (intl, link, providerFactory, onEditLink, metadata) {
528
+ return function (intl, link, onEditLink, metadata) {
529
529
  var isEditDropdownEnabled = options.platform !== 'mobile' && options.allowDatasource && (0, _platformFeatureFlags.fg)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar');
530
530
  var editLinkItem = isEditDropdownEnabled ? [{
531
531
  type: 'custom',
@@ -582,7 +582,6 @@ var getStartingToolbarItems = exports.getStartingToolbarItems = function getStar
582
582
  editorView: editorView,
583
583
  editorState: editorView.state,
584
584
  cardOptions: options,
585
- providerFactory: providerFactory,
586
585
  platform: options === null || options === void 0 ? void 0 : options.platform,
587
586
  editorAnalyticsApi: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
588
587
  editorPluginApi: api
@@ -5,15 +5,8 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.HyperlinkToolbarAppearance = void 0;
8
+ exports.HyperlinkToolbarAppearance = HyperlinkToolbarAppearance;
9
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
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
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
18
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
19
12
  var _react = _interopRequireWildcard(require("react"));
@@ -26,9 +19,7 @@ var _EditDatasourceButton = require("./EditDatasourceButton");
26
19
  var _LinkToolbarAppearance = require("./LinkToolbarAppearance");
27
20
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
28
21
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
29
- 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); }; }
30
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
31
- function HyperlinkToolbarAppearanceFunctional(props) {
22
+ function HyperlinkToolbarAppearance(props) {
32
23
  var _props$cardOptions3;
33
24
  var _useState = (0, _react.useState)(new Map()),
34
25
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -170,191 +161,4 @@ function HyperlinkToolbarAppearanceFunctional(props) {
170
161
  editorAnalyticsApi: editorAnalyticsApi,
171
162
  inputMethod: _analytics.INPUT_METHOD.FLOATING_TB
172
163
  }), /*#__PURE__*/_react.default.createElement(_ui.FloatingToolbarSeparator, null));
173
- }
174
-
175
- // eslint-disable-next-line @repo/internal/react/no-class-components
176
- var HyperlinkToolbarAppearanceClass = /*#__PURE__*/function (_Component) {
177
- (0, _inherits2.default)(HyperlinkToolbarAppearanceClass, _Component);
178
- var _super = _createSuper(HyperlinkToolbarAppearanceClass);
179
- function HyperlinkToolbarAppearanceClass() {
180
- var _this;
181
- (0, _classCallCheck2.default)(this, HyperlinkToolbarAppearanceClass);
182
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
183
- args[_key] = arguments[_key];
184
- }
185
- _this = _super.call.apply(_super, [this].concat(args));
186
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
187
- supportedUrlsMap: new Map()
188
- });
189
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getProvider", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
190
- return _regenerator.default.wrap(function _callee4$(_context4) {
191
- while (1) switch (_context4.prev = _context4.next) {
192
- case 0:
193
- if (!_this.cardProvider) {
194
- _context4.next = 2;
195
- break;
196
- }
197
- return _context4.abrupt("return", _this.cardProvider);
198
- case 2:
199
- return _context4.abrupt("return", new Promise(function (resolve) {
200
- var providerFactory = _this.props.providerFactory;
201
- providerFactory.subscribe('cardProvider', /*#__PURE__*/function () {
202
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_, cardProvider) {
203
- return _regenerator.default.wrap(function _callee3$(_context3) {
204
- while (1) switch (_context3.prev = _context3.next) {
205
- case 0:
206
- if (cardProvider) {
207
- _context3.next = 2;
208
- break;
209
- }
210
- return _context3.abrupt("return");
211
- case 2:
212
- _context3.next = 4;
213
- return cardProvider;
214
- case 4:
215
- _this.cardProvider = _context3.sent;
216
- resolve(_this.cardProvider);
217
- case 6:
218
- case "end":
219
- return _context3.stop();
220
- }
221
- }, _callee3);
222
- }));
223
- return function (_x2, _x3) {
224
- return _ref4.apply(this, arguments);
225
- };
226
- }());
227
- }));
228
- case 3:
229
- case "end":
230
- return _context4.stop();
231
- }
232
- }, _callee4);
233
- })));
234
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resolveUrl", /*#__PURE__*/function () {
235
- var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(url) {
236
- var supportedUrlsMap, isUrlSupported, _yield$provider$findP2, provider, newMap;
237
- return _regenerator.default.wrap(function _callee5$(_context5) {
238
- while (1) switch (_context5.prev = _context5.next) {
239
- case 0:
240
- supportedUrlsMap = _this.state.supportedUrlsMap;
241
- if (!supportedUrlsMap.has(url)) {
242
- _context5.next = 3;
243
- break;
244
- }
245
- return _context5.abrupt("return");
246
- case 3:
247
- isUrlSupported = false;
248
- _context5.prev = 4;
249
- _context5.next = 7;
250
- return _this.getProvider();
251
- case 7:
252
- provider = _context5.sent;
253
- _context5.next = 10;
254
- return provider === null || provider === void 0 ? void 0 : provider.findPattern(url);
255
- case 10:
256
- _context5.t1 = _yield$provider$findP2 = _context5.sent;
257
- _context5.t0 = _context5.t1 !== null;
258
- if (!_context5.t0) {
259
- _context5.next = 14;
260
- break;
261
- }
262
- _context5.t0 = _yield$provider$findP2 !== void 0;
263
- case 14:
264
- if (!_context5.t0) {
265
- _context5.next = 18;
266
- break;
267
- }
268
- _context5.t2 = _yield$provider$findP2;
269
- _context5.next = 19;
270
- break;
271
- case 18:
272
- _context5.t2 = false;
273
- case 19:
274
- isUrlSupported = _context5.t2;
275
- _context5.next = 25;
276
- break;
277
- case 22:
278
- _context5.prev = 22;
279
- _context5.t3 = _context5["catch"](4);
280
- isUrlSupported = false;
281
- case 25:
282
- newMap = new Map(supportedUrlsMap);
283
- newMap.set(url, isUrlSupported);
284
- _this.setState({
285
- supportedUrlsMap: newMap
286
- });
287
- case 28:
288
- case "end":
289
- return _context5.stop();
290
- }
291
- }, _callee5, null, [[4, 22]]);
292
- }));
293
- return function (_x4) {
294
- return _ref5.apply(this, arguments);
295
- };
296
- }());
297
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "componentDidMount", function () {
298
- return _this.resolveUrl(_this.props.url);
299
- });
300
- return _this;
301
- }
302
- (0, _createClass2.default)(HyperlinkToolbarAppearanceClass, [{
303
- key: "UNSAFE_componentWillReceiveProps",
304
- value:
305
- // needed so we display the right state on the Toolbar while the same Toolbar
306
- // instance is visible and we click other link
307
- function UNSAFE_componentWillReceiveProps(nextProps) {
308
- if (nextProps.url !== this.props.url) {
309
- this.resolveUrl(nextProps.url);
310
- }
311
- }
312
- }, {
313
- key: "render",
314
- value: function render() {
315
- var _this$props = this.props,
316
- url = _this$props.url,
317
- intl = _this$props.intl,
318
- editorView = _this$props.editorView,
319
- editorState = _this$props.editorState,
320
- cardOptions = _this$props.cardOptions,
321
- platform = _this$props.platform,
322
- editorAnalyticsApi = _this$props.editorAnalyticsApi;
323
- var supportedUrlsMap = this.state.supportedUrlsMap;
324
- if (!supportedUrlsMap.get(url)) {
325
- return null;
326
- }
327
- return /*#__PURE__*/_react.default.createElement(_primitives.Flex, null, !(0, _platformFeatureFlags.fg)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && /*#__PURE__*/_react.default.createElement(_EditDatasourceButton.EditDatasourceButton, {
328
- url: url,
329
- intl: intl,
330
- editorView: editorView,
331
- editorAnalyticsApi: editorAnalyticsApi,
332
- currentAppearance: "url"
333
- }), /*#__PURE__*/_react.default.createElement(_LinkToolbarAppearance.LinkToolbarAppearance, {
334
- key: "link-appearance",
335
- url: url,
336
- intl: intl,
337
- editorView: editorView,
338
- editorState: editorState,
339
- allowEmbeds: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowEmbeds,
340
- allowBlockCards: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowBlockCards,
341
- platform: platform,
342
- editorAnalyticsApi: editorAnalyticsApi
343
- }), (cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowDatasource) && /*#__PURE__*/_react.default.createElement(_DatasourceAppearanceButton.DatasourceAppearanceButton, {
344
- intl: intl,
345
- url: url,
346
- editorState: editorState,
347
- editorView: editorView,
348
- editorAnalyticsApi: editorAnalyticsApi,
349
- inputMethod: _analytics.INPUT_METHOD.FLOATING_TB
350
- }), /*#__PURE__*/_react.default.createElement(_ui.FloatingToolbarSeparator, null));
351
- }
352
- }]);
353
- return HyperlinkToolbarAppearanceClass;
354
- }(_react.Component);
355
- var HyperlinkToolbarAppearance = exports.HyperlinkToolbarAppearance = function HyperlinkToolbarAppearance(props) {
356
- if ((0, _platformFeatureFlags.fg)('platform_editor_get_card_provider_from_config')) {
357
- return /*#__PURE__*/_react.default.createElement(HyperlinkToolbarAppearanceFunctional, props);
358
- }
359
- return /*#__PURE__*/_react.default.createElement(HyperlinkToolbarAppearanceClass, props);
360
- };
164
+ }
@@ -149,15 +149,10 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
149
149
  }
150
150
  },
151
151
  view(view) {
152
- const subscriptionHandler = (name, provider) => handleProvider(name, provider, view);
153
152
  const domAtPos = view.domAtPos.bind(view);
154
153
  const rafCancellationCallbacks = [];
155
- if (fg('platform_editor_get_card_provider_from_config')) {
156
- if (options.provider) {
157
- handleProvider('cardProvider', options.provider, view);
158
- }
159
- } else {
160
- pmPluginFactoryParams.providerFactory.subscribe('cardProvider', subscriptionHandler);
154
+ if (options.provider) {
155
+ handleProvider('cardProvider', options.provider, view);
161
156
  }
162
157
  return {
163
158
  update(view, prevState) {
@@ -237,9 +232,6 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
237
232
  destroy() {
238
233
  // Cancel any outstanding raf callbacks.
239
234
  rafCancellationCallbacks.forEach(cancellationCallback => cancellationCallback());
240
- if (!fg('platform_editor_get_card_provider_from_config')) {
241
- pmPluginFactoryParams.providerFactory.unsubscribe('cardProvider', subscriptionHandler);
242
- }
243
235
  }
244
236
  };
245
237
  },
@@ -512,7 +512,7 @@ export const shouldRenderToolbarPulse = (embedEnabled, appearance, status, isDis
512
512
  return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled;
513
513
  };
514
514
  export const getStartingToolbarItems = (options, api) => {
515
- return (intl, link, providerFactory, onEditLink, metadata) => {
515
+ return (intl, link, onEditLink, metadata) => {
516
516
  const isEditDropdownEnabled = options.platform !== 'mobile' && options.allowDatasource && fg('platform.linking-platform.enable-datasource-edit-dropdown-toolbar');
517
517
  const editLinkItem = isEditDropdownEnabled ? [{
518
518
  type: 'custom',
@@ -567,7 +567,6 @@ export const getStartingToolbarItems = (options, api) => {
567
567
  editorView: editorView,
568
568
  editorState: editorView.state,
569
569
  cardOptions: options,
570
- providerFactory: providerFactory,
571
570
  platform: options === null || options === void 0 ? void 0 : options.platform,
572
571
  editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
573
572
  editorPluginApi: api
@@ -1,5 +1,4 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import React, { Component, useEffect, useRef, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
3
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
3
  import { FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
5
4
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -7,7 +6,7 @@ import { Flex } from '@atlaskit/primitives';
7
6
  import { DatasourceAppearanceButton } from './DatasourceAppearanceButton';
8
7
  import { EditDatasourceButton } from './EditDatasourceButton';
9
8
  import { LinkToolbarAppearance } from './LinkToolbarAppearance';
10
- function HyperlinkToolbarAppearanceFunctional(props) {
9
+ export function HyperlinkToolbarAppearance(props) {
11
10
  var _props$cardOptions3;
12
11
  const [supportedUrlsMap, setSupportedUrlsMap] = useState(new Map());
13
12
  const cardProvider = useRef(undefined);
@@ -85,107 +84,4 @@ function HyperlinkToolbarAppearanceFunctional(props) {
85
84
  editorAnalyticsApi: editorAnalyticsApi,
86
85
  inputMethod: INPUT_METHOD.FLOATING_TB
87
86
  }), /*#__PURE__*/React.createElement(Separator, null));
88
- }
89
-
90
- // eslint-disable-next-line @repo/internal/react/no-class-components
91
- class HyperlinkToolbarAppearanceClass extends Component {
92
- constructor(...args) {
93
- super(...args);
94
- _defineProperty(this, "state", {
95
- supportedUrlsMap: new Map()
96
- });
97
- _defineProperty(this, "getProvider", async () => {
98
- if (this.cardProvider) {
99
- return this.cardProvider;
100
- }
101
- return new Promise(resolve => {
102
- const {
103
- providerFactory
104
- } = this.props;
105
- providerFactory.subscribe('cardProvider', async (_, cardProvider) => {
106
- if (!cardProvider) {
107
- return;
108
- }
109
- this.cardProvider = await cardProvider;
110
- resolve(this.cardProvider);
111
- });
112
- });
113
- });
114
- _defineProperty(this, "resolveUrl", async url => {
115
- const {
116
- supportedUrlsMap
117
- } = this.state;
118
- if (supportedUrlsMap.has(url)) {
119
- return;
120
- }
121
- let isUrlSupported = false;
122
- try {
123
- var _await$provider$findP2;
124
- const provider = await this.getProvider();
125
- isUrlSupported = (_await$provider$findP2 = await (provider === null || provider === void 0 ? void 0 : provider.findPattern(url))) !== null && _await$provider$findP2 !== void 0 ? _await$provider$findP2 : false;
126
- } catch (error) {
127
- isUrlSupported = false;
128
- }
129
- const newMap = new Map(supportedUrlsMap);
130
- newMap.set(url, isUrlSupported);
131
- this.setState({
132
- supportedUrlsMap: newMap
133
- });
134
- });
135
- _defineProperty(this, "componentDidMount", () => this.resolveUrl(this.props.url));
136
- }
137
- // needed so we display the right state on the Toolbar while the same Toolbar
138
- // instance is visible and we click other link
139
- UNSAFE_componentWillReceiveProps(nextProps) {
140
- if (nextProps.url !== this.props.url) {
141
- this.resolveUrl(nextProps.url);
142
- }
143
- }
144
- render() {
145
- const {
146
- url,
147
- intl,
148
- editorView,
149
- editorState,
150
- cardOptions,
151
- platform,
152
- editorAnalyticsApi
153
- } = this.props;
154
- const {
155
- supportedUrlsMap
156
- } = this.state;
157
- if (!supportedUrlsMap.get(url)) {
158
- return null;
159
- }
160
- return /*#__PURE__*/React.createElement(Flex, null, !fg('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && /*#__PURE__*/React.createElement(EditDatasourceButton, {
161
- url: url,
162
- intl: intl,
163
- editorView: editorView,
164
- editorAnalyticsApi: editorAnalyticsApi,
165
- currentAppearance: "url"
166
- }), /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
167
- key: "link-appearance",
168
- url: url,
169
- intl: intl,
170
- editorView: editorView,
171
- editorState: editorState,
172
- allowEmbeds: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowEmbeds,
173
- allowBlockCards: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowBlockCards,
174
- platform: platform,
175
- editorAnalyticsApi: editorAnalyticsApi
176
- }), (cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowDatasource) && /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
177
- intl: intl,
178
- url: url,
179
- editorState: editorState,
180
- editorView: editorView,
181
- editorAnalyticsApi: editorAnalyticsApi,
182
- inputMethod: INPUT_METHOD.FLOATING_TB
183
- }), /*#__PURE__*/React.createElement(Separator, null));
184
- }
185
- }
186
- export const HyperlinkToolbarAppearance = props => {
187
- if (fg('platform_editor_get_card_provider_from_config')) {
188
- return /*#__PURE__*/React.createElement(HyperlinkToolbarAppearanceFunctional, props);
189
- }
190
- return /*#__PURE__*/React.createElement(HyperlinkToolbarAppearanceClass, props);
191
- };
87
+ }
@@ -149,17 +149,10 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
149
149
  }
150
150
  },
151
151
  view: function view(_view) {
152
- var subscriptionHandler = function subscriptionHandler(name, provider) {
153
- return handleProvider(name, provider, _view);
154
- };
155
152
  var domAtPos = _view.domAtPos.bind(_view);
156
153
  var rafCancellationCallbacks = [];
157
- if (fg('platform_editor_get_card_provider_from_config')) {
158
- if (options.provider) {
159
- handleProvider('cardProvider', options.provider, _view);
160
- }
161
- } else {
162
- pmPluginFactoryParams.providerFactory.subscribe('cardProvider', subscriptionHandler);
154
+ if (options.provider) {
155
+ handleProvider('cardProvider', options.provider, _view);
163
156
  }
164
157
  return {
165
158
  update: function update(view, prevState) {
@@ -233,9 +226,6 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
233
226
  rafCancellationCallbacks.forEach(function (cancellationCallback) {
234
227
  return cancellationCallback();
235
228
  });
236
- if (!fg('platform_editor_get_card_provider_from_config')) {
237
- pmPluginFactoryParams.providerFactory.unsubscribe('cardProvider', subscriptionHandler);
238
- }
239
229
  }
240
230
  };
241
231
  },
@@ -515,7 +515,7 @@ export var shouldRenderToolbarPulse = function shouldRenderToolbarPulse(embedEna
515
515
  return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled;
516
516
  };
517
517
  export var getStartingToolbarItems = function getStartingToolbarItems(options, api) {
518
- return function (intl, link, providerFactory, onEditLink, metadata) {
518
+ return function (intl, link, onEditLink, metadata) {
519
519
  var isEditDropdownEnabled = options.platform !== 'mobile' && options.allowDatasource && fg('platform.linking-platform.enable-datasource-edit-dropdown-toolbar');
520
520
  var editLinkItem = isEditDropdownEnabled ? [{
521
521
  type: 'custom',
@@ -572,7 +572,6 @@ export var getStartingToolbarItems = function getStartingToolbarItems(options, a
572
572
  editorView: editorView,
573
573
  editorState: editorView.state,
574
574
  cardOptions: options,
575
- providerFactory: providerFactory,
576
575
  platform: options === null || options === void 0 ? void 0 : options.platform,
577
576
  editorAnalyticsApi: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
578
577
  editorPluginApi: api
@@ -1,16 +1,7 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
9
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
10
- 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); }; }
11
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
12
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
13
- import React, { Component, useEffect, useRef, useState } from 'react';
4
+ import React, { useEffect, useRef, useState } from 'react';
14
5
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
15
6
  import { FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
16
7
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -18,7 +9,7 @@ import { Flex } from '@atlaskit/primitives';
18
9
  import { DatasourceAppearanceButton } from './DatasourceAppearanceButton';
19
10
  import { EditDatasourceButton } from './EditDatasourceButton';
20
11
  import { LinkToolbarAppearance } from './LinkToolbarAppearance';
21
- function HyperlinkToolbarAppearanceFunctional(props) {
12
+ export function HyperlinkToolbarAppearance(props) {
22
13
  var _props$cardOptions3;
23
14
  var _useState = useState(new Map()),
24
15
  _useState2 = _slicedToArray(_useState, 2),
@@ -160,191 +151,4 @@ function HyperlinkToolbarAppearanceFunctional(props) {
160
151
  editorAnalyticsApi: editorAnalyticsApi,
161
152
  inputMethod: INPUT_METHOD.FLOATING_TB
162
153
  }), /*#__PURE__*/React.createElement(Separator, null));
163
- }
164
-
165
- // eslint-disable-next-line @repo/internal/react/no-class-components
166
- var HyperlinkToolbarAppearanceClass = /*#__PURE__*/function (_Component) {
167
- _inherits(HyperlinkToolbarAppearanceClass, _Component);
168
- var _super = _createSuper(HyperlinkToolbarAppearanceClass);
169
- function HyperlinkToolbarAppearanceClass() {
170
- var _this;
171
- _classCallCheck(this, HyperlinkToolbarAppearanceClass);
172
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
173
- args[_key] = arguments[_key];
174
- }
175
- _this = _super.call.apply(_super, [this].concat(args));
176
- _defineProperty(_assertThisInitialized(_this), "state", {
177
- supportedUrlsMap: new Map()
178
- });
179
- _defineProperty(_assertThisInitialized(_this), "getProvider", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
180
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
181
- while (1) switch (_context4.prev = _context4.next) {
182
- case 0:
183
- if (!_this.cardProvider) {
184
- _context4.next = 2;
185
- break;
186
- }
187
- return _context4.abrupt("return", _this.cardProvider);
188
- case 2:
189
- return _context4.abrupt("return", new Promise(function (resolve) {
190
- var providerFactory = _this.props.providerFactory;
191
- providerFactory.subscribe('cardProvider', /*#__PURE__*/function () {
192
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_, cardProvider) {
193
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
194
- while (1) switch (_context3.prev = _context3.next) {
195
- case 0:
196
- if (cardProvider) {
197
- _context3.next = 2;
198
- break;
199
- }
200
- return _context3.abrupt("return");
201
- case 2:
202
- _context3.next = 4;
203
- return cardProvider;
204
- case 4:
205
- _this.cardProvider = _context3.sent;
206
- resolve(_this.cardProvider);
207
- case 6:
208
- case "end":
209
- return _context3.stop();
210
- }
211
- }, _callee3);
212
- }));
213
- return function (_x2, _x3) {
214
- return _ref4.apply(this, arguments);
215
- };
216
- }());
217
- }));
218
- case 3:
219
- case "end":
220
- return _context4.stop();
221
- }
222
- }, _callee4);
223
- })));
224
- _defineProperty(_assertThisInitialized(_this), "resolveUrl", /*#__PURE__*/function () {
225
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(url) {
226
- var supportedUrlsMap, isUrlSupported, _yield$provider$findP2, provider, newMap;
227
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
228
- while (1) switch (_context5.prev = _context5.next) {
229
- case 0:
230
- supportedUrlsMap = _this.state.supportedUrlsMap;
231
- if (!supportedUrlsMap.has(url)) {
232
- _context5.next = 3;
233
- break;
234
- }
235
- return _context5.abrupt("return");
236
- case 3:
237
- isUrlSupported = false;
238
- _context5.prev = 4;
239
- _context5.next = 7;
240
- return _this.getProvider();
241
- case 7:
242
- provider = _context5.sent;
243
- _context5.next = 10;
244
- return provider === null || provider === void 0 ? void 0 : provider.findPattern(url);
245
- case 10:
246
- _context5.t1 = _yield$provider$findP2 = _context5.sent;
247
- _context5.t0 = _context5.t1 !== null;
248
- if (!_context5.t0) {
249
- _context5.next = 14;
250
- break;
251
- }
252
- _context5.t0 = _yield$provider$findP2 !== void 0;
253
- case 14:
254
- if (!_context5.t0) {
255
- _context5.next = 18;
256
- break;
257
- }
258
- _context5.t2 = _yield$provider$findP2;
259
- _context5.next = 19;
260
- break;
261
- case 18:
262
- _context5.t2 = false;
263
- case 19:
264
- isUrlSupported = _context5.t2;
265
- _context5.next = 25;
266
- break;
267
- case 22:
268
- _context5.prev = 22;
269
- _context5.t3 = _context5["catch"](4);
270
- isUrlSupported = false;
271
- case 25:
272
- newMap = new Map(supportedUrlsMap);
273
- newMap.set(url, isUrlSupported);
274
- _this.setState({
275
- supportedUrlsMap: newMap
276
- });
277
- case 28:
278
- case "end":
279
- return _context5.stop();
280
- }
281
- }, _callee5, null, [[4, 22]]);
282
- }));
283
- return function (_x4) {
284
- return _ref5.apply(this, arguments);
285
- };
286
- }());
287
- _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
288
- return _this.resolveUrl(_this.props.url);
289
- });
290
- return _this;
291
- }
292
- _createClass(HyperlinkToolbarAppearanceClass, [{
293
- key: "UNSAFE_componentWillReceiveProps",
294
- value:
295
- // needed so we display the right state on the Toolbar while the same Toolbar
296
- // instance is visible and we click other link
297
- function UNSAFE_componentWillReceiveProps(nextProps) {
298
- if (nextProps.url !== this.props.url) {
299
- this.resolveUrl(nextProps.url);
300
- }
301
- }
302
- }, {
303
- key: "render",
304
- value: function render() {
305
- var _this$props = this.props,
306
- url = _this$props.url,
307
- intl = _this$props.intl,
308
- editorView = _this$props.editorView,
309
- editorState = _this$props.editorState,
310
- cardOptions = _this$props.cardOptions,
311
- platform = _this$props.platform,
312
- editorAnalyticsApi = _this$props.editorAnalyticsApi;
313
- var supportedUrlsMap = this.state.supportedUrlsMap;
314
- if (!supportedUrlsMap.get(url)) {
315
- return null;
316
- }
317
- return /*#__PURE__*/React.createElement(Flex, null, !fg('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && /*#__PURE__*/React.createElement(EditDatasourceButton, {
318
- url: url,
319
- intl: intl,
320
- editorView: editorView,
321
- editorAnalyticsApi: editorAnalyticsApi,
322
- currentAppearance: "url"
323
- }), /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
324
- key: "link-appearance",
325
- url: url,
326
- intl: intl,
327
- editorView: editorView,
328
- editorState: editorState,
329
- allowEmbeds: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowEmbeds,
330
- allowBlockCards: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowBlockCards,
331
- platform: platform,
332
- editorAnalyticsApi: editorAnalyticsApi
333
- }), (cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowDatasource) && /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
334
- intl: intl,
335
- url: url,
336
- editorState: editorState,
337
- editorView: editorView,
338
- editorAnalyticsApi: editorAnalyticsApi,
339
- inputMethod: INPUT_METHOD.FLOATING_TB
340
- }), /*#__PURE__*/React.createElement(Separator, null));
341
- }
342
- }]);
343
- return HyperlinkToolbarAppearanceClass;
344
- }(Component);
345
- export var HyperlinkToolbarAppearance = function HyperlinkToolbarAppearance(props) {
346
- if (fg('platform_editor_get_card_provider_from_config')) {
347
- return /*#__PURE__*/React.createElement(HyperlinkToolbarAppearanceFunctional, props);
348
- }
349
- return /*#__PURE__*/React.createElement(HyperlinkToolbarAppearanceClass, props);
350
- };
154
+ }
@@ -1,7 +1,6 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { CardOptions } from '@atlaskit/editor-common/card';
4
- import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
5
4
  import type { Command, ExtractInjectionAPI, FloatingToolbarHandler, FloatingToolbarItem, LinkPickerOptions } from '@atlaskit/editor-common/types';
6
5
  import type { CardPlatform } from '@atlaskit/smart-card';
7
6
  import type { CardPluginOptions } from './types';
@@ -14,7 +13,7 @@ export declare const getHyperlinkToolbarSettingsButton: (intl: IntlShape, editor
14
13
  export declare const getSettingsButton: (intl: IntlShape, editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink: string | undefined) => FloatingToolbarItem<Command>;
15
14
  export declare const getSettingsButtonGroup: (intl: IntlShape, editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink: string | undefined) => FloatingToolbarItem<Command>[];
16
15
  export declare const shouldRenderToolbarPulse: (embedEnabled: boolean, appearance: string, status: string, isDiscoverabilityEnabled: boolean) => boolean;
17
- export declare const getStartingToolbarItems: (options: CardPluginOptions, api?: ExtractInjectionAPI<typeof cardPlugin> | undefined) => (intl: IntlShape, link: string, providerFactory: ProviderFactory, onEditLink: Command, metadata: {
16
+ export declare const getStartingToolbarItems: (options: CardPluginOptions, api?: ExtractInjectionAPI<typeof cardPlugin> | undefined) => (intl: IntlShape, link: string, onEditLink: Command, metadata: {
18
17
  url: string;
19
18
  title: string;
20
19
  }) => FloatingToolbarItem<Command>[];
@@ -2,7 +2,6 @@
2
2
  import type { IntlShape } from 'react-intl-next';
3
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
4
  import type { CardOptions } from '@atlaskit/editor-common/card';
5
- import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
6
5
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
7
6
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
8
7
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -11,7 +10,6 @@ import { type CardPlugin } from '../plugin';
11
10
  export interface HyperlinkToolbarAppearanceProps {
12
11
  intl: IntlShape;
13
12
  editorState: EditorState;
14
- providerFactory: ProviderFactory;
15
13
  url: string;
16
14
  editorView?: EditorView;
17
15
  platform?: CardPlatform;
@@ -19,7 +17,4 @@ export interface HyperlinkToolbarAppearanceProps {
19
17
  editorAnalyticsApi: EditorAnalyticsAPI | undefined;
20
18
  editorPluginApi: ExtractInjectionAPI<CardPlugin> | undefined;
21
19
  }
22
- export interface HyperlinkToolbarAppearanceState {
23
- supportedUrlsMap: Map<string, boolean>;
24
- }
25
- export declare const HyperlinkToolbarAppearance: (props: HyperlinkToolbarAppearanceProps) => JSX.Element;
20
+ export declare function HyperlinkToolbarAppearance(props: HyperlinkToolbarAppearanceProps): JSX.Element | null;
@@ -1,7 +1,6 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { CardOptions } from '@atlaskit/editor-common/card';
4
- import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
5
4
  import type { Command, ExtractInjectionAPI, FloatingToolbarHandler, FloatingToolbarItem, LinkPickerOptions } from '@atlaskit/editor-common/types';
6
5
  import type { CardPlatform } from '@atlaskit/smart-card';
7
6
  import type { CardPluginOptions } from './types';
@@ -14,7 +13,7 @@ export declare const getHyperlinkToolbarSettingsButton: (intl: IntlShape, editor
14
13
  export declare const getSettingsButton: (intl: IntlShape, editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink: string | undefined) => FloatingToolbarItem<Command>;
15
14
  export declare const getSettingsButtonGroup: (intl: IntlShape, editorAnalyticsApi: EditorAnalyticsAPI | undefined, userPreferencesLink: string | undefined) => FloatingToolbarItem<Command>[];
16
15
  export declare const shouldRenderToolbarPulse: (embedEnabled: boolean, appearance: string, status: string, isDiscoverabilityEnabled: boolean) => boolean;
17
- export declare const getStartingToolbarItems: (options: CardPluginOptions, api?: ExtractInjectionAPI<typeof cardPlugin> | undefined) => (intl: IntlShape, link: string, providerFactory: ProviderFactory, onEditLink: Command, metadata: {
16
+ export declare const getStartingToolbarItems: (options: CardPluginOptions, api?: ExtractInjectionAPI<typeof cardPlugin> | undefined) => (intl: IntlShape, link: string, onEditLink: Command, metadata: {
18
17
  url: string;
19
18
  title: string;
20
19
  }) => FloatingToolbarItem<Command>[];
@@ -2,7 +2,6 @@
2
2
  import type { IntlShape } from 'react-intl-next';
3
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
4
  import type { CardOptions } from '@atlaskit/editor-common/card';
5
- import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
6
5
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
7
6
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
8
7
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -11,7 +10,6 @@ import { type CardPlugin } from '../plugin';
11
10
  export interface HyperlinkToolbarAppearanceProps {
12
11
  intl: IntlShape;
13
12
  editorState: EditorState;
14
- providerFactory: ProviderFactory;
15
13
  url: string;
16
14
  editorView?: EditorView;
17
15
  platform?: CardPlatform;
@@ -19,7 +17,4 @@ export interface HyperlinkToolbarAppearanceProps {
19
17
  editorAnalyticsApi: EditorAnalyticsAPI | undefined;
20
18
  editorPluginApi: ExtractInjectionAPI<CardPlugin> | undefined;
21
19
  }
22
- export interface HyperlinkToolbarAppearanceState {
23
- supportedUrlsMap: Map<string, boolean>;
24
- }
25
- export declare const HyperlinkToolbarAppearance: (props: HyperlinkToolbarAppearanceProps) => JSX.Element;
20
+ export declare function HyperlinkToolbarAppearance(props: HyperlinkToolbarAppearanceProps): JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "2.15.0",
3
+ "version": "2.15.2",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  "@atlaskit/adf-schema": "^40.9.0",
35
35
  "@atlaskit/analytics-next": "^10.1.0",
36
36
  "@atlaskit/custom-steps": "^0.7.0",
37
- "@atlaskit/editor-common": "^88.11.0",
37
+ "@atlaskit/editor-common": "^88.12.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
39
39
  "@atlaskit/editor-plugin-decorations": "^1.3.0",
40
40
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
@@ -55,7 +55,7 @@
55
55
  "@atlaskit/menu": "2.12.2",
56
56
  "@atlaskit/platform-feature-flags": "^0.3.0",
57
57
  "@atlaskit/primitives": "^12.1.0",
58
- "@atlaskit/smart-card": "^27.20.0",
58
+ "@atlaskit/smart-card": "^28.0.0",
59
59
  "@atlaskit/theme": "^13.0.0",
60
60
  "@atlaskit/tokens": "^1.59.0",
61
61
  "@babel/runtime": "^7.0.0",
@@ -131,9 +131,6 @@
131
131
  "platform.editor.card.inject-settings-button": {
132
132
  "type": "boolean"
133
133
  },
134
- "platform_editor_get_card_provider_from_config": {
135
- "type": "boolean"
136
- },
137
134
  "linking-platform-contenteditable-false-live-view": {
138
135
  "type": "boolean"
139
136
  },