@atlaskit/editor-plugin-card 4.5.17 → 4.5.18

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/nodeviews/blockCard.js +18 -2
  3. package/dist/cjs/nodeviews/embedCard.js +16 -1
  4. package/dist/cjs/nodeviews/inlineCard.js +16 -1
  5. package/dist/cjs/nodeviews/inlineCardWithAwareness.js +18 -3
  6. package/dist/cjs/pm-plugins/actions.js +12 -3
  7. package/dist/cjs/pm-plugins/reducers.js +13 -0
  8. package/dist/es2019/nodeviews/blockCard.js +19 -3
  9. package/dist/es2019/nodeviews/embedCard.js +17 -2
  10. package/dist/es2019/nodeviews/inlineCard.js +20 -3
  11. package/dist/es2019/nodeviews/inlineCardWithAwareness.js +12 -1
  12. package/dist/es2019/pm-plugins/actions.js +7 -2
  13. package/dist/es2019/pm-plugins/reducers.js +12 -0
  14. package/dist/esm/nodeviews/blockCard.js +19 -3
  15. package/dist/esm/nodeviews/embedCard.js +17 -2
  16. package/dist/esm/nodeviews/inlineCard.js +18 -3
  17. package/dist/esm/nodeviews/inlineCardWithAwareness.js +18 -3
  18. package/dist/esm/pm-plugins/actions.js +11 -2
  19. package/dist/esm/pm-plugins/reducers.js +13 -0
  20. package/dist/types/nodeviews/blockCard.d.ts +8 -2
  21. package/dist/types/nodeviews/embedCard.d.ts +8 -2
  22. package/dist/types/nodeviews/genericCard.d.ts +3 -1
  23. package/dist/types/pm-plugins/actions.d.ts +2 -1
  24. package/dist/types/pm-plugins/util/state.d.ts +1 -0
  25. package/dist/types/types/index.d.ts +7 -1
  26. package/dist/types-ts4.5/nodeviews/blockCard.d.ts +8 -2
  27. package/dist/types-ts4.5/nodeviews/embedCard.d.ts +8 -2
  28. package/dist/types-ts4.5/nodeviews/genericCard.d.ts +3 -1
  29. package/dist/types-ts4.5/pm-plugins/actions.d.ts +2 -1
  30. package/dist/types-ts4.5/pm-plugins/util/state.d.ts +1 -0
  31. package/dist/types-ts4.5/types/index.d.ts +7 -1
  32. package/package.json +12 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 4.5.18
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
3
9
  ## 4.5.17
4
10
 
5
11
  ### Patch Changes
@@ -14,6 +14,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
14
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
15
  var _react = _interopRequireDefault(require("react"));
16
16
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
17
+ var _v = _interopRequireDefault(require("uuid/v4"));
17
18
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
18
19
  var _ui = require("@atlaskit/editor-common/ui");
19
20
  var _utils = require("@atlaskit/editor-common/utils");
@@ -54,7 +55,8 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
54
55
  view.dispatch((0, _actions.registerCard)({
55
56
  title: title,
56
57
  url: url,
57
- pos: pos
58
+ pos: pos,
59
+ id: _this.props.id
58
60
  })(view.state.tr));
59
61
  })();
60
62
  });
@@ -120,6 +122,7 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
120
122
  args[_key] = arguments[_key];
121
123
  }
122
124
  _this2 = _callSuper(this, BlockCard, [].concat(args));
125
+ (0, _defineProperty2.default)(_this2, "id", (0, _v.default)());
123
126
  (0, _defineProperty2.default)(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
124
127
  divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
125
128
  });
@@ -177,7 +180,8 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
177
180
  getPos: this.getPos,
178
181
  actionOptions: actionOptions,
179
182
  pluginInjectionApi: pluginInjectionApi,
180
- onClickCallback: onClickCallback
183
+ onClickCallback: onClickCallback,
184
+ id: this.id
181
185
  });
182
186
  }
183
187
  }, {
@@ -185,6 +189,18 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
185
189
  value: function destroy() {
186
190
  var _this$unsubscribe;
187
191
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
192
+ if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
193
+ this.removeCard();
194
+ }
195
+ }
196
+ }, {
197
+ key: "removeCard",
198
+ value: function removeCard() {
199
+ var tr = this.view.state.tr;
200
+ (0, _actions.removeCard)({
201
+ id: this.id
202
+ })(tr);
203
+ this.view.dispatch(tr);
188
204
  }
189
205
  }]);
190
206
  }(_reactNodeView.default);
@@ -15,6 +15,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
15
15
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
16
16
  var _react = _interopRequireDefault(require("react"));
17
17
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
18
+ var _v = _interopRequireDefault(require("uuid/v4"));
18
19
  var _steps = require("@atlaskit/adf-schema/steps");
19
20
  var _hooks = require("@atlaskit/editor-common/hooks");
20
21
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
@@ -162,7 +163,8 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
162
163
  return view.dispatch((0, _actions.registerCard)({
163
164
  title: title,
164
165
  url: url,
165
- pos: pos
166
+ pos: pos,
167
+ id: _this.props.id
166
168
  })(view.state.tr));
167
169
  })();
168
170
  try {
@@ -345,6 +347,7 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
345
347
  args[_key] = arguments[_key];
346
348
  }
347
349
  _this2 = _callSuper(this, EmbedCard, [].concat(args));
350
+ (0, _defineProperty2.default)(_this2, "id", (0, _v.default)());
348
351
  (0, _defineProperty2.default)(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
349
352
  divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
350
353
  });
@@ -405,6 +408,18 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
405
408
  value: function destroy() {
406
409
  var _this$unsubscribe;
407
410
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
411
+ if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
412
+ this.removeCard();
413
+ }
414
+ }
415
+ }, {
416
+ key: "removeCard",
417
+ value: function removeCard() {
418
+ var tr = this.view.state.tr;
419
+ (0, _actions.removeCard)({
420
+ id: this.id
421
+ })(tr);
422
+ this.view.dispatch(tr);
408
423
  }
409
424
  }]);
410
425
  }(_reactNodeView.default);
