@atlaskit/editor-core 185.5.7 → 185.6.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 +18 -0
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +21 -8
- package/dist/cjs/plugins/card/pm-plugins/actions.js +14 -2
- package/dist/cjs/plugins/card/pm-plugins/doc.js +34 -2
- package/dist/cjs/plugins/card/pm-plugins/main.js +1 -0
- package/dist/cjs/plugins/card/pm-plugins/reducers.js +8 -0
- package/dist/cjs/plugins/card/styles.js +2 -1
- package/dist/cjs/plugins/card/toolbar.js +53 -1
- package/dist/cjs/plugins/card/ui/DatasourceModal.js +41 -0
- package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +45 -2
- package/dist/cjs/plugins/card/ui/SmallerEditIcon.js +20 -0
- package/dist/cjs/plugins/card/ui/styled.js +5 -3
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +21 -8
- package/dist/es2019/plugins/card/pm-plugins/actions.js +6 -0
- package/dist/es2019/plugins/card/pm-plugins/doc.js +34 -1
- package/dist/es2019/plugins/card/pm-plugins/main.js +1 -0
- package/dist/es2019/plugins/card/pm-plugins/reducers.js +9 -0
- package/dist/es2019/plugins/card/styles.js +23 -2
- package/dist/es2019/plugins/card/toolbar.js +54 -2
- package/dist/es2019/plugins/card/ui/DatasourceModal.js +30 -0
- package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +43 -1
- package/dist/es2019/plugins/card/ui/SmallerEditIcon.js +11 -0
- package/dist/es2019/plugins/card/ui/styled.js +3 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/ReactEditorViewInternal.js +21 -8
- package/dist/esm/plugins/card/pm-plugins/actions.js +10 -0
- package/dist/esm/plugins/card/pm-plugins/doc.js +32 -1
- package/dist/esm/plugins/card/pm-plugins/main.js +1 -0
- package/dist/esm/plugins/card/pm-plugins/reducers.js +8 -0
- package/dist/esm/plugins/card/styles.js +4 -3
- package/dist/esm/plugins/card/toolbar.js +54 -2
- package/dist/esm/plugins/card/ui/DatasourceModal.js +31 -0
- package/dist/esm/plugins/card/ui/EditLinkToolbar.js +42 -1
- package/dist/esm/plugins/card/ui/SmallerEditIcon.js +11 -0
- package/dist/esm/plugins/card/ui/styled.js +3 -2
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/create-editor/ReactEditorViewInternal.d.ts +1 -0
- package/dist/types/plugins/card/pm-plugins/actions.d.ts +2 -0
- package/dist/types/plugins/card/pm-plugins/doc.d.ts +3 -0
- package/dist/types/plugins/card/pm-plugins/util/state.d.ts +1 -0
- package/dist/types/plugins/card/types.d.ts +8 -1
- package/dist/types/plugins/card/ui/DatasourceModal.d.ts +13 -0
- package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +8 -1
- package/dist/types/plugins/card/ui/SmallerEditIcon.d.ts +3 -0
- package/dist/types/plugins/card/ui/styled.d.ts +1 -0
- package/dist/types/plugins/collab-edit/participants.d.ts +1 -1
- package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +1 -0
- package/dist/types-ts4.5/plugins/card/pm-plugins/actions.d.ts +2 -0
- package/dist/types-ts4.5/plugins/card/pm-plugins/doc.d.ts +3 -0
- package/dist/types-ts4.5/plugins/card/pm-plugins/util/state.d.ts +1 -0
- package/dist/types-ts4.5/plugins/card/types.d.ts +8 -1
- package/dist/types-ts4.5/plugins/card/ui/DatasourceModal.d.ts +13 -0
- package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +8 -1
- package/dist/types-ts4.5/plugins/card/ui/SmallerEditIcon.d.ts +3 -0
- package/dist/types-ts4.5/plugins/card/ui/styled.d.ts +1 -0
- package/dist/types-ts4.5/plugins/collab-edit/participants.d.ts +1 -1
- package/package.json +6 -6
|
@@ -11,13 +11,14 @@ import { changeSelectedCardToText } from './pm-plugins/doc';
|
|
|
11
11
|
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
12
12
|
import { pluginKey } from './pm-plugins/main';
|
|
13
13
|
import { richMediaClassName } from '@atlaskit/editor-common/styles';
|
|
14
|
-
import { buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/EditLinkToolbar';
|
|
14
|
+
import { editDatasource, buildEditLinkToolbar, editLink, editLinkToolbarConfig, openDatasourceModal } from './ui/EditLinkToolbar';
|
|
15
15
|
import { displayInfoForCard, findCardInfo, titleUrlPairFromNode, appearanceForNodeType } from './utils';
|
|
16
16
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
17
17
|
import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
|
|
18
18
|
import { messages } from './messages';
|
|
19
19
|
import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME } from './styles';
|
|
20
20
|
import { ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE, buildOpenedSettingsPayload, buildVisitedLinkPayload } from '@atlaskit/editor-common/analytics';
|
|
21
|
+
import { SmallerEditIcon } from './ui/SmallerEditIcon';
|
|
21
22
|
export const removeCard = editorAnalyticsApi => commandWithMetadata((state, dispatch) => {
|
|
22
23
|
if (!(state.selection instanceof NodeSelection)) {
|
|
23
24
|
return false;
|
|
@@ -163,7 +164,7 @@ const withToolbarMetadata = command => commandWithMetadata(command, {
|
|
|
163
164
|
inputMethod: INPUT_METHOD.FLOATING_TB
|
|
164
165
|
});
|
|
165
166
|
const generateToolbarItems = (state, featureFlags, intl, providerFactory, cardOptions, platform, linkPicker, pluginInjectionApi) => node => {
|
|
166
|
-
var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5;
|
|
167
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5, _node$attrs;
|
|
167
168
|
const {
|
|
168
169
|
url
|
|
169
170
|
} = titleUrlPairFromNode(node);
|
|
@@ -187,6 +188,7 @@ const generateToolbarItems = (state, featureFlags, intl, providerFactory, cardOp
|
|
|
187
188
|
const {
|
|
188
189
|
hoverDecoration
|
|
189
190
|
} = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.decorations) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {};
|
|
191
|
+
const isDatasource = currentAppearance === 'block' && (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
|
|
190
192
|
|
|
191
193
|
/* mobile builds toolbar natively using toolbarItems */
|
|
192
194
|
if (pluginState.showLinkingToolbar && platform !== 'mobile') {
|
|
@@ -197,6 +199,15 @@ const generateToolbarItems = (state, featureFlags, intl, providerFactory, cardOp
|
|
|
197
199
|
featureFlags,
|
|
198
200
|
pluginInjectionApi
|
|
199
201
|
})];
|
|
202
|
+
} else if (pluginState.showDatasourceModal) {
|
|
203
|
+
return [openDatasourceModal({
|
|
204
|
+
state,
|
|
205
|
+
node,
|
|
206
|
+
editorAnalyticsApi
|
|
207
|
+
})];
|
|
208
|
+
// not showing toolbar in mobile for now since not sure what our plans are for it
|
|
209
|
+
} else if (isDatasource && platform !== 'mobile') {
|
|
210
|
+
return getDatasourceButtonGroup(state, metadata, intl, editorAnalyticsApi, node, hoverDecoration);
|
|
200
211
|
} else {
|
|
201
212
|
const {
|
|
202
213
|
inlineCard
|
|
@@ -309,4 +320,45 @@ const getSettingsButtonGroup = (state, featureFlags, intl, editorAnalyticsApi) =
|
|
|
309
320
|
}, {
|
|
310
321
|
type: 'separator'
|
|
311
322
|
}] : [];
|
|
323
|
+
};
|
|
324
|
+
const getDatasourceButtonGroup = (state, metadata, intl, editorAnalyticsApi, node, hoverDecoration) => {
|
|
325
|
+
var _node$attrs2;
|
|
326
|
+
const toolbarItems = [{
|
|
327
|
+
id: 'editor.edit.datasource',
|
|
328
|
+
type: 'button',
|
|
329
|
+
icon: SmallerEditIcon,
|
|
330
|
+
metadata: metadata,
|
|
331
|
+
className: 'datasource-edit',
|
|
332
|
+
title: intl.formatMessage(linkToolbarMessages.editDatasource),
|
|
333
|
+
onClick: editDatasource(editorAnalyticsApi)
|
|
334
|
+
}];
|
|
335
|
+
if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
|
|
336
|
+
toolbarItems.push({
|
|
337
|
+
type: 'separator'
|
|
338
|
+
}, {
|
|
339
|
+
id: 'editor.link.openLink',
|
|
340
|
+
type: 'button',
|
|
341
|
+
icon: OpenIcon,
|
|
342
|
+
metadata: metadata,
|
|
343
|
+
className: 'hyperlink-open-link',
|
|
344
|
+
title: intl.formatMessage(linkMessages.openLink),
|
|
345
|
+
onClick: visitCardLink(editorAnalyticsApi)
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
toolbarItems.push({
|
|
349
|
+
type: 'separator'
|
|
350
|
+
}, {
|
|
351
|
+
id: 'editor.link.delete',
|
|
352
|
+
focusEditoronEnter: true,
|
|
353
|
+
type: 'button',
|
|
354
|
+
appearance: 'danger',
|
|
355
|
+
icon: RemoveIcon,
|
|
356
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
|
|
357
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
|
|
358
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
|
|
359
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
|
|
360
|
+
title: intl.formatMessage(commonMessages.remove),
|
|
361
|
+
onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
|
|
362
|
+
});
|
|
363
|
+
return toolbarItems;
|
|
312
364
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { JiraIssuesConfigModal } from '@atlaskit/link-datasource';
|
|
3
|
+
import { hideDatasourceModal } from '../pm-plugins/actions';
|
|
4
|
+
import { updateExistingDatasource } from '../pm-plugins/doc';
|
|
5
|
+
export const DatasourceModal = ({
|
|
6
|
+
state,
|
|
7
|
+
view,
|
|
8
|
+
node
|
|
9
|
+
}) => {
|
|
10
|
+
const isJiraDatasource = node.attrs.datasource.parameters.jql;
|
|
11
|
+
const onClose = useCallback(() => {
|
|
12
|
+
view.dispatch(hideDatasourceModal(view.state.tr));
|
|
13
|
+
}, [view]);
|
|
14
|
+
const onInsert = useCallback(newAdf => {
|
|
15
|
+
updateExistingDatasource(state, node, newAdf, view);
|
|
16
|
+
}, [state, node, view]);
|
|
17
|
+
if (isJiraDatasource) {
|
|
18
|
+
var _node$attrs$datasourc, _node$attrs$datasourc2;
|
|
19
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
"data-testId": "jira-config-modal"
|
|
21
|
+
}, /*#__PURE__*/React.createElement(JiraIssuesConfigModal, {
|
|
22
|
+
datasourceId: node.attrs.datasource.id,
|
|
23
|
+
visibleColumnKeys: (_node$attrs$datasourc = node.attrs.datasource.views[0]) === null || _node$attrs$datasourc === void 0 ? void 0 : (_node$attrs$datasourc2 = _node$attrs$datasourc.properties) === null || _node$attrs$datasourc2 === void 0 ? void 0 : _node$attrs$datasourc2.columns.map(column => column.key),
|
|
24
|
+
parameters: node.attrs.datasource.parameters,
|
|
25
|
+
onCancel: onClose,
|
|
26
|
+
onInsert: onInsert
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
return null; // null for now until we have modal component that handles other datasources
|
|
30
|
+
};
|
|
@@ -3,13 +3,14 @@ import React from 'react';
|
|
|
3
3
|
import { withOuterListeners } from '@atlaskit/editor-common/ui';
|
|
4
4
|
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
5
5
|
import HyperlinkToolbar from '../../hyperlink/ui/HyperlinkAddToolbar';
|
|
6
|
-
import { showLinkToolbar, hideLinkToolbar } from '../pm-plugins/actions';
|
|
6
|
+
import { showLinkToolbar, hideLinkToolbar, showDatasourceModal } from '../pm-plugins/actions';
|
|
7
7
|
import { INPUT_METHOD, ACTION, buildEditLinkPayload } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
import { LINKPICKER_HEIGHT_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '@atlaskit/editor-common/ui';
|
|
9
9
|
import { changeSelectedCardToLink, updateCard } from '../pm-plugins/doc';
|
|
10
10
|
import { findCardInfo, displayInfoForCard } from '../utils';
|
|
11
11
|
import { NodeSelection } from 'prosemirror-state';
|
|
12
12
|
import { linkToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
13
|
+
import { DatasourceModal } from './DatasourceModal';
|
|
13
14
|
const HyperLinkToolbarWithListeners = withOuterListeners(HyperlinkToolbar);
|
|
14
15
|
export class EditLinkToolbar extends React.Component {
|
|
15
16
|
constructor(...args) {
|
|
@@ -138,4 +139,45 @@ export const editLinkToolbarConfig = (showLinkingToolbar, lpLinkPicker) => {
|
|
|
138
139
|
width: RECENT_SEARCH_WIDTH_IN_PX,
|
|
139
140
|
forcePlacement: true
|
|
140
141
|
} : {};
|
|
142
|
+
};
|
|
143
|
+
export const editDatasource = editorAnalyticsApi => (state, dispatch) => {
|
|
144
|
+
if (dispatch) {
|
|
145
|
+
const {
|
|
146
|
+
tr
|
|
147
|
+
} = state;
|
|
148
|
+
showDatasourceModal(tr);
|
|
149
|
+
// editorAnalyticsApi?.attachAnalyticsEvent(
|
|
150
|
+
// buildEditLinkPayload(
|
|
151
|
+
// type as
|
|
152
|
+
// | ACTION_SUBJECT_ID.CARD_INLINE
|
|
153
|
+
// | ACTION_SUBJECT_ID.CARD_BLOCK
|
|
154
|
+
// | ACTION_SUBJECT_ID.EMBEDS,
|
|
155
|
+
// ),
|
|
156
|
+
// )(tr);
|
|
157
|
+
dispatch(tr);
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
};
|
|
162
|
+
export const openDatasourceModal = ({
|
|
163
|
+
state,
|
|
164
|
+
node,
|
|
165
|
+
editorAnalyticsApi
|
|
166
|
+
}) => {
|
|
167
|
+
return {
|
|
168
|
+
type: 'custom',
|
|
169
|
+
disableArrowNavigation: true,
|
|
170
|
+
fallback: [],
|
|
171
|
+
render: view => {
|
|
172
|
+
if (!view) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
return /*#__PURE__*/React.createElement(DatasourceModal, {
|
|
176
|
+
state: state,
|
|
177
|
+
view: view,
|
|
178
|
+
node: node,
|
|
179
|
+
editorAnalyticsApi: editorAnalyticsApi
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
};
|
|
141
183
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import EditIcon from '@atlaskit/icon/glyph/edit';
|
|
4
|
+
import { editIconStyles } from './styled';
|
|
5
|
+
export const SmallerEditIcon = () => {
|
|
6
|
+
return jsx("div", {
|
|
7
|
+
css: editIconStyles
|
|
8
|
+
}, jsx(EditIcon, {
|
|
9
|
+
label: "edit"
|
|
10
|
+
}));
|
|
11
|
+
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -481,14 +481,24 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
481
481
|
});
|
|
482
482
|
}
|
|
483
483
|
});
|
|
484
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
484
|
+
_defineProperty(_assertThisInitialized(_this), "createEditor", function (assistiveLabel) {
|
|
485
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
486
|
+
className: getUAPrefix(),
|
|
487
|
+
key: "ProseMirror",
|
|
488
|
+
ref: _this.handleEditorViewRef,
|
|
489
|
+
"aria-label": assistiveLabel || _this.props.intl.formatMessage(editorMessages.editorAssistiveLabel)
|
|
490
|
+
// setting aria-multiline to true when not mobile appearance.
|
|
491
|
+
// because somehow mobile tests are failing when it set.
|
|
492
|
+
// don't know why that is happening.
|
|
493
|
+
// Created https://product-fabric.atlassian.net/jira/servicedesk/projects/DTR/queues/issue/DTR-1675
|
|
494
|
+
// to investigate further.
|
|
495
|
+
,
|
|
496
|
+
"aria-multiline": _this.props.editorProps.appearance !== 'mobile' ? true : false,
|
|
497
|
+
role: "textbox",
|
|
498
|
+
id: EDIT_AREA_ID
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
_defineProperty(_assertThisInitialized(_this), "editor", _this.createEditor(_this.props.editorProps.assistiveLabel));
|
|
492
502
|
_this.pluginInjectionAPI = new EditorPluginInjectionAPI({
|
|
493
503
|
getEditorState: _this.getEditorState
|
|
494
504
|
});
|
|
@@ -617,6 +627,9 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
617
627
|
if (!this.transactionTracking.enabled) {
|
|
618
628
|
this.pluginPerformanceObserver.disconnect();
|
|
619
629
|
}
|
|
630
|
+
if (nextProps.editorProps.assistiveLabel !== this.props.editorProps.assistiveLabel) {
|
|
631
|
+
this.editor = this.createEditor(nextProps.editorProps.assistiveLabel);
|
|
632
|
+
}
|
|
620
633
|
}
|
|
621
634
|
}, {
|
|
622
635
|
key: "reconfigureState",
|
|
@@ -86,4 +86,14 @@ export var hideLinkToolbar = function hideLinkToolbar(tr) {
|
|
|
86
86
|
return cardAction(tr, {
|
|
87
87
|
type: 'HIDE_LINK_TOOLBAR'
|
|
88
88
|
});
|
|
89
|
+
};
|
|
90
|
+
export var showDatasourceModal = function showDatasourceModal(tr) {
|
|
91
|
+
return cardAction(tr, {
|
|
92
|
+
type: 'SHOW_DATASOURCE_MODAL'
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
export var hideDatasourceModal = function hideDatasourceModal(tr) {
|
|
96
|
+
return cardAction(tr, {
|
|
97
|
+
type: 'HIDE_DATASOURCE_MODAL'
|
|
98
|
+
});
|
|
89
99
|
};
|
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
+
import isEqual from 'lodash/isEqual';
|
|
5
6
|
import { NodeSelection, TextSelection } from 'prosemirror-state';
|
|
6
7
|
import { closeHistory } from 'prosemirror-history';
|
|
7
8
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
@@ -10,7 +11,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, SM
|
|
|
10
11
|
import { nodesBetweenChanged, processRawValue } from '@atlaskit/editor-common/utils';
|
|
11
12
|
import { isFromCurrentDomain, getLinkCreationAnalyticsEvent } from '@atlaskit/editor-common/utils';
|
|
12
13
|
import { appearanceForNodeType, selectedCardAppearance } from '../utils';
|
|
13
|
-
import { queueCards, resolveCard } from './actions';
|
|
14
|
+
import { queueCards, resolveCard, hideDatasourceModal } from './actions';
|
|
14
15
|
import { pluginKey } from './plugin-key';
|
|
15
16
|
import { shouldReplaceLink } from './shouldReplaceLink';
|
|
16
17
|
|
|
@@ -409,4 +410,34 @@ var getLinkNodeType = function getLinkNodeType(appearance, linkNodes) {
|
|
|
409
410
|
case 'embed':
|
|
410
411
|
return linkNodes.embedCard;
|
|
411
412
|
}
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
// Apply an update to a datasource (aka blockCard) node
|
|
416
|
+
export var updateExistingDatasource = function updateExistingDatasource(state, node, newAdf, view) {
|
|
417
|
+
var tr = state.tr,
|
|
418
|
+
from = state.selection.from,
|
|
419
|
+
schemaNodes = state.schema.nodes;
|
|
420
|
+
|
|
421
|
+
// datasource to datasource
|
|
422
|
+
if (newAdf.type === 'blockCard' && newAdf.attrs.datasource && node.attrs.datasource) {
|
|
423
|
+
var _ref, _ref2, _newViews$, _newViews$$properties, _oldViews$, _oldViews$$properties, _newAdf$attrs, _node$attrs;
|
|
424
|
+
var newViews = (_ref = newAdf.attrs.datasource.views) !== null && _ref !== void 0 ? _ref : [];
|
|
425
|
+
var oldViews = (_ref2 = node.attrs.datasource.views) !== null && _ref2 !== void 0 ? _ref2 : [];
|
|
426
|
+
var newColumnKeys = (_newViews$ = newViews[0]) === null || _newViews$ === void 0 ? void 0 : (_newViews$$properties = _newViews$.properties) === null || _newViews$$properties === void 0 ? void 0 : _newViews$$properties.columns.map(function (column) {
|
|
427
|
+
return column.key;
|
|
428
|
+
});
|
|
429
|
+
var oldColumnKeys = (_oldViews$ = oldViews[0]) === null || _oldViews$ === void 0 ? void 0 : (_oldViews$$properties = _oldViews$.properties) === null || _oldViews$$properties === void 0 ? void 0 : _oldViews$$properties.columns.map(function (column) {
|
|
430
|
+
return column.key;
|
|
431
|
+
});
|
|
432
|
+
var isColumnChange = !isEqual(oldColumnKeys, newColumnKeys);
|
|
433
|
+
var isUrlChange = ((_newAdf$attrs = newAdf.attrs) === null || _newAdf$attrs === void 0 ? void 0 : _newAdf$attrs.url) !== ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.url);
|
|
434
|
+
if (isColumnChange || isUrlChange) {
|
|
435
|
+
tr.setNodeMarkup(from, schemaNodes.blockCard, newAdf.attrs);
|
|
436
|
+
}
|
|
437
|
+
} else if (newAdf.type === 'inlineCard') {
|
|
438
|
+
// datasource to inline
|
|
439
|
+
tr.setNodeMarkup(from, schemaNodes.inlineCard, newAdf.attrs);
|
|
440
|
+
}
|
|
441
|
+
hideDatasourceModal(tr);
|
|
442
|
+
view.dispatch(tr.scrollIntoView());
|
|
412
443
|
};
|
|
@@ -38,6 +38,7 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
38
38
|
smartLinkEventsNext: undefined,
|
|
39
39
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
40
40
|
editorAppearance: editorAppearance,
|
|
41
|
+
showDatasourceModal: false,
|
|
41
42
|
datasourceTableRef: undefined,
|
|
42
43
|
layout: undefined
|
|
43
44
|
};
|
|
@@ -60,6 +60,11 @@ var setLinkToolbar = function setLinkToolbar(state, action) {
|
|
|
60
60
|
showLinkingToolbar: action.type === 'SHOW_LINK_TOOLBAR'
|
|
61
61
|
});
|
|
62
62
|
};
|
|
63
|
+
var setDatasourceModal = function setDatasourceModal(state, action) {
|
|
64
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
65
|
+
showDatasourceModal: action.type === 'SHOW_DATASOURCE_MODAL'
|
|
66
|
+
});
|
|
67
|
+
};
|
|
63
68
|
export default (function (state, action) {
|
|
64
69
|
switch (action.type) {
|
|
65
70
|
case 'QUEUE':
|
|
@@ -83,5 +88,8 @@ export default (function (state, action) {
|
|
|
83
88
|
case 'SHOW_LINK_TOOLBAR':
|
|
84
89
|
case 'HIDE_LINK_TOOLBAR':
|
|
85
90
|
return setLinkToolbar(state, action);
|
|
91
|
+
case 'SHOW_DATASOURCE_MODAL':
|
|
92
|
+
case 'HIDE_DATASOURCE_MODAL':
|
|
93
|
+
return setDatasourceModal(state, action);
|
|
86
94
|
}
|
|
87
95
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
var _templateObject;
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
-
import { SelectionStyle, getSelectionStyles, akEditorDeleteBorder, akEditorDeleteBackground } from '@atlaskit/editor-shared-styles';
|
|
5
|
-
import { N20 } from '@atlaskit/theme/colors';
|
|
4
|
+
import { SelectionStyle, getSelectionStyles, akEditorDeleteBorder, akEditorDeleteBackground, akEditorRuleBorderRadius } from '@atlaskit/editor-shared-styles';
|
|
5
|
+
import { N0, N20, N40 } from '@atlaskit/theme/colors';
|
|
6
6
|
import { SmartCardSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
7
7
|
import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
|
|
8
|
+
import { DATASOURCE_INNER_CONTAINER_CLASSNAME } from './nodeviews/datasource';
|
|
8
9
|
export var FLOATING_TOOLBAR_LINKPICKER_CLASSNAME = 'card-floating-toolbar--link-picker';
|
|
9
|
-
export var smartCardStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n max-width: calc(100% - 20px);\n vertical-align: top;\n word-break: break-all;\n\n .card {\n padding-left: 2px;\n padding-right: 2px;\n padding-top: 0.5em;\n padding-bottom: 0.5em;\n margin-bottom: -0.5em;\n\n .", " > a:focus {\n ", "\n }\n }\n\n &.", "\n .", "\n > a {\n ", "\n }\n .", " > a {\n /* EDM-1717: box-shadow Safari fix start */\n z-index: 1;\n position: relative;\n /* EDM-1717: box-shadow Safari fix end */\n }\n\n &.danger {\n .", " > a {\n box-shadow: 0 0 0 1px\n ", ";\n /* EDM-1717: box-shadow Safari fix start */\n z-index: 2;\n /* EDM-1717: box-shadow Safari fix end */\n }\n }\n }\n\n .", " {\n .", " > div {\n cursor: pointer;\n &:hover {\n background-color: ", ";\n }\n }\n\n &.", "\n .", "\n > div {\n ", "\n }\n\n &.danger {\n .", " > div {\n box-shadow: 0 0 0 1px\n ", " !important;\n }\n }\n }\n\n .", ".", " {\n max-width: 100%;\n display: flex;\n justify-content: center;\n }\n\n .", " {\n .", " > div {\n cursor: pointer;\n &::after {\n transition: box-shadow 0s;\n }\n }\n &.", "\n .", "\n > div {\n ", "\n }\n\n &.", "\n .", "\n > div::after {\n ", "\n }\n\n &.danger {\n .media-card-frame::after {\n box-shadow: 0 0 0 1px\n ", " !important;\n background: ", " !important;\n }\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n background: ", ";\n }\n }\n }\n\n .", " {\n padding: 0;\n }\n"])), SmartCardSharedCssClassName.INLINE_CARD_CONTAINER, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), SmartCardSharedCssClassName.LOADER_WRAPPER, SmartCardSharedCssClassName.LOADER_WRAPPER, "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), SmartCardSharedCssClassName.BLOCK_CARD_CONTAINER, SmartCardSharedCssClassName.LOADER_WRAPPER, "var(--ds-background-neutral-subtle-hovered, ".concat(N20, ")"), akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), SmartCardSharedCssClassName.LOADER_WRAPPER, "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), SmartCardSharedCssClassName.DATASOURCE_CONTAINER, SmartCardSharedCssClassName.BLOCK_CARD_CONTAINER, SmartCardSharedCssClassName.EMBED_CARD_CONTAINER, SmartCardSharedCssClassName.LOADER_WRAPPER, akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), "var(--ds-background-danger, ".concat(akEditorDeleteBackground, ")"), "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), FLOATING_TOOLBAR_LINKPICKER_CLASSNAME);
|
|
10
|
+
export var smartCardStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n max-width: calc(100% - 20px);\n vertical-align: top;\n word-break: break-all;\n\n .card {\n padding-left: 2px;\n padding-right: 2px;\n padding-top: 0.5em;\n padding-bottom: 0.5em;\n margin-bottom: -0.5em;\n\n .", " > a:focus {\n ", "\n }\n }\n\n &.", "\n .", "\n > a {\n ", "\n }\n .", " > a {\n /* EDM-1717: box-shadow Safari fix start */\n z-index: 1;\n position: relative;\n /* EDM-1717: box-shadow Safari fix end */\n }\n\n &.danger {\n .", " > a {\n box-shadow: 0 0 0 1px\n ", ";\n /* EDM-1717: box-shadow Safari fix start */\n z-index: 2;\n /* EDM-1717: box-shadow Safari fix end */\n }\n }\n }\n\n .", " {\n .", " > div {\n cursor: pointer;\n &:hover {\n background-color: ", ";\n }\n }\n\n &.", "\n .", "\n > div {\n ", "\n }\n\n &.danger {\n .", " > div {\n box-shadow: 0 0 0 1px\n ", " !important;\n }\n }\n }\n\n .", ".", " {\n max-width: 100%;\n display: flex;\n justify-content: center;\n\n .", " {\n cursor: pointer;\n background-color: ", ";\n border-radius: ", ";\n border: 1px solid ", ";\n }\n\n &.", " {\n .", " {\n ", "\n }\n }\n\n &.danger {\n .", " {\n box-shadow: 0 0 0 1px\n ", ";\n }\n }\n }\n\n .", " {\n .", " > div {\n cursor: pointer;\n &::after {\n transition: box-shadow 0s;\n }\n }\n &.", "\n .", "\n > div {\n ", "\n }\n\n &.", "\n .", "\n > div::after {\n ", "\n }\n\n &.danger {\n .media-card-frame::after {\n box-shadow: 0 0 0 1px\n ", " !important;\n background: ", " !important;\n }\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n background: ", ";\n }\n }\n }\n\n .", " {\n padding: 0;\n }\n"])), SmartCardSharedCssClassName.INLINE_CARD_CONTAINER, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), SmartCardSharedCssClassName.LOADER_WRAPPER, SmartCardSharedCssClassName.LOADER_WRAPPER, "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), SmartCardSharedCssClassName.BLOCK_CARD_CONTAINER, SmartCardSharedCssClassName.LOADER_WRAPPER, "var(--ds-background-neutral-subtle-hovered, ".concat(N20, ")"), akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), SmartCardSharedCssClassName.LOADER_WRAPPER, "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), SmartCardSharedCssClassName.DATASOURCE_CONTAINER, SmartCardSharedCssClassName.BLOCK_CARD_CONTAINER, DATASOURCE_INNER_CONTAINER_CLASSNAME, "var(--ds-background-neutral-subtle, ".concat(N0, ")"), "var(--ds-border-radius-100, ".concat(akEditorRuleBorderRadius, ")"), "var(--ds-border, ".concat(N40, ")"), akEditorSelectedNodeClassName, DATASOURCE_INNER_CONTAINER_CLASSNAME, getSelectionStyles([SelectionStyle.BoxShadow]), DATASOURCE_INNER_CONTAINER_CLASSNAME, "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), SmartCardSharedCssClassName.EMBED_CARD_CONTAINER, SmartCardSharedCssClassName.LOADER_WRAPPER, akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), "var(--ds-background-danger, ".concat(akEditorDeleteBackground, ")"), "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), FLOATING_TOOLBAR_LINKPICKER_CLASSNAME);
|
|
@@ -15,13 +15,14 @@ import { changeSelectedCardToText } from './pm-plugins/doc';
|
|
|
15
15
|
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
16
16
|
import { pluginKey } from './pm-plugins/main';
|
|
17
17
|
import { richMediaClassName } from '@atlaskit/editor-common/styles';
|
|
18
|
-
import { buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/EditLinkToolbar';
|
|
18
|
+
import { editDatasource, buildEditLinkToolbar, editLink, editLinkToolbarConfig, openDatasourceModal } from './ui/EditLinkToolbar';
|
|
19
19
|
import { displayInfoForCard, findCardInfo, titleUrlPairFromNode, appearanceForNodeType } from './utils';
|
|
20
20
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
21
21
|
import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
|
|
22
22
|
import { messages } from './messages';
|
|
23
23
|
import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME } from './styles';
|
|
24
24
|
import { ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE, buildOpenedSettingsPayload, buildVisitedLinkPayload } from '@atlaskit/editor-common/analytics';
|
|
25
|
+
import { SmallerEditIcon } from './ui/SmallerEditIcon';
|
|
25
26
|
export var removeCard = function removeCard(editorAnalyticsApi) {
|
|
26
27
|
return commandWithMetadata(function (state, dispatch) {
|
|
27
28
|
if (!(state.selection instanceof NodeSelection)) {
|
|
@@ -161,7 +162,7 @@ var withToolbarMetadata = function withToolbarMetadata(command) {
|
|
|
161
162
|
};
|
|
162
163
|
var generateToolbarItems = function generateToolbarItems(state, featureFlags, intl, providerFactory, cardOptions, platform, linkPicker, pluginInjectionApi) {
|
|
163
164
|
return function (node) {
|
|
164
|
-
var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5;
|
|
165
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5, _node$attrs;
|
|
165
166
|
var _titleUrlPairFromNode2 = titleUrlPairFromNode(node),
|
|
166
167
|
url = _titleUrlPairFromNode2.url;
|
|
167
168
|
var _ref = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.analytics) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
|
|
@@ -181,6 +182,7 @@ var generateToolbarItems = function generateToolbarItems(state, featureFlags, in
|
|
|
181
182
|
var currentAppearance = appearanceForNodeType(node.type);
|
|
182
183
|
var _ref2 = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.decorations) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {},
|
|
183
184
|
hoverDecoration = _ref2.hoverDecoration;
|
|
185
|
+
var isDatasource = currentAppearance === 'block' && (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
|
|
184
186
|
|
|
185
187
|
/* mobile builds toolbar natively using toolbarItems */
|
|
186
188
|
if (pluginState.showLinkingToolbar && platform !== 'mobile') {
|
|
@@ -191,6 +193,15 @@ var generateToolbarItems = function generateToolbarItems(state, featureFlags, in
|
|
|
191
193
|
featureFlags: featureFlags,
|
|
192
194
|
pluginInjectionApi: pluginInjectionApi
|
|
193
195
|
})];
|
|
196
|
+
} else if (pluginState.showDatasourceModal) {
|
|
197
|
+
return [openDatasourceModal({
|
|
198
|
+
state: state,
|
|
199
|
+
node: node,
|
|
200
|
+
editorAnalyticsApi: editorAnalyticsApi
|
|
201
|
+
})];
|
|
202
|
+
// not showing toolbar in mobile for now since not sure what our plans are for it
|
|
203
|
+
} else if (isDatasource && platform !== 'mobile') {
|
|
204
|
+
return getDatasourceButtonGroup(state, metadata, intl, editorAnalyticsApi, node, hoverDecoration);
|
|
194
205
|
} else {
|
|
195
206
|
var inlineCard = state.schema.nodes.inlineCard;
|
|
196
207
|
var toolbarItems = [{
|
|
@@ -300,4 +311,45 @@ var getSettingsButtonGroup = function getSettingsButtonGroup(state, featureFlags
|
|
|
300
311
|
}, {
|
|
301
312
|
type: 'separator'
|
|
302
313
|
}] : [];
|
|
314
|
+
};
|
|
315
|
+
var getDatasourceButtonGroup = function getDatasourceButtonGroup(state, metadata, intl, editorAnalyticsApi, node, hoverDecoration) {
|
|
316
|
+
var _node$attrs2;
|
|
317
|
+
var toolbarItems = [{
|
|
318
|
+
id: 'editor.edit.datasource',
|
|
319
|
+
type: 'button',
|
|
320
|
+
icon: SmallerEditIcon,
|
|
321
|
+
metadata: metadata,
|
|
322
|
+
className: 'datasource-edit',
|
|
323
|
+
title: intl.formatMessage(linkToolbarMessages.editDatasource),
|
|
324
|
+
onClick: editDatasource(editorAnalyticsApi)
|
|
325
|
+
}];
|
|
326
|
+
if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
|
|
327
|
+
toolbarItems.push({
|
|
328
|
+
type: 'separator'
|
|
329
|
+
}, {
|
|
330
|
+
id: 'editor.link.openLink',
|
|
331
|
+
type: 'button',
|
|
332
|
+
icon: OpenIcon,
|
|
333
|
+
metadata: metadata,
|
|
334
|
+
className: 'hyperlink-open-link',
|
|
335
|
+
title: intl.formatMessage(linkMessages.openLink),
|
|
336
|
+
onClick: visitCardLink(editorAnalyticsApi)
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
toolbarItems.push({
|
|
340
|
+
type: 'separator'
|
|
341
|
+
}, {
|
|
342
|
+
id: 'editor.link.delete',
|
|
343
|
+
focusEditoronEnter: true,
|
|
344
|
+
type: 'button',
|
|
345
|
+
appearance: 'danger',
|
|
346
|
+
icon: RemoveIcon,
|
|
347
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
|
|
348
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
|
|
349
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
|
|
350
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
|
|
351
|
+
title: intl.formatMessage(commonMessages.remove),
|
|
352
|
+
onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
|
|
353
|
+
});
|
|
354
|
+
return toolbarItems;
|
|
303
355
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { JiraIssuesConfigModal } from '@atlaskit/link-datasource';
|
|
3
|
+
import { hideDatasourceModal } from '../pm-plugins/actions';
|
|
4
|
+
import { updateExistingDatasource } from '../pm-plugins/doc';
|
|
5
|
+
export var DatasourceModal = function DatasourceModal(_ref) {
|
|
6
|
+
var state = _ref.state,
|
|
7
|
+
view = _ref.view,
|
|
8
|
+
node = _ref.node;
|
|
9
|
+
var isJiraDatasource = node.attrs.datasource.parameters.jql;
|
|
10
|
+
var onClose = useCallback(function () {
|
|
11
|
+
view.dispatch(hideDatasourceModal(view.state.tr));
|
|
12
|
+
}, [view]);
|
|
13
|
+
var onInsert = useCallback(function (newAdf) {
|
|
14
|
+
updateExistingDatasource(state, node, newAdf, view);
|
|
15
|
+
}, [state, node, view]);
|
|
16
|
+
if (isJiraDatasource) {
|
|
17
|
+
var _node$attrs$datasourc, _node$attrs$datasourc2;
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
"data-testId": "jira-config-modal"
|
|
20
|
+
}, /*#__PURE__*/React.createElement(JiraIssuesConfigModal, {
|
|
21
|
+
datasourceId: node.attrs.datasource.id,
|
|
22
|
+
visibleColumnKeys: (_node$attrs$datasourc = node.attrs.datasource.views[0]) === null || _node$attrs$datasourc === void 0 ? void 0 : (_node$attrs$datasourc2 = _node$attrs$datasourc.properties) === null || _node$attrs$datasourc2 === void 0 ? void 0 : _node$attrs$datasourc2.columns.map(function (column) {
|
|
23
|
+
return column.key;
|
|
24
|
+
}),
|
|
25
|
+
parameters: node.attrs.datasource.parameters,
|
|
26
|
+
onCancel: onClose,
|
|
27
|
+
onInsert: onInsert
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
return null; // null for now until we have modal component that handles other datasources
|
|
31
|
+
};
|
|
@@ -11,13 +11,14 @@ import React from 'react';
|
|
|
11
11
|
import { withOuterListeners } from '@atlaskit/editor-common/ui';
|
|
12
12
|
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
13
13
|
import HyperlinkToolbar from '../../hyperlink/ui/HyperlinkAddToolbar';
|
|
14
|
-
import { showLinkToolbar, hideLinkToolbar as _hideLinkToolbar } from '../pm-plugins/actions';
|
|
14
|
+
import { showLinkToolbar, hideLinkToolbar as _hideLinkToolbar, showDatasourceModal } from '../pm-plugins/actions';
|
|
15
15
|
import { INPUT_METHOD, ACTION, buildEditLinkPayload } from '@atlaskit/editor-common/analytics';
|
|
16
16
|
import { LINKPICKER_HEIGHT_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '@atlaskit/editor-common/ui';
|
|
17
17
|
import { changeSelectedCardToLink, updateCard } from '../pm-plugins/doc';
|
|
18
18
|
import { findCardInfo, displayInfoForCard } from '../utils';
|
|
19
19
|
import { NodeSelection } from 'prosemirror-state';
|
|
20
20
|
import { linkToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
21
|
+
import { DatasourceModal } from './DatasourceModal';
|
|
21
22
|
var HyperLinkToolbarWithListeners = withOuterListeners(HyperlinkToolbar);
|
|
22
23
|
export var EditLinkToolbar = /*#__PURE__*/function (_React$Component) {
|
|
23
24
|
_inherits(EditLinkToolbar, _React$Component);
|
|
@@ -161,4 +162,44 @@ export var editLinkToolbarConfig = function editLinkToolbarConfig(showLinkingToo
|
|
|
161
162
|
width: RECENT_SEARCH_WIDTH_IN_PX,
|
|
162
163
|
forcePlacement: true
|
|
163
164
|
} : {};
|
|
165
|
+
};
|
|
166
|
+
export var editDatasource = function editDatasource(editorAnalyticsApi) {
|
|
167
|
+
return function (state, dispatch) {
|
|
168
|
+
if (dispatch) {
|
|
169
|
+
var tr = state.tr;
|
|
170
|
+
showDatasourceModal(tr);
|
|
171
|
+
// editorAnalyticsApi?.attachAnalyticsEvent(
|
|
172
|
+
// buildEditLinkPayload(
|
|
173
|
+
// type as
|
|
174
|
+
// | ACTION_SUBJECT_ID.CARD_INLINE
|
|
175
|
+
// | ACTION_SUBJECT_ID.CARD_BLOCK
|
|
176
|
+
// | ACTION_SUBJECT_ID.EMBEDS,
|
|
177
|
+
// ),
|
|
178
|
+
// )(tr);
|
|
179
|
+
dispatch(tr);
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
export var openDatasourceModal = function openDatasourceModal(_ref2) {
|
|
186
|
+
var state = _ref2.state,
|
|
187
|
+
node = _ref2.node,
|
|
188
|
+
editorAnalyticsApi = _ref2.editorAnalyticsApi;
|
|
189
|
+
return {
|
|
190
|
+
type: 'custom',
|
|
191
|
+
disableArrowNavigation: true,
|
|
192
|
+
fallback: [],
|
|
193
|
+
render: function render(view) {
|
|
194
|
+
if (!view) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
return /*#__PURE__*/React.createElement(DatasourceModal, {
|
|
198
|
+
state: state,
|
|
199
|
+
view: view,
|
|
200
|
+
node: node,
|
|
201
|
+
editorAnalyticsApi: editorAnalyticsApi
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
};
|
|
164
205
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import EditIcon from '@atlaskit/icon/glyph/edit';
|
|
4
|
+
import { editIconStyles } from './styled';
|
|
5
|
+
export var SmallerEditIcon = function SmallerEditIcon() {
|
|
6
|
+
return jsx("div", {
|
|
7
|
+
css: editIconStyles
|
|
8
|
+
}, jsx(EditIcon, {
|
|
9
|
+
label: "edit"
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2;
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
export var embedCardStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n .embedCardView-content-wrap[layout^='wrap-'] {\n max-width: 100%;\n }\n\n .embedCardView-content-wrap[layout='wrap-left'] {\n float: left;\n }\n\n .embedCardView-content-wrap[layout='wrap-right'] {\n float: right;\n }\n\n .embedCardView-content-wrap[layout='wrap-right']\n + .embedCardView-content-wrap[layout='wrap-left'] {\n clear: both;\n }\n }\n"])));
|
|
5
|
-
export var embedSpacingStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin: 0 10px;\n"])));
|
|
5
|
+
export var embedSpacingStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin: 0 10px;\n"])));
|
|
6
|
+
export var editIconStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 20px;\n"])));
|
package/dist/esm/version.json
CHANGED
|
@@ -110,6 +110,7 @@ export declare class ReactEditorView<T = {}> extends React.Component<EditorViewP
|
|
|
110
110
|
private createEditorView;
|
|
111
111
|
handleEditorViewRef: (node: HTMLDivElement) => void;
|
|
112
112
|
dispatchAnalyticsEvent: (payload: AnalyticsEventPayload) => void;
|
|
113
|
+
private createEditor;
|
|
113
114
|
private editor;
|
|
114
115
|
render(): JSX.Element;
|
|
115
116
|
}
|
|
@@ -18,3 +18,5 @@ export declare const setCardLayoutAndDatasourceTableRef: ({ layout, datasourceTa
|
|
|
18
18
|
}) => (tr: Transaction) => Transaction<any>;
|
|
19
19
|
export declare const showLinkToolbar: (tr: Transaction) => Transaction<any>;
|
|
20
20
|
export declare const hideLinkToolbar: (tr: Transaction) => Transaction<any>;
|
|
21
|
+
export declare const showDatasourceModal: (tr: Transaction) => Transaction<any>;
|
|
22
|
+
export declare const hideDatasourceModal: (tr: Transaction) => Transaction<any>;
|