@atlaskit/editor-plugin-extension 1.1.7 → 1.1.8

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,12 @@
1
1
  # @atlaskit/editor-plugin-extension
2
2
 
3
+ ## 1.1.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#87119](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87119) [`0cea7cb799c3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0cea7cb799c3) - [EDF-462] Add analytics for AI Blocks
8
+ - Updated dependencies
9
+
3
10
  ## 1.1.7
4
11
 
5
12
  ### Patch Changes
@@ -4,13 +4,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.removeExtension = exports.removeDescendantNodes = exports.forceAutoSave = exports.clearEditingContext = exports.checkAndRemoveExtensionNode = void 0;
7
+ exports.removeSelectedNodeWithAnalytics = exports.removeExtension = exports.removeDescendantNodes = exports.forceAutoSave = exports.clearEditingContext = exports.checkAndRemoveExtensionNode = void 0;
8
8
  exports.setEditingContextToContextPanel = setEditingContextToContextPanel;
9
9
  exports.updateExtensionLayout = void 0;
10
10
  exports.updateState = updateState;
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _utils = require("@atlaskit/editor-common/utils");
14
+ var _state = require("@atlaskit/editor-prosemirror/state");
14
15
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
15
16
  var _pluginFactory = require("./plugin-factory");
16
17
  var _utils3 = require("./utils");
@@ -82,7 +83,7 @@ var removeExtension = exports.removeExtension = function removeExtension(editorA
82
83
  }
83
84
  }, function (tr, state) {
84
85
  if ((0, _utils3.getSelectedExtension)(state)) {
85
- return (0, _utils2.removeSelectedNode)(tr);
86
+ return removeSelectedNodeWithAnalytics(state, tr, editorAnalyticsAPI);
86
87
  } else {
87
88
  return checkAndRemoveExtensionNode(state, tr, editorAnalyticsAPI);
88
89
  }
@@ -98,6 +99,25 @@ var removeDescendantNodes = exports.removeDescendantNodes = function removeDesce
98
99
  return sourceNode ? (0, _utils.removeConnectedNodes)(state, sourceNode) : tr;
99
100
  });
100
101
  };
102
+ var removeSelectedNodeWithAnalytics = exports.removeSelectedNodeWithAnalytics = function removeSelectedNodeWithAnalytics(state, tr, analyticsApi) {
103
+ if (state.selection instanceof _state.NodeSelection) {
104
+ var node = state.selection.node;
105
+ if (analyticsApi) {
106
+ analyticsApi.attachAnalyticsEvent({
107
+ action: _analytics.ACTION.DELETED,
108
+ actionSubject: _analytics.ACTION_SUBJECT.EXTENSION,
109
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.EXTENSION,
110
+ eventType: _analytics.EVENT_TYPE.TRACK,
111
+ attributes: {
112
+ extensionType: node.attrs.extensionType,
113
+ extensionKey: node.attrs.extensionKey,
114
+ localId: node.attrs.localId
115
+ }
116
+ })(tr);
117
+ }
118
+ }
119
+ return (0, _utils2.removeSelectedNode)(tr);
120
+ };
101
121
  var checkAndRemoveExtensionNode = exports.checkAndRemoveExtensionNode = function checkAndRemoveExtensionNode(state, tr, analyticsApi) {
102
122
  var nodeType = state.schema.nodes.bodiedExtension;
103
123
  var maybeMBENode = (0, _utils2.findParentNodeOfType)(state.schema.nodes.multiBodiedExtension)(state.selection);
@@ -117,5 +137,21 @@ var checkAndRemoveExtensionNode = exports.checkAndRemoveExtensionNode = function
117
137
  })(tr);
118
138
  }
119
139
  }
140
+ var bodiedExtensionNode = (0, _utils2.findParentNodeOfType)(state.schema.nodes.bodiedExtension)(state.selection);
141
+ if (bodiedExtensionNode) {
142
+ if (analyticsApi) {
143
+ analyticsApi.attachAnalyticsEvent({
144
+ action: _analytics.ACTION.DELETED,
145
+ actionSubject: _analytics.ACTION_SUBJECT.EXTENSION,
146
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.EXTENSION_BODIED,
147
+ eventType: _analytics.EVENT_TYPE.TRACK,
148
+ attributes: {
149
+ extensionType: bodiedExtensionNode.node.attrs.extensionType,
150
+ extensionKey: bodiedExtensionNode.node.attrs.extensionKey,
151
+ localId: bodiedExtensionNode.node.attrs.localId
152
+ }
153
+ })(tr);
154
+ }
155
+ }
120
156
  return (0, _utils2.removeParentNodeOfType)(nodeType)(tr);
121
157
  };
@@ -1,5 +1,6 @@
1
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
2
  import { removeConnectedNodes } from '@atlaskit/editor-common/utils';
