@atlaskit/editor-plugin-card 1.11.0 → 1.11.2
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/ui/DatasourceModal/ModalWithState.js +29 -5
- package/dist/cjs/ui/DatasourceModal/index.js +94 -163
- package/dist/es2019/ui/DatasourceModal/ModalWithState.js +31 -4
- package/dist/es2019/ui/DatasourceModal/index.js +89 -136
- package/dist/esm/ui/DatasourceModal/ModalWithState.js +28 -4
- package/dist/esm/ui/DatasourceModal/index.js +94 -163
- package/dist/types/ui/DatasourceModal/ModalWithState.d.ts +12 -2
- package/dist/types/ui/DatasourceModal/index.d.ts +3 -4
- package/dist/types-ts4.5/ui/DatasourceModal/ModalWithState.d.ts +12 -2
- package/dist/types-ts4.5/ui/DatasourceModal/index.d.ts +3 -4
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 1.11.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#97599](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97599)
|
|
8
|
+
[`32c3130b08fe`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/32c3130b08fe) -
|
|
9
|
+
[ED-22282] Bump adf-schema to 36.1.0
|
|
10
|
+
|
|
11
|
+
## 1.11.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#97537](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97537)
|
|
16
|
+
[`7d76404fde3f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7d76404fde3f) -
|
|
17
|
+
Fix a bug where the confluence search config modal may appear to be empty when opening an
|
|
18
|
+
existing inline link.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 1.11.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -4,9 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = void 0;
|
|
7
|
+
exports.modalTypeToComponentMap = exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
|
+
var _linkDatasource = require("@atlaskit/link-datasource");
|
|
10
11
|
var _datasourceErrorBoundary = require("../../datasourceErrorBoundary");
|
|
11
12
|
var _CardContextProvider = require("../CardContextProvider");
|
|
12
13
|
var _index = require("./index");
|
|
@@ -15,19 +16,42 @@ var ModalWithState = function ModalWithState(_ref) {
|
|
|
15
16
|
editorView = _ref.editorView;
|
|
16
17
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['card']),
|
|
17
18
|
cardState = _useSharedPluginState.cardState;
|
|
18
|
-
if (!
|
|
19
|
+
if (!cardState) {
|
|
19
20
|
return null;
|
|
20
21
|
}
|
|
22
|
+
var showDatasourceModal = cardState.showDatasourceModal,
|
|
23
|
+
datasourceModalType = cardState.datasourceModalType;
|
|
24
|
+
if (!showDatasourceModal || !datasourceModalType) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
var _modalTypeToComponent = modalTypeToComponentMap[datasourceModalType],
|
|
28
|
+
datasourceId = _modalTypeToComponent.datasourceId,
|
|
29
|
+
componentType = _modalTypeToComponent.componentType;
|
|
21
30
|
return /*#__PURE__*/_react.default.createElement(_datasourceErrorBoundary.DatasourceErrorBoundary, {
|
|
22
31
|
view: editorView,
|
|
23
|
-
datasourceModalType:
|
|
32
|
+
datasourceModalType: datasourceModalType
|
|
24
33
|
}, /*#__PURE__*/_react.default.createElement(_CardContextProvider.CardContextProvider, null, function (_ref2) {
|
|
25
34
|
var cardContext = _ref2.cardContext;
|
|
26
35
|
return /*#__PURE__*/_react.default.createElement(_index.DatasourceModal, {
|
|
27
36
|
view: editorView,
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
cardContext: cardContext,
|
|
38
|
+
datasourceId: datasourceId,
|
|
39
|
+
componentType: componentType
|
|
30
40
|
});
|
|
31
41
|
}));
|
|
32
42
|
};
|
|
43
|
+
var modalTypeToComponentMap = exports.modalTypeToComponentMap = {
|
|
44
|
+
jira: {
|
|
45
|
+
componentType: _linkDatasource.JiraIssuesConfigModal,
|
|
46
|
+
datasourceId: _linkDatasource.JIRA_LIST_OF_LINKS_DATASOURCE_ID
|
|
47
|
+
},
|
|
48
|
+
'confluence-search': {
|
|
49
|
+
componentType: _linkDatasource.ConfluenceSearchConfigModal,
|
|
50
|
+
datasourceId: _linkDatasource.CONFLUENCE_SEARCH_DATASOURCE_ID
|
|
51
|
+
},
|
|
52
|
+
assets: {
|
|
53
|
+
componentType: _linkDatasource.AssetsConfigModal,
|
|
54
|
+
datasourceId: _linkDatasource.ASSETS_LIST_OF_LINKS_DATASOURCE_ID
|
|
55
|
+
}
|
|
56
|
+
};
|
|
33
57
|
var _default = exports.default = ModalWithState;
|
|
@@ -10,7 +10,6 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
|
-
var _linkDatasource = require("@atlaskit/link-datasource");
|
|
14
13
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
14
|
var _actions = require("../../pm-plugins/actions");
|
|
16
15
|
var _doc = require("../../pm-plugins/doc");
|
|
@@ -23,44 +22,56 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
23
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
24
23
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
25
24
|
var DatasourceModal = exports.DatasourceModal = function DatasourceModal(_ref) {
|
|
26
|
-
var _existingNode,
|
|
25
|
+
var _existingNode$attrs, _existingNode$attrs2;
|
|
27
26
|
var view = _ref.view,
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
cardContext = _ref.cardContext,
|
|
28
|
+
defaultDatasourceId = _ref.datasourceId,
|
|
29
|
+
Component = _ref.componentType;
|
|
30
|
+
var state = view.state;
|
|
31
|
+
var existingNode = getExistingNode(state);
|
|
30
32
|
var dispatch = view.dispatch,
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
existingNode = selection instanceof _state.NodeSelection ? selection.node : undefined;
|
|
50
|
-
}
|
|
51
|
-
var isRegularCardNode = !!(existingNode && !((_existingNode = existingNode) !== null && _existingNode !== void 0 && (_existingNode = _existingNode.attrs) !== null && _existingNode !== void 0 && _existingNode.datasource));
|
|
33
|
+
transaction = view.state.tr;
|
|
34
|
+
var onClose = (0, _react.useCallback)(function () {
|
|
35
|
+
dispatch((0, _actions.hideDatasourceModal)(transaction));
|
|
36
|
+
}, [dispatch, transaction]);
|
|
37
|
+
var onInsert = useOnInsert(view, existingNode);
|
|
38
|
+
var isRegularCardNode = !!(existingNode && !(existingNode !== null && existingNode !== void 0 && (_existingNode$attrs = existingNode.attrs) !== null && _existingNode$attrs !== void 0 && _existingNode$attrs.datasource));
|
|
39
|
+
var _ref2 = (existingNode === null || existingNode === void 0 || (_existingNode$attrs2 = existingNode.attrs) === null || _existingNode$attrs2 === void 0 ? void 0 : _existingNode$attrs2.datasource) || {},
|
|
40
|
+
_ref2$id = _ref2.id,
|
|
41
|
+
datasourceId = _ref2$id === void 0 ? defaultDatasourceId : _ref2$id,
|
|
42
|
+
_ref2$views = _ref2.views,
|
|
43
|
+
views = _ref2$views === void 0 ? [] : _ref2$views,
|
|
44
|
+
nodeParameters = _ref2.parameters;
|
|
45
|
+
var _resolveColumnsConfig = resolveColumnsConfig(views),
|
|
46
|
+
visibleColumnKeys = _resolveColumnsConfig.visibleColumnKeys,
|
|
47
|
+
wrappedColumnKeys = _resolveColumnsConfig.wrappedColumnKeys,
|
|
48
|
+
columnCustomSizes = _resolveColumnsConfig.columnCustomSizes;
|
|
52
49
|
var _useFetchDatasourceIn = (0, _useFetchDatasourceInfo.useFetchDatasourceInfo)({
|
|
53
50
|
isRegularCardNode: isRegularCardNode,
|
|
54
|
-
url:
|
|
51
|
+
url: existingNode === null || existingNode === void 0 ? void 0 : existingNode.attrs.url,
|
|
55
52
|
cardContext: cardContext,
|
|
56
|
-
nodeParameters:
|
|
53
|
+
nodeParameters: nodeParameters
|
|
57
54
|
}),
|
|
58
55
|
parameters = _useFetchDatasourceIn.parameters,
|
|
59
56
|
ready = _useFetchDatasourceIn.ready;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
57
|
+
if (!ready) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(Component, {
|
|
61
|
+
datasourceId: datasourceId,
|
|
62
|
+
viewMode: isRegularCardNode ? 'inline' : 'table' // Want non-datasource cards to open in inline view since they are in table view
|
|
63
|
+
,
|
|
64
|
+
parameters: parameters,
|
|
65
|
+
url: existingNode === null || existingNode === void 0 ? void 0 : existingNode.attrs.url,
|
|
66
|
+
visibleColumnKeys: visibleColumnKeys,
|
|
67
|
+
columnCustomSizes: columnCustomSizes,
|
|
68
|
+
wrappedColumnKeys: wrappedColumnKeys,
|
|
69
|
+
onCancel: onClose,
|
|
70
|
+
onInsert: onInsert
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
var useOnInsert = function useOnInsert(view, existingNode) {
|
|
74
|
+
return (0, _react.useCallback)(function (newAdf, analyticEvent) {
|
|
64
75
|
if (analyticEvent) {
|
|
65
76
|
analyticEvent.update(function (payload) {
|
|
66
77
|
return _objectSpread(_objectSpread({}, payload), {}, {
|
|
@@ -82,143 +93,63 @@ var DatasourceModal = exports.DatasourceModal = function DatasourceModal(_ref) {
|
|
|
82
93
|
(0, _doc.insertDatasource)(view.state, newAdf, view, analyticEvent);
|
|
83
94
|
}
|
|
84
95
|
}, [existingNode, view]);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
_ref2$views = _ref2.views,
|
|
94
|
-
views = _ref2$views === void 0 ? [] : _ref2$views;
|
|
95
|
-
var _ref3 = views,
|
|
96
|
-
_ref4 = (0, _slicedToArray2.default)(_ref3, 1),
|
|
97
|
-
tableView = _ref4[0];
|
|
98
|
-
var visibleColumnKeys = [];
|
|
99
|
-
var wrappedColumnKeys = [];
|
|
100
|
-
var columnCustomSizes;
|
|
101
|
-
var columns = tableView === null || tableView === void 0 || (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns;
|
|
102
|
-
if (columns) {
|
|
103
|
-
columnCustomSizes = {};
|
|
104
|
-
var _iterator = _createForOfIteratorHelper(columns),
|
|
105
|
-
_step;
|
|
106
|
-
try {
|
|
107
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
108
|
-
var _step$value = _step.value,
|
|
109
|
-
_key = _step$value.key,
|
|
110
|
-
width = _step$value.width,
|
|
111
|
-
isWrapped = _step$value.isWrapped;
|
|
112
|
-
visibleColumnKeys.push(_key);
|
|
113
|
-
if (width) {
|
|
114
|
-
columnCustomSizes[_key] = width;
|
|
115
|
-
}
|
|
116
|
-
if (isWrapped) {
|
|
117
|
-
wrappedColumnKeys.push(_key);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
} catch (err) {
|
|
121
|
-
_iterator.e(err);
|
|
122
|
-
} finally {
|
|
123
|
-
_iterator.f();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
127
|
-
"data-testid": "jira-config-modal"
|
|
128
|
-
}, /*#__PURE__*/_react.default.createElement(_linkDatasource.JiraIssuesConfigModal, {
|
|
129
|
-
datasourceId: datasourceId,
|
|
130
|
-
viewMode: isRegularCardNode ? 'inline' : 'table' // Want non-datasource cards to open in inline view since they are in table view
|
|
131
|
-
,
|
|
132
|
-
visibleColumnKeys: visibleColumnKeys,
|
|
133
|
-
parameters: parameters,
|
|
134
|
-
url: (_existingNode5 = existingNode) === null || _existingNode5 === void 0 ? void 0 : _existingNode5.attrs.url,
|
|
135
|
-
columnCustomSizes: columnCustomSizes,
|
|
136
|
-
wrappedColumnKeys: wrappedColumnKeys,
|
|
137
|
-
onCancel: onClose,
|
|
138
|
-
onInsert: onInsert
|
|
139
|
-
}));
|
|
140
|
-
}
|
|
141
|
-
if (modalType === 'assets') {
|
|
142
|
-
var _existingNode6, _tableView$properties2;
|
|
143
|
-
var _ref5 = ((_existingNode6 = existingNode) === null || _existingNode6 === void 0 || (_existingNode6 = _existingNode6.attrs) === null || _existingNode6 === void 0 ? void 0 : _existingNode6.datasource) || {},
|
|
144
|
-
_ref5$id = _ref5.id,
|
|
145
|
-
_datasourceId = _ref5$id === void 0 ? _linkDatasource.ASSETS_LIST_OF_LINKS_DATASOURCE_ID : _ref5$id,
|
|
146
|
-
_parameters = _ref5.parameters,
|
|
147
|
-
_ref5$views = _ref5.views,
|
|
148
|
-
_views = _ref5$views === void 0 ? [] : _ref5$views;
|
|
149
|
-
var _ref6 = _views,
|
|
150
|
-
_ref7 = (0, _slicedToArray2.default)(_ref6, 1),
|
|
151
|
-
_tableView = _ref7[0];
|
|
152
|
-
var _visibleColumnKeys = _tableView === null || _tableView === void 0 || (_tableView$properties2 = _tableView.properties) === null || _tableView$properties2 === void 0 ? void 0 : _tableView$properties2.columns.map(function (column) {
|
|
153
|
-
return column.key;
|
|
96
|
+
};
|
|
97
|
+
var getExistingNode = function getExistingNode(state) {
|
|
98
|
+
var selection = state.selection;
|
|
99
|
+
var existingNode;
|
|
100
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
101
|
+
// Check if the selection contains a link mark
|
|
102
|
+
var isLinkMark = state.doc.resolve(selection.from).marks().some(function (mark) {
|
|
103
|
+
return mark.type === state.schema.marks.link;
|
|
154
104
|
});
|
|
155
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
156
|
-
"data-testid": "assets-config-modal"
|
|
157
|
-
}, /*#__PURE__*/_react.default.createElement(_linkDatasource.AssetsConfigModal, {
|
|
158
|
-
datasourceId: _datasourceId,
|
|
159
|
-
visibleColumnKeys: _visibleColumnKeys,
|
|
160
|
-
parameters: _parameters,
|
|
161
|
-
onCancel: onClose,
|
|
162
|
-
onInsert: onInsert
|
|
163
|
-
}));
|
|
164
|
-
}
|
|
165
105
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
if (
|
|
170
|
-
|
|
106
|
+
// When selection is a TextNode and a link Mark is present return that node
|
|
107
|
+
if (selection instanceof _state.NodeSelection) {
|
|
108
|
+
existingNode = selection.node;
|
|
109
|
+
} else if (isLinkMark) {
|
|
110
|
+
var _state$doc$nodeAt;
|
|
111
|
+
existingNode = (_state$doc$nodeAt = state.doc.nodeAt(selection.from)) !== null && _state$doc$nodeAt !== void 0 ? _state$doc$nodeAt : undefined;
|
|
171
112
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
113
|
+
} else {
|
|
114
|
+
existingNode = selection instanceof _state.NodeSelection ? selection.node : undefined;
|
|
115
|
+
}
|
|
116
|
+
return existingNode;
|
|
117
|
+
};
|
|
118
|
+
var resolveColumnsConfig = function resolveColumnsConfig(views) {
|
|
119
|
+
var _tableView$properties;
|
|
120
|
+
var _views = (0, _slicedToArray2.default)(views, 1),
|
|
121
|
+
tableView = _views[0];
|
|
122
|
+
var visibleColumnKeys = [];
|
|
123
|
+
var wrappedColumnKeys = [];
|
|
124
|
+
var columnCustomSizes;
|
|
125
|
+
var columns = tableView === null || tableView === void 0 || (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns;
|
|
126
|
+
if (columns) {
|
|
127
|
+
columnCustomSizes = {};
|
|
128
|
+
var _iterator = _createForOfIteratorHelper(columns),
|
|
129
|
+
_step;
|
|
130
|
+
try {
|
|
131
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
132
|
+
var _step$value = _step.value,
|
|
133
|
+
_key = _step$value.key,
|
|
134
|
+
width = _step$value.width,
|
|
135
|
+
isWrapped = _step$value.isWrapped;
|
|
136
|
+
visibleColumnKeys.push(_key);
|
|
137
|
+
if (width) {
|
|
138
|
+
columnCustomSizes[_key] = width;
|
|
139
|
+
}
|
|
140
|
+
if (isWrapped) {
|
|
141
|
+
wrappedColumnKeys.push(_key);
|
|
202
142
|
}
|
|
203
|
-
} catch (err) {
|
|
204
|
-
_iterator2.e(err);
|
|
205
|
-
} finally {
|
|
206
|
-
_iterator2.f();
|
|
207
143
|
}
|
|
144
|
+
} catch (err) {
|
|
145
|
+
_iterator.e(err);
|
|
146
|
+
} finally {
|
|
147
|
+
_iterator.f();
|
|
208
148
|
}
|
|
209
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
210
|
-
"data-testid": "confluence-search-config-modal"
|
|
211
|
-
}, /*#__PURE__*/_react.default.createElement(_linkDatasource.ConfluenceSearchConfigModal, {
|
|
212
|
-
datasourceId: _datasourceId2,
|
|
213
|
-
viewMode: isRegularCardNode ? 'inline' : 'table',
|
|
214
|
-
visibleColumnKeys: _visibleColumnKeys2,
|
|
215
|
-
parameters: _parameters2,
|
|
216
|
-
url: (_existingNode8 = existingNode) === null || _existingNode8 === void 0 ? void 0 : _existingNode8.attrs.url,
|
|
217
|
-
columnCustomSizes: _columnCustomSizes,
|
|
218
|
-
wrappedColumnKeys: _wrappedColumnKeys,
|
|
219
|
-
onCancel: onClose,
|
|
220
|
-
onInsert: onInsert
|
|
221
|
-
}));
|
|
222
149
|
}
|
|
223
|
-
return
|
|
150
|
+
return {
|
|
151
|
+
visibleColumnKeys: visibleColumnKeys,
|
|
152
|
+
wrappedColumnKeys: wrappedColumnKeys,
|
|
153
|
+
columnCustomSizes: columnCustomSizes
|
|
154
|
+
};
|
|
224
155
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
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';
|
|
3
4
|
import { DatasourceErrorBoundary } from '../../datasourceErrorBoundary';
|
|
4
5
|
import { CardContextProvider } from '../CardContextProvider';
|
|
5
6
|
import { DatasourceModal } from './index';
|
|
@@ -10,18 +11,44 @@ const ModalWithState = ({
|
|
|
10
11
|
const {
|
|
11
12
|
cardState
|
|
12
13
|
} = useSharedPluginState(api, ['card']);
|
|
13
|
-
if (!
|
|
14
|
+
if (!cardState) {
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
17
|
+
const {
|
|
18
|
+
showDatasourceModal,
|
|
19
|
+
datasourceModalType
|
|
20
|
+
} = cardState;
|
|
21
|
+
if (!showDatasourceModal || !datasourceModalType) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const {
|
|
25
|
+
datasourceId,
|
|
26
|
+
componentType
|
|
27
|
+
} = modalTypeToComponentMap[datasourceModalType];
|
|
16
28
|
return /*#__PURE__*/React.createElement(DatasourceErrorBoundary, {
|
|
17
29
|
view: editorView,
|
|
18
|
-
datasourceModalType:
|
|
30
|
+
datasourceModalType: datasourceModalType
|
|
19
31
|
}, /*#__PURE__*/React.createElement(CardContextProvider, null, ({
|
|
20
32
|
cardContext
|
|
21
33
|
}) => /*#__PURE__*/React.createElement(DatasourceModal, {
|
|
22
34
|
view: editorView,
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
cardContext: cardContext,
|
|
36
|
+
datasourceId: datasourceId,
|
|
37
|
+
componentType: componentType
|
|
25
38
|
})));
|
|
26
39
|
};
|
|
40
|
+
export const modalTypeToComponentMap = {
|
|
41
|
+
jira: {
|
|
42
|
+
componentType: JiraIssuesConfigModal,
|
|
43
|
+
datasourceId: JIRA_LIST_OF_LINKS_DATASOURCE_ID
|
|
44
|
+
},
|
|
45
|
+
'confluence-search': {
|
|
46
|
+
componentType: ConfluenceSearchConfigModal,
|
|
47
|
+
datasourceId: CONFLUENCE_SEARCH_DATASOURCE_ID
|
|
48
|
+
},
|
|
49
|
+
assets: {
|
|
50
|
+
componentType: AssetsConfigModal,
|
|
51
|
+
datasourceId: ASSETS_LIST_OF_LINKS_DATASOURCE_ID
|
|
52
|
+
}
|
|
53
|
+
};
|
|
27
54
|
export default ModalWithState;
|
|
@@ -1,53 +1,68 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
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
3
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { hideDatasourceModal } from '../../pm-plugins/actions';
|
|
6
5
|
import { insertDatasource, updateCardViaDatasource } from '../../pm-plugins/doc';
|
|
7
6
|
import { useFetchDatasourceInfo } from '../useFetchDatasourceInfo';
|
|
8
7
|
export const DatasourceModal = ({
|
|
9
8
|
view,
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
cardContext,
|
|
10
|
+
datasourceId: defaultDatasourceId,
|
|
11
|
+
componentType: Component
|
|
12
12
|
}) => {
|
|
13
|
-
var _existingNode
|
|
13
|
+
var _existingNode$attrs, _existingNode$attrs2;
|
|
14
14
|
const {
|
|
15
|
-
dispatch,
|
|
16
15
|
state
|
|
17
16
|
} = view;
|
|
17
|
+
const existingNode = getExistingNode(state);
|
|
18
18
|
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
23
|
-
// Check if the selection contains a link mark
|
|
24
|
-
const $pos = state.doc.resolve(selection.from);
|
|
25
|
-
const isLinkMark = $pos.marks().some(mark => mark.type === state.schema.marks.link);
|
|
26
|
-
|
|
27
|
-
// When selection is a TextNode and a link Mark is present return that node
|
|
28
|
-
if (selection instanceof NodeSelection) {
|
|
29
|
-
existingNode = selection.node;
|
|
30
|
-
} else if (isLinkMark) {
|
|
31
|
-
var _state$doc$nodeAt;
|
|
32
|
-
existingNode = (_state$doc$nodeAt = state.doc.nodeAt(selection.from)) !== null && _state$doc$nodeAt !== void 0 ? _state$doc$nodeAt : undefined;
|
|
19
|
+
dispatch,
|
|
20
|
+
state: {
|
|
21
|
+
tr: transaction
|
|
33
22
|
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
} = view;
|
|
24
|
+
const onClose = useCallback(() => {
|
|
25
|
+
dispatch(hideDatasourceModal(transaction));
|
|
26
|
+
}, [dispatch, transaction]);
|
|
27
|
+
const onInsert = useOnInsert(view, existingNode);
|
|
28
|
+
const isRegularCardNode = !!(existingNode && !(existingNode !== null && existingNode !== void 0 && (_existingNode$attrs = existingNode.attrs) !== null && _existingNode$attrs !== void 0 && _existingNode$attrs.datasource));
|
|
29
|
+
const {
|
|
30
|
+
id: datasourceId = defaultDatasourceId,
|
|
31
|
+
views = [],
|
|
32
|
+
parameters: nodeParameters
|
|
33
|
+
} = (existingNode === null || existingNode === void 0 ? void 0 : (_existingNode$attrs2 = existingNode.attrs) === null || _existingNode$attrs2 === void 0 ? void 0 : _existingNode$attrs2.datasource) || {};
|
|
34
|
+
const {
|
|
35
|
+
visibleColumnKeys,
|
|
36
|
+
wrappedColumnKeys,
|
|
37
|
+
columnCustomSizes
|
|
38
|
+
} = resolveColumnsConfig(views);
|
|
38
39
|
const {
|
|
39
40
|
parameters,
|
|
40
41
|
ready
|
|
41
42
|
} = useFetchDatasourceInfo({
|
|
42
43
|
isRegularCardNode,
|
|
43
|
-
url:
|
|
44
|
+
url: existingNode === null || existingNode === void 0 ? void 0 : existingNode.attrs.url,
|
|
44
45
|
cardContext,
|
|
45
|
-
nodeParameters
|
|
46
|
+
nodeParameters
|
|
46
47
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
48
|
+
if (!ready) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
52
|
+
datasourceId: datasourceId,
|
|
53
|
+
viewMode: isRegularCardNode ? 'inline' : 'table' // Want non-datasource cards to open in inline view since they are in table view
|
|
54
|
+
,
|
|
55
|
+
parameters: parameters,
|
|
56
|
+
url: existingNode === null || existingNode === void 0 ? void 0 : existingNode.attrs.url,
|
|
57
|
+
visibleColumnKeys: visibleColumnKeys,
|
|
58
|
+
columnCustomSizes: columnCustomSizes,
|
|
59
|
+
wrappedColumnKeys: wrappedColumnKeys,
|
|
60
|
+
onCancel: onClose,
|
|
61
|
+
onInsert: onInsert
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const useOnInsert = (view, existingNode) => {
|
|
65
|
+
return useCallback((newAdf, analyticEvent) => {
|
|
51
66
|
if (analyticEvent) {
|
|
52
67
|
analyticEvent.update(payload => ({
|
|
53
68
|
...payload,
|
|
@@ -69,116 +84,54 @@ export const DatasourceModal = ({
|
|
|
69
84
|
insertDatasource(view.state, newAdf, view, analyticEvent);
|
|
70
85
|
}
|
|
71
86
|
}, [existingNode, view]);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const [tableView] = views;
|
|
82
|
-
const visibleColumnKeys = [];
|
|
83
|
-
const wrappedColumnKeys = [];
|
|
84
|
-
let columnCustomSizes;
|
|
85
|
-
const columns = tableView === null || tableView === void 0 ? void 0 : (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns;
|
|
86
|
-
if (columns) {
|
|
87
|
-
columnCustomSizes = {};
|
|
88
|
-
for (const {
|
|
89
|
-
key,
|
|
90
|
-
width,
|
|
91
|
-
isWrapped
|
|
92
|
-
} of columns) {
|
|
93
|
-
visibleColumnKeys.push(key);
|
|
94
|
-
if (width) {
|
|
95
|
-
columnCustomSizes[key] = width;
|
|
96
|
-
}
|
|
97
|
-
if (isWrapped) {
|
|
98
|
-
wrappedColumnKeys.push(key);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
103
|
-
"data-testid": "jira-config-modal"
|
|
104
|
-
}, /*#__PURE__*/React.createElement(JiraIssuesConfigModal, {
|
|
105
|
-
datasourceId: datasourceId,
|
|
106
|
-
viewMode: isRegularCardNode ? 'inline' : 'table' // Want non-datasource cards to open in inline view since they are in table view
|
|
107
|
-
,
|
|
108
|
-
visibleColumnKeys: visibleColumnKeys,
|
|
109
|
-
parameters: parameters,
|
|
110
|
-
url: (_existingNode5 = existingNode) === null || _existingNode5 === void 0 ? void 0 : _existingNode5.attrs.url,
|
|
111
|
-
columnCustomSizes: columnCustomSizes,
|
|
112
|
-
wrappedColumnKeys: wrappedColumnKeys,
|
|
113
|
-
onCancel: onClose,
|
|
114
|
-
onInsert: onInsert
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
if (modalType === 'assets') {
|
|
118
|
-
var _existingNode6, _existingNode6$attrs, _tableView$properties2;
|
|
119
|
-
const {
|
|
120
|
-
id: datasourceId = ASSETS_LIST_OF_LINKS_DATASOURCE_ID,
|
|
121
|
-
parameters,
|
|
122
|
-
views = []
|
|
123
|
-
} = ((_existingNode6 = existingNode) === null || _existingNode6 === void 0 ? void 0 : (_existingNode6$attrs = _existingNode6.attrs) === null || _existingNode6$attrs === void 0 ? void 0 : _existingNode6$attrs.datasource) || {};
|
|
124
|
-
const [tableView] = views;
|
|
125
|
-
const visibleColumnKeys = tableView === null || tableView === void 0 ? void 0 : (_tableView$properties2 = tableView.properties) === null || _tableView$properties2 === void 0 ? void 0 : _tableView$properties2.columns.map(column => column.key);
|
|
126
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
127
|
-
"data-testid": "assets-config-modal"
|
|
128
|
-
}, /*#__PURE__*/React.createElement(AssetsConfigModal, {
|
|
129
|
-
datasourceId: datasourceId,
|
|
130
|
-
visibleColumnKeys: visibleColumnKeys,
|
|
131
|
-
parameters: parameters,
|
|
132
|
-
onCancel: onClose,
|
|
133
|
-
onInsert: onInsert
|
|
134
|
-
}));
|
|
135
|
-
}
|
|
87
|
+
};
|
|
88
|
+
const getExistingNode = state => {
|
|
89
|
+
const {
|
|
90
|
+
selection
|
|
91
|
+
} = state;
|
|
92
|
+
let existingNode;
|
|
93
|
+
if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
94
|
+
// Check if the selection contains a link mark
|
|
95
|
+
const isLinkMark = state.doc.resolve(selection.from).marks().some(mark => mark.type === state.schema.marks.link);
|
|
136
96
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (
|
|
141
|
-
|
|
97
|
+
// When selection is a TextNode and a link Mark is present return that node
|
|
98
|
+
if (selection instanceof NodeSelection) {
|
|
99
|
+
existingNode = selection.node;
|
|
100
|
+
} else if (isLinkMark) {
|
|
101
|
+
var _state$doc$nodeAt;
|
|
102
|
+
existingNode = (_state$doc$nodeAt = state.doc.nodeAt(selection.from)) !== null && _state$doc$nodeAt !== void 0 ? _state$doc$nodeAt : undefined;
|
|
142
103
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
104
|
+
} else {
|
|
105
|
+
existingNode = selection instanceof NodeSelection ? selection.node : undefined;
|
|
106
|
+
}
|
|
107
|
+
return existingNode;
|
|
108
|
+
};
|
|
109
|
+
const resolveColumnsConfig = views => {
|
|
110
|
+
var _tableView$properties;
|
|
111
|
+
const [tableView] = views;
|
|
112
|
+
const visibleColumnKeys = [];
|
|
113
|
+
const wrappedColumnKeys = [];
|
|
114
|
+
let columnCustomSizes;
|
|
115
|
+
const columns = tableView === null || tableView === void 0 ? void 0 : (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns;
|
|
116
|
+
if (columns) {
|
|
117
|
+
columnCustomSizes = {};
|
|
118
|
+
for (const {
|
|
119
|
+
key,
|
|
120
|
+
width,
|
|
121
|
+
isWrapped
|
|
122
|
+
} of columns) {
|
|
123
|
+
visibleColumnKeys.push(key);
|
|
124
|
+
if (width) {
|
|
125
|
+
columnCustomSizes[key] = width;
|
|
126
|
+
}
|
|
127
|
+
if (isWrapped) {
|
|
128
|
+
wrappedColumnKeys.push(key);
|
|
167
129
|
}
|
|
168
130
|
}
|
|
169
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
170
|
-
"data-testid": "confluence-search-config-modal"
|
|
171
|
-
}, /*#__PURE__*/React.createElement(ConfluenceSearchConfigModal, {
|
|
172
|
-
datasourceId: datasourceId,
|
|
173
|
-
viewMode: isRegularCardNode ? 'inline' : 'table',
|
|
174
|
-
visibleColumnKeys: visibleColumnKeys,
|
|
175
|
-
parameters: parameters,
|
|
176
|
-
url: (_existingNode8 = existingNode) === null || _existingNode8 === void 0 ? void 0 : _existingNode8.attrs.url,
|
|
177
|
-
columnCustomSizes: columnCustomSizes,
|
|
178
|
-
wrappedColumnKeys: wrappedColumnKeys,
|
|
179
|
-
onCancel: onClose,
|
|
180
|
-
onInsert: onInsert
|
|
181
|
-
}));
|
|
182
131
|
}
|
|
183
|
-
return
|
|
132
|
+
return {
|
|
133
|
+
visibleColumnKeys,
|
|
134
|
+
wrappedColumnKeys,
|
|
135
|
+
columnCustomSizes
|
|
136
|
+
};
|
|
184
137
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
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';
|
|
3
4
|
import { DatasourceErrorBoundary } from '../../datasourceErrorBoundary';
|
|
4
5
|
import { CardContextProvider } from '../CardContextProvider';
|
|
5
6
|
import { DatasourceModal } from './index';
|
|
@@ -8,19 +9,42 @@ var ModalWithState = function ModalWithState(_ref) {
|
|
|
8
9
|
editorView = _ref.editorView;
|
|
9
10
|
var _useSharedPluginState = useSharedPluginState(api, ['card']),
|
|
10
11
|
cardState = _useSharedPluginState.cardState;
|
|
11
|
-
if (!
|
|
12
|
+
if (!cardState) {
|
|
12
13
|
return null;
|
|
13
14
|
}
|
|
15
|
+
var showDatasourceModal = cardState.showDatasourceModal,
|
|
16
|
+
datasourceModalType = cardState.datasourceModalType;
|
|
17
|
+
if (!showDatasourceModal || !datasourceModalType) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
var _modalTypeToComponent = modalTypeToComponentMap[datasourceModalType],
|
|
21
|
+
datasourceId = _modalTypeToComponent.datasourceId,
|
|
22
|
+
componentType = _modalTypeToComponent.componentType;
|
|
14
23
|
return /*#__PURE__*/React.createElement(DatasourceErrorBoundary, {
|
|
15
24
|
view: editorView,
|
|
16
|
-
datasourceModalType:
|
|
25
|
+
datasourceModalType: datasourceModalType
|
|
17
26
|
}, /*#__PURE__*/React.createElement(CardContextProvider, null, function (_ref2) {
|
|
18
27
|
var cardContext = _ref2.cardContext;
|
|
19
28
|
return /*#__PURE__*/React.createElement(DatasourceModal, {
|
|
20
29
|
view: editorView,
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
cardContext: cardContext,
|
|
31
|
+
datasourceId: datasourceId,
|
|
32
|
+
componentType: componentType
|
|
23
33
|
});
|
|
24
34
|
}));
|
|
25
35
|
};
|
|
36
|
+
export var modalTypeToComponentMap = {
|
|
37
|
+
jira: {
|
|
38
|
+
componentType: JiraIssuesConfigModal,
|
|
39
|
+
datasourceId: JIRA_LIST_OF_LINKS_DATASOURCE_ID
|
|
40
|
+
},
|
|
41
|
+
'confluence-search': {
|
|
42
|
+
componentType: ConfluenceSearchConfigModal,
|
|
43
|
+
datasourceId: CONFLUENCE_SEARCH_DATASOURCE_ID
|
|
44
|
+
},
|
|
45
|
+
assets: {
|
|
46
|
+
componentType: AssetsConfigModal,
|
|
47
|
+
datasourceId: ASSETS_LIST_OF_LINKS_DATASOURCE_ID
|
|
48
|
+
}
|
|
49
|
+
};
|
|
26
50
|
export default ModalWithState;
|
|
@@ -7,50 +7,61 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
8
|
import React, { useCallback } from 'react';
|
|
9
9
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
|
-
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, AssetsConfigModal, CONFLUENCE_SEARCH_DATASOURCE_ID, ConfluenceSearchConfigModal, JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
|
|
11
10
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
11
|
import { hideDatasourceModal } from '../../pm-plugins/actions';
|
|
13
12
|
import { insertDatasource, updateCardViaDatasource } from '../../pm-plugins/doc';
|
|
14
13
|
import { useFetchDatasourceInfo } from '../useFetchDatasourceInfo';
|
|
15
14
|
export var DatasourceModal = function DatasourceModal(_ref) {
|
|
16
|
-
var _existingNode,
|
|
15
|
+
var _existingNode$attrs, _existingNode$attrs2;
|
|
17
16
|
var view = _ref.view,
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
cardContext = _ref.cardContext,
|
|
18
|
+
defaultDatasourceId = _ref.datasourceId,
|
|
19
|
+
Component = _ref.componentType;
|
|
20
|
+
var state = view.state;
|
|
21
|
+
var existingNode = getExistingNode(state);
|
|
20
22
|
var dispatch = view.dispatch,
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
} else {
|
|
39
|
-
existingNode = selection instanceof NodeSelection ? selection.node : undefined;
|
|
40
|
-
}
|
|
41
|
-
var isRegularCardNode = !!(existingNode && !((_existingNode = existingNode) !== null && _existingNode !== void 0 && (_existingNode = _existingNode.attrs) !== null && _existingNode !== void 0 && _existingNode.datasource));
|
|
23
|
+
transaction = view.state.tr;
|
|
24
|
+
var onClose = useCallback(function () {
|
|
25
|
+
dispatch(hideDatasourceModal(transaction));
|
|
26
|
+
}, [dispatch, transaction]);
|
|
27
|
+
var onInsert = useOnInsert(view, existingNode);
|
|
28
|
+
var isRegularCardNode = !!(existingNode && !(existingNode !== null && existingNode !== void 0 && (_existingNode$attrs = existingNode.attrs) !== null && _existingNode$attrs !== void 0 && _existingNode$attrs.datasource));
|
|
29
|
+
var _ref2 = (existingNode === null || existingNode === void 0 || (_existingNode$attrs2 = existingNode.attrs) === null || _existingNode$attrs2 === void 0 ? void 0 : _existingNode$attrs2.datasource) || {},
|
|
30
|
+
_ref2$id = _ref2.id,
|
|
31
|
+
datasourceId = _ref2$id === void 0 ? defaultDatasourceId : _ref2$id,
|
|
32
|
+
_ref2$views = _ref2.views,
|
|
33
|
+
views = _ref2$views === void 0 ? [] : _ref2$views,
|
|
34
|
+
nodeParameters = _ref2.parameters;
|
|
35
|
+
var _resolveColumnsConfig = resolveColumnsConfig(views),
|
|
36
|
+
visibleColumnKeys = _resolveColumnsConfig.visibleColumnKeys,
|
|
37
|
+
wrappedColumnKeys = _resolveColumnsConfig.wrappedColumnKeys,
|
|
38
|
+
columnCustomSizes = _resolveColumnsConfig.columnCustomSizes;
|
|
42
39
|
var _useFetchDatasourceIn = useFetchDatasourceInfo({
|
|
43
40
|
isRegularCardNode: isRegularCardNode,
|
|
44
|
-
url:
|
|
41
|
+
url: existingNode === null || existingNode === void 0 ? void 0 : existingNode.attrs.url,
|
|
45
42
|
cardContext: cardContext,
|
|
46
|
-
nodeParameters:
|
|
43
|
+
nodeParameters: nodeParameters
|
|
47
44
|
}),
|
|
48
45
|
parameters = _useFetchDatasourceIn.parameters,
|
|
49
46
|
ready = _useFetchDatasourceIn.ready;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
47
|
+
if (!ready) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
51
|
+
datasourceId: datasourceId,
|
|
52
|
+
viewMode: isRegularCardNode ? 'inline' : 'table' // Want non-datasource cards to open in inline view since they are in table view
|
|
53
|
+
,
|
|
54
|
+
parameters: parameters,
|
|
55
|
+
url: existingNode === null || existingNode === void 0 ? void 0 : existingNode.attrs.url,
|
|
56
|
+
visibleColumnKeys: visibleColumnKeys,
|
|
57
|
+
columnCustomSizes: columnCustomSizes,
|
|
58
|
+
wrappedColumnKeys: wrappedColumnKeys,
|
|
59
|
+
onCancel: onClose,
|
|
60
|
+
onInsert: onInsert
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
var useOnInsert = function useOnInsert(view, existingNode) {
|
|
64
|
+
return useCallback(function (newAdf, analyticEvent) {
|
|
54
65
|
if (analyticEvent) {
|
|
55
66
|
analyticEvent.update(function (payload) {
|
|
56
67
|
return _objectSpread(_objectSpread({}, payload), {}, {
|
|
@@ -72,143 +83,63 @@ export var DatasourceModal = function DatasourceModal(_ref) {
|
|
|
72
83
|
insertDatasource(view.state, newAdf, view, analyticEvent);
|
|
73
84
|
}
|
|
74
85
|
}, [existingNode, view]);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
_ref2$views = _ref2.views,
|
|
84
|
-
views = _ref2$views === void 0 ? [] : _ref2$views;
|
|
85
|
-
var _ref3 = views,
|
|
86
|
-
_ref4 = _slicedToArray(_ref3, 1),
|
|
87
|
-
tableView = _ref4[0];
|
|
88
|
-
var visibleColumnKeys = [];
|
|
89
|
-
var wrappedColumnKeys = [];
|
|
90
|
-
var columnCustomSizes;
|
|
91
|
-
var columns = tableView === null || tableView === void 0 || (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns;
|
|
92
|
-
if (columns) {
|
|
93
|
-
columnCustomSizes = {};
|
|
94
|
-
var _iterator = _createForOfIteratorHelper(columns),
|
|
95
|
-
_step;
|
|
96
|
-
try {
|
|
97
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
98
|
-
var _step$value = _step.value,
|
|
99
|
-
_key = _step$value.key,
|
|
100
|
-
width = _step$value.width,
|
|
101
|
-
isWrapped = _step$value.isWrapped;
|
|
102
|
-
visibleColumnKeys.push(_key);
|
|
103
|
-
if (width) {
|
|
104
|
-
columnCustomSizes[_key] = width;
|
|
105
|
-
}
|
|
106
|
-
if (isWrapped) {
|
|
107
|
-
wrappedColumnKeys.push(_key);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
} catch (err) {
|
|
111
|
-
_iterator.e(err);
|
|
112
|
-
} finally {
|
|
113
|
-
_iterator.f();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
117
|
-
"data-testid": "jira-config-modal"
|
|
118
|
-
}, /*#__PURE__*/React.createElement(JiraIssuesConfigModal, {
|
|
119
|
-
datasourceId: datasourceId,
|
|
120
|
-
viewMode: isRegularCardNode ? 'inline' : 'table' // Want non-datasource cards to open in inline view since they are in table view
|
|
121
|
-
,
|
|
122
|
-
visibleColumnKeys: visibleColumnKeys,
|
|
123
|
-
parameters: parameters,
|
|
124
|
-
url: (_existingNode5 = existingNode) === null || _existingNode5 === void 0 ? void 0 : _existingNode5.attrs.url,
|
|
125
|
-
columnCustomSizes: columnCustomSizes,
|
|
126
|
-
wrappedColumnKeys: wrappedColumnKeys,
|
|
127
|
-
onCancel: onClose,
|
|
128
|
-
onInsert: onInsert
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
if (modalType === 'assets') {
|
|
132
|
-
var _existingNode6, _tableView$properties2;
|
|
133
|
-
var _ref5 = ((_existingNode6 = existingNode) === null || _existingNode6 === void 0 || (_existingNode6 = _existingNode6.attrs) === null || _existingNode6 === void 0 ? void 0 : _existingNode6.datasource) || {},
|
|
134
|
-
_ref5$id = _ref5.id,
|
|
135
|
-
_datasourceId = _ref5$id === void 0 ? ASSETS_LIST_OF_LINKS_DATASOURCE_ID : _ref5$id,
|
|
136
|
-
_parameters = _ref5.parameters,
|
|
137
|
-
_ref5$views = _ref5.views,
|
|
138
|
-
_views = _ref5$views === void 0 ? [] : _ref5$views;
|
|
139
|
-
var _ref6 = _views,
|
|
140
|
-
_ref7 = _slicedToArray(_ref6, 1),
|
|
141
|
-
_tableView = _ref7[0];
|
|
142
|
-
var _visibleColumnKeys = _tableView === null || _tableView === void 0 || (_tableView$properties2 = _tableView.properties) === null || _tableView$properties2 === void 0 ? void 0 : _tableView$properties2.columns.map(function (column) {
|
|
143
|
-
return column.key;
|
|
86
|
+
};
|
|
87
|
+
var getExistingNode = function getExistingNode(state) {
|
|
88
|
+
var selection = state.selection;
|
|
89
|
+
var existingNode;
|
|
90
|
+
if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
91
|
+
// Check if the selection contains a link mark
|
|
92
|
+
var isLinkMark = state.doc.resolve(selection.from).marks().some(function (mark) {
|
|
93
|
+
return mark.type === state.schema.marks.link;
|
|
144
94
|
});
|
|
145
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
146
|
-
"data-testid": "assets-config-modal"
|
|
147
|
-
}, /*#__PURE__*/React.createElement(AssetsConfigModal, {
|
|
148
|
-
datasourceId: _datasourceId,
|
|
149
|
-
visibleColumnKeys: _visibleColumnKeys,
|
|
150
|
-
parameters: _parameters,
|
|
151
|
-
onCancel: onClose,
|
|
152
|
-
onInsert: onInsert
|
|
153
|
-
}));
|
|
154
|
-
}
|
|
155
95
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
|
|
96
|
+
// When selection is a TextNode and a link Mark is present return that node
|
|
97
|
+
if (selection instanceof NodeSelection) {
|
|
98
|
+
existingNode = selection.node;
|
|
99
|
+
} else if (isLinkMark) {
|
|
100
|
+
var _state$doc$nodeAt;
|
|
101
|
+
existingNode = (_state$doc$nodeAt = state.doc.nodeAt(selection.from)) !== null && _state$doc$nodeAt !== void 0 ? _state$doc$nodeAt : undefined;
|
|
161
102
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
103
|
+
} else {
|
|
104
|
+
existingNode = selection instanceof NodeSelection ? selection.node : undefined;
|
|
105
|
+
}
|
|
106
|
+
return existingNode;
|
|
107
|
+
};
|
|
108
|
+
var resolveColumnsConfig = function resolveColumnsConfig(views) {
|
|
109
|
+
var _tableView$properties;
|
|
110
|
+
var _views = _slicedToArray(views, 1),
|
|
111
|
+
tableView = _views[0];
|
|
112
|
+
var visibleColumnKeys = [];
|
|
113
|
+
var wrappedColumnKeys = [];
|
|
114
|
+
var columnCustomSizes;
|
|
115
|
+
var columns = tableView === null || tableView === void 0 || (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns;
|
|
116
|
+
if (columns) {
|
|
117
|
+
columnCustomSizes = {};
|
|
118
|
+
var _iterator = _createForOfIteratorHelper(columns),
|
|
119
|
+
_step;
|
|
120
|
+
try {
|
|
121
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
122
|
+
var _step$value = _step.value,
|
|
123
|
+
_key = _step$value.key,
|
|
124
|
+
width = _step$value.width,
|
|
125
|
+
isWrapped = _step$value.isWrapped;
|
|
126
|
+
visibleColumnKeys.push(_key);
|
|
127
|
+
if (width) {
|
|
128
|
+
columnCustomSizes[_key] = width;
|
|
129
|
+
}
|
|
130
|
+
if (isWrapped) {
|
|
131
|
+
wrappedColumnKeys.push(_key);
|
|
192
132
|
}
|
|
193
|
-
} catch (err) {
|
|
194
|
-
_iterator2.e(err);
|
|
195
|
-
} finally {
|
|
196
|
-
_iterator2.f();
|
|
197
133
|
}
|
|
134
|
+
} catch (err) {
|
|
135
|
+
_iterator.e(err);
|
|
136
|
+
} finally {
|
|
137
|
+
_iterator.f();
|
|
198
138
|
}
|
|
199
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
200
|
-
"data-testid": "confluence-search-config-modal"
|
|
201
|
-
}, /*#__PURE__*/React.createElement(ConfluenceSearchConfigModal, {
|
|
202
|
-
datasourceId: _datasourceId2,
|
|
203
|
-
viewMode: isRegularCardNode ? 'inline' : 'table',
|
|
204
|
-
visibleColumnKeys: _visibleColumnKeys2,
|
|
205
|
-
parameters: _parameters2,
|
|
206
|
-
url: (_existingNode8 = existingNode) === null || _existingNode8 === void 0 ? void 0 : _existingNode8.attrs.url,
|
|
207
|
-
columnCustomSizes: _columnCustomSizes,
|
|
208
|
-
wrappedColumnKeys: _wrappedColumnKeys,
|
|
209
|
-
onCancel: onClose,
|
|
210
|
-
onInsert: onInsert
|
|
211
|
-
}));
|
|
212
139
|
}
|
|
213
|
-
return
|
|
140
|
+
return {
|
|
141
|
+
visibleColumnKeys: visibleColumnKeys,
|
|
142
|
+
wrappedColumnKeys: wrappedColumnKeys,
|
|
143
|
+
columnCustomSizes: columnCustomSizes
|
|
144
|
+
};
|
|
214
145
|
};
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DatasourceModalType, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { ConfigModalProps } from '@atlaskit/link-datasource/src/common/types';
|
|
5
|
+
import type { DatasourceAdf, InlineCardAdf } from '@atlaskit/linking-common';
|
|
6
|
+
import type { DatasourceParameters } from '@atlaskit/linking-types';
|
|
4
7
|
import type { cardPlugin } from '../../plugin';
|
|
5
8
|
declare const ModalWithState: ({ api, editorView, }: {
|
|
6
9
|
api: ExtractInjectionAPI<typeof cardPlugin> | undefined;
|
|
7
10
|
editorView: EditorView;
|
|
8
11
|
}) => JSX.Element | null;
|
|
12
|
+
export type ModalTypeToComponentMap = {
|
|
13
|
+
componentType: React.ComponentType<ConfigModalProps<InlineCardAdf | DatasourceAdf, DatasourceParameters>>;
|
|
14
|
+
datasourceId: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const modalTypeToComponentMap: {
|
|
17
|
+
[key in DatasourceModalType]: ModalTypeToComponentMap;
|
|
18
|
+
};
|
|
9
19
|
export default ModalWithState;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { DatasourceModalType } from '@atlaskit/editor-common/types';
|
|
4
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
4
|
import type { CardContext } from '@atlaskit/smart-card';
|
|
5
|
+
import type { ModalTypeToComponentMap } from './ModalWithState';
|
|
6
6
|
type DatasourceModalProps = {
|
|
7
7
|
view: EditorView;
|
|
8
8
|
editorAnalyticsApi?: EditorAnalyticsAPI;
|
|
9
|
-
modalType?: DatasourceModalType;
|
|
10
9
|
cardContext?: CardContext;
|
|
11
|
-
};
|
|
12
|
-
export declare const DatasourceModal: ({ view,
|
|
10
|
+
} & ModalTypeToComponentMap;
|
|
11
|
+
export declare const DatasourceModal: ({ view, cardContext, datasourceId: defaultDatasourceId, componentType: Component, }: DatasourceModalProps) => JSX.Element | null;
|
|
13
12
|
export {};
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DatasourceModalType, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { ConfigModalProps } from '@atlaskit/link-datasource/src/common/types';
|
|
5
|
+
import type { DatasourceAdf, InlineCardAdf } from '@atlaskit/linking-common';
|
|
6
|
+
import type { DatasourceParameters } from '@atlaskit/linking-types';
|
|
4
7
|
import type { cardPlugin } from '../../plugin';
|
|
5
8
|
declare const ModalWithState: ({ api, editorView, }: {
|
|
6
9
|
api: ExtractInjectionAPI<typeof cardPlugin> | undefined;
|
|
7
10
|
editorView: EditorView;
|
|
8
11
|
}) => JSX.Element | null;
|
|
12
|
+
export type ModalTypeToComponentMap = {
|
|
13
|
+
componentType: React.ComponentType<ConfigModalProps<InlineCardAdf | DatasourceAdf, DatasourceParameters>>;
|
|
14
|
+
datasourceId: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const modalTypeToComponentMap: {
|
|
17
|
+
[key in DatasourceModalType]: ModalTypeToComponentMap;
|
|
18
|
+
};
|
|
9
19
|
export default ModalWithState;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { DatasourceModalType } from '@atlaskit/editor-common/types';
|
|
4
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
4
|
import type { CardContext } from '@atlaskit/smart-card';
|
|
5
|
+
import type { ModalTypeToComponentMap } from './ModalWithState';
|
|
6
6
|
type DatasourceModalProps = {
|
|
7
7
|
view: EditorView;
|
|
8
8
|
editorAnalyticsApi?: EditorAnalyticsAPI;
|
|
9
|
-
modalType?: DatasourceModalType;
|
|
10
9
|
cardContext?: CardContext;
|
|
11
|
-
};
|
|
12
|
-
export declare const DatasourceModal: ({ view,
|
|
10
|
+
} & ModalTypeToComponentMap;
|
|
11
|
+
export declare const DatasourceModal: ({ view, cardContext, datasourceId: defaultDatasourceId, componentType: Component, }: DatasourceModalProps) => JSX.Element | null;
|
|
13
12
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
".": "./src/index.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@atlaskit/adf-schema": "^
|
|
35
|
+
"@atlaskit/adf-schema": "^36.1.0",
|
|
36
36
|
"@atlaskit/analytics-next": "^9.3.0",
|
|
37
37
|
"@atlaskit/custom-steps": "^0.1.0",
|
|
38
38
|
"@atlaskit/editor-common": "^79.2.0",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"@atlaskit/icon": "^22.1.0",
|
|
51
51
|
"@atlaskit/link-analytics": "^8.3.0",
|
|
52
52
|
"@atlaskit/link-client-extension": "^1.8.0",
|
|
53
|
-
"@atlaskit/link-datasource": "^2.
|
|
53
|
+
"@atlaskit/link-datasource": "^2.1.0",
|
|
54
54
|
"@atlaskit/linking-common": "^5.6.0",
|
|
55
55
|
"@atlaskit/linking-types": "^8.8.0",
|
|
56
56
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
57
57
|
"@atlaskit/primitives": "^6.1.0",
|
|
58
|
-
"@atlaskit/smart-card": "^26.
|
|
59
|
-
"@atlaskit/theme": "^12.
|
|
60
|
-
"@atlaskit/tokens": "^1.
|
|
58
|
+
"@atlaskit/smart-card": "^26.63.0",
|
|
59
|
+
"@atlaskit/theme": "^12.8.0",
|
|
60
|
+
"@atlaskit/tokens": "^1.46.0",
|
|
61
61
|
"@babel/runtime": "^7.0.0",
|
|
62
62
|
"@emotion/react": "^11.7.1",
|
|
63
63
|
"lodash": "^4.17.21",
|