@atlaskit/editor-plugin-analytics 2.1.2 → 2.2.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,24 @@
1
1
  # @atlaskit/editor-plugin-analytics
2
2
 
3
+ ## 2.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 2.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#126044](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/126044)
14
+ [`c397a5e304fa9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c397a5e304fa9) -
15
+ ED-26926 Moved findInsertLocation to editor-common and used it to add insertLocation to extension
16
+ insertion analytics
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 2.1.2
4
23
 
5
24
  ### Patch Changes
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.findInsertLocation = findInsertLocation;
7
6
  exports.findInsertedLocation = findInsertedLocation;
8
7
  exports.getSelectionType = getSelectionType;
9
8
  exports.getStateContext = getStateContext;
10
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
+ var _analytics2 = require("@atlaskit/editor-common/utils/analytics");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
12
  var _utils = require("@atlaskit/editor-prosemirror/utils");
13
13
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
@@ -43,23 +43,6 @@ function getSelectionType(selection) {
43
43
  position: position
44
44
  };
45
45
  }
46
- function findInsertLocation(selection) {
47
- var _selection$$from$doc$ = selection.$from.doc.type,
48
- schema = _selection$$from$doc$.schema,
49
- name = _selection$$from$doc$.name;
50
- if (selection instanceof _state.NodeSelection) {
51
- return selection.node.type.name;
52
- }
53
- if (selection instanceof _cellSelection.CellSelection) {
54
- return schema.nodes.table.name;
55
- }
56
-
57
- // Text selection
58
- var parentNodeInfo = (0, _utils.findParentNode)(function (node) {
59
- return node.type !== schema.nodes.paragraph;
60
- })(selection);
61
- return parentNodeInfo ? parentNodeInfo.node.type.name : name;
62
- }
63
46
  function findInsertedLocation(oldSelection, newSelection) {
64
47
  var schema = newSelection.$from.doc.type.schema;
65
48
  var _schema$nodes = schema.nodes,
@@ -90,7 +73,7 @@ function getStateContext(selection, payload, tr) {
90
73
  if (position) {
91
74
  payload.attributes.selectionPosition = position;
92
75
  }
93
- var insertLocation = findInsertLocation(selection);
76
+ var insertLocation = (0, _analytics2.findInsertLocation)(selection);
94
77
  if (payload.action === _analytics.ACTION.INSERTED && payload.actionSubject !== _analytics.ACTION_SUBJECT.ANNOTATION && payload.actionSubject !== _analytics.ACTION_SUBJECT.EDITOR_PLUGIN_AI) {
95
78
  payload.attributes.insertedLocation = findInsertedLocation(selection, tr.selection);
96
79
  }
@@ -10,7 +10,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
10
10
  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; }
11
11
  var getUndoRedoInputSource = function getUndoRedoInputSource(tr) {
12
12
  var _tr$getMeta;
13
- // TODO: Please, do not copy or use this kind of code below
13
+ // Please, do not copy or use this kind of code below
14
14
  return (_tr$getMeta = tr.getMeta('undoRedoPlugin$')) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : null;
15
15
  };
16
16
  var generateUndoRedoInputSoucePayload = exports.generateUndoRedoInputSoucePayload = function generateUndoRedoInputSoucePayload(tr) {
@@ -1,4 +1,5 @@
1
1
  import { ACTION, ACTION_SUBJECT, SELECTION_POSITION, SELECTION_TYPE } from '@atlaskit/editor-common/analytics';
2
+ import { findInsertLocation } from '@atlaskit/editor-common/utils/analytics';
2
3
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
4
5
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
@@ -36,22 +37,6 @@ export function getSelectionType(selection) {
36
37
  position
37
38
  };
38
39
  }
39
- export function findInsertLocation(selection) {
40
- const {
41
- schema,
42
- name
43
- } = selection.$from.doc.type;
44
- if (selection instanceof NodeSelection) {
45
- return selection.node.type.name;
46
- }
47
- if (selection instanceof CellSelection) {
48
- return schema.nodes.table.name;
49
- }
50
-
51
- // Text selection
52
- const parentNodeInfo = findParentNode(node => node.type !== schema.nodes.paragraph)(selection);
53
- return parentNodeInfo ? parentNodeInfo.node.type.name : name;
54
- }
55
40
  export function findInsertedLocation(oldSelection, newSelection) {
56
41
  const {
57
42
  schema
@@ -1,6 +1,6 @@
1
1
  const getUndoRedoInputSource = tr => {
2
2
  var _tr$getMeta;
3
- // TODO: Please, do not copy or use this kind of code below
3
+ // Please, do not copy or use this kind of code below
4
4
  return (_tr$getMeta = tr.getMeta('undoRedoPlugin$')) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : null;
5
5
  };
6
6
  export const generateUndoRedoInputSoucePayload = tr => {
@@ -1,4 +1,5 @@
1
1
  import { ACTION, ACTION_SUBJECT, SELECTION_POSITION, SELECTION_TYPE } from '@atlaskit/editor-common/analytics';
2
+ import { findInsertLocation } from '@atlaskit/editor-common/utils/analytics';
2
3
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
4
5
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
@@ -34,23 +35,6 @@ export function getSelectionType(selection) {
34
35
  position: position
35
36
  };
36
37
  }
37
- export function findInsertLocation(selection) {
38
- var _selection$$from$doc$ = selection.$from.doc.type,
39
- schema = _selection$$from$doc$.schema,
40
- name = _selection$$from$doc$.name;
41
- if (selection instanceof NodeSelection) {
42
- return selection.node.type.name;
43
- }
44
- if (selection instanceof CellSelection) {
45
- return schema.nodes.table.name;
46
- }
47
-
48
- // Text selection
49
- var parentNodeInfo = findParentNode(function (node) {
50
- return node.type !== schema.nodes.paragraph;
51
- })(selection);
52
- return parentNodeInfo ? parentNodeInfo.node.type.name : name;
53
- }
54
38
  export function findInsertedLocation(oldSelection, newSelection) {
55
39
  var schema = newSelection.$from.doc.type.schema;
56
40
  var _schema$nodes = schema.nodes,
@@ -3,7 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
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
  var getUndoRedoInputSource = function getUndoRedoInputSource(tr) {
5
5
  var _tr$getMeta;
6
- // TODO: Please, do not copy or use this kind of code below
6
+ // Please, do not copy or use this kind of code below
7
7
  return (_tr$getMeta = tr.getMeta('undoRedoPlugin$')) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : null;
8
8
  };
9
9
  export var generateUndoRedoInputSoucePayload = function generateUndoRedoInputSoucePayload(tr) {
@@ -5,6 +5,5 @@ export declare function getSelectionType(selection: Selection): {
5
5
  type: SELECTION_TYPE;
6
6
  position?: SELECTION_POSITION;
7
7
  };
8
- export declare function findInsertLocation(selection: Selection): string;
9
8
  export declare function findInsertedLocation(oldSelection: Selection, newSelection: Selection): string;
10
9
  export declare function getStateContext(selection: Selection, payload: AnalyticsEventPayload, tr: Transaction): AnalyticsEventPayload;
@@ -5,6 +5,5 @@ export declare function getSelectionType(selection: Selection): {
5
5
  type: SELECTION_TYPE;
6
6
  position?: SELECTION_POSITION;
7
7
  };
8
- export declare function findInsertLocation(selection: Selection): string;
9
8
  export declare function findInsertedLocation(oldSelection: Selection, newSelection: Selection): string;
10
9
  export declare function getStateContext(selection: Selection, payload: AnalyticsEventPayload, tr: Transaction): AnalyticsEventPayload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-analytics",
3
- "version": "2.1.2",
3
+ "version": "2.2.1",
4
4
  "description": "Analytics plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  "@atlaskit/adf-schema": "^47.6.0",
35
35
  "@atlaskit/analytics-listeners": "^9.0.0",
36
36
  "@atlaskit/analytics-next": "^11.0.0",
37
- "@atlaskit/editor-common": "^102.0.0",
37
+ "@atlaskit/editor-common": "^103.0.0",
38
38
  "@atlaskit/editor-plugin-feature-flags": "^1.3.0",
39
39
  "@atlaskit/editor-prosemirror": "7.0.0",
40
40
  "@atlaskit/editor-tables": "^2.9.0",