3
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { findParentNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
4
5
  import { createCommand } from './plugin-factory';
5
6
  import { getSelectedExtension } from './utils';
@@ -62,7 +63,7 @@ export const removeExtension = editorAnalyticsAPI => createCommand({
62
63
  }
63
64
  }, (tr, state) => {
64
65
  if (getSelectedExtension(state)) {
65
- return removeSelectedNode(tr);
66
+ return removeSelectedNodeWithAnalytics(state, tr, editorAnalyticsAPI);
66
67
  } else {
67
68
  return checkAndRemoveExtensionNode(state, tr, editorAnalyticsAPI);
68
69
  }
@@ -75,6 +76,25 @@ export const removeDescendantNodes = sourceNode => createCommand({
75
76
  }, (tr, state) => {
76
77
  return sourceNode ? removeConnectedNodes(state, sourceNode) : tr;
77
78
  });
79
+ export const removeSelectedNodeWithAnalytics = (state, tr, analyticsApi) => {
80
+ if (state.selection instanceof NodeSelection) {
81
+ const node = state.selection.node;
82
+ if (analyticsApi) {
83
+ analyticsApi.attachAnalyticsEvent({
84
+ action: ACTION.DELETED,
85
+ actionSubject: ACTION_SUBJECT.EXTENSION,
86
+ actionSubjectId: ACTION_SUBJECT_ID.EXTENSION,
87
+ eventType: EVENT_TYPE.TRACK,
88
+ attributes: {
89
+ extensionType: node.attrs.extensionType,
90
+ extensionKey: node.attrs.extensionKey,
91
+ localId: node.attrs.localId
92
+ }
93
+ })(tr);
94
+ }
95
+ }
96
+ return removeSelectedNode(tr);
97
+ };
78
98
  export const checkAndRemoveExtensionNode = (state, tr, analyticsApi) => {
79
99
  let nodeType = state.schema.nodes.bodiedExtension;
80
100
  const maybeMBENode = findParentNodeOfType(state.schema.nodes.multiBodiedExtension)(state.selection);
@@ -94,5 +114,21 @@ export const checkAndRemoveExtensionNode = (state, tr, analyticsApi) => {
94
114
  })(tr);
95
115
  }
96
116
  }
117
+ const bodiedExtensionNode = findParentNodeOfType(state.schema.nodes.bodiedExtension)(state.selection);
118
+ if (bodiedExtensionNode) {
119
+ if (analyticsApi) {
120
+ analyticsApi.attachAnalyticsEvent({
121
+ action: ACTION.DELETED,
122
+ actionSubject: ACTION_SUBJECT.EXTENSION,
123
+ actionSubjectId: ACTION_SUBJECT_ID.EXTENSION_BODIED,
124
+ eventType: EVENT_TYPE.TRACK,
125
+ attributes: {
126
+ extensionType: bodiedExtensionNode.node.attrs.extensionType,
127
+ extensionKey: bodiedExtensionNode.node.attrs.extensionKey,
128
+ localId: bodiedExtensionNode.node.attrs.localId
129
+ }
130
+ })(tr);
131
+ }
132
+ }
97
133
  return removeParentNodeOfType(nodeType)(tr);
98
134
  };
@@ -1,8 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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
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 { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
4
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
5
5
  import { removeConnectedNodes } from '@atlaskit/editor-common/utils';
6
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
6
7
  import { findParentNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
7
8
  import { createCommand } from './plugin-factory';
8
9
  import { getSelectedExtension } from './utils';
@@ -73,7 +74,7 @@ export var removeExtension = function removeExtension(editorAnalyticsAPI) {
73
74
  }
74
75
  }, function (tr, state) {
75
76
  if (getSelectedExtension(state)) {
76
- return removeSelectedNode(tr);
77
+ return removeSelectedNodeWithAnalytics(state, tr, editorAnalyticsAPI);
77
78
  } else {
78
79
  return checkAndRemoveExtensionNode(state, tr, editorAnalyticsAPI);
79
80
  }
@@ -89,6 +90,25 @@ export var removeDescendantNodes = function removeDescendantNodes(sourceNode) {
89
90
  return sourceNode ? removeConnectedNodes(state, sourceNode) : tr;
90
91
  });
91
92
  };
93
+ export var removeSelectedNodeWithAnalytics = function removeSelectedNodeWithAnalytics(state, tr, analyticsApi) {
94
+ if (state.selection instanceof NodeSelection) {
95
+ var node = state.selection.node;
96
+ if (analyticsApi) {
97
+ analyticsApi.attachAnalyticsEvent({
98
+ action: ACTION.DELETED,
99
+ actionSubject: ACTION_SUBJECT.EXTENSION,
100
+ actionSubjectId: ACTION_SUBJECT_ID.EXTENSION,
101
+ eventType: EVENT_TYPE.TRACK,
102
+ attributes: {
103
+ extensionType: node.attrs.extensionType,
104
+ extensionKey: node.attrs.extensionKey,
105
+ localId: node.attrs.localId
106
+ }
107
+ })(tr);
108
+ }
109
+ }
110
+ return removeSelectedNode(tr);
111
+ };
92
112
  export var checkAndRemoveExtensionNode = function checkAndRemoveExtensionNode(state, tr, analyticsApi) {
93
113
  var nodeType = state.schema.nodes.bodiedExtension;
94
114
  var maybeMBENode = findParentNodeOfType(state.schema.nodes.multiBodiedExtension)(state.selection);
@@ -108,5 +128,21 @@ export var checkAndRemoveExtensionNode = function checkAndRemoveExtensionNode(st
108
128
  })(tr);
