@atlaskit/editor-plugin-card 5.0.0 → 5.0.1

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,14 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 5.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#117971](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117971)
8
+ [`d63604c31bb17`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d63604c31bb17) -
9
+ [ux] Editor controls - Link consumption friendliness with open link on hover
10
+ - Updated dependencies
11
+
3
12
  ## 5.0.0
4
13
 
5
14
  ### Major Changes
@@ -9,10 +9,12 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
9
9
  var _react = require("react");
10
10
  var _react2 = require("@emotion/react");
11
11
  var _analyticsNext = require("@atlaskit/analytics-next");
12
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
12
13
  var _utils = require("../../pm-plugins/utils");
13
14
  var _useLinkUpgradeDiscoverability = _interopRequireDefault(require("../hooks/useLinkUpgradeDiscoverability"));
14
15
  var _InlineCardOverlay = _interopRequireDefault(require("../InlineCardOverlay"));
15
16
  var _localStorage = require("../local-storage");
17
+ var _OpenButtonOverlay = _interopRequireDefault(require("../OpenButtonOverlay"));
16
18
  var _Pulse = require("../Pulse");
17
19
  /**
18
20
  * @jsxRuntime classic
@@ -98,6 +100,18 @@ var AwarenessWrapper = exports.AwarenessWrapper = function AwarenessWrapper(_ref
98
100
  }
99
101
  return children;
100
102
  }, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
103
+ var cardWithOpenButtonOverlay = (0, _react.useMemo)(function () {
104
+ return (0, _react2.jsx)(_OpenButtonOverlay.default, {
105
+ isVisible: isHovered,
106
+ onMouseEnter: function onMouseEnter() {
107
+ return handleOverlayChange(true);
108
+ },
109
+ onMouseLeave: function onMouseLeave() {
110
+ return handleOverlayChange(false);
111
+ },
112
+ url: url
113
+ }, children);
114
+ }, [children, isHovered, url, handleOverlayChange]);
101
115
  return (0, _react.useMemo)(function () {
102
116
  var _cardContext$value;
103
117
  return (
@@ -115,7 +129,7 @@ var AwarenessWrapper = exports.AwarenessWrapper = function AwarenessWrapper(_ref
115
129
  discoveryMode: "start",
116
130
  shouldShowPulse: isResolvedViewRendered && shouldShowLinkPulse,
117
131
  testId: "link-discovery-pulse"
118
- }, cardWithOverlay)))
132
+ }, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? cardWithOpenButtonOverlay : cardWithOverlay)))
119
133
  );
120
- }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay]);
134
+ }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay, cardWithOpenButtonOverlay]);
121
135
  };
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _react2 = require("@emotion/react");
12
+ var _new = require("@atlaskit/button/new");
13
+ var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
14
+ var _excluded = ["children", "isVisible", "url"];
15
+ /* eslint-disable @atlaskit/design-system/no-nested-styles */
16
+ /* eslint-disable @atlaskit/design-system/prefer-primitives */
17
+ /**
18
+ * @jsxRuntime classic
19
+ * @jsx jsx
20
+ */
21
+ // eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
22
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
23
+ var containerStyles = (0, _react2.css)({
24
+ position: 'relative'
25
+ });
26
+ var overlayStyles = (0, _react2.css)({
27
+ position: 'absolute',
28
+ left: '2px',
29
+ top: 0,
30
+ backgroundColor: "var(--ds-background-accent-gray-subtlest, #F1F2F4)",
31
+ borderRadius: "var(--ds-border-radius, 3px)",
32
+ display: 'inline-flex',
33
+ justifyContent: 'flex-start',
34
+ alignItems: 'center',
35
+ verticalAlign: 'text-top',
36
+ height: '19px',
37
+ overflow: 'hidden',
38
+ // EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
39
+ zIndex: 2,
40
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
41
+ a: {
42
+ padding: "var(--ds-border-width, 1px)".concat(" ", "var(--ds-space-050, 4px)", " 0")
43
+ }
44
+ });
45
+ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
46
+ var children = _ref.children,
47
+ _ref$isVisible = _ref.isVisible,
48
+ isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
49
+ url = _ref.url,
50
+ props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
51
+ // TODO add translation
52
+ var label = 'Open';
53
+ var handleDoubleClick = function handleDoubleClick() {
54
+ // Double click opens the link in a new tab
55
+ window.open(url, '_blank');
56
+ };
57
+ return (
58
+ // Ignored via go/ees005
59
+ // eslint-disable-next-line react/jsx-props-no-spreading, jsx-a11y/no-static-element-interactions
60
+ (0, _react2.jsx)("span", (0, _extends2.default)({}, props, {
61
+ css: containerStyles,
62
+ onDoubleClick: handleDoubleClick
63
+ }), children, isVisible && (0, _react2.jsx)("div", {
64
+ css: [overlayStyles]
65
+ }, (0, _react2.jsx)(_new.LinkButton, {
66
+ spacing: "compact",
67
+ href: url,
68
+ target: "_blank",
69
+ iconBefore: _linkExternal.default,
70
+ appearance: "default"
71
+ }, label)))
72
+ );
73
+ };
74
+ var _default = exports.default = OpenButtonOverlay;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -7,10 +7,12 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { AnalyticsContext } from '@atlaskit/analytics-next';
10
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
11
  import { getResolvedAttributesFromStore } from '../../pm-plugins/utils';
