@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
@@ -1,190 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["children", "isSelected", "isVisible", "testId"];
5
- /* eslint-disable @atlaskit/design-system/no-nested-styles */
6
- /* eslint-disable @atlaskit/design-system/prefer-primitives */
7
- /** @jsx jsx */
8
- import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
9
-
10
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
11
- import { css, jsx } from '@emotion/react';
12
- import debounce from 'lodash/debounce';
13
- import { useIntl } from 'react-intl-next';
14
- import { cardMessages as messages } from '@atlaskit/editor-common/messages';
15
- import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace';
16
- import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
17
- import { N0, N30A, N40A, N60A, N700 } from '@atlaskit/theme/colors';
18
- import Tooltip from '@atlaskit/tooltip';
19
- import { getChildElement, getInlineCardAvailableWidth, isOneLine } from '../InlineCardOverlay/utils';
20
- var DEBOUNCE_IN_MS = 5;
21
- var PADDING_IN_PX = 4;
22
- var ICON_WIDTH_IN_PX = 16;
23
- var ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
24
- var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
25
- var TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
26
- var SMART_LINK_BACKGROUND_COLOR = "var(--ds-surface-raised, ".concat(N0, ")");
27
- var CONFIGURE_ICON_BACKGROUND_COLOR = "var(--ds-background-neutral, ".concat(N30A, ")");
28
- var CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR = "var(--ds-background-neutral-hovered, ".concat(N40A, ")");
29
- var CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR = "var(--ds-background-neutral-pressed, ".concat(N60A, ")");
30
- var containerStyles = css({
31
- position: 'relative',
32
- lineHeight: 'normal'
33
- });
34
- var overlayStyles = css({
35
- position: 'absolute',
36
- // Vertically align. Required for overlay to be centered inside the inline link (the inline lozenge is slightly larger than the designs)
37
- transform: 'translate(0%, -50%)',
38
- top: '50%',
39
- // Set default styling to be invisible but available in dom for width calculation.
40
- visibility: 'hidden',
41
- overflow: 'hidden',
42
- // EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
43
- zIndex: 2
44
- });
45
- var showOverlayStyles = css({
46
- visibility: 'visible'
47
- });
48
- var iconStyles = css({
49
- background: CONFIGURE_ICON_BACKGROUND_COLOR,
50
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
51
- ':hover': {
52
- background: CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR
53
- },
54
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
55
- ':active': {
56
- background: CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR
57
- },
58
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
59
- span: {
60
- // If PreferencesIcon left as inline-block (default), height is incorrect and border radius is clipped when parent element
61
- // uses 1lh height (rather than 100%)
62
- display: 'block'
63
- },
64
- // Note: The spec recomends 3px, but the icon doesn't fit left of the lozenge text if this size
65
- padding: "var(--ds-space-025, 2px)",
66
- borderRadius: '3px'
67
- });
68
- var iconAndLabelStyles = css({
69
- display: 'flex',
70
- alignItems: 'center',
71
- height: '100%',
72
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-space
73
- marginLeft: '2.5px',
74
- // Margin from very left of entire card (inclusive of blue)
75
-
76
- // This exists so if we set a semi-transparent background above, the provider icon doesn't show
77
- background: SMART_LINK_BACKGROUND_COLOR,
78
- // Ensure we don't have a white gap when the inline-card is in an active state
79
- borderRadius: '3px',
80
- color: "var(--ds-text-subtlest, ".concat(N700, ")")
81
- });
82
- var LeftIconOverlay = function LeftIconOverlay(_ref) {
83
- var children = _ref.children,
84
- _ref$isSelected = _ref.isSelected,
85
- isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
86
- _ref$isVisible = _ref.isVisible,
87
- isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
88
- _ref$testId = _ref.testId,
89
- testId = _ref$testId === void 0 ? 'inline-card-overlay' : _ref$testId,
90
- props = _objectWithoutProperties(_ref, _excluded);
91
- var _useState = useState(false),
92
- _useState2 = _slicedToArray(_useState, 2),
93
- showOverlay = _useState2[0],
94
- setShowOverlay = _useState2[1];
95
- var _useState3 = useState(undefined),
96
- _useState4 = _slicedToArray(_useState3, 2),
97
- availableWidth = _useState4[0],
98
- setAvailableWidth = _useState4[1];
99
- var containerRef = useRef(null);
100
-
101
- // TODO EDM-9853: Use availableWidth for small link edge case
102
- // Calculation logic will need to updated.
103
- availableWidth;
104
- var setVisibility = useCallback(function () {
105
- if (!containerRef.current) {
106
- return;
107
- }
108
- var marker = getChildElement(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
109
- if (!marker) {
110
- return;
111
- }
112
- try {
113
- var oneLine = isOneLine(containerRef.current, marker);
114
-
115
- // Get the width of the available space to display overlay.
116
- // This is the width of the inline link itself. If the inline
117
- // is wrapped to the next line, this is width of the last line.
118
- var _availableWidth = getInlineCardAvailableWidth(containerRef.current, marker) - PADDING_IN_PX - (
119
- // Always leave at least the icon visible
120
- oneLine ? ICON_WIDTH_IN_PX + PADDING_IN_PX : 0);
121
- setAvailableWidth(_availableWidth);
122
- var canShowOverlay = !isSelected;
123
- setShowOverlay(canShowOverlay);
124
- } catch (_unused) {
125
- // If something goes wrong, hide the overlay all together.
126
- setShowOverlay(false);
127
- }
128
- }, [isSelected]);
129
- useLayoutEffect(function () {
130
- if (!containerRef.current) {
131
- return;
132
- }
133
- if (isVisible) {
134
- setVisibility();
135
- }
136
- }, [setVisibility, isVisible]);
137
- useEffect(function () {
138
- var _containerRef$current;
139
- // Find the closest block parent to observe size change
140
- var parent = containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest(TEXT_NODE_SELECTOR);
141
- if (!parent) {
142
- return;
143
- }
144
- var updateOverlay = debounce(function (entries) {
145
- var _entries$;
146
- if (!isVisible) {
147
- return;
148
- }
149
- 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;
150
- if (!size) {
151
- return;
152
- }
153
- setVisibility();
154
- }, DEBOUNCE_IN_MS);
155
- var observer = new ResizeObserver(updateOverlay);
156
- observer.observe(parent);
157
- return function () {
158
- observer.disconnect();
159
- };
160
- }, [isVisible, setVisibility]);
161
- var intl = useIntl();
162
- var configureLinkLabel = intl.formatMessage(messages.inlineConfigureLink);
163
- return jsx("span", _extends({}, props, {
164
- css: containerStyles,
165
- ref: containerRef
166
- }), isVisible && jsx(Tooltip, {
167
- content: configureLinkLabel
168
- }, function (tooltipProps) {
169
- return jsx(React.Fragment, null, jsx("span", {
170
- "aria-hidden": "true",
171
- className: OVERLAY_MARKER_CLASSNAME
172
- }, ZERO_WIDTH_JOINER), jsx("span", {
173
- css: [overlayStyles, showOverlay && showOverlayStyles],
174
- tabIndex: -1,
175
- "data-testid": testId
176
- }, jsx("span", _extends({}, tooltipProps, {
177
- css: iconAndLabelStyles
178
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
179
- ,
180
- className: ICON_AND_LABEL_CLASSNAME
181
- }), jsx("span", {
182
- css: iconStyles
183
- }, jsx(PreferencesIcon, {
184
- label: configureLinkLabel,
185
- size: 'small',
186
- testId: "".concat(testId, "-icon")
187
- })))));
188
- }), children);
189
- };
190
- export default LeftIconOverlay;
@@ -1,18 +0,0 @@
1
- import { jsx } from '@emotion/react';
2
- import { type IntlShape } from 'react-intl-next';
3
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
- import type { Command } from '@atlaskit/editor-common/types';
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 interface EditDatasourceToolbarButtonProps {
9
- datasourceId?: string;
10
- intl: IntlShape;
11
- onLinkEditClick: Command;
12
- editorAnalyticsApi?: EditorAnalyticsAPI;
13
- url?: string;
14
- editorView?: EditorView;
15
- cardContext?: CardContext;
16
- currentAppearance?: CardType;
17
- }
18
- export declare const EditToolbarButton: (props: EditDatasourceToolbarButtonProps) => jsx.JSX.Element;
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- export type SmallLinkDropdownProps = {
3
- testId: string;
4
- };
5
- declare const ConfigureLinkDropdown: (props: SmallLinkDropdownProps) => JSX.Element;
6
- export default ConfigureLinkDropdown;
@@ -1,10 +0,0 @@
1
- /** @jsx jsx */
2
- import React from 'react';
3
- import { jsx } from '@emotion/react';
4
- export type LeftIconOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
5
- isSelected?: boolean;
6
- isVisible?: boolean;
7
- testId?: string;
8
- };
9
- declare const LeftIconOverlay: ({ children, isSelected, isVisible, testId, ...props }: React.PropsWithChildren<LeftIconOverlayProps>) => jsx.JSX.Element;
10
- export default LeftIconOverlay;
@@ -1,18 +0,0 @@
1
- import { jsx } from '@emotion/react';
2
- import { type IntlShape } from 'react-intl-next';
3
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
- import type { Command } from '@atlaskit/editor-common/types';
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 interface EditDatasourceToolbarButtonProps {
9
- datasourceId?: string;
10
- intl: IntlShape;
11
- onLinkEditClick: Command;
12
- editorAnalyticsApi?: EditorAnalyticsAPI;
13
- url?: string;
14
- editorView?: EditorView;
15
- cardContext?: CardContext;
16
- currentAppearance?: CardType;
17
- }
18
- export declare const EditToolbarButton: (props: EditDatasourceToolbarButtonProps) => jsx.JSX.Element;
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- export type SmallLinkDropdownProps = {
3
- testId: string;
4
- };
5
- declare const ConfigureLinkDropdown: (props: SmallLinkDropdownProps) => JSX.Element;
6
- export default ConfigureLinkDropdown;
@@ -1,10 +0,0 @@
1
- /** @jsx jsx */
2
- import React from 'react';
3
- import { jsx } from '@emotion/react';
4
- export type LeftIconOverlayProps = React.HTMLAttributes<HTMLSpanElement> & {
5
- isSelected?: boolean;
6
- isVisible?: boolean;
7
- testId?: string;
8
- };
9
- declare const LeftIconOverlay: ({ children, isSelected, isVisible, testId, ...props }: React.PropsWithChildren<LeftIconOverlayProps>) => jsx.JSX.Element;
10
- export default LeftIconOverlay;