109
129
  }
110
130
  }
131
+ var bodiedExtensionNode = findParentNodeOfType(state.schema.nodes.bodiedExtension)(state.selection);
132
+ if (bodiedExtensionNode) {
133
+ if (analyticsApi) {
134
+ analyticsApi.attachAnalyticsEvent({
135
+ action: ACTION.DELETED,
136
+ actionSubject: ACTION_SUBJECT.EXTENSION,
137
+ actionSubjectId: ACTION_SUBJECT_ID.EXTENSION_BODIED,
138
+ eventType: EVENT_TYPE.TRACK,
139
+ attributes: {
140
+ extensionType: bodiedExtensionNode.node.attrs.extensionType,
141
+ extensionKey: bodiedExtensionNode.node.attrs.extensionKey,
142
+ localId: bodiedExtensionNode.node.attrs.localId
143
+ }
144
+ })(tr);
145
+ }
146
+ }
111
147
  return removeParentNodeOfType(nodeType)(tr);
112
148
  };
@@ -3,7 +3,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { Parameters, TransformAfter, TransformBefore } from '@atlaskit/editor-common/extensions';
4
4
  import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
5
5
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
6
- import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
6
+ import { type EditorState, type Transaction } from '@atlaskit/editor-prosemirror/state';
7
7
  import type { ExtensionState, RejectSave } from './types';
8
8
  export declare function updateState(state: Partial<ExtensionState>): import("@atlaskit/editor-common/types").Command;
9
9
  export declare function setEditingContextToContextPanel<T extends Parameters = Parameters>(processParametersBefore: TransformBefore<T>, processParametersAfter: TransformAfter<T>, applyChangeToContextPanel: ApplyChangeHandler | undefined): import("@atlaskit/editor-common/types").Command;
@@ -12,4 +12,5 @@ export declare const forceAutoSave: (applyChangeToContextPanel: ApplyChangeHandl
12
12
  export declare const updateExtensionLayout: (layout: ExtensionLayout) => import("@atlaskit/editor-common/types").Command;
13
13
  export declare const removeExtension: (editorAnalyticsAPI?: EditorAnalyticsAPI) => import("@atlaskit/editor-common/types").Command;
14
14
  export declare const removeDescendantNodes: (sourceNode?: PMNode) => import("@atlaskit/editor-common/types").Command;
15
+ export declare const removeSelectedNodeWithAnalytics: (state: EditorState, tr: Transaction, analyticsApi?: EditorAnalyticsAPI) => Transaction;
15
16
  export declare const checkAndRemoveExtensionNode: (state: EditorState, tr: Transaction, analyticsApi?: EditorAnalyticsAPI) => Transaction;
@@ -3,7 +3,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { Parameters, TransformAfter, TransformBefore } from '@atlaskit/editor-common/extensions';
4
4
  import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
5
5
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
6
- import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
6
+ import { type EditorState, type Transaction } from '@atlaskit/editor-prosemirror/state';
7
7
  import type { ExtensionState, RejectSave } from './types';
8
8
  export declare function updateState(state: Partial<ExtensionState>): import("@atlaskit/editor-common/types").Command;
9
9
  export declare function setEditingContextToContextPanel<T extends Parameters = Parameters>(processParametersBefore: TransformBefore<T>, processParametersAfter: TransformAfter<T>, applyChangeToContextPanel: ApplyChangeHandler | undefined): import("@atlaskit/editor-common/types").Command;
@@ -12,4 +12,5 @@ export declare const forceAutoSave: (applyChangeToContextPanel: ApplyChangeHandl
12
12
  export declare const updateExtensionLayout: (layout: ExtensionLayout) => import("@atlaskit/editor-common/types").Command;
13
13
  export declare const removeExtension: (editorAnalyticsAPI?: EditorAnalyticsAPI) => import("@atlaskit/editor-common/types").Command;
14
14
  export declare const removeDescendantNodes: (sourceNode?: PMNode) => import("@atlaskit/editor-common/types").Command;
15
+ export declare const removeSelectedNodeWithAnalytics: (state: EditorState, tr: Transaction, analyticsApi?: EditorAnalyticsAPI) => Transaction;
15
16
  export declare const checkAndRemoveExtensionNode: (state: EditorState, tr: Transaction, analyticsApi?: EditorAnalyticsAPI) => Transaction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-extension",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "editor-plugin-extension plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -42,7 +42,7 @@
42
42
  "@atlaskit/editor-prosemirror": "3.0.0",
43
43
  "@atlaskit/editor-shared-styles": "^2.9.0",
44
44
  "@atlaskit/editor-tables": "^2.6.0",
45
- "@atlaskit/empty-state": "^7.7.0",
45
+ "@atlaskit/empty-state": "^7.8.0",
46
46
  "@atlaskit/form": "^9.2.0",
47
47
  "@atlaskit/icon": "^22.1.0",
48
48
  "@atlaskit/platform-feature-flags": "^0.2.0",