11
12
  import useLinkUpgradeDiscoverability from '../hooks/useLinkUpgradeDiscoverability';
12
13
  import InlineCardOverlay from '../InlineCardOverlay';
13
14
  import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../local-storage';
15
+ import OpenButtonOverlay from '../OpenButtonOverlay';
14
16
  import { DiscoveryPulse } from '../Pulse';
15
17
  // editor adds a standard line-height that is bigger than an inline smart link
16
18
  // due to that the link has a bit of white space around it, which doesn't look right when there is pulse around it
@@ -84,6 +86,14 @@ export const AwarenessWrapper = ({
84
86
  }
85
87
  return children;
86
88
  }, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
89
+ const cardWithOpenButtonOverlay = useMemo(() => {
90
+ return jsx(OpenButtonOverlay, {
91
+ isVisible: isHovered,
92
+ onMouseEnter: () => handleOverlayChange(true),
93
+ onMouseLeave: () => handleOverlayChange(false),
94
+ url: url
95
+ }, children);
96
+ }, [children, isHovered, url, handleOverlayChange]);
87
97
  return useMemo(() => {
88
98
  var _cardContext$value;
89
99
  return (
@@ -101,7 +111,7 @@ export const AwarenessWrapper = ({
101
111
  discoveryMode: "start",
102
112
  shouldShowPulse: isResolvedViewRendered && shouldShowLinkPulse,
103
113
  testId: "link-discovery-pulse"
104
- }, cardWithOverlay)))
114
+ }, editorExperiment('platform_editor_controls', 'variant1') ? cardWithOpenButtonOverlay : cardWithOverlay)))
105
115
  );
106
- }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay]);
116
+ }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay, cardWithOpenButtonOverlay]);
107
117
  };
