@atlaskit/editor-plugin-card 0.14.17 → 0.14.19

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 (31) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/nodeviews/inlineCard.js +16 -18
  3. package/dist/cjs/nodeviews/inlineCardWithAwareness.js +38 -81
  4. package/dist/cjs/pm-plugins/main.js +4 -3
  5. package/dist/cjs/ui/AwarenessWrapper/index.js +107 -0
  6. package/dist/cjs/ui/EditorLinkingPlatformAnalytics/common.js +6 -1
  7. package/dist/cjs/ui/LinkToolbarAppearance.js +2 -2
  8. package/dist/cjs/{common/pulse → ui/Pulse}/index.js +1 -1
  9. package/dist/es2019/nodeviews/inlineCard.js +17 -19
  10. package/dist/es2019/nodeviews/inlineCardWithAwareness.js +35 -75
  11. package/dist/es2019/pm-plugins/main.js +4 -3
  12. package/dist/es2019/ui/AwarenessWrapper/index.js +91 -0
  13. package/dist/es2019/ui/EditorLinkingPlatformAnalytics/common.js +6 -1
  14. package/dist/es2019/ui/LinkToolbarAppearance.js +1 -1
  15. package/dist/es2019/{common/pulse → ui/Pulse}/index.js +1 -1
  16. package/dist/esm/nodeviews/inlineCard.js +16 -18
  17. package/dist/esm/nodeviews/inlineCardWithAwareness.js +35 -80
  18. package/dist/esm/pm-plugins/main.js +4 -3
  19. package/dist/esm/ui/AwarenessWrapper/index.js +99 -0
  20. package/dist/esm/ui/EditorLinkingPlatformAnalytics/common.js +6 -1
  21. package/dist/esm/ui/LinkToolbarAppearance.js +1 -1
  22. package/dist/esm/{common/pulse → ui/Pulse}/index.js +1 -1
  23. package/dist/types/nodeviews/inlineCardWithAwareness.d.ts +2 -3
  24. package/dist/types/ui/AwarenessWrapper/index.d.ts +13 -0
  25. package/dist/types/ui/EditorLinkingPlatformAnalytics/LinkEvents.d.ts +1 -1
  26. package/dist/types-ts4.5/nodeviews/inlineCardWithAwareness.d.ts +2 -3
  27. package/dist/types-ts4.5/ui/AwarenessWrapper/index.d.ts +13 -0
  28. package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/LinkEvents.d.ts +1 -1
  29. package/package.json +3 -3
  30. /package/dist/types/{common/pulse → ui/Pulse}/index.d.ts +0 -0
  31. /package/dist/types-ts4.5/{common/pulse → ui/Pulse}/index.d.ts +0 -0
