@atlaskit/editor-plugin-card 2.6.1 → 2.6.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/nodeviews/blockCard.js +37 -13
  3. package/dist/cjs/nodeviews/embedCard.js +35 -10
  4. package/dist/cjs/toolbar.js +1 -0
  5. package/dist/cjs/ui/{EditToolbarButton.js → EditToolbarButton/EditToolbarButtonPresentation.js} +15 -65
  6. package/dist/cjs/ui/EditToolbarButton/index.js +286 -0
  7. package/dist/cjs/ui/EditToolbarButton/types.js +5 -0
  8. package/dist/cjs/ui/useFetchDatasourceDataInfo.js +75 -0
  9. package/dist/es2019/nodeviews/blockCard.js +21 -4
  10. package/dist/es2019/nodeviews/embedCard.js +20 -1
  11. package/dist/es2019/toolbar.js +1 -0
  12. package/dist/es2019/ui/{EditToolbarButton.js → EditToolbarButton/EditToolbarButtonPresentation.js} +14 -67
  13. package/dist/es2019/ui/EditToolbarButton/index.js +278 -0
  14. package/dist/es2019/ui/EditToolbarButton/types.js +1 -0
  15. package/dist/es2019/ui/useFetchDatasourceDataInfo.js +41 -0
  16. package/dist/esm/nodeviews/blockCard.js +38 -14
  17. package/dist/esm/nodeviews/embedCard.js +35 -10
  18. package/dist/esm/toolbar.js +1 -0
  19. package/dist/esm/ui/EditToolbarButton/EditToolbarButtonPresentation.js +116 -0
  20. package/dist/esm/ui/{EditToolbarButton.js → EditToolbarButton/index.js} +116 -4
  21. package/dist/esm/ui/EditToolbarButton/types.js +1 -0
  22. package/dist/esm/ui/useFetchDatasourceDataInfo.js +67 -0
  23. package/dist/types/nodeviews/blockCard.d.ts +3 -0
  24. package/dist/types/nodeviews/embedCard.d.ts +3 -0
  25. package/dist/types/ui/EditToolbarButton/EditToolbarButtonPresentation.d.ts +9 -0
  26. package/dist/types/ui/EditToolbarButton/index.d.ts +3 -0
  27. package/dist/types/ui/EditToolbarButton/types.d.ts +29 -0
  28. package/dist/types/ui/useFetchDatasourceDataInfo.d.ts +10 -0
  29. package/dist/types-ts4.5/nodeviews/blockCard.d.ts +3 -0
  30. package/dist/types-ts4.5/nodeviews/embedCard.d.ts +3 -0
  31. package/dist/types-ts4.5/ui/EditToolbarButton/EditToolbarButtonPresentation.d.ts +9 -0
  32. package/dist/types-ts4.5/ui/EditToolbarButton/index.d.ts +3 -0
  33. package/dist/types-ts4.5/ui/EditToolbarButton/types.d.ts +29 -0
  34. package/dist/types-ts4.5/ui/useFetchDatasourceDataInfo.d.ts +10 -0
  35. package/package.json +10 -7
  36. package/dist/cjs/ui/LeftIconOverlay/ConfigureLinkDropdown/index.js +0 -58
  37. package/dist/cjs/ui/LeftIconOverlay/index.js +0 -199
  38. package/dist/es2019/ui/LeftIconOverlay/ConfigureLinkDropdown/index.js +0 -47
  39. package/dist/es2019/ui/LeftIconOverlay/index.js +0 -177
  40. package/dist/esm/ui/LeftIconOverlay/ConfigureLinkDropdown/index.js +0 -48
  41. package/dist/esm/ui/LeftIconOverlay/index.js +0 -190
  42. package/dist/types/ui/EditToolbarButton.d.ts +0 -18
  43. package/dist/types/ui/LeftIconOverlay/ConfigureLinkDropdown/index.d.ts +0 -6
  44. package/dist/types/ui/LeftIconOverlay/index.d.ts +0 -10
  45. package/dist/types-ts4.5/ui/EditToolbarButton.d.ts +0 -18
  46. package/dist/types-ts4.5/ui/LeftIconOverlay/ConfigureLinkDropdown/index.d.ts +0 -6
  47. package/dist/types-ts4.5/ui/LeftIconOverlay/index.d.ts +0 -10
