@atlaskit/editor-common 134.7.1 → 134.7.2

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 (50) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/monitoring/error.js +1 -1
  3. package/dist/cjs/quick-insert/CompactQuickInsertMenuItem.compiled.css +2 -9
  4. package/dist/cjs/quick-insert/CompactQuickInsertMenuItem.js +6 -6
  5. package/dist/cjs/quick-insert/ElementBrowserQuickInsertMenuItem.js +76 -103
  6. package/dist/cjs/quick-insert/QuickInsertHoverPreview.compiled.css +1 -38
  7. package/dist/cjs/quick-insert/QuickInsertHoverPreview.js +9 -93
  8. package/dist/cjs/quick-insert/QuickInsertMenuItem.js +2 -1
  9. package/dist/cjs/quick-insert/QuickInsertPreviewContent.compiled.css +38 -0
  10. package/dist/cjs/quick-insert/QuickInsertPreviewContent.js +142 -0
  11. package/dist/cjs/quick-insert/QuickInsertShortcut.compiled.css +10 -0
  12. package/dist/cjs/quick-insert/QuickInsertShortcut.js +28 -0
  13. package/dist/cjs/ui/DropList/index.js +1 -1
  14. package/dist/cjs/ui/Layer/index.js +14 -208
  15. package/dist/cjs/vanilla-tooltip/index.js +5 -14
  16. package/dist/es2019/monitoring/error.js +1 -1
  17. package/dist/es2019/quick-insert/CompactQuickInsertMenuItem.compiled.css +2 -9
  18. package/dist/es2019/quick-insert/CompactQuickInsertMenuItem.js +6 -6
  19. package/dist/es2019/quick-insert/ElementBrowserQuickInsertMenuItem.js +74 -101
  20. package/dist/es2019/quick-insert/QuickInsertHoverPreview.compiled.css +1 -38
  21. package/dist/es2019/quick-insert/QuickInsertHoverPreview.js +10 -86
  22. package/dist/es2019/quick-insert/QuickInsertMenuItem.js +2 -1
  23. package/dist/es2019/quick-insert/QuickInsertPreviewContent.compiled.css +38 -0
  24. package/dist/es2019/quick-insert/QuickInsertPreviewContent.js +126 -0
  25. package/dist/es2019/quick-insert/QuickInsertShortcut.compiled.css +10 -0
  26. package/dist/es2019/quick-insert/QuickInsertShortcut.js +19 -0
  27. package/dist/es2019/ui/DropList/index.js +1 -1
  28. package/dist/es2019/ui/Layer/index.js +15 -192
  29. package/dist/es2019/vanilla-tooltip/index.js +7 -15
  30. package/dist/esm/monitoring/error.js +1 -1
  31. package/dist/esm/quick-insert/CompactQuickInsertMenuItem.compiled.css +2 -9
  32. package/dist/esm/quick-insert/CompactQuickInsertMenuItem.js +6 -6
  33. package/dist/esm/quick-insert/ElementBrowserQuickInsertMenuItem.js +77 -104
  34. package/dist/esm/quick-insert/QuickInsertHoverPreview.compiled.css +1 -38
  35. package/dist/esm/quick-insert/QuickInsertHoverPreview.js +10 -93
  36. package/dist/esm/quick-insert/QuickInsertMenuItem.js +2 -1
  37. package/dist/esm/quick-insert/QuickInsertPreviewContent.compiled.css +38 -0
  38. package/dist/esm/quick-insert/QuickInsertPreviewContent.js +135 -0
  39. package/dist/esm/quick-insert/QuickInsertShortcut.compiled.css +10 -0
  40. package/dist/esm/quick-insert/QuickInsertShortcut.js +21 -0
  41. package/dist/esm/ui/DropList/index.js +1 -1
  42. package/dist/esm/ui/Layer/index.js +15 -211
  43. package/dist/esm/vanilla-tooltip/index.js +7 -15
  44. package/dist/types/quick-insert/ElementBrowserQuickInsertMenuItem.d.ts +7 -1
  45. package/dist/types/quick-insert/QuickInsertHoverPreview.d.ts +0 -1
  46. package/dist/types/quick-insert/QuickInsertPreviewContent.d.ts +24 -0
  47. package/dist/types/quick-insert/QuickInsertShortcut.d.ts +13 -0
  48. package/dist/types/ui/Layer/index.d.ts +1 -15
  49. package/dist/types/vanilla-tooltip/index.d.ts +1 -1
  50. package/package.json +2 -7
@@ -1,88 +1,76 @@
1
1
  /* ElementBrowserQuickInsertMenuItem.tsx generated by @compiled/babel-plugin v3.0.2 */
2
2
  import "./ElementBrowserQuickInsertMenuItem.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
- import React, { useMemo } from 'react';
5
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
+ import React, { useId, useMemo } from 'react';
6
5
  /* eslint-disable @atlaskit/design-system/no-emotion-primitives -- Compiled primitives do not provide Pressable. */
7
6
  import { Box } from '@atlaskit/primitives/box';
8
- import { Inline } from '@atlaskit/primitives/inline';
9
7
  import { Pressable } from '@atlaskit/primitives/pressable';
