@atlaskit/editor-common 74.7.1 → 74.7.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,17 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 74.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1259df9a9ef`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1259df9a9ef) - converted some of block-type's analytics to use new EditorAnalyticsAPI
8
+
9
+ ## 74.7.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`b9c2562b357`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b9c2562b357) - Mark WithPluginState as deprecated.
14
+
3
15
  ## 74.7.1
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "withAnalytics", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _withAnalytics.withAnalytics;
10
+ }
11
+ });
12
+ var _withAnalytics = require("./withAnalytics");
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withAnalytics = withAnalytics;
7
+ /**
8
+ * Callback accepts EditorState
9
+ *
10
+ * @remarks
11
+ * The plugin using the Analytics may using an Optional<Analytics> dependency
12
+ * It can be undefined during testing, we may not have included analytics
13
+ * Also in cases where Analytics fails to load, the editor doesn't crash.
14
+ *
15
+ * @param state - EditorState, passed to the callback
16
+ */
17
+
18
+ /**
19
+ * Analytics API
20
+ * @example
21
+ * ```
22
+ * withAnalytics({
23
+ * eventType: EVENT_TYPE.TRACK,
24
+ * action: ACTION.REPLACED_ONE,
25
+ * actionSubject: ACTION_SUBJECT.TEXT,
26
+ * attributes: {
27
+ * triggerMethod,
28
+ * },
29
+ * })(replace(replaceText))
30
+ * ```
31
+ *
32
+ * @param analyticsApi - EditorAnalyticsAPI, undefined in tests or if analytics fails to load
33
+ * @param payload - AnalyticsEventPayload | AnalyticsEventPayloadCallback - payload to be attached to the transaction
34
+ * @param channel - string - channel to be used for analytics
35
+ */
36
+ function withAnalytics(analyticsApi, payload, channel) {
37
+ return function (command) {
38
+ return function (state, dispatch, view) {
39
+ return command(state, function (tr) {
40
+ if (dispatch) {
41
+ if (payload instanceof Function) {
42
+ var dynamicPayload = payload(state);
43
+ if (dynamicPayload) {
44
+ analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent(dynamicPayload, channel)(tr);
45
+ dispatch(tr);
46
+ }
47
+ } else {
48
+ analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent(payload, channel)(tr);
49
+ dispatch(tr);
50
+ }
51
+ }
52
+ }, view);
53
+ };
54
+ };
55
+ }
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "74.7.1";
19
+ var packageVersion = "74.7.3";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // TODO: Sanitise the URL instead of just removing it
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
24
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
25
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "74.7.1";
27
+ var packageVersion = "74.7.3";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.7.1",
3
+ "version": "74.7.3",
4
4
  "sideEffects": false
5
5
  }
@@ -30,20 +30,40 @@ var DEFAULT_SLOW_THRESHOLD = 4;
30
30
  // - EditorAction: packages/editor/editor-core/src/actions/index.ts
31
31
  // - EditorSharedConfig: packages/editor/editor-core/src/labs/next/internal/context/shared-config.tsx
32
32
  /**
33
- * Wraps component in a high order component that watches state changes of given plugins
34
- * and passes those states to the wrapped component.
33
+ * @private
34
+ * @deprecated
35
35
  *
36
- * Example:
36
+ * Using this component is deprecated. It should be replaced with `useSharedPluginState`.
37
+ * This requires having access to the injection API from the plugin itself.
38
+ *
39
+ * An example of the refactor with the new hook (using hyperlink as an example) is:
40
+ *
41
+ * Before:
42
+ * ```ts
37
43
  * <WithPluginState
38
- * eventDispatcher={eventDispatcher}
39
44
  * editorView={editorView}
40
45
  * plugins={{
41
- * hyperlink: hyperlinkPluginKey
46
+ * hyperlinkState: hyperlinkPluginKey
42
47
  * }}
