@atlaskit/editor-plugin-card 27.0.3 → 27.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 27.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`067939baaaeb9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/067939baaaeb9) -
8
+ Fix the pre-auth value proposition modal in the `platform_sl_3p_preauth_value_modal` experiment
9
+ treatments behind `platform_sl_3p_preauth_value_modal_killswitch`:
10
+ - Allow titles to wrap in both treatment variants. Preserve the image variant's default height
11
+ while allowing taller text to reveal more of the centered illustration, keeping provider icons
12
+ aligned.
13
+ - Truncate long provider names in the Connect button so the Close button remains fully visible.
14
+ - Prevent editor floating toolbars from appearing above the modal using the existing `overlayOpen`
15
+ user intent, without layout effects that warn during server rendering.
16
+
17
+ In `@atlaskit/smart-card/pre-auth-value-proposition-modal`, `PreAuthValuePropositionModalProps`
18
+ adds optional `onOpenChange` to notify hosts when the modal opens, closes, or unmounts.
19
+ `@atlaskit/editor-plugin-card` adds an optional `UserIntentPlugin` integration and declares its
20
+ package dependency.
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+
3
26
  ## 27.0.3
4
27
 
5
28
  ### Patch Changes
@@ -177,6 +177,7 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref2) {
177
177
  editorViewForPasteMenu = editorView;
178
178
  var breakoutEnabled = options.editorAppearance === 'full-page';
179
179
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (0, _fg.fg)('platform_sl_3p_preauth_value_modal_killswitch') ? /*#__PURE__*/_react.default.createElement(_PreAuthValuePropositionModal.PreAuthValuePropositionModalListener, {
180
+ api: api,
180
181
  cardPluginEvents: cardPluginEvents
181
182
  }) : null, shouldRegisterPasteDisplayAsMenu && /*#__PURE__*/_react.default.createElement(PasteMenuSmartCardClientSync, {
182
183
  clientRef: pasteMenuSmartCardClientRef
@@ -29,11 +29,35 @@ var getNewSmartLinkUrl = function getNewSmartLinkUrl(event) {
29
29
  }
30
30
  };
31
31
  var ModalListener = function ModalListener(_ref) {
32
- var cardPluginEvents = _ref.cardPluginEvents;
32
+ var api = _ref.api,
33
+ cardPluginEvents = _ref.cardPluginEvents;
33
34
  var _useState = (0, _react.useState)(),
34
35
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
35
36
  url = _useState2[0],
36
37
  setUrl = _useState2[1];
38
+ var _useState3 = (0, _react.useState)(false),
39
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
40
+ isOpen = _useState4[0],
41
+ setIsOpen = _useState4[1];
42
+
43
+ // While the pre-auth modal is visible, use 'overlayOpen' to suppress the floating toolbar.
44
+ // Jira portals editor popups above its issue dialog, so the toolbar would otherwise appear
45
+ // above the modal blanket. Keep it available while link eligibility is still being checked.
46
+ // On close or unmount, restore the previous intent unless another interaction has changed it.
47
+ (0, _react.useEffect)(function () {
48
+ var _api$userIntent$share, _api$userIntent$share2;
49
+ if (!isOpen || !(api !== null && api !== void 0 && api.userIntent)) {
50
+ return;
51
+ }
52
+ var previousIntent = (_api$userIntent$share = (_api$userIntent$share2 = api.userIntent.sharedState.currentState()) === null || _api$userIntent$share2 === void 0 ? void 0 : _api$userIntent$share2.currentUserIntent) !== null && _api$userIntent$share !== void 0 ? _api$userIntent$share : 'default';
53
+ api.core.actions.execute(api.userIntent.commands.setCurrentUserIntent('overlayOpen'));
54
+ return function () {
55
+ var _api$userIntent;
56
+ if (((_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) === 'overlayOpen') {
57
+ api.core.actions.execute(api.userIntent.commands.setCurrentUserIntent(previousIntent));
58
+ }
59
+ };
60
+ }, [api, isOpen]);
37
61
  (0, _react.useEffect)(function () {
38
62
  return cardPluginEvents.subscribe(function (event) {
39
63
  var newSmartLinkUrl = getNewSmartLinkUrl(event);
@@ -45,14 +69,16 @@ var ModalListener = function ModalListener(_ref) {
45
69
  });
46
70
  }, [cardPluginEvents]);
47
71
  var onFinished = (0, _react.useCallback)(function () {
48
- return setUrl(undefined);
72
+ setIsOpen(false);
73
+ setUrl(undefined);
49
74
  }, []);
50
75
  return url ? /*#__PURE__*/_react.default.createElement(_react.Suspense, {
51
76
  fallback: null
52
77
  }, /*#__PURE__*/_react.default.createElement(PreAuthValuePropositionModal, {
53
78
  key: url,
54
79
  url: url,
55
- onFinished: onFinished
80
+ onFinished: onFinished,
81
+ onOpenChange: setIsOpen
56
82
  })) : null;
57
83
  };
58
84
  var PreAuthValuePropositionModalListener = exports.PreAuthValuePropositionModalListener = /*#__PURE__*/_react.default.memo(ModalListener);
@@ -172,6 +172,7 @@ export const cardPlugin = ({
172
172
  editorViewForPasteMenu = editorView;
173
173
  const breakoutEnabled = options.editorAppearance === 'full-page';
174
174
  return /*#__PURE__*/React.createElement(React.Fragment, null, fg('platform_sl_3p_preauth_value_modal_killswitch') ? /*#__PURE__*/React.createElement(PreAuthValuePropositionModalListener, {
175
+ api: api,
175
176
  cardPluginEvents: cardPluginEvents
176
177
  }) : null, shouldRegisterPasteDisplayAsMenu && /*#__PURE__*/React.createElement(PasteMenuSmartCardClientSync, {
177
178
  clientRef: pasteMenuSmartCardClientRef
@@ -13,22 +13,47 @@ const getNewSmartLinkUrl = event => {
13
13
  }
14
14
  };
15
15
  const ModalListener = ({
16
+ api,
16
17
  cardPluginEvents
17
18
  }) => {
18
19
  const [url, setUrl] = useState();
20
+ const [isOpen, setIsOpen] = useState(false);
21
+
22
+ // While the pre-auth modal is visible, use 'overlayOpen' to suppress the floating toolbar.
23
+ // Jira portals editor popups above its issue dialog, so the toolbar would otherwise appear
24
+ // above the modal blanket. Keep it available while link eligibility is still being checked.
25
+ // On close or unmount, restore the previous intent unless another interaction has changed it.
26
+ useEffect(() => {
27
+ var _api$userIntent$share, _api$userIntent$share2;
28
+ if (!isOpen || !(api !== null && api !== void 0 && api.userIntent)) {
29
+ return;
30
+ }
31
+ const previousIntent = (_api$userIntent$share = (_api$userIntent$share2 = api.userIntent.sharedState.currentState()) === null || _api$userIntent$share2 === void 0 ? void 0 : _api$userIntent$share2.currentUserIntent) !== null && _api$userIntent$share !== void 0 ? _api$userIntent$share : 'default';
32
+ api.core.actions.execute(api.userIntent.commands.setCurrentUserIntent('overlayOpen'));
33
+ return () => {
34
+ var _api$userIntent, _api$userIntent$share3;
35
+ if (((_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : (_api$userIntent$share3 = _api$userIntent.sharedState.currentState()) === null || _api$userIntent$share3 === void 0 ? void 0 : _api$userIntent$share3.currentUserIntent) === 'overlayOpen') {
36
+ api.core.actions.execute(api.userIntent.commands.setCurrentUserIntent(previousIntent));
37
+ }
38
+ };
39
+ }, [api, isOpen]);
19
40
  useEffect(() => cardPluginEvents.subscribe(event => {
20
41
  const newSmartLinkUrl = getNewSmartLinkUrl(event);
21
42
  if (newSmartLinkUrl) {
22
43
  setUrl(currentUrl => currentUrl !== null && currentUrl !== void 0 ? currentUrl : newSmartLinkUrl);
23
44
  }
24
45
  }), [cardPluginEvents]);
25
- const onFinished = useCallback(() => setUrl(undefined), []);
46
+ const onFinished = useCallback(() => {
47
+ setIsOpen(false);
48
+ setUrl(undefined);
49
+ }, []);
26
50
  return url ? /*#__PURE__*/React.createElement(Suspense, {
27
51
  fallback: null
28
52
  }, /*#__PURE__*/React.createElement(PreAuthValuePropositionModal, {
29
53
  key: url,
30
54
  url: url,
31
- onFinished: onFinished
55
+ onFinished: onFinished,
56
+ onOpenChange: setIsOpen
32
57
  })) : null;
33
58
  };
34
59
  export const PreAuthValuePropositionModalListener = /*#__PURE__*/React.memo(ModalListener);
@@ -169,6 +169,7 @@ export var cardPlugin = function cardPlugin(_ref2) {
169
169
  editorViewForPasteMenu = editorView;
170
170
  var breakoutEnabled = options.editorAppearance === 'full-page';
171
171
  return /*#__PURE__*/React.createElement(React.Fragment, null, fg('platform_sl_3p_preauth_value_modal_killswitch') ? /*#__PURE__*/React.createElement(PreAuthValuePropositionModalListener, {
172
+ api: api,
172
173
  cardPluginEvents: cardPluginEvents
173
174
  }) : null, shouldRegisterPasteDisplayAsMenu && /*#__PURE__*/React.createElement(PasteMenuSmartCardClientSync, {
174
175
  clientRef: pasteMenuSmartCardClientRef
@@ -18,11 +18,35 @@ var getNewSmartLinkUrl = function getNewSmartLinkUrl(event) {
18
18
  }
19
19
  };
20
20
  var ModalListener = function ModalListener(_ref) {
21
- var cardPluginEvents = _ref.cardPluginEvents;
21
+ var api = _ref.api,
22
+ cardPluginEvents = _ref.cardPluginEvents;
22
23
  var _useState = useState(),
23
24
  _useState2 = _slicedToArray(_useState, 2),
24
25
  url = _useState2[0],
25
26
  setUrl = _useState2[1];
27
+ var _useState3 = useState(false),
28
+ _useState4 = _slicedToArray(_useState3, 2),
29
+ isOpen = _useState4[0],
30
+ setIsOpen = _useState4[1];
31
+
32
+ // While the pre-auth modal is visible, use 'overlayOpen' to suppress the floating toolbar.
33
+ // Jira portals editor popups above its issue dialog, so the toolbar would otherwise appear
34
+ // above the modal blanket. Keep it available while link eligibility is still being checked.
35
+ // On close or unmount, restore the previous intent unless another interaction has changed it.
36
+ useEffect(function () {
37
+ var _api$userIntent$share, _api$userIntent$share2;
38
+ if (!isOpen || !(api !== null && api !== void 0 && api.userIntent)) {
39
+ return;
40
+ }
41
+ var previousIntent = (_api$userIntent$share = (_api$userIntent$share2 = api.userIntent.sharedState.currentState()) === null || _api$userIntent$share2 === void 0 ? void 0 : _api$userIntent$share2.currentUserIntent) !== null && _api$userIntent$share !== void 0 ? _api$userIntent$share : 'default';
42
+ api.core.actions.execute(api.userIntent.commands.setCurrentUserIntent('overlayOpen'));
43
+ return function () {
44
+ var _api$userIntent;
45
+ if (((_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) === 'overlayOpen') {
46
+ api.core.actions.execute(api.userIntent.commands.setCurrentUserIntent(previousIntent));
47
+ }
48
+ };
49
+ }, [api, isOpen]);
26
50
  useEffect(function () {
27
51
  return cardPluginEvents.subscribe(function (event) {
28
52
  var newSmartLinkUrl = getNewSmartLinkUrl(event);
@@ -34,14 +58,16 @@ var ModalListener = function ModalListener(_ref) {
34
58
  });
35
59
  }, [cardPluginEvents]);
36
60
  var onFinished = useCallback(function () {
37
- return setUrl(undefined);
61
+ setIsOpen(false);
62
+ setUrl(undefined);
38
63
  }, []);
39
64
  return url ? /*#__PURE__*/React.createElement(Suspense, {
40
65
  fallback: null
41
66
  }, /*#__PURE__*/React.createElement(PreAuthValuePropositionModal, {
42
67
  key: url,
43
68
  url: url,
44
- onFinished: onFinished
69
+ onFinished: onFinished,
70
+ onOpenChange: setIsOpen
45
71
  })) : null;
46
72
  };
47
73
  export var PreAuthValuePropositionModalListener = /*#__PURE__*/React.memo(ModalListener);
@@ -16,6 +16,7 @@ import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
16
16
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
17
17
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
18
18
  import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
19
+ import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent/user-intent-plugin-type';
19
20
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
20
21
  import type { CardPluginOptions, CardPluginState } from './types';
21
22
  type DummyAnnotationPlugin = NextEditorPlugin<'annotation', {
@@ -38,7 +39,8 @@ export type CardPluginDependencies = [
38
39
  OptionalPlugin<ConnectivityPlugin>,
39
40
  OptionalPlugin<BasePlugin>,
40
41
  OptionalPlugin<ToolbarPlugin>,
41
- OptionalPlugin<UiControlRegistryPlugin>
42
+ OptionalPlugin<UiControlRegistryPlugin>,
43
+ OptionalPlugin<UserIntentPlugin>
42
44
  ];
43
45
  export type CardPlugin = NextEditorPlugin<'card', {
44
46
  actions: CardPluginActions;
@@ -1,7 +1,10 @@
1
1
  import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { CardPlugin } from '../cardPluginType';
2
4
  import type { EditorCardPluginEvents } from './analytics/create-events-queue';
3
5
  import type { CardPluginEvent } from './analytics/types';
4
6
  type PreAuthValuePropositionModalListenerProps = {
7
+ api?: ExtractInjectionAPI<CardPlugin>;
5
8
  cardPluginEvents: EditorCardPluginEvents<CardPluginEvent>;
6
9
  };
7
10
  export declare const PreAuthValuePropositionModalListener: React.MemoExoticComponent<(props: PreAuthValuePropositionModalListenerProps) => React.JSX.Element | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "27.0.3",
3
+ "version": "27.1.0",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -40,6 +40,7 @@
40
40
  "@atlaskit/editor-plugin-selection": "^21.0.0",
41
41
  "@atlaskit/editor-plugin-toolbar": "^18.0.0",
42
42
  "@atlaskit/editor-plugin-ui-control-registry": "^15.0.0",
43
+ "@atlaskit/editor-plugin-user-intent": "^19.0.0",
43
44
  "@atlaskit/editor-plugin-width": "^22.0.0",
44
45
  "@atlaskit/editor-prosemirror": "^9.0.0",
45
46
  "@atlaskit/editor-shared-styles": "^4.3.0",
@@ -62,7 +63,7 @@
62
63
  "@atlaskit/platform-feature-flags-react": "^1.2.0",
63
64
  "@atlaskit/primitives": "^22.5.0",
64
65
  "@atlaskit/prosemirror-history": "^1.2.0",
65
- "@atlaskit/smart-card": "^46.0.0",
66
+ "@atlaskit/smart-card": "^46.1.0",
66
67
  "@atlaskit/tmp-editor-statsig": "^208.0.0",
67
68
  "@atlaskit/tokens": "^20.0.0",
68
69
  "@babel/runtime": "^7.0.0",