@@ -12,6 +12,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
12
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
13
  var _react = _interopRequireWildcard(require("react"));
14
14
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
15
+ var _v = _interopRequireDefault(require("uuid/v4"));
15
16
  var _hooks = require("@atlaskit/editor-common/hooks");
16
17
  var _link = require("@atlaskit/editor-common/link");
17
18
  var _ui = require("@atlaskit/editor-common/ui");
@@ -40,6 +41,19 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
40
41
  var _node$attrs = node.attrs,
41
42
  url = _node$attrs.url,
42
43
  data = _node$attrs.data;
44
+ var refId = (0, _react.useRef)((0, _v.default)());
45
+ (0, _react.useEffect)(function () {
46
+ var id = refId.current;
47
+ return function () {
48
+ if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
49
+ var tr = view.state.tr;
50
+ (0, _actions.removeCard)({
51
+ id: id
52
+ })(tr);
53
+ view.dispatch(tr);
54
+ }
55
+ };
56
+ }, [getPos, view]);
43
57
  var scrollContainer = (0, _react.useMemo)(
44
58
  // Ignored via go/ees005
45
59
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -64,7 +78,8 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
64
78
  (0, _actions.registerCard)({
65
79
  title: title,
66
80
  url: url,
67
- pos: pos
81
+ pos: pos,
82
+ id: refId.current
68
83
  })(tr);
69
84
  onRes === null || onRes === void 0 || onRes(tr, title);
70
85
  view.dispatch(tr);
@@ -8,7 +8,9 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.InlineCardWithAwareness = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  var _actions = require("../pm-plugins/actions");
13
+ var _pluginKey = require("../pm-plugins/plugin-key");
12
14
  var _AwarenessWrapper = require("../ui/AwarenessWrapper");
13
15
  var _inlineCard = require("./inlineCard");
14
16
  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); }
@@ -38,9 +40,22 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
38
40
  isResolvedViewRendered = _useState6[0],
39
41
  setIsResolvedViewRendered = _useState6[1];
40
42
  var onResolve = (0, _react.useCallback)(function (tr, title) {
41
- (0, _actions.registerRemoveOverlay)(function () {
42
- return setIsInserted(false);
43
- })(tr);
43
+ if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
44
+ var metadata = tr.getMeta(_pluginKey.pluginKey);
45
+ if (metadata && metadata.type === 'REGISTER') {
46
+ (0, _actions.registerRemoveOverlay)(function () {
47
+ return setIsInserted(false);
48
+ }, metadata.info)(tr);
49
+ } else {
50
+ (0, _actions.registerRemoveOverlay)(function () {
51
+ return setIsInserted(false);
52
+ })(tr);
53
+ }
54
+ } else {
55
+ (0, _actions.registerRemoveOverlay)(function () {
56
+ return setIsInserted(false);
57
+ })(tr);
58
+ }
44
59
  if (title) {
45
60
  setIsResolvedViewRendered(true);
46
61
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.showLinkToolbar = exports.showDatasourceModal = exports.setProvider = exports.setDatasourceTableRef = exports.setDatasourceStash = exports.setCardLayoutAndDatasourceTableRef = exports.setCardLayout = exports.resolveCard = exports.removeDatasourceStash = exports.registerSmartCardEvents = exports.registerRemoveOverlay = exports.registerCard = exports.queueCards = exports.hideLinkToolbar = exports.hideDatasourceModal = exports.clearOverlayCandidate = exports.cardAction = void 0;
6
+ exports.showLinkToolbar = exports.showDatasourceModal = exports.setProvider = exports.setDatasourceTableRef = exports.setDatasourceStash = exports.setCardLayoutAndDatasourceTableRef = exports.setCardLayout = exports.resolveCard = exports.removeDatasourceStash = exports.removeCard = exports.registerSmartCardEvents = exports.registerRemoveOverlay = exports.registerCard = exports.queueCards = exports.hideLinkToolbar = exports.hideDatasourceModal = exports.clearOverlayCandidate = exports.cardAction = void 0;
7
7
  var _pluginKey = require("./plugin-key");
8
8
  var cardAction = exports.cardAction = function cardAction(tr, action) {
9
9
  return tr.setMeta(_pluginKey.pluginKey, action);
@@ -32,11 +32,20 @@ var registerCard = exports.registerCard = function registerCard(info) {
32
32
  });
33
33
  };
34
34
  };
35
- var registerRemoveOverlay = exports.registerRemoveOverlay = function registerRemoveOverlay(callback) {
35
+ var removeCard = exports.removeCard = function removeCard(info) {
36
+ return function (tr) {
37
+ return cardAction(tr, {
38
+ type: 'REMOVE_CARD',
39
+ info: info
40
+ });
41
+ };
42
+ };
43
+ var registerRemoveOverlay = exports.registerRemoveOverlay = function registerRemoveOverlay(callback, info) {
36
44
  return function (tr) {
37
45
  return cardAction(tr, {
38
46
  type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK',
39
- callback: callback
47
+ callback: callback,
48
+ info: info
40
49
  });
41
50
  };
42
51
  };
@@ -35,6 +35,13 @@ var register = function register(state, action) {
35
35
  }).concat(action.info)
36
36
  });
37
37
  };
