@atlaskit/editor-common 125.2.1 → 125.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/dist/cjs/element-browser/components/ElementBrowserLoader.js +8 -31
- package/dist/cjs/extensions/buildMenuItem.js +6 -3
- package/dist/cjs/extensions/extension-handlers.js +17 -96
- package/dist/cjs/floating-toolbar/DropdownMenuExtensionItems.js +4 -25
- package/dist/cjs/icons/index.js +10 -33
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/quick-insert/CompactQuickInsertMenuItem.compiled.css +0 -1
- package/dist/cjs/quick-insert/CompactQuickInsertMenuItem.js +22 -28
- package/dist/cjs/quick-insert/QuickInsertHoverPreview.compiled.css +42 -1
- package/dist/cjs/quick-insert/QuickInsertHoverPreview.js +147 -68
- package/dist/cjs/quick-insert/QuickInsertMenuItem.js +4 -0
- package/dist/cjs/quick-insert/QuickInsertMenuSection.js +11 -4
- package/dist/cjs/quick-insert/assets/index.js +257 -888
- package/dist/cjs/quick-insert/confluence-attribution-icon.js +18 -0
- package/dist/cjs/quick-insert/jira-attribution-icon.js +18 -0
- package/dist/cjs/quick-insert/messages.js +30 -0
- package/dist/cjs/quick-insert/preview.js +5 -0
- package/dist/cjs/quick-insert/snippetPreviewImageUrls.js +43 -43
- package/dist/cjs/quick-insert/use-menu-list-height.js +58 -0
- package/dist/cjs/quick-insert/use-menu-popup-sizing.js +60 -0
- package/dist/cjs/toolbar-flag-check.js +2 -2
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/Mention/mention-with-profilecard.js +19 -30
- package/dist/cjs/ui/Popup/index.js +101 -17
- package/dist/es2019/element-browser/components/ElementBrowserLoader.js +2 -16
- package/dist/es2019/extensions/buildMenuItem.js +5 -1
- package/dist/es2019/extensions/extension-handlers.js +15 -70
- package/dist/es2019/floating-toolbar/DropdownMenuExtensionItems.js +2 -16
- package/dist/es2019/icons/index.js +3 -17
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/quick-insert/CompactQuickInsertMenuItem.compiled.css +0 -1
- package/dist/es2019/quick-insert/CompactQuickInsertMenuItem.js +20 -29
- package/dist/es2019/quick-insert/QuickInsertHoverPreview.compiled.css +42 -1
- package/dist/es2019/quick-insert/QuickInsertHoverPreview.js +130 -55
- package/dist/es2019/quick-insert/QuickInsertMenuItem.js +4 -0
- package/dist/es2019/quick-insert/QuickInsertMenuSection.js +11 -4
- package/dist/es2019/quick-insert/assets/index.js +66 -386
- package/dist/es2019/quick-insert/confluence-attribution-icon.js +10 -0
- package/dist/es2019/quick-insert/jira-attribution-icon.js +10 -0
- package/dist/es2019/quick-insert/messages.js +30 -0
- package/dist/es2019/quick-insert/preview.js +1 -0
- package/dist/es2019/quick-insert/snippetPreviewImageUrls.js +43 -43
- package/dist/es2019/quick-insert/use-menu-list-height.js +37 -0
- package/dist/es2019/quick-insert/use-menu-popup-sizing.js +49 -0
- package/dist/es2019/toolbar-flag-check.js +2 -2
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/Mention/mention-with-profilecard.js +12 -15
- package/dist/es2019/ui/Popup/index.js +89 -7
- package/dist/esm/element-browser/components/ElementBrowserLoader.js +6 -28
- package/dist/esm/extensions/buildMenuItem.js +6 -3
- package/dist/esm/extensions/extension-handlers.js +17 -97
- package/dist/esm/floating-toolbar/DropdownMenuExtensionItems.js +4 -24
- package/dist/esm/icons/index.js +7 -29
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/quick-insert/CompactQuickInsertMenuItem.compiled.css +0 -1
- package/dist/esm/quick-insert/CompactQuickInsertMenuItem.js +23 -29
- package/dist/esm/quick-insert/QuickInsertHoverPreview.compiled.css +42 -1
- package/dist/esm/quick-insert/QuickInsertHoverPreview.js +150 -68
- package/dist/esm/quick-insert/QuickInsertMenuItem.js +4 -0
- package/dist/esm/quick-insert/QuickInsertMenuSection.js +11 -4
- package/dist/esm/quick-insert/assets/index.js +194 -764
- package/dist/esm/quick-insert/confluence-attribution-icon.js +12 -0
- package/dist/esm/quick-insert/jira-attribution-icon.js +12 -0
- package/dist/esm/quick-insert/messages.js +30 -0
- package/dist/esm/quick-insert/preview.js +1 -0
- package/dist/esm/quick-insert/snippetPreviewImageUrls.js +43 -43
- package/dist/esm/quick-insert/use-menu-list-height.js +51 -0
- package/dist/esm/quick-insert/use-menu-popup-sizing.js +53 -0
- package/dist/esm/toolbar-flag-check.js +2 -2
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/Mention/mention-with-profilecard.js +16 -25
- package/dist/esm/ui/Popup/index.js +101 -17
- package/dist/types/extensions/types/extension-manifest.d.ts +5 -0
- package/dist/types/extensions/types/utils.d.ts +2 -0
- package/dist/types/icons/index.d.ts +3 -5
- package/dist/types/provider-factory/profile-card-provider.d.ts +14 -1
- package/dist/types/provider-factory/quick-insert-provider.d.ts +3 -0
- package/dist/types/quick-insert/CompactQuickInsertMenuItem.d.ts +1 -1
- package/dist/types/quick-insert/QuickInsertHoverPreview.d.ts +7 -6
- package/dist/types/quick-insert/QuickInsertMenuItem.d.ts +7 -2
- package/dist/types/quick-insert/assets/index.d.ts +32 -34
- package/dist/types/quick-insert/confluence-attribution-icon.d.ts +3 -0
- package/dist/types/quick-insert/jira-attribution-icon.d.ts +3 -0
- package/dist/types/quick-insert/messages.d.ts +5 -2
- package/dist/types/quick-insert/preview.d.ts +16 -0
- package/dist/types/quick-insert/use-menu-list-height.d.ts +6 -0
- package/dist/types/quick-insert/use-menu-popup-sizing.d.ts +11 -0
- package/dist/types/ui/Popup/index.d.ts +11 -0
- package/package.json +6 -6
- package/quick-insert/confluence-attribution-icon/package.json +10 -0
- package/quick-insert/jira-attribution-icon/package.json +10 -0
- package/quick-insert/preview/package.json +10 -0
- package/quick-insert/use-menu-list-height/package.json +10 -0
- package/quick-insert/use-menu-popup-sizing/package.json +10 -0
|
@@ -2,86 +2,161 @@
|
|
|
2
2
|
import "./QuickInsertHoverPreview.compiled.css";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
import { useState } from 'react';
|
|
5
|
+
import { useLayoutEffect, useState } from 'react';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
// Viewport calculations and multiline clamping require styles outside @atlaskit/css's schema.
|
|
9
|
+
|
|
10
|
+
import { useIntl } from 'react-intl';
|
|
11
|
+
|
|
12
|
+
// Viewport clamping requires modifiers, which the top-layer adapter does not support.
|
|
13
|
+
import { Popper } from '@atlaskit/popper/react-popper';
|
|
14
|
+
import { Text } from '@atlaskit/primitives/compiled/text';
|
|
8
15
|
import { useThemeObserver } from '@atlaskit/tokens/use-theme-observer';
|
|
9
|
-
|
|
10
|
-
const PREVIEW_OFFSET = [-4, 4];
|
|
16
|
+
import { messages } from './messages';
|
|
11
17
|
const PREVIEW_MODIFIERS = [{
|
|
18
|
+
name: 'offset',
|
|
19
|
+
options: {
|
|
20
|
+
offset: [0, 4]
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
name: 'flip',
|
|
24
|
+
options: {
|
|
25
|
+
fallbackPlacements: ['left-start'],
|
|
26
|
+
// Choose the side by horizontal space; vertical overflow is shifted into view.
|
|
27
|
+
altAxis: false,
|
|
28
|
+
padding: 8,
|
|
29
|
+
rootBoundary: 'viewport'
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
12
32
|
name: 'preventOverflow',
|
|
13
33
|
options: {
|
|
14
|
-
mainAxis:
|
|
34
|
+
mainAxis: true,
|
|
35
|
+
altAxis: true,
|
|
36
|
+
tether: false,
|
|
37
|
+
padding: 8,
|
|
38
|
+
rootBoundary: 'viewport'
|
|
15
39
|
}
|
|
16
40
|
}];
|
|
17
41
|
const styles = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
42
|
+
positioner: "_c71lk6is _p12f1oec _1pby16oo",
|
|
43
|
+
panel: "_2rko1qi0 _1reo15vq _18m915vq _1rjcutpp _18zrutpp _vchhusvi _bfhk1bhr _16qs130s _c71l1kw7 _p12f1osq _1bsbncxg",
|
|
44
|
+
content: "_zulpu2gc _1e0c1txw _2lx21bp4",
|
|
45
|
+
title: "_11c81qyo _1reo15vq _18m915vq _syazazsu _1i4qfg65 _1e0ccj1k _sudp1e54 _1yyjcs5v",
|
|
46
|
+
description: "_11c8fhey _1reo15vq _18m915vq _syazi7uo _1e0ccj1k _1i4qfg65 _sudp1e54 _1yyjegat",
|
|
47
|
+
imageArea: "_2rko12b0 _1reo15vq _18m915vq _bfhkhfxm _4t3i68cl _6rthu2gc _p12f1osq _1bsbp3fh",
|
|
48
|
+
image: "_1e0c1ule _4t3i1osq _5ral1f51 _1bsb1osq",
|
|
49
|
+
imageHidden: "_3um015vq",
|
|
50
|
+
attribution: "_11c8wadc _zulp1b66 _4cvr1h6o _syazazsu _1e0c1txw _1i4qfg65",
|
|
51
|
+
attributionIcon: "_16jlidpf _1o9zidpf _i0dlexct _4cvr1h6o _1e0c1txw _4t3i7vkz _1bah1h6o _1bsb7vkz"
|
|
21
52
|
};
|
|
22
53
|
|
|
23
|
-
/**
|
|
54
|
+
/** The selected item's description and attribution are announced through its aria-describedby. */
|
|
24
55
|
export const QuickInsertHoverPreview = ({
|
|
25
|
-
|
|
26
|
-
|
|
56
|
+
description,
|
|
57
|
+
id,
|
|
58
|
+
preview,
|
|
59
|
+
referenceElement,
|
|
60
|
+
title
|
|
27
61
|
}) => {
|
|
28
62
|
const {
|
|
29
63
|
colorMode
|
|
30
64
|
} = useThemeObserver();
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
key: previewImageUrl,
|
|
34
|
-
previewImageUrl: previewImageUrl,
|
|
35
|
-
referenceElement: referenceElement
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
const QuickInsertHoverPreviewImage = ({
|
|
39
|
-
previewImageUrl,
|
|
40
|
-
referenceElement
|
|
41
|
-
}) => {
|
|
42
|
-
const [hasFailed, setHasFailed] = useState(false);
|
|
43
|
-
const [dimensions, setDimensions] = useState();
|
|
44
|
-
if (hasFailed) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Unlike a dialog popup, this decorative preview must not introduce focus or ARIA ownership.
|
|
65
|
+
const imageUrl = preview.image ? colorMode === 'dark' && preview.image.dark ? preview.image.dark : preview.image.light : undefined;
|
|
66
|
+
const hasAccessibleContent = Boolean(description || preview.attribution);
|
|
49
67
|
return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(Popper, {
|
|
50
|
-
offset: PREVIEW_OFFSET,
|
|
51
68
|
placement: "right-start",
|
|
52
69
|
referenceElement: referenceElement,
|
|
53
70
|
strategy: "fixed",
|
|
54
|
-
shouldFitViewport: true,
|
|
55
71
|
modifiers: PREVIEW_MODIFIERS
|
|
56
72
|
}, ({
|
|
57
73
|
ref,
|
|
58
|
-
style
|
|
59
|
-
|
|
74
|
+
style,
|
|
75
|
+
update
|
|
76
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
60
77
|
ref: ref,
|
|
61
|
-
style:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
style: style,
|
|
79
|
+
className: ax([styles.positioner])
|
|
80
|
+
}, /*#__PURE__*/React.createElement(QuickInsertPreviewPanel, {
|
|
81
|
+
description: description,
|
|
82
|
+
id: hasAccessibleContent ? id : undefined,
|
|
83
|
+
imageUrl: imageUrl,
|
|
84
|
+
preview: preview,
|
|
85
|
+
referenceElement: referenceElement,
|
|
86
|
+
title: title,
|
|
87
|
+
update: update
|
|
88
|
+
}))), referenceElement.ownerDocument.body);
|
|
89
|
+
};
|
|
90
|
+
const QuickInsertPreviewPanel = ({
|
|
91
|
+
description,
|
|
92
|
+
id,
|
|
93
|
+
imageUrl,
|
|
94
|
+
preview,
|
|
95
|
+
referenceElement,
|
|
96
|
+
title,
|
|
97
|
+
update
|
|
98
|
+
}) => {
|
|
99
|
+
var _preview$attribution;
|
|
100
|
+
const {
|
|
101
|
+
formatMessage
|
|
102
|
+
} = useIntl();
|
|
103
|
+
const [panelElement, setPanelElement] = useState(null);
|
|
104
|
+
const AttributionIcon = (_preview$attribution = preview.attribution) === null || _preview$attribution === void 0 ? void 0 : _preview$attribution.icon;
|
|
105
|
+
useLayoutEffect(() => {
|
|
106
|
+
var _referenceElement$own;
|
|
107
|
+
void update();
|
|
108
|
+
const ResizeObserverConstructor = (_referenceElement$own = referenceElement.ownerDocument.defaultView) === null || _referenceElement$own === void 0 ? void 0 : _referenceElement$own.ResizeObserver;
|
|
109
|
+
if (!panelElement || !ResizeObserverConstructor) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const observer = new ResizeObserverConstructor(() => void update());
|
|
113
|
+
observer.observe(panelElement);
|
|
114
|
+
return () => observer.disconnect();
|
|
115
|
+
}, [panelElement, referenceElement, update]);
|
|
116
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
117
|
+
ref: setPanelElement,
|
|
118
|
+
id: id,
|
|
119
|
+
role: id ? 'tooltip' : undefined,
|
|
120
|
+
"data-testid": "quick-insert-preview-panel",
|
|
121
|
+
className: ax([styles.panel])
|
|
122
|
+
}, imageUrl && /*#__PURE__*/React.createElement(PreviewImage, {
|
|
123
|
+
key: imageUrl,
|
|
124
|
+
imageUrl: imageUrl
|
|
125
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
126
|
+
className: ax([styles.content])
|
|
127
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
128
|
+
"aria-hidden": "true",
|
|
129
|
+
className: ax([styles.title])
|
|
130
|
+
}, title), description && /*#__PURE__*/React.createElement("div", {
|
|
131
|
+
className: ax([styles.description])
|
|
132
|
+
}, description), preview.attribution && /*#__PURE__*/React.createElement("div", {
|
|
133
|
+
className: ax([styles.attribution])
|
|
134
|
+
}, AttributionIcon && /*#__PURE__*/React.createElement("span", {
|
|
135
|
+
"aria-hidden": "true",
|
|
136
|
+
className: ax([styles.attributionIcon])
|
|
137
|
+
}, /*#__PURE__*/React.createElement(AttributionIcon, null)), /*#__PURE__*/React.createElement(Text, {
|
|
138
|
+
size: "small",
|
|
139
|
+
color: "color.text.subtle"
|
|
140
|
+
}, AttributionIcon ? preview.attribution.name : formatMessage(messages.previewAttributionBy, {
|
|
141
|
+
name: preview.attribution.name
|
|
142
|
+
})))));
|
|
143
|
+
};
|
|
144
|
+
const PreviewImage = ({
|
|
145
|
+
imageUrl
|
|
146
|
+
}) => {
|
|
147
|
+
const [hasFailed, setHasFailed] = useState(false);
|
|
148
|
+
const [hasLoaded, setHasLoaded] = useState(false);
|
|
149
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
150
|
+
"aria-hidden": "true",
|
|
151
|
+
"data-testid": "quick-insert-preview-image-area",
|
|
152
|
+
className: ax([styles.imageArea])
|
|
153
|
+
}, !hasFailed && /*#__PURE__*/React.createElement("img", {
|
|
67
154
|
"aria-hidden": "true",
|
|
68
155
|
"data-testid": "quick-insert-hover-preview",
|
|
69
|
-
src:
|
|
156
|
+
src: imageUrl,
|
|
70
157
|
alt: "",
|
|
71
|
-
onLoad:
|
|
72
|
-
const {
|
|
73
|
-
naturalHeight,
|
|
74
|
-
naturalWidth
|
|
75
|
-
} = event.currentTarget;
|
|
76
|
-
if (naturalWidth === 0) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
setDimensions({
|
|
80
|
-
height: naturalHeight / naturalWidth * PREVIEW_WIDTH,
|
|
81
|
-
width: PREVIEW_WIDTH
|
|
82
|
-
});
|
|
83
|
-
},
|
|
158
|
+
onLoad: () => setHasLoaded(true),
|
|
84
159
|
onError: () => setHasFailed(true),
|
|
85
|
-
className: ax([styles.image,
|
|
86
|
-
}))
|
|
160
|
+
className: ax([styles.image, !hasLoaded && styles.imageHidden])
|
|
161
|
+
}));
|
|
87
162
|
};
|
|
@@ -8,8 +8,10 @@ export const QuickInsertMenuItem = ({
|
|
|
8
8
|
iconBefore,
|
|
9
9
|
isDisabled,
|
|
10
10
|
onSelect,
|
|
11
|
+
preview,
|
|
11
12
|
previewImageUrls,
|
|
12
13
|
shortcut,
|
|
14
|
+
shouldShowPreview,
|
|
13
15
|
shouldWrapIcon,
|
|
14
16
|
title
|
|
15
17
|
}) => {
|
|
@@ -31,8 +33,10 @@ export const QuickInsertMenuItem = ({
|
|
|
31
33
|
iconBefore: iconBefore,
|
|
32
34
|
isDisabled: isDisabled,
|
|
33
35
|
onSelect: onSelect,
|
|
36
|
+
preview: preview,
|
|
34
37
|
previewImageUrls: previewImageUrls,
|
|
35
38
|
shortcut: shortcut,
|
|
39
|
+
shouldShowPreview: shouldShowPreview,
|
|
36
40
|
shouldWrapIcon: shouldWrapIcon,
|
|
37
41
|
title: title
|
|
38
42
|
});
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import HeadingItem from '@atlaskit/menu/heading-item';
|
|
3
|
+
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
3
4
|
export const QuickInsertMenuSection = ({
|
|
4
5
|
children,
|
|
5
6
|
title
|
|
6
|
-
}) => /*#__PURE__*/React.createElement(
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
}) => /*#__PURE__*/React.createElement(Box, {
|
|
8
|
+
role: "group",
|
|
9
|
+
"aria-label": title
|
|
10
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
11
|
+
paddingBlockStart: "space.150",
|
|
12
|
+
paddingBlockEnd: "space.050"
|
|
13
|
+
}, /*#__PURE__*/React.createElement(HeadingItem, {
|
|
14
|
+
"aria-hidden": true
|
|
15
|
+
}, title)), children);
|