@@ -0,0 +1,29 @@
1
+ import { type IntlShape } from 'react-intl-next';
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
+ import type { Command } from '@atlaskit/editor-common/types';
4
+ import type { Node } from '@atlaskit/editor-prosemirror/model';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { CardContext } from '@atlaskit/link-provider';
7
+ import { type CardType } from '../../types';
8
+ export type EditVariant = 'none' | 'edit-link' | 'edit-datasource' | 'edit-dropdown';
9
+ export interface EditDatasourceToolbarButtonWithCommonProps {
10
+ intl: IntlShape;
11
+ onLinkEditClick: Command;
12
+ editorAnalyticsApi?: EditorAnalyticsAPI;
13
+ editorView?: EditorView;
14
+ currentAppearance?: CardType;
15
+ }
16
+ export interface EditDatasourceToolbarButtonWithUrlProps extends EditDatasourceToolbarButtonWithCommonProps {
17
+ cardContext?: CardContext;
18
+ url: string;
19
+ }
20
+ export interface EditDatasourceToolbarButtonWithDatasourceIdProps extends EditDatasourceToolbarButtonWithCommonProps {
21
+ datasourceId: string;
22
+ node: Node;
23
+ }
24
+ export type EditDatasourceToolbarButtonProps = EditDatasourceToolbarButtonWithCommonProps & {
25
+ cardContext?: CardContext;
26
+ url?: string;
27
+ datasourceId?: string;
28
+ node?: Node;
29
+ };
@@ -0,0 +1,10 @@
1
+ import type { JiraIssueDatasourceParameters } from '@atlaskit/link-datasource';
2
+ import type { DatasourceParameters } from '@atlaskit/linking-types';
3
+ export interface useFetchDatasourceDataInfoProps {
4
+ datasourceId: string;
5
+ parameters?: DatasourceParameters | JiraIssueDatasourceParameters;
6
+ visibleColumnKeys?: string[];
7
+ }
8
+ export declare const useFetchDatasourceDataInfo: ({ datasourceId, parameters, visibleColumnKeys, }: useFetchDatasourceDataInfoProps) => {
9
+ extensionKey: string | undefined;
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,10 +34,8 @@
34
34
  "dependencies": {
35
35
  "@atlaskit/adf-schema": "^39.0.3",
36
36
  "@atlaskit/analytics-next": "^9.3.0",
37
- "@atlaskit/button": "^18.4.0",
38
37
  "@atlaskit/custom-steps": "^0.4.0",
39
- "@atlaskit/dropdown-menu": "^12.14.0",
40
- "@atlaskit/editor-common": "^86.0.0",
38
+ "@atlaskit/editor-common": "^86.2.0",
41
39
  "@atlaskit/editor-plugin-analytics": "^1.4.0",
42
40
  "@atlaskit/editor-plugin-decorations": "^1.1.0",
43
41
  "@atlaskit/editor-plugin-editor-disabled": "^1.1.0",
@@ -55,13 +53,12 @@
55
53
  "@atlaskit/link-datasource": "^2.5.0",
56
54
  "@atlaskit/linking-common": "^5.7.0",
57
55
  "@atlaskit/linking-types": "^8.11.0",
58
- "@atlaskit/menu": "2.8.0",
56
+ "@atlaskit/menu": "2.8.1",
59
57
  "@atlaskit/platform-feature-flags": "^0.3.0",
60
58
  "@atlaskit/primitives": "^11.0.0",
61
59
  "@atlaskit/smart-card": "^27.9.0",
62
60
  "@atlaskit/theme": "^12.11.0",
63
- "@atlaskit/tokens": "^1.55.0",
64
- "@atlaskit/tooltip": "^18.5.0",
61
+ "@atlaskit/tokens": "^1.56.0",
65
62
  "@babel/runtime": "^7.0.0",
66
63
  "@emotion/react": "^11.7.1",
67
64
  "lodash": "^4.17.21",
@@ -107,6 +104,9 @@
107
104
  }
108
105
  },
109
106
  "platform-feature-flags": {
107
+ "enable_datasource_nourl_edit_dropdown_datafetch": {
108
+ "type": "boolean"
109
+ },
110
110
  "platform.linking-platform.enable-datasource-edit-dropdown-toolbar": {
111
111
  "type": "boolean"
112
112
  },
@@ -136,6 +136,9 @@
136
136
  },
137
137
  "platform_editor_get_card_provider_from_config": {
138
138
  "type": "boolean"
139
+ },
140
+ "linking-platform-contenteditable-false-live-view": {
141
+ "type": "boolean"
139
142
  }
