@atlaskit/editor-plugin-card 1.14.4 → 1.15.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/.eslintrc.js +12 -12
- package/CHANGELOG.md +692 -681
- package/LICENSE.md +6 -8
- package/dist/cjs/nodeviews/datasource.js +1 -0
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +4 -1
- package/dist/cjs/pm-plugins/doc.js +21 -1
- package/dist/cjs/toolbar.js +36 -6
- package/dist/cjs/ui/AwarenessWrapper/index.js +20 -18
- package/dist/cjs/ui/DatasourceModal/index.js +4 -5
- package/dist/cjs/ui/EditDatasourceButton.js +5 -26
- package/dist/cjs/ui/EditToolbarButton.js +139 -0
- package/dist/cjs/ui/InlineCardOverlay/index.js +9 -3
- package/dist/cjs/ui/{NewInlineCardOverlay → LeftIconOverlay}/index.js +60 -101
- package/dist/cjs/ui/ResizableEmbedCard.js +3 -0
- package/dist/cjs/utils.js +4 -1
- package/dist/es2019/nodeviews/datasource.js +1 -0
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +4 -1
- package/dist/es2019/pm-plugins/doc.js +22 -2
- package/dist/es2019/toolbar.js +33 -7
- package/dist/es2019/ui/AwarenessWrapper/index.js +20 -18
- package/dist/es2019/ui/DatasourceModal/index.js +4 -5
- package/dist/es2019/ui/EditDatasourceButton.js +1 -22
- package/dist/es2019/ui/EditToolbarButton.js +123 -0
- package/dist/es2019/ui/InlineCardOverlay/index.js +9 -3
- package/dist/es2019/ui/{NewInlineCardOverlay → LeftIconOverlay}/index.js +51 -94
- package/dist/es2019/ui/ResizableEmbedCard.js +4 -0
- package/dist/es2019/utils.js +3 -0
- package/dist/esm/nodeviews/datasource.js +1 -0
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +4 -1
- package/dist/esm/pm-plugins/doc.js +22 -2
- package/dist/esm/toolbar.js +38 -8
- package/dist/esm/ui/AwarenessWrapper/index.js +20 -18
- package/dist/esm/ui/DatasourceModal/index.js +4 -5
- package/dist/esm/ui/EditDatasourceButton.js +1 -22
- package/dist/esm/ui/EditToolbarButton.js +131 -0
- package/dist/esm/ui/InlineCardOverlay/index.js +9 -3
- package/dist/esm/ui/{NewInlineCardOverlay → LeftIconOverlay}/index.js +62 -103
- package/dist/esm/ui/ResizableEmbedCard.js +3 -0
- package/dist/esm/utils.js +3 -0
- package/dist/types/pm-plugins/doc.d.ts +1 -0
- package/dist/types/ui/EditDatasourceButton.d.ts +0 -2
- package/dist/types/ui/EditToolbarButton.d.ts +15 -0
- package/dist/types/ui/EditorAnalyticsContext.d.ts +1 -1
- package/dist/types/ui/EditorLinkingPlatformAnalytics/DatasourceEvents.d.ts +1 -1
- package/dist/types/ui/EditorLinkingPlatformAnalytics/LinkEvents.d.ts +1 -1
- package/dist/types/ui/EditorSmartCardEvents.d.ts +1 -1
- package/dist/types/ui/LeftIconOverlay/index.d.ts +10 -0
- package/dist/types/utils.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/doc.d.ts +1 -0
- package/dist/types-ts4.5/ui/EditDatasourceButton.d.ts +0 -2
- package/dist/types-ts4.5/ui/EditToolbarButton.d.ts +15 -0
- package/dist/types-ts4.5/ui/EditorAnalyticsContext.d.ts +1 -1
- package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/DatasourceEvents.d.ts +1 -1
- package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/LinkEvents.d.ts +1 -1
- package/dist/types-ts4.5/ui/EditorSmartCardEvents.d.ts +1 -1
- package/dist/types-ts4.5/ui/LeftIconOverlay/index.d.ts +10 -0
- package/dist/types-ts4.5/utils.d.ts +2 -0
- package/package.json +9 -6
- package/report.api.md +94 -96
- package/dist/types/ui/NewInlineCardOverlay/index.d.ts +0 -6
- package/dist/types-ts4.5/ui/NewInlineCardOverlay/index.d.ts +0 -6
|
@@ -9,7 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
13
|
var _react2 = require("@emotion/react");
|
|
15
14
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
@@ -18,77 +17,74 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
18
17
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
19
18
|
var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferences"));
|
|
20
19
|
var _colors = require("@atlaskit/theme/colors");
|
|
20
|
+
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
21
21
|
var _utils2 = require("../InlineCardOverlay/utils");
|
|
22
|
-
var _excluded = ["children", "isSelected", "isVisible", "testId"
|
|
22
|
+
var _excluded = ["children", "isSelected", "isVisible", "testId"];
|
|
23
23
|
/* eslint-disable @atlaskit/design-system/no-nested-styles */
|
|
24
24
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
27
27
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
28
28
|
var DEBOUNCE_IN_MS = 5;
|
|
29
|
-
var ESTIMATED_MIN_WIDTH_IN_PX = 16;
|
|
30
29
|
var PADDING_IN_PX = 4;
|
|
31
|
-
var ICON_WIDTH_IN_PX =
|
|
30
|
+
var ICON_WIDTH_IN_PX = 16;
|
|
32
31
|
var ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
|
|
33
|
-
var OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
|
|
34
32
|
var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
|
|
35
33
|
var TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
|
|
36
34
|
var SMART_LINK_BACKGROUND_COLOR = "var(--ds-surface-raised, ".concat(_colors.N0, ")");
|
|
37
|
-
|
|
38
|
-
var
|
|
35
|
+
var CONFIGURE_ICON_BACKGROUND_COLOR = "var(--ds-background-neutral, ".concat(_colors.N30A, ")");
|
|
36
|
+
var CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR = "var(--ds-background-neutral-hovered, ".concat(_colors.N40A, ")");
|
|
37
|
+
var CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR = "var(--ds-background-neutral-pressed, ".concat(_colors.N60A, ")");
|
|
39
38
|
var containerStyles = (0, _react2.css)({
|
|
40
39
|
position: 'relative',
|
|
41
|
-
lineHeight: 'normal'
|
|
42
|
-
':active': (0, _defineProperty2.default)({}, ".".concat(ICON_AND_LABEL_CLASSNAME), {
|
|
43
|
-
background: SMART_LINK_ACTIVE_COLOR
|
|
44
|
-
})
|
|
40
|
+
lineHeight: 'normal'
|
|
45
41
|
});
|
|
46
42
|
var overlayStyles = (0, _react2.css)({
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
// Vertically align. Required for overlay to be centered inside the inline link (the inline lozenge is slightly larger than the designs)
|
|
45
|
+
transform: 'translate(0%, -50%)',
|
|
46
|
+
top: '50%',
|
|
47
47
|
// Set default styling to be invisible but available in dom for width calculation.
|
|
48
48
|
visibility: 'hidden',
|
|
49
|
-
marginTop: "var(--ds-space-050, 4px)",
|
|
50
|
-
position: 'absolute',
|
|
51
|
-
verticalAlign: 'text-top',
|
|
52
|
-
height: '1lh',
|
|
53
|
-
'@supports not (height: 1lh)': {
|
|
54
|
-
height: '1.2em'
|
|
55
|
-
},
|
|
56
49
|
overflow: 'hidden',
|
|
57
50
|
// EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
|
|
58
|
-
zIndex: 2
|
|
59
|
-
pointerEvents: 'none'
|
|
51
|
+
zIndex: 2
|
|
60
52
|
});
|
|
61
53
|
var showOverlayStyles = (0, _react2.css)({
|
|
62
54
|
visibility: 'visible'
|
|
63
55
|
});
|
|
64
56
|
var iconStyles = (0, _react2.css)({
|
|
65
|
-
|
|
57
|
+
background: CONFIGURE_ICON_BACKGROUND_COLOR,
|
|
58
|
+
':hover': {
|
|
59
|
+
background: CONFIGURE_ICON_BACKGROUND_HOVERED_COLOR
|
|
60
|
+
},
|
|
61
|
+
':active': {
|
|
62
|
+
background: CONFIGURE_ICON_BACKGROUND_ACTIVE_COLOR
|
|
63
|
+
},
|
|
66
64
|
span: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
// If PreferencesIcon left as inline-block (default), height is incorrect and border radius is clipped when parent element
|
|
66
|
+
// uses 1lh height (rather than 100%)
|
|
67
|
+
display: 'block'
|
|
68
|
+
},
|
|
69
|
+
// Note: The spec recomends 3px, but the icon doesn't fit left of the lozenge text if this size
|
|
70
|
+
padding: "var(--ds-space-025, 2px)",
|
|
71
|
+
borderRadius: '3px'
|
|
74
72
|
});
|
|
75
73
|
var iconAndLabelStyles = (0, _react2.css)({
|
|
76
74
|
display: 'flex',
|
|
77
75
|
alignItems: 'center',
|
|
78
76
|
height: '100%',
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-space
|
|
78
|
+
marginLeft: '2.5px',
|
|
79
|
+
// Margin from very left of entire card (inclusive of blue)
|
|
80
|
+
|
|
81
|
+
// This exists so if we set a semi-transparent background above, the provider icon doesn't show
|
|
81
82
|
background: SMART_LINK_BACKGROUND_COLOR,
|
|
83
|
+
// Ensure we don't have a white gap when the inline-card is in an active state
|
|
84
|
+
borderRadius: '3px',
|
|
82
85
|
color: "var(--ds-text-subtlest, ".concat(_colors.N700, ")")
|
|
83
86
|
});
|
|
84
|
-
var
|
|
85
|
-
display: 'flex',
|
|
86
|
-
flexDirection: 'row-reverse',
|
|
87
|
-
alignItems: 'center',
|
|
88
|
-
width: 'max-content',
|
|
89
|
-
height: '100%'
|
|
90
|
-
});
|
|
91
|
-
var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
|
|
87
|
+
var LeftIconOverlay = function LeftIconOverlay(_ref) {
|
|
92
88
|
var children = _ref.children,
|
|
93
89
|
_ref$isSelected = _ref.isSelected,
|
|
94
90
|
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
@@ -96,7 +92,6 @@ var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
|
|
|
96
92
|
isVisible = _ref$isVisible === void 0 ? false : _ref$isVisible,
|
|
97
93
|
_ref$testId = _ref.testId,
|
|
98
94
|
testId = _ref$testId === void 0 ? 'inline-card-overlay' : _ref$testId,
|
|
99
|
-
url = _ref.url,
|
|
100
95
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
101
96
|
var _useState = (0, _react.useState)(false),
|
|
102
97
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -106,16 +101,13 @@ var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
|
|
|
106
101
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
107
102
|
availableWidth = _useState4[0],
|
|
108
103
|
setAvailableWidth = _useState4[1];
|
|
109
|
-
var maxOverlayWidth = (0, _react.useRef)(0);
|
|
110
|
-
var minOverlayWidth = (0, _react.useRef)(ESTIMATED_MIN_WIDTH_IN_PX);
|
|
111
|
-
var parentWidth = (0, _react.useRef)(0);
|
|
112
|
-
var iconSize = (0, _react.useRef)('small');
|
|
113
104
|
var containerRef = (0, _react.useRef)(null);
|
|
114
105
|
|
|
115
|
-
// TODO EDM-
|
|
106
|
+
// TODO EDM-9853: Use availableWidth for small link edge case
|
|
107
|
+
// Calculation logic will need to updated.
|
|
116
108
|
availableWidth;
|
|
117
109
|
var setVisibility = (0, _react.useCallback)(function () {
|
|
118
|
-
if (!containerRef.current
|
|
110
|
+
if (!containerRef.current) {
|
|
119
111
|
return;
|
|
120
112
|
}
|
|
121
113
|
var marker = (0, _utils2.getChildElement)(containerRef, ".".concat(OVERLAY_MARKER_CLASSNAME));
|
|
@@ -140,29 +132,9 @@ var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
|
|
|
140
132
|
}
|
|
141
133
|
}, [isSelected]);
|
|
142
134
|
(0, _react.useLayoutEffect)(function () {
|
|
143
|
-
// Using useLayoutEffect here.
|
|
144
|
-
// 1) We want all to be able to determine whether to display label before
|
|
145
|
-
// the overlay becomes visible.
|
|
146
|
-
// 2) We need to wait for the refs to be assigned to be able to do determine
|
|
147
|
-
// the width of the overlay.
|
|
148
135
|
if (!containerRef.current) {
|
|
149
136
|
return;
|
|
150
137
|
}
|
|
151
|
-
|
|
152
|
-
// This should run only once
|
|
153
|
-
if (!maxOverlayWidth.current) {
|
|
154
|
-
var iconAndLabel = (0, _utils2.getChildElement)(containerRef, ".".concat(ICON_AND_LABEL_CLASSNAME));
|
|
155
|
-
var _label = (0, _utils2.getChildElement)(containerRef, ".".concat(OVERLAY_LABEL_CLASSNAME));
|
|
156
|
-
if (iconAndLabel && _label) {
|
|
157
|
-
// Set overlay max (label + icon) and min (icon only) width.
|
|
158
|
-
var _getOverlayWidths = (0, _utils2.getOverlayWidths)(iconAndLabel, _label),
|
|
159
|
-
max = _getOverlayWidths.max,
|
|
160
|
-
min = _getOverlayWidths.min;
|
|
161
|
-
maxOverlayWidth.current = max;
|
|
162
|
-
minOverlayWidth.current = min;
|
|
163
|
-
iconSize.current = (0, _utils2.getIconSize)(_label);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
138
|
if (isVisible) {
|
|
167
139
|
setVisibility();
|
|
168
140
|
}
|
|
@@ -183,13 +155,6 @@ var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
|
|
|
183
155
|
if (!size) {
|
|
184
156
|
return;
|
|
185
157
|
}
|
|
186
|
-
if (!parentWidth.current) {
|
|
187
|
-
parentWidth.current = size;
|
|
188
|
-
}
|
|
189
|
-
if (parentWidth.current === size) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
parentWidth.current = size;
|
|
193
158
|
setVisibility();
|
|
194
159
|
}, DEBOUNCE_IN_MS);
|
|
195
160
|
var observer = new ResizeObserver(updateOverlay);
|
|
@@ -199,36 +164,30 @@ var NarrowInlineCardOverlay = function NarrowInlineCardOverlay(_ref) {
|
|
|
199
164
|
};
|
|
200
165
|
}, [isVisible, setVisibility]);
|
|
201
166
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
202
|
-
var
|
|
167
|
+
var configureLinkLabel = intl.formatMessage(_messages.cardMessages.inlineConfigureLink);
|
|
203
168
|
return (0, _react2.jsx)("span", (0, _extends2.default)({}, props, {
|
|
204
169
|
css: containerStyles,
|
|
205
170
|
ref: containerRef
|
|
206
|
-
}), isVisible && (0, _react2.jsx)(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
testId: "".concat(testId, "-icon")
|
|
228
|
-
})), (0, _react2.jsx)("span", {
|
|
229
|
-
css: labelStyles,
|
|
230
|
-
className: OVERLAY_LABEL_CLASSNAME,
|
|
231
|
-
"data-testid": "".concat(testId, "-label")
|
|
232
|
-
}))))), children);
|
|
171
|
+
}), isVisible && (0, _react2.jsx)(_tooltip.default, {
|
|
172
|
+
content: configureLinkLabel
|
|
173
|
+
}, function (tooltipProps) {
|
|
174
|
+
return (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("span", {
|
|
175
|
+
"aria-hidden": "true",
|
|
176
|
+
className: OVERLAY_MARKER_CLASSNAME
|
|
177
|
+
}, _utils.ZERO_WIDTH_JOINER), (0, _react2.jsx)("span", {
|
|
178
|
+
css: [overlayStyles, showOverlay && showOverlayStyles],
|
|
179
|
+
tabIndex: -1,
|
|
180
|
+
"data-testid": testId
|
|
181
|
+
}, (0, _react2.jsx)("span", (0, _extends2.default)({}, tooltipProps, {
|
|
182
|
+
css: iconAndLabelStyles,
|
|
183
|
+
className: ICON_AND_LABEL_CLASSNAME
|
|
184
|
+
}), (0, _react2.jsx)("span", {
|
|
185
|
+
css: iconStyles
|
|
186
|
+
}, (0, _react2.jsx)(_preferences.default, {
|
|
187
|
+
label: configureLinkLabel,
|
|
188
|
+
size: 'small',
|
|
189
|
+
testId: "".concat(testId, "-icon")
|
|
190
|
+
})))));
|
|
191
|
+
}), children);
|
|
233
192
|
};
|
|
234
|
-
var _default = exports.default =
|
|
193
|
+
var _default = exports.default = LeftIconOverlay;
|
|
@@ -314,9 +314,12 @@ var ResizableEmbedCard = exports.default = /*#__PURE__*/function (_React$Compone
|
|
|
314
314
|
return (0, _react2.jsx)("span", {
|
|
315
315
|
"data-testid": 'resizable-embed-card-height-definer',
|
|
316
316
|
style: _objectSpread({
|
|
317
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
317
318
|
display: 'block',
|
|
318
319
|
/* Fixes extra padding problem in Firefox */
|
|
320
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
319
321
|
fontSize: 0,
|
|
322
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
320
323
|
lineHeight: 0
|
|
321
324
|
}, heightDefiningStyles)
|
|
322
325
|
});
|
package/dist/cjs/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.titleUrlPairFromNode = exports.selectedCardAppearance = exports.mergeCardInfo = exports.isEmbedSupportedAtPosition = exports.isDatasourceNode = exports.isDatasourceConfigEditable = exports.isDatasourceAdfAttributes = exports.isBlockSupportedAtPosition = exports.getResolvedAttributesFromStore = exports.findCardInfo = exports.displayInfoForCard = exports.appearanceForNodeType = void 0;
|
|
7
|
+
exports.titleUrlPairFromNode = exports.selectedCardAppearance = exports.mergeCardInfo = exports.isEmbedSupportedAtPosition = exports.isEditDropdownEnabled = exports.isDatasourceNode = exports.isDatasourceConfigEditable = exports.isDatasourceAdfAttributes = exports.isBlockSupportedAtPosition = exports.getResolvedAttributesFromStore = exports.findCardInfo = exports.displayInfoForCard = exports.appearanceForNodeType = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -87,6 +87,9 @@ var isDatasourceConfigEditable = exports.isDatasourceConfigEditable = function i
|
|
|
87
87
|
}
|
|
88
88
|
return datasourcesWithConfigModal.includes(datasourceId);
|
|
89
89
|
};
|
|
90
|
+
var isEditDropdownEnabled = exports.isEditDropdownEnabled = function isEditDropdownEnabled(platform) {
|
|
91
|
+
return (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') && platform !== 'mobile';
|
|
92
|
+
};
|
|
90
93
|
|
|
91
94
|
/**
|
|
92
95
|
* Typeguard that checks node attributes are datasource node attributes
|
|
@@ -229,6 +229,7 @@ export class Datasource extends ReactNodeView {
|
|
|
229
229
|
url: attrs.url,
|
|
230
230
|
datasourceId: attrs === null || attrs === void 0 ? void 0 : (_attrs$datasource = attrs.datasource) === null || _attrs$datasource === void 0 ? void 0 : _attrs$datasource.id
|
|
231
231
|
}, jsx("div", {
|
|
232
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
232
233
|
className: DATASOURCE_INNER_CONTAINER_CLASSNAME,
|
|
233
234
|
style: {
|
|
234
235
|
minWidth: this.isNodeNested ? '100%' : calcBreakoutWidth(attrs.layout || DATASOURCE_DEFAULT_LAYOUT, this.tableWidth)
|
|
@@ -109,7 +109,10 @@ const InlineCard = ({
|
|
|
109
109
|
markMostRecentlyInsertedLink: markMostRecentlyInsertedLink,
|
|
110
110
|
pluginInjectionApi: pluginInjectionApi,
|
|
111
111
|
setOverlayHoveredStyles: setOverlayHoveredStyles
|
|
112
|
-
}, innerCard) :
|
|
112
|
+
}, innerCard) :
|
|
113
|
+
/*#__PURE__*/
|
|
114
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
115
|
+
React.createElement("span", {
|
|
113
116
|
className: "card"
|
|
114
117
|
}, innerCard);
|
|
115
118
|
}, [cardContext, getPos, innerCard, isHovered, isInserted, isOverlayEnabled, isPulseEnabled, isResolvedViewRendered, isSelected, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url]);
|
|
@@ -2,12 +2,12 @@ import isEqual from 'lodash/isEqual';
|
|
|
2
2
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, SMART_LINK_TYPE, unlinkPayload } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { addLinkMetadata } from '@atlaskit/editor-common/card';
|
|
5
|
-
import { getLinkCreationAnalyticsEvent, isFromCurrentDomain, nodesBetweenChanged, processRawValue } from '@atlaskit/editor-common/utils';
|
|
5
|
+
import { getDatasourceType, getLinkCreationAnalyticsEvent, isFromCurrentDomain, nodesBetweenChanged, processRawValue } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
7
7
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { appearanceForNodeType, isDatasourceConfigEditable, isDatasourceNode, selectedCardAppearance } from '../utils';
|
|
10
|
-
import { hideDatasourceModal, queueCards, removeDatasourceStash, resolveCard, setDatasourceStash } from './actions';
|
|
10
|
+
import { hideDatasourceModal, queueCards, removeDatasourceStash, resolveCard, setDatasourceStash, showDatasourceModal } from './actions';
|
|
11
11
|
import { pluginKey } from './plugin-key';
|
|
12
12
|
import { shouldReplaceLink } from './shouldReplaceLink';
|
|
13
13
|
/**
|
|
@@ -554,4 +554,24 @@ const updateDatasourceStash = (tr, selectedNode) => {
|
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
|
+
};
|
|
558
|
+
export const editDatasource = (datasourceId, _editorAnalyticsApi) => (state, dispatch) => {
|
|
559
|
+
const datasourceType = getDatasourceType(datasourceId);
|
|
560
|
+
if (dispatch && datasourceType) {
|
|
561
|
+
const {
|
|
562
|
+
tr
|
|
563
|
+
} = state;
|
|
564
|
+
showDatasourceModal(datasourceType)(tr);
|
|
565
|
+
// editorAnalyticsApi?.attachAnalyticsEvent(
|
|
566
|
+
// buildEditLinkPayload(
|
|
567
|
+
// type as
|
|
568
|
+
// | ACTION_SUBJECT_ID.CARD_INLINE
|
|
569
|
+
// | ACTION_SUBJECT_ID.CARD_BLOCK
|
|
570
|
+
// | ACTION_SUBJECT_ID.EMBEDS,
|
|
571
|
+
// ),
|
|
572
|
+
// )(tr);
|
|
573
|
+
dispatch(tr);
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
return false;
|
|
557
577
|
};
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -14,14 +14,15 @@ import CogIcon from '@atlaskit/icon/glyph/editor/settings';
|
|
|
14
14
|
import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
|
|
15
15
|
import OpenIcon from '@atlaskit/icon/glyph/shortcut';
|
|
16
16
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
17
|
-
import { changeSelectedCardToText } from './pm-plugins/doc';
|
|
17
|
+
import { changeSelectedCardToText, editDatasource } from './pm-plugins/doc';
|
|
18
18
|
import { pluginKey } from './pm-plugins/main';
|
|
19
19
|
import { DatasourceAppearanceButton } from './ui/DatasourceAppearanceButton';
|
|
20
|
-
import {
|
|
20
|
+
import { EditDatasourceButton } from './ui/EditDatasourceButton';
|
|
21
21
|
import { buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/EditLinkToolbar';
|
|
22
|
+
import { EditToolbarButton } from './ui/EditToolbarButton';
|
|
22
23
|
import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
|
|
23
24
|
import { ToolbarViewedEvent } from './ui/ToolbarViewedEvent';
|
|
24
|
-
import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, isDatasourceNode, titleUrlPairFromNode } from './utils';
|
|
25
|
+
import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, isDatasourceNode, isEditDropdownEnabled, titleUrlPairFromNode } from './utils';
|
|
25
26
|
export const removeCard = editorAnalyticsApi => commandWithMetadata((state, dispatch) => {
|
|
26
27
|
if (!(state.selection instanceof NodeSelection)) {
|
|
27
28
|
return false;
|
|
@@ -219,7 +220,18 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
219
220
|
const {
|
|
220
221
|
inlineCard
|
|
221
222
|
} = state.schema.nodes;
|
|
222
|
-
const toolbarItems = [{
|
|
223
|
+
const toolbarItems = [isEditDropdownEnabled(platform) && cardOptions.allowDatasource ? {
|
|
224
|
+
type: 'custom',
|
|
225
|
+
fallback: [],
|
|
226
|
+
render: editorView => /*#__PURE__*/React.createElement(EditToolbarButton, {
|
|
227
|
+
key: "edit-toolbar-item",
|
|
228
|
+
url: url,
|
|
229
|
+
intl: intl,
|
|
230
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
231
|
+
editorView: editorView,
|
|
232
|
+
onLinkEditClick: editLink(editorAnalyticsApi)
|
|
233
|
+
})
|
|
234
|
+
} : {
|
|
223
235
|
id: 'editor.link.edit',
|
|
224
236
|
type: 'button',
|
|
225
237
|
selected: false,
|
|
@@ -318,7 +330,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
318
330
|
type: 'separator'
|
|
319
331
|
});
|
|
320
332
|
}
|
|
321
|
-
const shouldShowDatasourceEditButton = platform !== 'mobile' && allowDatasource;
|
|
333
|
+
const shouldShowDatasourceEditButton = platform !== 'mobile' && allowDatasource && !getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar');
|
|
322
334
|
if (shouldShowDatasourceEditButton) {
|
|
323
335
|
toolbarItems.unshift({
|
|
324
336
|
type: 'custom',
|
|
@@ -375,7 +387,7 @@ export const getSettingsButtonGroup = (intl, editorAnalyticsApi, userPreferences
|
|
|
375
387
|
const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform, cardActions) => {
|
|
376
388
|
var _node$attrs3;
|
|
377
389
|
const toolbarItems = [];
|
|
378
|
-
if (isDatasourceConfigEditable(datasourceId)) {
|
|
390
|
+
if (isDatasourceConfigEditable(datasourceId) && !getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
|
|
379
391
|
toolbarItems.push({
|
|
380
392
|
id: 'editor.edit.datasource',
|
|
381
393
|
type: 'button',
|
|
@@ -389,6 +401,20 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
389
401
|
type: 'separator'
|
|
390
402
|
});
|
|
391
403
|
}
|
|
404
|
+
const editDropdownWithSeparator = [{
|
|
405
|
+
type: 'custom',
|
|
406
|
+
fallback: [],
|
|
407
|
+
render: editorView => /*#__PURE__*/React.createElement(EditToolbarButton, {
|
|
408
|
+
key: "edit-toolbar-item",
|
|
409
|
+
url: metadata.url,
|
|
410
|
+
intl: intl,
|
|
411
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
412
|
+
editorView: editorView,
|
|
413
|
+
onLinkEditClick: editLink(editorAnalyticsApi)
|
|
414
|
+
})
|
|
415
|
+
}, {
|
|
416
|
+
type: 'separator'
|
|
417
|
+
}];
|
|
392
418
|
const canShowMainToolbar = () => {
|
|
393
419
|
// we do not show smart-link or the datasource icons when the node does not have a url to resolve
|
|
394
420
|
if (!metadata.url) {
|
|
@@ -446,7 +472,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
446
472
|
})
|
|
447
473
|
}, {
|
|
448
474
|
type: 'separator'
|
|
449
|
-
});
|
|
475
|
+
}, ...(getBooleanFF('platform.linking-platform.enable-datasource-edit-dropdown-toolbar') ? [...editDropdownWithSeparator] : []));
|
|
450
476
|
}
|
|
451
477
|
if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
|
|
452
478
|
toolbarItems.push({
|
|
@@ -7,7 +7,7 @@ import useLinkUpgradeDiscoverability from '../../common/hooks/useLinkUpgradeDisc
|
|
|
7
7
|
import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../../common/local-storage';
|
|
8
8
|
import { getResolvedAttributesFromStore } from '../../utils';
|
|
9
9
|
import InlineCardOverlay from '../InlineCardOverlay';
|
|
10
|
-
import
|
|
10
|
+
import LeftIconOverlay from '../LeftIconOverlay';
|
|
11
11
|
import { DiscoveryPulse } from '../Pulse';
|
|
12
12
|
// editor adds a standard line-height that is bigger than an inline smart link
|
|
13
13
|
// due to that the link has a bit of white space around it, which doesn't look right when there is pulse around it
|
|
@@ -71,12 +71,11 @@ export const AwarenessWrapper = ({
|
|
|
71
71
|
const cardWithOverlay = useMemo(() => {
|
|
72
72
|
if (shouldShowLinkOverlay) {
|
|
73
73
|
if (getBooleanFF('platform.linking-platform.smart-links-in-live-pages')) {
|
|
74
|
-
return jsx(
|
|
74
|
+
return jsx(LeftIconOverlay, {
|
|
75
75
|
isSelected: isSelected,
|
|
76
76
|
isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
|
|
77
77
|
onMouseEnter: () => handleOverlayChange(true),
|
|
78
|
-
onMouseLeave: () => handleOverlayChange(false)
|
|
79
|
-
url: url
|
|
78
|
+
onMouseLeave: () => handleOverlayChange(false)
|
|
80
79
|
}, children);
|
|
81
80
|
}
|
|
82
81
|
return jsx(InlineCardOverlay, {
|
|
@@ -91,19 +90,22 @@ export const AwarenessWrapper = ({
|
|
|
91
90
|
}, [shouldShowLinkOverlay, isSelected, isResolvedViewRendered, isInserted, isHovered, url, children, handleOverlayChange]);
|
|
92
91
|
return useMemo(() => {
|
|
93
92
|
var _cardContext$value;
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
return (
|
|
94
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
95
|
+
jsx("span", {
|
|
96
|
+
css: shouldShowLinkPulse && loaderWrapperStyles,
|
|
97
|
+
className: "card"
|
|
98
|
+
}, jsx(AnalyticsContext, {
|
|
99
|
+
data: {
|
|
100
|
+
attributes: getResolvedAttributesFromStore(url, 'inline', cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store)
|
|
101
|
+
}
|
|
102
|
+
}, jsx(DiscoveryPulse, {
|
|
103
|
+
localStorageKey: LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK,
|
|
104
|
+
localStorageKeyExpirationInMs: ONE_DAY_IN_MILLISECONDS,
|
|
105
|
+
discoveryMode: "start",
|
|
106
|
+
shouldShowPulse: isResolvedViewRendered && shouldShowLinkPulse,
|
|
107
|
+
testId: "link-discovery-pulse"
|
|
108
|
+
}, cardWithOverlay)))
|
|
109
|
+
);
|
|
108
110
|
}, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, isResolvedViewRendered, cardWithOverlay]);
|
|
109
111
|
};
|
|
@@ -24,7 +24,7 @@ export const DatasourceModal = ({
|
|
|
24
24
|
const onClose = useCallback(() => {
|
|
25
25
|
dispatch(hideDatasourceModal(transaction));
|
|
26
26
|
}, [dispatch, transaction]);
|
|
27
|
-
const
|
|
27
|
+
const updateAdf = useUpdateAdf(view, existingNode);
|
|
28
28
|
const isRegularCardNode = !!(existingNode && !(existingNode !== null && existingNode !== void 0 && (_existingNode$attrs = existingNode.attrs) !== null && _existingNode$attrs !== void 0 && _existingNode$attrs.datasource));
|
|
29
29
|
const {
|
|
30
30
|
id: datasourceId = defaultDatasourceId,
|
|
@@ -58,10 +58,10 @@ export const DatasourceModal = ({
|
|
|
58
58
|
columnCustomSizes: columnCustomSizes,
|
|
59
59
|
wrappedColumnKeys: wrappedColumnKeys,
|
|
60
60
|
onCancel: onClose,
|
|
61
|
-
onInsert:
|
|
61
|
+
onInsert: updateAdf
|
|
62
62
|
});
|
|
63
63
|
};
|
|
64
|
-
const
|
|
64
|
+
const useUpdateAdf = (view, existingNode) => {
|
|
65
65
|
return useCallback((newAdf, analyticEvent) => {
|
|
66
66
|
if (analyticEvent) {
|
|
67
67
|
analyticEvent.update(payload => ({
|
|
@@ -111,10 +111,9 @@ const resolveColumnsConfig = views => {
|
|
|
111
111
|
const [tableView] = views;
|
|
112
112
|
const visibleColumnKeys = [];
|
|
113
113
|
const wrappedColumnKeys = [];
|
|
114
|
-
|
|
114
|
+
const columnCustomSizes = {};
|
|
115
115
|
const columns = tableView === null || tableView === void 0 ? void 0 : (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns;
|
|
116
116
|
if (columns) {
|
|
117
|
-
columnCustomSizes = {};
|
|
118
117
|
for (const {
|
|
119
118
|
key,
|
|
120
119
|
width,
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
import { css, jsx } from '@emotion/react';
|
|
3
3
|
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator, SmallerEditIcon } from '@atlaskit/editor-common/ui';
|
|
5
|
-
import { getDatasourceType } from '@atlaskit/editor-common/utils';
|
|
6
5
|
import { Flex } from '@atlaskit/primitives';
|
|
7
|
-
import {
|
|
6
|
+
import { editDatasource } from '../pm-plugins/doc';
|
|
8
7
|
import { isDatasourceConfigEditable } from '../utils';
|
|
9
8
|
import { CardContextProvider } from './CardContextProvider';
|
|
10
9
|
import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
|
|
@@ -71,24 +70,4 @@ export const EditDatasourceButton = ({
|
|
|
71
70
|
editorState: editorState,
|
|
72
71
|
cardContext: cardContext
|
|
73
72
|
}));
|
|
74
|
-
};
|
|
75
|
-
export const editDatasource = (datasourceId, editorAnalyticsApi) => (state, dispatch) => {
|
|
76
|
-
const datasourceType = getDatasourceType(datasourceId);
|
|
77
|
-
if (dispatch && datasourceType) {
|
|
78
|
-
const {
|
|
79
|
-
tr
|
|
80
|
-
} = state;
|
|
81
|
-
showDatasourceModal(datasourceType)(tr);
|
|
82
|
-
// editorAnalyticsApi?.attachAnalyticsEvent(
|
|
83
|
-
// buildEditLinkPayload(
|
|
84
|
-
// type as
|
|
85
|
-
// | ACTION_SUBJECT_ID.CARD_INLINE
|
|
86
|
-
// | ACTION_SUBJECT_ID.CARD_BLOCK
|
|
87
|
-
// | ACTION_SUBJECT_ID.EMBEDS,
|
|
88
|
-
// ),
|
|
89
|
-
// )(tr);
|
|
90
|
-
dispatch(tr);
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
return false;
|
|
94
73
|
};
|