@atlaskit/editor-plugin-analytics 0.4.7 → 1.0.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 +13 -0
- package/dist/cjs/analytics-api/attach-payload-into-transaction.js +1 -1
- package/dist/cjs/analytics-api/editor-state-context.js +24 -1
- package/dist/es2019/analytics-api/attach-payload-into-transaction.js +1 -1
- package/dist/es2019/analytics-api/editor-state-context.js +26 -1
- package/dist/esm/analytics-api/attach-payload-into-transaction.js +1 -1
- package/dist/esm/analytics-api/editor-state-context.js +23 -1
- package/dist/types/analytics-api/attach-payload-into-transaction.d.ts +1 -1
- package/dist/types/analytics-api/editor-state-context.d.ts +3 -2
- package/dist/types-ts4.5/analytics-api/attach-payload-into-transaction.d.ts +1 -1
- package/dist/types-ts4.5/analytics-api/editor-state-context.d.ts +3 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-analytics
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#72295](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/72295) [`eefc8788ab31`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/eefc8788ab31) - ED-22046 Add insertedLocation attribute for analytics in node insertion
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 1.0.0
|
|
11
|
+
|
|
12
|
+
### Major Changes
|
|
13
|
+
|
|
14
|
+
- [#72386](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/72386) [`0c52b0be40c1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0c52b0be40c1) - This changeset exists to bump all editor plugins that currently don't have a major version. This is to address an issue with Jira plugin consumption.
|
|
15
|
+
|
|
3
16
|
## 0.4.7
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -32,7 +32,7 @@ var attachPayloadIntoTransaction = exports.attachPayloadIntoTransaction = functi
|
|
|
32
32
|
selection = _ref2.selection,
|
|
33
33
|
tr = _ref2.tr,
|
|
34
34
|
channel = _ref2.channel;
|
|
35
|
-
payload = (0, _editorStateContext.getStateContext)(selection, payload);
|
|
35
|
+
payload = (0, _editorStateContext.getStateContext)(selection, payload, tr);
|
|
36
36
|
payload = (0, _mapAttributes.mapActionSubjectIdToAttributes)(payload);
|
|
37
37
|
var storedMarks = tr.storedMarks;
|
|
38
38
|
var pos = tr.mapping.map(selection.$from.pos, -1);
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.findInsertLocation = findInsertLocation;
|
|
7
|
+
exports.findInsertedLocation = findInsertedLocation;
|
|
7
8
|
exports.getSelectionType = getSelectionType;
|
|
8
9
|
exports.getStateContext = getStateContext;
|
|
9
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -57,7 +58,26 @@ function findInsertLocation(selection) {
|
|
|
57
58
|
})(selection);
|
|
58
59
|
return parentNodeInfo ? parentNodeInfo.node.type.name : name;
|
|
59
60
|
}
|
|
60
|
-
function
|
|
61
|
+
function findInsertedLocation(oldSelection, newSelection) {
|
|
62
|
+
var schema = newSelection.$from.doc.type.schema;
|
|
63
|
+
var _schema$nodes = schema.nodes,
|
|
64
|
+
paragraph = _schema$nodes.paragraph,
|
|
65
|
+
table = _schema$nodes.table;
|
|
66
|
+
if (oldSelection instanceof _cellSelection.CellSelection) {
|
|
67
|
+
return table.name;
|
|
68
|
+
}
|
|
69
|
+
var insertLocationInfo = (0, _utils.findParentNode)(function (node) {
|
|
70
|
+
return node.type !== paragraph;
|
|
71
|
+
})(oldSelection);
|
|
72
|
+
var parentNodePos = newSelection.$from.doc.resolve((insertLocationInfo === null || insertLocationInfo === void 0 ? void 0 : insertLocationInfo.start) || 0);
|
|
73
|
+
|
|
74
|
+
// Keep going one level above the attempted insert position till we find a node that contains the current cursor position in it's range
|
|
75
|
+
while (parentNodePos.end() < newSelection.$from.pos) {
|
|
76
|
+
parentNodePos = newSelection.$from.doc.resolve(parentNodePos.start(Math.max(parentNodePos.depth - 1, 0)));
|
|
77
|
+
}
|
|
78
|
+
return parentNodePos.node().type.name;
|
|
79
|
+
}
|
|
80
|
+
function getStateContext(selection, payload, tr) {
|
|
61
81
|
if (!payload.attributes) {
|
|
62
82
|
return payload;
|
|
63
83
|
}
|
|
@@ -69,6 +89,9 @@ function getStateContext(selection, payload) {
|
|
|
69
89
|
payload.attributes.selectionPosition = position;
|
|
70
90
|
}
|
|
71
91
|
var insertLocation = findInsertLocation(selection);
|
|
92
|
+
if (payload.action === _analytics.ACTION.INSERTED && payload.actionSubject !== _analytics.ACTION_SUBJECT.ANNOTATION) {
|
|
93
|
+
payload.attributes.insertedLocation = findInsertedLocation(selection, tr.selection);
|
|
94
|
+
}
|
|
72
95
|
if (payload.action === _analytics.ACTION.INSERTED && payload.actionSubject === _analytics.ACTION_SUBJECT.DOCUMENT && payload.attributes) {
|
|
73
96
|
payload.attributes.insertLocation = insertLocation;
|
|
74
97
|
} else {
|
|
@@ -50,7 +50,29 @@ export function findInsertLocation(selection) {
|
|
|
50
50
|
const parentNodeInfo = findParentNode(node => node.type !== schema.nodes.paragraph)(selection);
|
|
51
51
|
return parentNodeInfo ? parentNodeInfo.node.type.name : name;
|
|
52
52
|
}
|
|
53
|
-
export function
|
|
53
|
+
export function findInsertedLocation(oldSelection, newSelection) {
|
|
54
|
+
const {
|
|
55
|
+
schema
|
|
56
|
+
} = newSelection.$from.doc.type;
|
|
57
|
+
const {
|
|
58
|
+
nodes: {
|
|
59
|
+
paragraph,
|
|
60
|
+
table
|
|
61
|
+
}
|
|
62
|
+
} = schema;
|
|
63
|
+
if (oldSelection instanceof CellSelection) {
|
|
64
|
+
return table.name;
|
|
65
|
+
}
|
|
66
|
+
const insertLocationInfo = findParentNode(node => node.type !== paragraph)(oldSelection);
|
|
67
|
+
let parentNodePos = newSelection.$from.doc.resolve((insertLocationInfo === null || insertLocationInfo === void 0 ? void 0 : insertLocationInfo.start) || 0);
|
|
68
|
+
|
|
69
|
+
// Keep going one level above the attempted insert position till we find a node that contains the current cursor position in it's range
|
|
70
|
+
while (parentNodePos.end() < newSelection.$from.pos) {
|
|
71
|
+
parentNodePos = newSelection.$from.doc.resolve(parentNodePos.start(Math.max(parentNodePos.depth - 1, 0)));
|
|
72
|
+
}
|
|
73
|
+
return parentNodePos.node().type.name;
|
|
74
|
+
}
|
|
75
|
+
export function getStateContext(selection, payload, tr) {
|
|
54
76
|
if (!payload.attributes) {
|
|
55
77
|
return payload;
|
|
56
78
|
}
|
|
@@ -63,6 +85,9 @@ export function getStateContext(selection, payload) {
|
|
|
63
85
|
payload.attributes.selectionPosition = position;
|
|
64
86
|
}
|
|
65
87
|
const insertLocation = findInsertLocation(selection);
|
|
88
|
+
if (payload.action === ACTION.INSERTED && payload.actionSubject !== ACTION_SUBJECT.ANNOTATION) {
|
|
89
|
+
payload.attributes.insertedLocation = findInsertedLocation(selection, tr.selection);
|
|
90
|
+
}
|
|
66
91
|
if (payload.action === ACTION.INSERTED && payload.actionSubject === ACTION_SUBJECT.DOCUMENT && payload.attributes) {
|
|
67
92
|
payload.attributes.insertLocation = insertLocation;
|
|
68
93
|
} else {
|
|
@@ -26,7 +26,7 @@ export var attachPayloadIntoTransaction = function attachPayloadIntoTransaction(
|
|
|
26
26
|
selection = _ref2.selection,
|
|
27
27
|
tr = _ref2.tr,
|
|
28
28
|
channel = _ref2.channel;
|
|
29
|
-
payload = getStateContext(selection, payload);
|
|
29
|
+
payload = getStateContext(selection, payload, tr);
|
|
30
30
|
payload = mapActionSubjectIdToAttributes(payload);
|
|
31
31
|
var storedMarks = tr.storedMarks;
|
|
32
32
|
var pos = tr.mapping.map(selection.$from.pos, -1);
|
|
@@ -49,7 +49,26 @@ export function findInsertLocation(selection) {
|
|
|
49
49
|
})(selection);
|
|
50
50
|
return parentNodeInfo ? parentNodeInfo.node.type.name : name;
|
|
51
51
|
}
|
|
52
|
-
export function
|
|
52
|
+
export function findInsertedLocation(oldSelection, newSelection) {
|
|
53
|
+
var schema = newSelection.$from.doc.type.schema;
|
|
54
|
+
var _schema$nodes = schema.nodes,
|
|
55
|
+
paragraph = _schema$nodes.paragraph,
|
|
56
|
+
table = _schema$nodes.table;
|
|
57
|
+
if (oldSelection instanceof CellSelection) {
|
|
58
|
+
return table.name;
|
|
59
|
+
}
|
|
60
|
+
var insertLocationInfo = findParentNode(function (node) {
|
|
61
|
+
return node.type !== paragraph;
|
|
62
|
+
})(oldSelection);
|
|
63
|
+
var parentNodePos = newSelection.$from.doc.resolve((insertLocationInfo === null || insertLocationInfo === void 0 ? void 0 : insertLocationInfo.start) || 0);
|
|
64
|
+
|
|
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
|
|
66
|
+
while (parentNodePos.end() < newSelection.$from.pos) {
|
|
67
|
+
parentNodePos = newSelection.$from.doc.resolve(parentNodePos.start(Math.max(parentNodePos.depth - 1, 0)));
|
|
68
|
+
}
|
|
69
|
+
return parentNodePos.node().type.name;
|
|
70
|
+
}
|
|
71
|
+
export function getStateContext(selection, payload, tr) {
|
|
53
72
|
if (!payload.attributes) {
|
|
54
73
|
return payload;
|
|
55
74
|
}
|
|
@@ -61,6 +80,9 @@ export function getStateContext(selection, payload) {
|
|
|
61
80
|
payload.attributes.selectionPosition = position;
|
|
62
81
|
}
|
|
63
82
|
var insertLocation = findInsertLocation(selection);
|
|
83
|
+
if (payload.action === ACTION.INSERTED && payload.actionSubject !== ACTION_SUBJECT.ANNOTATION) {
|
|
84
|
+
payload.attributes.insertedLocation = findInsertedLocation(selection, tr.selection);
|
|
85
|
+
}
|
|
64
86
|
if (payload.action === ACTION.INSERTED && payload.actionSubject === ACTION_SUBJECT.DOCUMENT && payload.attributes) {
|
|
65
87
|
payload.attributes.insertLocation = insertLocation;
|
|
66
88
|
} else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
type AttachPayloadIntoTransaction = (props: {
|
|
4
4
|
payload: AnalyticsEventPayload;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { SELECTION_POSITION, SELECTION_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
export declare function getSelectionType(selection: Selection): {
|
|
5
5
|
type: SELECTION_TYPE;
|
|
6
6
|
position?: SELECTION_POSITION;
|
|
7
7
|
};
|
|
8
8
|
export declare function findInsertLocation(selection: Selection): string;
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function findInsertedLocation(oldSelection: Selection, newSelection: Selection): string;
|
|
10
|
+
export declare function getStateContext(selection: Selection, payload: AnalyticsEventPayload, tr: Transaction): AnalyticsEventPayload;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
type AttachPayloadIntoTransaction = (props: {
|
|
4
4
|
payload: AnalyticsEventPayload;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { SELECTION_POSITION, SELECTION_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
export declare function getSelectionType(selection: Selection): {
|
|
5
5
|
type: SELECTION_TYPE;
|
|
6
6
|
position?: SELECTION_POSITION;
|
|
7
7
|
};
|
|
8
8
|
export declare function findInsertLocation(selection: Selection): string;
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function findInsertedLocation(oldSelection: Selection, newSelection: Selection): string;
|
|
10
|
+
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": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Analytics plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@atlaskit/adf-schema": "^35.5.1",
|
|
36
36
|
"@atlaskit/analytics-listeners": "^8.9.0",
|
|
37
37
|
"@atlaskit/analytics-next": "^9.2.0",
|
|
38
|
-
"@atlaskit/editor-common": "^77.
|
|
38
|
+
"@atlaskit/editor-common": "^77.5.0",
|
|
39
39
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
41
41
|
"@atlaskit/editor-tables": "^2.5.0",
|