43
- * render={renderComponent}
48
+ * render={({ hyperlinkState }) =>
49
+ * renderComponent({ hyperlinkState })
50
+ * }
44
51
  * />
52
+ * ```
53
+ *
54
+ * After:
55
+ * ```ts
56
+ * import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
57
+ * import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
58
+ *
59
+ * function ComponentWithState(
60
+ * api: ExtractInjectionAPI<typeof hyperlinkPlugin> | undefined
61
+ * ) {
62
+ * const { hyperlinkState } = useSharedPluginState(api, ['hyperlink']);
63
+ * return renderComponent({ hyperlinkState })
64
+ * }
65
+ * ```
45
66
  *
46
- * renderComponent: ({ hyperlink }) => React.Component;
47
67
  */
48
68
  var WithPluginState = /*#__PURE__*/function (_React$Component) {
49
69
  (0, _inherits2.default)(WithPluginState, _React$Component);
@@ -0,0 +1 @@
1
+ export { withAnalytics } from './withAnalytics';
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Callback accepts EditorState
3
+ *
4
+ * @remarks
5
+ * The plugin using the Analytics may using an Optional<Analytics> dependency
6
+ * It can be undefined during testing, we may not have included analytics
7
+ * Also in cases where Analytics fails to load, the editor doesn't crash.
8
+ *
9
+ * @param state - EditorState, passed to the callback
10
+ */
11
+
12
+ /**
13
+ * Analytics API
14
+ * @example
15
+ * ```
16
+ * withAnalytics({
17
+ * eventType: EVENT_TYPE.TRACK,
18
+ * action: ACTION.REPLACED_ONE,
19
+ * actionSubject: ACTION_SUBJECT.TEXT,
20
+ * attributes: {
21
+ * triggerMethod,
22
+ * },
23
+ * })(replace(replaceText))
24
+ * ```
25
+ *
26
+ * @param analyticsApi - EditorAnalyticsAPI, undefined in tests or if analytics fails to load
27
+ * @param payload - AnalyticsEventPayload | AnalyticsEventPayloadCallback - payload to be attached to the transaction
28
+ * @param channel - string - channel to be used for analytics
29
+ */
30
+ export function withAnalytics(analyticsApi, payload, channel) {
31
+ return command => (state, dispatch, view) => command(state, tr => {
32
+ if (dispatch) {
33
+ if (payload instanceof Function) {
34
+ const dynamicPayload = payload(state);
35
+ if (dynamicPayload) {
36
+ analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent(dynamicPayload, channel)(tr);
37
+ dispatch(tr);
38
+ }
39
+ } else {
40
+ analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent(payload, channel)(tr);
41
+ dispatch(tr);
42
+ }
43
+ }
44
+ }, view);
45
+ }
@@ -1,6 +1,6 @@
1
1
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
2
2
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
3
- const packageVersion = "74.7.1";
3
+ const packageVersion = "74.7.3";
4
4
  const sanitiseSentryEvents = (data, _hint) => {
5
5
  // Remove URL as it has UGC
6
6
  // TODO: Sanitise the URL instead of just removing it
@@ -8,7 +8,7 @@ import { themed } from '@atlaskit/theme/components';
8
8
  import { borderRadius } from '@atlaskit/theme/constants';
9
9
  import Layer from '../Layer';
10
10
  const packageName = "@atlaskit/editor-common";
11
- const packageVersion = "74.7.1";
11
+ const packageVersion = "74.7.3";
12
12
  const halfFocusRing = 1;
13
13
  const dropOffset = '0, 8';
14
14
  class DropList extends Component {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.7.1",
3
+ "version": "74.7.3",
4
4
  "sideEffects": false
5
5
  }
@@ -13,20 +13,40 @@ const DEFAULT_SLOW_THRESHOLD = 4;
13
13
  // - EditorAction: packages/editor/editor-core/src/actions/index.ts
14
14
  // - EditorSharedConfig: packages/editor/editor-core/src/labs/next/internal/context/shared-config.tsx
15
15
  /**
16
- * Wraps component in a high order component that watches state changes of given plugins
17
- * and passes those states to the wrapped component.
16
+ * @private
17
+ * @deprecated
18
18
  *
19
- * Example:
19
+ * Using this component is deprecated. It should be replaced with `useSharedPluginState`.
20
+ * This requires having access to the injection API from the plugin itself.
21
+ *
22
+ * An example of the refactor with the new hook (using hyperlink as an example) is:
23
+ *
24
+ * Before:
25
+ * ```ts
20
26
  * <WithPluginState
