@atlaskit/editor-plugin-card 0.10.8 → 0.10.10

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,18 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 0.10.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#42151](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42151) [`192b62f6d36`](https://bitbucket.org/atlassian/atlassian-frontend/commits/192b62f6d36) - Cleans up editor feature flag 'lp-analytics-events-next'. Card plugin will now always dispatch link tracking events.
8
+
9
+ ## 0.10.9
10
+
11
+ ### Patch Changes
12
+
13
+ - [#42607](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42607) [`87e6390f290`](https://bitbucket.org/atlassian/atlassian-frontend/commits/87e6390f290) - [ux] Added a DiscoveryPulse component that can be used for feature discovery based on local storage keys
14
+ - Updated dependencies
15
+
3
16
  ## 0.10.8
4
17
 
5
18
  ### Patch Changes
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.markLocalStorageKeyDiscovered = exports.isLocalStorageKeyDiscovered = exports.LOCAL_STORAGE_DISCOVERED_KEY = exports.LOCAL_STORAGE_CLIENT_KEY = void 0;
7
+ var _frontendUtilities = require("@atlaskit/frontend-utilities");
8
+ var LOCAL_STORAGE_CLIENT_KEY = exports.LOCAL_STORAGE_CLIENT_KEY = '@atlaskit/editor-plugin-card';
9
+ var LOCAL_STORAGE_DISCOVERED_KEY = exports.LOCAL_STORAGE_DISCOVERED_KEY = 'discovered';
10
+ var storageClient = new _frontendUtilities.StorageClient(LOCAL_STORAGE_CLIENT_KEY);
11
+ var isLocalStorageKeyDiscovered = exports.isLocalStorageKeyDiscovered = function isLocalStorageKeyDiscovered(key) {
12
+ var localStorageValue = storageClient.getItem(key);
13
+ return !!localStorageValue && localStorageValue === LOCAL_STORAGE_DISCOVERED_KEY;
14
+ };
15
+ var markLocalStorageKeyDiscovered = exports.markLocalStorageKeyDiscovered = function markLocalStorageKeyDiscovered(key, expiration) {
16
+ storageClient.setItemWithExpiry(key, LOCAL_STORAGE_DISCOVERED_KEY, expiration);
17
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.DiscoveryPulse = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _linkingCommon = require("@atlaskit/linking-common");
10
+ var _localStorage = require("../local-storage");
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ 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; }
13
+ var DiscoveryPulse = exports.DiscoveryPulse = function DiscoveryPulse(_ref) {
14
+ var children = _ref.children,
15
+ localStorageKey = _ref.localStorageKey,
16
+ isDiscovered = _ref.isDiscovered,
17
+ timeToDiscoverInMs = _ref.timeToDiscoverInMs,
18
+ localStorageKeyExpirationInMs = _ref.localStorageKeyExpirationInMs;
19
+ var onDiscovery = (0, _react.useCallback)(function () {
20
+ (0, _localStorage.markLocalStorageKeyDiscovered)(localStorageKey, localStorageKeyExpirationInMs);
21
+ }, [localStorageKey, localStorageKeyExpirationInMs]);
22
+ (0, _react.useEffect)(function () {
23
+ if (timeToDiscoverInMs) {
24
+ var timeoutUntilDiscovery = setTimeout(function () {
25
+ onDiscovery();
26
+ }, timeToDiscoverInMs);
27
+ return function () {
28
+ return clearTimeout(timeoutUntilDiscovery);
29
+ };
30
+ }
31
+ onDiscovery();
32
+ }, [isDiscovered, localStorageKey, onDiscovery, timeToDiscoverInMs]);
33
+ return /*#__PURE__*/_react.default.createElement(_linkingCommon.Pulse, {
34
+ isDiscovered: isDiscovered
35
+ }, children);
36
+ };
37
+ var _default = exports.default = _linkingCommon.Pulse;
@@ -35,7 +35,7 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
35
35
  var options = _ref.config,
36
36
  api = _ref.api;
37
37
  var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
38
- var cardPluginEvents = featureFlags !== null && featureFlags !== void 0 && featureFlags.lpAnalyticsEventsNext ? (0, _createEventsQueue.createEventsQueue)() : undefined;
38
+ var cardPluginEvents = (0, _createEventsQueue.createEventsQueue)();
39
39
  return {
40
40
  name: 'card',
41
41
  getSharedState: function getSharedState(editorState) {
@@ -101,7 +101,7 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
101
101
  popupsBoundariesElement = _ref3.popupsBoundariesElement;
102
102
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_EditorSmartCardEvents.EditorSmartCardEvents, {
103
103
  editorView: editorView
104
- }), cardPluginEvents && /*#__PURE__*/_react.default.createElement(_EditorLinkingPlatformAnalytics.EditorLinkingPlatformAnalytics, {
104
+ }), /*#__PURE__*/_react.default.createElement(_EditorLinkingPlatformAnalytics.EditorLinkingPlatformAnalytics, {
105
105
  cardPluginEvents: cardPluginEvents,
106
106
  editorView: editorView
107
107
  }), /*#__PURE__*/_react.default.createElement(_LayoutButton.default, {
@@ -29,14 +29,15 @@ var EditorLinkingPlatformAnalytics = exports.EditorLinkingPlatformAnalytics = /*
29
29
  (0, _createClass2.default)(EditorLinkingPlatformAnalytics, [{
30
30
  key: "render",
31
31
  value: function render() {
32
- var cardContext = this.context.contextAdapter.card;
32
+ var _this$context;
33
+ var cardContext = (_this$context = this.context) === null || _this$context === void 0 || (_this$context = _this$context.contextAdapter) === null || _this$context === void 0 ? void 0 : _this$context.card;
33
34
 
34
35
  /**
35
36
  * The analytics hook needs to be able to communicate with the card context
36
37
  * If we can't access it, don't mount the event bindings
37
38
  * This effectively entirely disables all tracking behaviour
38
39
  */
39
- if (!cardContext) {
40
+ if (!(cardContext !== null && cardContext !== void 0 && cardContext.value)) {
40
41
  return null;
41
42
  }
42
43
  return /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
@@ -0,0 +1,11 @@
1
+ import { StorageClient } from '@atlaskit/frontend-utilities';
2
+ export const LOCAL_STORAGE_CLIENT_KEY = '@atlaskit/editor-plugin-card';
3
+ export const LOCAL_STORAGE_DISCOVERED_KEY = 'discovered';
4
+ const storageClient = new StorageClient(LOCAL_STORAGE_CLIENT_KEY);
5
+ export const isLocalStorageKeyDiscovered = key => {
6
+ const localStorageValue = storageClient.getItem(key);
7
+ return !!localStorageValue && localStorageValue === LOCAL_STORAGE_DISCOVERED_KEY;
8
+ };
9
+ export const markLocalStorageKeyDiscovered = (key, expiration) => {
10
+ storageClient.setItemWithExpiry(key, LOCAL_STORAGE_DISCOVERED_KEY, expiration);
11
+ };
@@ -0,0 +1,27 @@
1
+ import React, { useCallback, useEffect } from 'react';
2
+ import { Pulse } from '@atlaskit/linking-common';
3
+ import { markLocalStorageKeyDiscovered } from '../local-storage';
4
+ export const DiscoveryPulse = ({
5
+ children,
6
+ localStorageKey,
7
+ isDiscovered,
8
+ timeToDiscoverInMs,
9
+ localStorageKeyExpirationInMs
10
+ }) => {
11
+ const onDiscovery = useCallback(() => {
12
+ markLocalStorageKeyDiscovered(localStorageKey, localStorageKeyExpirationInMs);
13
+ }, [localStorageKey, localStorageKeyExpirationInMs]);
14
+ useEffect(() => {
15
+ if (timeToDiscoverInMs) {
16
+ const timeoutUntilDiscovery = setTimeout(() => {
17
+ onDiscovery();
18
+ }, timeToDiscoverInMs);
19
+ return () => clearTimeout(timeoutUntilDiscovery);
20
+ }
21
+ onDiscovery();
22
+ }, [isDiscovered, localStorageKey, onDiscovery, timeToDiscoverInMs]);
23
+ return /*#__PURE__*/React.createElement(Pulse, {
24
+ isDiscovered: isDiscovered
25
+ }, children);
26
+ };
27
+ export default Pulse;
@@ -26,7 +26,7 @@ export const cardPlugin = ({
26
26
  }) => {
27
27
  var _api$featureFlags;
28
28
  const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
29
- const cardPluginEvents = featureFlags !== null && featureFlags !== void 0 && featureFlags.lpAnalyticsEventsNext ? createEventsQueue() : undefined;
29
+ const cardPluginEvents = createEventsQueue();
30
30
  return {
31
31
  name: 'card',
32
32
  getSharedState(editorState) {
@@ -93,7 +93,7 @@ export const cardPlugin = ({
93
93
  }) {
94
94
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorSmartCardEvents, {
95
95
  editorView: editorView
96
- }), cardPluginEvents && /*#__PURE__*/React.createElement(EditorLinkingPlatformAnalytics, {
96
+ }), /*#__PURE__*/React.createElement(EditorLinkingPlatformAnalytics, {
97
97
  cardPluginEvents: cardPluginEvents,
98
98
  editorView: editorView
99
99
  }), /*#__PURE__*/React.createElement(LayoutButton, {
@@ -8,14 +8,15 @@ import { LinkEventsBinding } from './LinkEvents';
8
8
  // eslint-disable-next-line @repo/internal/react/no-class-components
9
9
  export class EditorLinkingPlatformAnalytics extends React.PureComponent {
10
10
  render() {
11
- const cardContext = this.context.contextAdapter.card;
11
+ var _this$context, _this$context$context;
12
+ const cardContext = (_this$context = this.context) === null || _this$context === void 0 ? void 0 : (_this$context$context = _this$context.contextAdapter) === null || _this$context$context === void 0 ? void 0 : _this$context$context.card;
12
13
 
13
14
  /**
14
15
  * The analytics hook needs to be able to communicate with the card context
15
16
  * If we can't access it, don't mount the event bindings
16
17
  * This effectively entirely disables all tracking behaviour
17
18
  */
18
- if (!cardContext) {
19
+ if (!(cardContext !== null && cardContext !== void 0 && cardContext.value)) {
19
20
  return null;
20
21
  }
21
22
  return /*#__PURE__*/React.createElement(cardContext.Provider, {
@@ -0,0 +1,11 @@
1
+ import { StorageClient } from '@atlaskit/frontend-utilities';
2
+ export var LOCAL_STORAGE_CLIENT_KEY = '@atlaskit/editor-plugin-card';
3
+ export var LOCAL_STORAGE_DISCOVERED_KEY = 'discovered';
4
+ var storageClient = new StorageClient(LOCAL_STORAGE_CLIENT_KEY);
5
+ export var isLocalStorageKeyDiscovered = function isLocalStorageKeyDiscovered(key) {
6
+ var localStorageValue = storageClient.getItem(key);
7
+ return !!localStorageValue && localStorageValue === LOCAL_STORAGE_DISCOVERED_KEY;
8
+ };
9
+ export var markLocalStorageKeyDiscovered = function markLocalStorageKeyDiscovered(key, expiration) {
10
+ storageClient.setItemWithExpiry(key, LOCAL_STORAGE_DISCOVERED_KEY, expiration);
11
+ };
@@ -0,0 +1,28 @@
1
+ import React, { useCallback, useEffect } from 'react';
2
+ import { Pulse } from '@atlaskit/linking-common';
3
+ import { markLocalStorageKeyDiscovered } from '../local-storage';
4
+ export var DiscoveryPulse = function DiscoveryPulse(_ref) {
5
+ var children = _ref.children,
6
+ localStorageKey = _ref.localStorageKey,
7
+ isDiscovered = _ref.isDiscovered,
8
+ timeToDiscoverInMs = _ref.timeToDiscoverInMs,
9
+ localStorageKeyExpirationInMs = _ref.localStorageKeyExpirationInMs;
10
+ var onDiscovery = useCallback(function () {
11
+ markLocalStorageKeyDiscovered(localStorageKey, localStorageKeyExpirationInMs);
12
+ }, [localStorageKey, localStorageKeyExpirationInMs]);
13
+ useEffect(function () {
14
+ if (timeToDiscoverInMs) {
15
+ var timeoutUntilDiscovery = setTimeout(function () {
16
+ onDiscovery();
17
+ }, timeToDiscoverInMs);
18
+ return function () {
19
+ return clearTimeout(timeoutUntilDiscovery);
20
+ };
21
+ }
22
+ onDiscovery();
23
+ }, [isDiscovered, localStorageKey, onDiscovery, timeToDiscoverInMs]);
24
+ return /*#__PURE__*/React.createElement(Pulse, {
25
+ isDiscovered: isDiscovered
26
+ }, children);
27
+ };
28
+ export default Pulse;
@@ -28,7 +28,7 @@ export var cardPlugin = function cardPlugin(_ref) {
28
28
  var options = _ref.config,
29
29
  api = _ref.api;
30
30
  var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
31
- var cardPluginEvents = featureFlags !== null && featureFlags !== void 0 && featureFlags.lpAnalyticsEventsNext ? createEventsQueue() : undefined;
31
+ var cardPluginEvents = createEventsQueue();
32
32
  return {
33
33
  name: 'card',
34
34
  getSharedState: function getSharedState(editorState) {
@@ -94,7 +94,7 @@ export var cardPlugin = function cardPlugin(_ref) {
94
94
  popupsBoundariesElement = _ref3.popupsBoundariesElement;
95
95
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorSmartCardEvents, {
96
96
  editorView: editorView
97
- }), cardPluginEvents && /*#__PURE__*/React.createElement(EditorLinkingPlatformAnalytics, {
97
+ }), /*#__PURE__*/React.createElement(EditorLinkingPlatformAnalytics, {
98
98
  cardPluginEvents: cardPluginEvents,
99
99
  editorView: editorView
100
100
  }), /*#__PURE__*/React.createElement(LayoutButton, {
@@ -23,14 +23,15 @@ export var EditorLinkingPlatformAnalytics = /*#__PURE__*/function (_React$PureCo
23
23
  _createClass(EditorLinkingPlatformAnalytics, [{
24
24
  key: "render",
25
25
  value: function render() {
26
- var cardContext = this.context.contextAdapter.card;
26
+ var _this$context;
27
+ var cardContext = (_this$context = this.context) === null || _this$context === void 0 || (_this$context = _this$context.contextAdapter) === null || _this$context === void 0 ? void 0 : _this$context.card;
27
28
 
28
29
  /**
29
30
  * The analytics hook needs to be able to communicate with the card context
30
31
  * If we can't access it, don't mount the event bindings
31
32
  * This effectively entirely disables all tracking behaviour
32
33
  */
33
- if (!cardContext) {
34
+ if (!(cardContext !== null && cardContext !== void 0 && cardContext.value)) {
34
35
  return null;
35
36
  }
36
37
  return /*#__PURE__*/React.createElement(cardContext.Provider, {
@@ -0,0 +1,4 @@
1
+ export declare const LOCAL_STORAGE_CLIENT_KEY = "@atlaskit/editor-plugin-card";
2
+ export declare const LOCAL_STORAGE_DISCOVERED_KEY = "discovered";
3
+ export declare const isLocalStorageKeyDiscovered: (key: string) => boolean;
4
+ export declare const markLocalStorageKeyDiscovered: (key: string, expiration?: number) => void;
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ import { Pulse } from '@atlaskit/linking-common';
3
+ export interface PulseProps {
4
+ /**
5
+ * The component around which the Pulse should be displayed
6
+ */
7
+ children: JSX.Element;
8
+ /**
9
+ * The key that is used in local storage to identify the descoverability of a feature where the Pulse is used
10
+ */
11
+ localStorageKey: string;
12
+ /**
13
+ * The time in ms after which the key in local storage will be considered expired and the Pulse will be shown again
14
+ */
15
+ localStorageKeyExpirationInMs?: number;
16
+ /**
17
+ * The time in ms since the Pulse has started after which the key will be stored in local storage.
18
+ */
19
+ timeToDiscoverInMs?: number;
20
+ /**
21
+ * And indicator that the feature was discovered externally and the pulsation needs to stop.
22
+ */
23
+ isDiscovered?: boolean;
24
+ }
25
+ export declare const DiscoveryPulse: ({ children, localStorageKey, isDiscovered, timeToDiscoverInMs, localStorageKeyExpirationInMs, }: PulseProps) => JSX.Element;
26
+ export default Pulse;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { AnalyticsBindingsProps } from './common';
3
+ import type { AnalyticsBindingsProps } from './common';
4
4
  export declare class EditorLinkingPlatformAnalytics extends React.PureComponent<AnalyticsBindingsProps> {
5
5
  static contextTypes: {
6
6
  contextAdapter: PropTypes.Requireable<object>;
@@ -0,0 +1,4 @@
1
+ export declare const LOCAL_STORAGE_CLIENT_KEY = "@atlaskit/editor-plugin-card";
2
+ export declare const LOCAL_STORAGE_DISCOVERED_KEY = "discovered";
3
+ export declare const isLocalStorageKeyDiscovered: (key: string) => boolean;
4
+ export declare const markLocalStorageKeyDiscovered: (key: string, expiration?: number) => void;
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ import { Pulse } from '@atlaskit/linking-common';
3
+ export interface PulseProps {
4
+ /**
5
+ * The component around which the Pulse should be displayed
6
+ */
7
+ children: JSX.Element;
8
+ /**
9
+ * The key that is used in local storage to identify the descoverability of a feature where the Pulse is used
10
+ */
11
+ localStorageKey: string;
12
+ /**
13
+ * The time in ms after which the key in local storage will be considered expired and the Pulse will be shown again
14
+ */
15
+ localStorageKeyExpirationInMs?: number;
16
+ /**
17
+ * The time in ms since the Pulse has started after which the key will be stored in local storage.
18
+ */
19
+ timeToDiscoverInMs?: number;
20
+ /**
21
+ * And indicator that the feature was discovered externally and the pulsation needs to stop.
22
+ */
23
+ isDiscovered?: boolean;
24
+ }
25
+ export declare const DiscoveryPulse: ({ children, localStorageKey, isDiscovered, timeToDiscoverInMs, localStorageKeyExpirationInMs, }: PulseProps) => JSX.Element;
26
+ export default Pulse;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { AnalyticsBindingsProps } from './common';
3
+ import type { AnalyticsBindingsProps } from './common';
4
4
  export declare class EditorLinkingPlatformAnalytics extends React.PureComponent<AnalyticsBindingsProps> {
5
5
  static contextTypes: {
6
6
  contextAdapter: PropTypes.Requireable<object>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.10.8",
3
+ "version": "0.10.10",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -44,9 +44,11 @@
44
44
  "@atlaskit/editor-plugin-width": "^0.2.0",
45
45
  "@atlaskit/editor-prosemirror": "1.1.0",
46
46
  "@atlaskit/editor-shared-styles": "^2.8.0",
47
+ "@atlaskit/frontend-utilities": "^2.7.0",
47
48
  "@atlaskit/icon": "^21.12.0",
48
49
  "@atlaskit/link-analytics": "^8.3.0",
49
- "@atlaskit/link-datasource": "^1.12.0",
50
+ "@atlaskit/link-datasource": "^1.13.0",
51
+ "@atlaskit/linking-common": "^4.16.0",
50
52
  "@atlaskit/platform-feature-flags": "^0.2.0",
51
53
  "@atlaskit/smart-card": "^26.41.0",
52
54
  "@atlaskit/theme": "^12.6.0",