@atlaskit/editor-plugin-card 4.3.5 → 4.3.7
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 +18 -0
- package/dist/cjs/toolbar.js +25 -64
- package/dist/cjs/ui/EditLinkToolbar.js +2 -2
- package/dist/cjs/ui/EditToolbarButton/EditToolbarButtonPresentation.js +2 -2
- package/dist/cjs/ui/EditToolbarButton/index.js +2 -2
- package/dist/cjs/ui/HyperlinkToolbarAppearance.js +1 -9
- package/dist/cjs/ui/editDatasourceAction.js +31 -0
- package/dist/es2019/toolbar.js +25 -62
- package/dist/es2019/ui/EditLinkToolbar.js +1 -1
- package/dist/es2019/ui/EditToolbarButton/EditToolbarButtonPresentation.js +1 -1
- package/dist/es2019/ui/EditToolbarButton/index.js +1 -1
- package/dist/es2019/ui/HyperlinkToolbarAppearance.js +1 -9
- package/dist/es2019/ui/editDatasourceAction.js +25 -0
- package/dist/esm/toolbar.js +27 -66
- package/dist/esm/ui/EditLinkToolbar.js +1 -1
- package/dist/esm/ui/EditToolbarButton/EditToolbarButtonPresentation.js +1 -1
- package/dist/esm/ui/EditToolbarButton/index.js +1 -1
- package/dist/esm/ui/HyperlinkToolbarAppearance.js +1 -9
- package/dist/esm/ui/editDatasourceAction.js +25 -0
- package/dist/types/ui/EditLinkToolbar.d.ts +1 -1
- package/dist/types/ui/editDatasourceAction.d.ts +4 -0
- package/dist/types-ts4.5/ui/EditLinkToolbar.d.ts +1 -1
- package/dist/types-ts4.5/ui/editDatasourceAction.d.ts +4 -0
- package/package.json +5 -8
- package/dist/cjs/ui/EditDatasourceButton.js +0 -113
- package/dist/es2019/ui/EditDatasourceButton.js +0 -108
- package/dist/esm/ui/EditDatasourceButton.js +0 -106
- package/dist/types/ui/EditDatasourceButton.d.ts +0 -18
- package/dist/types-ts4.5/ui/EditDatasourceButton.d.ts +0 -18
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import { useCallback } from 'react';
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
|
-
import { css, jsx } from '@emotion/react';
|
|
9
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
10
|
-
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
11
|
-
import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator, SmallerEditIcon } from '@atlaskit/editor-common/ui';
|
|
12
|
-
import { getDatasourceType } from '@atlaskit/editor-common/utils';
|
|
13
|
-
import { Flex } from '@atlaskit/primitives';
|
|
14
|
-
import { showDatasourceModal } from '../pm-plugins/actions';
|
|
15
|
-
import { focusEditorView, isDatasourceConfigEditable } from '../utils';
|
|
16
|
-
import { CardContextProvider } from './CardContextProvider';
|
|
17
|
-
import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
|
|
18
|
-
var buttonStyles = css({
|
|
19
|
-
pointerEvents: 'auto'
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// Edit button in toolbar to open datasource modal. This button is shown for inline, block, and embed cards
|
|
23
|
-
// if they can resolve into a datasource.
|
|
24
|
-
var EditDatasourceButtonWithCardContext = function EditDatasourceButtonWithCardContext(_ref) {
|
|
25
|
-
var cardContext = _ref.cardContext,
|
|
26
|
-
datasourceIdFromAdf = _ref.datasourceId,
|
|
27
|
-
intl = _ref.intl,
|
|
28
|
-
editorAnalyticsApi = _ref.editorAnalyticsApi,
|
|
29
|
-
url = _ref.url,
|
|
30
|
-
editorView = _ref.editorView,
|
|
31
|
-
currentAppearance = _ref.currentAppearance;
|
|
32
|
-
var _useFetchDatasourceIn = useFetchDatasourceInfo({
|
|
33
|
-
isRegularCardNode: true,
|
|
34
|
-
url: url,
|
|
35
|
-
cardContext: cardContext
|
|
36
|
-
}),
|
|
37
|
-
datasourceIdFromUrl = _useFetchDatasourceIn.datasourceId,
|
|
38
|
-
extensionKey = _useFetchDatasourceIn.extensionKey;
|
|
39
|
-
var datasourceId = datasourceIdFromUrl !== null && datasourceIdFromUrl !== void 0 ? datasourceIdFromUrl : datasourceIdFromAdf;
|
|
40
|
-
var onEditDatasource = useCallback(function () {
|
|
41
|
-
if (editorView && datasourceId) {
|
|
42
|
-
editDatasource(datasourceId, editorAnalyticsApi, currentAppearance, extensionKey)(editorView.state, editorView.dispatch);
|
|
43
|
-
focusEditorView(editorView);
|
|
44
|
-
}
|
|
45
|
-
}, [currentAppearance, datasourceId, editorAnalyticsApi, editorView, extensionKey]);
|
|
46
|
-
if (!datasourceId || !isDatasourceConfigEditable(datasourceId)) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
if (url) {
|
|
50
|
-
var _cardContext$store, _urlState$error;
|
|
51
|
-
var urlState = cardContext === null || cardContext === void 0 || (_cardContext$store = cardContext.store) === null || _cardContext$store === void 0 ? void 0 : _cardContext$store.getState()[url];
|
|
52
|
-
if ((urlState === null || urlState === void 0 || (_urlState$error = urlState.error) === null || _urlState$error === void 0 ? void 0 : _urlState$error.kind) === 'fatal') {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return jsx(Flex, null, jsx(Button, {
|
|
57
|
-
css: buttonStyles,
|
|
58
|
-
title: intl.formatMessage(messages.datasourceTitle),
|
|
59
|
-
icon: jsx(SmallerEditIcon, null),
|
|
60
|
-
selected: false,
|
|
61
|
-
onClick: onEditDatasource,
|
|
62
|
-
testId: 'card-edit-datasource-button'
|
|
63
|
-
}), jsx(Separator, null));
|
|
64
|
-
};
|
|
65
|
-
export var EditDatasourceButton = function EditDatasourceButton(_ref2) {
|
|
66
|
-
var datasourceId = _ref2.datasourceId,
|
|
67
|
-
intl = _ref2.intl,
|
|
68
|
-
editorAnalyticsApi = _ref2.editorAnalyticsApi,
|
|
69
|
-
url = _ref2.url,
|
|
70
|
-
editorView = _ref2.editorView,
|
|
71
|
-
currentAppearance = _ref2.currentAppearance;
|
|
72
|
-
return jsx(CardContextProvider, null, function (_ref3) {
|
|
73
|
-
var cardContext = _ref3.cardContext;
|
|
74
|
-
return jsx(EditDatasourceButtonWithCardContext, {
|
|
75
|
-
datasourceId: datasourceId,
|
|
76
|
-
url: url,
|
|
77
|
-
intl: intl,
|
|
78
|
-
editorAnalyticsApi: editorAnalyticsApi,
|
|
79
|
-
editorView: editorView,
|
|
80
|
-
cardContext: cardContext,
|
|
81
|
-
currentAppearance: currentAppearance
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
export var editDatasource = function editDatasource(datasourceId, editorAnalyticsApi, appearance, extensionKey) {
|
|
86
|
-
return function (state, dispatch) {
|
|
87
|
-
var datasourceType = getDatasourceType(datasourceId);
|
|
88
|
-
if (dispatch && datasourceType) {
|
|
89
|
-
var tr = state.tr;
|
|
90
|
-
showDatasourceModal(datasourceType)(tr);
|
|
91
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
92
|
-
action: ACTION.CLICKED,
|
|
93
|
-
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
94
|
-
actionSubjectId: ACTION_SUBJECT_ID.EDIT_DATASOURCE,
|
|
95
|
-
eventType: EVENT_TYPE.UI,
|
|
96
|
-
attributes: {
|
|
97
|
-
extensionKey: extensionKey,
|
|
98
|
-
appearance: appearance
|
|
99
|
-
}
|
|
100
|
-
})(tr);
|
|
101
|
-
dispatch(tr);
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
return false;
|
|
105
|
-
};
|
|
106
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx } from '@emotion/react';
|
|
2
|
-
import type { IntlShape } from 'react-intl-next';
|
|
3
|
-
import { type EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { type Command } from '@atlaskit/editor-common/types';
|
|
5
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import type { CardContext } from '@atlaskit/link-provider';
|
|
7
|
-
import { type CardType } from '../types';
|
|
8
|
-
export interface EditDatasourceButtonProps {
|
|
9
|
-
datasourceId?: string;
|
|
10
|
-
intl: IntlShape;
|
|
11
|
-
editorAnalyticsApi?: EditorAnalyticsAPI;
|
|
12
|
-
url?: string;
|
|
13
|
-
editorView?: EditorView;
|
|
14
|
-
cardContext?: CardContext;
|
|
15
|
-
currentAppearance?: CardType;
|
|
16
|
-
}
|
|
17
|
-
export declare const EditDatasourceButton: ({ datasourceId, intl, editorAnalyticsApi, url, editorView, currentAppearance, }: EditDatasourceButtonProps) => jsx.JSX.Element;
|
|
18
|
-
export declare const editDatasource: (datasourceId: string, editorAnalyticsApi?: EditorAnalyticsAPI, appearance?: CardType, extensionKey?: string) => Command;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx } from '@emotion/react';
|
|
2
|
-
import type { IntlShape } from 'react-intl-next';
|
|
3
|
-
import { type EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { type Command } from '@atlaskit/editor-common/types';
|
|
5
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import type { CardContext } from '@atlaskit/link-provider';
|
|
7
|
-
import { type CardType } from '../types';
|
|
8
|
-
export interface EditDatasourceButtonProps {
|
|
9
|
-
datasourceId?: string;
|
|
10
|
-
intl: IntlShape;
|
|
11
|
-
editorAnalyticsApi?: EditorAnalyticsAPI;
|
|
12
|
-
url?: string;
|
|
13
|
-
editorView?: EditorView;
|
|
14
|
-
cardContext?: CardContext;
|
|
15
|
-
currentAppearance?: CardType;
|
|
16
|
-
}
|
|
17
|
-
export declare const EditDatasourceButton: ({ datasourceId, intl, editorAnalyticsApi, url, editorView, currentAppearance, }: EditDatasourceButtonProps) => jsx.JSX.Element;
|
|
18
|
-
export declare const editDatasource: (datasourceId: string, editorAnalyticsApi?: EditorAnalyticsAPI, appearance?: CardType, extensionKey?: string) => Command;
|