@atlaskit/editor-plugin-collab-edit 23.0.0 → 23.0.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 (30) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/cjs/collabEditPlugin.js +25 -23
  3. package/dist/cjs/pm-plugins/collabSendHold.js +76 -0
  4. package/dist/cjs/pm-plugins/collapseStreamingSteps.js +127 -0
  5. package/dist/cjs/pm-plugins/events/send-transaction.js +13 -2
  6. package/dist/cjs/pm-plugins/mergeOverlappingSteps.js +152 -0
  7. package/dist/cjs/pm-plugins/track-steps.js +1 -104
  8. package/dist/es2019/collabEditPlugin.js +23 -23
  9. package/dist/es2019/pm-plugins/collabSendHold.js +68 -0
  10. package/dist/es2019/pm-plugins/collapseStreamingSteps.js +114 -0
  11. package/dist/es2019/pm-plugins/events/send-transaction.js +12 -2
  12. package/dist/es2019/pm-plugins/mergeOverlappingSteps.js +144 -0
  13. package/dist/es2019/pm-plugins/track-steps.js +0 -93
  14. package/dist/esm/collabEditPlugin.js +25 -23
  15. package/dist/esm/pm-plugins/collabSendHold.js +70 -0
  16. package/dist/esm/pm-plugins/collapseStreamingSteps.js +122 -0
  17. package/dist/esm/pm-plugins/events/send-transaction.js +13 -2
  18. package/dist/esm/pm-plugins/mergeOverlappingSteps.js +147 -0
  19. package/dist/esm/pm-plugins/track-steps.js +0 -104
  20. package/dist/types/pm-plugins/collabSendHold.d.ts +51 -0
  21. package/dist/types/pm-plugins/collapseStreamingSteps.d.ts +18 -0
  22. package/dist/types/pm-plugins/events/send-transaction.d.ts +7 -1
  23. package/dist/types/pm-plugins/mergeOverlappingSteps.d.ts +28 -0
  24. package/dist/types/pm-plugins/track-steps.d.ts +0 -41
  25. package/package.json +8 -5
  26. package/tsconfig.typecheck-typecheck-dev.tsbuildinfo +1 -0
  27. package/dist/cjs/pm-plugins/track-step-metrics.js +0 -82
  28. package/dist/es2019/pm-plugins/track-step-metrics.js +0 -79
  29. package/dist/esm/pm-plugins/track-step-metrics.js +0 -75
  30. package/dist/types/pm-plugins/track-step-metrics.d.ts +0 -48
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-collab-edit",
3
- "version": "23.0.0",
3
+ "version": "23.0.2",
4
4
  "description": "Collab Edit plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,17 +28,16 @@
28
28
  "@atlaskit/editor-plugin-feature-flags": "^21.0.0",
29
29
  "@atlaskit/editor-prosemirror": "^9.0.0",
30
30
  "@atlaskit/editor-shared-styles": "^4.3.0",
31
- "@atlaskit/frontend-utilities": "^5.0.0",
32
31
  "@atlaskit/platform-feature-experiments": "^0.3.0",
33
32
  "@atlaskit/platform-feature-flags": "^2.2.0",
34
33
  "@atlaskit/prosemirror-collab": "^1.1.0",
35
- "@atlaskit/tmp-editor-statsig": "^209.0.0",
36
- "@atlaskit/tokens": "^20.0.0",
34
+ "@atlaskit/tmp-editor-statsig": "^211.0.0",
35
+ "@atlaskit/tokens": "^20.1.0",
37
36
  "@babel/runtime": "^7.0.0",
38
37
  "memoize-one": "^6.0.0"
39
38
  },
40
39
  "peerDependencies": {
41
- "@atlaskit/editor-common": "^126.0.0",
40
+ "@atlaskit/editor-common": "^126.1.0",
42
41
  "react": "^18.2.0 || ^19.2.0",
43
42
  "react-dom": "^18.2.0 || ^19.2.0"
44
43
  },
@@ -49,6 +48,10 @@
49
48
  "wait-for-expect": "^1.2.0"
50
49
  },