@@ -0,0 +1,99 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ /** @jsx jsx */
3
+ import { useCallback, useEffect, useMemo, useState } from 'react';
4
+ import { css, jsx } from '@emotion/react';
5
+ import { AnalyticsContext } from '@atlaskit/analytics-next';
6
+ import useLinkUpgradeDiscoverability from '../../common/hooks/useLinkUpgradeDiscoverability';
7
+ import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../../common/local-storage';
8
+ import { getResolvedAttributesFromStore } from '../../utils';
9
+ import InlineCardOverlay from '../InlineCardOverlay';
10
+ import { DiscoveryPulse } from '../Pulse';
11
+ // editor adds a standard line-height that is bigger than an inline smart link
12
+ // due to that the link has a bit of white space around it, which doesn't look right when there is pulse around it
13
+ var loaderWrapperStyles = css({
14
+ // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
15
+ '.loader-wrapper': {
16
+ lineHeight: 'normal'
17
+ }
18
+ });
19
+ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
20
+ var _cardContext$value2;
21
+ var cardContext = _ref.cardContext,
22
+ children = _ref.children,
23
+ getPos = _ref.getPos,
24
+ isInserted = _ref.isInserted,
25
+ isOverlayEnabled = _ref.isOverlayEnabled,
26
+ isSelected = _ref.isSelected,
27
+ isResolvedViewRendered = _ref.isResolvedViewRendered,
28
+ isPulseEnabled = _ref.isPulseEnabled,
29
+ markMostRecentlyInsertedLink = _ref.markMostRecentlyInsertedLink,
30
+ pluginInjectionApi = _ref.pluginInjectionApi,
31
+ setOverlayHoveredStyles = _ref.setOverlayHoveredStyles,
32
+ url = _ref.url;
33
+ var _useState = useState(false),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ isHovered = _useState2[0],
36
+ setIsHovered = _useState2[1];
37
+ var linkPosition = useMemo(function () {
38
+ if (!getPos || typeof getPos === 'boolean') {
39
+ return undefined;
40
+ }
41
+ var pos = getPos();
42
+ return typeof pos === 'number' ? pos : undefined;
43
+ }, [getPos]);
44
+ var _useLinkUpgradeDiscov = useLinkUpgradeDiscoverability({
45
+ url: url,
46
+ linkPosition: linkPosition || -1,
47
+ cardContext: cardContext === null || cardContext === void 0 ? void 0 : cardContext.value,
48
+ pluginInjectionApi: pluginInjectionApi,
49
+ isOverlayEnabled: isOverlayEnabled,
50
+ isPulseEnabled: isPulseEnabled
51
+ }),
52
+ shouldShowLinkPulse = _useLinkUpgradeDiscov.shouldShowLinkPulse,
53
+ shouldShowToolbarPulse = _useLinkUpgradeDiscov.shouldShowToolbarPulse,
54
+ shouldShowLinkOverlay = _useLinkUpgradeDiscov.shouldShowLinkOverlay,
55
+ isLinkMostRecentlyInserted = _useLinkUpgradeDiscov.isLinkMostRecentlyInserted;
56
+
57
+ // If the toolbar pulse has not yet been invalidated and this is a case where we will be showing it,
58
+ // we need to invalidate the link pulse too. Toolbar pulse will be invalidated in the corresponding component.
59
+ if (isSelected && shouldShowToolbarPulse && !isLocalStorageKeyDiscovered(LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR)) {
60
+ markLocalStorageKeyDiscovered(LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK);
61
+ }
62
+ useEffect(function () {
63
+ if (shouldShowLinkOverlay && isLinkMostRecentlyInserted) {
64
+ markMostRecentlyInsertedLink(true);
65
+ }
66
+ }, [isLinkMostRecentlyInserted, markMostRecentlyInsertedLink, shouldShowLinkOverlay]);
67
+ var handleOverlayChange = useCallback(function (isHovered) {
68
+ setIsHovered(isHovered);
69
+ setOverlayHoveredStyles(isHovered);
70
+ }, [setOverlayHoveredStyles]);
71
+ var cardWithOverlay = useMemo(function () {
72
+ return shouldShowLinkOverlay ? jsx(InlineCardOverlay, {
73
+ isSelected: isSelected,
74
+ isVisible: isResolvedViewRendered && (isInserted || isHovered || isSelected),
75
+ onMouseEnter: function onMouseEnter() {
76
+ return handleOverlayChange(true);
77
+ },
78
+ onMouseLeave: function onMouseLeave() {
79
+ return handleOverlayChange(false);
80
+ },
81
+ url: url
82
+ }, children) : children;
83
+ }, [shouldShowLinkOverlay, isSelected, isResolvedViewRendered, isInserted, isHovered, url, children, handleOverlayChange]);
84
+ return useMemo(function () {
85
+ var _cardContext$value;
86
+ return jsx("span", {
87
+ css: shouldShowLinkPulse && loaderWrapperStyles,
88
+ className: "card"
89
+ }, shouldShowLinkPulse ? jsx(AnalyticsContext, {
90
+ data: {
91
+ attributes: getResolvedAttributesFromStore(url, 'inline', cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store)
92
+ }
93
+ }, jsx(DiscoveryPulse, {
94
+ localStorageKey: LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK,
95
+ localStorageKeyExpirationInMs: ONE_DAY_IN_MILLISECONDS,
96
+ discoveryMode: "start"
97
+ }, cardWithOverlay)) : cardWithOverlay);
98
+ }, [shouldShowLinkPulse, url, cardContext === null || cardContext === void 0 || (_cardContext$value2 = cardContext.value) === null || _cardContext$value2 === void 0 ? void 0 : _cardContext$value2.store, cardWithOverlay]);
99
+ };
@@ -19,7 +19,10 @@ var withHistoryMethod = function withHistoryMethod(fn) {
19
19
  };
20
20
  };