38
+ var removeCard = function removeCard(state, action) {
39
+ return _objectSpread(_objectSpread({}, state), {}, {
40
+ cards: state.cards.filter(function (card) {
41
+ return card.id !== action.info.id;
42
+ })
43
+ });
44
+ };
38
45
  var setProvider = function setProvider(state, action) {
39
46
  return _objectSpread(_objectSpread({}, state), {}, {
40
47
  provider: action.provider
@@ -85,6 +92,10 @@ var clearOverlayCandidate = function clearOverlayCandidate(state) {
85
92
  };
86
93
  var registerRemoveOverlayOnInsertedLink = function registerRemoveOverlayOnInsertedLink(state, action) {
87
94
  return _objectSpread(_objectSpread({}, state), {}, {
95
+ cards: action.info ? state.cards.filter(function (card) {
96
+ var _action$info;
97
+ return card.pos !== ((_action$info = action.info) === null || _action$info === void 0 ? void 0 : _action$info.pos);
98
+ }).concat(action.info) : state.cards,
88
99
  removeOverlay: action.callback
89
100
  });
90
101
  };
@@ -114,6 +125,8 @@ var _default = exports.default = function _default(state, action) {
114
125
  return resolve(state, action);
115
126
  case 'REGISTER':
116
127
  return register(state, action);
128
+ case 'REMOVE_CARD':
129
+ return removeCard(state, action);
117
130
  case 'REGISTER_EVENTS':
118
131
  return registerEvents(state, action);
119
132
  case 'SET_DATASOURCE_TABLE_REF':
@@ -1,13 +1,14 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import rafSchedule from 'raf-schd';
4
+ import uuid from 'uuid/v4';
4
5
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
5
6
  import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
6
7
  import { browser, canRenderDatasource } from '@atlaskit/editor-common/utils';
7
8
  import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { Card as SmartCard } from '@atlaskit/smart-card';
9
10
  import { Datasource } from '../nodeviews/datasource';
10
- import { registerCard } from '../pm-plugins/actions';
11
+ import { registerCard, removeCard } from '../pm-plugins/actions';
11
12
  import { isDatasourceNode } from '../pm-plugins/utils';
12
13
  import { Card } from './genericCard';
13
14
 
@@ -40,7 +41,8 @@ export class BlockCardComponent extends React.PureComponent {
40
41
  view.dispatch(registerCard({
41
42
  title,
42
43
  url,
43
- pos
44
+ pos,
45
+ id: this.props.id
44
46
  })(view.state.tr));
45
47
  })();
46
48
  });
@@ -99,6 +101,7 @@ const WrappedBlockCard = Card(BlockCardComponent, UnsupportedBlock);
99
101
  export class BlockCard extends ReactNodeView {
100
102
  constructor(...args) {
101
103
  super(...args);
104
+ _defineProperty(this, "id", uuid());
102
105
  _defineProperty(this, "updateContentEditable", (editorViewModeState, divElement) => {
103
106
  divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
104
107
  });
@@ -144,12 +147,25 @@ export class BlockCard extends ReactNodeView {
144
147
  getPos: this.getPos,
145
148
  actionOptions: actionOptions,
146
149
  pluginInjectionApi: pluginInjectionApi,
147
- onClickCallback: onClickCallback
150
+ onClickCallback: onClickCallback,
151
+ id: this.id
148
152
  });
149
153
  }
150
154
  destroy() {
151
155
  var _this$unsubscribe;
152
156
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
157
+ if (fg('platform_editor_fix_card_plugin_state')) {
158
+ this.removeCard();
159
+ }
160
+ }
161
+ removeCard() {
162
+ const {
163
+ tr
164
+ } = this.view.state;
165
+ removeCard({
166
+ id: this.id
167
+ })(tr);
168
+ this.view.dispatch(tr);
153
169
  }
154
170
  }