21
- * eventDispatcher={eventDispatcher}
22
27
  * editorView={editorView}
23
28
  * plugins={{
24
- * hyperlink: hyperlinkPluginKey
29
+ * hyperlinkState: hyperlinkPluginKey
25
30
  * }}
26
- * render={renderComponent}
31
+ * render={({ hyperlinkState }) =>
32
+ * renderComponent({ hyperlinkState })
33
+ * }
27
34
  * />
35
+ * ```
36
+ *
37
+ * After:
38
+ * ```ts
39
+ * import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
40
+ * import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
41
+ *
42
+ * function ComponentWithState(
43
+ * api: ExtractInjectionAPI<typeof hyperlinkPlugin> | undefined
44
+ * ) {
45
+ * const { hyperlinkState } = useSharedPluginState(api, ['hyperlink']);
46
+ * return renderComponent({ hyperlinkState })
47
+ * }
48
+ * ```
28
49
  *
29
- * renderComponent: ({ hyperlink }) => React.Component;
30
50
  */
31
51
  class WithPluginState extends React.Component {
32
52
  constructor(...args) {
@@ -0,0 +1 @@
1
+ export { withAnalytics } from './withAnalytics';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Callback accepts EditorState
3
+ *
4
+ * @remarks
5
+ * The plugin using the Analytics may using an Optional<Analytics> dependency
6
+ * It can be undefined during testing, we may not have included analytics
7
+ * Also in cases where Analytics fails to load, the editor doesn't crash.
8
+ *
9
+ * @param state - EditorState, passed to the callback
10
+ */
11
+
12
+ /**
13
+ * Analytics API
14
+ * @example
15
+ * ```
16
+ * withAnalytics({
17
+ * eventType: EVENT_TYPE.TRACK,
18
+ * action: ACTION.REPLACED_ONE,
19
+ * actionSubject: ACTION_SUBJECT.TEXT,
20
+ * attributes: {
21
+ * triggerMethod,
22
+ * },
23
+ * })(replace(replaceText))
24
+ * ```
25
+ *
26
+ * @param analyticsApi - EditorAnalyticsAPI, undefined in tests or if analytics fails to load
27
+ * @param payload - AnalyticsEventPayload | AnalyticsEventPayloadCallback - payload to be attached to the transaction
28
+ * @param channel - string - channel to be used for analytics
29
+ */
30
+ export function withAnalytics(analyticsApi, payload, channel) {
31
+ return function (command) {
32
+ return function (state, dispatch, view) {
33
+ return command(state, function (tr) {
34
+ if (dispatch) {
35
+ if (payload instanceof Function) {
36
+ var dynamicPayload = payload(state);
37
+ if (dynamicPayload) {
38
+ analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent(dynamicPayload, channel)(tr);
39
+ dispatch(tr);
40
+ }
41
+ } else {
42
+ analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent(payload, channel)(tr);
43
+ dispatch(tr);
44
+ }
45
+ }
46
+ }, view);
47
+ };
48
+ };
49
+ }
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
7
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
8
8
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
9
- var packageVersion = "74.7.1";
9
+ var packageVersion = "74.7.3";
10
10
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
11
11
  // Remove URL as it has UGC
12
12
  // TODO: Sanitise the URL instead of just removing it
@@ -18,7 +18,7 @@ import { themed } from '@atlaskit/theme/components';
18
18
  import { borderRadius } from '@atlaskit/theme/constants';
19
19
  import Layer from '../Layer';
20
20
  var packageName = "@atlaskit/editor-common";
21
- var packageVersion = "74.7.1";
21
+ var packageVersion = "74.7.3";
22
22
  var halfFocusRing = 1;
23
23
  var dropOffset = '0, 8';
24
24
  var DropList = /*#__PURE__*/function (_Component) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.7.1",
3
+ "version": "74.7.3",
4
4
  "sideEffects": false
5
5
  }
@@ -23,20 +23,40 @@ var DEFAULT_SLOW_THRESHOLD = 4;
23
23
  // - EditorAction: packages/editor/editor-core/src/actions/index.ts
24
24
  // - EditorSharedConfig: packages/editor/editor-core/src/labs/next/internal/context/shared-config.tsx
25
25
  /**
26
- * Wraps component in a high order component that watches state changes of given plugins
27
- * and passes those states to the wrapped component.
26
+ * @private
27
+ * @deprecated
28
28
  *
29
- * Example:
29
+ * Using this component is deprecated. It should be replaced with `useSharedPluginState`.
30
+ * This requires having access to the injection API from the plugin itself.
31
+ *
32
+ * An example of the refactor with the new hook (using hyperlink as an example) is:
33
+ *
34
+ * Before:
35
+ * ```ts
30
36
  * <WithPluginState