21
21
  export var getMethod = withHistoryMethod(function (_ref) {
22
- var inputMethod = _ref.inputMethod;
22
+ var _inputMethod, _payload;
23
+ var inputMethod = _ref.inputMethod,
24
+ sourceEvent = _ref.sourceEvent;
25
+ inputMethod = (_inputMethod = inputMethod) !== null && _inputMethod !== void 0 ? _inputMethod : sourceEvent === null || sourceEvent === void 0 || (_payload = sourceEvent.payload) === null || _payload === void 0 || (_payload = _payload.attributes) === null || _payload === void 0 ? void 0 : _payload.inputMethod;
23
26
  switch (inputMethod) {
24
27
  case INPUT_METHOD.CLIPBOARD:
25
28
  return 'editor_paste';
@@ -32,6 +35,8 @@ export var getMethod = withHistoryMethod(function (_ref) {
32
35
  return 'linkpicker_searchResult';
33
36
  case INPUT_METHOD.MANUAL:
34
37
  return 'linkpicker_manual';
38
+ case INPUT_METHOD.DATASOURCE:
39
+ return 'datasource_config';
35
40
  default:
36
41
  return 'unknown';
37
42
  }
@@ -18,9 +18,9 @@ import nodeNames, { cardMessages as messages } from '@atlaskit/editor-common/mes
18
18
  import { isSupportedInParent } from '@atlaskit/editor-common/utils';
19
19
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
20
20
  import { LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR } from '../common/local-storage';
21
- import { DiscoveryPulse } from '../common/pulse';
22
21
  import { shouldRenderToolbarPulse } from '../toolbar';
23
22
  import { getResolvedAttributesFromStore } from '../utils';
23
+ import { DiscoveryPulse } from './Pulse';
24
24
  // eslint-disable-next-line @repo/internal/react/no-class-components
25
25
  export var LinkToolbarAppearance = /*#__PURE__*/function (_React$Component) {
26
26
  _inherits(LinkToolbarAppearance, _React$Component);
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useEffect } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { Pulse } from '@atlaskit/linking-common';
4
- import { isLocalStorageKeyDiscovered, markLocalStorageKeyDiscovered } from '../local-storage';
4
+ import { isLocalStorageKeyDiscovered, markLocalStorageKeyDiscovered } from '../../common/local-storage';
5
5
  export var DiscoveryPulse = function DiscoveryPulse(_ref) {
6
6
  var children = _ref.children,
7
7
  localStorageKey = _ref.localStorageKey,
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
- import { jsx } from '@emotion/react';
1
+ import React from 'react';
3
2
  import type { SmartCardProps } from './genericCard';
4
- export declare const InlineCardWithAwareness: import("react").MemoExoticComponent<({ node, cardContext, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, isSelected, }: SmartCardProps) => jsx.JSX.Element | null>;
3
+ export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, isSelected, }: SmartCardProps) => JSX.Element | null>;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { jsx } from '@emotion/react';
3
+ import type { SmartCardProps } from '../../nodeviews/genericCard';
4
+ type AwarenessWrapperProps = {
5
+ isInserted?: boolean;
6
+ isResolvedViewRendered?: boolean;
7
+ children: JSX.Element;
8
+ markMostRecentlyInsertedLink: (isLinkMostRecentlyInserted: boolean) => void;
9
+ setOverlayHoveredStyles: (isHovered: boolean) => void;
10
+ url: string;
11
+ } & Partial<SmartCardProps>;
12
+ export declare const AwarenessWrapper: ({ cardContext, children, getPos, isInserted, isOverlayEnabled, isSelected, isResolvedViewRendered, isPulseEnabled, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url, }: AwarenessWrapperProps) => jsx.JSX.Element;
13
+ export {};
@@ -1,4 +1,4 @@
1
- import { AnalyticsBindingsProps } from './common';
1
+ import type { AnalyticsBindingsProps } from './common';
2
2
  /**
3
3
  * Subscribes to the events occuring in the card
4
4
  * plugin and fires analytics events accordingly
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
- import { jsx } from '@emotion/react';
1
+ import React from 'react';
3
2
  import type { SmartCardProps } from './genericCard';
4
- export declare const InlineCardWithAwareness: import("react").MemoExoticComponent<({ node, cardContext, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, isSelected, }: SmartCardProps) => jsx.JSX.Element | null>;
3
+ export declare const InlineCardWithAwareness: React.MemoExoticComponent<({ node, cardContext, showServerActions, useAlternativePreloader, view, getPos, isOverlayEnabled, isPulseEnabled, pluginInjectionApi, isSelected, }: SmartCardProps) => JSX.Element | null>;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { jsx } from '@emotion/react';
3
+ import type { SmartCardProps } from '../../nodeviews/genericCard';
4
+ type AwarenessWrapperProps = {
5
+ isInserted?: boolean;
6
+ isResolvedViewRendered?: boolean;
7
+ children: JSX.Element;
8
+ markMostRecentlyInsertedLink: (isLinkMostRecentlyInserted: boolean) => void;
9
+ setOverlayHoveredStyles: (isHovered: boolean) => void;
10
+ url: string;
11
+ } & Partial<SmartCardProps>;
12
+ export declare const AwarenessWrapper: ({ cardContext, children, getPos, isInserted, isOverlayEnabled, isSelected, isResolvedViewRendered, isPulseEnabled, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url, }: AwarenessWrapperProps) => jsx.JSX.Element;
13
+ export {};
@@ -1,4 +1,4 @@
1
- import { AnalyticsBindingsProps } from './common';
1
+ import type { AnalyticsBindingsProps } from './common';
2
2
  /**
3
3
  * Subscribes to the events occuring in the card
4
4
  * plugin and fires analytics events accordingly
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.14.17",
3
+ "version": "0.14.19",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -52,10 +52,10 @@
52
52
  "@atlaskit/linking-common": "^4.21.0",
53
53
  "@atlaskit/linking-types": "^8.5.0",
54
54
  "@atlaskit/platform-feature-flags": "^0.2.0",
55
- "@atlaskit/primitives": "^1.14.0",
55
+ "@atlaskit/primitives": "^1.15.0",
56
56
  "@atlaskit/smart-card": "^26.43.0",
57
57
  "@atlaskit/theme": "^12.6.0",
58
- "@atlaskit/tokens": "^1.29.0",
58
+ "@atlaskit/tokens": "^1.30.0",
59
59
  "@babel/runtime": "^7.0.0",
60
60
  "@emotion/react": "^11.7.1",
61
61
  "lodash": "^4.17.21",