140
143
  },
141
144
  "stricter": {
@@ -1,58 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
- var _react = _interopRequireDefault(require("react"));
12
- var _reactIntlNext = require("react-intl-next");
13
- var _new = _interopRequireDefault(require("@atlaskit/button/new"));
14
- var _dropdownMenu = _interopRequireWildcard(require("@atlaskit/dropdown-menu"));
15
- var _messages = require("@atlaskit/editor-common/messages");
16
- var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
17
- var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferences"));
18
- var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
19
- var _excluded = ["triggerRef"];
20
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
21
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
- var ConfigureLinkDropdown = function ConfigureLinkDropdown(props) {
23
- var testId = props.testId;
24
- var intl = (0, _reactIntlNext.useIntl)();
25
- var configureLinkLabel = intl.formatMessage(_messages.cardMessages.inlineConfigureLink);
26
- var goToLinkLabel = intl.formatMessage(_messages.cardMessages.inlineConfigureLink);
27
- return /*#__PURE__*/_react.default.createElement(_dropdownMenu.default, {
28
- trigger: function trigger(_ref) {
29
- var triggerRef = _ref.triggerRef,
30
- props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
31
- return /*#__PURE__*/_react.default.createElement(_new.default, (0, _extends2.default)({}, props, {
32
- spacing: 'none',
33
- ref: triggerRef
34
- }), /*#__PURE__*/_react.default.createElement("span", {
35
- style: {
36
- padding: "0 ".concat("var(--ds-space-025, 2px)")
37
- }
38
- }, /*#__PURE__*/_react.default.createElement(_chevronDown.default, {
39
- label: configureLinkLabel,
40
- size: 'small',
41
- testId: "".concat(testId, "-icon")
42
- })));
43
- },
44
- spacing: 'compact',
45
- placement: 'bottom-start'
46
- }, /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItemGroup, null, /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItem, {
47
- elemBefore: /*#__PURE__*/_react.default.createElement(_shortcut.default, {
48
- label: goToLinkLabel,
49
- size: 'small'
50
- })
51
- }, goToLinkLabel), /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItem, {
52
- elemBefore: /*#__PURE__*/_react.default.createElement(_preferences.default, {
53
- label: configureLinkLabel,
54
- size: 'small'
55
- })
56
- }, configureLinkLabel)));
57
- };
58
- var _default = exports.default = ConfigureLinkDropdown;
@@ -1,199 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
- var _react = _interopRequireWildcard(require("react"));
13
- var _react2 = require("@emotion/react");
14
- var _debounce = _interopRequireDefault(require("lodash/debounce"));
15
- var _reactIntlNext = require("react-intl-next");
16
- var _messages = require("@atlaskit/editor-common/messages");
17
- var _whitespace = require("@atlaskit/editor-common/whitespace");
18
- var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferences"));
19
- var _colors = require("@atlaskit/theme/colors");
20
- var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
21
- var _utils = require("../InlineCardOverlay/utils");
22
- var _excluded = ["children", "isSelected", "isVisible", "testId"];
23
- /* eslint-disable @atlaskit/design-system/no-nested-styles */
24
- /* eslint-disable @atlaskit/design-system/prefer-primitives */
25
- /** @jsx jsx */
26
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
27
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
28
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
29
- var DEBOUNCE_IN_MS = 5;
30
- var PADDING_IN_PX = 4;
31
- var ICON_WIDTH_IN_PX = 16;
32
- var ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
33
- var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
34
- var TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
35
- var SMART_LINK_BACKGROUND_COLOR = "var(--ds-surface-raised, ".concat(_colors.N0, ")");
36
- var CONFIGURE_ICON_BACKGROUND_COLOR = "var(--ds-background-neutral, ".concat(_colors.N30A, ")");
37
- var CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR = "var(--ds-background-neutral-hovered, ".concat(_colors.N40A, ")");
38
- var CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR = "var(--ds-background-neutral-pressed, ".concat(_colors.N60A, ")");
39
- var containerStyles = (0, _react2.css)({
40
- position: 'relative',
41
- lineHeight: 'normal'
42
- });
43
- var overlayStyles = (0, _react2.css)({
44
- position: 'absolute',
45
- // Vertically align. Required for overlay to be centered inside the inline link (the inline lozenge is slightly larger than the designs)
46
- transform: 'translate(0%, -50%)',
47
- top: '50%',
48
- // Set default styling to be invisible but available in dom for width calculation.
49
- visibility: 'hidden',
50
- overflow: 'hidden',
51
- // EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
52
- zIndex: 2
53
- });
54
- var showOverlayStyles = (0, _react2.css)({
55
- visibility: 'visible'
56
- });
57
- var iconStyles = (0, _react2.css)({
58
- background: CONFIGURE_ICON_BACKGROUND_COLOR,
59
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
60
- ':hover': {
61
- background: CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR
62
- },
63
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
64
- ':active': {
65
- background: CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR
66
- },
67
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
68
- span: {
69
- // If PreferencesIcon left as inline-block (default), height is incorrect and border radius is clipped when parent element
70
- // uses 1lh height (rather than 100%)
71
- display: 'block'
72
- },
73
- // Note: The spec recomends 3px, but the icon doesn't fit left of the lozenge text if this size
74
- padding: "var(--ds-space-025, 2px)",
75
- borderRadius: '3px'
76
- });
77
- var iconAndLabelStyles = (0, _react2.css)({
78
- display: 'flex',
79
- alignItems: 'center',
80
- height: '100%',
81
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-space
82
- marginLeft: '2.5px',
83
- // Margin from very left of entire card (inclusive of blue)
84
-
85
- // This exists so if we set a semi-transparent background above, the provider icon doesn't show
86
- background: SMART_LINK_BACKGROUND_COLOR,
87
- // Ensure we don't have a white gap when the inline-card is in an active state
88
- borderRadius: '3px',
89
- color: "var(--ds-text-subtlest, ".concat(_colors.N700, ")")
90
- });
91
- var LeftIconOverlay = function LeftIconOverlay(_ref) {
92
- var children = _ref.children,
93
- _ref$isSelected = _ref.isSelected,
94
- isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
95
- _ref$isVisible = _ref.isVisible,
96
- isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
97
- _ref$testId = _ref.testId,
98
- testId = _ref$testId === void 0 ? 'inline-card-overlay' : _ref$testId,
99
- props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
100
- var _useState = (0, _react.useState)(false),
101
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
102
- showOverlay = _useState2[0],
103
- setShowOverlay = _useState2[1];
104
- var _useState3 = (0, _react.useState)(undefined),
105
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
106
- availableWidth = _useState4[0],
107
- setAvailableWidth = _useState4[1];
108
- var containerRef = (0, _react.useRef)(null);
109
-
110
- // TODO EDM-9853: Use availableWidth for small link edge case
111
- // Calculation logic will need to updated.
112
- availableWidth;
113
- var setVisibility = (0, _react.useCallback)(function () {
114
- if (!containerRef.current) {
115
- return;
116
- }
117
- var marker = (0, _utils.getChildElement)(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
118
- if (!marker) {
119
- return;
120
- }
121
- try {
122
- var oneLine = (0, _utils.isOneLine)(containerRef.current, marker);
123
-
124
- // Get the width of the available space to display overlay.
125
- // This is the width of the inline link itself. If the inline
126
- // is wrapped to the next line, this is width of the last line.
127
- var _availableWidth = (0, _utils.getInlineCardAvailableWidth)(containerRef.current, marker) - PADDING_IN_PX - (
128
- // Always leave at least the icon visible
129
- oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
130
- setAvailableWidth(_availableWidth);
131
- var canShowOverlay = !isSelected;
132
- setShowOverlay(canShowOverlay);
133
- } catch (_unused) {
134
- // If something goes wrong, hide the overlay all together.
135
- setShowOverlay(false);
136
- }
137
- }, [isSelected]);
138
- (0, _react.useLayoutEffect)(function () {
139
- if (!containerRef.current) {
140
- return;
141
- }
142
- if (isVisible) {
143
- setVisibility();
144
- }
145
- }, [setVisibility, isVisible]);
146
- (0, _react.useEffect)(function () {
147
- var _containerRef$current;
148
- // Find the closest block parent to observe size change
149
- var parent = containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest(TEXT_NODE_SELECTOR);
150
- if (!parent) {
151
- return;
152
- }
153
- var updateOverlay = (0, _debounce.default)(function (entries) {
154
- var _entries$;
155
- if (!isVisible) {
156
- return;
157
- }
158
- var size = entries === null || entries === void 0 || (_entries$ = entries[0]) === null || _entries$ === void 0 || (_entries$ = _entries$.contentBoxSize) === null || _entries$ === void 0 || (_entries$ = _entries$[0]) === null || _entries$ === void 0 ? void 0 : _entries$.inlineSize;
159
- if (!size) {
160
- return;
161
- }
162
- setVisibility();
163
- }, DEBOUNCE_IN_MS);
164
- var observer = new ResizeObserver(updateOverlay);
165
- observer.observe(parent);
166
- return function () {
167
- observer.disconnect();
168
- };
169
- }, [isVisible, setVisibility]);
170
- var intl = (0, _reactIntlNext.useIntl)();
171
- var configureLinkLabel = intl.formatMessage(_messages.cardMessages.inlineConfigureLink);
172
- return (0, _react2.jsx)("span", (0, _extends2.default)({}, props, {
173
- css: containerStyles,
174
- ref: containerRef
175
- }), isVisible && (0, _react2.jsx)(_tooltip.default, {
176
- content: configureLinkLabel
177
- }, function (tooltipProps) {
178
- return (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("span", {
179
- "aria-hidden": "true",
180
- className: OVERLAY_MARKER_CLASSNAME
181
- }, _whitespace.ZERO_WIDTH_JOINER), (0, _react2.jsx)("span", {
182
- css: [overlayStyles, showOverlay && showOverlayStyles],
183
- tabIndex: -1,
184
- "data-testid": testId
185
- }, (0, _react2.jsx)("span", (0, _extends2.default)({}, tooltipProps, {
186
- css: iconAndLabelStyles
187
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
188
- ,
189
- className: ICON_AND_LABEL_CLASSNAME
190
- }), (0, _react2.jsx)("span", {
191
- css: iconStyles
192
- }, (0, _react2.jsx)(_preferences.default, {
193
- label: configureLinkLabel,
194
- size: 'small',
195
- testId: "".concat(testId, "-icon")
196
- })))));
197
- }), children);
198
- };
199
- var _default = exports.default = LeftIconOverlay;
@@ -1,47 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
3
- import { useIntl } from 'react-intl-next';
4
- import Button from '@atlaskit/button/new';
5
- import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
6
- import { cardMessages as messages } from '@atlaskit/editor-common/messages';
7
- import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
8
- import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
9
- import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
10
- const ConfigureLinkDropdown = props => {
11
- const {
12
- testId
13
- } = props;
14
- const intl = useIntl();
15
- const configureLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
16
- const goToLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
17
- return /*#__PURE__*/React.createElement(DropdownMenu, {
18
- trigger: ({
19
- triggerRef,
20
- ...props
21
- }) => /*#__PURE__*/React.createElement(Button, _extends({}, props, {
22
- spacing: 'none',
23
- ref: triggerRef
24
- }), /*#__PURE__*/React.createElement("span", {
25
- style: {
26
- padding: `0 ${"var(--ds-space-025, 2px)"}`
27
- }
28
- }, /*#__PURE__*/React.createElement(ChevronDownIcon, {
29
- label: configureLinkLabel,
30
- size: 'small',
31
- testId: `${testId}-icon`
32
- }))),
33
- spacing: 'compact',
34
- placement: 'bottom-start'
35
- }, /*#__PURE__*/React.createElement(DropdownItemGroup, null, /*#__PURE__*/React.createElement(DropdownItem, {
36
- elemBefore: /*#__PURE__*/React.createElement(ShortcutIcon, {
37
- label: goToLinkLabel,
38
- size: 'small'
39
- })
40
- }, goToLinkLabel), /*#__PURE__*/React.createElement(DropdownItem, {
41
- elemBefore: /*#__PURE__*/React.createElement(PreferencesIcon, {
42
- label: configureLinkLabel,
43
- size: 'small'
44
- })
45
- }, configureLinkLabel)));
46
- };
47
- export default ConfigureLinkDropdown;
@@ -1,177 +0,0 @@
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
- /** @jsx jsx */
5
- import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
6
-
7
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
- import { css, jsx } from '@emotion/react';
9
- import debounce from 'lodash/debounce';
10
- import { useIntl } from 'react-intl-next';
11
- import { cardMessages as messages } from '@atlaskit/editor-common/messages';
12
- import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace';
13
- import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
14
- import { N0, N30A, N40A, N60A, N700 } from '@atlaskit/theme/colors';
15
- import Tooltip from '@atlaskit/tooltip';
16
- import { getChildElement, getInlineCardAvailableWidth, isOneLine } from '../InlineCardOverlay/utils';
17
- const DEBOUNCE_IN_MS = 5;
18
- const PADDING_IN_PX = 4;
19
- const ICON_WIDTH_IN_PX = 16;
20
- const ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
21
- const OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
22
- const TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
23
- const SMART_LINK_BACKGROUND_COLOR = `var(--ds-surface-raised, ${N0})`;
24
- const CONFIGURE_ICON_BACKGROUND_COLOR = `var(--ds-background-neutral, ${N30A})`;
25
- const CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR = `var(--ds-background-neutral-hovered, ${N40A})`;
26
- const CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR = `var(--ds-background-neutral-pressed, ${N60A})`;
27
- const containerStyles = css({
28
- position: 'relative',
29
- lineHeight: 'normal'
30
- });
31
- const overlayStyles = css({
32
- position: 'absolute',
33
- // Vertically align. Required for overlay to be centered inside the inline link (the inline lozenge is slightly larger than the designs)
34
- transform: 'translate(0%, -50%)',
35
- top: '50%',
36
- // Set default styling to be invisible but available in dom for width calculation.
37
- visibility: 'hidden',
38
- overflow: 'hidden',
39
- // EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
40
- zIndex: 2
41
- });
42
- const showOverlayStyles = css({
43
- visibility: 'visible'
44
- });
45
- const iconStyles = css({
46
- background: CONFIGURE_ICON_BACKGROUND_COLOR,
47
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
48
- ':hover': {
49
- background: CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR
50
- },
51
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
52
- ':active': {
53
- background: CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR
54
- },
55
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
56
- span: {
57
- // If PreferencesIcon left as inline-block (default), height is incorrect and border radius is clipped when parent element
58
- // uses 1lh height (rather than 100%)
59
- display: 'block'
60
- },
61
- // Note: The spec recomends 3px, but the icon doesn't fit left of the lozenge text if this size
62
- padding: "var(--ds-space-025, 2px)",
63
- borderRadius: '3px'
64
- });
65
- const iconAndLabelStyles = css({
66
- display: 'flex',
67
- alignItems: 'center',
68
- height: '100%',
69
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-space
70
- marginLeft: '2.5px',
71
- // Margin from very left of entire card (inclusive of blue)
72
-
73
- // This exists so if we set a semi-transparent background above, the provider icon doesn't show
74
- background: SMART_LINK_BACKGROUND_COLOR,
75
- // Ensure we don't have a white gap when the inline-card is in an active state
76
- borderRadius: '3px',
77
- color: `var(--ds-text-subtlest, ${N700})`
78
- });
79
- const LeftIconOverlay = ({
80
- children,
81
- isSelected = false,
82
- isVisible = false,
83
- testId = 'inline-card-overlay',
84
- ...props
85
- }) => {
86
- const [showOverlay, setShowOverlay] = useState(false);
87
- const [availableWidth, setAvailableWidth] = useState(undefined);
88
- const containerRef = useRef(null);
89
-
90
- // TODO EDM-9853: Use availableWidth for small link edge case
91
- // Calculation logic will need to updated.
92
- availableWidth;
93
- const setVisibility = useCallback(() => {
94
- if (!containerRef.current) {
95
- return;
96
- }
97
- const marker = getChildElement(containerRef, `.${OVERLAY_MARKER_CLASSNAME}`);
98
- if (!marker) {
99
- return;
100
- }
101
- try {
102
- const oneLine = isOneLine(containerRef.current, marker);
103
-
104
- // Get the width of the available space to display overlay.
105
- // This is the width of the inline link itself. If the inline
106
- // is wrapped to the next line, this is width of the last line.
107
- const availableWidth = getInlineCardAvailableWidth(containerRef.current, marker) - PADDING_IN_PX - (
108
- // Always leave at least the icon visible
109
- oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
110
- setAvailableWidth(availableWidth);
111
- const canShowOverlay = !isSelected;
112
- setShowOverlay(canShowOverlay);
113
- } catch {
114
- // If something goes wrong, hide the overlay all together.
115
- setShowOverlay(false);
116
- }
117
- }, [isSelected]);
118
- useLayoutEffect(() => {
119
- if (!containerRef.current) {
120
- return;
121
- }
122
- if (isVisible) {
123
- setVisibility();
124
- }
125
- }, [setVisibility, isVisible]);
126
- useEffect(() => {
127
- var _containerRef$current;
128
- // Find the closest block parent to observe size change
129
- const parent = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest(TEXT_NODE_SELECTOR);
130
- if (!parent) {
131
- return;
132
- }
133
- const updateOverlay = debounce(entries => {
134
- var _entries$, _entries$$contentBoxS, _entries$$contentBoxS2;
135
- if (!isVisible) {
136
- return;
137
- }
138
- const size = entries === null || entries === void 0 ? void 0 : (_entries$ = entries[0]) === null || _entries$ === void 0 ? void 0 : (_entries$$contentBoxS = _entries$.contentBoxSize) === null || _entries$$contentBoxS === void 0 ? void 0 : (_entries$$contentBoxS2 = _entries$$contentBoxS[0]) === null || _entries$$contentBoxS2 === void 0 ? void 0 : _entries$$contentBoxS2.inlineSize;
139
- if (!size) {
140
- return;
141
- }
142
- setVisibility();
143
- }, DEBOUNCE_IN_MS);
144
- const observer = new ResizeObserver(updateOverlay);
145
- observer.observe(parent);
146
- return () => {
147
- observer.disconnect();
148
- };
149
- }, [isVisible, setVisibility]);
150
- const intl = useIntl();
151
- const configureLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
152
- return jsx("span", _extends({}, props, {
153
- css: containerStyles,
154
- ref: containerRef
155
- }), isVisible && jsx(Tooltip, {
156
- content: configureLinkLabel
157
- }, tooltipProps => jsx(React.Fragment, null, jsx("span", {
158
- "aria-hidden": "true",
159
- className: OVERLAY_MARKER_CLASSNAME
160
- }, ZERO_WIDTH_JOINER), jsx("span", {
161
- css: [overlayStyles, showOverlay && showOverlayStyles],
162
- tabIndex: -1,
163
- "data-testid": testId
164
- }, jsx("span", _extends({}, tooltipProps, {
165
- css: iconAndLabelStyles
166
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
167
- ,
168
- className: ICON_AND_LABEL_CLASSNAME
169
- }), jsx("span", {
170
- css: iconStyles
171
- }, jsx(PreferencesIcon, {
172
- label: configureLinkLabel,
173
- size: 'small',
174
- testId: `${testId}-icon`
175
- })))))), children);
176
- };
177
- export default LeftIconOverlay;
@@ -1,48 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["triggerRef"];
4
- import React from 'react';
5
- import { useIntl } from 'react-intl-next';
6
- import Button from '@atlaskit/button/new';
7
- import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
8
- import { cardMessages as messages } from '@atlaskit/editor-common/messages';
9
- import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
10
- import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
11
- import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
12
- var ConfigureLinkDropdown = function ConfigureLinkDropdown(props) {
13
- var testId = props.testId;
14
- var intl = useIntl();
15
- var configureLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
16
- var goToLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
17
- return /*#__PURE__*/React.createElement(DropdownMenu, {
18
- trigger: function trigger(_ref) {
19
- var triggerRef = _ref.triggerRef,
20
- props = _objectWithoutProperties(_ref, _excluded);
21
- return /*#__PURE__*/React.createElement(Button, _extends({}, props, {
22
- spacing: 'none',
23
- ref: triggerRef
24
- }), /*#__PURE__*/React.createElement("span", {
25
- style: {
26
- padding: "0 ".concat("var(--ds-space-025, 2px)")
27
- }
28
- }, /*#__PURE__*/React.createElement(ChevronDownIcon, {
29
- label: configureLinkLabel,
30
- size: 'small',
31
- testId: "".concat(testId, "-icon")
32
- })));
33
- },
34
- spacing: 'compact',
35
- placement: 'bottom-start'
36
- }, /*#__PURE__*/React.createElement(DropdownItemGroup, null, /*#__PURE__*/React.createElement(DropdownItem, {
37
- elemBefore: /*#__PURE__*/React.createElement(ShortcutIcon, {
38
- label: goToLinkLabel,
39
- size: 'small'
40
- })
41
- }, goToLinkLabel), /*#__PURE__*/React.createElement(DropdownItem, {
42
- elemBefore: /*#__PURE__*/React.createElement(PreferencesIcon, {
43
- label: configureLinkLabel,
44
- size: 'small'
45
- })
46
- }, configureLinkLabel)));
47
- };
48
- export default ConfigureLinkDropdown;