31
- * eventDispatcher={eventDispatcher}
32
37
  * editorView={editorView}
33
38
  * plugins={{
34
- * hyperlink: hyperlinkPluginKey
39
+ * hyperlinkState: hyperlinkPluginKey
35
40
  * }}
36
- * render={renderComponent}
41
+ * render={({ hyperlinkState }) =>
42
+ * renderComponent({ hyperlinkState })
43
+ * }
37
44
  * />
45
+ * ```
46
+ *
47
+ * After:
48
+ * ```ts
49
+ * import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
50
+ * import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
51
+ *
52
+ * function ComponentWithState(
53
+ * api: ExtractInjectionAPI<typeof hyperlinkPlugin> | undefined
54
+ * ) {
55
+ * const { hyperlinkState } = useSharedPluginState(api, ['hyperlink']);
56
+ * return renderComponent({ hyperlinkState })
57
+ * }
58
+ * ```
38
59
  *
39
- * renderComponent: ({ hyperlink }) => React.Component;
40
60
  */
41
61
  var WithPluginState = /*#__PURE__*/function (_React$Component) {
42
62
  _inherits(WithPluginState, _React$Component);
@@ -0,0 +1 @@
1
+ export { withAnalytics } from './withAnalytics';
@@ -0,0 +1,34 @@
1
+ import type { EditorState } from 'prosemirror-state';
2
+ import type { AnalyticsEventPayload, EditorAnalyticsAPI } from '../analytics';
3
+ import type { HigherOrderCommand } from '../types';
4
+ /**
5
+ * Callback accepts EditorState
6
+ *
7
+ * @remarks
8
+ * The plugin using the Analytics may using an Optional<Analytics> dependency
9
+ * It can be undefined during testing, we may not have included analytics
10
+ * Also in cases where Analytics fails to load, the editor doesn't crash.
11
+ *
12
+ * @param state - EditorState, passed to the callback
13
+ */
14
+ type AnalyticsEventPayloadCallback = (state: EditorState) => AnalyticsEventPayload | undefined;
15
+ /**
16
+ * Analytics API
17
+ * @example
18
+ * ```
19
+ * withAnalytics({
20
+ * eventType: EVENT_TYPE.TRACK,
21
+ * action: ACTION.REPLACED_ONE,
22
+ * actionSubject: ACTION_SUBJECT.TEXT,
23
+ * attributes: {
24
+ * triggerMethod,
25
+ * },
26
+ * })(replace(replaceText))
27
+ * ```
28
+ *
29
+ * @param analyticsApi - EditorAnalyticsAPI, undefined in tests or if analytics fails to load
30
+ * @param payload - AnalyticsEventPayload | AnalyticsEventPayloadCallback - payload to be attached to the transaction
31
+ * @param channel - string - channel to be used for analytics
32
+ */
33
+ export declare function withAnalytics(analyticsApi: EditorAnalyticsAPI | undefined, payload: AnalyticsEventPayload | AnalyticsEventPayloadCallback, channel?: string): HigherOrderCommand;
34
+ export {};
@@ -38,20 +38,40 @@ export interface Props<P extends NamedPluginKeys> {
38
38
  render: (pluginState: NamedPluginStates<P>) => React.ReactElement | null;
39
39
  }
40
40
  /**
41
- * Wraps component in a high order component that watches state changes of given plugins
42
- * and passes those states to the wrapped component.
41
+ * @private
42
+ * @deprecated
43
43
  *
44
- * Example:
44
+ * Using this component is deprecated. It should be replaced with `useSharedPluginState`.
45
+ * This requires having access to the injection API from the plugin itself.
46
+ *
47
+ * An example of the refactor with the new hook (using hyperlink as an example) is:
48
+ *
49
+ * Before:
50
+ * ```ts
45
51
  * <WithPluginState
