@atlaskit/editor-plugin-analytics 8.0.1 → 8.0.3
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,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-analytics
|
|
2
2
|
|
|
3
|
+
## 8.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ddcd9f9430dfe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ddcd9f9430dfe) -
|
|
8
|
+
EDITOR-5602 Add position check when insertLocation is fired
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 8.0.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 8.0.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -10,6 +10,7 @@ var _analytics2 = require("@atlaskit/editor-common/utils/analytics");
|
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
12
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
13
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
14
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
14
15
|
function getSelectionType(selection) {
|
|
15
16
|
var _selection$constructo;
|
|
@@ -43,7 +44,7 @@ function getSelectionType(selection) {
|
|
|
43
44
|
position: position
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
|
-
function findInsertedLocation(oldSelection, newSelection) {
|
|
47
|
+
function findInsertedLocation(oldSelection, newSelection, tr) {
|
|
47
48
|
var schema = newSelection.$from.doc.type.schema;
|
|
48
49
|
var _schema$nodes = schema.nodes,
|
|
49
50
|
paragraph = _schema$nodes.paragraph,
|
|
@@ -51,14 +52,21 @@ function findInsertedLocation(oldSelection, newSelection) {
|
|
|
51
52
|
if (oldSelection instanceof _cellSelection.CellSelection) {
|
|
52
53
|
return table.name;
|
|
53
54
|
}
|
|
55
|
+
var newDoc = newSelection.$from.doc;
|
|
54
56
|
var insertLocationInfo = (0, _utils.findParentNode)(function (node) {
|
|
55
57
|
return node.type !== paragraph;
|
|
56
58
|
})(oldSelection);
|
|
57
|
-
var
|
|
59
|
+
var pos = (insertLocationInfo === null || insertLocationInfo === void 0 ? void 0 : insertLocationInfo.start) || 0;
|
|
60
|
+
;
|
|
61
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_insert_location_check', 'isEnabled', true)) {
|
|
62
|
+
// Map the old document position through the transaction's steps
|
|
63
|
+
pos = tr.mapping.map(pos);
|
|
64
|
+
}
|
|
65
|
+
var parentNodePos = newDoc.resolve(pos);
|
|
58
66
|
|
|
59
67
|
// Keep going one level above the attempted insert position till we find a node that contains the current cursor position in it's range
|
|
60
68
|
while (parentNodePos.end() < newSelection.$from.pos) {
|
|
61
|
-
parentNodePos =
|
|
69
|
+
parentNodePos = newDoc.resolve(parentNodePos.start(Math.max(parentNodePos.depth - 1, 0)));
|
|
62
70
|
}
|
|
63
71
|
return parentNodePos.node().type.name;
|
|
64
72
|
}
|
|
@@ -75,7 +83,7 @@ function getStateContext(selection, payload, tr) {
|
|
|
75
83
|
}
|
|
76
84
|
var insertLocation = (0, _analytics2.findInsertLocation)(selection);
|
|
77
85
|
if (tr && payload.action === _analytics.ACTION.INSERTED && payload.actionSubject !== _analytics.ACTION_SUBJECT.ANNOTATION && payload.actionSubject !== _analytics.ACTION_SUBJECT.EDITOR_PLUGIN_AI) {
|
|
78
|
-
payload.attributes.insertedLocation = findInsertedLocation(selection, tr.selection);
|
|
86
|
+
payload.attributes.insertedLocation = findInsertedLocation(selection, tr.selection, tr);
|
|
79
87
|
}
|
|
80
88
|
if (payload.action === _analytics.ACTION.INSERTED && payload.actionSubject === _analytics.ACTION_SUBJECT.DOCUMENT && payload.attributes) {
|
|
81
89
|
payload.attributes.insertLocation = insertLocation;
|
|
@@ -3,6 +3,7 @@ import { findInsertLocation } from '@atlaskit/editor-common/utils/analytics';
|
|
|
3
3
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { findParentNode, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
6
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
8
|
export function getSelectionType(selection) {
|
|
8
9
|
var _selection$constructo;
|
|
@@ -38,7 +39,7 @@ export function getSelectionType(selection) {
|
|
|
38
39
|
position
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
|
-
function findInsertedLocation(oldSelection, newSelection) {
|
|
42
|
+
function findInsertedLocation(oldSelection, newSelection, tr) {
|
|
42
43
|
const {
|
|
43
44
|
schema
|
|
44
45
|
} = newSelection.$from.doc.type;
|
|
@@ -51,12 +52,19 @@ function findInsertedLocation(oldSelection, newSelection) {
|
|
|
51
52
|
if (oldSelection instanceof CellSelection) {
|
|
52
53
|
return table.name;
|
|
53
54
|
}
|
|
55
|
+
const newDoc = newSelection.$from.doc;
|
|
54
56
|
const insertLocationInfo = findParentNode(node => node.type !== paragraph)(oldSelection);
|
|
55
|
-
let
|
|
57
|
+
let pos = (insertLocationInfo === null || insertLocationInfo === void 0 ? void 0 : insertLocationInfo.start) || 0;
|
|
58
|
+
;
|
|
59
|
+
if (expValEquals('platform_editor_insert_location_check', 'isEnabled', true)) {
|
|
60
|
+
// Map the old document position through the transaction's steps
|
|
61
|
+
pos = tr.mapping.map(pos);
|
|
62
|
+
}
|
|
63
|
+
let parentNodePos = newDoc.resolve(pos);
|
|
56
64
|
|
|
57
65
|
// Keep going one level above the attempted insert position till we find a node that contains the current cursor position in it's range
|
|
58
66
|
while (parentNodePos.end() < newSelection.$from.pos) {
|
|
59
|
-
parentNodePos =
|
|
67
|
+
parentNodePos = newDoc.resolve(parentNodePos.start(Math.max(parentNodePos.depth - 1, 0)));
|
|
60
68
|
}
|
|
61
69
|
return parentNodePos.node().type.name;
|
|
62
70
|
}
|
|
@@ -74,7 +82,7 @@ export function getStateContext(selection, payload, tr) {
|
|
|
74
82
|
}
|
|
75
83
|
const insertLocation = findInsertLocation(selection);
|
|
76
84
|
if (tr && payload.action === ACTION.INSERTED && payload.actionSubject !== ACTION_SUBJECT.ANNOTATION && payload.actionSubject !== ACTION_SUBJECT.EDITOR_PLUGIN_AI) {
|
|
77
|
-
payload.attributes.insertedLocation = findInsertedLocation(selection, tr.selection);
|
|
85
|
+
payload.attributes.insertedLocation = findInsertedLocation(selection, tr.selection, tr);
|
|
78
86
|
}
|
|
79
87
|
if (payload.action === ACTION.INSERTED && payload.actionSubject === ACTION_SUBJECT.DOCUMENT && payload.attributes) {
|
|
80
88
|
payload.attributes.insertLocation = insertLocation;
|
|
@@ -3,6 +3,7 @@ import { findInsertLocation } from '@atlaskit/editor-common/utils/analytics';
|
|
|
3
3
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { findParentNode, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
6
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
8
|
export function getSelectionType(selection) {
|
|
8
9
|
var _selection$constructo;
|
|
@@ -36,7 +37,7 @@ export function getSelectionType(selection) {
|
|
|
36
37
|
position: position
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
|
-
function findInsertedLocation(oldSelection, newSelection) {
|
|
40
|
+
function findInsertedLocation(oldSelection, newSelection, tr) {
|
|
40
41
|
var schema = newSelection.$from.doc.type.schema;
|
|
41
42
|
var _schema$nodes = schema.nodes,
|
|
42
43
|
paragraph = _schema$nodes.paragraph,
|
|
@@ -44,14 +45,21 @@ function findInsertedLocation(oldSelection, newSelection) {
|
|
|
44
45
|
if (oldSelection instanceof CellSelection) {
|
|
45
46
|
return table.name;
|
|
46
47
|
}
|
|
48
|
+
var newDoc = newSelection.$from.doc;
|
|
47
49
|
var insertLocationInfo = findParentNode(function (node) {
|
|
48
50
|
return node.type !== paragraph;
|
|
49
51
|
})(oldSelection);
|
|
50
|
-
var
|
|
52
|
+
var pos = (insertLocationInfo === null || insertLocationInfo === void 0 ? void 0 : insertLocationInfo.start) || 0;
|
|
53
|
+
;
|
|
54
|
+
if (expValEquals('platform_editor_insert_location_check', 'isEnabled', true)) {
|
|
55
|
+
// Map the old document position through the transaction's steps
|
|
56
|
+
pos = tr.mapping.map(pos);
|
|
57
|
+
}
|
|
58
|
+
var parentNodePos = newDoc.resolve(pos);
|
|
51
59
|
|
|
52
60
|
// Keep going one level above the attempted insert position till we find a node that contains the current cursor position in it's range
|
|
53
61
|
while (parentNodePos.end() < newSelection.$from.pos) {
|
|
54
|
-
parentNodePos =
|
|
62
|
+
parentNodePos = newDoc.resolve(parentNodePos.start(Math.max(parentNodePos.depth - 1, 0)));
|
|
55
63
|
}
|
|
56
64
|
return parentNodePos.node().type.name;
|
|
57
65
|
}
|
|
@@ -68,7 +76,7 @@ export function getStateContext(selection, payload, tr) {
|
|
|
68
76
|
}
|
|
69
77
|
var insertLocation = findInsertLocation(selection);
|
|
70
78
|
if (tr && payload.action === ACTION.INSERTED && payload.actionSubject !== ACTION_SUBJECT.ANNOTATION && payload.actionSubject !== ACTION_SUBJECT.EDITOR_PLUGIN_AI) {
|
|
71
|
-
payload.attributes.insertedLocation = findInsertedLocation(selection, tr.selection);
|
|
79
|
+
payload.attributes.insertedLocation = findInsertedLocation(selection, tr.selection, tr);
|
|
72
80
|
}
|
|
73
81
|
if (payload.action === ACTION.INSERTED && payload.actionSubject === ACTION_SUBJECT.DOCUMENT && payload.attributes) {
|
|
74
82
|
payload.attributes.insertLocation = insertLocation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-analytics",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.3",
|
|
4
4
|
"description": "Analytics plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
35
35
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
36
36
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
37
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
37
|
+
"@atlaskit/tmp-editor-statsig": "^38.0.0",
|
|
38
38
|
"@babel/runtime": "^7.0.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@atlaskit/editor-common": "^112.
|
|
41
|
+
"@atlaskit/editor-common": "^112.2.0",
|
|
42
42
|
"react": "^18.2.0"
|
|
43
43
|
},
|
|
44
44
|
"techstack": {
|