@atlaskit/editor-plugin-card 2.3.3 → 2.3.5
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 +17 -0
- package/dist/cjs/nodeviews/genericCard.js +1 -1
- package/dist/cjs/nodeviews/inlineCard.js +101 -16
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +40 -96
- package/dist/cjs/plugin.js +2 -2
- package/dist/cjs/ui/AwarenessWrapper/index.js +2 -11
- package/dist/cjs/utils.js +15 -2
- package/dist/es2019/nodeviews/genericCard.js +2 -2
- package/dist/es2019/nodeviews/inlineCard.js +100 -17
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +39 -97
- package/dist/es2019/plugin.js +3 -3
- package/dist/es2019/ui/AwarenessWrapper/index.js +2 -11
- package/dist/es2019/utils.js +15 -2
- package/dist/esm/nodeviews/genericCard.js +2 -2
- package/dist/esm/nodeviews/inlineCard.js +98 -17
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +41 -97
- package/dist/esm/plugin.js +3 -3
- package/dist/esm/ui/AwarenessWrapper/index.js +2 -11
- package/dist/esm/utils.js +15 -2
- package/dist/types/nodeviews/genericCard.d.ts +6 -4
- package/dist/types/nodeviews/inlineCard.d.ts +3 -7
- package/dist/types/nodeviews/inlineCardWithAwareness.d.ts +6 -1
- package/dist/types/ui/AwarenessWrapper/index.d.ts +4 -3
- package/dist/types/utils.d.ts +6 -0
- package/dist/types-ts4.5/nodeviews/genericCard.d.ts +6 -4
- package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +3 -7
- package/dist/types-ts4.5/nodeviews/inlineCardWithAwareness.d.ts +6 -1
- package/dist/types-ts4.5/ui/AwarenessWrapper/index.d.ts +4 -3
- package/dist/types-ts4.5/utils.d.ts +6 -0
- package/package.json +2 -2
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
2
|
-
import
|
|
3
|
-
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
4
|
-
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
5
|
-
import { registerCard, registerRemoveOverlay } from '../pm-plugins/actions';
|
|
2
|
+
import { registerRemoveOverlay } from '../pm-plugins/actions';
|
|
6
3
|
import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
7
|
-
|
|
4
|
+
import { InlineCard } from './inlineCard';
|
|
5
|
+
export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
8
6
|
node,
|
|
9
7
|
cardContext,
|
|
10
8
|
actionOptions,
|
|
@@ -12,63 +10,21 @@ const InlineCard = ({
|
|
|
12
10
|
useAlternativePreloader,
|
|
13
11
|
view,
|
|
14
12
|
getPos,
|
|
15
|
-
isOverlayEnabled,
|
|
16
|
-
isPulseEnabled,
|
|
17
13
|
pluginInjectionApi,
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
onClick,
|
|
15
|
+
isPulseEnabled,
|
|
16
|
+
isOverlayEnabled,
|
|
17
|
+
isSelected
|
|
20
18
|
}) => {
|
|
21
|
-
const {
|
|
22
|
-
url,
|
|
23
|
-
data
|
|
24
|
-
} = node.attrs;
|
|
25
19
|
const [isHovered, setIsHovered] = useState(false);
|
|
26
20
|
const [isInserted, setIsInserted] = useState(false);
|
|
27
21
|
const [isResolvedViewRendered, setIsResolvedViewRendered] = useState(false);
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
if (!getPos || typeof getPos === 'boolean') {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const {
|
|
34
|
-
title,
|
|
35
|
-
url
|
|
36
|
-
} = data;
|
|
37
|
-
// don't dispatch immediately since we might be in the middle of
|
|
38
|
-
// rendering a nodeview
|
|
39
|
-
rafSchedule(() => {
|
|
40
|
-
// prosemirror-bump-fix
|
|
41
|
-
const pos = getPos();
|
|
42
|
-
if (typeof pos !== 'number') {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const tr = view.state.tr;
|
|
46
|
-
registerCard({
|
|
47
|
-
title,
|
|
48
|
-
url,
|
|
49
|
-
pos
|
|
50
|
-
})(tr);
|
|
51
|
-
registerRemoveOverlay(() => setIsInserted(false))(tr);
|
|
52
|
-
view.dispatch(tr);
|
|
53
|
-
})();
|
|
22
|
+
const onResolve = useCallback((tr, title) => {
|
|
23
|
+
registerRemoveOverlay(() => setIsInserted(false))(tr);
|
|
54
24
|
if (title) {
|
|
55
25
|
setIsResolvedViewRendered(true);
|
|
56
26
|
}
|
|
57
|
-
}, [
|
|
58
|
-
const onError = useCallback(data => {
|
|
59
|
-
const {
|
|
60
|
-
url,
|
|
61
|
-
err
|
|
62
|
-
} = data;
|
|
63
|
-
if (err) {
|
|
64
|
-
throw err;
|
|
65
|
-
}
|
|
66
|
-
onResolve({
|
|
67
|
-
url
|
|
68
|
-
});
|
|
69
|
-
}, [onResolve]);
|
|
70
|
-
|
|
71
|
-
// Begin Upgrade Awareness related code
|
|
27
|
+
}, []);
|
|
72
28
|
const markMostRecentlyInsertedLink = useCallback(isLinkMostRecentlyInserted => {
|
|
73
29
|
if (isOverlayEnabled) {
|
|
74
30
|
setIsInserted(isLinkMostRecentlyInserted);
|
|
@@ -79,49 +35,35 @@ const InlineCard = ({
|
|
|
79
35
|
setIsHovered(isHovered);
|
|
80
36
|
}
|
|
81
37
|
}, [isOverlayEnabled]);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
data: data,
|
|
88
|
-
appearance: "inline",
|
|
89
|
-
onClick: onClick,
|
|
90
|
-
container: scrollContainer,
|
|
91
|
-
onResolve: onResolve,
|
|
92
|
-
onError: onError,
|
|
93
|
-
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
38
|
+
const innerCard = useMemo(() => /*#__PURE__*/React.createElement(InlineCard, {
|
|
39
|
+
node: node,
|
|
40
|
+
view: view,
|
|
41
|
+
getPos: getPos,
|
|
42
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
94
43
|
actionOptions: actionOptions,
|
|
95
44
|
showServerActions: showServerActions,
|
|
45
|
+
onResolve: onResolve,
|
|
46
|
+
onClick: onClick,
|
|
47
|
+
cardContext: cardContext,
|
|
96
48
|
isHovered: isHovered
|
|
97
|
-
}), [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}, innerCard);
|
|
119
|
-
}, [cardContext, getPos, innerCard, isHovered, isInserted, isOverlayEnabled, isPulseEnabled, isResolvedViewRendered, isSelected, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url, view]);
|
|
120
|
-
|
|
121
|
-
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
122
|
-
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
123
|
-
return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
124
|
-
value: cardContext.value
|
|
125
|
-
}, card) : data ? card : null;
|
|
126
|
-
};
|
|
127
|
-
export const InlineCardWithAwareness = /*#__PURE__*/memo(InlineCard);
|
|
49
|
+
}), [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, showServerActions, useAlternativePreloader, view]);
|
|
50
|
+
return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/React.createElement(AwarenessWrapper, {
|
|
51
|
+
isOverlayEnabled: isOverlayEnabled,
|
|
52
|
+
isPulseEnabled: isPulseEnabled,
|
|
53
|
+
cardContext: cardContext,
|
|
54
|
+
getPos: getPos,
|
|
55
|
+
isHovered: isHovered,
|
|
56
|
+
isInserted: isInserted,
|
|
57
|
+
url: node.attrs.url,
|
|
58
|
+
isSelected: isSelected,
|
|
59
|
+
isResolvedViewRendered: isResolvedViewRendered,
|
|
60
|
+
markMostRecentlyInsertedLink: markMostRecentlyInsertedLink,
|
|
61
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
62
|
+
setOverlayHoveredStyles: setOverlayHoveredStyles
|
|
63
|
+
}, innerCard) :
|
|
64
|
+
/*#__PURE__*/
|
|
65
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
66
|
+
React.createElement("span", {
|
|
67
|
+
className: "card"
|
|
68
|
+
}, innerCard);
|
|
69
|
+
});
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -4,10 +4,10 @@ import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
|
4
4
|
import { IconDatasourceAssetsObjects, IconDatasourceConfluenceSearch, IconDatasourceJiraIssue } from '@atlaskit/editor-common/quick-insert';
|
|
5
5
|
import { canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, CONFLUENCE_SEARCH_DATASOURCE_ID } from '@atlaskit/link-datasource';
|
|
7
|
-
import {
|
|
8
|
-
import { queueCardsFromChangedTr } from '../src/pm-plugins/doc';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { createEventsQueue } from './analytics/create-events-queue';
|
|
10
9
|
import { hideLinkToolbar, showDatasourceModal } from './pm-plugins/actions';
|
|
10
|
+
import { queueCardsFromChangedTr } from './pm-plugins/doc';
|
|
11
11
|
import { cardKeymap } from './pm-plugins/keymap';
|
|
12
12
|
import { createPlugin } from './pm-plugins/main';
|
|
13
13
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
@@ -135,7 +135,7 @@ export const cardPlugin = ({
|
|
|
135
135
|
if (canRenderDatasource(ASSETS_LIST_OF_LINKS_DATASOURCE_ID)) {
|
|
136
136
|
quickInsertArray.push({
|
|
137
137
|
id: 'datasource',
|
|
138
|
-
title:
|
|
138
|
+
title: fg('platform.linking-platform.datasource-assets_objects_remove_beta') ? formatMessage(messages.datasourceAssetsObjectsGeneralAvailability) : formatMessage(messages.datasourceAssetsObjects),
|
|
139
139
|
description: formatMessage(messages.datasourceAssetsObjectsDescription),
|
|
140
140
|
categories: ['external-content', 'development'],
|
|
141
141
|
keywords: ['assets'],
|
|
@@ -4,11 +4,9 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
4
4
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
5
5
|
import { css, jsx } from '@emotion/react';
|
|
6
6
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
7
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import useLinkUpgradeDiscoverability from '../../common/hooks/useLinkUpgradeDiscoverability';
|
|
9
8
|
import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../../common/local-storage';
|
|
10
9
|
import { getResolvedAttributesFromStore } from '../../utils';
|
|
11
|
-
import OverlayWrapper from '../ConfigureOverlay';
|
|
12
10
|
import InlineCardOverlay from '../InlineCardOverlay';
|
|
13
11
|
import { DiscoveryPulse } from '../Pulse';
|
|
14
12
|
// editor adds a standard line-height that is bigger than an inline smart link
|
|
@@ -31,8 +29,7 @@ export const AwarenessWrapper = ({
|
|
|
31
29
|
markMostRecentlyInsertedLink,
|
|
32
30
|
pluginInjectionApi,
|
|
33
31
|
setOverlayHoveredStyles,
|
|
34
|
-
url
|
|
35
|
-
view
|
|
32
|
+
url
|
|
36
33
|
}) => {
|
|
37
34
|
var _cardContext$value2;
|
|
38
35
|
const [isHovered, setIsHovered] = useState(false);
|
|
@@ -72,12 +69,6 @@ export const AwarenessWrapper = ({
|
|
|
72
69
|
setOverlayHoveredStyles(isHovered);
|
|
73
70
|
}, [setOverlayHoveredStyles]);
|
|
74
71
|
const cardWithOverlay = useMemo(() => {
|
|
75
|
-
if (getBooleanFF('platform.linking-platform.smart-links-in-live-pages')) {
|
|
76
|
-
return jsx(OverlayWrapper, {
|
|
77
|
-
targetElementPos: linkPosition,
|
|
78
|
-
view: view
|
|
79
|
-
}, children);
|
|
80
|
-
}
|
|
81
72
|
if (shouldShowLinkOverlay) {
|
|
82
73
|
return jsx(InlineCardOverlay, {
|
|
83
74
|
isSelected: isSelected,
|
|
@@ -88,7 +79,7 @@ export const AwarenessWrapper = ({
|
|
|
88
79
|
}, children);
|
|
89
80
|
}
|
|
90
81
|
return children;
|
|
91
|
-
}, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url,
|
|
82
|
+
}, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
|
|
92
83
|
return useMemo(() => {
|
|
93
84
|
var _cardContext$value;
|
|
94
85
|
return (
|
package/dist/es2019/utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { getResolvedAttributes } from '@atlaskit/link-analytics/resolved-attributes';
|
|
4
4
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, CONFLUENCE_SEARCH_DATASOURCE_ID, JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource';
|
|
5
|
-
import {
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
7
7
|
export const appearanceForNodeType = spec => {
|
|
8
8
|
if (spec.name === 'inlineCard') {
|
|
@@ -68,7 +68,7 @@ export const getResolvedAttributesFromStore = (url, display, store) => {
|
|
|
68
68
|
};
|
|
69
69
|
export const isDatasourceConfigEditable = datasourceId => {
|
|
70
70
|
const datasourcesWithConfigModal = [JIRA_LIST_OF_LINKS_DATASOURCE_ID, ASSETS_LIST_OF_LINKS_DATASOURCE_ID];
|
|
71
|
-
if (
|
|
71
|
+
if (fg('platform.linking-platform.datasource.enable-confluence-search-modal')) {
|
|
72
72
|
datasourcesWithConfigModal.push(CONFLUENCE_SEARCH_DATASOURCE_ID);
|
|
73
73
|
}
|
|
74
74
|
return datasourcesWithConfigModal.includes(datasourceId);
|
|
@@ -118,4 +118,17 @@ export const focusEditorView = editorView => {
|
|
|
118
118
|
if (!editorView.hasFocus()) {
|
|
119
119
|
editorView.focus();
|
|
120
120
|
}
|
|
121
|
+
};
|
|
122
|
+
export const getAwarenessProps = (editorState, getPos, allowEmbeds, allowBlockCards) => {
|
|
123
|
+
var _editorState$selectio, _editorState$selectio2, _editorState$selectio3;
|
|
124
|
+
const getPosFunction = typeof getPos !== 'boolean' ? getPos : undefined;
|
|
125
|
+
const linkPosition = getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction();
|
|
126
|
+
const canBeUpgradedToEmbed = !!linkPosition && allowEmbeds ? isEmbedSupportedAtPosition(linkPosition, editorState, 'inline') : false;
|
|
127
|
+
const canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? isBlockSupportedAtPosition(linkPosition, editorState, 'inline') : false;
|
|
128
|
+
const isSelected = editorState.selection instanceof NodeSelection && ((_editorState$selectio = editorState.selection) === null || _editorState$selectio === void 0 ? void 0 : (_editorState$selectio2 = _editorState$selectio.node) === null || _editorState$selectio2 === void 0 ? void 0 : _editorState$selectio2.type) === editorState.schema.nodes.inlineCard && ((_editorState$selectio3 = editorState.selection) === null || _editorState$selectio3 === void 0 ? void 0 : _editorState$selectio3.from) === (getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction());
|
|
129
|
+
return {
|
|
130
|
+
isPulseEnabled: canBeUpgradedToEmbed,
|
|
131
|
+
isOverlayEnabled: canBeUpgradedToEmbed || canBeUpgradedToBlock,
|
|
132
|
+
isSelected
|
|
133
|
+
};
|
|
121
134
|
};
|
|
@@ -14,7 +14,7 @@ import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
|
14
14
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
15
15
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
16
16
|
import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
|
|
17
|
-
import {
|
|
17
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
18
|
import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
|
|
19
19
|
import { getPluginState } from '../pm-plugins/util/state';
|
|
20
20
|
import { titleUrlPairFromNode } from '../utils';
|
|
@@ -97,7 +97,7 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
|
|
|
97
97
|
// Below is added for the future implementation of Linking Platform namespaced analytics context
|
|
98
98
|
location: analyticsEditorAppearance
|
|
99
99
|
}
|
|
100
|
-
},
|
|
100
|
+
}, fg('platform.linking-platform.smart-card.on-click-callback') ? /*#__PURE__*/React.createElement(WithClickHandler, {
|
|
101
101
|
pluginInjectionApi: pluginInjectionApi,
|
|
102
102
|
onClickCallback: onClickCallback,
|
|
103
103
|
url: url
|
|
@@ -1,11 +1,90 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import React, { memo, useCallback, useMemo } from 'react';
|
|
3
|
+
import rafSchedule from 'raf-schd';
|
|
4
|
+
import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
7
|
+
import { registerCard } from '../pm-plugins/actions';
|
|
8
|
+
import OverlayWrapper from '../ui/ConfigureOverlay';
|
|
9
|
+
import { getAwarenessProps } from '../utils';
|
|
6
10
|
import { Card } from './genericCard';
|
|
7
11
|
import { InlineCardWithAwareness } from './inlineCardWithAwareness';
|
|
12
|
+
export var InlineCard = /*#__PURE__*/memo(function (_ref) {
|
|
13
|
+
var node = _ref.node,
|
|
14
|
+
cardContext = _ref.cardContext,
|
|
15
|
+
actionOptions = _ref.actionOptions,
|
|
16
|
+
showServerActions = _ref.showServerActions,
|
|
17
|
+
useAlternativePreloader = _ref.useAlternativePreloader,
|
|
18
|
+
view = _ref.view,
|
|
19
|
+
getPos = _ref.getPos,
|
|
20
|
+
onClick = _ref.onClick,
|
|
21
|
+
onRes = _ref.onResolve,
|
|
22
|
+
isHovered = _ref.isHovered;
|
|
23
|
+
var _node$attrs = node.attrs,
|
|
24
|
+
url = _node$attrs.url,
|
|
25
|
+
data = _node$attrs.data;
|
|
26
|
+
var scrollContainer = useMemo(function () {
|
|
27
|
+
return findOverflowScrollParent(view.dom) || undefined;
|
|
28
|
+
}, [view.dom]);
|
|
29
|
+
var onResolve = useCallback(function (data) {
|
|
30
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
var title = data.title,
|
|
34
|
+
url = data.url;
|
|
35
|
+
// don't dispatch immediately since we might be in the middle of
|
|
36
|
+
// rendering a nodeview
|
|
37
|
+
rafSchedule(function () {
|
|
38
|
+
// prosemirror-bump-fix
|
|
39
|
+
var pos = getPos();
|
|
40
|
+
if (typeof pos !== 'number') {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
var tr = view.state.tr;
|
|
44
|
+
registerCard({
|
|
45
|
+
title: title,
|
|
46
|
+
url: url,
|
|
47
|
+
pos: pos
|
|
48
|
+
})(tr);
|
|
49
|
+
onRes === null || onRes === void 0 || onRes(tr, title);
|
|
50
|
+
view.dispatch(tr);
|
|
51
|
+
})();
|
|
52
|
+
}, [getPos, view, onRes]);
|
|
53
|
+
var onError = useCallback(function (data) {
|
|
54
|
+
var url = data.url,
|
|
55
|
+
err = data.err;
|
|
56
|
+
if (err) {
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
onResolve({
|
|
60
|
+
url: url
|
|
61
|
+
});
|
|
62
|
+
}, [onResolve]);
|
|
63
|
+
var card = useMemo(function () {
|
|
64
|
+
return /*#__PURE__*/React.createElement(SmartCard, {
|
|
65
|
+
key: url,
|
|
66
|
+
url: url,
|
|
67
|
+
data: data,
|
|
68
|
+
appearance: "inline",
|
|
69
|
+
onClick: onClick,
|
|
70
|
+
container: scrollContainer,
|
|
71
|
+
onResolve: onResolve,
|
|
72
|
+
onError: onError,
|
|
73
|
+
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
74
|
+
actionOptions: actionOptions,
|
|
75
|
+
showServerActions: showServerActions,
|
|
76
|
+
isHovered: isHovered
|
|
77
|
+
});
|
|
78
|
+
}, [data, isHovered, onError, onResolve, scrollContainer, url, useAlternativePreloader, actionOptions, showServerActions, onClick]);
|
|
79
|
+
|
|
80
|
+
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
81
|
+
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
82
|
+
return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
83
|
+
value: cardContext.value
|
|
84
|
+
}, card) : data ? card : null;
|
|
85
|
+
});
|
|
8
86
|
var WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
|
|
87
|
+
var WrappedInlineCard = Card(InlineCard, UnsupportedInline);
|
|
9
88
|
export function InlineCardNodeView(props) {
|
|
10
89
|
var useAlternativePreloader = props.useAlternativePreloader,
|
|
11
90
|
node = props.node,
|
|
@@ -18,6 +97,20 @@ export function InlineCardNodeView(props) {
|
|
|
18
97
|
enableInlineUpgradeFeatures = props.enableInlineUpgradeFeatures,
|
|
19
98
|
pluginInjectionApi = props.pluginInjectionApi,
|
|
20
99
|
onClickCallback = props.onClickCallback;
|
|
100
|
+
if (fg('platform.linking-platform.smart-links-in-live-pages')) {
|
|
101
|
+
return /*#__PURE__*/React.createElement(OverlayWrapper, {
|
|
102
|
+
targetElementPos: getPos(),
|
|
103
|
+
view: view
|
|
104
|
+
}, /*#__PURE__*/React.createElement(WrappedInlineCard, {
|
|
105
|
+
node: node,
|
|
106
|
+
view: view,
|
|
107
|
+
getPos: getPos,
|
|
108
|
+
actionOptions: actionOptions,
|
|
109
|
+
showServerActions: showServerActions,
|
|
110
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
111
|
+
onClickCallback: onClickCallback
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
21
114
|
return /*#__PURE__*/React.createElement(WrappedInlineCardWithAwareness, _extends({
|
|
22
115
|
node: node,
|
|
23
116
|
view: view,
|
|
@@ -28,16 +121,4 @@ export function InlineCardNodeView(props) {
|
|
|
28
121
|
pluginInjectionApi: pluginInjectionApi,
|
|
29
122
|
onClickCallback: onClickCallback
|
|
30
123
|
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards)));
|
|
31
|
-
}
|
|
32
|
-
var getAwarenessProps = function getAwarenessProps(editorState, getPos, allowEmbeds, allowBlockCards) {
|
|
33
|
-
var _editorState$selectio, _editorState$selectio2;
|
|
34
|
-
var linkPosition = getPos && typeof getPos() === 'number' ? getPos() : undefined;
|
|
35
|
-
var canBeUpgradedToEmbed = !!linkPosition && allowEmbeds ? isEmbedSupportedAtPosition(linkPosition, editorState, 'inline') : false;
|
|
36
|
-
var canBeUpgradedToBlock = !!linkPosition && allowBlockCards ? isBlockSupportedAtPosition(linkPosition, editorState, 'inline') : false;
|
|
37
|
-
var isSelected = editorState.selection instanceof NodeSelection && ((_editorState$selectio = editorState.selection) === null || _editorState$selectio === void 0 || (_editorState$selectio = _editorState$selectio.node) === null || _editorState$selectio === void 0 ? void 0 : _editorState$selectio.type) === editorState.schema.nodes.inlineCard && ((_editorState$selectio2 = editorState.selection) === null || _editorState$selectio2 === void 0 ? void 0 : _editorState$selectio2.from) === getPos();
|
|
38
|
-
return {
|
|
39
|
-
isPulseEnabled: canBeUpgradedToEmbed,
|
|
40
|
-
isOverlayEnabled: canBeUpgradedToEmbed || canBeUpgradedToBlock,
|
|
41
|
-
isSelected: isSelected
|
|
42
|
-
};
|
|
43
|
-
};
|
|
124
|
+
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
3
|
-
import
|
|
4
|
-
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
5
|
-
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
6
|
-
import { registerCard, registerRemoveOverlay } from '../pm-plugins/actions';
|
|
3
|
+
import { registerRemoveOverlay } from '../pm-plugins/actions';
|
|
7
4
|
import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
8
|
-
|
|
5
|
+
import { InlineCard } from './inlineCard';
|
|
6
|
+
export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
9
7
|
var node = _ref.node,
|
|
10
8
|
cardContext = _ref.cardContext,
|
|
11
9
|
actionOptions = _ref.actionOptions,
|
|
@@ -13,15 +11,11 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
13
11
|
useAlternativePreloader = _ref.useAlternativePreloader,
|
|
14
12
|
view = _ref.view,
|
|
15
13
|
getPos = _ref.getPos,
|
|
16
|
-
isOverlayEnabled = _ref.isOverlayEnabled,
|
|
17
|
-
isPulseEnabled = _ref.isPulseEnabled,
|
|
18
14
|
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
url = _node$attrs.url,
|
|
24
|
-
data = _node$attrs.data;
|
|
15
|
+
onClick = _ref.onClick,
|
|
16
|
+
isPulseEnabled = _ref.isPulseEnabled,
|
|
17
|
+
isOverlayEnabled = _ref.isOverlayEnabled,
|
|
18
|
+
isSelected = _ref.isSelected;
|
|
25
19
|
var _useState = useState(false),
|
|
26
20
|
_useState2 = _slicedToArray(_useState, 2),
|
|
27
21
|
isHovered = _useState2[0],
|
|
@@ -34,50 +28,14 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
34
28
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
35
29
|
isResolvedViewRendered = _useState6[0],
|
|
36
30
|
setIsResolvedViewRendered = _useState6[1];
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!getPos || typeof getPos === 'boolean') {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
var title = data.title,
|
|
45
|
-
url = data.url;
|
|
46
|
-
// don't dispatch immediately since we might be in the middle of
|
|
47
|
-
// rendering a nodeview
|
|
48
|
-
rafSchedule(function () {
|
|
49
|
-
// prosemirror-bump-fix
|
|
50
|
-
var pos = getPos();
|
|
51
|
-
if (typeof pos !== 'number') {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
var tr = view.state.tr;
|
|
55
|
-
registerCard({
|
|
56
|
-
title: title,
|
|
57
|
-
url: url,
|
|
58
|
-
pos: pos
|
|
59
|
-
})(tr);
|
|
60
|
-
registerRemoveOverlay(function () {
|
|
61
|
-
return setIsInserted(false);
|
|
62
|
-
})(tr);
|
|
63
|
-
view.dispatch(tr);
|
|
64
|
-
})();
|
|
31
|
+
var onResolve = useCallback(function (tr, title) {
|
|
32
|
+
registerRemoveOverlay(function () {
|
|
33
|
+
return setIsInserted(false);
|
|
34
|
+
})(tr);
|
|
65
35
|
if (title) {
|
|
66
36
|
setIsResolvedViewRendered(true);
|
|
67
37
|
}
|
|
68
|
-
}, [
|
|
69
|
-
var onError = useCallback(function (data) {
|
|
70
|
-
var url = data.url,
|
|
71
|
-
err = data.err;
|
|
72
|
-
if (err) {
|
|
73
|
-
throw err;
|
|
74
|
-
}
|
|
75
|
-
onResolve({
|
|
76
|
-
url: url
|
|
77
|
-
});
|
|
78
|
-
}, [onResolve]);
|
|
79
|
-
|
|
80
|
-
// Begin Upgrade Awareness related code
|
|
38
|
+
}, []);
|
|
81
39
|
var markMostRecentlyInsertedLink = useCallback(function (isLinkMostRecentlyInserted) {
|
|
82
40
|
if (isOverlayEnabled) {
|
|
83
41
|
setIsInserted(isLinkMostRecentlyInserted);
|
|
@@ -88,51 +46,37 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
88
46
|
setIsHovered(isHovered);
|
|
89
47
|
}
|
|
90
48
|
}, [isOverlayEnabled]);
|
|
91
|
-
// End Upgrade Awareness related code
|
|
92
|
-
|
|
93
49
|
var innerCard = useMemo(function () {
|
|
94
|
-
return /*#__PURE__*/React.createElement(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
onClick: onClick,
|
|
100
|
-
container: scrollContainer,
|
|
101
|
-
onResolve: onResolve,
|
|
102
|
-
onError: onError,
|
|
103
|
-
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
50
|
+
return /*#__PURE__*/React.createElement(InlineCard, {
|
|
51
|
+
node: node,
|
|
52
|
+
view: view,
|
|
53
|
+
getPos: getPos,
|
|
54
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
104
55
|
actionOptions: actionOptions,
|
|
105
56
|
showServerActions: showServerActions,
|
|
57
|
+
onResolve: onResolve,
|
|
58
|
+
onClick: onClick,
|
|
59
|
+
cardContext: cardContext,
|
|
106
60
|
isHovered: isHovered
|
|
107
61
|
});
|
|
108
|
-
}, [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}, innerCard);
|
|
130
|
-
}, [cardContext, getPos, innerCard, isHovered, isInserted, isOverlayEnabled, isPulseEnabled, isResolvedViewRendered, isSelected, markMostRecentlyInsertedLink, pluginInjectionApi, setOverlayHoveredStyles, url, view]);
|
|
131
|
-
|
|
132
|
-
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
133
|
-
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
134
|
-
return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
135
|
-
value: cardContext.value
|
|
136
|
-
}, card) : data ? card : null;
|
|
137
|
-
};
|
|
138
|
-
export var InlineCardWithAwareness = /*#__PURE__*/memo(InlineCard);
|
|
62
|
+
}, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, showServerActions, useAlternativePreloader, view]);
|
|
63
|
+
return isOverlayEnabled || isPulseEnabled ? /*#__PURE__*/React.createElement(AwarenessWrapper, {
|
|
64
|
+
isOverlayEnabled: isOverlayEnabled,
|
|
65
|
+
isPulseEnabled: isPulseEnabled,
|
|
66
|
+
cardContext: cardContext,
|
|
67
|
+
getPos: getPos,
|
|
68
|
+
isHovered: isHovered,
|
|
69
|
+
isInserted: isInserted,
|
|
70
|
+
url: node.attrs.url,
|
|
71
|
+
isSelected: isSelected,
|
|
72
|
+
isResolvedViewRendered: isResolvedViewRendered,
|
|
73
|
+
markMostRecentlyInsertedLink: markMostRecentlyInsertedLink,
|
|
74
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
75
|
+
setOverlayHoveredStyles: setOverlayHoveredStyles
|
|
76
|
+
}, innerCard) :
|
|
77
|
+
/*#__PURE__*/
|
|
78
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
79
|
+
React.createElement("span", {
|
|
80
|
+
className: "card"
|
|
81
|
+
}, innerCard);
|
|
82
|
+
});
|
package/dist/esm/plugin.js
CHANGED
|
@@ -7,10 +7,10 @@ import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
|
7
7
|
import { IconDatasourceAssetsObjects, IconDatasourceConfluenceSearch, IconDatasourceJiraIssue } from '@atlaskit/editor-common/quick-insert';
|
|
8
8
|
import { canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, CONFLUENCE_SEARCH_DATASOURCE_ID } from '@atlaskit/link-datasource';
|
|
10
|
-
import {
|
|
11
|
-
import { queueCardsFromChangedTr } from '../src/pm-plugins/doc';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
11
|
import { createEventsQueue } from './analytics/create-events-queue';
|
|
13
12
|
import { hideLinkToolbar, showDatasourceModal } from './pm-plugins/actions';
|
|
13
|
+
import { queueCardsFromChangedTr } from './pm-plugins/doc';
|
|
14
14
|
import { cardKeymap } from './pm-plugins/keymap';
|
|
15
15
|
import { createPlugin } from './pm-plugins/main';
|
|
16
16
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
@@ -135,7 +135,7 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
135
135
|
if (canRenderDatasource(ASSETS_LIST_OF_LINKS_DATASOURCE_ID)) {
|
|
136
136
|
quickInsertArray.push({
|
|
137
137
|
id: 'datasource',
|
|
138
|
-
title:
|
|
138
|
+
title: fg('platform.linking-platform.datasource-assets_objects_remove_beta') ? formatMessage(messages.datasourceAssetsObjectsGeneralAvailability) : formatMessage(messages.datasourceAssetsObjects),
|
|
139
139
|
description: formatMessage(messages.datasourceAssetsObjectsDescription),
|
|
140
140
|
categories: ['external-content', 'development'],
|
|
141
141
|
keywords: ['assets'],
|
|
@@ -5,11 +5,9 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
5
5
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
6
|
import { css, jsx } from '@emotion/react';
|
|
7
7
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
8
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import useLinkUpgradeDiscoverability from '../../common/hooks/useLinkUpgradeDiscoverability';
|
|
10
9
|
import { isLocalStorageKeyDiscovered, LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK, LOCAL_STORAGE_DISCOVERY_KEY_TOOLBAR, markLocalStorageKeyDiscovered, ONE_DAY_IN_MILLISECONDS } from '../../common/local-storage';
|
|
11
10
|
import { getResolvedAttributesFromStore } from '../../utils';
|
|
12
|
-
import OverlayWrapper from '../ConfigureOverlay';
|
|
13
11
|
import InlineCardOverlay from '../InlineCardOverlay';
|
|
14
12
|
import { DiscoveryPulse } from '../Pulse';
|
|
15
13
|
// editor adds a standard line-height that is bigger than an inline smart link
|
|
@@ -33,8 +31,7 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
|
|
|
33
31
|
markMostRecentlyInsertedLink = _ref.markMostRecentlyInsertedLink,
|
|
34
32
|
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
35
33
|
setOverlayHoveredStyles = _ref.setOverlayHoveredStyles,
|
|
36
|
-
url = _ref.url
|
|
37
|
-
view = _ref.view;
|
|
34
|
+
url = _ref.url;
|
|
38
35
|
var _useState = useState(false),
|
|
39
36
|
_useState2 = _slicedToArray(_useState, 2),
|
|
40
37
|
isHovered = _useState2[0],
|
|
@@ -74,12 +71,6 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
|
|
|
74
71
|
setOverlayHoveredStyles(isHovered);
|
|
75
72
|
}, [setOverlayHoveredStyles]);
|
|
76
73
|
var cardWithOverlay = useMemo(function () {
|
|
77
|
-
if (getBooleanFF('platform.linking-platform.smart-links-in-live-pages')) {
|
|
78
|
-
return jsx(OverlayWrapper, {
|
|
79
|
-
targetElementPos: linkPosition,
|
|
80
|
-
view: view
|
|
81
|
-
}, children);
|
|
82
|
-
}
|
|
83
74
|
if (shouldShowLinkOverlay) {
|
|
84
75
|
return jsx(InlineCardOverlay, {
|
|
85
76
|
isSelected: isSelected,
|
|
@@ -94,7 +85,7 @@ export var AwarenessWrapper = function AwarenessWrapper(_ref) {
|
|
|
94
85
|
}, children);
|
|
95
86
|
}
|
|
96
87
|
return children;
|
|
97
|
-
}, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url,
|
|
88
|
+
}, [shouldShowLinkOverlay, children, isSelected, isResolvedViewRendered, isInserted, isHovered, url, handleOverlayChange]);
|
|
98
89
|
return useMemo(function () {
|
|
99
90
|
var _cardContext$value;
|
|
100
91
|
return (
|