46
- * eventDispatcher={eventDispatcher}
47
52
  * editorView={editorView}
48
53
  * plugins={{
49
- * hyperlink: hyperlinkPluginKey
54
+ * hyperlinkState: hyperlinkPluginKey
50
55
  * }}
51
- * render={renderComponent}
56
+ * render={({ hyperlinkState }) =>
57
+ * renderComponent({ hyperlinkState })
58
+ * }
52
59
  * />
60
+ * ```
61
+ *
62
+ * After:
63
+ * ```ts
64
+ * import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
65
+ * import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
66
+ *
67
+ * function ComponentWithState(
68
+ * api: ExtractInjectionAPI<typeof hyperlinkPlugin> | undefined
69
+ * ) {
70
+ * const { hyperlinkState } = useSharedPluginState(api, ['hyperlink']);
71
+ * return renderComponent({ hyperlinkState })
72
+ * }
73
+ * ```
53
74
  *
54
- * renderComponent: ({ hyperlink }) => React.Component;
55
75
  */
56
76
  declare class WithPluginState<P extends NamedPluginKeys> extends React.Component<Props<P>, State> {
57
77
  static displayName: string;
@@ -0,0 +1 @@
1
+ export { withAnalytics } from './withAnalytics';
@@ -0,0 +1,34 @@
1
+ import type { EditorState } from 'prosemirror-state';
2
+ import type { AnalyticsEventPayload, EditorAnalyticsAPI } from '../analytics';
3
+ import type { HigherOrderCommand } from '../types';
4
+ /**
5
+ * Callback accepts EditorState
6
+ *
7
+ * @remarks
8
+ * The plugin using the Analytics may using an Optional<Analytics> dependency
9
+ * It can be undefined during testing, we may not have included analytics
10
+ * Also in cases where Analytics fails to load, the editor doesn't crash.
11
+ *
12
+ * @param state - EditorState, passed to the callback
13
+ */
14
+ type AnalyticsEventPayloadCallback = (state: EditorState) => AnalyticsEventPayload | undefined;
15
+ /**
16
+ * Analytics API
17
+ * @example
18
+ * ```
19
+ * withAnalytics({
20
+ * eventType: EVENT_TYPE.TRACK,
21
+ * action: ACTION.REPLACED_ONE,
22
+ * actionSubject: ACTION_SUBJECT.TEXT,
23
+ * attributes: {
24
+ * triggerMethod,
25
+ * },
26
+ * })(replace(replaceText))
27
+ * ```
28
+ *
29
+ * @param analyticsApi - EditorAnalyticsAPI, undefined in tests or if analytics fails to load
30
+ * @param payload - AnalyticsEventPayload | AnalyticsEventPayloadCallback - payload to be attached to the transaction
31
+ * @param channel - string - channel to be used for analytics
32
+ */
33
+ export declare function withAnalytics(analyticsApi: EditorAnalyticsAPI | undefined, payload: AnalyticsEventPayload | AnalyticsEventPayloadCallback, channel?: string): HigherOrderCommand;
34
+ export {};
@@ -38,20 +38,40 @@ export interface Props<P extends NamedPluginKeys> {
38
38
  render: (pluginState: NamedPluginStates<P>) => React.ReactElement | null;
39
39
  }
40
40
  /**
41
- * Wraps component in a high order component that watches state changes of given plugins
42
- * and passes those states to the wrapped component.
41
+ * @private
42
+ * @deprecated
43
43
  *
44
- * Example:
44
+ * Using this component is deprecated. It should be replaced with `useSharedPluginState`.
45
+ * This requires having access to the injection API from the plugin itself.
46
+ *
47
+ * An example of the refactor with the new hook (using hyperlink as an example) is:
48
+ *
49
+ * Before:
50
+ * ```ts
45
51
  * <WithPluginState