@@ -0,0 +1,65 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ /* eslint-disable @atlaskit/design-system/no-nested-styles */
3
+ /* eslint-disable @atlaskit/design-system/prefer-primitives */
4
+ /**
5
+ * @jsxRuntime classic
6
+ * @jsx jsx
7
+ */
8
+ import React from 'react';
9
+ import { css, jsx } from '@emotion/react'; // eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
10
+
11
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
12
+ import { LinkButton } from '@atlaskit/button/new';
13
+ import LinkExternalIcon from '@atlaskit/icon/core/link-external';
14
+ const containerStyles = css({
15
+ position: 'relative'
16
+ });
17
+ const overlayStyles = css({
18
+ position: 'absolute',
19
+ left: '2px',
20
+ top: 0,
21
+ backgroundColor: "var(--ds-background-accent-gray-subtlest, #F1F2F4)",
22
+ borderRadius: "var(--ds-border-radius, 3px)",
23
+ display: 'inline-flex',
24
+ justifyContent: 'flex-start',
25
+ alignItems: 'center',
26
+ verticalAlign: 'text-top',
27
+ height: '19px',
28
+ overflow: 'hidden',
29
+ // EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
30
+ zIndex: 2,
31
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
32
+ a: {
33
+ padding: `${"var(--ds-border-width, 1px)"} ${"var(--ds-space-050, 4px)"} 0`
34
+ }
35
+ });
36
+ const OpenButtonOverlay = ({
37
+ children,
38
+ isVisible = false,
39
+ url,
40
+ ...props
41
+ }) => {
42
+ // TODO add translation
43
+ const label = 'Open';
44
+ const handleDoubleClick = () => {
45
+ // Double click opens the link in a new tab
46
+ window.open(url, '_blank');
47
+ };
48
+ return (
49
+ // Ignored via go/ees005
50
+ // eslint-disable-next-line react/jsx-props-no-spreading, jsx-a11y/no-static-element-interactions
51
+ jsx("span", _extends({}, props, {
52
+ css: containerStyles,
53
+ onDoubleClick: handleDoubleClick
54
+ }), children, isVisible && jsx("div", {
55
+ css: [overlayStyles]
56
+ }, jsx(LinkButton, {
57
+ spacing: "compact",
58
+ href: url,
59
+ target: "_blank",
60
+ iconBefore: LinkExternalIcon,
61
+ appearance: "default"
62
+ }, label)))
63
+ );
64
+ };
65
+ export default OpenButtonOverlay;
File without changes
@@ -8,10 +8,12 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
9
  import { css, jsx } from '@emotion/react';
10
10
  import { AnalyticsContext } from '@atlaskit/analytics-next';
11
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
12
  import { getResolvedAttributesFromStore } from '../../pm-plugins/utils';
12
13
  import useLinkUpgradeDiscoverability from '../hooks/useLinkUpgradeDiscoverability';
13
14
  import InlineCardOverlay from '../InlineCardOverlay';
14
15
  import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../local-storage';
16
+ import OpenButtonOverlay from '../OpenButtonOverlay';
15
17
  import { DiscoveryPulse } from '../Pulse';
16
18
  // editor adds a standard line-height that is bigger than an inline smart link
17
19
  // due to that the link has a bit of white space around it, which doesn't look right when there is pulse around it
@@ -90,6 +92,18 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
90
92
  }
91
93
  return children;
92
94
  }, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
95
+ var cardWithOpenButtonOverlay = useMemo(function () {
96
+ return jsx(OpenButtonOverlay, {
97
+ isVisible: isHovered,
98
+ onMouseEnter: function onMouseEnter() {
99
+ return handleOverlayChange(true);
100
+ },
101
+ onMouseLeave: function onMouseLeave() {
102
+ return handleOverlayChange(false);
103
+ },
104
+ url: url
105
+ }, children);
106
+ }, [children, isHovered, url, handleOverlayChange]);
93
107
  return useMemo(function () {
94
108
  var _cardContext$value;
95
109
  return (
@@ -107,7 +121,7 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
107
121
  discoveryMode: "start",
108
122
  shouldShowPulse: isResolvedViewRendered && shouldShowLinkPulse,
109
123
  testId: "link-discovery-pulse"
110
- }, cardWithOverlay)))
124
+ }, editorExperiment('platform_editor_controls', 'variant1') ? cardWithOpenButtonOverlay : cardWithOverlay)))
111
125
  );
112
- }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay]);
126
+ }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay, cardWithOpenButtonOverlay]);
113
127
  };
