@atlaskit/editor-plugin-card 0.8.0 → 0.8.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 (27) hide show
  1. package/.eslintrc.js +12 -0
  2. package/CHANGELOG.md +15 -0
  3. package/dist/cjs/analytics/events-from-tr.js +22 -7
  4. package/dist/cjs/datasourceErrorBoundary.js +6 -3
  5. package/dist/cjs/pm-plugins/doc.js +2 -1
  6. package/dist/cjs/ui/EditorLinkingPlatformAnalytics/DatasourceEvents.js +1 -3
  7. package/dist/cjs/ui/EditorLinkingPlatformAnalytics/common.js +4 -0
  8. package/dist/cjs/ui/LayoutButton/index.js +1 -4
  9. package/dist/es2019/analytics/events-from-tr.js +19 -8
  10. package/dist/es2019/datasourceErrorBoundary.js +6 -3
  11. package/dist/es2019/pm-plugins/doc.js +2 -1
  12. package/dist/es2019/ui/EditorLinkingPlatformAnalytics/DatasourceEvents.js +1 -3
  13. package/dist/es2019/ui/EditorLinkingPlatformAnalytics/common.js +4 -0
  14. package/dist/es2019/ui/LayoutButton/index.js +1 -1
  15. package/dist/esm/analytics/events-from-tr.js +23 -8
  16. package/dist/esm/datasourceErrorBoundary.js +6 -3
  17. package/dist/esm/pm-plugins/doc.js +2 -1
  18. package/dist/esm/ui/EditorLinkingPlatformAnalytics/DatasourceEvents.js +1 -3
  19. package/dist/esm/ui/EditorLinkingPlatformAnalytics/common.js +4 -0
  20. package/dist/esm/ui/LayoutButton/index.js +1 -1
  21. package/dist/types/datasourceErrorBoundary.d.ts +2 -2
  22. package/dist/types/ui/EditorLinkingPlatformAnalytics/common.d.ts +3 -3
  23. package/dist/types/ui/LayoutButton/index.d.ts +7 -7
  24. package/dist/types-ts4.5/datasourceErrorBoundary.d.ts +2 -2
  25. package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/common.d.ts +3 -3
  26. package/dist/types-ts4.5/ui/LayoutButton/index.d.ts +7 -7
  27. package/package.json +5 -5
