@atlaskit/editor-plugin-card 13.0.1 → 13.0.3

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,20 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 13.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 13.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`14aa7871be0b7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/14aa7871be0b7) -
14
+ [ux] EDITOR-5513: fix(editor-plugin-card): guard inline card cleanup to dispatch removeCard at
15
+ most once per effect cycle
16
+ - Updated dependencies
17
+
3
18
  ## 13.0.1
4
19
 
5
20
  ### Patch Changes
@@ -49,12 +49,18 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
49
49
  data = _node$attrs.data;
50
50
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
51
51
  var refId = (0, _react.useRef)((0, _v.default)());
52
+ var removeCardDispatched = (0, _react.useRef)(false);
52
53
  var _ref2 = (cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {},
53
54
  getSmartlinkState = _ref2.getState;
54
55
  var cardState = getSmartlinkState === null || getSmartlinkState === void 0 ? void 0 : getSmartlinkState()[url || ''];
55
56
  (0, _react.useEffect)(function () {
56
57
  var id = refId.current;
58
+ removeCardDispatched.current = false;
57
59
  return function () {
60
+ if ((0, _expValEquals.expValEquals)('platform_editor_inline_card_dispatch_guard', 'isEnabled', true) && removeCardDispatched.current) {
61
+ return;
62
+ }
63
+ removeCardDispatched.current = true;
58
64
  var tr = view.state.tr;
59
65
  (0, _actions.removeCard)({
60
66
  id: id
@@ -167,6 +173,7 @@ var selector = function selector(states) {
167
173
  };
168
174
 
169
175
  /**
176
+ * Inline card node view component that renders a Smart Link inline card within the editor.
170
177
  *
171
178
  * @param props
172
179
  * @example
@@ -39,13 +39,19 @@ export const InlineCard = /*#__PURE__*/memo(({
39
39
  } = node.attrs;
40
40
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
41
41
  const refId = useRef(uuid());
42
+ const removeCardDispatched = useRef(false);
42
43
  const {
43
44
  getState: getSmartlinkState
44
45
  } = (cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {};
45
46
  const cardState = getSmartlinkState === null || getSmartlinkState === void 0 ? void 0 : getSmartlinkState()[url || ''];
46
47
  useEffect(() => {
47
48
  const id = refId.current;
49
+ removeCardDispatched.current = false;
48
50
  return () => {
51
+ if (expValEquals('platform_editor_inline_card_dispatch_guard', 'isEnabled', true) && removeCardDispatched.current) {
52
+ return;
53
+ }
54
+ removeCardDispatched.current = true;
49
55
  const {
50
56
  tr
51
57
  } = view.state;
@@ -163,6 +169,7 @@ const selector = states => {
163
169
  };
164
170
 
165
171
  /**
172
+ * Inline card node view component that renders a Smart Link inline card within the editor.
166
173
  *
167
174
  * @param props
168
175
  * @example
@@ -37,12 +37,18 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
37
37
  data = _node$attrs.data;
38
38
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
39
39
  var refId = useRef(uuid());
40
+ var removeCardDispatched = useRef(false);
40
41
  var _ref2 = (cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {},
41
42
  getSmartlinkState = _ref2.getState;
42
43
  var cardState = getSmartlinkState === null || getSmartlinkState === void 0 ? void 0 : getSmartlinkState()[url || ''];
43
44
  useEffect(function () {
44
45
  var id = refId.current;
46
+ removeCardDispatched.current = false;
45
47
  return function () {
48
+ if (expValEquals('platform_editor_inline_card_dispatch_guard', 'isEnabled', true) && removeCardDispatched.current) {
49
+ return;
50
+ }
51
+ removeCardDispatched.current = true;
46
52
  var tr = view.state.tr;
47
53
  removeCard({
48
54
  id: id
@@ -155,6 +161,7 @@ var selector = function selector(states) {
155
161
  };
156
162
 
157
163
  /**
164
+ * Inline card node view component that renders a Smart Link inline card within the editor.
158
165
  *
159
166
  * @param props
160
167
  * @example
@@ -7,6 +7,7 @@ import { type InlineCardWithAwarenessProps } from './inlineCardWithAwareness';
7
7
  export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, onClick, onResolve, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, pluginInjectionApi, disablePreviewPanel, }: SmartCardProps) => React.JSX.Element | null>;
8
8
  export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback' | 'isPageSSRed' | 'CompetitorPrompt' | 'provider'>;
9
9
  /**
10
+ * Inline card node view component that renders a Smart Link inline card within the editor.
10
11
  *
11
12
  * @param props
12
13
  * @example
@@ -7,6 +7,7 @@ import { type InlineCardWithAwarenessProps } from './inlineCardWithAwareness';
7
7
  export declare const InlineCard: React.MemoExoticComponent<({ node, cardContext, actionOptions, useAlternativePreloader, view, getPos, onClick, onResolve, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, pluginInjectionApi, disablePreviewPanel, }: SmartCardProps) => React.JSX.Element | null>;
8
8
  export type InlineCardNodeViewProps = Pick<SmartCardProps, 'useAlternativePreloader' | 'actionOptions' | 'allowEmbeds' | 'allowBlockCards' | 'enableInlineUpgradeFeatures' | 'pluginInjectionApi' | 'onClickCallback' | 'isPageSSRed' | 'CompetitorPrompt' | 'provider'>;
9
9
  /**
10
+ * Inline card node view component that renders a Smart Link inline card within the editor.
10
11
  *
11
12
  * @param props
12
13
  * @example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "13.0.1",
3
+ "version": "13.0.3",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -62,7 +62,7 @@
62
62
  "@atlaskit/prosemirror-history": "^0.2.0",
63
63
  "@atlaskit/smart-card": "^43.26.0",
64
64
  "@atlaskit/theme": "^22.0.0",
65
- "@atlaskit/tmp-editor-statsig": "^36.0.0",
65
+ "@atlaskit/tmp-editor-statsig": "^37.0.0",
66
66
  "@atlaskit/tokens": "^11.1.0",
67
67
  "@babel/runtime": "^7.0.0",
68
68
  "@emotion/react": "^11.7.1",
@@ -72,7 +72,7 @@
72
72
  "uuid": "^3.1.0"
73
73
  },
74
74
  "peerDependencies": {
75
- "@atlaskit/editor-common": "^112.0.0",
75
+ "@atlaskit/editor-common": "^112.2.0",
76
76
  "@atlaskit/link-provider": "^4.2.0",
77
77
  "react": "^18.2.0",
78
78
  "react-intl-next": "npm:react-intl@^5.18.1"