@@ -0,0 +1,67 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["children", "isVisible", "url"];
4
+ /* eslint-disable @atlaskit/design-system/no-nested-styles */
5
+ /* eslint-disable @atlaskit/design-system/prefer-primitives */
6
+ /**
7
+ * @jsxRuntime classic
8
+ * @jsx jsx
9
+ */
10
+ import React from 'react';
11
+ import { css, jsx } from '@emotion/react'; // eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
12
+
13
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
14
+ import { LinkButton } from '@atlaskit/button/new';
15
+ import LinkExternalIcon from '@atlaskit/icon/core/link-external';
16
+ var containerStyles = css({
17
+ position: 'relative'
18
+ });
19
+ var overlayStyles = css({
20
+ position: 'absolute',
21
+ left: '2px',
22
+ top: 0,
23
+ backgroundColor: "var(--ds-background-accent-gray-subtlest, #F1F2F4)",
24
+ borderRadius: "var(--ds-border-radius, 3px)",
25
+ display: 'inline-flex',
26
+ justifyContent: 'flex-start',
27
+ alignItems: 'center',
28
+ verticalAlign: 'text-top',
29
+ height: '19px',
30
+ overflow: 'hidden',
31
+ // EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
32
+ zIndex: 2,
33
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
34
+ a: {
35
+ padding: "var(--ds-border-width, 1px)".concat(" ", "var(--ds-space-050, 4px)", " 0")
36
+ }
37
+ });
38
+ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
39
+ var children = _ref.children,
40
+ _ref$isVisible = _ref.isVisible,
41
+ isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
42
+ url = _ref.url,
43
+ props = _objectWithoutProperties(_ref, _excluded);
44
+ // TODO add translation
45
+ var label = 'Open';
46
+ var handleDoubleClick = function handleDoubleClick() {
47
+ // Double click opens the link in a new tab
48
+ window.open(url, '_blank');
49
+ };
50
+ return (
51
+ // Ignored via go/ees005
52
+ // eslint-disable-next-line react/jsx-props-no-spreading, jsx-a11y/no-static-element-interactions
53
+ jsx("span", _extends({}, props, {
54
+ css: containerStyles,
55
+ onDoubleClick: handleDoubleClick
56
+ }), children, isVisible && jsx("div", {
57
+ css: [overlayStyles]
58
+ }, jsx(LinkButton, {
59
+ spacing: "compact",
60
+ href: url,
61
+ target: "_blank",
62
+ iconBefore: LinkExternalIcon,
63
+ appearance: "default"
64
+ }, label)))
65
+ );
66
+ };
67
+ export default OpenButtonOverlay;
File without changes
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import React from 'react';
6
+ import { jsx } from '@emotion/react';
7
+ import type { OpenButtonOverlayProps } from './types';
8
+ declare const OpenButtonOverlay: ({ children, isVisible, url, ...props }: React.PropsWithChildren<OpenButtonOverlayProps>) => jsx.JSX.Element;
9
+ export default OpenButtonOverlay;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export type OpenButtonOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
3
+ isVisible?: boolean;
4
+ url: string;
5
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import React from 'react';
6
+ import { jsx } from '@emotion/react';
7
+ import type { OpenButtonOverlayProps } from './types';
8
+ declare const OpenButtonOverlay: ({ children, isVisible, url, ...props }: React.PropsWithChildren<OpenButtonOverlayProps>) => jsx.JSX.Element;
9
+ export default OpenButtonOverlay;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export type OpenButtonOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
3
+ isVisible?: boolean;
4
+ url: string;
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
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": "^47.2.1",
35
35
  "@atlaskit/analytics-next": "^11.0.0",
36
36
  "@atlaskit/custom-steps": "^0.10.0",
37
- "@atlaskit/editor-common": "^100.0.0",
37
+ "@atlaskit/editor-common": "^100.1.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.0.0",
39
39
  "@atlaskit/editor-plugin-base": "^2.2.0",
40
40
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
@@ -59,8 +59,8 @@
59
59
  "@atlaskit/primitives": "^14.0.0",
60
60
  "@atlaskit/smart-card": "^35.0.0",
61
61
  "@atlaskit/theme": "^17.0.0",
62
- "@atlaskit/tmp-editor-statsig": "^3.0.0",
63
- "@atlaskit/tokens": "^4.0.0",
62
+ "@atlaskit/tmp-editor-statsig": "^3.1.0",
63
+ "@atlaskit/tokens": "^4.1.0",
64
64
  "@babel/runtime": "^7.0.0",
65
65
  "@emotion/react": "^11.7.1",
66
66
  "lodash": "^4.17.21",