@atlaskit/editor-plugin-card 1.14.2 → 1.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/nodeviews/blockCard.js +9 -0
- package/dist/cjs/pm-plugins/doc.js +32 -11
- package/dist/cjs/pm-plugins/main.js +10 -5
- package/dist/cjs/toolbar.js +1 -1
- package/dist/cjs/ui/LayoutButton/index.js +11 -9
- package/dist/cjs/ui/LayoutButton/types.js +3 -1
- package/dist/cjs/ui/LayoutButton/utils.js +25 -1
- package/dist/cjs/utils.js +39 -1
- package/dist/es2019/nodeviews/blockCard.js +9 -0
- package/dist/es2019/pm-plugins/doc.js +33 -12
- package/dist/es2019/pm-plugins/main.js +8 -3
- package/dist/es2019/toolbar.js +2 -2
- package/dist/es2019/ui/LayoutButton/index.js +9 -7
- package/dist/es2019/ui/LayoutButton/types.js +1 -1
- package/dist/es2019/ui/LayoutButton/utils.js +19 -0
- package/dist/es2019/utils.js +36 -0
- package/dist/esm/nodeviews/blockCard.js +9 -0
- package/dist/esm/pm-plugins/doc.js +33 -12
- package/dist/esm/pm-plugins/main.js +8 -3
- package/dist/esm/toolbar.js +2 -2
- package/dist/esm/ui/LayoutButton/index.js +9 -7
- package/dist/esm/ui/LayoutButton/types.js +1 -1
- package/dist/esm/ui/LayoutButton/utils.js +23 -0
- package/dist/esm/utils.js +37 -0
- package/dist/types/pm-plugins/shouldReplaceLink.d.ts +1 -1
- package/dist/types/pm-plugins/util/resolve.d.ts +1 -1
- package/dist/types/pm-plugins/util/state.d.ts +1 -1
- package/dist/types/types.d.ts +6 -1
- package/dist/types/ui/LayoutButton/types.d.ts +6 -5
- package/dist/types/ui/LayoutButton/utils.d.ts +7 -1
- package/dist/types/utils.d.ts +16 -1
- package/dist/types-ts4.5/pm-plugins/shouldReplaceLink.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/util/resolve.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/util/state.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +6 -1
- package/dist/types-ts4.5/ui/LayoutButton/types.d.ts +10 -5
- package/dist/types-ts4.5/ui/LayoutButton/utils.d.ts +7 -1
- package/dist/types-ts4.5/utils.d.ts +16 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 1.14.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#102406](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102406)
|
|
8
|
+
[`4e5db5fc8294`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4e5db5fc8294) -
|
|
9
|
+
Minor refactors to improve type-safety. No expected functional changes.
|
|
10
|
+
|
|
3
11
|
## 1.14.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -19,8 +19,10 @@ var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
|
19
19
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
20
20
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
21
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
22
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
23
|
var _smartCard = require("@atlaskit/smart-card");
|
|
23
24
|
var _actions = require("../pm-plugins/actions");
|
|
25
|
+
var _utils2 = require("../utils");
|
|
24
26
|
var _genericCard = require("./genericCard");
|
|
25
27
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
26
28
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
@@ -153,6 +155,13 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
153
155
|
key: "validUpdate",
|
|
154
156
|
value: function validUpdate(currentNode, newNode) {
|
|
155
157
|
var _currentNode$attrs, _newNode$attrs;
|
|
158
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.editor-datasource-typeguards')) {
|
|
159
|
+
var _isCurrentNodeBlockCard = !(0, _utils2.isDatasourceNode)(currentNode);
|
|
160
|
+
var _isNewNodeDatasource = (0, _utils2.isDatasourceNode)(newNode);
|
|
161
|
+
|
|
162
|
+
// need to return falsy to update node
|
|
163
|
+
return !(_isCurrentNodeBlockCard && _isNewNodeDatasource);
|
|
164
|
+
}
|
|
156
165
|
var isCurrentNodeBlockCard = !((_currentNode$attrs = currentNode.attrs) !== null && _currentNode$attrs !== void 0 && _currentNode$attrs.datasource);
|
|
157
166
|
var isNewNodeDatasource = (_newNode$attrs = newNode.attrs) === null || _newNode$attrs === void 0 ? void 0 : _newNode$attrs.datasource;
|
|
158
167
|
|
|
@@ -497,7 +497,9 @@ var updateCardViaDatasource = exports.updateCardViaDatasource = function updateC
|
|
|
497
497
|
inputMethod: inputMethod
|
|
498
498
|
});
|
|
499
499
|
if (isDeletingConfig) {
|
|
500
|
-
|
|
500
|
+
if (typeof node.attrs.url === 'string') {
|
|
501
|
+
(0, _actions.removeDatasourceStash)(tr, node.attrs.url);
|
|
502
|
+
}
|
|
501
503
|
} else {
|
|
502
504
|
(0, _actions.hideDatasourceModal)(tr);
|
|
503
505
|
}
|
|
@@ -531,19 +533,38 @@ var getAttrsForAppearance = exports.getAttrsForAppearance = function getAttrsFor
|
|
|
531
533
|
layout: 'center'
|
|
532
534
|
});
|
|
533
535
|
}
|
|
534
|
-
if (
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
536
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.editor-datasource-typeguards')) {
|
|
537
|
+
if ((0, _utils2.isDatasourceNode)(selectedNode)) {
|
|
538
|
+
return {
|
|
539
|
+
url: selectedNode.attrs.url
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
} else {
|
|
543
|
+
if (selectedNode.attrs.datasource) {
|
|
544
|
+
return {
|
|
545
|
+
url: selectedNode.attrs.url
|
|
546
|
+
};
|
|
547
|
+
}
|
|
538
548
|
}
|
|
539
549
|
return selectedNode.attrs;
|
|
540
550
|
};
|
|
541
551
|
var updateDatasourceStash = function updateDatasourceStash(tr, selectedNode) {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
552
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
553
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.editor-datasource-typeguards')) {
|
|
554
|
+
if ((0, _utils2.isDatasourceNode)(selectedNode) && !(0, _utils2.isDatasourceConfigEditable)(selectedNode.attrs.datasource.id) && selectedNode.attrs.url) {
|
|
555
|
+
(0, _actions.setDatasourceStash)(tr, {
|
|
556
|
+
url: selectedNode.attrs.url,
|
|
557
|
+
views: selectedNode.attrs.datasource.views
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
} else {
|
|
561
|
+
var _selectedNode$attrs;
|
|
562
|
+
if (selectedNode !== null && selectedNode !== void 0 && (_selectedNode$attrs = selectedNode.attrs) !== null && _selectedNode$attrs !== void 0 && _selectedNode$attrs.datasource && !(0, _utils2.isDatasourceConfigEditable)(selectedNode.attrs.datasource.id)) {
|
|
563
|
+
(0, _actions.setDatasourceStash)(tr, {
|
|
564
|
+
url: selectedNode.attrs.url,
|
|
565
|
+
views: selectedNode.attrs.datasource.views
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
}
|
|
548
569
|
}
|
|
549
570
|
};
|
|
@@ -29,7 +29,8 @@ var _blockCard = require("../nodeviews/blockCard");
|
|
|
29
29
|
var _datasource = require("../nodeviews/datasource");
|
|
30
30
|
var _embedCard = require("../nodeviews/embedCard");
|
|
31
31
|
var _inlineCard = require("../nodeviews/inlineCard");
|
|
32
|
-
var _utils3 = require("../utils");
|
|
32
|
+
var _utils3 = require("../ui/LayoutButton/utils");
|
|
33
|
+
var _utils4 = require("../utils");
|
|
33
34
|
var _actions = require("./actions");
|
|
34
35
|
var _pluginKey = require("./plugin-key");
|
|
35
36
|
var _reducers = _interopRequireDefault(require("./reducers"));
|
|
@@ -148,8 +149,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
148
149
|
return newState;
|
|
149
150
|
}
|
|
150
151
|
var linkPosition = pluginState.requests[0].pos;
|
|
151
|
-
var canBeUpgradedToBlock = allowBlockCards && (0,
|
|
152
|
-
var canBeUpgradedToEmbed = allowEmbeds && (0,
|
|
152
|
+
var canBeUpgradedToBlock = allowBlockCards && (0, _utils4.isBlockSupportedAtPosition)(linkPosition, prevEditorState, 'inline');
|
|
153
|
+
var canBeUpgradedToEmbed = allowEmbeds && (0, _utils4.isEmbedSupportedAtPosition)(linkPosition, prevEditorState, 'inline');
|
|
153
154
|
if (canBeUpgradedToBlock || canBeUpgradedToEmbed) {
|
|
154
155
|
newState.overlayCandidatePosition = linkPosition;
|
|
155
156
|
}
|
|
@@ -185,8 +186,12 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
185
186
|
var shouldUpdateTableRef = datasourceTableRef && (currentState === null || currentState === void 0 ? void 0 : currentState.datasourceTableRef) !== datasourceTableRef;
|
|
186
187
|
if (isDatasource && shouldUpdateTableRef) {
|
|
187
188
|
var _node$attrs2;
|
|
189
|
+
var getLayout = function getLayout() {
|
|
190
|
+
return (0, _utils3.isDatasourceTableLayout)(node.attrs.layout) ? node.attrs.layout : _linkingCommon.DATASOURCE_DEFAULT_LAYOUT;
|
|
191
|
+
};
|
|
192
|
+
|
|
188
193
|
// since we use the plugin state, which is a shared state, we need to update the datasourceTableRef, layout on each selection
|
|
189
|
-
var layout = (node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.layout) || _linkingCommon.DATASOURCE_DEFAULT_LAYOUT;
|
|
194
|
+
var layout = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.editor-datasource-typeguards') ? getLayout() : (node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.layout) || _linkingCommon.DATASOURCE_DEFAULT_LAYOUT;
|
|
190
195
|
var isNested = selection.$anchor.depth > 0;
|
|
191
196
|
|
|
192
197
|
// we want to disable resize button when datasource table is nested by not setting then datasourceTableRef on selection
|
|
@@ -258,7 +263,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
258
263
|
onClickCallback: options.onClickCallback
|
|
259
264
|
};
|
|
260
265
|
var hasIntlContext = true;
|
|
261
|
-
var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
|
|
266
|
+
var isDatasource = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.editor-datasource-typeguards') ? (0, _utils4.isDatasourceNode)(node) : !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
|
|
262
267
|
if (isDatasource) {
|
|
263
268
|
var _node$attrs4;
|
|
264
269
|
if (options.allowDatasource && platform !== 'mobile' && (0, _utils.canRenderDatasource)(node === null || node === void 0 || (_node$attrs4 = node.attrs) === null || _node$attrs4 === void 0 || (_node$attrs4 = _node$attrs4.datasource) === null || _node$attrs4 === void 0 ? void 0 : _node$attrs4.id)) {
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -206,7 +206,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
206
206
|
var currentAppearance = (0, _utils3.appearanceForNodeType)(node.type);
|
|
207
207
|
var _ref2 = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
|
|
208
208
|
hoverDecoration = _ref2.hoverDecoration;
|
|
209
|
-
var isDatasource = currentAppearance === 'block' && (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
|
|
209
|
+
var isDatasource = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.editor-datasource-typeguards') ? (0, _utils3.isDatasourceNode)(node) : currentAppearance === 'block' && (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
|
|
210
210
|
var shouldRenderDatasourceToolbar = isDatasource &&
|
|
211
211
|
// not showing toolbar in mobile for now since not sure what our plans are for it
|
|
212
212
|
platform !== 'mobile' && cardOptions.allowDatasource && (0, _utils.canRenderDatasource)(node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 || (_node$attrs2 = _node$attrs2.datasource) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.id);
|
|
@@ -16,9 +16,11 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
16
16
|
var _collapse = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/collapse"));
|
|
17
17
|
var _expand = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/expand"));
|
|
18
18
|
var _linkingCommon = require("@atlaskit/linking-common");
|
|
19
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
20
|
var _colors = require("@atlaskit/theme/colors");
|
|
20
21
|
var _actions = require("../../pm-plugins/actions");
|
|
21
|
-
var _utils2 = require("
|
|
22
|
+
var _utils2 = require("../../utils");
|
|
23
|
+
var _utils3 = require("./utils");
|
|
22
24
|
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; }
|
|
23
25
|
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; } /** @jsx jsx */
|
|
24
26
|
var toolbarButtonWrapperStyles = (0, _react2.css)({
|
|
@@ -81,17 +83,20 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
|
81
83
|
api = _ref2.api;
|
|
82
84
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['card']),
|
|
83
85
|
cardState = _useSharedPluginState.cardState;
|
|
84
|
-
var _getDatasource = (0,
|
|
86
|
+
var _getDatasource = (0, _utils3.getDatasource)(editorView),
|
|
85
87
|
node = _getDatasource.node,
|
|
86
88
|
pos = _getDatasource.pos;
|
|
89
|
+
var isDatasource = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.editor-datasource-typeguards') ? (0, _utils2.isDatasourceNode)(node) : !!(node !== null && node !== void 0 && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.datasource);
|
|
90
|
+
if (!isDatasource) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
87
93
|
|
|
88
94
|
// If layout doesn't exist in ADF it returns null, we want to change to undefined
|
|
89
95
|
// which results in default parameter value being used in LayoutButton.
|
|
90
96
|
var _ref3 = cardState !== null && cardState !== void 0 ? cardState : {},
|
|
91
97
|
datasourceTableRef = _ref3.datasourceTableRef,
|
|
92
98
|
_ref3$layout = _ref3.layout,
|
|
93
|
-
layout = _ref3$layout === void 0 ? (node === null || node === void 0 || (_node$
|
|
94
|
-
var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.datasource);
|
|
99
|
+
layout = _ref3$layout === void 0 ? (node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.layout) || undefined : _ref3$layout;
|
|
95
100
|
var onLayoutChange = function onLayoutChange(layout) {
|
|
96
101
|
var _getDatasource$node;
|
|
97
102
|
if (pos === undefined) {
|
|
@@ -100,22 +105,19 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
|
100
105
|
var state = editorView.state,
|
|
101
106
|
dispatch = editorView.dispatch;
|
|
102
107
|
// If the button does not re-render due to no card state change, node reference will be stale
|
|
103
|
-
var datasourceNode = (_getDatasource$node = (0,
|
|
108
|
+
var datasourceNode = (_getDatasource$node = (0, _utils3.getDatasource)(editorView).node) !== null && _getDatasource$node !== void 0 ? _getDatasource$node : node;
|
|
104
109
|
var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, datasourceNode === null || datasourceNode === void 0 ? void 0 : datasourceNode.attrs), {}, {
|
|
105
110
|
layout: layout
|
|
106
111
|
}));
|
|
107
112
|
tr.setMeta('scrollIntoView', false);
|
|
108
113
|
dispatch((0, _actions.setCardLayout)(layout)(tr));
|
|
109
114
|
};
|
|
110
|
-
if (!isDatasource) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
115
|
return (0, _react2.jsx)(LayoutButton, {
|
|
114
116
|
mountPoint: mountPoint,
|
|
115
117
|
scrollableElement: scrollableElement,
|
|
116
118
|
boundariesElement: boundariesElement,
|
|
117
119
|
targetElement: datasourceTableRef,
|
|
118
|
-
layout: layout,
|
|
120
|
+
layout: (0, _utils3.isDatasourceTableLayout)(layout) ? layout : undefined,
|
|
119
121
|
onLayoutChange: onLayoutChange,
|
|
120
122
|
intl: intl
|
|
121
123
|
});
|
|
@@ -1,18 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.getDatasource = void 0;
|
|
7
|
+
exports.isDatasourceTableLayout = exports.getDatasource = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
|
+
var _utils2 = require("../../utils");
|
|
12
|
+
var _types = require("./types");
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
8
15
|
var getDatasource = exports.getDatasource = function getDatasource(editorView) {
|
|
9
16
|
var _findSelectedNodeOfTy;
|
|
10
17
|
var _editorView$state = editorView.state,
|
|
11
18
|
selection = _editorView$state.selection,
|
|
12
19
|
schema = _editorView$state.schema;
|
|
13
20
|
var blockCard = schema.nodes.blockCard;
|
|
21
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.editor-datasource-typeguards')) {
|
|
22
|
+
var findResult = (0, _utils.findSelectedNodeOfType)([blockCard])(selection);
|
|
23
|
+
if (findResult && (0, _utils2.isDatasourceNode)(findResult.node)) {
|
|
24
|
+
return _objectSpread(_objectSpread({}, findResult), {}, {
|
|
25
|
+
node: findResult.node
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
node: undefined,
|
|
30
|
+
pos: undefined
|
|
31
|
+
};
|
|
32
|
+
}
|
|
14
33
|
return (_findSelectedNodeOfTy = (0, _utils.findSelectedNodeOfType)([blockCard])(selection)) !== null && _findSelectedNodeOfTy !== void 0 ? _findSelectedNodeOfTy : {
|
|
15
34
|
node: undefined,
|
|
16
35
|
pos: undefined
|
|
17
36
|
};
|
|
37
|
+
};
|
|
38
|
+
var isDatasourceTableLayout = exports.isDatasourceTableLayout = function isDatasourceTableLayout(layout) {
|
|
39
|
+
return _types.DATASOURCE_TABLE_LAYOUTS.some(function (l) {
|
|
40
|
+
return l === layout;
|
|
41
|
+
});
|
|
18
42
|
};
|
package/dist/cjs/utils.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.titleUrlPairFromNode = exports.selectedCardAppearance = exports.mergeCardInfo = exports.isEmbedSupportedAtPosition = exports.isDatasourceConfigEditable = exports.isBlockSupportedAtPosition = exports.getResolvedAttributesFromStore = exports.findCardInfo = exports.displayInfoForCard = exports.appearanceForNodeType = void 0;
|
|
7
|
+
exports.titleUrlPairFromNode = exports.selectedCardAppearance = exports.mergeCardInfo = exports.isEmbedSupportedAtPosition = exports.isDatasourceNode = exports.isDatasourceConfigEditable = exports.isDatasourceAdfAttributes = exports.isBlockSupportedAtPosition = exports.getResolvedAttributesFromStore = exports.findCardInfo = exports.displayInfoForCard = exports.appearanceForNodeType = void 0;
|
|
8
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
7
9
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
11
|
var _resolvedAttributes = require("@atlaskit/link-analytics/resolved-attributes");
|
|
@@ -84,4 +86,40 @@ var isDatasourceConfigEditable = exports.isDatasourceConfigEditable = function i
|
|
|
84
86
|
datasourcesWithConfigModal.push(_linkDatasource.CONFLUENCE_SEARCH_DATASOURCE_ID);
|
|
85
87
|
}
|
|
86
88
|
return datasourcesWithConfigModal.includes(datasourceId);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Typeguard that checks node attributes are datasource node attributes
|
|
93
|
+
* ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
|
|
94
|
+
* this function will not be updated automatically
|
|
95
|
+
*/
|
|
96
|
+
var isDatasourceAdfAttributes = exports.isDatasourceAdfAttributes = function isDatasourceAdfAttributes(attrs) {
|
|
97
|
+
// Check is attributes object
|
|
98
|
+
if (!((0, _typeof2.default)(attrs) === 'object' && attrs !== null)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Check datasource attribute is an object
|
|
103
|
+
if (!('datasource' in attrs)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
if ((0, _typeof2.default)(attrs.datasource) !== 'object' || attrs.datasource === null) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
var hasId = 'id' in attrs.datasource && typeof attrs.datasource.id === 'string';
|
|
110
|
+
var hasParameters = 'parameters' in attrs.datasource && (0, _typeof2.default)(attrs.datasource.parameters) === 'object' && attrs.datasource.parameters !== null && !Array.isArray(attrs.datasource.parameters);
|
|
111
|
+
var hasViews = 'views' in attrs.datasource && Array.isArray(attrs.datasource.views);
|
|
112
|
+
return hasId && hasParameters && hasViews;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Typeguard that checks a node is a datasource node (blockCard and has datasource attributes)
|
|
117
|
+
* ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
|
|
118
|
+
* this function will not be updated automatically
|
|
119
|
+
*/
|
|
120
|
+
var isDatasourceNode = exports.isDatasourceNode = function isDatasourceNode(node) {
|
|
121
|
+
if (!node) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return node.type.name === 'blockCard' && isDatasourceAdfAttributes(node.attrs);
|
|
87
125
|
};
|
|
@@ -5,8 +5,10 @@ import rafSchedule from 'raf-schd';
|
|
|
5
5
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
6
6
|
import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
7
7
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
8
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
9
10
|
import { registerCard } from '../pm-plugins/actions';
|
|
11
|
+
import { isDatasourceNode } from '../utils';
|
|
10
12
|
import { Card } from './genericCard';
|
|
11
13
|
|
|
12
14
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -122,6 +124,13 @@ export class BlockCard extends ReactNodeView {
|
|
|
122
124
|
// Otherwise, the node view will still consider the node as a blockCard and render a regular blockCard.
|
|
123
125
|
validUpdate(currentNode, newNode) {
|
|
124
126
|
var _currentNode$attrs, _newNode$attrs;
|
|
127
|
+
if (getBooleanFF('platform.linking-platform.editor-datasource-typeguards')) {
|
|
128
|
+
const isCurrentNodeBlockCard = !isDatasourceNode(currentNode);
|
|
129
|
+
const isNewNodeDatasource = isDatasourceNode(newNode);
|
|
130
|
+
|
|
131
|
+
// need to return falsy to update node
|
|
132
|
+
return !(isCurrentNodeBlockCard && isNewNodeDatasource);
|
|
133
|
+
}
|
|
125
134
|
const isCurrentNodeBlockCard = !((_currentNode$attrs = currentNode.attrs) !== null && _currentNode$attrs !== void 0 && _currentNode$attrs.datasource);
|
|
126
135
|
const isNewNodeDatasource = (_newNode$attrs = newNode.attrs) === null || _newNode$attrs === void 0 ? void 0 : _newNode$attrs.datasource;
|
|
127
136
|
|
|
@@ -6,7 +6,7 @@ import { getLinkCreationAnalyticsEvent, isFromCurrentDomain, nodesBetweenChanged
|
|
|
6
6
|
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
7
7
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
|
-
import { appearanceForNodeType, isDatasourceConfigEditable, selectedCardAppearance } from '../utils';
|
|
9
|
+
import { appearanceForNodeType, isDatasourceConfigEditable, isDatasourceNode, selectedCardAppearance } from '../utils';
|
|
10
10
|
import { hideDatasourceModal, queueCards, removeDatasourceStash, resolveCard, setDatasourceStash } from './actions';
|
|
11
11
|
import { pluginKey } from './plugin-key';
|
|
12
12
|
import { shouldReplaceLink } from './shouldReplaceLink';
|
|
@@ -475,7 +475,9 @@ export const updateCardViaDatasource = args => {
|
|
|
475
475
|
inputMethod
|
|
476
476
|
});
|
|
477
477
|
if (isDeletingConfig) {
|
|
478
|
-
|
|
478
|
+
if (typeof node.attrs.url === 'string') {
|
|
479
|
+
removeDatasourceStash(tr, node.attrs.url);
|
|
480
|
+
}
|
|
479
481
|
} else {
|
|
480
482
|
hideDatasourceModal(tr);
|
|
481
483
|
}
|
|
@@ -518,19 +520,38 @@ export const getAttrsForAppearance = (appearance, selectedNode) => {
|
|
|
518
520
|
layout: 'center'
|
|
519
521
|
};
|
|
520
522
|
}
|
|
521
|
-
if (
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
523
|
+
if (getBooleanFF('platform.linking-platform.editor-datasource-typeguards')) {
|
|
524
|
+
if (isDatasourceNode(selectedNode)) {
|
|
525
|
+
return {
|
|
526
|
+
url: selectedNode.attrs.url
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
} else {
|
|
530
|
+
if (selectedNode.attrs.datasource) {
|
|
531
|
+
return {
|
|
532
|
+
url: selectedNode.attrs.url
|
|
533
|
+
};
|
|
534
|
+
}
|
|
525
535
|
}
|
|
526
536
|
return selectedNode.attrs;
|
|
527
537
|
};
|
|
528
538
|
const updateDatasourceStash = (tr, selectedNode) => {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
539
|
+
if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
540
|
+
if (getBooleanFF('platform.linking-platform.editor-datasource-typeguards')) {
|
|
541
|
+
if (isDatasourceNode(selectedNode) && !isDatasourceConfigEditable(selectedNode.attrs.datasource.id) && selectedNode.attrs.url) {
|
|
542
|
+
setDatasourceStash(tr, {
|
|
543
|
+
url: selectedNode.attrs.url,
|
|
544
|
+
views: selectedNode.attrs.datasource.views
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
} else {
|
|
548
|
+
var _selectedNode$attrs;
|
|
549
|
+
if (selectedNode !== null && selectedNode !== void 0 && (_selectedNode$attrs = selectedNode.attrs) !== null && _selectedNode$attrs !== void 0 && _selectedNode$attrs.datasource && !isDatasourceConfigEditable(selectedNode.attrs.datasource.id)) {
|
|
550
|
+
setDatasourceStash(tr, {
|
|
551
|
+
url: selectedNode.attrs.url,
|
|
552
|
+
views: selectedNode.attrs.datasource.views
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
}
|
|
535
556
|
}
|
|
536
557
|
};
|
|
@@ -13,7 +13,8 @@ import { BlockCard } from '../nodeviews/blockCard';
|
|
|
13
13
|
import { Datasource } from '../nodeviews/datasource';
|
|
14
14
|
import { EmbedCard } from '../nodeviews/embedCard';
|
|
15
15
|
import { InlineCardNodeView } from '../nodeviews/inlineCard';
|
|
16
|
-
import {
|
|
16
|
+
import { isDatasourceTableLayout } from '../ui/LayoutButton/utils';
|
|
17
|
+
import { isBlockSupportedAtPosition, isDatasourceNode, isEmbedSupportedAtPosition } from '../utils';
|
|
17
18
|
import { clearOverlayCandidate, setCardLayoutAndDatasourceTableRef, setDatasourceTableRef } from './actions';
|
|
18
19
|
import { pluginKey } from './plugin-key';
|
|
19
20
|
import reducer from './reducers';
|
|
@@ -174,8 +175,12 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
174
175
|
const shouldUpdateTableRef = datasourceTableRef && (currentState === null || currentState === void 0 ? void 0 : currentState.datasourceTableRef) !== datasourceTableRef;
|
|
175
176
|
if (isDatasource && shouldUpdateTableRef) {
|
|
176
177
|
var _node$attrs2;
|
|
178
|
+
const getLayout = () => {
|
|
179
|
+
return isDatasourceTableLayout(node.attrs.layout) ? node.attrs.layout : DATASOURCE_DEFAULT_LAYOUT;
|
|
180
|
+
};
|
|
181
|
+
|
|
177
182
|
// since we use the plugin state, which is a shared state, we need to update the datasourceTableRef, layout on each selection
|
|
178
|
-
const layout = (node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.layout) || DATASOURCE_DEFAULT_LAYOUT;
|
|
183
|
+
const layout = getBooleanFF('platform.linking-platform.editor-datasource-typeguards') ? getLayout() : (node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.layout) || DATASOURCE_DEFAULT_LAYOUT;
|
|
179
184
|
const isNested = selection.$anchor.depth > 0;
|
|
180
185
|
|
|
181
186
|
// we want to disable resize button when datasource table is nested by not setting then datasourceTableRef on selection
|
|
@@ -249,7 +254,7 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
249
254
|
onClickCallback: options.onClickCallback
|
|
250
255
|
};
|
|
251
256
|
const hasIntlContext = true;
|
|
252
|
-
const isDatasource = !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
|
|
257
|
+
const isDatasource = getBooleanFF('platform.linking-platform.editor-datasource-typeguards') ? isDatasourceNode(node) : !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
|
|
253
258
|
if (isDatasource) {
|
|
254
259
|
var _node$attrs4, _node$attrs4$datasour;
|
|
255
260
|
if (options.allowDatasource && platform !== 'mobile' && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$attrs4 = node.attrs) === null || _node$attrs4 === void 0 ? void 0 : (_node$attrs4$datasour = _node$attrs4.datasource) === null || _node$attrs4$datasour === void 0 ? void 0 : _node$attrs4$datasour.id)) {
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -21,7 +21,7 @@ import { editDatasource, EditDatasourceButton } from './ui/EditDatasourceButton'
|
|
|
21
21
|
import { buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/EditLinkToolbar';
|
|
22
22
|
import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
|
|
23
23
|
import { ToolbarViewedEvent } from './ui/ToolbarViewedEvent';
|
|
24
|
-
import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, titleUrlPairFromNode } from './utils';
|
|
24
|
+
import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, isDatasourceNode, titleUrlPairFromNode } from './utils';
|
|
25
25
|
export const removeCard = editorAnalyticsApi => commandWithMetadata((state, dispatch) => {
|
|
26
26
|
if (!(state.selection instanceof NodeSelection)) {
|
|
27
27
|
return false;
|
|
@@ -198,7 +198,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
198
198
|
const {
|
|
199
199
|
hoverDecoration
|
|
200
200
|
} = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {};
|
|
201
|
-
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);
|
|
201
|
+
const isDatasource = getBooleanFF('platform.linking-platform.editor-datasource-typeguards') ? isDatasourceNode(node) : currentAppearance === 'block' && (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
|
|
202
202
|
const shouldRenderDatasourceToolbar = isDatasource &&
|
|
203
203
|
// not showing toolbar in mobile for now since not sure what our plans are for it
|
|
204
204
|
platform !== 'mobile' && cardOptions.allowDatasource && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : (_node$attrs2$datasour = _node$attrs2.datasource) === null || _node$attrs2$datasour === void 0 ? void 0 : _node$attrs2$datasour.id);
|
|
@@ -9,9 +9,11 @@ import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
|
|
|
9
9
|
import CollapseIcon from '@atlaskit/icon/glyph/editor/collapse';
|
|
10
10
|
import ExpandIcon from '@atlaskit/icon/glyph/editor/expand';
|
|
11
11
|
import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
|
|
12
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { B300, N20A, N300 } from '@atlaskit/theme/colors';
|
|
13
14
|
import { setCardLayout } from '../../pm-plugins/actions';
|
|
14
|
-
import {
|
|
15
|
+
import { isDatasourceNode } from '../../utils';
|
|
16
|
+
import { getDatasource, isDatasourceTableLayout } from './utils';
|
|
15
17
|
const toolbarButtonWrapperStyles = css({
|
|
16
18
|
background: `${`var(--ds-background-neutral, ${N20A})`}`,
|
|
17
19
|
color: `${`var(--ds-icon, ${N300})`}`,
|
|
@@ -79,14 +81,17 @@ const LayoutButtonWrapper = ({
|
|
|
79
81
|
node,
|
|
80
82
|
pos
|
|
81
83
|
} = getDatasource(editorView);
|
|
84
|
+
const isDatasource = getBooleanFF('platform.linking-platform.editor-datasource-typeguards') ? isDatasourceNode(node) : !!(node !== null && node !== void 0 && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.datasource);
|
|
85
|
+
if (!isDatasource) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
82
88
|
|
|
83
89
|
// If layout doesn't exist in ADF it returns null, we want to change to undefined
|
|
84
90
|
// which results in default parameter value being used in LayoutButton.
|
|
85
91
|
const {
|
|
86
92
|
datasourceTableRef,
|
|
87
|
-
layout = (node === null || node === void 0 ? void 0 : (_node$
|
|
93
|
+
layout = (node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.layout) || undefined
|
|
88
94
|
} = cardState !== null && cardState !== void 0 ? cardState : {};
|
|
89
|
-
const isDatasource = !!(node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.datasource);
|
|
90
95
|
const onLayoutChange = layout => {
|
|
91
96
|
var _getDatasource$node;
|
|
92
97
|
if (pos === undefined) {
|
|
@@ -105,15 +110,12 @@ const LayoutButtonWrapper = ({
|
|
|
105
110
|
tr.setMeta('scrollIntoView', false);
|
|
106
111
|
dispatch(setCardLayout(layout)(tr));
|
|
107
112
|
};
|
|
108
|
-
if (!isDatasource) {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
113
|
return jsx(LayoutButton, {
|
|
112
114
|
mountPoint: mountPoint,
|
|
113
115
|
scrollableElement: scrollableElement,
|
|
114
116
|
boundariesElement: boundariesElement,
|
|
115
117
|
targetElement: datasourceTableRef,
|
|
116
|
-
layout: layout,
|
|
118
|
+
layout: isDatasourceTableLayout(layout) ? layout : undefined,
|
|
117
119
|
onLayoutChange: onLayoutChange,
|
|
118
120
|
intl: intl
|
|
119
121
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const DATASOURCE_TABLE_LAYOUTS = ['full-width', 'center', 'wide'];
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { isDatasourceNode } from '../../utils';
|
|
4
|
+
import { DATASOURCE_TABLE_LAYOUTS } from './types';
|
|
2
5
|
export const getDatasource = editorView => {
|
|
3
6
|
var _findSelectedNodeOfTy;
|
|
4
7
|
const {
|
|
@@ -8,8 +11,24 @@ export const getDatasource = editorView => {
|
|
|
8
11
|
const {
|
|
9
12
|
blockCard
|
|
10
13
|
} = schema.nodes;
|
|
14
|
+
if (getBooleanFF('platform.linking-platform.editor-datasource-typeguards')) {
|
|
15
|
+
const findResult = findSelectedNodeOfType([blockCard])(selection);
|
|
16
|
+
if (findResult && isDatasourceNode(findResult.node)) {
|
|
17
|
+
return {
|
|
18
|
+
...findResult,
|
|
19
|
+
node: findResult.node
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
node: undefined,
|
|
24
|
+
pos: undefined
|
|
25
|
+
};
|
|
26
|
+
}
|
|
11
27
|
return (_findSelectedNodeOfTy = findSelectedNodeOfType([blockCard])(selection)) !== null && _findSelectedNodeOfTy !== void 0 ? _findSelectedNodeOfTy : {
|
|
12
28
|
node: undefined,
|
|
13
29
|
pos: undefined
|
|
14
30
|
};
|
|
31
|
+
};
|
|
32
|
+
export const isDatasourceTableLayout = layout => {
|
|
33
|
+
return DATASOURCE_TABLE_LAYOUTS.some(l => l === layout);
|
|
15
34
|
};
|
package/dist/es2019/utils.js
CHANGED
|
@@ -72,4 +72,40 @@ export const isDatasourceConfigEditable = datasourceId => {
|
|
|
72
72
|
datasourcesWithConfigModal.push(CONFLUENCE_SEARCH_DATASOURCE_ID);
|
|
73
73
|
}
|
|
74
74
|
return datasourcesWithConfigModal.includes(datasourceId);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Typeguard that checks node attributes are datasource node attributes
|
|
79
|
+
* ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
|
|
80
|
+
* this function will not be updated automatically
|
|
81
|
+
*/
|
|
82
|
+
export const isDatasourceAdfAttributes = attrs => {
|
|
83
|
+
// Check is attributes object
|
|
84
|
+
if (!(typeof attrs === 'object' && attrs !== null)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Check datasource attribute is an object
|
|
89
|
+
if (!('datasource' in attrs)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if (typeof attrs.datasource !== 'object' || attrs.datasource === null) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
const hasId = 'id' in attrs.datasource && typeof attrs.datasource.id === 'string';
|
|
96
|
+
const hasParameters = 'parameters' in attrs.datasource && typeof attrs.datasource.parameters === 'object' && attrs.datasource.parameters !== null && !Array.isArray(attrs.datasource.parameters);
|
|
97
|
+
const hasViews = 'views' in attrs.datasource && Array.isArray(attrs.datasource.views);
|
|
98
|
+
return hasId && hasParameters && hasViews;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Typeguard that checks a node is a datasource node (blockCard and has datasource attributes)
|
|
103
|
+
* ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
|
|
104
|
+
* this function will not be updated automatically
|
|
105
|
+
*/
|
|
106
|
+
export const isDatasourceNode = node => {
|
|
107
|
+
if (!node) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return node.type.name === 'blockCard' && isDatasourceAdfAttributes(node.attrs);
|
|
75
111
|
};
|
|
@@ -14,8 +14,10 @@ import rafSchedule from 'raf-schd';
|
|
|
14
14
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
15
15
|
import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
16
16
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
17
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
17
18
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
18
19
|
import { registerCard } from '../pm-plugins/actions';
|
|
20
|
+
import { isDatasourceNode } from '../utils';
|
|
19
21
|
import { Card } from './genericCard';
|
|
20
22
|
|
|
21
23
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -147,6 +149,13 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
147
149
|
key: "validUpdate",
|
|
148
150
|
value: function validUpdate(currentNode, newNode) {
|
|
149
151
|
var _currentNode$attrs, _newNode$attrs;
|
|
152
|
+
if (getBooleanFF('platform.linking-platform.editor-datasource-typeguards')) {
|
|
153
|
+
var _isCurrentNodeBlockCard = !isDatasourceNode(currentNode);
|
|
154
|
+
var _isNewNodeDatasource = isDatasourceNode(newNode);
|
|
155
|
+
|
|
156
|
+
// need to return falsy to update node
|
|
157
|
+
return !(_isCurrentNodeBlockCard && _isNewNodeDatasource);
|
|
158
|
+
}
|
|
150
159
|
var isCurrentNodeBlockCard = !((_currentNode$attrs = currentNode.attrs) !== null && _currentNode$attrs !== void 0 && _currentNode$attrs.datasource);
|
|
151
160
|
var isNewNodeDatasource = (_newNode$attrs = newNode.attrs) === null || _newNode$attrs === void 0 ? void 0 : _newNode$attrs.datasource;
|
|
152
161
|
|
|
@@ -10,7 +10,7 @@ import { getLinkCreationAnalyticsEvent, isFromCurrentDomain, nodesBetweenChanged
|
|
|
10
10
|
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
11
11
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
12
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
13
|
-
import { appearanceForNodeType, isDatasourceConfigEditable, selectedCardAppearance } from '../utils';
|
|
13
|
+
import { appearanceForNodeType, isDatasourceConfigEditable, isDatasourceNode, selectedCardAppearance } from '../utils';
|
|
14
14
|
import { hideDatasourceModal, queueCards, removeDatasourceStash, resolveCard, setDatasourceStash } from './actions';
|
|
15
15
|
import { pluginKey } from './plugin-key';
|
|
16
16
|
import { shouldReplaceLink } from './shouldReplaceLink';
|
|
@@ -490,7 +490,9 @@ export var updateCardViaDatasource = function updateCardViaDatasource(args) {
|
|
|
490
490
|
inputMethod: inputMethod
|
|
491
491
|
});
|
|
492
492
|
if (isDeletingConfig) {
|
|
493
|
-
|
|
493
|
+
if (typeof node.attrs.url === 'string') {
|
|
494
|
+
removeDatasourceStash(tr, node.attrs.url);
|
|
495
|
+
}
|
|
494
496
|
} else {
|
|
495
497
|
hideDatasourceModal(tr);
|
|
496
498
|
}
|
|
@@ -524,19 +526,38 @@ export var getAttrsForAppearance = function getAttrsForAppearance(appearance, se
|
|
|
524
526
|
layout: 'center'
|
|
525
527
|
});
|
|
526
528
|
}
|
|
527
|
-
if (
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
529
|
+
if (getBooleanFF('platform.linking-platform.editor-datasource-typeguards')) {
|
|
530
|
+
if (isDatasourceNode(selectedNode)) {
|
|
531
|
+
return {
|
|
532
|
+
url: selectedNode.attrs.url
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
} else {
|
|
536
|
+
if (selectedNode.attrs.datasource) {
|
|
537
|
+
return {
|
|
538
|
+
url: selectedNode.attrs.url
|
|
539
|
+
};
|
|
540
|
+
}
|
|
531
541
|
}
|
|
532
542
|
return selectedNode.attrs;
|
|
533
543
|
};
|
|
534
544
|
var updateDatasourceStash = function updateDatasourceStash(tr, selectedNode) {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
545
|
+
if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
546
|
+
if (getBooleanFF('platform.linking-platform.editor-datasource-typeguards')) {
|
|
547
|
+
if (isDatasourceNode(selectedNode) && !isDatasourceConfigEditable(selectedNode.attrs.datasource.id) && selectedNode.attrs.url) {
|
|
548
|
+
setDatasourceStash(tr, {
|
|
549
|
+
url: selectedNode.attrs.url,
|
|
550
|
+
views: selectedNode.attrs.datasource.views
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
} else {
|
|
554
|
+
var _selectedNode$attrs;
|
|
555
|
+
if (selectedNode !== null && selectedNode !== void 0 && (_selectedNode$attrs = selectedNode.attrs) !== null && _selectedNode$attrs !== void 0 && _selectedNode$attrs.datasource && !isDatasourceConfigEditable(selectedNode.attrs.datasource.id)) {
|
|
556
|
+
setDatasourceStash(tr, {
|
|
557
|
+
url: selectedNode.attrs.url,
|
|
558
|
+
views: selectedNode.attrs.datasource.views
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
}
|
|
541
562
|
}
|
|
542
563
|
};
|
|
@@ -17,7 +17,8 @@ import { BlockCard } from '../nodeviews/blockCard';
|
|
|
17
17
|
import { Datasource } from '../nodeviews/datasource';
|
|
18
18
|
import { EmbedCard } from '../nodeviews/embedCard';
|
|
19
19
|
import { InlineCardNodeView } from '../nodeviews/inlineCard';
|
|
20
|
-
import {
|
|
20
|
+
import { isDatasourceTableLayout } from '../ui/LayoutButton/utils';
|
|
21
|
+
import { isBlockSupportedAtPosition, isDatasourceNode, isEmbedSupportedAtPosition } from '../utils';
|
|
21
22
|
import { clearOverlayCandidate, setCardLayoutAndDatasourceTableRef, setDatasourceTableRef } from './actions';
|
|
22
23
|
import { pluginKey } from './plugin-key';
|
|
23
24
|
import reducer from './reducers';
|
|
@@ -172,8 +173,12 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
172
173
|
var shouldUpdateTableRef = datasourceTableRef && (currentState === null || currentState === void 0 ? void 0 : currentState.datasourceTableRef) !== datasourceTableRef;
|
|
173
174
|
if (isDatasource && shouldUpdateTableRef) {
|
|
174
175
|
var _node$attrs2;
|
|
176
|
+
var getLayout = function getLayout() {
|
|
177
|
+
return isDatasourceTableLayout(node.attrs.layout) ? node.attrs.layout : DATASOURCE_DEFAULT_LAYOUT;
|
|
178
|
+
};
|
|
179
|
+
|
|
175
180
|
// since we use the plugin state, which is a shared state, we need to update the datasourceTableRef, layout on each selection
|
|
176
|
-
var layout = (node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.layout) || DATASOURCE_DEFAULT_LAYOUT;
|
|
181
|
+
var layout = getBooleanFF('platform.linking-platform.editor-datasource-typeguards') ? getLayout() : (node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.layout) || DATASOURCE_DEFAULT_LAYOUT;
|
|
177
182
|
var isNested = selection.$anchor.depth > 0;
|
|
178
183
|
|
|
179
184
|
// we want to disable resize button when datasource table is nested by not setting then datasourceTableRef on selection
|
|
@@ -245,7 +250,7 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
245
250
|
onClickCallback: options.onClickCallback
|
|
246
251
|
};
|
|
247
252
|
var hasIntlContext = true;
|
|
248
|
-
var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
|
|
253
|
+
var isDatasource = getBooleanFF('platform.linking-platform.editor-datasource-typeguards') ? isDatasourceNode(node) : !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
|
|
249
254
|
if (isDatasource) {
|
|
250
255
|
var _node$attrs4;
|
|
251
256
|
if (options.allowDatasource && platform !== 'mobile' && canRenderDatasource(node === null || node === void 0 || (_node$attrs4 = node.attrs) === null || _node$attrs4 === void 0 || (_node$attrs4 = _node$attrs4.datasource) === null || _node$attrs4 === void 0 ? void 0 : _node$attrs4.id)) {
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -25,7 +25,7 @@ import { editDatasource, EditDatasourceButton } from './ui/EditDatasourceButton'
|
|
|
25
25
|
import { buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/EditLinkToolbar';
|
|
26
26
|
import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
|
|
27
27
|
import { ToolbarViewedEvent } from './ui/ToolbarViewedEvent';
|
|
28
|
-
import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, titleUrlPairFromNode } from './utils';
|
|
28
|
+
import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, isDatasourceNode, titleUrlPairFromNode } from './utils';
|
|
29
29
|
export var removeCard = function removeCard(editorAnalyticsApi) {
|
|
30
30
|
return commandWithMetadata(function (state, dispatch) {
|
|
31
31
|
if (!(state.selection instanceof NodeSelection)) {
|
|
@@ -196,7 +196,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
196
196
|
var currentAppearance = appearanceForNodeType(node.type);
|
|
197
197
|
var _ref2 = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
|
|
198
198
|
hoverDecoration = _ref2.hoverDecoration;
|
|
199
|
-
var isDatasource = currentAppearance === 'block' && (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
|
|
199
|
+
var isDatasource = getBooleanFF('platform.linking-platform.editor-datasource-typeguards') ? isDatasourceNode(node) : currentAppearance === 'block' && (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
|
|
200
200
|
var shouldRenderDatasourceToolbar = isDatasource &&
|
|
201
201
|
// not showing toolbar in mobile for now since not sure what our plans are for it
|
|
202
202
|
platform !== 'mobile' && cardOptions.allowDatasource && canRenderDatasource(node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 || (_node$attrs2 = _node$attrs2.datasource) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.id);
|
|
@@ -12,9 +12,11 @@ import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
|
|
|
12
12
|
import CollapseIcon from '@atlaskit/icon/glyph/editor/collapse';
|
|
13
13
|
import ExpandIcon from '@atlaskit/icon/glyph/editor/expand';
|
|
14
14
|
import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
|
|
15
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
15
16
|
import { B300, N20A, N300 } from '@atlaskit/theme/colors';
|
|
16
17
|
import { setCardLayout } from '../../pm-plugins/actions';
|
|
17
|
-
import {
|
|
18
|
+
import { isDatasourceNode } from '../../utils';
|
|
19
|
+
import { getDatasource, isDatasourceTableLayout } from './utils';
|
|
18
20
|
var toolbarButtonWrapperStyles = css({
|
|
19
21
|
background: "".concat("var(--ds-background-neutral, ".concat(N20A, ")")),
|
|
20
22
|
color: "".concat("var(--ds-icon, ".concat(N300, ")")),
|
|
@@ -78,14 +80,17 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
|
78
80
|
var _getDatasource = getDatasource(editorView),
|
|
79
81
|
node = _getDatasource.node,
|
|
80
82
|
pos = _getDatasource.pos;
|
|
83
|
+
var isDatasource = getBooleanFF('platform.linking-platform.editor-datasource-typeguards') ? isDatasourceNode(node) : !!(node !== null && node !== void 0 && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.datasource);
|
|
84
|
+
if (!isDatasource) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
81
87
|
|
|
82
88
|
// If layout doesn't exist in ADF it returns null, we want to change to undefined
|
|
83
89
|
// which results in default parameter value being used in LayoutButton.
|
|
84
90
|
var _ref3 = cardState !== null && cardState !== void 0 ? cardState : {},
|
|
85
91
|
datasourceTableRef = _ref3.datasourceTableRef,
|
|
86
92
|
_ref3$layout = _ref3.layout,
|
|
87
|
-
layout = _ref3$layout === void 0 ? (node === null || node === void 0 || (_node$
|
|
88
|
-
var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.datasource);
|
|
93
|
+
layout = _ref3$layout === void 0 ? (node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.layout) || undefined : _ref3$layout;
|
|
89
94
|
var onLayoutChange = function onLayoutChange(layout) {
|
|
90
95
|
var _getDatasource$node;
|
|
91
96
|
if (pos === undefined) {
|
|
@@ -101,15 +106,12 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
|
101
106
|
tr.setMeta('scrollIntoView', false);
|
|
102
107
|
dispatch(setCardLayout(layout)(tr));
|
|
103
108
|
};
|
|
104
|
-
if (!isDatasource) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
109
|
return jsx(LayoutButton, {
|
|
108
110
|
mountPoint: mountPoint,
|
|
109
111
|
scrollableElement: scrollableElement,
|
|
110
112
|
boundariesElement: boundariesElement,
|
|
111
113
|
targetElement: datasourceTableRef,
|
|
112
|
-
layout: layout,
|
|
114
|
+
layout: isDatasourceTableLayout(layout) ? layout : undefined,
|
|
113
115
|
onLayoutChange: onLayoutChange,
|
|
114
116
|
intl: intl
|
|
115
117
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var DATASOURCE_TABLE_LAYOUTS = ['full-width', 'center', 'wide'];
|
|
@@ -1,12 +1,35 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
1
4
|
import { findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { isDatasourceNode } from '../../utils';
|
|
7
|
+
import { DATASOURCE_TABLE_LAYOUTS } from './types';
|
|
2
8
|
export var getDatasource = function getDatasource(editorView) {
|
|
3
9
|
var _findSelectedNodeOfTy;
|
|
4
10
|
var _editorView$state = editorView.state,
|
|
5
11
|
selection = _editorView$state.selection,
|
|
6
12
|
schema = _editorView$state.schema;
|
|
7
13
|
var blockCard = schema.nodes.blockCard;
|
|
14
|
+
if (getBooleanFF('platform.linking-platform.editor-datasource-typeguards')) {
|
|
15
|
+
var findResult = findSelectedNodeOfType([blockCard])(selection);
|
|
16
|
+
if (findResult && isDatasourceNode(findResult.node)) {
|
|
17
|
+
return _objectSpread(_objectSpread({}, findResult), {}, {
|
|
18
|
+
node: findResult.node
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
node: undefined,
|
|
23
|
+
pos: undefined
|
|
24
|
+
};
|
|
25
|
+
}
|
|
8
26
|
return (_findSelectedNodeOfTy = findSelectedNodeOfType([blockCard])(selection)) !== null && _findSelectedNodeOfTy !== void 0 ? _findSelectedNodeOfTy : {
|
|
9
27
|
node: undefined,
|
|
10
28
|
pos: undefined
|
|
11
29
|
};
|
|
30
|
+
};
|
|
31
|
+
export var isDatasourceTableLayout = function isDatasourceTableLayout(layout) {
|
|
32
|
+
return DATASOURCE_TABLE_LAYOUTS.some(function (l) {
|
|
33
|
+
return l === layout;
|
|
34
|
+
});
|
|
12
35
|
};
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
1
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import { getResolvedAttributes } from '@atlaskit/link-analytics/resolved-attributes';
|
|
@@ -78,4 +79,40 @@ export var isDatasourceConfigEditable = function isDatasourceConfigEditable(data
|
|
|
78
79
|
datasourcesWithConfigModal.push(CONFLUENCE_SEARCH_DATASOURCE_ID);
|
|
79
80
|
}
|
|
80
81
|
return datasourcesWithConfigModal.includes(datasourceId);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Typeguard that checks node attributes are datasource node attributes
|
|
86
|
+
* ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
|
|
87
|
+
* this function will not be updated automatically
|
|
88
|
+
*/
|
|
89
|
+
export var isDatasourceAdfAttributes = function isDatasourceAdfAttributes(attrs) {
|
|
90
|
+
// Check is attributes object
|
|
91
|
+
if (!(_typeof(attrs) === 'object' && attrs !== null)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Check datasource attribute is an object
|
|
96
|
+
if (!('datasource' in attrs)) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (_typeof(attrs.datasource) !== 'object' || attrs.datasource === null) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
var hasId = 'id' in attrs.datasource && typeof attrs.datasource.id === 'string';
|
|
103
|
+
var hasParameters = 'parameters' in attrs.datasource && _typeof(attrs.datasource.parameters) === 'object' && attrs.datasource.parameters !== null && !Array.isArray(attrs.datasource.parameters);
|
|
104
|
+
var hasViews = 'views' in attrs.datasource && Array.isArray(attrs.datasource.views);
|
|
105
|
+
return hasId && hasParameters && hasViews;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Typeguard that checks a node is a datasource node (blockCard and has datasource attributes)
|
|
110
|
+
* ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
|
|
111
|
+
* this function will not be updated automatically
|
|
112
|
+
*/
|
|
113
|
+
export var isDatasourceNode = function isDatasourceNode(node) {
|
|
114
|
+
if (!node) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
return node.type.name === 'blockCard' && isDatasourceAdfAttributes(node.attrs);
|
|
81
118
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Node } from '@atlaskit/editor-prosemirror/model';
|
|
1
|
+
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
export declare function shouldReplaceLink(node: Node, compareLinkText?: boolean, compareToUrl?: string): boolean;
|
|
@@ -4,5 +4,5 @@ import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
|
4
4
|
import type { CardProvider, DatasourceAdf } from '@atlaskit/editor-common/provider-factory';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { Request } from '../../types';
|
|
7
|
-
export declare const resolveWithProvider: (view: EditorView, provider: CardProvider, request: Request, options: CardOptions, editorAnalyticsApi: EditorAnalyticsAPI | undefined, createAnalyticsEvent: CreateUIAnalyticsEvent | undefined) => Promise<void | import("@atlaskit/linking-common").InlineCardAdf | import("@atlaskit/linking-common").BlockCardAdf | import("@atlaskit/linking-common").EmbedCardAdf
|
|
7
|
+
export declare const resolveWithProvider: (view: EditorView, provider: CardProvider, request: Request, options: CardOptions, editorAnalyticsApi: EditorAnalyticsAPI | undefined, createAnalyticsEvent: CreateUIAnalyticsEvent | undefined) => Promise<void | DatasourceAdf<Record<string, unknown>> | import("@atlaskit/linking-common").InlineCardAdf | import("@atlaskit/linking-common").BlockCardAdf | import("@atlaskit/linking-common").EmbedCardAdf>;
|
|
8
8
|
export declare const handleProvider: (_: 'cardProvider', provider: Promise<CardProvider> | undefined, view: EditorView) => void;
|
|
@@ -30,7 +30,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
|
|
|
30
30
|
showDatasourceModal: boolean;
|
|
31
31
|
datasourceModalType?: import("@atlaskit/editor-common/types").DatasourceModalType | undefined;
|
|
32
32
|
datasourceTableRef?: HTMLElement | undefined;
|
|
33
|
-
layout?:
|
|
33
|
+
layout?: "full-width" | "center" | "wide" | undefined;
|
|
34
34
|
inlineCardAwarenessCandidatePosition?: number | undefined;
|
|
35
35
|
overlayCandidatePosition?: number | undefined;
|
|
36
36
|
removeOverlay?: (() => void) | undefined;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import type { RichMediaAttributes } from '@atlaskit/adf-schema';
|
|
1
2
|
import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
2
3
|
import type { ACTION } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import type { CardOptions, CardReplacementInputMethod, OnClickCallback } from '@atlaskit/editor-common/card';
|
|
4
5
|
import type { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
5
6
|
import type { DatasourceModalType, EditorAppearance, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
6
|
-
import type {
|
|
7
|
+
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
+
import type { DatasourceAdf, DatasourceAdfView } from '@atlaskit/linking-common';
|
|
7
9
|
import type { SmartLinkEvents } from '@atlaskit/smart-card';
|
|
8
10
|
import type { EditorCardPluginEvents } from './analytics/create-events-queue';
|
|
9
11
|
import type { CardPluginEvent } from './analytics/types';
|
|
10
12
|
import type { DatasourceTableLayout } from './ui/LayoutButton/types';
|
|
13
|
+
export type DatasourceNode = Omit<Node, 'attrs'> & {
|
|
14
|
+
readonly attrs: DatasourceAdf['attrs'] & Partial<RichMediaAttributes>;
|
|
15
|
+
};
|
|
11
16
|
export type CardInfo = {
|
|
12
17
|
title?: string;
|
|
13
18
|
url?: string;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { IntlShape } from 'react-intl-next';
|
|
2
|
-
import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { cardPlugin } from '../../index';
|
|
5
|
-
export
|
|
5
|
+
export declare const DATASOURCE_TABLE_LAYOUTS: readonly ["full-width", "center", "wide"];
|
|
6
|
+
export type DatasourceTableLayout = (typeof DATASOURCE_TABLE_LAYOUTS)[number];
|
|
6
7
|
export type LayoutButtonProps = {
|
|
7
8
|
mountPoint?: HTMLElement;
|
|
8
9
|
boundariesElement?: HTMLElement;
|
|
9
10
|
scrollableElement?: HTMLElement;
|
|
10
11
|
targetElement?: HTMLElement;
|
|
11
|
-
layout
|
|
12
|
+
layout?: DatasourceTableLayout;
|
|
12
13
|
onLayoutChange?: (layout: DatasourceTableLayout) => void;
|
|
13
14
|
testId?: string;
|
|
14
15
|
intl: IntlShape;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
1
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
export declare const getDatasource: (editorView: EditorView) => import("prosemirror-utils/dist/types").ContentNodeWithPos | {
|
|
3
|
+
node: import("../../types").DatasourceNode;
|
|
4
|
+
start: number;
|
|
5
|
+
depth: number;
|
|
6
|
+
pos: number;
|
|
7
|
+
} | {
|
|
3
8
|
node: undefined;
|
|
4
9
|
pos: undefined;
|
|
5
10
|
};
|
|
11
|
+
export declare const isDatasourceTableLayout: (layout: unknown) => layout is "full-width" | "center" | "wide";
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
|
2
2
|
import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { CardContext } from '@atlaskit/link-provider';
|
|
5
|
-
import type { CardInfo } from './types';
|
|
5
|
+
import type { CardInfo, DatasourceNode } from './types';
|
|
6
6
|
export declare const appearanceForNodeType: (spec: NodeType) => CardAppearance | undefined;
|
|
7
7
|
export declare const selectedCardAppearance: (state: EditorState) => CardAppearance | undefined;
|
|
8
8
|
export type TitleUrlPair = {
|
|
@@ -22,3 +22,18 @@ export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, e
|
|
|
22
22
|
export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
|
|
23
23
|
export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext['store']) => {};
|
|
24
24
|
export declare const isDatasourceConfigEditable: (datasourceId: string) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Typeguard that checks node attributes are datasource node attributes
|
|
27
|
+
* ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
|
|
28
|
+
* this function will not be updated automatically
|
|
29
|
+
*/
|
|
30
|
+
export declare const isDatasourceAdfAttributes: (attrs: Record<string, unknown> | undefined) => attrs is {
|
|
31
|
+
url?: string | undefined;
|
|
32
|
+
datasource: import("@atlaskit/linking-common").Datasource<Record<string, unknown>>;
|
|
33
|
+
} & Partial<import("@atlaskit/adf-schema").RichMediaAttributes>;
|
|
34
|
+
/**
|
|
35
|
+
* Typeguard that checks a node is a datasource node (blockCard and has datasource attributes)
|
|
36
|
+
* ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
|
|
37
|
+
* this function will not be updated automatically
|
|
38
|
+
*/
|
|
39
|
+
export declare const isDatasourceNode: (node?: Node) => node is DatasourceNode;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Node } from '@atlaskit/editor-prosemirror/model';
|
|
1
|
+
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
export declare function shouldReplaceLink(node: Node, compareLinkText?: boolean, compareToUrl?: string): boolean;
|
|
@@ -4,5 +4,5 @@ import type { CardOptions } from '@atlaskit/editor-common/card';
|
|
|
4
4
|
import type { CardProvider, DatasourceAdf } from '@atlaskit/editor-common/provider-factory';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { Request } from '../../types';
|
|
7
|
-
export declare const resolveWithProvider: (view: EditorView, provider: CardProvider, request: Request, options: CardOptions, editorAnalyticsApi: EditorAnalyticsAPI | undefined, createAnalyticsEvent: CreateUIAnalyticsEvent | undefined) => Promise<void | import("@atlaskit/linking-common").InlineCardAdf | import("@atlaskit/linking-common").BlockCardAdf | import("@atlaskit/linking-common").EmbedCardAdf
|
|
7
|
+
export declare const resolveWithProvider: (view: EditorView, provider: CardProvider, request: Request, options: CardOptions, editorAnalyticsApi: EditorAnalyticsAPI | undefined, createAnalyticsEvent: CreateUIAnalyticsEvent | undefined) => Promise<void | DatasourceAdf<Record<string, unknown>> | import("@atlaskit/linking-common").InlineCardAdf | import("@atlaskit/linking-common").BlockCardAdf | import("@atlaskit/linking-common").EmbedCardAdf>;
|
|
8
8
|
export declare const handleProvider: (_: 'cardProvider', provider: Promise<CardProvider> | undefined, view: EditorView) => void;
|
|
@@ -30,7 +30,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
|
|
|
30
30
|
showDatasourceModal: boolean;
|
|
31
31
|
datasourceModalType?: import("@atlaskit/editor-common/types").DatasourceModalType | undefined;
|
|
32
32
|
datasourceTableRef?: HTMLElement | undefined;
|
|
33
|
-
layout?:
|
|
33
|
+
layout?: "full-width" | "center" | "wide" | undefined;
|
|
34
34
|
inlineCardAwarenessCandidatePosition?: number | undefined;
|
|
35
35
|
overlayCandidatePosition?: number | undefined;
|
|
36
36
|
removeOverlay?: (() => void) | undefined;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import type { RichMediaAttributes } from '@atlaskit/adf-schema';
|
|
1
2
|
import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
2
3
|
import type { ACTION } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import type { CardOptions, CardReplacementInputMethod, OnClickCallback } from '@atlaskit/editor-common/card';
|
|
4
5
|
import type { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
5
6
|
import type { DatasourceModalType, EditorAppearance, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
6
|
-
import type {
|
|
7
|
+
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
+
import type { DatasourceAdf, DatasourceAdfView } from '@atlaskit/linking-common';
|
|
7
9
|
import type { SmartLinkEvents } from '@atlaskit/smart-card';
|
|
8
10
|
import type { EditorCardPluginEvents } from './analytics/create-events-queue';
|
|
9
11
|
import type { CardPluginEvent } from './analytics/types';
|
|
10
12
|
import type { DatasourceTableLayout } from './ui/LayoutButton/types';
|
|
13
|
+
export type DatasourceNode = Omit<Node, 'attrs'> & {
|
|
14
|
+
readonly attrs: DatasourceAdf['attrs'] & Partial<RichMediaAttributes>;
|
|
15
|
+
};
|
|
11
16
|
export type CardInfo = {
|
|
12
17
|
title?: string;
|
|
13
18
|
url?: string;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { IntlShape } from 'react-intl-next';
|
|
2
|
-
import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { cardPlugin } from '../../index';
|
|
5
|
-
export
|
|
5
|
+
export declare const DATASOURCE_TABLE_LAYOUTS: readonly [
|
|
6
|
+
"full-width",
|
|
7
|
+
"center",
|
|
8
|
+
"wide"
|
|
9
|
+
];
|
|
10
|
+
export type DatasourceTableLayout = (typeof DATASOURCE_TABLE_LAYOUTS)[number];
|
|
6
11
|
export type LayoutButtonProps = {
|
|
7
12
|
mountPoint?: HTMLElement;
|
|
8
13
|
boundariesElement?: HTMLElement;
|
|
9
14
|
scrollableElement?: HTMLElement;
|
|
10
15
|
targetElement?: HTMLElement;
|
|
11
|
-
layout
|
|
16
|
+
layout?: DatasourceTableLayout;
|
|
12
17
|
onLayoutChange?: (layout: DatasourceTableLayout) => void;
|
|
13
18
|
testId?: string;
|
|
14
19
|
intl: IntlShape;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
1
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
export declare const getDatasource: (editorView: EditorView) => import("prosemirror-utils/dist/types").ContentNodeWithPos | {
|
|
3
|
+
node: import("../../types").DatasourceNode;
|
|
4
|
+
start: number;
|
|
5
|
+
depth: number;
|
|
6
|
+
pos: number;
|
|
7
|
+
} | {
|
|
3
8
|
node: undefined;
|
|
4
9
|
pos: undefined;
|
|
5
10
|
};
|
|
11
|
+
export declare const isDatasourceTableLayout: (layout: unknown) => layout is "full-width" | "center" | "wide";
|
|
@@ -2,7 +2,7 @@ import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
|
2
2
|
import type { Node, NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { CardContext } from '@atlaskit/link-provider';
|
|
5
|
-
import type { CardInfo } from './types';
|
|
5
|
+
import type { CardInfo, DatasourceNode } from './types';
|
|
6
6
|
export declare const appearanceForNodeType: (spec: NodeType) => CardAppearance | undefined;
|
|
7
7
|
export declare const selectedCardAppearance: (state: EditorState) => CardAppearance | undefined;
|
|
8
8
|
export type TitleUrlPair = {
|
|
@@ -22,3 +22,18 @@ export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, e
|
|
|
22
22
|
export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
|
|
23
23
|
export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext['store']) => {};
|
|
24
24
|
export declare const isDatasourceConfigEditable: (datasourceId: string) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Typeguard that checks node attributes are datasource node attributes
|
|
27
|
+
* ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
|
|
28
|
+
* this function will not be updated automatically
|
|
29
|
+
*/
|
|
30
|
+
export declare const isDatasourceAdfAttributes: (attrs: Record<string, unknown> | undefined) => attrs is {
|
|
31
|
+
url?: string | undefined;
|
|
32
|
+
datasource: import("@atlaskit/linking-common").Datasource<Record<string, unknown>>;
|
|
33
|
+
} & Partial<import("@atlaskit/adf-schema").RichMediaAttributes>;
|
|
34
|
+
/**
|
|
35
|
+
* Typeguard that checks a node is a datasource node (blockCard and has datasource attributes)
|
|
36
|
+
* ** WARNING ** Typeguards are not a guarantee, if the asserted type changes
|
|
37
|
+
* this function will not be updated automatically
|
|
38
|
+
*/
|
|
39
|
+
export declare const isDatasourceNode: (node?: Node) => node is DatasourceNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.3",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@atlaskit/linking-types": "^8.9.0",
|
|
56
56
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
57
57
|
"@atlaskit/primitives": "^6.3.0",
|
|
58
|
-
"@atlaskit/smart-card": "^26.
|
|
58
|
+
"@atlaskit/smart-card": "^26.71.0",
|
|
59
59
|
"@atlaskit/theme": "^12.8.0",
|
|
60
60
|
"@atlaskit/tokens": "^1.49.0",
|
|
61
61
|
"@babel/runtime": "^7.0.0",
|
|
@@ -131,6 +131,9 @@
|
|
|
131
131
|
},
|
|
132
132
|
"platform.linking-platform.smart-card.on-click-callback": {
|
|
133
133
|
"type": "boolean"
|
|
134
|
+
},
|
|
135
|
+
"platform.linking-platform.editor-datasource-typeguards": {
|
|
136
|
+
"type": "boolean"
|
|
134
137
|
}
|
|
135
138
|
},
|
|
136
139
|
"stricter": {
|