46
- * eventDispatcher={eventDispatcher}
47
52
  * editorView={editorView}
48
53
  * plugins={{
49
- * hyperlink: hyperlinkPluginKey
54
+ * hyperlinkState: hyperlinkPluginKey
50
55
  * }}
51
- * render={renderComponent}
56
+ * render={({ hyperlinkState }) =>
57
+ * renderComponent({ hyperlinkState })
58
+ * }
52
59
  * />
60
+ * ```
61
+ *
62
+ * After:
63
+ * ```ts
64
+ * import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
65
+ * import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
66
+ *
67
+ * function ComponentWithState(
68
+ * api: ExtractInjectionAPI<typeof hyperlinkPlugin> | undefined
69
+ * ) {
70
+ * const { hyperlinkState } = useSharedPluginState(api, ['hyperlink']);
71
+ * return renderComponent({ hyperlinkState })
72
+ * }
73
+ * ```
53
74
  *
54
- * renderComponent: ({ hyperlink }) => React.Component;
55
75
  */
56
76
  declare class WithPluginState<P extends NamedPluginKeys> extends React.Component<Props<P>, State> {
57
77
  static displayName: string;
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/editor-analytics",
3
+ "main": "../dist/cjs/editor-analytics/index.js",
4
+ "module": "../dist/esm/editor-analytics/index.js",
5
+ "module:es2019": "../dist/es2019/editor-analytics/index.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/editor-analytics/index.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <4.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/editor-analytics/index.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.7.1",
3
+ "version": "74.7.3",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -66,7 +66,8 @@
66
66
  "./hooks": "./src/hooks/index.ts",
67
67
  "./monitoring": "./src/monitoring/index.ts",
68
68
  "./paste": "./src/paste/index.ts",
69
- "./resizer": "./src/resizer/index.ts"
69
+ "./resizer": "./src/resizer/index.ts",
70
+ "./editor-analytics": "./src/editor-analytics/index.ts"
70
71
  },
71
72
  "dependencies": {
72
73
  "@atlaskit/activity-provider": "^2.4.0",
@@ -87,7 +88,7 @@
87
88
  "@atlaskit/icon": "^21.12.0",
88
89
  "@atlaskit/in-product-testing": "^0.2.0",
89
90
  "@atlaskit/media-card": "^76.0.0",
90
- "@atlaskit/media-client": "^23.0.0",
91
+ "@atlaskit/media-client": "^23.1.0",
91
92
  "@atlaskit/media-picker": "^66.0.0",
92
93
  "@atlaskit/mention": "^22.1.0",
93
94
  "@atlaskit/menu": "^1.7.0",