@atlaskit/editor-plugin-card 2.7.0 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/nodeviews/blockCard.js +2 -10
- package/dist/cjs/pm-plugins/doc.js +12 -28
- package/dist/cjs/pm-plugins/main.js +4 -10
- package/dist/cjs/toolbar.js +5 -5
- package/dist/cjs/ui/LayoutButton/index.js +3 -4
- package/dist/cjs/ui/LayoutButton/utils.js +6 -14
- package/dist/es2019/nodeviews/blockCard.js +2 -10
- package/dist/es2019/pm-plugins/doc.js +12 -28
- package/dist/es2019/pm-plugins/main.js +4 -10
- package/dist/es2019/toolbar.js +5 -5
- package/dist/es2019/ui/LayoutButton/index.js +3 -4
- package/dist/es2019/ui/LayoutButton/utils.js +5 -13
- package/dist/esm/nodeviews/blockCard.js +2 -10
- package/dist/esm/pm-plugins/doc.js +12 -28
- package/dist/esm/pm-plugins/main.js +4 -10
- package/dist/esm/toolbar.js +5 -5
- package/dist/esm/ui/LayoutButton/index.js +3 -4
- package/dist/esm/ui/LayoutButton/utils.js +6 -14
- package/dist/types/ui/LayoutButton/utils.d.ts +1 -1
- package/dist/types-ts4.5/ui/LayoutButton/utils.d.ts +1 -1
- package/package.json +4 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 2.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`338c00056aa27`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/338c00056aa27) -
|
|
8
|
+
Cleans up internal refactor (platform.linking-platform.editor-datasource-typeguards). No expected
|
|
9
|
+
functional changes.
|
|
10
|
+
|
|
3
11
|
## 2.7.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -172,16 +172,8 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
172
172
|
// If so, we return false so we can get the node to re-render properly as a datasource node instead.
|
|
173
173
|
// Otherwise, the node view will still consider the node as a blockCard and render a regular blockCard.
|
|
174
174
|
function validUpdate(currentNode, newNode) {
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
var _isCurrentNodeBlockCard = !(0, _utils2.isDatasourceNode)(currentNode);
|
|
178
|
-
var _isNewNodeDatasource = (0, _utils2.isDatasourceNode)(newNode);
|
|
179
|
-
|
|
180
|
-
// need to return falsy to update node
|
|
181
|
-
return !(_isCurrentNodeBlockCard && _isNewNodeDatasource);
|
|
182
|
-
}
|
|
183
|
-
var isCurrentNodeBlockCard = !((_currentNode$attrs = currentNode.attrs) !== null && _currentNode$attrs !== void 0 && _currentNode$attrs.datasource);
|
|
184
|
-
var isNewNodeDatasource = (_newNode$attrs = newNode.attrs) === null || _newNode$attrs === void 0 ? void 0 : _newNode$attrs.datasource;
|
|
175
|
+
var isCurrentNodeBlockCard = !(0, _utils2.isDatasourceNode)(currentNode);
|
|
176
|
+
var isNewNodeDatasource = (0, _utils2.isDatasourceNode)(newNode);
|
|
185
177
|
|
|
186
178
|
// need to return falsy to update node
|
|
187
179
|
return !(isCurrentNodeBlockCard && isNewNodeDatasource);
|
|
@@ -471,7 +471,9 @@ var updateCardViaDatasource = exports.updateCardViaDatasource = function updateC
|
|
|
471
471
|
if (isColumnChange || isUrlChange) {
|
|
472
472
|
tr.setNodeMarkup(from, schemaNodes.blockCard, _objectSpread(_objectSpread({}, oldAttrs), newAdf.attrs));
|
|
473
473
|
}
|
|
474
|
-
} else if (
|
|
474
|
+
} else if (
|
|
475
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
476
|
+
(0, _platformFeatureFlags.fg)('platform.linking-platform.enable-datasource-appearance-toolbar') && node.type.isText) {
|
|
475
477
|
// url to datasource
|
|
476
478
|
var link;
|
|
477
479
|
state.doc.nodesBetween(from, to, function (node, pos) {
|
|
@@ -543,38 +545,20 @@ var getAttrsForAppearance = exports.getAttrsForAppearance = function getAttrsFor
|
|
|
543
545
|
layout: 'center'
|
|
544
546
|
});
|
|
545
547
|
}
|
|
546
|
-
if ((0,
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
};
|
|
551
|
-
}
|
|
552
|
-
} else {
|
|
553
|
-
if (selectedNode.attrs.datasource) {
|
|
554
|
-
return {
|
|
555
|
-
url: selectedNode.attrs.url
|
|
556
|
-
};
|
|
557
|
-
}
|
|
548
|
+
if ((0, _utils2.isDatasourceNode)(selectedNode)) {
|
|
549
|
+
return {
|
|
550
|
+
url: selectedNode.attrs.url
|
|
551
|
+
};
|
|
558
552
|
}
|
|
559
553
|
return selectedNode.attrs;
|
|
560
554
|
};
|
|
561
555
|
var updateDatasourceStash = function updateDatasourceStash(tr, selectedNode) {
|
|
562
556
|
if ((0, _platformFeatureFlags.fg)('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
563
|
-
if ((0,
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
} else {
|
|
571
|
-
var _selectedNode$attrs;
|
|
572
|
-
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)) {
|
|
573
|
-
(0, _actions.setDatasourceStash)(tr, {
|
|
574
|
-
url: selectedNode.attrs.url,
|
|
575
|
-
views: selectedNode.attrs.datasource.views
|
|
576
|
-
});
|
|
577
|
-
}
|
|
557
|
+
if ((0, _utils2.isDatasourceNode)(selectedNode) && !(0, _utils2.isDatasourceConfigEditable)(selectedNode.attrs.datasource.id) && selectedNode.attrs.url) {
|
|
558
|
+
(0, _actions.setDatasourceStash)(tr, {
|
|
559
|
+
url: selectedNode.attrs.url,
|
|
560
|
+
views: selectedNode.attrs.datasource.views
|
|
561
|
+
});
|
|
578
562
|
}
|
|
579
563
|
}
|
|
580
564
|
};
|
|
@@ -192,13 +192,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
192
192
|
var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.datasource);
|
|
193
193
|
var shouldUpdateTableRef = datasourceTableRef && (currentState === null || currentState === void 0 ? void 0 : currentState.datasourceTableRef) !== datasourceTableRef;
|
|
194
194
|
if (isDatasource && shouldUpdateTableRef) {
|
|
195
|
-
var _node$attrs2;
|
|
196
|
-
var getLayout = function getLayout() {
|
|
197
|
-
return (0, _utils3.isDatasourceTableLayout)(node.attrs.layout) ? node.attrs.layout : _linkingCommon.DATASOURCE_DEFAULT_LAYOUT;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
195
|
// since we use the plugin state, which is a shared state, we need to update the datasourceTableRef, layout on each selection
|
|
201
|
-
var layout = (0,
|
|
196
|
+
var layout = (0, _utils3.isDatasourceTableLayout)(node.attrs.layout) ? node.attrs.layout : _linkingCommon.DATASOURCE_DEFAULT_LAYOUT;
|
|
202
197
|
var isNested = selection.$anchor.depth > 0;
|
|
203
198
|
|
|
204
199
|
// we want to disable resize button when datasource table is nested by not setting then datasourceTableRef on selection
|
|
@@ -261,7 +256,6 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
261
256
|
nodeViews: {
|
|
262
257
|
inlineCard: inlineCardViewProducer,
|
|
263
258
|
blockCard: function blockCard(node, view, getPos, decorations) {
|
|
264
|
-
var _node$attrs3;
|
|
265
259
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
266
260
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher;
|
|
267
261
|
var reactComponentProps = {
|
|
@@ -271,10 +265,10 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
271
265
|
pluginInjectionApi: pluginInjectionApi,
|
|
272
266
|
onClickCallback: options.onClickCallback
|
|
273
267
|
};
|
|
274
|
-
var isDatasource = (0,
|
|
268
|
+
var isDatasource = (0, _utils4.isDatasourceNode)(node);
|
|
275
269
|
if (isDatasource) {
|
|
276
|
-
var _node$
|
|
277
|
-
if (options.allowDatasource && platform !== 'mobile' && (0, _utils.canRenderDatasource)(node === null || node === void 0 || (_node$
|
|
270
|
+
var _node$attrs2;
|
|
271
|
+
if (options.allowDatasource && platform !== 'mobile' && (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)) {
|
|
278
272
|
var datasourcePosition = typeof getPos === 'function' && getPos();
|
|
279
273
|
var datasourceResolvedPosition = datasourcePosition && view.state.doc.resolve(datasourcePosition);
|
|
280
274
|
var isNodeNested = !!(datasourceResolvedPosition && datasourceResolvedPosition.depth > 0);
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -188,7 +188,7 @@ var getToolbarViewedItem = function getToolbarViewedItem(url, display) {
|
|
|
188
188
|
};
|
|
189
189
|
var generateToolbarItems = function generateToolbarItems(state, intl, providerFactory, cardOptions, lpLinkPicker, platform, linkPicker, pluginInjectionApi) {
|
|
190
190
|
return function (node) {
|
|
191
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _node$attrs
|
|
191
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _node$attrs;
|
|
192
192
|
var _titleUrlPairFromNode2 = (0, _utils3.titleUrlPairFromNode)(node),
|
|
193
193
|
url = _titleUrlPairFromNode2.url;
|
|
194
194
|
var _ref = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
|
|
@@ -208,10 +208,10 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
208
208
|
var currentAppearance = (0, _utils3.appearanceForNodeType)(node.type);
|
|
209
209
|
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 : {},
|
|
210
210
|
hoverDecoration = _ref2.hoverDecoration;
|
|
211
|
-
var isDatasource = (0,
|
|
211
|
+
var isDatasource = (0, _utils3.isDatasourceNode)(node);
|
|
212
212
|
var shouldRenderDatasourceToolbar = isDatasource &&
|
|
213
213
|
// not showing toolbar in mobile for now since not sure what our plans are for it
|
|
214
|
-
platform !== 'mobile' && cardOptions.allowDatasource && (0, _utils.canRenderDatasource)(node === null || node === void 0 || (_node$
|
|
214
|
+
platform !== 'mobile' && cardOptions.allowDatasource && (0, _utils.canRenderDatasource)(node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 || (_node$attrs = _node$attrs.datasource) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id);
|
|
215
215
|
|
|
216
216
|
/* mobile builds toolbar natively using toolbarItems */
|
|
217
217
|
if (pluginState !== null && pluginState !== void 0 && pluginState.showLinkingToolbar && platform !== 'mobile') {
|
|
@@ -397,7 +397,7 @@ var getSettingsButtonGroup = exports.getSettingsButtonGroup = function getSettin
|
|
|
397
397
|
}];
|
|
398
398
|
};
|
|
399
399
|
var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform) {
|
|
400
|
-
var _node$
|
|
400
|
+
var _node$attrs2;
|
|
401
401
|
var toolbarItems = [];
|
|
402
402
|
if ((0, _utils3.isDatasourceConfigEditable)(datasourceId) && !(0, _platformFeatureFlags.fg)('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
|
|
403
403
|
toolbarItems.push({
|
|
@@ -488,7 +488,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
488
488
|
}
|
|
489
489
|
});
|
|
490
490
|
}
|
|
491
|
-
if (node !== null && node !== void 0 && (_node$
|
|
491
|
+
if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
|
|
492
492
|
toolbarItems.push({
|
|
493
493
|
id: 'editor.link.openLink',
|
|
494
494
|
type: 'button',
|
|
@@ -16,7 +16,6 @@ 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");
|
|
20
19
|
var _colors = require("@atlaskit/theme/colors");
|
|
21
20
|
var _actions = require("../../pm-plugins/actions");
|
|
22
21
|
var _utils2 = require("../../utils");
|
|
@@ -79,7 +78,7 @@ var LayoutButton = exports.LayoutButton = function LayoutButton(_ref) {
|
|
|
79
78
|
}));
|
|
80
79
|
};
|
|
81
80
|
var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
82
|
-
var _node$attrs
|
|
81
|
+
var _node$attrs;
|
|
83
82
|
var editorView = _ref2.editorView,
|
|
84
83
|
mountPoint = _ref2.mountPoint,
|
|
85
84
|
scrollableElement = _ref2.scrollableElement,
|
|
@@ -91,7 +90,7 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
|
91
90
|
var _getDatasource = (0, _utils3.getDatasource)(editorView),
|
|
92
91
|
node = _getDatasource.node,
|
|
93
92
|
pos = _getDatasource.pos;
|
|
94
|
-
var isDatasource = (0,
|
|
93
|
+
var isDatasource = (0, _utils2.isDatasourceNode)(node);
|
|
95
94
|
if (!isDatasource) {
|
|
96
95
|
return null;
|
|
97
96
|
}
|
|
@@ -101,7 +100,7 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
|
101
100
|
var _ref3 = cardState !== null && cardState !== void 0 ? cardState : {},
|
|
102
101
|
datasourceTableRef = _ref3.datasourceTableRef,
|
|
103
102
|
_ref3$layout = _ref3.layout,
|
|
104
|
-
layout = _ref3$layout === void 0 ? (node === null || node === void 0 || (_node$
|
|
103
|
+
layout = _ref3$layout === void 0 ? (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) || undefined : _ref3$layout;
|
|
105
104
|
var onLayoutChange = function onLayoutChange(layout) {
|
|
106
105
|
var _getDatasource$node;
|
|
107
106
|
if (pos === undefined) {
|
|
@@ -7,30 +7,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.isDatasourceTableLayout = exports.getDatasource = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
10
|
var _utils2 = require("../../utils");
|
|
12
11
|
var _types = require("./types");
|
|
13
12
|
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
13
|
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; }
|
|
15
14
|
var getDatasource = exports.getDatasource = function getDatasource(editorView) {
|
|
16
|
-
var _findSelectedNodeOfTy;
|
|
17
15
|
var _editorView$state = editorView.state,
|
|
18
16
|
selection = _editorView$state.selection,
|
|
19
17
|
schema = _editorView$state.schema;
|
|
20
18
|
var blockCard = schema.nodes.blockCard;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
node: undefined,
|
|
30
|
-
pos: undefined
|
|
31
|
-
};
|
|
19
|
+
var findResult = (0, _utils.findSelectedNodeOfType)([blockCard])(selection);
|
|
20
|
+
if (findResult && (0, _utils2.isDatasourceNode)(findResult.node)) {
|
|
21
|
+
return _objectSpread(_objectSpread({}, findResult), {}, {
|
|
22
|
+
node: findResult.node
|
|
23
|
+
});
|
|
32
24
|
}
|
|
33
|
-
return
|
|
25
|
+
return {
|
|
34
26
|
node: undefined,
|
|
35
27
|
pos: undefined
|
|
36
28
|
};
|
|
@@ -136,16 +136,8 @@ export class BlockCard extends ReactNodeView {
|
|
|
136
136
|
// If so, we return false so we can get the node to re-render properly as a datasource node instead.
|
|
137
137
|
// Otherwise, the node view will still consider the node as a blockCard and render a regular blockCard.
|
|
138
138
|
validUpdate(currentNode, newNode) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const isCurrentNodeBlockCard = !isDatasourceNode(currentNode);
|
|
142
|
-
const isNewNodeDatasource = isDatasourceNode(newNode);
|
|
143
|
-
|
|
144
|
-
// need to return falsy to update node
|
|
145
|
-
return !(isCurrentNodeBlockCard && isNewNodeDatasource);
|
|
146
|
-
}
|
|
147
|
-
const isCurrentNodeBlockCard = !((_currentNode$attrs = currentNode.attrs) !== null && _currentNode$attrs !== void 0 && _currentNode$attrs.datasource);
|
|
148
|
-
const isNewNodeDatasource = (_newNode$attrs = newNode.attrs) === null || _newNode$attrs === void 0 ? void 0 : _newNode$attrs.datasource;
|
|
139
|
+
const isCurrentNodeBlockCard = !isDatasourceNode(currentNode);
|
|
140
|
+
const isNewNodeDatasource = isDatasourceNode(newNode);
|
|
149
141
|
|
|
150
142
|
// need to return falsy to update node
|
|
151
143
|
return !(isCurrentNodeBlockCard && isNewNodeDatasource);
|
|
@@ -452,7 +452,9 @@ export const updateCardViaDatasource = args => {
|
|
|
452
452
|
...newAdf.attrs
|
|
453
453
|
});
|
|
454
454
|
}
|
|
455
|
-
} else if (
|
|
455
|
+
} else if (
|
|
456
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
457
|
+
fg('platform.linking-platform.enable-datasource-appearance-toolbar') && node.type.isText) {
|
|
456
458
|
// url to datasource
|
|
457
459
|
let link;
|
|
458
460
|
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
@@ -531,38 +533,20 @@ export const getAttrsForAppearance = (appearance, selectedNode) => {
|
|
|
531
533
|
layout: 'center'
|
|
532
534
|
};
|
|
533
535
|
}
|
|
534
|
-
if (
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
};
|
|
539
|
-
}
|
|
540
|
-
} else {
|
|
541
|
-
if (selectedNode.attrs.datasource) {
|
|
542
|
-
return {
|
|
543
|
-
url: selectedNode.attrs.url
|
|
544
|
-
};
|
|
545
|
-
}
|
|
536
|
+
if (isDatasourceNode(selectedNode)) {
|
|
537
|
+
return {
|
|
538
|
+
url: selectedNode.attrs.url
|
|
539
|
+
};
|
|
546
540
|
}
|
|
547
541
|
return selectedNode.attrs;
|
|
548
542
|
};
|
|
549
543
|
const updateDatasourceStash = (tr, selectedNode) => {
|
|
550
544
|
if (fg('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
551
|
-
if (
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
} else {
|
|
559
|
-
var _selectedNode$attrs;
|
|
560
|
-
if (selectedNode !== null && selectedNode !== void 0 && (_selectedNode$attrs = selectedNode.attrs) !== null && _selectedNode$attrs !== void 0 && _selectedNode$attrs.datasource && !isDatasourceConfigEditable(selectedNode.attrs.datasource.id)) {
|
|
561
|
-
setDatasourceStash(tr, {
|
|
562
|
-
url: selectedNode.attrs.url,
|
|
563
|
-
views: selectedNode.attrs.datasource.views
|
|
564
|
-
});
|
|
565
|
-
}
|
|
545
|
+
if (isDatasourceNode(selectedNode) && !isDatasourceConfigEditable(selectedNode.attrs.datasource.id) && selectedNode.attrs.url) {
|
|
546
|
+
setDatasourceStash(tr, {
|
|
547
|
+
url: selectedNode.attrs.url,
|
|
548
|
+
views: selectedNode.attrs.datasource.views
|
|
549
|
+
});
|
|
566
550
|
}
|
|
567
551
|
}
|
|
568
552
|
};
|
|
@@ -183,13 +183,8 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
183
183
|
const isDatasource = !!(node !== null && node !== void 0 && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.datasource);
|
|
184
184
|
const shouldUpdateTableRef = datasourceTableRef && (currentState === null || currentState === void 0 ? void 0 : currentState.datasourceTableRef) !== datasourceTableRef;
|
|
185
185
|
if (isDatasource && shouldUpdateTableRef) {
|
|
186
|
-
var _node$attrs2;
|
|
187
|
-
const getLayout = () => {
|
|
188
|
-
return isDatasourceTableLayout(node.attrs.layout) ? node.attrs.layout : DATASOURCE_DEFAULT_LAYOUT;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
186
|
// since we use the plugin state, which is a shared state, we need to update the datasourceTableRef, layout on each selection
|
|
192
|
-
const layout =
|
|
187
|
+
const layout = isDatasourceTableLayout(node.attrs.layout) ? node.attrs.layout : DATASOURCE_DEFAULT_LAYOUT;
|
|
193
188
|
const isNested = selection.$anchor.depth > 0;
|
|
194
189
|
|
|
195
190
|
// we want to disable resize button when datasource table is nested by not setting then datasourceTableRef on selection
|
|
@@ -252,7 +247,6 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
252
247
|
nodeViews: {
|
|
253
248
|
inlineCard: inlineCardViewProducer,
|
|
254
249
|
blockCard: (node, view, getPos, decorations) => {
|
|
255
|
-
var _node$attrs3;
|
|
256
250
|
const {
|
|
257
251
|
portalProviderAPI,
|
|
258
252
|
eventDispatcher
|
|
@@ -264,10 +258,10 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
264
258
|
pluginInjectionApi,
|
|
265
259
|
onClickCallback: options.onClickCallback
|
|
266
260
|
};
|
|
267
|
-
const isDatasource =
|
|
261
|
+
const isDatasource = isDatasourceNode(node);
|
|
268
262
|
if (isDatasource) {
|
|
269
|
-
var _node$
|
|
270
|
-
if (options.allowDatasource && platform !== 'mobile' && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$
|
|
263
|
+
var _node$attrs2, _node$attrs2$datasour;
|
|
264
|
+
if (options.allowDatasource && platform !== 'mobile' && 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)) {
|
|
271
265
|
const datasourcePosition = typeof getPos === 'function' && getPos();
|
|
272
266
|
const datasourceResolvedPosition = datasourcePosition && view.state.doc.resolve(datasourcePosition);
|
|
273
267
|
const isNodeNested = !!(datasourceResolvedPosition && datasourceResolvedPosition.depth > 0);
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -176,7 +176,7 @@ const getToolbarViewedItem = (url, display) => {
|
|
|
176
176
|
}];
|
|
177
177
|
};
|
|
178
178
|
const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkPicker, platform, linkPicker, pluginInjectionApi) => node => {
|
|
179
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _node$attrs, _node$
|
|
179
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _node$attrs, _node$attrs$datasourc;
|
|
180
180
|
const {
|
|
181
181
|
url
|
|
182
182
|
} = titleUrlPairFromNode(node);
|
|
@@ -200,10 +200,10 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
200
200
|
const {
|
|
201
201
|
hoverDecoration
|
|
202
202
|
} = (_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 : {};
|
|
203
|
-
const isDatasource =
|
|
203
|
+
const isDatasource = isDatasourceNode(node);
|
|
204
204
|
const shouldRenderDatasourceToolbar = isDatasource &&
|
|
205
205
|
// not showing toolbar in mobile for now since not sure what our plans are for it
|
|
206
|
-
platform !== 'mobile' && cardOptions.allowDatasource && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$
|
|
206
|
+
platform !== 'mobile' && cardOptions.allowDatasource && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : (_node$attrs$datasourc = _node$attrs.datasource) === null || _node$attrs$datasourc === void 0 ? void 0 : _node$attrs$datasourc.id);
|
|
207
207
|
|
|
208
208
|
/* mobile builds toolbar natively using toolbarItems */
|
|
209
209
|
if (pluginState !== null && pluginState !== void 0 && pluginState.showLinkingToolbar && platform !== 'mobile') {
|
|
@@ -384,7 +384,7 @@ export const getSettingsButtonGroup = (intl, editorAnalyticsApi, userPreferences
|
|
|
384
384
|
}];
|
|
385
385
|
};
|
|
386
386
|
const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform) => {
|
|
387
|
-
var _node$
|
|
387
|
+
var _node$attrs2;
|
|
388
388
|
const toolbarItems = [];
|
|
389
389
|
if (isDatasourceConfigEditable(datasourceId) && !fg('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
|
|
390
390
|
toolbarItems.push({
|
|
@@ -475,7 +475,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
|
|
|
475
475
|
})
|
|
476
476
|
});
|
|
477
477
|
}
|
|
478
|
-
if (node !== null && node !== void 0 && (_node$
|
|
478
|
+
if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
|
|
479
479
|
toolbarItems.push({
|
|
480
480
|
id: 'editor.link.openLink',
|
|
481
481
|
type: 'button',
|
|
@@ -14,7 +14,6 @@ import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
|
|
|
14
14
|
import CollapseIcon from '@atlaskit/icon/glyph/editor/collapse';
|
|
15
15
|
import ExpandIcon from '@atlaskit/icon/glyph/editor/expand';
|
|
16
16
|
import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
|
|
17
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
18
17
|
import { B300, N20A, N300 } from '@atlaskit/theme/colors';
|
|
19
18
|
import { setCardLayout } from '../../pm-plugins/actions';
|
|
20
19
|
import { isDatasourceNode } from '../../utils';
|
|
@@ -80,7 +79,7 @@ const LayoutButtonWrapper = ({
|
|
|
80
79
|
intl,
|
|
81
80
|
api
|
|
82
81
|
}) => {
|
|
83
|
-
var _node$attrs
|
|
82
|
+
var _node$attrs;
|
|
84
83
|
const {
|
|
85
84
|
cardState
|
|
86
85
|
} = useSharedPluginState(api, ['card']);
|
|
@@ -88,7 +87,7 @@ const LayoutButtonWrapper = ({
|
|
|
88
87
|
node,
|
|
89
88
|
pos
|
|
90
89
|
} = getDatasource(editorView);
|
|
91
|
-
const isDatasource =
|
|
90
|
+
const isDatasource = isDatasourceNode(node);
|
|
92
91
|
if (!isDatasource) {
|
|
93
92
|
return null;
|
|
94
93
|
}
|
|
@@ -97,7 +96,7 @@ const LayoutButtonWrapper = ({
|
|
|
97
96
|
// which results in default parameter value being used in LayoutButton.
|
|
98
97
|
const {
|
|
99
98
|
datasourceTableRef,
|
|
100
|
-
layout = (node === null || node === void 0 ? void 0 : (_node$
|
|
99
|
+
layout = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) || undefined
|
|
101
100
|
} = cardState !== null && cardState !== void 0 ? cardState : {};
|
|
102
101
|
const onLayoutChange = layout => {
|
|
103
102
|
var _getDatasource$node;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { isDatasourceNode } from '../../utils';
|
|
4
3
|
import { DATASOURCE_TABLE_LAYOUTS } from './types';
|
|
5
4
|
export const getDatasource = editorView => {
|
|
6
|
-
var _findSelectedNodeOfTy;
|
|
7
5
|
const {
|
|
8
6
|
selection,
|
|
9
7
|
schema
|
|
@@ -11,20 +9,14 @@ export const getDatasource = editorView => {
|
|
|
11
9
|
const {
|
|
12
10
|
blockCard
|
|
13
11
|
} = schema.nodes;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (findResult && isDatasourceNode(findResult.node)) {
|
|
17
|
-
return {
|
|
18
|
-
...findResult,
|
|
19
|
-
node: findResult.node
|
|
20
|
-
};
|
|
21
|
-
}
|
|
12
|
+
const findResult = findSelectedNodeOfType([blockCard])(selection);
|
|
13
|
+
if (findResult && isDatasourceNode(findResult.node)) {
|
|
22
14
|
return {
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
...findResult,
|
|
16
|
+
node: findResult.node
|
|
25
17
|
};
|
|
26
18
|
}
|
|
27
|
-
return
|
|
19
|
+
return {
|
|
28
20
|
node: undefined,
|
|
29
21
|
pos: undefined
|
|
30
22
|
};
|
|
@@ -166,16 +166,8 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
166
166
|
// If so, we return false so we can get the node to re-render properly as a datasource node instead.
|
|
167
167
|
// Otherwise, the node view will still consider the node as a blockCard and render a regular blockCard.
|
|
168
168
|
function validUpdate(currentNode, newNode) {
|
|
169
|
-
var
|
|
170
|
-
|
|
171
|
-
var _isCurrentNodeBlockCard = !isDatasourceNode(currentNode);
|
|
172
|
-
var _isNewNodeDatasource = isDatasourceNode(newNode);
|
|
173
|
-
|
|
174
|
-
// need to return falsy to update node
|
|
175
|
-
return !(_isCurrentNodeBlockCard && _isNewNodeDatasource);
|
|
176
|
-
}
|
|
177
|
-
var isCurrentNodeBlockCard = !((_currentNode$attrs = currentNode.attrs) !== null && _currentNode$attrs !== void 0 && _currentNode$attrs.datasource);
|
|
178
|
-
var isNewNodeDatasource = (_newNode$attrs = newNode.attrs) === null || _newNode$attrs === void 0 ? void 0 : _newNode$attrs.datasource;
|
|
169
|
+
var isCurrentNodeBlockCard = !isDatasourceNode(currentNode);
|
|
170
|
+
var isNewNodeDatasource = isDatasourceNode(newNode);
|
|
179
171
|
|
|
180
172
|
// need to return falsy to update node
|
|
181
173
|
return !(isCurrentNodeBlockCard && isNewNodeDatasource);
|
|
@@ -465,7 +465,9 @@ export var updateCardViaDatasource = function updateCardViaDatasource(args) {
|
|
|
465
465
|
if (isColumnChange || isUrlChange) {
|
|
466
466
|
tr.setNodeMarkup(from, schemaNodes.blockCard, _objectSpread(_objectSpread({}, oldAttrs), newAdf.attrs));
|
|
467
467
|
}
|
|
468
|
-
} else if (
|
|
468
|
+
} else if (
|
|
469
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
470
|
+
fg('platform.linking-platform.enable-datasource-appearance-toolbar') && node.type.isText) {
|
|
469
471
|
// url to datasource
|
|
470
472
|
var link;
|
|
471
473
|
state.doc.nodesBetween(from, to, function (node, pos) {
|
|
@@ -537,38 +539,20 @@ export var getAttrsForAppearance = function getAttrsForAppearance(appearance, se
|
|
|
537
539
|
layout: 'center'
|
|
538
540
|
});
|
|
539
541
|
}
|
|
540
|
-
if (
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
} else {
|
|
547
|
-
if (selectedNode.attrs.datasource) {
|
|
548
|
-
return {
|
|
549
|
-
url: selectedNode.attrs.url
|
|
550
|
-
};
|
|
551
|
-
}
|
|
542
|
+
if (isDatasourceNode(selectedNode)) {
|
|
543
|
+
return {
|
|
544
|
+
url: selectedNode.attrs.url
|
|
545
|
+
};
|
|
552
546
|
}
|
|
553
547
|
return selectedNode.attrs;
|
|
554
548
|
};
|
|
555
549
|
var updateDatasourceStash = function updateDatasourceStash(tr, selectedNode) {
|
|
556
550
|
if (fg('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
557
|
-
if (
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
} else {
|
|
565
|
-
var _selectedNode$attrs;
|
|
566
|
-
if (selectedNode !== null && selectedNode !== void 0 && (_selectedNode$attrs = selectedNode.attrs) !== null && _selectedNode$attrs !== void 0 && _selectedNode$attrs.datasource && !isDatasourceConfigEditable(selectedNode.attrs.datasource.id)) {
|
|
567
|
-
setDatasourceStash(tr, {
|
|
568
|
-
url: selectedNode.attrs.url,
|
|
569
|
-
views: selectedNode.attrs.datasource.views
|
|
570
|
-
});
|
|
571
|
-
}
|
|
551
|
+
if (isDatasourceNode(selectedNode) && !isDatasourceConfigEditable(selectedNode.attrs.datasource.id) && selectedNode.attrs.url) {
|
|
552
|
+
setDatasourceStash(tr, {
|
|
553
|
+
url: selectedNode.attrs.url,
|
|
554
|
+
views: selectedNode.attrs.datasource.views
|
|
555
|
+
});
|
|
572
556
|
}
|
|
573
557
|
}
|
|
574
558
|
};
|
|
@@ -179,13 +179,8 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
179
179
|
var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.datasource);
|
|
180
180
|
var shouldUpdateTableRef = datasourceTableRef && (currentState === null || currentState === void 0 ? void 0 : currentState.datasourceTableRef) !== datasourceTableRef;
|
|
181
181
|
if (isDatasource && shouldUpdateTableRef) {
|
|
182
|
-
var _node$attrs2;
|
|
183
|
-
var getLayout = function getLayout() {
|
|
184
|
-
return isDatasourceTableLayout(node.attrs.layout) ? node.attrs.layout : DATASOURCE_DEFAULT_LAYOUT;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
182
|
// since we use the plugin state, which is a shared state, we need to update the datasourceTableRef, layout on each selection
|
|
188
|
-
var layout =
|
|
183
|
+
var layout = isDatasourceTableLayout(node.attrs.layout) ? node.attrs.layout : DATASOURCE_DEFAULT_LAYOUT;
|
|
189
184
|
var isNested = selection.$anchor.depth > 0;
|
|
190
185
|
|
|
191
186
|
// we want to disable resize button when datasource table is nested by not setting then datasourceTableRef on selection
|
|
@@ -248,7 +243,6 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
248
243
|
nodeViews: {
|
|
249
244
|
inlineCard: inlineCardViewProducer,
|
|
250
245
|
blockCard: function blockCard(node, view, getPos, decorations) {
|
|
251
|
-
var _node$attrs3;
|
|
252
246
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
253
247
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher;
|
|
254
248
|
var reactComponentProps = {
|
|
@@ -258,10 +252,10 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
258
252
|
pluginInjectionApi: pluginInjectionApi,
|
|
259
253
|
onClickCallback: options.onClickCallback
|
|
260
254
|
};
|
|
261
|
-
var isDatasource =
|
|
255
|
+
var isDatasource = isDatasourceNode(node);
|
|
262
256
|
if (isDatasource) {
|
|
263
|
-
var _node$
|
|
264
|
-
if (options.allowDatasource && platform !== 'mobile' && canRenderDatasource(node === null || node === void 0 || (_node$
|
|
257
|
+
var _node$attrs2;
|
|
258
|
+
if (options.allowDatasource && platform !== 'mobile' && 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)) {
|
|
265
259
|
var datasourcePosition = typeof getPos === 'function' && getPos();
|
|
266
260
|
var datasourceResolvedPosition = datasourcePosition && view.state.doc.resolve(datasourcePosition);
|
|
267
261
|
var isNodeNested = !!(datasourceResolvedPosition && datasourceResolvedPosition.depth > 0);
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -178,7 +178,7 @@ var getToolbarViewedItem = function getToolbarViewedItem(url, display) {
|
|
|
178
178
|
};
|
|
179
179
|
var generateToolbarItems = function generateToolbarItems(state, intl, providerFactory, cardOptions, lpLinkPicker, platform, linkPicker, pluginInjectionApi) {
|
|
180
180
|
return function (node) {
|
|
181
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _node$attrs
|
|
181
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _node$attrs;
|
|
182
182
|
var _titleUrlPairFromNode2 = titleUrlPairFromNode(node),
|
|
183
183
|
url = _titleUrlPairFromNode2.url;
|
|
184
184
|
var _ref = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
|
|
@@ -198,10 +198,10 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
198
198
|
var currentAppearance = appearanceForNodeType(node.type);
|
|
199
199
|
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 : {},
|
|
200
200
|
hoverDecoration = _ref2.hoverDecoration;
|
|
201
|
-
var isDatasource =
|
|
201
|
+
var isDatasource = isDatasourceNode(node);
|
|
202
202
|
var shouldRenderDatasourceToolbar = isDatasource &&
|
|
203
203
|
// not showing toolbar in mobile for now since not sure what our plans are for it
|
|
204
|
-
platform !== 'mobile' && cardOptions.allowDatasource && canRenderDatasource(node === null || node === void 0 || (_node$
|
|
204
|
+
platform !== 'mobile' && cardOptions.allowDatasource && canRenderDatasource(node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 || (_node$attrs = _node$attrs.datasource) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id);
|
|
205
205
|
|
|
206
206
|
/* mobile builds toolbar natively using toolbarItems */
|
|
207
207
|
if (pluginState !== null && pluginState !== void 0 && pluginState.showLinkingToolbar && platform !== 'mobile') {
|
|
@@ -387,7 +387,7 @@ export var getSettingsButtonGroup = function getSettingsButtonGroup(intl, editor
|
|
|
387
387
|
}];
|
|
388
388
|
};
|
|
389
389
|
var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance, platform) {
|
|
390
|
-
var _node$
|
|
390
|
+
var _node$attrs2;
|
|
391
391
|
var toolbarItems = [];
|
|
392
392
|
if (isDatasourceConfigEditable(datasourceId) && !fg('platform.linking-platform.enable-datasource-edit-dropdown-toolbar')) {
|
|
393
393
|
toolbarItems.push({
|
|
@@ -478,7 +478,7 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
478
478
|
}
|
|
479
479
|
});
|
|
480
480
|
}
|
|
481
|
-
if (node !== null && node !== void 0 && (_node$
|
|
481
|
+
if (node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.url) {
|
|
482
482
|
toolbarItems.push({
|
|
483
483
|
id: 'editor.link.openLink',
|
|
484
484
|
type: 'button',
|
|
@@ -17,7 +17,6 @@ import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
|
|
|
17
17
|
import CollapseIcon from '@atlaskit/icon/glyph/editor/collapse';
|
|
18
18
|
import ExpandIcon from '@atlaskit/icon/glyph/editor/expand';
|
|
19
19
|
import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common';
|
|
20
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
21
20
|
import { B300, N20A, N300 } from '@atlaskit/theme/colors';
|
|
22
21
|
import { setCardLayout } from '../../pm-plugins/actions';
|
|
23
22
|
import { isDatasourceNode } from '../../utils';
|
|
@@ -75,7 +74,7 @@ export var LayoutButton = function LayoutButton(_ref) {
|
|
|
75
74
|
}));
|
|
76
75
|
};
|
|
77
76
|
var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
78
|
-
var _node$attrs
|
|
77
|
+
var _node$attrs;
|
|
79
78
|
var editorView = _ref2.editorView,
|
|
80
79
|
mountPoint = _ref2.mountPoint,
|
|
81
80
|
scrollableElement = _ref2.scrollableElement,
|
|
@@ -87,7 +86,7 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
|
87
86
|
var _getDatasource = getDatasource(editorView),
|
|
88
87
|
node = _getDatasource.node,
|
|
89
88
|
pos = _getDatasource.pos;
|
|
90
|
-
var isDatasource =
|
|
89
|
+
var isDatasource = isDatasourceNode(node);
|
|
91
90
|
if (!isDatasource) {
|
|
92
91
|
return null;
|
|
93
92
|
}
|
|
@@ -97,7 +96,7 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
|
97
96
|
var _ref3 = cardState !== null && cardState !== void 0 ? cardState : {},
|
|
98
97
|
datasourceTableRef = _ref3.datasourceTableRef,
|
|
99
98
|
_ref3$layout = _ref3.layout,
|
|
100
|
-
layout = _ref3$layout === void 0 ? (node === null || node === void 0 || (_node$
|
|
99
|
+
layout = _ref3$layout === void 0 ? (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) || undefined : _ref3$layout;
|
|
101
100
|
var onLayoutChange = function onLayoutChange(layout) {
|
|
102
101
|
var _getDatasource$node;
|
|
103
102
|
if (pos === undefined) {
|
|
@@ -2,28 +2,20 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
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
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; }
|
|
4
4
|
import { findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { isDatasourceNode } from '../../utils';
|
|
7
6
|
import { DATASOURCE_TABLE_LAYOUTS } from './types';
|
|
8
7
|
export var getDatasource = function getDatasource(editorView) {
|
|
9
|
-
var _findSelectedNodeOfTy;
|
|
10
8
|
var _editorView$state = editorView.state,
|
|
11
9
|
selection = _editorView$state.selection,
|
|
12
10
|
schema = _editorView$state.schema;
|
|
13
11
|
var blockCard = schema.nodes.blockCard;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
node: undefined,
|
|
23
|
-
pos: undefined
|
|
24
|
-
};
|
|
12
|
+
var findResult = findSelectedNodeOfType([blockCard])(selection);
|
|
13
|
+
if (findResult && isDatasourceNode(findResult.node)) {
|
|
14
|
+
return _objectSpread(_objectSpread({}, findResult), {}, {
|
|
15
|
+
node: findResult.node
|
|
16
|
+
});
|
|
25
17
|
}
|
|
26
|
-
return
|
|
18
|
+
return {
|
|
27
19
|
node: undefined,
|
|
28
20
|
pos: undefined
|
|
29
21
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
export declare const getDatasource: (editorView: EditorView) =>
|
|
2
|
+
export declare const getDatasource: (editorView: EditorView) => {
|
|
3
3
|
node: import("../../types").DatasourceNode;
|
|
4
4
|
start: number;
|
|
5
5
|
depth: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
export declare const getDatasource: (editorView: EditorView) =>
|
|
2
|
+
export declare const getDatasource: (editorView: EditorView) => {
|
|
3
3
|
node: import("../../types").DatasourceNode;
|
|
4
4
|
start: number;
|
|
5
5
|
depth: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"@atlaskit/icon": "^22.7.0",
|
|
51
51
|
"@atlaskit/link-analytics": "^8.3.0",
|
|
52
52
|
"@atlaskit/link-client-extension": "^1.10.0",
|
|
53
|
-
"@atlaskit/link-datasource": "^2.
|
|
53
|
+
"@atlaskit/link-datasource": "^2.7.0",
|
|
54
54
|
"@atlaskit/linking-common": "^5.7.0",
|
|
55
55
|
"@atlaskit/linking-types": "^8.12.0",
|
|
56
56
|
"@atlaskit/menu": "2.8.1",
|
|
57
57
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
58
|
-
"@atlaskit/primitives": "^11.
|
|
59
|
-
"@atlaskit/smart-card": "^27.
|
|
58
|
+
"@atlaskit/primitives": "^11.1.0",
|
|
59
|
+
"@atlaskit/smart-card": "^27.11.0",
|
|
60
60
|
"@atlaskit/theme": "^12.11.0",
|
|
61
61
|
"@atlaskit/tokens": "^1.56.0",
|
|
62
62
|
"@babel/runtime": "^7.0.0",
|
|
@@ -131,9 +131,6 @@
|
|
|
131
131
|
"platform.editor.card.inject-settings-button": {
|
|
132
132
|
"type": "boolean"
|
|
133
133
|
},
|
|
134
|
-
"platform.linking-platform.editor-datasource-typeguards": {
|
|
135
|
-
"type": "boolean"
|
|
136
|
-
},
|
|
137
134
|
"platform_editor_get_card_provider_from_config": {
|
|
138
135
|
"type": "boolean"
|
|
139
136
|
},
|