155
171
  export const blockCardNodeView = ({
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import React from 'react';
4
4
  import rafSchedule from 'raf-schd';
5
+ import uuid from 'uuid/v4';
5
6
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
6
7
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
8
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
@@ -10,7 +11,7 @@ import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-
10
11
  import { DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
11
12
  import { fg } from '@atlaskit/platform-feature-flags';
12
13
  import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
13
- import { registerCard } from '../pm-plugins/actions';
14
+ import { registerCard, removeCard } from '../pm-plugins/actions';
14
15
  import ResizableEmbedCard from '../ui/ResizableEmbedCard';
15
16
  import { Card } from './genericCard';
16
17
  const CardInner = ({
@@ -151,7 +152,8 @@ export class EmbedCardComponent extends React.PureComponent {
151
152
  return view.dispatch(registerCard({
152
153
  title,
153
154
  url,
154
- pos
155
+ pos,
156
+ id: this.props.id
155
157
  })(view.state.tr));
156
158
  })();
157
159
  try {
@@ -332,6 +334,7 @@ const WrappedBlockCard = Card(EmbedCardComponent, UnsupportedBlock);
332
334
  export class EmbedCard extends ReactNodeView {
333
335
  constructor(...args) {
334
336
  super(...args);
337
+ _defineProperty(this, "id", uuid());
335
338
  _defineProperty(this, "updateContentEditable", (editorViewModeState, divElement) => {
336
339
  divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
337
340
  });
@@ -381,6 +384,18 @@ export class EmbedCard extends ReactNodeView {
381
384
  destroy() {
382
385
  var _this$unsubscribe;
383
386
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
387
+ if (fg('platform_editor_fix_card_plugin_state')) {
388
+ this.removeCard();
389
+ }
390
+ }
391
+ removeCard() {
392
+ const {
393
+ tr
394
+ } = this.view.state;
395
+ removeCard({
396
+ id: this.id
397
+ })(tr);
398
+ this.view.dispatch(tr);
384
399
  }
385
400
  }
386
401
  export const embedCardNodeView = ({
@@ -1,13 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { memo, useCallback, useMemo, useState } from 'react';
2
+ import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import rafSchedule from 'raf-schd';
4
+ import uuid from 'uuid/v4';
4
5
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
6
  import { handleNavigation } from '@atlaskit/editor-common/link';
6
7
  import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
7
8
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
8
9
  import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import { Card as SmartCard } from '@atlaskit/smart-card';
10
- import { registerCard } from '../pm-plugins/actions';
11
+ import { registerCard, removeCard } from '../pm-plugins/actions';
11
12
  import { getAwarenessProps } from '../pm-plugins/utils';
12
13
  import OverlayWrapper from '../ui/ConfigureOverlay';
13
14
  import { Card } from './genericCard';
@@ -29,6 +30,21 @@ export const InlineCard = /*#__PURE__*/memo(({
29
30
  url,
30
31
  data
31
32
  } = node.attrs;
33
+ const refId = useRef(uuid());
34
+ useEffect(() => {
35
+ const id = refId.current;
36
+ return () => {
37
+ if (fg('platform_editor_fix_card_plugin_state')) {
38
+ const {
39
+ tr
40
+ } = view.state;
41
+ removeCard({
42
+ id
43
+ })(tr);
44
+ view.dispatch(tr);
45
+ }
46
+ };
47
+ }, [getPos, view]);
32
48
  const scrollContainer = useMemo(
33
49
  // Ignored via go/ees005
34
50
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -53,7 +69,8 @@ export const InlineCard = /*#__PURE__*/memo(({
53
69
  registerCard({
54
70
  title,
55
71
  url,
56
- pos
72
+ pos,
73
+ id: refId.current
57
74
  })(tr);
58
75
  onRes === null || onRes === void 0 ? void 0 : onRes(tr, title);
59
76
  view.dispatch(tr);
@@ -1,5 +1,7 @@
1
1
  import React, { memo, useCallback, useMemo, useState } from 'react';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { registerRemoveOverlay } from '../pm-plugins/actions';
4
+ import { pluginKey } from '../pm-plugins/plugin-key';
3
5
  import { AwarenessWrapper } from '../ui/AwarenessWrapper';
4
6
  import { InlineCard } from './inlineCard';
5
7
  export const InlineCardWithAwareness = /*#__PURE__*/memo(({
@@ -19,7 +21,16 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
19
21
  const [isInserted, setIsInserted] = useState(false);
20
22
  const [isResolvedViewRendered, setIsResolvedViewRendered] = useState(false);
21
23
  const onResolve = useCallback((tr, title) => {
22
- registerRemoveOverlay(() => setIsInserted(false))(tr);
24
+ if (fg('platform_editor_fix_card_plugin_state')) {
25
+ const metadata = tr.getMeta(pluginKey);
26
+ if (metadata && metadata.type === 'REGISTER') {
27
+ registerRemoveOverlay(() => setIsInserted(false), metadata.info)(tr);
28
+ } else {
29
+ registerRemoveOverlay(() => setIsInserted(false))(tr);
30
+ }
31
+ } else {
32
+ registerRemoveOverlay(() => setIsInserted(false))(tr);
33
+ }
23
34
  if (title) {
24
35
  setIsResolvedViewRendered(true);
25
36
  }
@@ -14,9 +14,14 @@ export const registerCard = info => tr => cardAction(tr, {
14
14
  type: 'REGISTER',
15
15
  info
16
16
  });
17
- export const registerRemoveOverlay = callback => tr => cardAction(tr, {
17
+ export const removeCard = info => tr => cardAction(tr, {
18
+ type: 'REMOVE_CARD',
19
+ info
20
+ });
21
+ export const registerRemoveOverlay = (callback, info) => tr => cardAction(tr, {
18
22
  type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK',
19
- callback
23
+ callback,
24
+ info
20
25
  });
21
26
  export const registerSmartCardEvents = smartLinkEvents => tr => cardAction(tr, {
22
27
  type: 'REGISTER_EVENTS',
@@ -22,6 +22,12 @@ const register = (state, action) => {
22
22
  cards: state.cards.filter(card => card.pos !== action.info.pos).concat(action.info)
23
23
  };
24
24
  };
25
+ const removeCard = (state, action) => {
26
+ return {
27
+ ...state,
28
+ cards: state.cards.filter(card => card.id !== action.info.id)
29
+ };
30
+ };
25
31
  const setProvider = (state, action) => {
26
32
  return {
27
33
  ...state,
@@ -82,6 +88,10 @@ const clearOverlayCandidate = state => {
82
88
  const registerRemoveOverlayOnInsertedLink = (state, action) => {
83
89
  return {
84
90
  ...state,
91
+ cards: action.info ? state.cards.filter(card => {
92
+ var _action$info;
93
+ return card.pos !== ((_action$info = action.info) === null || _action$info === void 0 ? void 0 : _action$info.pos);
94
+ }).concat(action.info) : state.cards,
85
95
  removeOverlay: action.callback
86
96
  };
87
97
  };
@@ -116,6 +126,8 @@ export default ((state, action) => {
116
126
  return resolve(state, action);
117
127
  case 'REGISTER':
118
128
  return register(state, action);
129
+ case 'REMOVE_CARD':
130
+ return removeCard(state, action);
119
131
  case 'REGISTER_EVENTS':
120
132
  return registerEvents(state, action);
121
133
  case 'SET_DATASOURCE_TABLE_REF':
@@ -10,13 +10,14 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
10
10
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
11
  import React from 'react';
12
12
  import rafSchedule from 'raf-schd';
13
+ import uuid from 'uuid/v4';
13
14
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
14
15
  import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
15
16
  import { browser, canRenderDatasource } from '@atlaskit/editor-common/utils';
16
17
  import { fg } from '@atlaskit/platform-feature-flags';
17
18
  import { Card as SmartCard } from '@atlaskit/smart-card';
18
19
  import { Datasource } from '../nodeviews/datasource';
19
- import { registerCard } from '../pm-plugins/actions';
20
+ import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
20
21
  import { isDatasourceNode } from '../pm-plugins/utils';
21
22
  import { Card } from './genericCard';
22
23
 
@@ -48,7 +49,8 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
48
49
  view.dispatch(registerCard({
49
50
  title: title,
50
51
  url: url,
51
- pos: pos
52
+ pos: pos,
53
+ id: _this.props.id
52
54
  })(view.state.tr));
53
55
  })();
54
56
  });
@@ -114,6 +116,7 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
114
116
  args[_key] = arguments[_key];
115
117
  }
116
118
  _this2 = _callSuper(this, BlockCard, [].concat(args));
119
+ _defineProperty(_this2, "id", uuid());
117
120
  _defineProperty(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
118
121
  divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
119
122
  });
@@ -171,7 +174,8 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
171
174
  getPos: this.getPos,
172
175
  actionOptions: actionOptions,
173
176
  pluginInjectionApi: pluginInjectionApi,
174
- onClickCallback: onClickCallback
177
+ onClickCallback: onClickCallback,
178
+ id: this.id
175
179
  });
176
180
  }
177
181
  }, {
@@ -179,6 +183,18 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
179
183
  value: function destroy() {
180
184
  var _this$unsubscribe;
181
185
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
186
+ if (fg('platform_editor_fix_card_plugin_state')) {
187
+ this.removeCard();
188
+ }
189
+ }
190
+ }, {
191
+ key: "removeCard",
192
+ value: function removeCard() {
193
+ var tr = this.view.state.tr;
194
+ _removeCard({
195
+ id: this.id
196
+ })(tr);
197
+ this.view.dispatch(tr);
182
198
  }
183
199
  }]);
184
200
  }(ReactNodeView);
@@ -13,6 +13,7 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
13
13
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
14
14
  import React from 'react';
15
15
  import rafSchedule from 'raf-schd';
16
+ import uuid from 'uuid/v4';
16
17
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
17
18
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
18
19
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
@@ -21,7 +22,7 @@ import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-
21
22
  import { DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
22
23
  import { fg } from '@atlaskit/platform-feature-flags';
23
24
  import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
24
- import { registerCard } from '../pm-plugins/actions';
25
+ import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
25
26
  import ResizableEmbedCard from '../ui/ResizableEmbedCard';
26
27
  import { Card } from './genericCard';
27
28
  var CardInner = function CardInner(_ref) {
@@ -155,7 +156,8 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
155
156
  return view.dispatch(registerCard({
156
157
  title: title,
157
158
  url: url,
158
- pos: pos
159
+ pos: pos,
160
+ id: _this.props.id
159
161
  })(view.state.tr));
160
162
  })();
161
163
  try {
@@ -338,6 +340,7 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
338
340
  args[_key] = arguments[_key];
339
341
  }
340
342
  _this2 = _callSuper(this, EmbedCard, [].concat(args));
343
+ _defineProperty(_this2, "id", uuid());
341
344
  _defineProperty(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
342
345
  divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
343
346
  });
@@ -398,6 +401,18 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
398
401
  value: function destroy() {
399
402
  var _this$unsubscribe;
400
403
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
404
+ if (fg('platform_editor_fix_card_plugin_state')) {
405
+ this.removeCard();
406
+ }
407
+ }
408
+ }, {
409
+ key: "removeCard",
410
+ value: function removeCard() {
411
+ var tr = this.view.state.tr;
412
+ _removeCard({
413
+ id: this.id
414
+ })(tr);
415
+ this.view.dispatch(tr);
401
416
  }
402
417
  }]);
403
418
  }(ReactNodeView);
@@ -1,14 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import React, { memo, useCallback, useMemo, useState } from 'react';
3
+ import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import rafSchedule from 'raf-schd';
5
+ import uuid from 'uuid/v4';
5
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
7
  import { handleNavigation } from '@atlaskit/editor-common/link';
7
8
  import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
8
9
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
9
10
  import { fg } from '@atlaskit/platform-feature-flags';
10
11
  import { Card as SmartCard } from '@atlaskit/smart-card';
11
- import { registerCard } from '../pm-plugins/actions';
12
+ import { registerCard, removeCard } from '../pm-plugins/actions';
12
13
  import { getAwarenessProps } from '../pm-plugins/utils';
13
14
  import OverlayWrapper from '../ui/ConfigureOverlay';
14
15
  import { Card } from './genericCard';
@@ -28,6 +29,19 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
28
29
  var _node$attrs = node.attrs,
29
30
  url = _node$attrs.url,
30
31
  data = _node$attrs.data;
32
+ var refId = useRef(uuid());
33
+ useEffect(function () {
34
+ var id = refId.current;
35
+ return function () {
36
+ if (fg('platform_editor_fix_card_plugin_state')) {
37
+ var tr = view.state.tr;
38
+ removeCard({
39
+ id: id
40
+ })(tr);
41
+ view.dispatch(tr);
42
+ }
43
+ };
44
+ }, [getPos, view]);
31
45
  var scrollContainer = useMemo(
32
46
  // Ignored via go/ees005
33
47
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -52,7 +66,8 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
52
66
  registerCard({
53
67
  title: title,
54
68
  url: url,
55
- pos: pos
69
+ pos: pos,
70
+ id: refId.current
56
71
  })(tr);
57
72
  onRes === null || onRes === void 0 || onRes(tr, title);
58
73
  view.dispatch(tr);
@@ -1,6 +1,8 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { memo, useCallback, useMemo, useState } from 'react';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { registerRemoveOverlay } from '../pm-plugins/actions';
5
+ import { pluginKey } from '../pm-plugins/plugin-key';
4
6
  import { AwarenessWrapper } from '../ui/AwarenessWrapper';
5
7
  import { InlineCard } from './inlineCard';
6
8
  export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
@@ -28,9 +30,22 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
28
30
  isResolvedViewRendered = _useState6[0],
29
31
  setIsResolvedViewRendered = _useState6[1];
30
32
  var onResolve = useCallback(function (tr, title) {
31
- registerRemoveOverlay(function () {
32
- return setIsInserted(false);
33
- })(tr);
33
+ if (fg('platform_editor_fix_card_plugin_state')) {
34
+ var metadata = tr.getMeta(pluginKey);
35
+ if (metadata && metadata.type === 'REGISTER') {
36
+ registerRemoveOverlay(function () {
37
+ return setIsInserted(false);
38
+ }, metadata.info)(tr);
39
+ } else {
40
+ registerRemoveOverlay(function () {
41
+ return setIsInserted(false);
42
+ })(tr);
43
+ }
44
+ } else {
45
+ registerRemoveOverlay(function () {
46
+ return setIsInserted(false);
47
+ })(tr);
48
+ }
34
49
  if (title) {
35
50
  setIsResolvedViewRendered(true);
36
51
  }
@@ -26,11 +26,20 @@ export var registerCard = function registerCard(info) {
26
26
  });
27
27
  };
28
28
  };
29
- export var registerRemoveOverlay = function registerRemoveOverlay(callback) {
29
+ export var removeCard = function removeCard(info) {
30
+ return function (tr) {
31
+ return cardAction(tr, {
32
+ type: 'REMOVE_CARD',
33
+ info: info
34
+ });
35
+ };
36
+ };
37
+ export var registerRemoveOverlay = function registerRemoveOverlay(callback, info) {
30
38
  return function (tr) {
31
39
  return cardAction(tr, {
32
40
  type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK',
33
- callback: callback
41
+ callback: callback,
42
+ info: info
34
43
  });
35
44
  };
36
45
  };
@@ -28,6 +28,13 @@ var register = function register(state, action) {
28
28
  }).concat(action.info)
29
29
  });
30
30
  };
31
+ var removeCard = function removeCard(state, action) {
32
+ return _objectSpread(_objectSpread({}, state), {}, {
33
+ cards: state.cards.filter(function (card) {
34
+ return card.id !== action.info.id;
35
+ })
36
+ });
37
+ };
31
38
  var setProvider = function setProvider(state, action) {
32
39
  return _objectSpread(_objectSpread({}, state), {}, {
33
40
  provider: action.provider
@@ -78,6 +85,10 @@ var clearOverlayCandidate = function clearOverlayCandidate(state) {
78
85
  };
79
86
  var registerRemoveOverlayOnInsertedLink = function registerRemoveOverlayOnInsertedLink(state, action) {
80
87
  return _objectSpread(_objectSpread({}, state), {}, {
88
+ cards: action.info ? state.cards.filter(function (card) {
89
+ var _action$info;
90
+ return card.pos !== ((_action$info = action.info) === null || _action$info === void 0 ? void 0 : _action$info.pos);
91
+ }).concat(action.info) : state.cards,
81
92
  removeOverlay: action.callback
82
93
  });
83
94
  };
@@ -107,6 +118,8 @@ export default (function (state, action) {
107
118
  return resolve(state, action);
108
119
  case 'REGISTER':
109
120
  return register(state, action);
121
+ case 'REMOVE_CARD':
122
+ return removeCard(state, action);
110
123
  case 'REGISTER_EVENTS':
111
124
  return registerEvents(state, action);
112
125
  case 'SET_DATASOURCE_TABLE_REF':
@@ -5,9 +5,13 @@ import type { Node } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Decoration, DecorationSource, EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import { Datasource } from '../nodeviews/datasource';
7
7
  import type { SmartCardProps } from './genericCard';
8
- export declare class BlockCardComponent extends React.PureComponent<SmartCardProps> {
8
+ export declare class BlockCardComponent extends React.PureComponent<SmartCardProps & {
9
+ id?: string;
10
+ }> {
9
11
  private scrollContainer?;
10
- constructor(props: SmartCardProps);
12
+ constructor(props: SmartCardProps & {
13
+ id?: string;
14
+ });
11
15
  onResolve: (data: {
12
16
  url?: string | undefined;
13
17
  title?: string | undefined;
@@ -20,6 +24,7 @@ export declare class BlockCardComponent extends React.PureComponent<SmartCardPro
20
24
  }
21
25
  export type BlockCardNodeViewProps = Pick<SmartCardProps, 'actionOptions' | 'pluginInjectionApi' | 'onClickCallback'>;
22
26
  export declare class BlockCard extends ReactNodeView<BlockCardNodeViewProps> {
27
+ private id;
23
28
  unsubscribe: (() => void) | undefined;
24
29
  createDomRef(): HTMLElement;
25
30
  private updateContentEditable;
@@ -27,6 +32,7 @@ export declare class BlockCard extends ReactNodeView<BlockCardNodeViewProps> {
27
32
  update(node: Node, decorations: ReadonlyArray<Decoration>, _innerDecorations?: DecorationSource): boolean;
28
33
  render(): JSX.Element;
29
34
  destroy(): void;
35
+ private removeCard;
30
36
  }
31
37
  export interface BlockCardNodeViewProperties {
32
38
  pmPluginFactoryParams: PMPluginFactoryParams;
@@ -11,10 +11,14 @@ export type EmbedCardState = {
11
11
  liveHeight?: number;
12
12
  initialAspectRatio?: number;
13
13
  };
14
- export declare class EmbedCardComponent extends React.PureComponent<SmartCardProps, EmbedCardState> {
14
+ export declare class EmbedCardComponent extends React.PureComponent<SmartCardProps & {
15
+ id?: string;
16
+ }, EmbedCardState> {
15
17
  private scrollContainer?;
16
18
  private embedIframeRef;
17
- constructor(props: SmartCardProps);
19
+ constructor(props: SmartCardProps & {
20
+ id?: string;
21
+ });
18
22
  state: EmbedCardState;
19
23
  private getPosSafely;
20
24
  onResolve: (data: {
@@ -38,12 +42,14 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
38
42
  }
39
43
  export type EmbedCardNodeViewProps = Pick<SmartCardProps, 'eventDispatcher' | 'allowResizing' | 'fullWidthMode' | 'dispatchAnalyticsEvent' | 'pluginInjectionApi' | 'actionOptions' | 'onClickCallback'>;
40
44
  export declare class EmbedCard extends ReactNodeView<EmbedCardNodeViewProps> {
45
+ private id;
41
46
  unsubscribe: (() => void) | undefined;
42
47
  viewShouldUpdate(nextNode: PMNode): boolean;
43
48
  createDomRef(): HTMLElement;
44
49
  private updateContentEditable;
45
50
  render(): JSX.Element;
46
51
  destroy(): void;
52
+ private removeCard;
47
53
  }
48
54
  export interface EmbedCardNodeViewProperties {
49
55
  allowResizing: EmbedCardNodeViewProps['allowResizing'];
@@ -46,4 +46,6 @@ export interface SmartCardProps extends CardProps {
46
46
  allowBlockCards?: boolean;
47
47
  enableInlineUpgradeFeatures?: boolean;
48
48
  }
49
- export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
49
+ export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps & {
50
+ id?: string;
51
+ }>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
@@ -9,7 +9,8 @@ export declare const cardAction: (tr: Transaction, action: CardPluginAction) =>
9
9
  export declare const resolveCard: (url: string) => (tr: Transaction) => Transaction;
10
10
  export declare const queueCards: (requests: Request[]) => (tr: Transaction) => Transaction;
11
11
  export declare const registerCard: (info: CardInfo) => (tr: Transaction) => Transaction;
12
- export declare const registerRemoveOverlay: (callback: () => void) => (tr: Transaction) => Transaction;
12
+ export declare const removeCard: (info: Partial<CardInfo>) => (tr: Transaction) => Transaction;
13
+ export declare const registerRemoveOverlay: (callback: () => void, info?: CardInfo) => (tr: Transaction) => Transaction;
13
14
  export declare const registerSmartCardEvents: (smartLinkEvents: SmartLinkEvents) => (tr: Transaction) => Transaction;
14
15
  export declare const setProvider: (cardProvider: CardProvider | null) => (tr: Transaction) => Transaction;
15
16
  export declare const setDatasourceTableRef: (datasourceTableRef?: HTMLElement) => (tr: Transaction) => Transaction;
@@ -17,6 +17,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
17
17
  pos: number;
18
18
  title?: string | undefined;
19
19
  url?: string | undefined;
20
+ id?: string | undefined;
20
21
  }[];
21
22
  provider: import("@atlaskit/editor-common/provider-factory").CardProvider | null;
22
23
  datasourceStash: {
@@ -17,6 +17,7 @@ export type DatasourceNode = Omit<Node, 'attrs'> & {
17
17
  export type CardInfo = {
18
18
  title?: string;
19
19
  url?: string;
20
+ id?: string;
20
21
  pos: number;
21
22
  };
22
23
  export type Request = {
@@ -123,6 +124,10 @@ export type Register = {
123
124
  type: 'REGISTER';
124
125
  info: CardInfo;
125
126
  };
127
+ export type RemoveCard = {
128
+ type: 'REMOVE_CARD';
129
+ info: Partial<CardInfo>;
130
+ };
126
131
  export type ShowLinkToolbar = {
127
132
  type: 'SHOW_LINK_TOOLBAR';
128
133
  };
@@ -159,6 +164,7 @@ type ClearOverlayCandidate = {
159
164
  type RegisterRemoveOverlayOnInsertedLink = {
160
165
  type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK';
161
166
  callback: () => void;
167
+ info?: Register['info'];
162
168
  };
163
169
  export type SetDatasourceStash = {
164
170
  type: 'SET_DATASOURCE_STASH';
@@ -171,5 +177,5 @@ export type RemoveDatasourceStash = {
171
177
  type: 'REMOVE_DATASOURCE_STASH';
172
178
  url: string;
173
179
  };
174
- export type CardPluginAction = SetProvider | Queue | Resolve | Register | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
180
+ export type CardPluginAction = SetProvider | Queue | Resolve | Register | RemoveCard | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
175
181
  export {};
@@ -5,9 +5,13 @@ import type { Node } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Decoration, DecorationSource, EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import { Datasource } from '../nodeviews/datasource';
7
7
  import type { SmartCardProps } from './genericCard';
8
- export declare class BlockCardComponent extends React.PureComponent<SmartCardProps> {
8
+ export declare class BlockCardComponent extends React.PureComponent<SmartCardProps & {
9
+ id?: string;
10
+ }> {
9
11
  private scrollContainer?;
10
- constructor(props: SmartCardProps);
12
+ constructor(props: SmartCardProps & {
13
+ id?: string;
14
+ });
11
15
  onResolve: (data: {
12
16
  url?: string | undefined;
13
17
  title?: string | undefined;
@@ -20,6 +24,7 @@ export declare class BlockCardComponent extends React.PureComponent<SmartCardPro
20
24
  }
21
25
  export type BlockCardNodeViewProps = Pick<SmartCardProps, 'actionOptions' | 'pluginInjectionApi' | 'onClickCallback'>;
22
26
  export declare class BlockCard extends ReactNodeView<BlockCardNodeViewProps> {
27
+ private id;
23
28
  unsubscribe: (() => void) | undefined;
24
29
  createDomRef(): HTMLElement;
25
30
  private updateContentEditable;
@@ -27,6 +32,7 @@ export declare class BlockCard extends ReactNodeView<BlockCardNodeViewProps> {
27
32
  update(node: Node, decorations: ReadonlyArray<Decoration>, _innerDecorations?: DecorationSource): boolean;
28
33
  render(): JSX.Element;
29
34
  destroy(): void;
35
+ private removeCard;
30
36
  }
31
37
  export interface BlockCardNodeViewProperties {
32
38
  pmPluginFactoryParams: PMPluginFactoryParams;
@@ -11,10 +11,14 @@ export type EmbedCardState = {
11
11
  liveHeight?: number;
12
12
  initialAspectRatio?: number;
13
13
  };
14
- export declare class EmbedCardComponent extends React.PureComponent<SmartCardProps, EmbedCardState> {
14
+ export declare class EmbedCardComponent extends React.PureComponent<SmartCardProps & {
15
+ id?: string;
16
+ }, EmbedCardState> {
15
17
  private scrollContainer?;
16
18
  private embedIframeRef;
17
- constructor(props: SmartCardProps);
19
+ constructor(props: SmartCardProps & {
20
+ id?: string;
21
+ });
18
22
  state: EmbedCardState;
19
23
  private getPosSafely;
20
24
  onResolve: (data: {
@@ -38,12 +42,14 @@ export declare class EmbedCardComponent extends React.PureComponent<SmartCardPro
38
42
  }
39
43
  export type EmbedCardNodeViewProps = Pick<SmartCardProps, 'eventDispatcher' | 'allowResizing' | 'fullWidthMode' | 'dispatchAnalyticsEvent' | 'pluginInjectionApi' | 'actionOptions' | 'onClickCallback'>;
40
44
  export declare class EmbedCard extends ReactNodeView<EmbedCardNodeViewProps> {
45
+ private id;
41
46
  unsubscribe: (() => void) | undefined;
42
47
  viewShouldUpdate(nextNode: PMNode): boolean;
43
48
  createDomRef(): HTMLElement;
44
49
  private updateContentEditable;
45
50
  render(): JSX.Element;
46
51
  destroy(): void;
52
+ private removeCard;
47
53
  }
48
54
  export interface EmbedCardNodeViewProperties {
49
55
  allowResizing: EmbedCardNodeViewProps['allowResizing'];
@@ -46,4 +46,6 @@ export interface SmartCardProps extends CardProps {
46
46
  allowBlockCards?: boolean;
47
47
  enableInlineUpgradeFeatures?: boolean;
48
48
  }
49
- export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
49
+ export declare function Card(SmartCardComponent: React.ComponentType<React.PropsWithChildren<SmartCardProps & {
50
+ id?: string;
51
+ }>>, UnsupportedComponent: React.ComponentType<React.PropsWithChildren<unknown>>): React.ComponentType<React.PropsWithChildren<CardProps>>;
@@ -9,7 +9,8 @@ export declare const cardAction: (tr: Transaction, action: CardPluginAction) =>
9
9
  export declare const resolveCard: (url: string) => (tr: Transaction) => Transaction;
10
10
  export declare const queueCards: (requests: Request[]) => (tr: Transaction) => Transaction;
11
11
  export declare const registerCard: (info: CardInfo) => (tr: Transaction) => Transaction;
12
- export declare const registerRemoveOverlay: (callback: () => void) => (tr: Transaction) => Transaction;
12
+ export declare const removeCard: (info: Partial<CardInfo>) => (tr: Transaction) => Transaction;
13
+ export declare const registerRemoveOverlay: (callback: () => void, info?: CardInfo) => (tr: Transaction) => Transaction;
13
14
  export declare const registerSmartCardEvents: (smartLinkEvents: SmartLinkEvents) => (tr: Transaction) => Transaction;
14
15
  export declare const setProvider: (cardProvider: CardProvider | null) => (tr: Transaction) => Transaction;
15
16
  export declare const setDatasourceTableRef: (datasourceTableRef?: HTMLElement) => (tr: Transaction) => Transaction;
@@ -17,6 +17,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
17
17
  pos: number;
18
18
  title?: string | undefined;
19
19
  url?: string | undefined;
20
+ id?: string | undefined;
20
21
  }[];
21
22
  provider: import("@atlaskit/editor-common/provider-factory").CardProvider | null;
22
23
  datasourceStash: {
@@ -17,6 +17,7 @@ export type DatasourceNode = Omit<Node, 'attrs'> & {
17
17
  export type CardInfo = {
18
18
  title?: string;
19
19
  url?: string;
20
+ id?: string;
20
21
  pos: number;
21
22
  };
22
23
  export type Request = {
@@ -123,6 +124,10 @@ export type Register = {
123
124
  type: 'REGISTER';
124
125
  info: CardInfo;
125
126
  };
127
+ export type RemoveCard = {
128
+ type: 'REMOVE_CARD';
129
+ info: Partial<CardInfo>;
130
+ };
126
131
  export type ShowLinkToolbar = {
127
132
  type: 'SHOW_LINK_TOOLBAR';
128
133
  };
@@ -159,6 +164,7 @@ type ClearOverlayCandidate = {
159
164
  type RegisterRemoveOverlayOnInsertedLink = {
160
165
  type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK';
161
166
  callback: () => void;
167
+ info?: Register['info'];
162
168
  };
163
169
  export type SetDatasourceStash = {
164
170
  type: 'SET_DATASOURCE_STASH';
@@ -171,5 +177,5 @@ export type RemoveDatasourceStash = {
171
177
  type: 'REMOVE_DATASOURCE_STASH';
172
178
  url: string;
173
179
  };
174
- export type CardPluginAction = SetProvider | Queue | Resolve | Register | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
180
+ export type CardPluginAction = SetProvider | Queue | Resolve | Register | RemoveCard | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
175
181
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "4.5.17",
3
+ "version": "4.5.18",
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": "^46.1.0",
35
35
  "@atlaskit/analytics-next": "^10.3.0",
36
36
  "@atlaskit/custom-steps": "^0.9.0",
37
- "@atlaskit/editor-common": "^99.6.0",
37
+ "@atlaskit/editor-common": "^99.7.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^1.11.0",
39
39
  "@atlaskit/editor-plugin-base": "^2.1.0",
40
40
  "@atlaskit/editor-plugin-connectivity": "^1.1.0",
@@ -48,16 +48,16 @@
48
48
  "@atlaskit/editor-prosemirror": "6.2.1",
49
49
  "@atlaskit/editor-shared-styles": "^3.2.0",
50
50
  "@atlaskit/frontend-utilities": "^2.9.0",
51
- "@atlaskit/icon": "^23.5.0",
51
+ "@atlaskit/icon": "^23.6.0",
52
52
  "@atlaskit/link-analytics": "^8.7.0",
53
53
  "@atlaskit/link-client-extension": "^3.1.0",
54
- "@atlaskit/link-datasource": "^3.17.0",
54
+ "@atlaskit/link-datasource": "^3.18.0",
55
55
  "@atlaskit/linking-common": "^6.2.0",
56
56
  "@atlaskit/linking-types": "^9.6.0",
57
- "@atlaskit/menu": "2.14.0",
58
- "@atlaskit/platform-feature-flags": "^0.3.0",
57
+ "@atlaskit/menu": "2.14.1",
58
+ "@atlaskit/platform-feature-flags": "^1.0.0",
59
59
  "@atlaskit/primitives": "^13.4.0",
60
- "@atlaskit/smart-card": "^34.8.0",
60
+ "@atlaskit/smart-card": "^34.10.0",
61
61
  "@atlaskit/theme": "^14.1.0",
62
62
  "@atlaskit/tmp-editor-statsig": "^2.41.0",
63
63
  "@atlaskit/tokens": "^3.3.0",
@@ -65,7 +65,8 @@
65
65
  "@emotion/react": "^11.7.1",
66
66
  "lodash": "^4.17.21",
67
67
  "prop-types": "^15.5.10",
68
- "raf-schd": "^4.0.3"
68
+ "raf-schd": "^4.0.3",
69
+ "uuid": "^3.1.0"
69
70
  },
70
71
  "peerDependencies": {
71
72
  "@atlaskit/link-provider": "^1.17.0",
@@ -133,6 +134,9 @@
133
134
  "platform_inline_node_as_valid_annotation_selection": {
134
135
  "type": "boolean"
135
136
  },
137
+ "platform_editor_fix_card_plugin_state": {
138
+ "type": "boolean"
139
+ },
136
140
  "platform_fix_embedded_card_re-rendering": {
137
141
  "type": "boolean"
138
142
  }