10
- import { Stack } from '@atlaskit/primitives/stack';
11
- import { Text } from '@atlaskit/primitives/text';
12
8
  import { xcss } from '@atlaskit/primitives/xcss/xcss';
13
9
  import { useQuickInsertMenuItemSelection } from './quickInsertMenuItemUtils';
10
+ import { QuickInsertPreviewContent } from './QuickInsertPreviewContent';
14
11
  import { useQuickInsertContext } from './useQuickInsertContext';
15
- const borderlessItemStyles = xcss({
16
- alignItems: 'start',
17
- backgroundColor: 'color.background.neutral.subtle',
18
- borderRadius: 'radius.medium',
12
+ const cardStyles = xcss({
13
+ backgroundColor: 'elevation.surface',
14
+ borderColor: 'color.border',
15
+ borderRadius: 'radius.large',
16
+ borderStyle: 'solid',
17
+ borderWidth: 'border.width',
19
18
  color: 'color.text',
20
19
  cursor: 'pointer',
21
20
  display: 'flex',
22
- gap: 'space.150',
23
- height: '88px',
21
+ flexDirection: 'column',
22
+ gap: 'space.100',
23
+ // Fills the grid row so every tile in a row is as tall as the tallest one.
24
+ height: '100%',
24
25
  padding: 'space.150',
25
26
  textAlign: 'start',
26
- width: '100%'
27
+ width: '100%',
28
+ ':hover': {
29
+ backgroundColor: 'elevation.surface.hovered'
30
+ }
27
31
  });
28
- const borderlessSelectedItemStyles = xcss({
29
- alignItems: 'start',
32
+
33
+ // Each state is a complete style so the tile can pick one without composing styles at render.
34
+ const selectedCardStyles = xcss({
30
35
  backgroundColor: 'color.background.selected',
31
- borderRadius: 'radius.medium',
36
+ borderColor: 'color.border.selected',
37
+ borderRadius: 'radius.large',
38
+ borderStyle: 'solid',
39
+ borderWidth: 'border.width',
32
40
  color: 'color.text',
33
41
  cursor: 'pointer',
34
42
  display: 'flex',
35
- gap: 'space.150',
36
- height: '88px',
43
+ flexDirection: 'column',
44
+ gap: 'space.100',
45
+ height: '100%',
37
46
  padding: 'space.150',
38
- position: 'relative',
39
47
  textAlign: 'start',
40
48
  width: '100%',
41
- '::before': {
42
- borderInlineStartColor: 'color.border.selected',
43
- borderInlineStartStyle: 'solid',
44
- borderInlineStartWidth: 'border.width.selected',
45
- content: "''",
46
- insetBlock: 'space.0',
47
- insetInlineStart: 'space.0',
48
- pointerEvents: 'none',
49
- position: 'absolute'
49
+ ':hover': {
50
+ backgroundColor: 'color.background.selected.hovered'
51
+ },
52
+ // Keyboard focus draws the focus ring, so drop the selected border to avoid a double outline.
53
+ ':focus-visible': {
54
+ borderColor: 'color.border'
50
55
  }
51
56
  });
52
- const borderlessDisabledItemStyles = xcss({
53
- alignItems: 'start',
54
- backgroundColor: 'color.background.neutral.subtle',
55
- borderRadius: 'radius.medium',
57
+ const disabledCardStyles = xcss({
58
+ backgroundColor: 'elevation.surface',
59
+ borderColor: 'color.border',
60
+ borderRadius: 'radius.large',
61
+ borderStyle: 'solid',
62
+ borderWidth: 'border.width',
56
63
  color: 'color.text.disabled',
57
64
  cursor: 'not-allowed',
58
65
  display: 'flex',
59
- gap: 'space.150',
60
- height: '88px',
66
+ flexDirection: 'column',
67
+ gap: 'space.100',
68
+ height: '100%',
61
69
  padding: 'space.150',
62
70
  textAlign: 'start',
63
71
  width: '100%'
64
72
  });
65
- const hoveredItemStyles = xcss({
66
- ':hover': {
67
- backgroundColor: 'elevation.surface.hovered',
68
- borderRadius: 'radius.medium'
69
- }
70
- });
71
73
  const iconStyles = xcss({
72
- alignItems: 'center',
73
- backgroundColor: 'elevation.surface.overlay',
74
- borderColor: 'color.border',
75
- borderRadius: 'radius.medium',
76
- borderStyle: 'solid',
77
- borderWidth: 'border.width',
78
- display: 'flex',
79
- flexShrink: 0,
80
- height: '40px',
81
- justifyContent: 'center',
82
- overflow: 'hidden',
83
- width: '40px'
84
- });
85
- const iconLargeStyles = xcss({
86
74
  alignItems: 'center',
87
75
  backgroundColor: 'elevation.surface.overlay',
88
76
  borderColor: 'color.border',
@@ -91,10 +79,10 @@ const iconLargeStyles = xcss({
91
79
  borderWidth: 'border.width',
92
80
  display: 'flex',
93
81
  flexShrink: 0,
94
- height: '40px',
82
+ height: '32px',
95
83
  justifyContent: 'center',
96
84
  overflow: 'hidden',
97
- width: '40px'
85
+ width: '32px'
98
86
  });
99
87
  const iconColorStyles = null;
100
88
 
@@ -107,24 +95,23 @@ const iconColorStyles = null;
107
95
  const pinnedIconColorResetStyles = null;
108
96
  /* eslint-enable @atlaskit/design-system/no-unsafe-design-token-usage, @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-important-styles */
109
97
 
110
- const shortcutStyles = xcss({
111
- backgroundColor: 'color.background.neutral',
112
- borderRadius: 'radius.small',
113
- color: 'color.text.subtle',
114
- font: 'font.body.small',
115
- paddingBlock: 'space.025',
116
- paddingInline: 'space.050'
117
- });
98
+ /**
99
+ * An Element Browser tile: the item's hover preview card (image, title, full description, and
100
+ * attribution), with its shortcut beside the title. Items without a preview image show their icon,
101
+ * always in a bordered box, above the title instead. The hover card's small title icon
102
+ * (`previewIcon`) is not shown, so a tile never repeats its icon.
103
+ */
118
104
  export const ElementBrowserQuickInsertMenuItem = ({
119
105
  ariaLabel,
120
106
  description,
121
107
  iconBefore,
122
- isDisabled,
108
+ isDisabled = false,
123
109
  lozenge,
124
110
  onSelect,
111
+ preview,
112
+ previewImageUrls,
125
113
  shortcut,
126
114
  titleContent,
127
- shouldWrapIcon = true,
128
115
  title
129
116
  }) => {
130
117
  const {
@@ -139,48 +126,34 @@ export const ElementBrowserQuickInsertMenuItem = ({
139
126
  };
140
127
  const itemDescription = description !== null && description !== void 0 ? description : item === null || item === void 0 ? void 0 : item.description;
141
128
  const handleClick = useQuickInsertMenuItemSelection(onSelect);
142
- const itemStyles = useMemo(() => [isDisabled ? borderlessDisabledItemStyles : isSelected ? borderlessSelectedItemStyles : borderlessItemStyles, isExperimentEnabled('platform_editor_slash_command') && !isDisabled && !isSelected && hoveredItemStyles], [isDisabled, isSelected]);
143
- const itemTitle = titleContent !== null && titleContent !== void 0 ? titleContent : /*#__PURE__*/React.createElement(Text, {
144
- color: isDisabled ? 'color.text.disabled' : 'color.text',
145
- maxLines: 1,
146
- size: "medium",
147
- weight: "medium"
148
- }, title);
149
-
150
- // Disabled items keep the dimmed colour inherited from the item.
129
+ const descriptionId = useId();
130
+ const resolvedPreview = useMemo(() => preview !== null && preview !== void 0 ? preview : previewImageUrls ? {
131
+ image: previewImageUrls
132
+ } : {}, [preview, previewImageUrls]);
133
+ const hasDescription = Boolean(itemDescription || resolvedPreview.attribution || shortcut);
151
134
  const icon = iconBefore ? /*#__PURE__*/React.createElement("span", {
152
135
  className: ax(["_rpzpjdj5 _1pgcjdj5", !isDisabled && "_syaz1q3r"])
153
- }, iconBefore) : iconBefore;
136
+ }, iconBefore) : undefined;
154
137
  return /*#__PURE__*/React.createElement(Pressable, {
155
- "aria-label": ariaLabel,
138
+ "aria-describedby": hasDescription ? descriptionId : undefined,
139
+ "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : title,
156
140
  "aria-selected": isSelected,
157
141
  id: id,
158
142
  isDisabled: isDisabled,
159
143
  onClick: handleClick,
160
144
  role: "option",
161
- tabIndex: isSelected ? 0 : -1
162
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage -- Memoizes composition of module-scoped xcss styles for Pressable.
163
- ,
164
- xcss: itemStyles
165
- }, iconBefore && shouldWrapIcon ? /*#__PURE__*/React.createElement(Box, {
166
- xcss: isExperimentEnabled('platform_editor_slash_command') ? iconLargeStyles : iconStyles
167
- }, icon) : icon, /*#__PURE__*/React.createElement(Stack, {
168
- space: "space.050",
169
- grow: "fill"
170
- }, /*#__PURE__*/React.createElement(Inline, {
171
- alignBlock: "center",
172
- spread: "space-between",
173
- space: "space.100"
174
- }, lozenge ? /*#__PURE__*/React.createElement(Inline, {
175
- alignBlock: "center",
176
- space: "space.100"
177
- }, itemTitle, lozenge) : itemTitle, shortcut && /*#__PURE__*/React.createElement(Box, {
178
- as: "span",
179
- xcss: shortcutStyles
180
- }, shortcut)), itemDescription && /*#__PURE__*/React.createElement(Text, {
181
- color: "color.text.subtlest",
182
- maxLines: 2,
183
- size: "small",
184
- weight: "regular"
185
- }, itemDescription)));
145
+ tabIndex: isSelected ? 0 : -1,
146
+ xcss: isDisabled ? disabledCardStyles : isSelected ? selectedCardStyles : cardStyles
147
+ }, !resolvedPreview.image && icon && /*#__PURE__*/React.createElement(Box, {
148
+ xcss: iconStyles
149
+ }, icon), /*#__PURE__*/React.createElement(QuickInsertPreviewContent, {
150
+ description: itemDescription,
151
+ id: hasDescription ? descriptionId : undefined,
152
+ isDisabled: isDisabled,
153
+ lozenge: lozenge,
154
+ preview: resolvedPreview,
155
+ shortcut: shortcut,
156
+ shouldClampText: false,
157
+ title: titleContent !== null && titleContent !== void 0 ? titleContent : title
158
+ }));
186
159
  };
@@ -1,50 +1,13 @@
1
- ._11c81qyo{font:var(--ds-font-heading-xsmall,normal 653 14px/20px "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
2
- ._11c8fhey{font:var(--ds-font-body,normal 400 14px/20px "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
3
- ._11c8wadc{font:var(--ds-font-body-small,normal 400 9pt/1pc "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
4
- ._2rko12b0{border-radius:var(--ds-radius-small,4px)}
5
1
  ._2rko1qi0{border-radius:var(--ds-radius-medium,6px)}
6
- ._zulp1b66{gap:var(--ds-space-050,4px)}
7
- ._zulpu2gc{gap:var(--ds-space-100,8px)}
8
2
  ._18zrutpp{padding-inline:var(--ds-space-150,9pt)}
9
- ._1rjcutpp{padding-block:var(--ds-space-150,9pt)}
10
- ._16jlidpf{flex-grow:0}
11
- ._16jlkb7n{flex-grow:1}
12
- ._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
3
+ ._1rjcutpp{padding-block:var(--ds-space-150,9pt)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
13
4
  ._18m915vq{overflow-y:hidden}
14
- ._1bah1h6o{justify-content:center}
15
- ._1bsb1osq{width:100%}
16
- ._1bsb7vkz{width:1pc}
17
5
  ._1bsbncxg{width:264px}
18
- ._1bsbp3fh{width:15pc}
19
- ._1e0c1txw{display:flex}
20
- ._1e0c1ule{display:block}
21
- ._1e0ccj1k{display:-webkit-box}
22
- ._1i4qfg65{overflow-wrap:anywhere}
23
- ._1o9zidpf{flex-shrink:0}
24
- ._1o9zkb7n{flex-shrink:1}
25
6
  ._1pby16oo{z-index:510}
26
7
  ._1reo15vq{overflow-x:hidden}
27
- ._1ul9idpf{min-width:0}
28
- ._1yyjcs5v{-webkit-line-clamp:2}
29
- ._1yyjegat{-webkit-line-clamp:4}
30
- ._2lx21bp4{flex-direction:column}
31
- ._3um015vq{visibility:hidden}
32
- ._4cvr1h6o{align-items:center}
33
- ._4t3i1osq{height:100%}
34
- ._4t3i68cl{height:90pt}
35
- ._4t3i7vkz{height:1pc}
36
- ._5ral1f51{object-fit:contain}
37
- ._6rthu2gc{margin-block-end:var(--ds-space-100,8px)}
38
8
  ._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
39
- ._bfhkhfxm{background-color:var(--ds-surface-sunken,#f8f8f8)}
40
9
  ._c71l1kw7{max-height:inherit}
41
10
  ._c71lk6is{max-height:calc(100vh - 1pc)}
42
- ._i0dl1wug{flex-basis:auto}
43
- ._i0dlexct{flex-basis:16px}
44
- ._k48pwu06{font-weight:var(--ds-font-weight-bold,653)}
45
11
  ._p12f1oec{max-width:calc(100vw - 1pc)}
46
12
  ._p12f1osq{max-width:100%}
47
- ._sudp1e54{-webkit-box-orient:vertical}
48
- ._syazazsu{color:var(--ds-text-subtle,#505258)}
49
- ._syazi7uo{color:var(--ds-text,#292a2e)}
50
13
  ._vchhusvi{box-sizing:border-box}
@@ -4,17 +4,13 @@ import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useLayoutEffect, useState } from 'react';
5
5
  import { createPortal } from 'react-dom';
6
6
 
7
- // Viewport calculations and multiline clamping require styles outside @atlaskit/css's schema.
7
+ // Viewport calculations require styles outside @atlaskit/css's schema.
8
8
 
9
9
  import { bind } from 'bind-event-listener';
10
- import { useIntl } from 'react-intl';
10
+
11
11
  // Viewport clamping requires modifiers, which the top-layer adapter does not support.
12
12
  import { Popper } from '@atlaskit/popper/react-popper';
13
- import { Box } from '@atlaskit/primitives/compiled/box';
14
- import { Inline } from '@atlaskit/primitives/compiled/inline';
15
- import { Text } from '@atlaskit/primitives/compiled/text';
16
- import { useThemeObserver } from '@atlaskit/tokens/use-theme-observer';
17
- import { messages } from './messages';
13
+ import { QuickInsertPreviewContent } from './QuickInsertPreviewContent';
18
14
  const PREVIEW_MODIFIERS = [{
19
15
  name: 'offset',
20
16
  options: {
@@ -39,25 +35,9 @@ const PREVIEW_MODIFIERS = [{
39
35
  rootBoundary: 'viewport'
40
36
  }
41
37
  }];
42
- const layoutStyles = {
43
- titleRow: "_1ul9idpf",
44
- titleIcon: "_4cvr1h6o _1e0c1txw _1o9zidpf _1bah1h6o",
45
- attributionText: "_16jlkb7n _1o9zkb7n _i0dl1wug _1ul9idpf _1i4qfg65"
46
- };
47
38
  const styles = {
48
39
  positioner: "_c71lk6is _p12f1oec _1pby16oo",
49
- panel: "_2rko1qi0 _1reo15vq _18m915vq _1rjcutpp _18zrutpp _vchhusvi _bfhk1bhr _16qs130s _c71l1kw7 _p12f1osq _1bsbncxg",
50
- content: "_zulpu2gc _1e0c1txw _2lx21bp4",
51
- title: "_11c81qyo _16jlkb7n _1o9zkb7n _i0dl1wug _1reo15vq _18m915vq _syazazsu _1ul9idpf _1i4qfg65 _1e0ccj1k _sudp1e54 _1yyjcs5v",
52
- unclampedTitle: "_11c8fhey _16jlkb7n _1o9zkb7n _i0dl1wug _syazi7uo _k48pwu06 _1ul9idpf _1i4qfg65",
53
- description: "_11c8fhey _1reo15vq _18m915vq _syazi7uo _1e0ccj1k _1i4qfg65 _sudp1e54 _1yyjegat",
54
- unclampedDescription: "_11c8fhey _syazi7uo _1i4qfg65",
55
- imageArea: "_2rko12b0 _1reo15vq _18m915vq _bfhkhfxm _4t3i68cl _6rthu2gc _p12f1osq _1bsbp3fh",
56
- image: "_1e0c1ule _4t3i1osq _5ral1f51 _1bsb1osq",
57
- imageHidden: "_3um015vq",
58
- attribution: "_zulp1b66 _4cvr1h6o _syazazsu _1e0c1txw _1i4qfg65",
59
- compactAttribution: "_11c8wadc",
60
- attributionIcon: "_16jlidpf _1o9zidpf _i0dlexct _4cvr1h6o _1e0c1txw _4t3i7vkz _1bah1h6o _1bsb7vkz"
40
+ panel: "_2rko1qi0 _1reo15vq _18m915vq _1rjcutpp _18zrutpp _vchhusvi _bfhk1bhr _16qs130s _c71l1kw7 _p12f1osq _1bsbncxg"
61
41
  };
62
42
 
63
43
  /** The selected item's description and attribution are announced through its aria-describedby. */
@@ -72,10 +52,6 @@ export const QuickInsertHoverPreview = ({
72
52
  title,
73
53
  titleContent
74
54
  }) => {
75
- const {
76
- colorMode
77
- } = useThemeObserver();
78
- const imageUrl = preview.image ? colorMode === 'dark' && preview.image.dark ? preview.image.dark : preview.image.light : undefined;
79
55
  const hasAccessibleContent = Boolean(description || preview.attribution);
80
56
  const portalTarget = popupsMountPoint !== null && popupsMountPoint !== void 0 ? popupsMountPoint : referenceElement.ownerDocument.body;
81
57
  return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(Popper, {
@@ -95,7 +71,6 @@ export const QuickInsertHoverPreview = ({
95
71
  description: description,
96
72
  icon: icon,
97
73
  id: hasAccessibleContent ? id : undefined,
98
- imageUrl: imageUrl,
99
74
  preview: preview,
100
75
  popupsMountPoint: popupsMountPoint,
101
76
  referenceElement: referenceElement,
@@ -109,7 +84,6 @@ const QuickInsertPreviewPanel = ({
109
84
  description,
110
85
  icon,
111
86
  id,
112
- imageUrl,
113
87
  preview,
114
88
  popupsMountPoint,
115
89
  referenceElement,
@@ -118,14 +92,7 @@ const QuickInsertPreviewPanel = ({
118
92
  titleContent,
119
93
  update
120
94
  }) => {
121
- var _preview$attribution, _preview$attribution2;
122
- const {
123
- formatMessage
124
- } = useIntl();
125
95
  const [panelElement, setPanelElement] = useState(null);
126
- const AttributionIcon = (_preview$attribution = preview.attribution) === null || _preview$attribution === void 0 ? void 0 : _preview$attribution.icon;
127
- const attributionName = (_preview$attribution2 = preview.attribution) === null || _preview$attribution2 === void 0 ? void 0 : _preview$attribution2.name;
128
- const formattedAttributionName = typeof attributionName === 'string' ? attributionName : attributionName ? formatMessage(attributionName) : '';
129
96
  useLayoutEffect(() => {
130
97
  var _ownerDocument$defaul;
131
98
  void update();
@@ -159,54 +126,11 @@ const QuickInsertPreviewPanel = ({
159
126
  role: id ? 'tooltip' : undefined,
160
127
  "data-testid": "quick-insert-preview-panel",
161
128
  className: ax([styles.panel])
162
- }, /*#__PURE__*/React.createElement(React.Fragment, null, imageUrl && /*#__PURE__*/React.createElement(PreviewImage, {
163
- key: imageUrl,
164
- imageUrl: imageUrl
165
- }), /*#__PURE__*/React.createElement("div", {
166
- className: ax([styles.content])
167
- }, /*#__PURE__*/React.createElement(Inline, {
168
- alignBlock: "center",
169
- space: "space.100",
170
- xcss: layoutStyles.titleRow,
171
- "aria-hidden": "true"
172
- }, icon && /*#__PURE__*/React.createElement(Box, {
173
- as: "span",
174
- "aria-hidden": "true",
175
- xcss: layoutStyles.titleIcon
176
- }, icon), /*#__PURE__*/React.createElement("span", {
177
- className: ax([shouldClampText && styles.title, !shouldClampText && styles.unclampedTitle])
178
- }, titleContent !== null && titleContent !== void 0 ? titleContent : title)), description && /*#__PURE__*/React.createElement("div", {
179
- className: ax([shouldClampText && styles.description, !shouldClampText && styles.unclampedDescription])
180
- }, description), preview.attribution && /*#__PURE__*/React.createElement("div", {
181
- className: ax([styles.attribution, shouldClampText && styles.compactAttribution])
182
- }, AttributionIcon && /*#__PURE__*/React.createElement("span", {
183
- "aria-hidden": "true",
184
- className: ax([styles.attributionIcon])
185
- }, /*#__PURE__*/React.createElement(AttributionIcon, null)), /*#__PURE__*/React.createElement("span", {
186
- className: ax([layoutStyles.attributionText])
187
- }, /*#__PURE__*/React.createElement(Text, {
188
- size: "small",
189
- color: "color.text.subtle"
190
- }, AttributionIcon ? formattedAttributionName : formatMessage(messages.previewAttributionBy, {
191
- name: formattedAttributionName
192
- })))))));
193
- };
194
- const PreviewImage = ({
195
- imageUrl
196
- }) => {
197
- const [hasFailed, setHasFailed] = useState(false);
198
- const [hasLoaded, setHasLoaded] = useState(false);
199
- return /*#__PURE__*/React.createElement("div", {
200
- "aria-hidden": "true",
201
- "data-testid": "quick-insert-preview-image-area",
202
- className: ax([styles.imageArea])
203
- }, !hasFailed && /*#__PURE__*/React.createElement("img", {
204
- "aria-hidden": "true",
205
- "data-testid": "quick-insert-hover-preview",
206
- src: imageUrl,
207
- alt: "",
208
- onLoad: () => setHasLoaded(true),
209
- onError: () => setHasFailed(true),
210
- className: ax([styles.image, !hasLoaded && styles.imageHidden])
129
+ }, /*#__PURE__*/React.createElement(QuickInsertPreviewContent, {
130
+ description: description,
131
+ icon: icon,
132
+ preview: preview,
133
+ shouldClampText: shouldClampText,
134
+ title: titleContent !== null && titleContent !== void 0 ? titleContent : title
211
135
  }));
212
136
  };
@@ -32,9 +32,10 @@ export const QuickInsertMenuItem = ({
32
32
  isDisabled: isDisabled,
33
33
  lozenge: lozenge,
34
34
  onSelect: onSelect,
35
+ preview: preview,
36
+ previewImageUrls: previewImageUrls,
35
37
  shortcut: shortcut,
36
38
  titleContent: titleContent,
37
- shouldWrapIcon: shouldWrapIcon,
38
39
  title: title
39
40
  }) : /*#__PURE__*/React.createElement(CompactQuickInsertMenuItem, {
40
41
  ariaLabel: ariaLabel,
@@ -0,0 +1,38 @@
1
+ ._11c81qyo{font:var(--ds-font-heading-xsmall,normal 653 14px/20px "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
2
+ ._11c8fhey{font:var(--ds-font-body,normal 400 14px/20px "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
3
+ ._11c8wadc{font:var(--ds-font-body-small,normal 400 9pt/1pc "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
4
+ ._2rko12b0{border-radius:var(--ds-radius-small,4px)}
5
+ ._zulp1b66{gap:var(--ds-space-050,4px)}
6
+ ._zulpu2gc{gap:var(--ds-space-100,8px)}
7
+ ._16jlidpf{flex-grow:0}
8
+ ._16jlkb7n{flex-grow:1}
9
+ ._18m915vq{overflow-y:hidden}
10
+ ._1bah1h6o{justify-content:center}
11
+ ._1bsb1osq{width:100%}
12
+ ._1bsb7vkz{width:1pc}
13
+ ._1e0c1txw{display:flex}
14
+ ._1e0c1ule{display:block}
15
+ ._1e0ccj1k{display:-webkit-box}
16
+ ._1i4qfg65{overflow-wrap:anywhere}
17
+ ._1o9zidpf{flex-shrink:0}
18
+ ._1o9zkb7n{flex-shrink:1}
19
+ ._1pfh1wug{margin-block-start:auto}
20
+ ._1reo15vq{overflow-x:hidden}
21
+ ._1ul9idpf{min-width:0}
22
+ ._1yyjcs5v{-webkit-line-clamp:2}
23
+ ._1yyjegat{-webkit-line-clamp:4}
24
+ ._2lx21bp4{flex-direction:column}
25
+ ._3um015vq{visibility:hidden}
26
+ ._4cvr1h6o{align-items:center}
27
+ ._4t3i1osq{height:100%}
28
+ ._4t3i68cl{height:90pt}
29
+ ._4t3i7vkz{height:1pc}
30
+ ._5ral1f51{object-fit:contain}
31
+ ._6rthu2gc{margin-block-end:var(--ds-space-100,8px)}
32
+ ._bfhkhfxm{background-color:var(--ds-surface-sunken,#f8f8f8)}
33
+ ._i0dl1wug{flex-basis:auto}
34
+ ._i0dlexct{flex-basis:16px}
35
+ ._sudp1e54{-webkit-box-orient:vertical}
36
+ ._syaz1gmx{color:var(--ds-text-disabled,#080f214a)}
37
+ ._syazazsu{color:var(--ds-text-subtle,#505258)}
38
+ ._syazi7uo{color:var(--ds-text,#292a2e)}
@@ -0,0 +1,126 @@
1
+ /* QuickInsertPreviewContent.tsx generated by @compiled/babel-plugin v3.0.2 */
2
+ import "./QuickInsertPreviewContent.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React, { useState } from 'react';
5
+
6
+ // Multiline clamping requires styles outside @atlaskit/css's schema.
7
+
8
+ import { useIntl } from 'react-intl';
9
+ import { Box } from '@atlaskit/primitives/compiled/box';
10
+ import { Inline } from '@atlaskit/primitives/compiled/inline';
11
+ import { Text } from '@atlaskit/primitives/compiled/text';
12
+ import { useThemeObserver } from '@atlaskit/tokens/use-theme-observer';
13
+ import { messages } from './messages';
14
+ import { QuickInsertShortcut } from './QuickInsertShortcut';
15
+ const layoutStyles = {
16
+ titleRow: "_1ul9idpf",
17
+ titleIcon: "_4cvr1h6o _1e0c1txw _1o9zidpf _1bah1h6o",
18
+ attributionText: "_16jlkb7n _1o9zkb7n _i0dl1wug _1ul9idpf _1i4qfg65"
19
+ };
20
+ const styles = {
21
+ root: "_1e0c1txw _2lx21bp4 _16jlkb7n _1ul9idpf",
22
+ content: "_zulpu2gc _1e0c1txw _2lx21bp4 _16jlkb7n",
23
+ title: "_11c81qyo _16jlidpf _1o9zkb7n _i0dl1wug _syazazsu _1ul9idpf _1i4qfg65",
24
+ clampedTitle: "_1reo15vq _18m915vq _1e0ccj1k _sudp1e54 _1yyjcs5v",
25
+ description: "_11c8fhey _1reo15vq _18m915vq _syazi7uo _1e0ccj1k _1i4qfg65 _sudp1e54 _1yyjegat",
26
+ unclampedDescription: "_11c8fhey _syazi7uo _1i4qfg65",
27
+ disabledText: "_syaz1gmx",
28
+ imageArea: "_2rko12b0 _1reo15vq _18m915vq _bfhkhfxm _4t3i68cl _6rthu2gc _1bsb1osq",
29
+ image: "_1e0c1ule _4t3i1osq _5ral1f51 _1bsb1osq",
30
+ imageHidden: "_3um015vq",
31
+ attribution: "_zulp1b66 _4cvr1h6o _syazazsu _1e0c1txw _1pfh1wug _1i4qfg65",
32
+ compactAttribution: "_11c8wadc",
33
+ attributionIcon: "_16jlidpf _1o9zidpf _i0dlexct _4cvr1h6o _1e0c1txw _4t3i7vkz _1bah1h6o _1bsb7vkz"
34
+ };
35
+
36
+ /**
37
+ * The image, title, description, and attribution shared by the Quick Insert hover preview and
38
+ * Element Browser tiles. It fills its container; callers own its width and accessible name.
39
+ */
40
+ export const QuickInsertPreviewContent = ({
41
+ description,
42
+ icon,
43
+ id,
44
+ isDisabled = false,
45
+ lozenge,
46
+ preview,
47
+ shortcut,
48
+ shouldClampText = true,
49
+ title
50
+ }) => {
51
+ var _preview$attribution, _preview$attribution2;
52
+ const {
53
+ formatMessage
54
+ } = useIntl();
55
+ const {
56
+ colorMode
57
+ } = useThemeObserver();
58
+ const imageUrl = preview.image ? colorMode === 'dark' && preview.image.dark ? preview.image.dark : preview.image.light : undefined;
59
+ const AttributionIcon = (_preview$attribution = preview.attribution) === null || _preview$attribution === void 0 ? void 0 : _preview$attribution.icon;
60
+ const attributionName = (_preview$attribution2 = preview.attribution) === null || _preview$attribution2 === void 0 ? void 0 : _preview$attribution2.name;
61
+ const formattedAttributionName = typeof attributionName === 'string' ? attributionName : attributionName ? formatMessage(attributionName) : '';
62
+ const titleRow = /*#__PURE__*/React.createElement(Inline, {
63
+ alignBlock: "center",
64
+ space: "space.100",
65
+ xcss: layoutStyles.titleRow
66
+ }, icon && /*#__PURE__*/React.createElement(Box, {
67
+ as: "span",
68
+ "aria-hidden": "true",
69
+ xcss: layoutStyles.titleIcon
70
+ }, icon), /*#__PURE__*/React.createElement("span", {
71
+ "aria-hidden": "true",
72
+ className: ax([styles.title, shouldClampText && styles.clampedTitle, isDisabled && styles.disabledText])
73
+ }, title), lozenge);
74
+ return /*#__PURE__*/React.createElement("div", {
75
+ id: id,
76
+ className: ax([styles.root])
77
+ }, imageUrl && /*#__PURE__*/React.createElement(PreviewImage, {
78
+ key: imageUrl,
79
+ imageUrl: imageUrl
80
+ }), /*#__PURE__*/React.createElement("div", {
81
+ className: ax([styles.content])
82
+ }, shortcut ? /*#__PURE__*/React.createElement(Inline, {
83
+ alignBlock: "start",
84
+ space: "space.100",
85
+ spread: "space-between"
86
+ }, titleRow, /*#__PURE__*/React.createElement(QuickInsertShortcut, {
87
+ isDisabled: isDisabled,
88
+ shortcut: shortcut
89
+ })) : titleRow, description && /*#__PURE__*/React.createElement("div", {
90
+ className: ax([shouldClampText && styles.description, !shouldClampText && styles.unclampedDescription, isDisabled && styles.disabledText])
91
+ }, description), preview.attribution && /*#__PURE__*/React.createElement("div", {
92
+ className: ax([styles.attribution, shouldClampText && styles.compactAttribution, isDisabled && styles.disabledText])
93
+ }, AttributionIcon && /*#__PURE__*/React.createElement("span", {
94
+ "aria-hidden": "true",
95
+ className: ax([styles.attributionIcon])
96
+ }, /*#__PURE__*/React.createElement(AttributionIcon, null)), /*#__PURE__*/React.createElement("span", {
97
+ className: ax([layoutStyles.attributionText])
98
+ }, /*#__PURE__*/React.createElement(Text, {
99
+ size: "small",
100
+ color: isDisabled ? 'color.text.disabled' : 'color.text.subtle'
101
+ }, AttributionIcon ? formattedAttributionName : formatMessage(messages.previewAttributionBy, {
102
+ name: formattedAttributionName
103
+ }))))));
104
+ };
105
+ const PreviewImage = ({
106
+ imageUrl
107
+ }) => {
108
+ const [hasFailed, setHasFailed] = useState(false);
109
+ const [hasLoaded, setHasLoaded] = useState(false);
110
+ return /*#__PURE__*/React.createElement("div", {
111
+ "aria-hidden": "true",
112
+ "data-testid": "quick-insert-preview-image-area",
113
+ className: ax([styles.imageArea])
114
+ }, !hasFailed && /*#__PURE__*/React.createElement("img", {
115
+ "aria-hidden": "true",
116
+ "data-testid": "quick-insert-hover-preview"
117
+ // Element Browser tiles below the fold load as they scroll into view.
118
+ ,
119
+ loading: "lazy",
120
+ src: imageUrl,
121
+ alt: "",
122
+ onLoad: () => setHasLoaded(true),
123
+ onError: () => setHasFailed(true),
124
+ className: ax([styles.image, !hasLoaded && styles.imageHidden])
125
+ }));
126
+ };
@@ -0,0 +1,10 @@
1
+ ._11c8wadc{font:var(--ds-font-body-small,normal 400 9pt/1pc "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
2
+ ._2rko12b0{border-radius:var(--ds-radius-small,4px)}
3
+ ._18zr1b66{padding-inline:var(--ds-space-050,4px)}
4
+ ._1rjcv77o{padding-block:var(--ds-space-025,2px)}
5
+ ._1o9zidpf{flex-shrink:0}
6
+ ._bfhk187o{background-color:var(--ds-background-disabled,#0515240f)}
7
+ ._bfhki8nm{background-color:var(--ds-background-neutral,#0515240f)}
8
+ ._o5721q9c{white-space:nowrap}
9
+ ._syaz1gmx{color:var(--ds-text-disabled,#080f214a)}
10
+ ._syazazsu{color:var(--ds-text-subtle,#505258)}
@@ -0,0 +1,19 @@
1
+ /* QuickInsertShortcut.tsx generated by @compiled/babel-plugin v3.0.2 */
2
+ import "./QuickInsertShortcut.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React from 'react';
5
+ const styles = {
6
+ shortcut: "_2rko12b0 _11c8wadc _1rjcv77o _18zr1b66 _bfhki8nm _syazazsu _1o9zidpf _o5721q9c",
7
+ disabled: "_bfhk187o _syaz1gmx"
8
+ };
9
+
10
+ /**
11
+ * The keyboard or markdown shortcut chip shown beside a Quick Insert item's title, in both the
12
+ * slash-menu row and the Element Browser tile.
13
+ */
14
+ export const QuickInsertShortcut = ({
15
+ isDisabled = false,
16
+ shortcut
17
+ }) => /*#__PURE__*/React.createElement("span", {
18
+ className: ax([styles.shortcut, isDisabled && styles.disabled])
19
+ }, shortcut);