51
50
  "platform-feature-flags": {
51
+ "platform_editor_ai_collapse_streaming_steps": {
52
+ "type": "boolean",
53
+ "referenceOnly": true
54
+ },
52
55
  "confluence_ncs_step_diffing_version_history": {
53
56
  "type": "boolean",
54
57
  "referenceOnly": true
@@ -0,0 +1 @@
1
+ {"version":"7.0.2","errors":true,"root":["./docs/0-intro.tsx"],"packageJsons":["../../../../node_modules/@types/prop-types/package.json","../../../../node_modules/@types/react/package.json","../../../../node_modules/csstype/package.json","../../../../node_modules/prop-types/package.json","../../../../node_modules/react/package.json","../../../build/website/docs/package.json","../../design-system/tokens/package.json","../editor-common/package.json","./package.json"],"missingPackageJsons":["../../../../node_modules/@atlaskit/editor-common/doc-utils/package.json","../../../node_modules/@atlaskit/docs/package.json","../../../node_modules/@atlaskit/editor-common/doc-utils/package.json","../../../node_modules/@atlaskit/editor-common/package.json","../../../node_modules/@atlaskit/tokens/package.json","../../../node_modules/react/package.json"]}
@@ -1,82 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.updateNcsSessionStepMetrics = exports.updateNcsActiveSessions = exports.getNcsSessionStepMetrics = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _ncsStepMetrics = require("@atlaskit/editor-common/ncs-step-metrics");
10
- var _StorageClient = require("@atlaskit/frontend-utilities/StorageClient");
11
- 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; }
12
- 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; }
13
- var storageClient = new _StorageClient.StorageClient(_ncsStepMetrics.NCS_STORAGE.NCS_STORAGE_CLIENT_KEY);
14
-
15
- /**
16
- * Gets the current step session metrics for a given session ID
17
- * If the session ID does not exist, it initializes a new metrics object.
18
- * It calculates the total size of the steps, the number of steps,
19
- * the maximum step size, and the sum of step sizes for P90 calculation.
20
- *
21
- * @param metrics - The existing metrics object from local storage.
22
- * @param sessionId - The session ID for which to get the metrics.
23
- * @param steps - The steps to calculate the metrics from.
24
- * @returns The updated step session metrics for the given session ID.
25
- */
26
- var getNcsSessionStepMetrics = exports.getNcsSessionStepMetrics = function getNcsSessionStepMetrics(metrics, sessionId, steps) {
27
- var _metrics$sessionId;
28
- var current = (_metrics$sessionId = metrics[sessionId]) !== null && _metrics$sessionId !== void 0 ? _metrics$sessionId : {
29
- ncsSessionId: sessionId,
30
- totalStepSize: 0,
31
- numberOfSteps: 0,
32
- maxStepSize: 0,
33
- stepSizeSumForP90: []
34
- };
35
- steps.forEach(function (step) {
36
- var stepSize = JSON.stringify(step).length;
37
- current.totalStepSize += stepSize;
38
- current.numberOfSteps += 1;
39
- current.maxStepSize = Math.max(current.maxStepSize, stepSize || 0);
40
- current.stepSizeSumForP90.push(stepSize || 0);
41
- });
42
- return current;
43
- };
44
-
45
- /**
46
- * Gets the current active sessions from local storage
47
- * If the session ID does not exist, it initializes a new active session.
48
- *
49
- * This is used in the ncsStepMetricsPlugin to determine if the session is still active
50
- * before sending the ncs steps analytics event.
51
- *
52
- * @param sessionId - The session ID to check or update in local storage.
53
- * @returns void
54
- */
55
- var updateNcsActiveSessions = exports.updateNcsActiveSessions = function updateNcsActiveSessions(sessionId) {
56
- var currentActiveSessions = JSON.parse(storageClient.getItem(_ncsStepMetrics.NCS_STORAGE.NCS_ACTIVE_SESSIONS) || '{}');
57
- if (!currentActiveSessions[sessionId]) {
58
- storageClient.setItemWithExpiry(_ncsStepMetrics.NCS_STORAGE.NCS_ACTIVE_SESSIONS, JSON.stringify(_objectSpread(_objectSpread({}, currentActiveSessions), {}, (0, _defineProperty2.default)({}, sessionId, true))));
59
- }
60
- };
61
- // delete this function when cleaning up platform_editor_remove_collab_step_metrics
62
- /**
63
- * Updates the step session metrics in local storage for a given session ID.
64
- * It calculates the metrics based on the provided steps and updates the storage.
65
- *
66
- * @param api - The API to access the collab edit plugin.
67
- * @param steps - The steps to calculate the metrics from.
68
- * @return void
69
- */
70
- var updateNcsSessionStepMetrics = exports.updateNcsSessionStepMetrics = function updateNcsSessionStepMetrics(_ref) {
71
- var _api$collabEdit;
72
- var api = _ref.api,
73
- steps = _ref.steps;
74
- var sessionId = api === null || api === void 0 || (_api$collabEdit = api.collabEdit) === null || _api$collabEdit === void 0 || (_api$collabEdit = _api$collabEdit.sharedState.currentState()) === null || _api$collabEdit === void 0 ? void 0 : _api$collabEdit.sessionId;
75
- if (!sessionId) {
76
- return;
77
- }
78
- var existingMetrics = JSON.parse(storageClient.getItem(_ncsStepMetrics.NCS_STORAGE.NCS_SESSION_STEP_METRICS) || '{}');
79
- var ncsSessionStepMetrics = getNcsSessionStepMetrics(existingMetrics, sessionId, steps);
80
- storageClient.setItemWithExpiry(_ncsStepMetrics.NCS_STORAGE.NCS_SESSION_STEP_METRICS, JSON.stringify(_objectSpread(_objectSpread({}, existingMetrics), {}, (0, _defineProperty2.default)({}, sessionId, ncsSessionStepMetrics))));
81
- updateNcsActiveSessions(sessionId);
82
- };
@@ -1,79 +0,0 @@
1
- import { NCS_STORAGE } from '@atlaskit/editor-common/ncs-step-metrics';
2
- import { StorageClient } from '@atlaskit/frontend-utilities/StorageClient';
3
- const storageClient = new StorageClient(NCS_STORAGE.NCS_STORAGE_CLIENT_KEY);
4
-
5
- /**
6
- * Gets the current step session metrics for a given session ID
7
- * If the session ID does not exist, it initializes a new metrics object.
8
- * It calculates the total size of the steps, the number of steps,
9
- * the maximum step size, and the sum of step sizes for P90 calculation.
10
- *
11
- * @param metrics - The existing metrics object from local storage.
12
- * @param sessionId - The session ID for which to get the metrics.
13
- * @param steps - The steps to calculate the metrics from.
14
- * @returns The updated step session metrics for the given session ID.
15
- */
16
- export const getNcsSessionStepMetrics = (metrics, sessionId, steps) => {
17
- var _metrics$sessionId;
18
- const current = (_metrics$sessionId = metrics[sessionId]) !== null && _metrics$sessionId !== void 0 ? _metrics$sessionId : {
19
- ncsSessionId: sessionId,
20
- totalStepSize: 0,
21
- numberOfSteps: 0,
22
- maxStepSize: 0,
23
- stepSizeSumForP90: []
24
- };
25
- steps.forEach(step => {
26
- const stepSize = JSON.stringify(step).length;
27
- current.totalStepSize += stepSize;
28
- current.numberOfSteps += 1;
29
- current.maxStepSize = Math.max(current.maxStepSize, stepSize || 0);
30
- current.stepSizeSumForP90.push(stepSize || 0);
31
- });
32
- return current;
33
- };
34
-
35
- /**
36
- * Gets the current active sessions from local storage
37
- * If the session ID does not exist, it initializes a new active session.
38
- *
39
- * This is used in the ncsStepMetricsPlugin to determine if the session is still active
40
- * before sending the ncs steps analytics event.
41
- *
42
- * @param sessionId - The session ID to check or update in local storage.
43
- * @returns void
44
- */
45
- export const updateNcsActiveSessions = sessionId => {
46
- const currentActiveSessions = JSON.parse(storageClient.getItem(NCS_STORAGE.NCS_ACTIVE_SESSIONS) || '{}');
47
- if (!currentActiveSessions[sessionId]) {
48
- storageClient.setItemWithExpiry(NCS_STORAGE.NCS_ACTIVE_SESSIONS, JSON.stringify({
49
- ...currentActiveSessions,
50
- [sessionId]: true
51
- }));
52
- }
53
- };
54
- // delete this function when cleaning up platform_editor_remove_collab_step_metrics
55
- /**
56
- * Updates the step session metrics in local storage for a given session ID.
57
- * It calculates the metrics based on the provided steps and updates the storage.
58
- *
59
- * @param api - The API to access the collab edit plugin.
60
- * @param steps - The steps to calculate the metrics from.
61
- * @return void
62
- */
63
- export const updateNcsSessionStepMetrics = ({
64
- api,
65
- steps
66
- }) => {
67
- var _api$collabEdit, _api$collabEdit$share;
68
- const sessionId = api === null || api === void 0 ? void 0 : (_api$collabEdit = api.collabEdit) === null || _api$collabEdit === void 0 ? void 0 : (_api$collabEdit$share = _api$collabEdit.sharedState.currentState()) === null || _api$collabEdit$share === void 0 ? void 0 : _api$collabEdit$share.sessionId;
69
- if (!sessionId) {
70
- return;
71
- }
72
- const existingMetrics = JSON.parse(storageClient.getItem(NCS_STORAGE.NCS_SESSION_STEP_METRICS) || '{}');
73
- const ncsSessionStepMetrics = getNcsSessionStepMetrics(existingMetrics, sessionId, steps);
74
- storageClient.setItemWithExpiry(NCS_STORAGE.NCS_SESSION_STEP_METRICS, JSON.stringify({
75
- ...existingMetrics,
76
- [sessionId]: ncsSessionStepMetrics
77
- }));
78
- updateNcsActiveSessions(sessionId);
79
- };
@@ -1,75 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
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
- 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
- import { NCS_STORAGE } from '@atlaskit/editor-common/ncs-step-metrics';
5
- import { StorageClient } from '@atlaskit/frontend-utilities/StorageClient';
6
- var storageClient = new StorageClient(NCS_STORAGE.NCS_STORAGE_CLIENT_KEY);
7
-
8
- /**
9
- * Gets the current step session metrics for a given session ID
10
- * If the session ID does not exist, it initializes a new metrics object.
11
- * It calculates the total size of the steps, the number of steps,
12
- * the maximum step size, and the sum of step sizes for P90 calculation.
13
- *
14
- * @param metrics - The existing metrics object from local storage.
15
- * @param sessionId - The session ID for which to get the metrics.
16
- * @param steps - The steps to calculate the metrics from.
17
- * @returns The updated step session metrics for the given session ID.
18
- */
19
- export var getNcsSessionStepMetrics = function getNcsSessionStepMetrics(metrics, sessionId, steps) {
20
- var _metrics$sessionId;
21
- var current = (_metrics$sessionId = metrics[sessionId]) !== null && _metrics$sessionId !== void 0 ? _metrics$sessionId : {
22
- ncsSessionId: sessionId,
23
- totalStepSize: 0,
24
- numberOfSteps: 0,
25
- maxStepSize: 0,
26
- stepSizeSumForP90: []
27
- };
28
- steps.forEach(function (step) {
29
- var stepSize = JSON.stringify(step).length;
30
- current.totalStepSize += stepSize;
31
- current.numberOfSteps += 1;
32
- current.maxStepSize = Math.max(current.maxStepSize, stepSize || 0);
33
- current.stepSizeSumForP90.push(stepSize || 0);
34
- });
35
- return current;
36
- };
37
-
38
- /**
39
- * Gets the current active sessions from local storage
40
- * If the session ID does not exist, it initializes a new active session.
41
- *
42
- * This is used in the ncsStepMetricsPlugin to determine if the session is still active
43
- * before sending the ncs steps analytics event.
44
- *
45
- * @param sessionId - The session ID to check or update in local storage.
46
- * @returns void
47
- */
48
- export var updateNcsActiveSessions = function updateNcsActiveSessions(sessionId) {
49
- var currentActiveSessions = JSON.parse(storageClient.getItem(NCS_STORAGE.NCS_ACTIVE_SESSIONS) || '{}');
50
- if (!currentActiveSessions[sessionId]) {
51
- storageClient.setItemWithExpiry(NCS_STORAGE.NCS_ACTIVE_SESSIONS, JSON.stringify(_objectSpread(_objectSpread({}, currentActiveSessions), {}, _defineProperty({}, sessionId, true))));
52
- }
53
- };
54
- // delete this function when cleaning up platform_editor_remove_collab_step_metrics
55
- /**
56
- * Updates the step session metrics in local storage for a given session ID.
57
- * It calculates the metrics based on the provided steps and updates the storage.
58
- *
59
- * @param api - The API to access the collab edit plugin.
60
- * @param steps - The steps to calculate the metrics from.
61
- * @return void
62
- */
63
- export var updateNcsSessionStepMetrics = function updateNcsSessionStepMetrics(_ref) {
64
- var _api$collabEdit;
65
- var api = _ref.api,
66
- steps = _ref.steps;
67
- var sessionId = api === null || api === void 0 || (_api$collabEdit = api.collabEdit) === null || _api$collabEdit === void 0 || (_api$collabEdit = _api$collabEdit.sharedState.currentState()) === null || _api$collabEdit === void 0 ? void 0 : _api$collabEdit.sessionId;
68
- if (!sessionId) {
69
- return;
70
- }
71
- var existingMetrics = JSON.parse(storageClient.getItem(NCS_STORAGE.NCS_SESSION_STEP_METRICS) || '{}');
72
- var ncsSessionStepMetrics = getNcsSessionStepMetrics(existingMetrics, sessionId, steps);
73
- storageClient.setItemWithExpiry(NCS_STORAGE.NCS_SESSION_STEP_METRICS, JSON.stringify(_objectSpread(_objectSpread({}, existingMetrics), {}, _defineProperty({}, sessionId, ncsSessionStepMetrics))));
74
- updateNcsActiveSessions(sessionId);
75
- };
@@ -1,48 +0,0 @@
1
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
- import type { Step } from '@atlaskit/editor-prosemirror/transform-override';
3
- import type { CollabEditPlugin } from '../collabEditPluginType';
4
- type StepSessionMetrics = {
5
- maxStepSize: number;
6
- numberOfSteps: number;
7
- stepSizeSumForP90: number[];
8
- totalStepSize: number;
9
- };
10
- /**
11
- * Gets the current step session metrics for a given session ID
12
- * If the session ID does not exist, it initializes a new metrics object.
13
- * It calculates the total size of the steps, the number of steps,
14
- * the maximum step size, and the sum of step sizes for P90 calculation.
15
- *
16
- * @param metrics - The existing metrics object from local storage.
17
- * @param sessionId - The session ID for which to get the metrics.
18
- * @param steps - The steps to calculate the metrics from.
19
- * @returns The updated step session metrics for the given session ID.
20
- */
21
- export declare const getNcsSessionStepMetrics: (metrics: {
22
- [sessionId: string]: StepSessionMetrics;
23
- }, sessionId: string, steps: Step[]) => StepSessionMetrics;
24
- /**
25
- * Gets the current active sessions from local storage
26
- * If the session ID does not exist, it initializes a new active session.
27
- *
28
- * This is used in the ncsStepMetricsPlugin to determine if the session is still active
29
- * before sending the ncs steps analytics event.
30
- *
31
- * @param sessionId - The session ID to check or update in local storage.
32
- * @returns void
33
- */
34
- export declare const updateNcsActiveSessions: (sessionId: string) => void;
35
- type UpdateNcsSessionStepMetricProps = {
36
- api: ExtractInjectionAPI<CollabEditPlugin> | undefined;
37
- steps: Step[];
38
- };
39
- /**
40
- * Updates the step session metrics in local storage for a given session ID.
41
- * It calculates the metrics based on the provided steps and updates the storage.
42
- *
43
- * @param api - The API to access the collab edit plugin.
44
- * @param steps - The steps to calculate the metrics from.
45
- * @return void
46
- */
47
- export declare const updateNcsSessionStepMetrics: ({ api, steps, }: UpdateNcsSessionStepMetricProps) => void;
48
- export {};