@atlaskit/editor-plugin-card 0.7.3 → 0.8.1

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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 0.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ae7c1132c88`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ae7c1132c88) - Added analytics fix for undo/redo scenarious of link upgrade to a datasource
8
+ - [`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.
9
+
10
+ ## 0.8.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`e4721cc5a3f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e4721cc5a3f) - Make issue count clickable
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 0.7.3
4
21
 
5
22
  ### Patch 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 {
@@ -97,6 +97,7 @@ var DatasourceComponent = /*#__PURE__*/function (_React$PureComponent) {
97
97
  value: function render() {
98
98
  var cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
99
99
  var datasource = this.getDatasource();
100
+ var attrs = this.props.node.attrs;
100
101
  var tableView = this.getTableView();
101
102
  if (tableView) {
102
103
  var _tableView$properties;
@@ -115,7 +116,8 @@ var DatasourceComponent = /*#__PURE__*/function (_React$PureComponent) {
115
116
  datasourceId: datasource.id,
116
117
  parameters: datasource.parameters,
117
118
  visibleColumnKeys: visibleColumnKeys,
118
- onVisibleColumnKeysChange: this.handleColumnChange
119
+ onVisibleColumnKeysChange: this.handleColumnChange,
120
+ url: attrs === null || attrs === void 0 ? void 0 : attrs.url
119
121
  })));
120
122
  }
121
123
  }
@@ -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
  }
@@ -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 {
@@ -72,6 +72,7 @@ export class DatasourceComponent extends React.PureComponent {
72
72
  render() {
73
73
  const cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
74
74
  const datasource = this.getDatasource();
75
+ const attrs = this.props.node.attrs;
75
76
  const tableView = this.getTableView();
76
77
  if (tableView) {
77
78
  var _tableView$properties;
@@ -89,7 +90,8 @@ export class DatasourceComponent extends React.PureComponent {
89
90
  datasourceId: datasource.id,
90
91
  parameters: datasource.parameters,
91
92
  visibleColumnKeys: visibleColumnKeys,
92
- onVisibleColumnKeysChange: this.handleColumnChange
93
+ onVisibleColumnKeysChange: this.handleColumnChange,
94
+ url: attrs === null || attrs === void 0 ? void 0 : attrs.url
93
95
  })));
94
96
  }
95
97
  }
@@ -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
  }
@@ -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 {
@@ -91,6 +91,7 @@ export var DatasourceComponent = /*#__PURE__*/function (_React$PureComponent) {
91
91
  value: function render() {
92
92
  var cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
93
93
  var datasource = this.getDatasource();
94
+ var attrs = this.props.node.attrs;
94
95
  var tableView = this.getTableView();
95
96
  if (tableView) {
96
97
  var _tableView$properties;
@@ -109,7 +110,8 @@ export var DatasourceComponent = /*#__PURE__*/function (_React$PureComponent) {
109
110
  datasourceId: datasource.id,
110
111
  parameters: datasource.parameters,
111
112
  visibleColumnKeys: visibleColumnKeys,
112
- onVisibleColumnKeysChange: this.handleColumnChange
113
+ onVisibleColumnKeysChange: this.handleColumnChange,
114
+ url: attrs === null || attrs === void 0 ? void 0 : attrs.url
113
115
  })));
114
116
  }
115
117
  }
@@ -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
  }
@@ -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,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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.7.3",
3
+ "version": "0.8.1",
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.2.0",
36
+ "@atlaskit/editor-common": "^75.6.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",
@@ -45,9 +45,9 @@
45
45
  "@atlaskit/editor-shared-styles": "^2.7.0",
46
46
  "@atlaskit/icon": "^21.12.0",
47
47
  "@atlaskit/link-analytics": "^8.3.0",
48
- "@atlaskit/link-datasource": "^1.2.0",
48
+ "@atlaskit/link-datasource": "^1.3.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",