@atlaskit/editor-plugin-card 0.10.7 → 0.10.9

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.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+ - Updated dependencies
9
+
10
+ ## 0.10.8
11
+
12
+ ### Patch Changes
13
+
14
+ - [#42586](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42586) [`ed2a549e705`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ed2a549e705) - ED-20177 Use updated transaction when closing modal
15
+
3
16
  ## 0.10.7
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;
@@ -37,8 +37,8 @@ var DatasourceModal = exports.DatasourceModal = function DatasourceModal(_ref) {
37
37
  parameters = _useFetchDatasourceIn.parameters,
38
38
  ready = _useFetchDatasourceIn.ready;
39
39
  var onClose = (0, _react.useCallback)(function () {
40
- dispatch((0, _actions.hideDatasourceModal)(state.tr));
41
- }, [dispatch, state.tr]);
40
+ dispatch((0, _actions.hideDatasourceModal)(view.state.tr));
41
+ }, [dispatch, view.state.tr]);
42
42
  var onInsert = (0, _react.useCallback)(function (newAdf, analyticEvent) {
43
43
  if (analyticEvent) {
44
44
  analyticEvent.update(function (payload) {
@@ -50,11 +50,11 @@ var DatasourceModal = exports.DatasourceModal = function DatasourceModal(_ref) {
50
50
  });
51
51
  }
52
52
  if (existingNode) {
53
- (0, _doc.updateCardFromDatasourceModal)(state, existingNode, newAdf, view, analyticEvent);
53
+ (0, _doc.updateCardFromDatasourceModal)(view.state, existingNode, newAdf, view, analyticEvent);
54
54
  } else {
55
- (0, _doc.insertDatasource)(state, newAdf, view, analyticEvent);
55
+ (0, _doc.insertDatasource)(view.state, newAdf, view, analyticEvent);
56
56
  }
57
- }, [existingNode, state, view]);
57
+ }, [existingNode, view]);
58
58
  if (modalType === 'jira') {
59
59
  var _existingNode$attrs3, _tableView$properties;
60
60
  if (!ready) {
@@ -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;
@@ -29,8 +29,8 @@ export const DatasourceModal = ({
29
29
  nodeParameters: existingNode === null || existingNode === void 0 ? void 0 : (_existingNode$attrs2 = existingNode.attrs) === null || _existingNode$attrs2 === void 0 ? void 0 : (_existingNode$attrs2$ = _existingNode$attrs2.datasource) === null || _existingNode$attrs2$ === void 0 ? void 0 : _existingNode$attrs2$.parameters
30
30
  });
31
31
  const onClose = useCallback(() => {
32
- dispatch(hideDatasourceModal(state.tr));
33
- }, [dispatch, state.tr]);
32
+ dispatch(hideDatasourceModal(view.state.tr));
33
+ }, [dispatch, view.state.tr]);
34
34
  const onInsert = useCallback((newAdf, analyticEvent) => {
35
35
  if (analyticEvent) {
36
36
  analyticEvent.update(payload => ({
@@ -42,11 +42,11 @@ export const DatasourceModal = ({
42
42
  }));
43
43
  }
44
44
  if (existingNode) {
45
- updateCardFromDatasourceModal(state, existingNode, newAdf, view, analyticEvent);
45
+ updateCardFromDatasourceModal(view.state, existingNode, newAdf, view, analyticEvent);
46
46
  } else {
47
- insertDatasource(state, newAdf, view, analyticEvent);
47
+ insertDatasource(view.state, newAdf, view, analyticEvent);
48
48
  }
49
- }, [existingNode, state, view]);
49
+ }, [existingNode, view]);
50
50
  if (modalType === 'jira') {
51
51
  var _existingNode$attrs3, _tableView$properties;
52
52
  if (!ready) {
@@ -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;
@@ -27,8 +27,8 @@ export var DatasourceModal = function DatasourceModal(_ref) {
27
27
  parameters = _useFetchDatasourceIn.parameters,
28
28
  ready = _useFetchDatasourceIn.ready;
29
29
  var onClose = useCallback(function () {
30
- dispatch(hideDatasourceModal(state.tr));
31
- }, [dispatch, state.tr]);
30
+ dispatch(hideDatasourceModal(view.state.tr));
31
+ }, [dispatch, view.state.tr]);
32
32
  var onInsert = useCallback(function (newAdf, analyticEvent) {
33
33
  if (analyticEvent) {
34
34
  analyticEvent.update(function (payload) {
@@ -40,11 +40,11 @@ export var DatasourceModal = function DatasourceModal(_ref) {
40
40
  });
41
41
  }
42
42
  if (existingNode) {
43
- updateCardFromDatasourceModal(state, existingNode, newAdf, view, analyticEvent);
43
+ updateCardFromDatasourceModal(view.state, existingNode, newAdf, view, analyticEvent);
44
44
  } else {
45
- insertDatasource(state, newAdf, view, analyticEvent);
45
+ insertDatasource(view.state, newAdf, view, analyticEvent);
46
46
  }
47
- }, [existingNode, state, view]);
47
+ }, [existingNode, view]);
48
48
  if (modalType === 'jira') {
49
49
  var _existingNode$attrs3, _tableView$properties;
50
50
  if (!ready) {
@@ -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;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.10.7",
3
+ "version": "0.10.9",
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
50
  "@atlaskit/link-datasource": "^1.12.0",
51
+ "@atlaskit/linking-common": "^4.15.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",