@atlaskit/editor-common 102.10.3 → 102.11.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 +17 -0
- package/dist/cjs/floating-toolbar/DropdownMenuExtensionItems.js +203 -0
- package/dist/cjs/floating-toolbar/DropdownMenuItem.js +203 -0
- package/dist/cjs/floating-toolbar/index.js +15 -1
- package/dist/cjs/messages/index.js +5 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/floating-toolbar/DropdownMenuExtensionItems.js +126 -0
- package/dist/es2019/floating-toolbar/DropdownMenuItem.js +196 -0
- package/dist/es2019/floating-toolbar/index.js +3 -1
- package/dist/es2019/messages/index.js +5 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/floating-toolbar/DropdownMenuExtensionItems.js +193 -0
- package/dist/esm/floating-toolbar/DropdownMenuItem.js +195 -0
- package/dist/esm/floating-toolbar/index.js +3 -1
- package/dist/esm/messages/index.js +5 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/floating-toolbar/DropdownMenuExtensionItems.d.ts +24 -0
- package/dist/types/floating-toolbar/DropdownMenuItem.d.ts +43 -0
- package/dist/types/floating-toolbar/index.d.ts +3 -0
- package/dist/types/messages/index.d.ts +5 -0
- package/dist/types/types/floating-toolbar.d.ts +8 -1
- package/dist/types-ts4.5/floating-toolbar/DropdownMenuExtensionItems.d.ts +24 -0
- package/dist/types-ts4.5/floating-toolbar/DropdownMenuItem.d.ts +43 -0
- package/dist/types-ts4.5/floating-toolbar/index.d.ts +3 -0
- package/dist/types-ts4.5/messages/index.d.ts +5 -0
- package/dist/types-ts4.5/types/floating-toolbar.d.ts +8 -1
- package/package.json +2 -2
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { useCallback, useEffect, useMemo, 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
|
+
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
10
|
+
|
|
11
|
+
import EditorDoneIcon from '@atlaskit/icon/core/migration/check-mark--editor-done';
|
|
12
|
+
import { ButtonItem } from '@atlaskit/menu';
|
|
13
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
14
|
+
import { messages } from '../floating-toolbar';
|
|
15
|
+
export const menuItemDimensions = {
|
|
16
|
+
width: 175,
|
|
17
|
+
height: 32
|
|
18
|
+
};
|
|
19
|
+
const labelStyles = css({
|
|
20
|
+
display: 'inline-block',
|
|
21
|
+
width: '100%'
|
|
22
|
+
});
|
|
23
|
+
const spacerStyles = css({
|
|
24
|
+
display: 'flex',
|
|
25
|
+
flex: 1,
|
|
26
|
+
padding: "var(--ds-space-100, 8px)"
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Extend the ButtonItem component type to allow mouse events to be accepted from the Typescript check
|
|
30
|
+
|
|
31
|
+
const DropdownButtonItem = ButtonItem;
|
|
32
|
+
const SelectedIconBefore = ({
|
|
33
|
+
itemSelected,
|
|
34
|
+
intl,
|
|
35
|
+
showSelected
|
|
36
|
+
}) => {
|
|
37
|
+
if (showSelected && itemSelected) {
|
|
38
|
+
return jsx("span", {
|
|
39
|
+
"aria-hidden": "true"
|
|
40
|
+
}, jsx(EditorDoneIcon, {
|
|
41
|
+
LEGACY_primaryColor: "var(--ds-icon-selected, #0C66E4)",
|
|
42
|
+
LEGACY_size: "small",
|
|
43
|
+
label: intl.formatMessage(messages.confirmModalOK),
|
|
44
|
+
spacing: "none"
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
return jsx("span", {
|
|
48
|
+
css: spacerStyles
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export const DropdownMenuItem = props => {
|
|
52
|
+
const {
|
|
53
|
+
item,
|
|
54
|
+
hide,
|
|
55
|
+
dispatchCommand,
|
|
56
|
+
editorView,
|
|
57
|
+
showSelected,
|
|
58
|
+
intl
|
|
59
|
+
} = props;
|
|
60
|
+
const itemSelected = item.selected;
|
|
61
|
+
const iconBefore = useMemo(() => {
|
|
62
|
+
if (item.icon) {
|
|
63
|
+
return item.icon;
|
|
64
|
+
} else {
|
|
65
|
+
return jsx(SelectedIconBefore, {
|
|
66
|
+
itemSelected: itemSelected,
|
|
67
|
+
showSelected: showSelected,
|
|
68
|
+
intl: intl
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}, [itemSelected, showSelected, intl, item.icon]);
|
|
72
|
+
const [tooltipContent, setTooltipContent] = useState(item.tooltip || '');
|
|
73
|
+
const handleItemMouseOut = useCallback(() => {
|
|
74
|
+
setTooltipContent('');
|
|
75
|
+
if (item.onMouseOut) {
|
|
76
|
+
dispatchCommand(item.onMouseOut);
|
|
77
|
+
}
|
|
78
|
+
}, [item.onMouseOut, dispatchCommand]);
|
|
79
|
+
const handleItemMouseDown = useCallback(e => {
|
|
80
|
+
e.preventDefault(); // ED-16204 - This is needed for safari to get handleItemClick() to work
|
|
81
|
+
if (item.onMouseDown) {
|
|
82
|
+
dispatchCommand(item.onMouseDown);
|
|
83
|
+
}
|
|
84
|
+
}, [item.onMouseDown, dispatchCommand]);
|
|
85
|
+
const handleItemMouseOver = useCallback(() => {
|
|
86
|
+
setTooltipContent(item.tooltip || '');
|
|
87
|
+
if (item.onMouseOver) {
|
|
88
|
+
dispatchCommand(item.onMouseOver);
|
|
89
|
+
}
|
|
90
|
+
}, [item.tooltip, item.onMouseOver, dispatchCommand]);
|
|
91
|
+
const handleItemMouseEnter = useCallback(e => {
|
|
92
|
+
if (item.onMouseEnter) {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
dispatchCommand(item.onMouseEnter);
|
|
95
|
+
}
|
|
96
|
+
}, [item.onMouseEnter, dispatchCommand]);
|
|
97
|
+
const handleItemMouseLeave = useCallback(e => {
|
|
98
|
+
if (item.onMouseLeave) {
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
dispatchCommand(item.onMouseLeave);
|
|
101
|
+
}
|
|
102
|
+
}, [item.onMouseLeave, dispatchCommand]);
|
|
103
|
+
const handleItemOnFocus = useCallback(e => {
|
|
104
|
+
if (item.onFocus) {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
dispatchCommand(item.onFocus);
|
|
107
|
+
}
|
|
108
|
+
}, [item.onFocus, dispatchCommand]);
|
|
109
|
+
const handleItemOnBlur = useCallback(e => {
|
|
110
|
+
if (item.onBlur) {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
dispatchCommand(item.onBlur);
|
|
113
|
+
}
|
|
114
|
+
}, [item.onBlur, dispatchCommand]);
|
|
115
|
+
const handleItemClick = useCallback(() => {
|
|
116
|
+
/**
|
|
117
|
+
* The order of dispatching the event and hide() is important, because
|
|
118
|
+
* the ClickAreaBlock will be relying on the element to calculate the
|
|
119
|
+
* click coordinate.
|
|
120
|
+
* For more details, please visit the comment in this PR https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/5328/edm-1321-set-selection-near-smart-link?link_source=email#chg-packages/editor/editor-core/src/plugins/floating-toolbar/ui/DropdownMenu.tsx
|
|
121
|
+
*/
|
|
122
|
+
dispatchCommand(item.onClick);
|
|
123
|
+
hide();
|
|
124
|
+
if (!(editorView !== null && editorView !== void 0 && editorView.hasFocus())) {
|
|
125
|
+
editorView === null || editorView === void 0 ? void 0 : editorView.focus();
|
|
126
|
+
}
|
|
127
|
+
}, [dispatchCommand, item.onClick, hide, editorView]);
|
|
128
|
+
|
|
129
|
+
/* ED-16704 - Native mouse event handler to overcome firefox issue on disabled <button> - https://github.com/whatwg/html/issues/5886 */
|
|
130
|
+
const labelRef = useRef(null);
|
|
131
|
+
const handleTitleWrapperMouseEvent = useCallback(
|
|
132
|
+
// Ignored via go/ees005
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
|
+
e => {
|
|
135
|
+
if (item.disabled) {
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
}
|
|
139
|
+
}, [item.disabled]);
|
|
140
|
+
|
|
141
|
+
// Ignored via go/ees005
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
143
|
+
const isAriaChecked = item => {
|
|
144
|
+
const {
|
|
145
|
+
selected,
|
|
146
|
+
domItemOptions
|
|
147
|
+
} = item;
|
|
148
|
+
return (domItemOptions === null || domItemOptions === void 0 ? void 0 : domItemOptions.type) === 'item-checkbox' ? selected : undefined;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// Ignored via go/ees005
|
|
152
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
153
|
+
const hasRole = item => {
|
|
154
|
+
var _item$domItemOptions;
|
|
155
|
+
return ((_item$domItemOptions = item.domItemOptions) === null || _item$domItemOptions === void 0 ? void 0 : _item$domItemOptions.type) === 'item-checkbox' ? 'menuitemcheckbox' : undefined;
|
|
156
|
+
};
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
const labelRefCurrent = labelRef.current;
|
|
159
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
160
|
+
labelRefCurrent === null || labelRefCurrent === void 0 ? void 0 : labelRefCurrent.addEventListener('click', handleTitleWrapperMouseEvent);
|
|
161
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
162
|
+
labelRefCurrent === null || labelRefCurrent === void 0 ? void 0 : labelRefCurrent.addEventListener('mousedown', handleTitleWrapperMouseEvent);
|
|
163
|
+
return () => {
|
|
164
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
165
|
+
labelRefCurrent === null || labelRefCurrent === void 0 ? void 0 : labelRefCurrent.removeEventListener('click', handleTitleWrapperMouseEvent);
|
|
166
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
167
|
+
labelRefCurrent === null || labelRefCurrent === void 0 ? void 0 : labelRefCurrent.removeEventListener('mousedown', handleTitleWrapperMouseEvent);
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
const itemContent = jsx(DropdownButtonItem, {
|
|
171
|
+
isSelected: itemSelected,
|
|
172
|
+
iconBefore: iconBefore,
|
|
173
|
+
iconAfter: item.elemAfter,
|
|
174
|
+
onClick: handleItemClick,
|
|
175
|
+
"data-testid": item.testId,
|
|
176
|
+
isDisabled: item.disabled,
|
|
177
|
+
onMouseDown: handleItemMouseDown,
|
|
178
|
+
onMouseOver: handleItemMouseOver,
|
|
179
|
+
onMouseEnter: handleItemMouseEnter,
|
|
180
|
+
onMouseLeave: handleItemMouseLeave,
|
|
181
|
+
onMouseOut: handleItemMouseOut,
|
|
182
|
+
onFocus: handleItemOnFocus,
|
|
183
|
+
onBlur: handleItemOnBlur,
|
|
184
|
+
role: hasRole(item),
|
|
185
|
+
"aria-checked": isAriaChecked(item)
|
|
186
|
+
}, jsx("span", {
|
|
187
|
+
ref: labelRef,
|
|
188
|
+
css: labelStyles
|
|
189
|
+
}, item.title));
|
|
190
|
+
if (tooltipContent) {
|
|
191
|
+
return jsx(Tooltip, {
|
|
192
|
+
content: tooltipContent
|
|
193
|
+
}, itemContent);
|
|
194
|
+
}
|
|
195
|
+
return itemContent;
|
|
196
|
+
};
|
|
@@ -102,5 +102,7 @@ export const areSameItems = (leftArr, rightArr) => {
|
|
|
102
102
|
return leftArr.every((item, index) => isSameItem(rightArr[index], item));
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
106
|
+
export { DropdownMenuExtensionItems } from './DropdownMenuExtensionItems';
|
|
107
|
+
export { DropdownMenuItem } from './DropdownMenuItem';
|
|
106
108
|
export { default as messages } from './messages';
|
|
@@ -82,6 +82,11 @@ export default defineMessages({
|
|
|
82
82
|
defaultMessage: 'Align left',
|
|
83
83
|
description: 'Aligns image to the left'
|
|
84
84
|
},
|
|
85
|
+
delete: {
|
|
86
|
+
id: 'fabric.editor.delete',
|
|
87
|
+
defaultMessage: 'Delete',
|
|
88
|
+
description: 'Delete the element (image, panel, table, etc.) from your document'
|
|
89
|
+
},
|
|
85
90
|
remove: {
|
|
86
91
|
id: 'fabric.editor.remove',
|
|
87
92
|
defaultMessage: 'Remove',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isFedRamp } from './environment';
|
|
2
2
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
3
3
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
4
|
-
const packageVersion = "102.
|
|
4
|
+
const packageVersion = "102.11.0";
|
|
5
5
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
6
6
|
// Remove URL as it has UGC
|
|
7
7
|
// Ignored via go/ees007
|
|
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
13
13
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
14
14
|
import Layer from '../Layer';
|
|
15
15
|
const packageName = "@atlaskit/editor-common";
|
|
16
|
-
const packageVersion = "102.
|
|
16
|
+
const packageVersion = "102.11.0";
|
|
17
17
|
const halfFocusRing = 1;
|
|
18
18
|
const dropOffset = '0, 8';
|
|
19
19
|
// Ignored via go/ees005
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import React, { useEffect, useState } from 'react';
|
|
5
|
+
import Loadable from 'react-loadable';
|
|
6
|
+
import { getContextualToolbarItemsFromModule } from '../extensions';
|
|
7
|
+
import { nodeToJSON } from '../utils';
|
|
8
|
+
import { DropdownMenuItem } from './DropdownMenuItem';
|
|
9
|
+
var noop = function noop() {
|
|
10
|
+
return null;
|
|
11
|
+
};
|
|
12
|
+
var isDefaultExport = function isDefaultExport(mod) {
|
|
13
|
+
return mod.hasOwnProperty('default');
|
|
14
|
+
};
|
|
15
|
+
var resolveExtensionIcon = /*#__PURE__*/function () {
|
|
16
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(getIcon) {
|
|
17
|
+
var maybeIcon;
|
|
18
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19
|
+
while (1) switch (_context.prev = _context.next) {
|
|
20
|
+
case 0:
|
|
21
|
+
if (getIcon) {
|
|
22
|
+
_context.next = 2;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
return _context.abrupt("return", noop);
|
|
26
|
+
case 2:
|
|
27
|
+
_context.next = 4;
|
|
28
|
+
return getIcon();
|
|
29
|
+
case 4:
|
|
30
|
+
maybeIcon = _context.sent;
|
|
31
|
+
return _context.abrupt("return", isDefaultExport(maybeIcon) ? maybeIcon.default : maybeIcon);
|
|
32
|
+
case 6:
|
|
33
|
+
case "end":
|
|
34
|
+
return _context.stop();
|
|
35
|
+
}
|
|
36
|
+
}, _callee);
|
|
37
|
+
}));
|
|
38
|
+
return function resolveExtensionIcon(_x) {
|
|
39
|
+
return _ref.apply(this, arguments);
|
|
40
|
+
};
|
|
41
|
+
}();
|
|
42
|
+
var convertExtensionToDropdownMenuItem = function convertExtensionToDropdownMenuItem(_ref2) {
|
|
43
|
+
var item = _ref2.item,
|
|
44
|
+
disabled = _ref2.disabled,
|
|
45
|
+
node = _ref2.node,
|
|
46
|
+
extension = _ref2.extension;
|
|
47
|
+
var ButtonIcon = item.icon ? Loadable({
|
|
48
|
+
// Ignored via go/ees005
|
|
49
|
+
// eslint-disable-next-line require-await
|
|
50
|
+
loader: function () {
|
|
51
|
+
var _loader = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
52
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
53
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
54
|
+
case 0:
|
|
55
|
+
return _context2.abrupt("return", resolveExtensionIcon(item.icon));
|
|
56
|
+
case 1:
|
|
57
|
+
case "end":
|
|
58
|
+
return _context2.stop();
|
|
59
|
+
}
|
|
60
|
+
}, _callee2);
|
|
61
|
+
}));
|
|
62
|
+
function loader() {
|
|
63
|
+
return _loader.apply(this, arguments);
|
|
64
|
+
}
|
|
65
|
+
return loader;
|
|
66
|
+
}(),
|
|
67
|
+
loading: noop
|
|
68
|
+
}) : undefined;
|
|
69
|
+
var title = '';
|
|
70
|
+
if (item.label) {
|
|
71
|
+
title = item.label;
|
|
72
|
+
} else if (typeof item.tooltip === 'string') {
|
|
73
|
+
title = item.tooltip;
|
|
74
|
+
} else if (item.ariaLabel) {
|
|
75
|
+
title = item.ariaLabel;
|
|
76
|
+
}
|
|
77
|
+
item.disabled = (disabled === null || disabled === void 0 ? void 0 : disabled(item.key)) || false;
|
|
78
|
+
return {
|
|
79
|
+
title: title,
|
|
80
|
+
icon: ButtonIcon ? /*#__PURE__*/React.createElement(ButtonIcon, {
|
|
81
|
+
label: item.label || ''
|
|
82
|
+
}) : undefined,
|
|
83
|
+
disabled: item.disabled,
|
|
84
|
+
onClick: function onClick() {
|
|
85
|
+
if (typeof item.action !== 'function') {
|
|
86
|
+
throw new Error("'action' of context toolbar item '".concat(item.key, "' is not a function"));
|
|
87
|
+
}
|
|
88
|
+
var targetNodeAdf = nodeToJSON(node);
|
|
89
|
+
extension.extensionApi && item.action(targetNodeAdf, extension.extensionApi);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
var DropdownMenuExtensionItem = function DropdownMenuExtensionItem(_ref3) {
|
|
95
|
+
var item = _ref3.item,
|
|
96
|
+
editorView = _ref3.editorView,
|
|
97
|
+
disabled = _ref3.disabled,
|
|
98
|
+
node = _ref3.node,
|
|
99
|
+
extension = _ref3.extension,
|
|
100
|
+
dropdownOptions = _ref3.dropdownOptions;
|
|
101
|
+
var dropdownItem = convertExtensionToDropdownMenuItem({
|
|
102
|
+
item: item,
|
|
103
|
+
disabled: disabled,
|
|
104
|
+
node: node,
|
|
105
|
+
extension: extension
|
|
106
|
+
});
|
|
107
|
+
if (!dropdownItem) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
return /*#__PURE__*/React.createElement(DropdownMenuItem, {
|
|
111
|
+
key: item.key,
|
|
112
|
+
item: dropdownItem,
|
|
113
|
+
editorView: editorView,
|
|
114
|
+
hide: dropdownOptions.hide,
|
|
115
|
+
dispatchCommand: dropdownOptions.dispatchCommand,
|
|
116
|
+
showSelected: dropdownOptions.showSelected,
|
|
117
|
+
intl: dropdownOptions.intl
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
export var DropdownMenuExtensionItems = function DropdownMenuExtensionItems(props) {
|
|
121
|
+
var node = props.node,
|
|
122
|
+
editorView = props.editorView,
|
|
123
|
+
extension = props.extension,
|
|
124
|
+
disabled = props.disabled,
|
|
125
|
+
dropdownOptions = props.dropdownOptions;
|
|
126
|
+
|
|
127
|
+
// Ignored via go/ees005
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
+
var _useState = useState([]),
|
|
130
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
131
|
+
extensions = _useState2[0],
|
|
132
|
+
setExtensions = _useState2[1];
|
|
133
|
+
useEffect(function () {
|
|
134
|
+
getExtensions();
|
|
135
|
+
function getExtensions() {
|
|
136
|
+
return _getExtensions.apply(this, arguments);
|
|
137
|
+
}
|
|
138
|
+
function _getExtensions() {
|
|
139
|
+
_getExtensions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
140
|
+
var provider;
|
|
141
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
142
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
143
|
+
case 0:
|
|
144
|
+
_context3.next = 2;
|
|
145
|
+
return extension.extensionProvider;
|
|
146
|
+
case 2:
|
|
147
|
+
provider = _context3.sent;
|
|
148
|
+
if (!provider) {
|
|
149
|
+
_context3.next = 9;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
_context3.t0 = setExtensions;
|
|
153
|
+
_context3.next = 7;
|
|
154
|
+
return provider.getExtensions();
|
|
155
|
+
case 7:
|
|
156
|
+
_context3.t1 = _context3.sent;
|
|
157
|
+
(0, _context3.t0)(_context3.t1);
|
|
158
|
+
case 9:
|
|
159
|
+
case "end":
|
|
160
|
+
return _context3.stop();
|
|
161
|
+
}
|
|
162
|
+
}, _callee3);
|
|
163
|
+
}));
|
|
164
|
+
return _getExtensions.apply(this, arguments);
|
|
165
|
+
}
|
|
166
|
+
}, [extension.extensionProvider]);
|
|
167
|
+
var nodeAdf = React.useMemo(function () {
|
|
168
|
+
return nodeToJSON(node);
|
|
169
|
+
}, [node]);
|
|
170
|
+
var extensionItems = React.useMemo(function () {
|
|
171
|
+
if (!extension.extensionApi) {
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
return getContextualToolbarItemsFromModule(extensions, nodeAdf, extension.extensionApi);
|
|
175
|
+
}, [extensions, nodeAdf, extension.extensionApi]);
|
|
176
|
+
if (!extensionItems.length || !dropdownOptions) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, extensionItems.map(function (item, idx) {
|
|
180
|
+
if (!('key' in item)) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
return /*#__PURE__*/React.createElement(DropdownMenuExtensionItem, {
|
|
184
|
+
key: item.key,
|
|
185
|
+
item: item,
|
|
186
|
+
editorView: editorView,
|
|
187
|
+
disabled: disabled,
|
|
188
|
+
node: node,
|
|
189
|
+
extension: extension,
|
|
190
|
+
dropdownOptions: dropdownOptions
|
|
191
|
+
});
|
|
192
|
+
}));
|
|
193
|
+
};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
|
+
import { css, jsx } from '@emotion/react';
|
|
10
|
+
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
11
|
+
|
|
12
|
+
import EditorDoneIcon from '@atlaskit/icon/core/migration/check-mark--editor-done';
|
|
13
|
+
import { ButtonItem } from '@atlaskit/menu';
|
|
14
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
15
|
+
import { messages } from '../floating-toolbar';
|
|
16
|
+
export var menuItemDimensions = {
|
|
17
|
+
width: 175,
|
|
18
|
+
height: 32
|
|
19
|
+
};
|
|
20
|
+
var labelStyles = css({
|
|
21
|
+
display: 'inline-block',
|
|
22
|
+
width: '100%'
|
|
23
|
+
});
|
|
24
|
+
var spacerStyles = css({
|
|
25
|
+
display: 'flex',
|
|
26
|
+
flex: 1,
|
|
27
|
+
padding: "var(--ds-space-100, 8px)"
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Extend the ButtonItem component type to allow mouse events to be accepted from the Typescript check
|
|
31
|
+
|
|
32
|
+
var DropdownButtonItem = ButtonItem;
|
|
33
|
+
var SelectedIconBefore = function SelectedIconBefore(_ref) {
|
|
34
|
+
var itemSelected = _ref.itemSelected,
|
|
35
|
+
intl = _ref.intl,
|
|
36
|
+
showSelected = _ref.showSelected;
|
|
37
|
+
if (showSelected && itemSelected) {
|
|
38
|
+
return jsx("span", {
|
|
39
|
+
"aria-hidden": "true"
|
|
40
|
+
}, jsx(EditorDoneIcon, {
|
|
41
|
+
LEGACY_primaryColor: "var(--ds-icon-selected, #0C66E4)",
|
|
42
|
+
LEGACY_size: "small",
|
|
43
|
+
label: intl.formatMessage(messages.confirmModalOK),
|
|
44
|
+
spacing: "none"
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
return jsx("span", {
|
|
48
|
+
css: spacerStyles
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export var DropdownMenuItem = function DropdownMenuItem(props) {
|
|
52
|
+
var item = props.item,
|
|
53
|
+
hide = props.hide,
|
|
54
|
+
dispatchCommand = props.dispatchCommand,
|
|
55
|
+
editorView = props.editorView,
|
|
56
|
+
showSelected = props.showSelected,
|
|
57
|
+
intl = props.intl;
|
|
58
|
+
var itemSelected = item.selected;
|
|
59
|
+
var iconBefore = useMemo(function () {
|
|
60
|
+
if (item.icon) {
|
|
61
|
+
return item.icon;
|
|
62
|
+
} else {
|
|
63
|
+
return jsx(SelectedIconBefore, {
|
|
64
|
+
itemSelected: itemSelected,
|
|
65
|
+
showSelected: showSelected,
|
|
66
|
+
intl: intl
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}, [itemSelected, showSelected, intl, item.icon]);
|
|
70
|
+
var _useState = useState(item.tooltip || ''),
|
|
71
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
72
|
+
tooltipContent = _useState2[0],
|
|
73
|
+
setTooltipContent = _useState2[1];
|
|
74
|
+
var handleItemMouseOut = useCallback(function () {
|
|
75
|
+
setTooltipContent('');
|
|
76
|
+
if (item.onMouseOut) {
|
|
77
|
+
dispatchCommand(item.onMouseOut);
|
|
78
|
+
}
|
|
79
|
+
}, [item.onMouseOut, dispatchCommand]);
|
|
80
|
+
var handleItemMouseDown = useCallback(function (e) {
|
|
81
|
+
e.preventDefault(); // ED-16204 - This is needed for safari to get handleItemClick() to work
|
|
82
|
+
if (item.onMouseDown) {
|
|
83
|
+
dispatchCommand(item.onMouseDown);
|
|
84
|
+
}
|
|
85
|
+
}, [item.onMouseDown, dispatchCommand]);
|
|
86
|
+
var handleItemMouseOver = useCallback(function () {
|
|
87
|
+
setTooltipContent(item.tooltip || '');
|
|
88
|
+
if (item.onMouseOver) {
|
|
89
|
+
dispatchCommand(item.onMouseOver);
|
|
90
|
+
}
|
|
91
|
+
}, [item.tooltip, item.onMouseOver, dispatchCommand]);
|
|
92
|
+
var handleItemMouseEnter = useCallback(function (e) {
|
|
93
|
+
if (item.onMouseEnter) {
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
dispatchCommand(item.onMouseEnter);
|
|
96
|
+
}
|
|
97
|
+
}, [item.onMouseEnter, dispatchCommand]);
|
|
98
|
+
var handleItemMouseLeave = useCallback(function (e) {
|
|
99
|
+
if (item.onMouseLeave) {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
dispatchCommand(item.onMouseLeave);
|
|
102
|
+
}
|
|
103
|
+
}, [item.onMouseLeave, dispatchCommand]);
|
|
104
|
+
var handleItemOnFocus = useCallback(function (e) {
|
|
105
|
+
if (item.onFocus) {
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
dispatchCommand(item.onFocus);
|
|
108
|
+
}
|
|
109
|
+
}, [item.onFocus, dispatchCommand]);
|
|
110
|
+
var handleItemOnBlur = useCallback(function (e) {
|
|
111
|
+
if (item.onBlur) {
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
dispatchCommand(item.onBlur);
|
|
114
|
+
}
|
|
115
|
+
}, [item.onBlur, dispatchCommand]);
|
|
116
|
+
var handleItemClick = useCallback(function () {
|
|
117
|
+
/**
|
|
118
|
+
* The order of dispatching the event and hide() is important, because
|
|
119
|
+
* the ClickAreaBlock will be relying on the element to calculate the
|
|
120
|
+
* click coordinate.
|
|
121
|
+
* For more details, please visit the comment in this PR https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/5328/edm-1321-set-selection-near-smart-link?link_source=email#chg-packages/editor/editor-core/src/plugins/floating-toolbar/ui/DropdownMenu.tsx
|
|
122
|
+
*/
|
|
123
|
+
dispatchCommand(item.onClick);
|
|
124
|
+
hide();
|
|
125
|
+
if (!(editorView !== null && editorView !== void 0 && editorView.hasFocus())) {
|
|
126
|
+
editorView === null || editorView === void 0 || editorView.focus();
|
|
127
|
+
}
|
|
128
|
+
}, [dispatchCommand, item.onClick, hide, editorView]);
|
|
129
|
+
|
|
130
|
+
/* ED-16704 - Native mouse event handler to overcome firefox issue on disabled <button> - https://github.com/whatwg/html/issues/5886 */
|
|
131
|
+
var labelRef = useRef(null);
|
|
132
|
+
var handleTitleWrapperMouseEvent = useCallback(
|
|
133
|
+
// Ignored via go/ees005
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
|
+
function (e) {
|
|
136
|
+
if (item.disabled) {
|
|
137
|
+
e.stopPropagation();
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
}
|
|
140
|
+
}, [item.disabled]);
|
|
141
|
+
|
|
142
|
+
// Ignored via go/ees005
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
|
+
var isAriaChecked = function isAriaChecked(item) {
|
|
145
|
+
var selected = item.selected,
|
|
146
|
+
domItemOptions = item.domItemOptions;
|
|
147
|
+
return (domItemOptions === null || domItemOptions === void 0 ? void 0 : domItemOptions.type) === 'item-checkbox' ? selected : undefined;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// Ignored via go/ees005
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
152
|
+
var hasRole = function hasRole(item) {
|
|
153
|
+
var _item$domItemOptions;
|
|
154
|
+
return ((_item$domItemOptions = item.domItemOptions) === null || _item$domItemOptions === void 0 ? void 0 : _item$domItemOptions.type) === 'item-checkbox' ? 'menuitemcheckbox' : undefined;
|
|
155
|
+
};
|
|
156
|
+
useEffect(function () {
|
|
157
|
+
var labelRefCurrent = labelRef.current;
|
|
158
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
159
|
+
labelRefCurrent === null || labelRefCurrent === void 0 || labelRefCurrent.addEventListener('click', handleTitleWrapperMouseEvent);
|
|
160
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
161
|
+
labelRefCurrent === null || labelRefCurrent === void 0 || labelRefCurrent.addEventListener('mousedown', handleTitleWrapperMouseEvent);
|
|
162
|
+
return function () {
|
|
163
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
164
|
+
labelRefCurrent === null || labelRefCurrent === void 0 || labelRefCurrent.removeEventListener('click', handleTitleWrapperMouseEvent);
|
|
165
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
166
|
+
labelRefCurrent === null || labelRefCurrent === void 0 || labelRefCurrent.removeEventListener('mousedown', handleTitleWrapperMouseEvent);
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
var itemContent = jsx(DropdownButtonItem, {
|
|
170
|
+
isSelected: itemSelected,
|
|
171
|
+
iconBefore: iconBefore,
|
|
172
|
+
iconAfter: item.elemAfter,
|
|
173
|
+
onClick: handleItemClick,
|
|
174
|
+
"data-testid": item.testId,
|
|
175
|
+
isDisabled: item.disabled,
|
|
176
|
+
onMouseDown: handleItemMouseDown,
|
|
177
|
+
onMouseOver: handleItemMouseOver,
|
|
178
|
+
onMouseEnter: handleItemMouseEnter,
|
|
179
|
+
onMouseLeave: handleItemMouseLeave,
|
|
180
|
+
onMouseOut: handleItemMouseOut,
|
|
181
|
+
onFocus: handleItemOnFocus,
|
|
182
|
+
onBlur: handleItemOnBlur,
|
|
183
|
+
role: hasRole(item),
|
|
184
|
+
"aria-checked": isAriaChecked(item)
|
|
185
|
+
}, jsx("span", {
|
|
186
|
+
ref: labelRef,
|
|
187
|
+
css: labelStyles
|
|
188
|
+
}, item.title));
|
|
189
|
+
if (tooltipContent) {
|
|
190
|
+
return jsx(Tooltip, {
|
|
191
|
+
content: tooltipContent
|
|
192
|
+
}, itemContent);
|
|
193
|
+
}
|
|
194
|
+
return itemContent;
|
|
195
|
+
};
|
|
@@ -117,5 +117,7 @@ export var areSameItems = function areSameItems(leftArr, rightArr) {
|
|
|
117
117
|
});
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
121
|
+
export { DropdownMenuExtensionItems } from './DropdownMenuExtensionItems';
|
|
122
|
+
export { DropdownMenuItem } from './DropdownMenuItem';
|
|
121
123
|
export { default as messages } from './messages';
|
|
@@ -82,6 +82,11 @@ export default defineMessages({
|
|
|
82
82
|
defaultMessage: 'Align left',
|
|
83
83
|
description: 'Aligns image to the left'
|
|
84
84
|
},
|
|
85
|
+
delete: {
|
|
86
|
+
id: 'fabric.editor.delete',
|
|
87
|
+
defaultMessage: 'Delete',
|
|
88
|
+
description: 'Delete the element (image, panel, table, etc.) from your document'
|
|
89
|
+
},
|
|
85
90
|
remove: {
|
|
86
91
|
id: 'fabric.editor.remove',
|
|
87
92
|
defaultMessage: 'Remove',
|
|
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
import { isFedRamp } from './environment';
|
|
8
8
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
9
9
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
10
|
-
var packageVersion = "102.
|
|
10
|
+
var packageVersion = "102.11.0";
|
|
11
11
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
12
12
|
// Remove URL as it has UGC
|
|
13
13
|
// Ignored via go/ees007
|
|
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
20
20
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
21
21
|
import Layer from '../Layer';
|
|
22
22
|
var packageName = "@atlaskit/editor-common";
|
|
23
|
-
var packageVersion = "102.
|
|
23
|
+
var packageVersion = "102.11.0";
|
|
24
24
|
var halfFocusRing = 1;
|
|
25
25
|
var dropOffset = '0, 8';
|
|
26
26
|
// Ignored via go/ees005
|