package/.eslintrc.js CHANGED
@@ -2,6 +2,18 @@ module.exports = {
2
2
  rules: {
3
3
  '@typescript-eslint/no-duplicate-imports': 'error',
4
4
  '@typescript-eslint/no-explicit-any': 'error',
5
+ '@typescript-eslint/ban-types': [
6
+ 'error',
7
+ {
8
+ types: {
9
+ 'React.FC':
10
+ 'Please use types directly on props instead, and explicitly define children if required',
11
+ 'React.FunctionalComponent':
12
+ 'Please use types directly on props instead, and explicitly define children if required',
13
+ },
14
+ extendDefaults: false,
15
+ },
16
+ ],
5
17
  },
6
18
  overrides: [
7
19
  {
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 0.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4e7058a65f4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4e7058a65f4) - Add eslint rule to ban React.FC and React.FunctionalComponent in editor. In most packages this is still a warning.
8
+ - [`08c899663fa`](https://bitbucket.org/atlassian/atlassian-frontend/commits/08c899663fa) - Add datasource failed analytic events to datasourceErrorBoundary
9
+ - Updated dependencies
10
+
11
+ ## 0.8.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [`ae7c1132c88`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ae7c1132c88) - Added analytics fix for undo/redo scenarious of link upgrade to a datasource
16
+ - [`553b34b5fd4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/553b34b5fd4) - Small analytics bug fixes relating to auto-linking on enter, legacy link picker, and unresolvable links.
17
+
3
18
  ## 0.8.0
4
19
 
5
20
  ### Minor Changes
@@ -143,7 +143,7 @@ var findChanged = function findChanged(tr, state) {
143
143
 
144
144
  /**
145
145
  * If there is no identifiable input method, and the links inserted and removed appear to be the same,
146
- * then this transaction likely is not intended to be consided to be the insertion and removal of links
146
+ * then this transaction likely is not intended to be considered to be the insertion and removal of links
147
147
  */
148
148
  if (!inputMethod && (0, _utils2.areSameNodes)(removed, inserted)) {
149
149
  return {
@@ -158,6 +158,8 @@ var findChanged = function findChanged(tr, state) {
158
158
  updated: updated
159
159
  };
160
160
  }
161
+ var updateInserted = [];
162
+ var updateRemoved = [];
161
163
  for (var _i = 0; _i < inserted.length; _i++) {
162
164
  if (isResolveReplace) {
163
165
  var newLink = inserted[_i];
@@ -174,15 +176,22 @@ var findChanged = function findChanged(tr, state) {
174
176
  continue;
175
177
  }
176
178
  if (inserted.length === removed.length) {
177
- updated.push({
178
- removed: removed[_i],
179
- inserted: inserted[_i]
180
- });
179
+ var previousSubject = (0, _utils2.getNodeSubject)(removed[_i].node);
180
+ var currentSubject = (0, _utils2.getNodeSubject)(inserted[_i].node);
181
+ if (isDatasourceUpgrade(previousSubject, currentSubject) || isDatasourceDowngrade(previousSubject, currentSubject)) {
182
+ updateInserted.push(inserted[_i]);
183
+ updateRemoved.push(removed[_i]);
184
+ } else {
185
+ updated.push({
186
+ removed: removed[_i],
187
+ inserted: inserted[_i]
188
+ });
189
+ }
181
190
  }
182
191
  }
183
192
  return {
184
- inserted: [],
185
- removed: [],
193
+ inserted: updateInserted,
194
+ removed: updateRemoved,
186
195
  updated: updated
187
196
  };
188
197
  };
@@ -274,6 +283,12 @@ var getResolveLinkPrevDisplay = function getResolveLinkPrevDisplay(state, pos) {
274
283
  return request.pos === pos;
275
284
  })) === null || _cardState$requests$f === void 0 ? void 0 : _cardState$requests$f.previousAppearance;
276
285
  };
286
+ var isDatasourceDowngrade = function isDatasourceDowngrade(previousSubject, currentSubject) {
287
+ return previousSubject === _types.EVENT_SUBJECT.DATASOURCE && currentSubject === _types.EVENT_SUBJECT.LINK;
288
+ };
289
+ var isDatasourceUpgrade = function isDatasourceUpgrade(previousSubject, currentSubject) {
290
+ return previousSubject === _types.EVENT_SUBJECT.LINK && currentSubject === _types.EVENT_SUBJECT.DATASOURCE;
291
+ };
277
292
  function eventsFromTransaction(tr, state) {
278
293
  var events = [];
279
294
  try {
@@ -14,6 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
14
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
15
  var _react = _interopRequireDefault(require("react"));
16
16
  var _adfSchema = require("@atlaskit/adf-schema");
17
+ var _linkDatasource = require("@atlaskit/link-datasource");
17
18
  var _doc = require("./pm-plugins/doc");
18
19
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
19
20
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /* eslint-disable @repo/internal/react/no-class-components */
@@ -52,11 +53,13 @@ var DatasourceErrorBoundary = /*#__PURE__*/function (_React$Component) {
52
53
  view = _this$props.view;
53
54
  if (this.state.isError) {
54
55
  if (url && (0, _adfSchema.isSafeUrl)(url)) {
55
- return (0, _doc.setSelectedCardAppearance)('inline', undefined)(view.state, view.dispatch);
56
+ return /*#__PURE__*/_react.default.createElement(_linkDatasource.DatasourceRenderFailedAnalyticsWrapper, null, (0, _doc.setSelectedCardAppearance)('inline', undefined)(view.state, view.dispatch));
57
+ } else {
58
+ return /*#__PURE__*/_react.default.createElement(_linkDatasource.DatasourceRenderFailedAnalyticsWrapper, null, /*#__PURE__*/_react.default.createElement(UnsupportedComponent, null));
56
59
  }
57
- return /*#__PURE__*/_react.default.createElement(UnsupportedComponent, null);
60
+ } else {
61
+ return this.props.children;
58
62
  }
59
- return this.props.children;
60
63
  }
61
64
  }], [{
62
65
  key: "getDerivedStateFromError",
@@ -140,7 +140,8 @@ var handleFallbackWithAnalytics = function handleFallbackWithAnalytics(request,
140
140
  }
141
141
  (0, _card.addLinkMetadata)(state.selection, tr, {
142
142
  action: request.analyticsAction,
143
- inputMethod: request.source
143
+ inputMethod: request.source,
144
+ sourceEvent: request.sourceEvent
144
145
  });
145
146
  if (dispatch) {
146
147
  dispatch((0, _actions.resolveCard)(request.url)(tr));
@@ -45,9 +45,7 @@ function getAnalyticAttributesFromNode(datasourceAttrs, metadata) {
45
45
  var actions = [];
46
46
  if (metadata.inputMethod) {
47
47
  var _getMethod;
48
- inputMethod = (_getMethod = (0, _common.getMethod)({
49
- inputMethod: metadata.inputMethod
50
- })) !== null && _getMethod !== void 0 ? _getMethod : '';
48
+ inputMethod = (_getMethod = (0, _common.getMethod)(metadata)) !== null && _getMethod !== void 0 ? _getMethod : '';
51
49
  } else if (metadata.sourceEvent instanceof _analyticsNext.UIAnalyticsEvent) {
52
50
  var _metadata$sourceEvent, _metadata$sourceEvent2;
53
51
  inputMethod = (_metadata$sourceEvent = metadata.sourceEvent.payload.attributes) === null || _metadata$sourceEvent === void 0 ? void 0 : _metadata$sourceEvent.inputMethod;
@@ -34,6 +34,10 @@ var getMethod = withHistoryMethod(function (_ref) {
34
34
  case _analytics.INPUT_METHOD.AUTO_DETECT:
35
35
  case _analytics.INPUT_METHOD.FORMATTING:
36
36
  return 'editor_type';
37
+ case _analytics.INPUT_METHOD.TYPEAHEAD:
38
+ return 'linkpicker_searchResult';
39
+ case _analytics.INPUT_METHOD.MANUAL:
40
+ return 'linkpicker_manual';
37
41
  default:
38
42
  return 'unknown';
39
43
  }
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = exports.LayoutButton = void 0;
9
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _react = _interopRequireWildcard(require("react"));
9
+ var _react = require("react");
11
10
  var _react2 = require("@emotion/react");
12
11
  var _reactIntlNext = require("react-intl-next");
13
12
  var _hooks = require("@atlaskit/editor-common/hooks");
@@ -19,8 +18,6 @@ var _expand = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/expand
19
18
  var _colors = require("@atlaskit/theme/colors");
20
19
  var _actions = require("../../pm-plugins/actions");
21
20
  var _utils2 = require("./utils");
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
21
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25
22
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** @jsx jsx */
26
23
  var toolbarButtonWrapperStyles = (0, _react2.css)({
@@ -5,7 +5,7 @@ import { isLinkMark, pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
5
5
  import { AddMarkStep, RemoveMarkStep } from '@atlaskit/editor-prosemirror/transform';
6
6
  import { pluginKey } from '../pm-plugins/plugin-key';
7
7
  import { getPluginState } from '../pm-plugins/util/state';
8
- import { EVENT } from './types';
8
+ import { EVENT, EVENT_SUBJECT } from './types';
9
9
  import { appearanceForLink, areSameNodes, findAtPositions, findInNodeRange, getNodeContext, getNodeSubject } from './utils';
10
10
 
11
11
  /**
@@ -126,7 +126,7 @@ export const findChanged = (tr, state) => {
126
126
 
127
127
  /**
128
128
  * If there is no identifiable input method, and the links inserted and removed appear to be the same,
129
- * then this transaction likely is not intended to be consided to be the insertion and removal of links
129
+ * then this transaction likely is not intended to be considered to be the insertion and removal of links
130
130
  */
131
131
  if (!inputMethod && areSameNodes(removed, inserted)) {
132
132
  return {
@@ -141,6 +141,8 @@ export const findChanged = (tr, state) => {
141
141
  updated
142
142
  };
143
143
  }
144
+ const updateInserted = [];
145
+ const updateRemoved = [];
144
146
  for (let i = 0; i < inserted.length; i++) {
145
147
  if (isResolveReplace) {
146
148
  const newLink = inserted[i];
@@ -157,15 +159,22 @@ export const findChanged = (tr, state) => {
157
159
  continue;
158
160
  }
159
161
  if (inserted.length === removed.length) {
160
- updated.push({
161
- removed: removed[i],
162
- inserted: inserted[i]
163
- });
162
+ const previousSubject = getNodeSubject(removed[i].node);
163
+ const currentSubject = getNodeSubject(inserted[i].node);
164
+ if (isDatasourceUpgrade(previousSubject, currentSubject) || isDatasourceDowngrade(previousSubject, currentSubject)) {
165
+ updateInserted.push(inserted[i]);
166
+ updateRemoved.push(removed[i]);
167
+ } else {
168
+ updated.push({
169
+ removed: removed[i],
170
+ inserted: inserted[i]
171
+ });
172
+ }
164
173
  }
165
174
  }
166
175
  return {
167
- inserted: [],
168
- removed: [],
176
+ inserted: updateInserted,
177
+ removed: updateRemoved,
169
178
  updated
170
179
  };
171
180
  };
@@ -250,6 +259,8 @@ const getResolveLinkPrevDisplay = (state, pos) => {
250
259
  }
251
260
  return (_cardState$requests$f = cardState.requests.find(request => request.pos === pos)) === null || _cardState$requests$f === void 0 ? void 0 : _cardState$requests$f.previousAppearance;
252
261
  };
262
+ const isDatasourceDowngrade = (previousSubject, currentSubject) => previousSubject === EVENT_SUBJECT.DATASOURCE && currentSubject === EVENT_SUBJECT.LINK;
263
+ const isDatasourceUpgrade = (previousSubject, currentSubject) => previousSubject === EVENT_SUBJECT.LINK && currentSubject === EVENT_SUBJECT.DATASOURCE;
253
264
  export function eventsFromTransaction(tr, state) {
254
265
  const events = [];
255
266
  try {
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  /* eslint-disable @repo/internal/react/no-class-components */
3
3
  import React from 'react';
4
4
  import { isSafeUrl } from '@atlaskit/adf-schema';
5
+ import { DatasourceRenderFailedAnalyticsWrapper } from '@atlaskit/link-datasource';
5
6
  import { setSelectedCardAppearance } from './pm-plugins/doc';
6
7
  export class DatasourceErrorBoundary extends React.Component {
7
8
  constructor(...args) {
@@ -32,10 +33,12 @@ export class DatasourceErrorBoundary extends React.Component {
32
33
  } = this.props;
33
34
  if (this.state.isError) {
34
35
  if (url && isSafeUrl(url)) {
35
- return setSelectedCardAppearance('inline', undefined)(view.state, view.dispatch);
36
+ return /*#__PURE__*/React.createElement(DatasourceRenderFailedAnalyticsWrapper, null, setSelectedCardAppearance('inline', undefined)(view.state, view.dispatch));
37
+ } else {
38
+ return /*#__PURE__*/React.createElement(DatasourceRenderFailedAnalyticsWrapper, null, /*#__PURE__*/React.createElement(UnsupportedComponent, null));
36
39
  }
37
- return /*#__PURE__*/React.createElement(UnsupportedComponent, null);
40
+ } else {
41
+ return this.props.children;
38
42
  }
39
- return this.props.children;
40
43
  }
41
44
  }
@@ -119,7 +119,8 @@ export const handleFallbackWithAnalytics = (request, editorAnalyticsApi) => (sta
119
119
  }
120
120
  addLinkMetadata(state.selection, tr, {
121
121
  action: request.analyticsAction,
122
- inputMethod: request.source
122
+ inputMethod: request.source,
123
+ sourceEvent: request.sourceEvent
123
124
  });
124
125
  if (dispatch) {
125
126
  dispatch(resolveCard(request.url)(tr));
@@ -38,9 +38,7 @@ function getAnalyticAttributesFromNode(datasourceAttrs, metadata) {
38
38
  let actions = [];
39
39
  if (metadata.inputMethod) {
40
40
  var _getMethod;
41
- inputMethod = (_getMethod = getMethod({
42
- inputMethod: metadata.inputMethod
43
- })) !== null && _getMethod !== void 0 ? _getMethod : '';
41
+ inputMethod = (_getMethod = getMethod(metadata)) !== null && _getMethod !== void 0 ? _getMethod : '';
44
42
  } else if (metadata.sourceEvent instanceof UIAnalyticsEvent) {
45
43
  var _metadata$sourceEvent, _metadata$sourceEvent2;
46
44
  inputMethod = (_metadata$sourceEvent = metadata.sourceEvent.payload.attributes) === null || _metadata$sourceEvent === void 0 ? void 0 : _metadata$sourceEvent.inputMethod;
@@ -31,6 +31,10 @@ export const getMethod = withHistoryMethod(({
31
31
  case INPUT_METHOD.AUTO_DETECT:
32
32
  case INPUT_METHOD.FORMATTING:
33
33
  return 'editor_type';
34
+ case INPUT_METHOD.TYPEAHEAD:
35
+ return 'linkpicker_searchResult';
36
+ case INPUT_METHOD.MANUAL:
37
+ return 'linkpicker_manual';
34
38
  default:
35
39
  return 'unknown';
36
40
  }
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import React, { useCallback, useMemo } from 'react';
2
+ import { useCallback, useMemo } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import { injectIntl } from 'react-intl-next';
5
5
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
@@ -7,7 +7,7 @@ import { isLinkMark, pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
7
7
  import { AddMarkStep, RemoveMarkStep } from '@atlaskit/editor-prosemirror/transform';
8
8
  import { pluginKey } from '../pm-plugins/plugin-key';
9
9
  import { getPluginState } from '../pm-plugins/util/state';
10
- import { EVENT } from './types';
10
+ import { EVENT, EVENT_SUBJECT } from './types';
11
11
  import { appearanceForLink, areSameNodes, findAtPositions, findInNodeRange, getNodeContext, getNodeSubject } from './utils';
12
12
 
13
13
  /**
@@ -136,7 +136,7 @@ export var findChanged = function findChanged(tr, state) {
136
136
 
137
137
  /**
138
138
  * If there is no identifiable input method, and the links inserted and removed appear to be the same,
139
- * then this transaction likely is not intended to be consided to be the insertion and removal of links
139
+ * then this transaction likely is not intended to be considered to be the insertion and removal of links
140
140
  */
141
141
  if (!inputMethod && areSameNodes(removed, inserted)) {
142
142
  return {
@@ -151,6 +151,8 @@ export var findChanged = function findChanged(tr, state) {
151
151
  updated: updated
152
152
  };
153
153
  }
154
+ var updateInserted = [];
155
+ var updateRemoved = [];
154
156
  for (var _i = 0; _i < inserted.length; _i++) {
155
157
  if (isResolveReplace) {
156
158
  var newLink = inserted[_i];
@@ -167,15 +169,22 @@ export var findChanged = function findChanged(tr, state) {
167
169
  continue;
168
170
  }
169
171
  if (inserted.length === removed.length) {
170
- updated.push({
171
- removed: removed[_i],
172
- inserted: inserted[_i]
173
- });
172
+ var previousSubject = getNodeSubject(removed[_i].node);
173
+ var currentSubject = getNodeSubject(inserted[_i].node);
174
+ if (isDatasourceUpgrade(previousSubject, currentSubject) || isDatasourceDowngrade(previousSubject, currentSubject)) {
175
+ updateInserted.push(inserted[_i]);
176
+ updateRemoved.push(removed[_i]);
177
+ } else {
178
+ updated.push({
179
+ removed: removed[_i],
180
+ inserted: inserted[_i]
181
+ });
182
+ }
174
183
  }
175
184
  }
176
185
  return {
177
- inserted: [],
178
- removed: [],
186
+ inserted: updateInserted,
187
+ removed: updateRemoved,
179
188
  updated: updated
180
189
  };
181
190
  };
@@ -266,6 +275,12 @@ var getResolveLinkPrevDisplay = function getResolveLinkPrevDisplay(state, pos) {
266
275
  return request.pos === pos;
267
276
  })) === null || _cardState$requests$f === void 0 ? void 0 : _cardState$requests$f.previousAppearance;
268
277
  };
278
+ var isDatasourceDowngrade = function isDatasourceDowngrade(previousSubject, currentSubject) {
279
+ return previousSubject === EVENT_SUBJECT.DATASOURCE && currentSubject === EVENT_SUBJECT.LINK;
280
+ };
281
+ var isDatasourceUpgrade = function isDatasourceUpgrade(previousSubject, currentSubject) {
282
+ return previousSubject === EVENT_SUBJECT.LINK && currentSubject === EVENT_SUBJECT.DATASOURCE;
283
+ };
269
284
  export function eventsFromTransaction(tr, state) {
270
285
  var events = [];
271
286
  try {
@@ -10,6 +10,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
10
10
  /* eslint-disable @repo/internal/react/no-class-components */
11
11
  import React from 'react';
12
12
  import { isSafeUrl } from '@atlaskit/adf-schema';
13
+ import { DatasourceRenderFailedAnalyticsWrapper } from '@atlaskit/link-datasource';
13
14
  import { setSelectedCardAppearance } from './pm-plugins/doc';
14
15
  export var DatasourceErrorBoundary = /*#__PURE__*/function (_React$Component) {
15
16
  _inherits(DatasourceErrorBoundary, _React$Component);
@@ -46,11 +47,13 @@ export var DatasourceErrorBoundary = /*#__PURE__*/function (_React$Component) {
46
47
  view = _this$props.view;
47
48
  if (this.state.isError) {
48
49
  if (url && isSafeUrl(url)) {
49
- return setSelectedCardAppearance('inline', undefined)(view.state, view.dispatch);
50
+ return /*#__PURE__*/React.createElement(DatasourceRenderFailedAnalyticsWrapper, null, setSelectedCardAppearance('inline', undefined)(view.state, view.dispatch));
51
+ } else {
52
+ return /*#__PURE__*/React.createElement(DatasourceRenderFailedAnalyticsWrapper, null, /*#__PURE__*/React.createElement(UnsupportedComponent, null));
50
53
  }
51
- return /*#__PURE__*/React.createElement(UnsupportedComponent, null);
54
+ } else {
55
+ return this.props.children;
52
56
  }
53
- return this.props.children;
54
57
  }
55
58
  }], [{
56
59
  key: "getDerivedStateFromError",
@@ -132,7 +132,8 @@ export var handleFallbackWithAnalytics = function handleFallbackWithAnalytics(re
132
132
  }
133
133
  addLinkMetadata(state.selection, tr, {
134
134
  action: request.analyticsAction,
135
- inputMethod: request.source
135
+ inputMethod: request.source,
136
+ sourceEvent: request.sourceEvent
136
137
  });
137
138
  if (dispatch) {
138
139
  dispatch(resolveCard(request.url)(tr));
@@ -38,9 +38,7 @@ function getAnalyticAttributesFromNode(datasourceAttrs, metadata) {
38
38
  var actions = [];
39
39
  if (metadata.inputMethod) {
40
40
  var _getMethod;
41
- inputMethod = (_getMethod = getMethod({
42
- inputMethod: metadata.inputMethod
43
- })) !== null && _getMethod !== void 0 ? _getMethod : '';
41
+ inputMethod = (_getMethod = getMethod(metadata)) !== null && _getMethod !== void 0 ? _getMethod : '';
44
42
  } else if (metadata.sourceEvent instanceof UIAnalyticsEvent) {
45
43
  var _metadata$sourceEvent, _metadata$sourceEvent2;
46
44
  inputMethod = (_metadata$sourceEvent = metadata.sourceEvent.payload.attributes) === null || _metadata$sourceEvent === void 0 ? void 0 : _metadata$sourceEvent.inputMethod;
@@ -28,6 +28,10 @@ export var getMethod = withHistoryMethod(function (_ref) {
28
28
  case INPUT_METHOD.AUTO_DETECT:
29
29
  case INPUT_METHOD.FORMATTING:
30
30
  return 'editor_type';
31
+ case INPUT_METHOD.TYPEAHEAD:
32
+ return 'linkpicker_searchResult';
33
+ case INPUT_METHOD.MANUAL:
34
+ return 'linkpicker_manual';
31
35
  default:
32
36
  return 'unknown';
33
37
  }
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  /** @jsx jsx */
5
- import React, { useCallback, useMemo } from 'react';
5
+ import { useCallback, useMemo } from 'react';
6
6
  import { css, jsx } from '@emotion/react';
7
7
  import { injectIntl } from 'react-intl-next';
8
8
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { APIError } from '@atlaskit/smart-card';
3
- import { DatasourceProps } from './nodeviews/datasource';
2
+ import type { APIError } from '@atlaskit/smart-card';
3
+ import type { DatasourceProps } from './nodeviews/datasource';
4
4
  export declare class DatasourceErrorBoundary extends React.Component<{
5
5
  url?: string;
6
6
  unsupportedComponent: React.ComponentType;
@@ -1,7 +1,7 @@
1
1
  import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
2
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
3
- import { EditorCardPluginEvents } from '../../analytics/create-events-queue';
4
- import { CardPluginEvent } from '../../analytics/types';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { EditorCardPluginEvents } from '../../analytics/create-events-queue';
4
+ import type { CardPluginEvent } from '../../analytics/types';
5
5
  export type AnalyticsBindingsProps = {
6
6
  editorView: EditorView;
7
7
  cardPluginEvents: EditorCardPluginEvents<CardPluginEvent>;
@@ -1,9 +1,9 @@
1
- /** @jsx jsx */
2
- import React from 'react';
3
- import { WrappedComponentProps } from 'react-intl-next';
4
- import { LayoutButtonProps, LayoutButtonWrapperProps } from './types';
5
- export declare const LayoutButton: React.FC<LayoutButtonProps>;
6
- declare const _default: React.FC<import("react-intl-next").WithIntlProps<LayoutButtonWrapperProps & WrappedComponentProps<"intl">>> & {
7
- WrappedComponent: React.ComponentType<LayoutButtonWrapperProps & WrappedComponentProps<"intl">>;
1
+ /// <reference types="react" />
2
+ import { jsx } from '@emotion/react';
3
+ import type { WrappedComponentProps } from 'react-intl-next';
4
+ import type { LayoutButtonProps, LayoutButtonWrapperProps } from './types';
5
+ export declare const LayoutButton: ({ onLayoutChange, layout, intl: { formatMessage }, mountPoint, boundariesElement, scrollableElement, targetElement, testId, }: LayoutButtonProps) => jsx.JSX.Element | null;
6
+ declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<LayoutButtonWrapperProps & WrappedComponentProps<"intl">>> & {
7
+ WrappedComponent: import("react").ComponentType<LayoutButtonWrapperProps & WrappedComponentProps<"intl">>;
8
8
  };
9
9
  export default _default;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { APIError } from '@atlaskit/smart-card';
3
- import { DatasourceProps } from './nodeviews/datasource';
2
+ import type { APIError } from '@atlaskit/smart-card';
3
+ import type { DatasourceProps } from './nodeviews/datasource';
4
4
  export declare class DatasourceErrorBoundary extends React.Component<{
5
5
  url?: string;
6
6
  unsupportedComponent: React.ComponentType;
@@ -1,7 +1,7 @@
1
1
  import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
2
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
3
- import { EditorCardPluginEvents } from '../../analytics/create-events-queue';
4
- import { CardPluginEvent } from '../../analytics/types';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { EditorCardPluginEvents } from '../../analytics/create-events-queue';
4
+ import type { CardPluginEvent } from '../../analytics/types';
5
5
  export type AnalyticsBindingsProps = {
6
6
  editorView: EditorView;
7
7
  cardPluginEvents: EditorCardPluginEvents<CardPluginEvent>;
@@ -1,9 +1,9 @@
1
- /** @jsx jsx */
2
- import React from 'react';
3
- import { WrappedComponentProps } from 'react-intl-next';
4
- import { LayoutButtonProps, LayoutButtonWrapperProps } from './types';
5
- export declare const LayoutButton: React.FC<LayoutButtonProps>;
6
- declare const _default: React.FC<import("react-intl-next").WithIntlProps<LayoutButtonWrapperProps & WrappedComponentProps<"intl">>> & {
7
- WrappedComponent: React.ComponentType<LayoutButtonWrapperProps & WrappedComponentProps<"intl">>;
1
+ /// <reference types="react" />
2
+ import { jsx } from '@emotion/react';
3
+ import type { WrappedComponentProps } from 'react-intl-next';
4
+ import type { LayoutButtonProps, LayoutButtonWrapperProps } from './types';
5
+ export declare const LayoutButton: ({ onLayoutChange, layout, intl: { formatMessage }, mountPoint, boundariesElement, scrollableElement, targetElement, testId, }: LayoutButtonProps) => jsx.JSX.Element | null;
6
+ declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<LayoutButtonWrapperProps & WrappedComponentProps<"intl">>> & {
7
+ WrappedComponent: import("react").ComponentType<LayoutButtonWrapperProps & WrappedComponentProps<"intl">>;
8
8
  };
9
9
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^29.1.0",
35
35
  "@atlaskit/analytics-next": "^9.1.0",
36
- "@atlaskit/editor-common": "^75.5.0",
36
+ "@atlaskit/editor-common": "^75.8.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^0.2.0",
38
38
  "@atlaskit/editor-plugin-decorations": "^0.2.0",
39
39
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",
@@ -42,12 +42,12 @@
42
42
  "@atlaskit/editor-plugin-hyperlink": "^0.5.0",
43
43
  "@atlaskit/editor-plugin-width": "^0.2.0",
44
44
  "@atlaskit/editor-prosemirror": "1.1.0",
45
- "@atlaskit/editor-shared-styles": "^2.7.0",
45
+ "@atlaskit/editor-shared-styles": "^2.8.0",
46
46
  "@atlaskit/icon": "^21.12.0",
47
47
  "@atlaskit/link-analytics": "^8.3.0",
48
- "@atlaskit/link-datasource": "^1.3.0",
48
+ "@atlaskit/link-datasource": "^1.4.0",
49
49
  "@atlaskit/platform-feature-flags": "^0.2.0",
50
- "@atlaskit/smart-card": "^26.27.0",
50
+ "@atlaskit/smart-card": "^26.28.0",
51
51
  "@atlaskit/theme": "^12.6.0",
52
52
  "@atlaskit/tokens": "^1.25.0",
53
53
  "@babel/runtime": "^7.0.0",