@atlaskit/editor-plugin-card 4.5.0 → 4.5.1
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 +8 -0
- package/dist/cjs/nodeviews/blockCard.js +0 -4
- package/dist/cjs/nodeviews/datasource.js +14 -26
- package/dist/cjs/nodeviews/embedCard.js +4 -15
- package/dist/cjs/nodeviews/genericCard.js +17 -19
- package/dist/cjs/ui/DatasourceAppearanceButton.js +11 -13
- package/dist/cjs/ui/DatasourceModal/ModalWithState.js +16 -10
- package/dist/cjs/ui/EditToolbarButton/index.js +26 -28
- package/dist/cjs/ui/EditorLinkingPlatformAnalytics/index.js +5 -25
- package/dist/cjs/ui/LinkToolbarAppearance.js +5 -6
- package/dist/cjs/ui/ToolbarViewedEvent.js +7 -9
- package/dist/cjs/ui/WithCardContext.js +14 -0
- package/dist/es2019/nodeviews/blockCard.js +0 -4
- package/dist/es2019/nodeviews/datasource.js +14 -26
- package/dist/es2019/nodeviews/embedCard.js +4 -16
- package/dist/es2019/nodeviews/genericCard.js +5 -9
- package/dist/es2019/ui/DatasourceAppearanceButton.js +4 -5
- package/dist/es2019/ui/DatasourceModal/ModalWithState.js +14 -6
- package/dist/es2019/ui/EditToolbarButton/index.js +26 -29
- package/dist/es2019/ui/EditorLinkingPlatformAnalytics/index.js +4 -23
- package/dist/es2019/ui/LinkToolbarAppearance.js +3 -6
- package/dist/es2019/ui/ToolbarViewedEvent.js +4 -5
- package/dist/es2019/ui/WithCardContext.js +8 -0
- package/dist/esm/nodeviews/blockCard.js +0 -4
- package/dist/esm/nodeviews/datasource.js +14 -26
- package/dist/esm/nodeviews/embedCard.js +4 -15
- package/dist/esm/nodeviews/genericCard.js +17 -19
- package/dist/esm/ui/DatasourceAppearanceButton.js +11 -13
- package/dist/esm/ui/DatasourceModal/ModalWithState.js +16 -10
- package/dist/esm/ui/EditToolbarButton/index.js +26 -28
- package/dist/esm/ui/EditorLinkingPlatformAnalytics/index.js +5 -25
- package/dist/esm/ui/LinkToolbarAppearance.js +6 -6
- package/dist/esm/ui/ToolbarViewedEvent.js +7 -9
- package/dist/esm/ui/WithCardContext.js +7 -0
- package/dist/types/nodeviews/blockCard.d.ts +0 -4
- package/dist/types/nodeviews/datasource.d.ts +0 -5
- package/dist/types/nodeviews/embedCard.d.ts +0 -5
- package/dist/types/ui/DatasourceAppearanceButton.d.ts +1 -1
- package/dist/types/ui/DatasourceModal/ModalWithState.d.ts +4 -3
- package/dist/types/ui/EditorLinkingPlatformAnalytics/index.d.ts +1 -6
- package/dist/types/ui/LinkToolbarAppearance.d.ts +1 -6
- package/dist/types/ui/WithCardContext.d.ts +5 -0
- package/dist/types-ts4.5/nodeviews/blockCard.d.ts +0 -4
- package/dist/types-ts4.5/nodeviews/datasource.d.ts +0 -5
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +0 -5
- package/dist/types-ts4.5/ui/DatasourceAppearanceButton.d.ts +1 -1
- package/dist/types-ts4.5/ui/DatasourceModal/ModalWithState.d.ts +4 -3
- package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/index.d.ts +1 -6
- package/dist/types-ts4.5/ui/LinkToolbarAppearance.d.ts +1 -6
- package/dist/types-ts4.5/ui/WithCardContext.d.ts +5 -0
- package/package.json +1 -1
- package/dist/cjs/ui/CardContextProvider.js +0 -47
- package/dist/es2019/ui/CardContextProvider.js +0 -22
- package/dist/esm/ui/CardContextProvider.js +0 -40
- package/dist/types/ui/CardContextProvider.d.ts +0 -20
- package/dist/types-ts4.5/ui/CardContextProvider.d.ts +0 -20
|
@@ -7,12 +7,12 @@ import React from 'react';
|
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
9
|
import { jsx } from '@emotion/react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
10
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
12
11
|
import { DATASOURCE_INNER_CONTAINER_CLASSNAME, SmartCardSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
13
12
|
import { UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
14
13
|
import { calcBreakoutWidth } from '@atlaskit/editor-common/utils';
|
|
15
14
|
import { DatasourceTableView } from '@atlaskit/link-datasource';
|
|
15
|
+
import { EditorSmartCardProvider, EditorSmartCardProviderValueGuard } from '@atlaskit/link-provider';
|
|
16
16
|
import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
|
|
17
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
18
|
import { DatasourceErrorBoundary } from '../datasourceErrorBoundary';
|
|
@@ -29,8 +29,6 @@ const getPosSafely = pos => {
|
|
|
29
29
|
};
|
|
30
30
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
31
31
|
export class DatasourceComponent extends React.PureComponent {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
-
|
|
34
32
|
constructor(props) {
|
|
35
33
|
super(props);
|
|
36
34
|
_defineProperty(this, "getDatasource", () => this.props.node.attrs.datasource);
|
|
@@ -148,7 +146,6 @@ export class DatasourceComponent extends React.PureComponent {
|
|
|
148
146
|
};
|
|
149
147
|
}
|
|
150
148
|
render() {
|
|
151
|
-
const cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
|
|
152
149
|
const datasource = this.getDatasource();
|
|
153
150
|
const attrs = this.props.node.attrs;
|
|
154
151
|
const tableView = this.getTableView();
|
|
@@ -158,32 +155,23 @@ export class DatasourceComponent extends React.PureComponent {
|
|
|
158
155
|
columnCustomSizes,
|
|
159
156
|
wrappedColumnKeys
|
|
160
157
|
} = this.getColumnsInfo();
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
onColumnResize: this.handleColumnResize,
|
|
175
|
-
columnCustomSizes: columnCustomSizes,
|
|
176
|
-
onWrappedColumnChange: this.handleWrappedColumnChange,
|
|
177
|
-
wrappedColumnKeys: wrappedColumnKeys
|
|
178
|
-
})));
|
|
179
|
-
}
|
|
158
|
+
return jsx(EditorSmartCardProviderValueGuard, null, jsx(EditorAnalyticsContext, {
|
|
159
|
+
editorView: this.props.view
|
|
160
|
+
}, jsx(EditorSmartCardProvider, null, jsx(DatasourceTableView, {
|
|
161
|
+
datasourceId: datasource.id,
|
|
162
|
+
parameters: datasource.parameters,
|
|
163
|
+
visibleColumnKeys: visibleColumnKeys,
|
|
164
|
+
onVisibleColumnKeysChange: this.handleColumnChange,
|
|
165
|
+
url: attrs === null || attrs === void 0 ? void 0 : attrs.url,
|
|
166
|
+
onColumnResize: this.handleColumnResize,
|
|
167
|
+
columnCustomSizes: columnCustomSizes,
|
|
168
|
+
onWrappedColumnChange: this.handleWrappedColumnChange,
|
|
169
|
+
wrappedColumnKeys: wrappedColumnKeys
|
|
170
|
+
}))));
|
|
180
171
|
}
|
|
181
172
|
return null;
|
|
182
173
|
}
|
|
183
174
|
}
|
|
184
|
-
_defineProperty(DatasourceComponent, "contextTypes", {
|
|
185
|
-
contextAdapter: PropTypes.object
|
|
186
|
-
});
|
|
187
175
|
export class Datasource extends ReactNodeView {
|
|
188
176
|
constructor(props) {
|
|
189
177
|
var _props$pluginInjectio, _props$pluginInjectio2, _sharedState$currentS;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
4
|
import rafSchedule from 'raf-schd';
|
|
6
5
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
7
6
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
@@ -143,8 +142,9 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
143
142
|
})(view.state.tr));
|
|
144
143
|
})();
|
|
145
144
|
try {
|
|
146
|
-
|
|
147
|
-
const
|
|
145
|
+
var _this$props$cardConte, _this$props$cardConte2;
|
|
146
|
+
const cardContext = (_this$props$cardConte = this.props.cardContext) !== null && _this$props$cardConte !== void 0 && _this$props$cardConte.value ? (_this$props$cardConte2 = this.props.cardContext) === null || _this$props$cardConte2 === void 0 ? void 0 : _this$props$cardConte2.value : undefined;
|
|
147
|
+
const hasPreview = url && cardContext && cardContext.extractors.getPreview(url, 'web');
|
|
148
148
|
if (!hasPreview) {
|
|
149
149
|
this.setState({
|
|
150
150
|
hasPreview: false
|
|
@@ -240,13 +240,9 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
240
240
|
});
|
|
241
241
|
this.scrollContainer = findOverflowScrollParent(props.view.dom) || undefined;
|
|
242
242
|
}
|
|
243
|
-
|
|
244
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
245
|
-
|
|
246
243
|
render() {
|
|
247
244
|
const {
|
|
248
245
|
node,
|
|
249
|
-
cardContext,
|
|
250
246
|
allowResizing,
|
|
251
247
|
fullWidthMode,
|
|
252
248
|
view,
|
|
@@ -298,7 +294,7 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
298
294
|
embedIframeRef: this.embedIframeRef,
|
|
299
295
|
actionOptions: actionOptions
|
|
300
296
|
});
|
|
301
|
-
|
|
297
|
+
return /*#__PURE__*/React.createElement(EmbedResizeMessageListener, {
|
|
302
298
|
embedIframeRef: this.embedIframeRef,
|
|
303
299
|
onHeightUpdate: this.onHeightUpdate
|
|
304
300
|
}, /*#__PURE__*/React.createElement(CardInner, {
|
|
@@ -317,16 +313,8 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
317
313
|
cardProps: cardProps,
|
|
318
314
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
319
315
|
}));
|
|
320
|
-
|
|
321
|
-
// [WS-2307]: we only render card wrapped into a Provider when the value is ready
|
|
322
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
323
|
-
value: cardContext.value
|
|
324
|
-
}, cardInner) : null);
|
|
325
316
|
}
|
|
326
317
|
}
|
|
327
|
-
_defineProperty(EmbedCardComponent, "contextTypes", {
|
|
328
|
-
contextAdapter: PropTypes.object
|
|
329
|
-
});
|
|
330
318
|
const WrappedBlockCard = Card(EmbedCardComponent, UnsupportedBlock);
|
|
331
319
|
export class EmbedCard extends ReactNodeView {
|
|
332
320
|
constructor(...args) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import React, { useCallback } from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
4
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
6
5
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
7
6
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
@@ -9,6 +8,7 @@ import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
|
|
|
9
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
9
|
import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
|
|
11
10
|
import { getPluginState } from '../pm-plugins/util/state';
|
|
11
|
+
import { WithCardContext } from '../ui/WithCardContext';
|
|
12
12
|
import { titleUrlPairFromNode } from '../utils';
|
|
13
13
|
const WithClickHandler = ({
|
|
14
14
|
pluginInjectionApi,
|
|
@@ -52,8 +52,7 @@ const WithClickHandler = ({
|
|
|
52
52
|
}));
|
|
53
53
|
};
|
|
54
54
|
export function Card(SmartCardComponent, UnsupportedComponent) {
|
|
55
|
-
|
|
56
|
-
return _class = class extends React.Component {
|
|
55
|
+
return class extends React.Component {
|
|
57
56
|
constructor(...args) {
|
|
58
57
|
super(...args);
|
|
59
58
|
_defineProperty(this, "state", {
|
|
@@ -84,7 +83,6 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
|
|
|
84
83
|
return /*#__PURE__*/React.createElement(UnsupportedComponent, null);
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
|
-
const cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
|
|
88
86
|
const editorAppearance = (_getPluginState = getPluginState(this.props.view.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.editorAppearance;
|
|
89
87
|
const analyticsEditorAppearance = getAnalyticsEditorAppearance(editorAppearance);
|
|
90
88
|
return /*#__PURE__*/React.createElement(AnalyticsContext, {
|
|
@@ -102,12 +100,12 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
|
|
|
102
100
|
__livePage: this.props.__livePage
|
|
103
101
|
}, ({
|
|
104
102
|
onClick
|
|
105
|
-
}) => /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
|
|
103
|
+
}) => /*#__PURE__*/React.createElement(WithCardContext, null, cardContext => /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
|
|
106
104
|
key: url,
|
|
107
105
|
cardContext: cardContext
|
|
108
106
|
}, this.props, {
|
|
109
107
|
onClick: onClick
|
|
110
|
-
}))));
|
|
108
|
+
})))));
|
|
111
109
|
}
|
|
112
110
|
componentDidCatch(error) {
|
|
113
111
|
const maybeAPIError = error;
|
|
@@ -142,7 +140,5 @@ export function Card(SmartCardComponent, UnsupportedComponent) {
|
|
|
142
140
|
});
|
|
143
141
|
}
|
|
144
142
|
}
|
|
145
|
-
}
|
|
146
|
-
contextAdapter: PropTypes.object
|
|
147
|
-
}), _class;
|
|
143
|
+
};
|
|
148
144
|
}
|
|
@@ -11,10 +11,10 @@ import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
|
11
11
|
import { canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
12
12
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
13
|
import { buildDatasourceAdf } from '@atlaskit/link-datasource';
|
|
14
|
+
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
14
15
|
import { Flex } from '@atlaskit/primitives';
|
|
15
16
|
import { updateCardViaDatasource } from '../pm-plugins/doc';
|
|
16
17
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
17
|
-
import { CardContextProvider } from './CardContextProvider';
|
|
18
18
|
import { DatasourceIcon } from './DatasourceIcon';
|
|
19
19
|
import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
|
|
20
20
|
const buttonStyles = css({
|
|
@@ -108,9 +108,8 @@ export const DatasourceAppearanceButton = ({
|
|
|
108
108
|
selected,
|
|
109
109
|
inputMethod
|
|
110
110
|
}) => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}) => jsx(DatasourceAppearanceButtonWithCardContext, {
|
|
111
|
+
const cardContext = useSmartLinkContext();
|
|
112
|
+
return jsx(DatasourceAppearanceButtonWithCardContext, {
|
|
114
113
|
url: url,
|
|
115
114
|
intl: intl,
|
|
116
115
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
@@ -119,5 +118,5 @@ export const DatasourceAppearanceButton = ({
|
|
|
119
118
|
cardContext: cardContext,
|
|
120
119
|
selected: selected,
|
|
121
120
|
inputMethod: inputMethod
|
|
122
|
-
})
|
|
121
|
+
});
|
|
123
122
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, AssetsConfigModal, CONFLUENCE_SEARCH_DATASOURCE_ID, ConfluenceSearchConfigModal, JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
|
|
4
|
+
import { EditorSmartCardProviderValueGuard, useSmartLinkContext } from '@atlaskit/link-provider';
|
|
4
5
|
import { DatasourceErrorBoundary } from '../../datasourceErrorBoundary';
|
|
5
|
-
import { CardContextProvider } from '../CardContextProvider';
|
|
6
6
|
import { DatasourceModal } from './index';
|
|
7
7
|
const ModalWithState = ({
|
|
8
8
|
api,
|
|
9
9
|
editorView
|
|
10
10
|
}) => {
|
|
11
|
+
const cardContext = useSmartLinkContext();
|
|
11
12
|
const {
|
|
12
13
|
cardState
|
|
13
14
|
} = useSharedPluginState(api, ['card']);
|
|
@@ -28,15 +29,22 @@ const ModalWithState = ({
|
|
|
28
29
|
return /*#__PURE__*/React.createElement(DatasourceErrorBoundary, {
|
|
29
30
|
view: editorView,
|
|
30
31
|
datasourceModalType: datasourceModalType
|
|
31
|
-
}, /*#__PURE__*/React.createElement(
|
|
32
|
-
cardContext
|
|
33
|
-
}) => /*#__PURE__*/React.createElement(DatasourceModal, {
|
|
32
|
+
}, /*#__PURE__*/React.createElement(DatasourceModal, {
|
|
34
33
|
view: editorView,
|
|
35
34
|
cardContext: cardContext,
|
|
36
35
|
datasourceId: datasourceId,
|
|
37
36
|
componentType: componentType
|
|
38
|
-
}))
|
|
37
|
+
}));
|
|
39
38
|
};
|
|
39
|
+
const SafeModalWithState = /*#__PURE__*/React.memo(({
|
|
40
|
+
api,
|
|
41
|
+
editorView
|
|
42
|
+
}) => {
|
|
43
|
+
return /*#__PURE__*/React.createElement(EditorSmartCardProviderValueGuard, null, /*#__PURE__*/React.createElement(ModalWithState, {
|
|
44
|
+
api: api,
|
|
45
|
+
editorView: editorView
|
|
46
|
+
}));
|
|
47
|
+
});
|
|
40
48
|
export const modalTypeToComponentMap = {
|
|
41
49
|
jira: {
|
|
42
50
|
componentType: JiraIssuesConfigModal,
|
|
@@ -51,4 +59,4 @@ export const modalTypeToComponentMap = {
|
|
|
51
59
|
datasourceId: ASSETS_LIST_OF_LINKS_DATASOURCE_ID
|
|
52
60
|
}
|
|
53
61
|
};
|
|
54
|
-
export default
|
|
62
|
+
export default SafeModalWithState;
|
|
@@ -11,10 +11,10 @@ import { linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-
|
|
|
11
11
|
import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
|
|
12
12
|
import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu';
|
|
13
13
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
14
|
+
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
14
15
|
import { ButtonItem } from '@atlaskit/menu';
|
|
15
16
|
import { Flex } from '@atlaskit/primitives';
|
|
16
17
|
import { focusEditorView, isDatasourceConfigEditable } from '../../utils';
|
|
17
|
-
import { CardContextProvider } from '../CardContextProvider';
|
|
18
18
|
import { editDatasource } from '../editDatasourceAction';
|
|
19
19
|
import { useFetchDatasourceDataInfo } from '../useFetchDatasourceDataInfo';
|
|
20
20
|
import { useFetchDatasourceInfo } from '../useFetchDatasourceInfo';
|
|
@@ -241,35 +241,11 @@ export const EditToolbarButton = props => {
|
|
|
241
241
|
onLinkEditClick,
|
|
242
242
|
url
|
|
243
243
|
} = props;
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (props.url) {
|
|
248
|
-
return jsx(EditToolbarButtonWithUrl, {
|
|
249
|
-
datasourceId: datasourceId,
|
|
250
|
-
url: props.url,
|
|
251
|
-
intl: intl,
|
|
252
|
-
editorAnalyticsApi: editorAnalyticsApi,
|
|
253
|
-
editorView: editorView,
|
|
254
|
-
cardContext: cardContext,
|
|
255
|
-
onLinkEditClick: onLinkEditClick,
|
|
256
|
-
currentAppearance: currentAppearance
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
if (props.datasourceId && props.node) {
|
|
260
|
-
return jsx(EditToolbarButtonWithDatasourceId, {
|
|
261
|
-
datasourceId: props.datasourceId,
|
|
262
|
-
node: props.node,
|
|
263
|
-
intl: intl,
|
|
264
|
-
editorAnalyticsApi: editorAnalyticsApi,
|
|
265
|
-
editorView: editorView,
|
|
266
|
-
onLinkEditClick: onLinkEditClick,
|
|
267
|
-
currentAppearance: currentAppearance
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
return jsx(EditToolbarButtonWithCardContext, {
|
|
244
|
+
const cardContext = useSmartLinkContext();
|
|
245
|
+
if (props.url) {
|
|
246
|
+
return jsx(EditToolbarButtonWithUrl, {
|
|
271
247
|
datasourceId: datasourceId,
|
|
272
|
-
url: url,
|
|
248
|
+
url: props.url,
|
|
273
249
|
intl: intl,
|
|
274
250
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
275
251
|
editorView: editorView,
|
|
@@ -277,5 +253,26 @@ export const EditToolbarButton = props => {
|
|
|
277
253
|
onLinkEditClick: onLinkEditClick,
|
|
278
254
|
currentAppearance: currentAppearance
|
|
279
255
|
});
|
|
256
|
+
}
|
|
257
|
+
if (props.datasourceId && props.node) {
|
|
258
|
+
return jsx(EditToolbarButtonWithDatasourceId, {
|
|
259
|
+
datasourceId: props.datasourceId,
|
|
260
|
+
node: props.node,
|
|
261
|
+
intl: intl,
|
|
262
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
263
|
+
editorView: editorView,
|
|
264
|
+
onLinkEditClick: onLinkEditClick,
|
|
265
|
+
currentAppearance: currentAppearance
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
return jsx(EditToolbarButtonWithCardContext, {
|
|
269
|
+
datasourceId: datasourceId,
|
|
270
|
+
url: url,
|
|
271
|
+
intl: intl,
|
|
272
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
273
|
+
editorView: editorView,
|
|
274
|
+
cardContext: cardContext,
|
|
275
|
+
onLinkEditClick: onLinkEditClick,
|
|
276
|
+
currentAppearance: currentAppearance
|
|
280
277
|
});
|
|
281
278
|
};
|
|
@@ -1,33 +1,14 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import
|
|
2
|
+
import { EditorSmartCardProvider, EditorSmartCardProviderValueGuard } from '@atlaskit/link-provider';
|
|
4
3
|
import { EditorAnalyticsContext } from '../EditorAnalyticsContext';
|
|
5
4
|
import { DatasourceEventsBinding } from './DatasourceEvents';
|
|
6
5
|
import { LinkEventsBinding } from './LinkEvents';
|
|
7
6
|
|
|
8
7
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
9
8
|
export class EditorLinkingPlatformAnalytics extends React.PureComponent {
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
-
|
|
12
9
|
render() {
|
|
13
|
-
|
|
14
|
-
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;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The analytics hook needs to be able to communicate with the card context
|
|
18
|
-
* If we can't access it, don't mount the event bindings
|
|
19
|
-
* This effectively entirely disables all tracking behaviour
|
|
20
|
-
*/
|
|
21
|
-
if (!(cardContext !== null && cardContext !== void 0 && cardContext.value)) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
return /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
25
|
-
value: cardContext.value
|
|
26
|
-
}, /*#__PURE__*/React.createElement(EditorAnalyticsContext, {
|
|
10
|
+
return /*#__PURE__*/React.createElement(EditorSmartCardProvider, null, /*#__PURE__*/React.createElement(EditorSmartCardProviderValueGuard, null, /*#__PURE__*/React.createElement(EditorAnalyticsContext, {
|
|
27
11
|
editorView: this.props.editorView
|
|
28
|
-
}, /*#__PURE__*/React.createElement(LinkEventsBinding, this.props), /*#__PURE__*/React.createElement(DatasourceEventsBinding, this.props)));
|
|
12
|
+
}, /*#__PURE__*/React.createElement(LinkEventsBinding, this.props), /*#__PURE__*/React.createElement(DatasourceEventsBinding, this.props))));
|
|
29
13
|
}
|
|
30
|
-
}
|
|
31
|
-
_defineProperty(EditorLinkingPlatformAnalytics, "contextTypes", {
|
|
32
|
-
contextAdapter: PropTypes.object
|
|
33
|
-
});
|
|
14
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
3
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
5
4
|
import { ACTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
5
|
import { commandWithMetadata, getButtonGroupOption, LinkToolbarButtonGroup } from '@atlaskit/editor-common/card';
|
|
@@ -12,7 +11,9 @@ import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugi
|
|
|
12
11
|
import { shouldRenderToolbarPulse } from '../toolbar';
|
|
13
12
|
import { getResolvedAttributesFromStore } from '../utils';
|
|
14
13
|
import { DiscoveryPulse } from './Pulse';
|
|
14
|
+
import { WithCardContext } from './WithCardContext';
|
|
15
15
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
16
|
+
|
|
16
17
|
export class LinkToolbarAppearance extends React.Component {
|
|
17
18
|
constructor(...args) {
|
|
18
19
|
super(...args);
|
|
@@ -114,16 +115,12 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
117
|
render() {
|
|
117
|
-
const cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
|
|
118
118
|
const {
|
|
119
119
|
editorView
|
|
120
120
|
} = this.props;
|
|
121
|
-
return this.renderDropdown(editorView, cardContext && cardContext.value);
|
|
121
|
+
return /*#__PURE__*/React.createElement(WithCardContext, null, cardContext => this.renderDropdown(editorView, cardContext && cardContext.value));
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
_defineProperty(LinkToolbarAppearance, "contextTypes", {
|
|
125
|
-
contextAdapter: PropTypes.object
|
|
126
|
-
});
|
|
127
124
|
const getUnavailableMessage = (state, intl) => {
|
|
128
125
|
try {
|
|
129
126
|
const parentNode = state.selection.$from.node(1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
|
|
3
|
+
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
3
4
|
import { getResolvedAttributesFromStore } from '../utils';
|
|
4
|
-
import { CardContextProvider } from './CardContextProvider';
|
|
5
5
|
import { EditorAnalyticsContext } from './EditorAnalyticsContext';
|
|
6
6
|
/**
|
|
7
7
|
* Handles firing the toolbar viewed event
|
|
@@ -38,13 +38,12 @@ export const ToolbarViewedEvent = ({
|
|
|
38
38
|
display,
|
|
39
39
|
editorView
|
|
40
40
|
}) => {
|
|
41
|
+
const cardContext = useSmartLinkContext();
|
|
41
42
|
return /*#__PURE__*/React.createElement(EditorAnalyticsContext, {
|
|
42
43
|
editorView: editorView
|
|
43
|
-
}, /*#__PURE__*/React.createElement(
|
|
44
|
-
cardContext
|
|
45
|
-
}) => url ? /*#__PURE__*/React.createElement(ToolbarViewedEventBase, {
|
|
44
|
+
}, url ? /*#__PURE__*/React.createElement(ToolbarViewedEventBase, {
|
|
46
45
|
url: url,
|
|
47
46
|
display: display,
|
|
48
47
|
cardContext: cardContext
|
|
49
|
-
}) : null)
|
|
48
|
+
}) : null);
|
|
50
49
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSmartCardContext } from '@atlaskit/link-provider';
|
|
3
|
+
export const WithCardContext = ({
|
|
4
|
+
children
|
|
5
|
+
}) => {
|
|
6
|
+
const cardContext = useSmartCardContext();
|
|
7
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children(cardContext));
|
|
8
|
+
};
|
|
@@ -9,7 +9,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
9
9
|
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
|
|
10
10
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
11
|
import React from 'react';
|
|
12
|
-
import PropTypes from 'prop-types';
|
|
13
12
|
import rafSchedule from 'raf-schd';
|
|
14
13
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
15
14
|
import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
@@ -106,9 +105,6 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
106
105
|
}]);
|
|
107
106
|
return BlockCardComponent;
|
|
108
107
|
}(React.PureComponent);
|
|
109
|
-
_defineProperty(BlockCardComponent, "contextTypes", {
|
|
110
|
-
contextAdapter: PropTypes.object
|
|
111
|
-
});
|
|
112
108
|
var WrappedBlockCard = Card(BlockCardComponent, UnsupportedBlock);
|
|
113
109
|
export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
114
110
|
_inherits(BlockCard, _ReactNodeView);
|
|
@@ -19,12 +19,12 @@ import React from 'react';
|
|
|
19
19
|
|
|
20
20
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
21
21
|
import { jsx } from '@emotion/react';
|
|
22
|
-
import PropTypes from 'prop-types';
|
|
23
22
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
24
23
|
import { DATASOURCE_INNER_CONTAINER_CLASSNAME, SmartCardSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
25
24
|
import { UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
26
25
|
import { calcBreakoutWidth } from '@atlaskit/editor-common/utils';
|
|
27
26
|
import { DatasourceTableView } from '@atlaskit/link-datasource';
|
|
27
|
+
import { EditorSmartCardProvider, EditorSmartCardProviderValueGuard } from '@atlaskit/link-provider';
|
|
28
28
|
import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
|
|
29
29
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
30
30
|
import { DatasourceErrorBoundary } from '../datasourceErrorBoundary';
|
|
@@ -43,8 +43,6 @@ var getPosSafely = function getPosSafely(pos) {
|
|
|
43
43
|
export var DatasourceComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
44
44
|
_inherits(DatasourceComponent, _React$PureComponent);
|
|
45
45
|
var _super = _createSuper(DatasourceComponent);
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
-
|
|
48
46
|
function DatasourceComponent(props) {
|
|
49
47
|
var _this;
|
|
50
48
|
_classCallCheck(this, DatasourceComponent);
|
|
@@ -180,7 +178,6 @@ export var DatasourceComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
180
178
|
}, {
|
|
181
179
|
key: "render",
|
|
182
180
|
value: function render() {
|
|
183
|
-
var cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
|
|
184
181
|
var datasource = this.getDatasource();
|
|
185
182
|
var attrs = this.props.node.attrs;
|
|
186
183
|
var tableView = this.getTableView();
|
|
@@ -189,34 +186,25 @@ export var DatasourceComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
189
186
|
visibleColumnKeys = _this$getColumnsInfo10.visibleColumnKeys,
|
|
190
187
|
columnCustomSizes = _this$getColumnsInfo10.columnCustomSizes,
|
|
191
188
|
wrappedColumnKeys = _this$getColumnsInfo10.wrappedColumnKeys;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
onColumnResize: this.handleColumnResize,
|
|
206
|
-
columnCustomSizes: columnCustomSizes,
|
|
207
|
-
onWrappedColumnChange: this.handleWrappedColumnChange,
|
|
208
|
-
wrappedColumnKeys: wrappedColumnKeys
|
|
209
|
-
})));
|
|
210
|
-
}
|
|
189
|
+
return jsx(EditorSmartCardProviderValueGuard, null, jsx(EditorAnalyticsContext, {
|
|
190
|
+
editorView: this.props.view
|
|
191
|
+
}, jsx(EditorSmartCardProvider, null, jsx(DatasourceTableView, {
|
|
192
|
+
datasourceId: datasource.id,
|
|
193
|
+
parameters: datasource.parameters,
|
|
194
|
+
visibleColumnKeys: visibleColumnKeys,
|
|
195
|
+
onVisibleColumnKeysChange: this.handleColumnChange,
|
|
196
|
+
url: attrs === null || attrs === void 0 ? void 0 : attrs.url,
|
|
197
|
+
onColumnResize: this.handleColumnResize,
|
|
198
|
+
columnCustomSizes: columnCustomSizes,
|
|
199
|
+
onWrappedColumnChange: this.handleWrappedColumnChange,
|
|
200
|
+
wrappedColumnKeys: wrappedColumnKeys
|
|
201
|
+
}))));
|
|
211
202
|
}
|
|
212
203
|
return null;
|
|
213
204
|
}
|
|
214
205
|
}]);
|
|
215
206
|
return DatasourceComponent;
|
|
216
207
|
}(React.PureComponent);
|
|
217
|
-
_defineProperty(DatasourceComponent, "contextTypes", {
|
|
218
|
-
contextAdapter: PropTypes.object
|
|
219
|
-
});
|
|
220
208
|
export var Datasource = /*#__PURE__*/function (_ReactNodeView) {
|
|
221
209
|
_inherits(Datasource, _ReactNodeView);
|
|
222
210
|
var _super2 = _createSuper(Datasource);
|
|
@@ -12,7 +12,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
12
12
|
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
|
|
13
13
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
14
|
import React from 'react';
|
|
15
|
-
import PropTypes from 'prop-types';
|
|
16
15
|
import rafSchedule from 'raf-schd';
|
|
17
16
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
18
17
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
@@ -149,8 +148,9 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
149
148
|
})(view.state.tr));
|
|
150
149
|
})();
|
|
151
150
|
try {
|
|
152
|
-
var
|
|
153
|
-
var
|
|
151
|
+
var _this$props$cardConte, _this$props$cardConte2;
|
|
152
|
+
var cardContext = (_this$props$cardConte = _this.props.cardContext) !== null && _this$props$cardConte !== void 0 && _this$props$cardConte.value ? (_this$props$cardConte2 = _this.props.cardContext) === null || _this$props$cardConte2 === void 0 ? void 0 : _this$props$cardConte2.value : undefined;
|
|
153
|
+
var hasPreview = url && cardContext && cardContext.extractors.getPreview(url, 'web');
|
|
154
154
|
if (!hasPreview) {
|
|
155
155
|
_this.setState({
|
|
156
156
|
hasPreview: false
|
|
@@ -242,14 +242,11 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
242
242
|
_this.scrollContainer = findOverflowScrollParent(props.view.dom) || undefined;
|
|
243
243
|
return _this;
|
|
244
244
|
}
|
|
245
|
-
|
|
246
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
247
245
|
_createClass(EmbedCardComponent, [{
|
|
248
246
|
key: "render",
|
|
249
247
|
value: function render() {
|
|
250
248
|
var _this$props = this.props,
|
|
251
249
|
node = _this$props.node,
|
|
252
|
-
cardContext = _this$props.cardContext,
|
|
253
250
|
allowResizing = _this$props.allowResizing,
|
|
254
251
|
fullWidthMode = _this$props.fullWidthMode,
|
|
255
252
|
view = _this$props.view,
|
|
@@ -298,7 +295,7 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
298
295
|
embedIframeRef: this.embedIframeRef,
|
|
299
296
|
actionOptions: actionOptions
|
|
300
297
|
});
|
|
301
|
-
|
|
298
|
+
return /*#__PURE__*/React.createElement(EmbedResizeMessageListener, {
|
|
302
299
|
embedIframeRef: this.embedIframeRef,
|
|
303
300
|
onHeightUpdate: this.onHeightUpdate
|
|
304
301
|
}, /*#__PURE__*/React.createElement(CardInner, {
|
|
@@ -317,18 +314,10 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
317
314
|
cardProps: cardProps,
|
|
318
315
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
319
316
|
}));
|
|
320
|
-
|
|
321
|
-
// [WS-2307]: we only render card wrapped into a Provider when the value is ready
|
|
322
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
323
|
-
value: cardContext.value
|
|
324
|
-
}, cardInner) : null);
|
|
325
317
|
}
|
|
326
318
|
}]);
|
|
327
319
|
return EmbedCardComponent;
|
|
328
320
|
}(React.PureComponent);
|
|
329
|
-
_defineProperty(EmbedCardComponent, "contextTypes", {
|
|
330
|
-
contextAdapter: PropTypes.object
|
|
331
|
-
});
|
|
332
321
|
var WrappedBlockCard = Card(EmbedCardComponent, UnsupportedBlock);
|
|
333
322
|
export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
334
323
|
_inherits(EmbedCard, _ReactNodeView);
|