@atlaskit/editor-plugin-card 1.1.0 → 1.1.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 +7 -0
- package/dist/cjs/pm-plugins/doc.js +25 -1
- package/dist/cjs/ui/DatasourceAppearanceButton.js +19 -1
- package/dist/cjs/ui/DatasourceModal/index.js +28 -10
- package/dist/cjs/ui/HyperlinkToolbarAppearance.js +8 -0
- package/dist/es2019/pm-plugins/doc.js +22 -1
- package/dist/es2019/ui/DatasourceAppearanceButton.js +17 -1
- package/dist/es2019/ui/DatasourceModal/index.js +26 -10
- package/dist/es2019/ui/HyperlinkToolbarAppearance.js +8 -0
- package/dist/esm/pm-plugins/doc.js +25 -1
- package/dist/esm/ui/DatasourceAppearanceButton.js +19 -1
- package/dist/esm/ui/DatasourceModal/index.js +28 -10
- package/dist/esm/ui/HyperlinkToolbarAppearance.js +8 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#76864](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/76864) [`7ef524e422c3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7ef524e422c3) - Fixes switching card view from inline to Datasources
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 1.1.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
|
@@ -434,7 +434,9 @@ var getLinkNodeType = exports.getLinkNodeType = function getLinkNodeType(appeara
|
|
|
434
434
|
// Apply an update made from a datasource ui interaction
|
|
435
435
|
var updateCardViaDatasource = exports.updateCardViaDatasource = function updateCardViaDatasource(state, node, newAdf, view, sourceEvent, isDeletingConfig) {
|
|
436
436
|
var tr = state.tr,
|
|
437
|
-
|
|
437
|
+
_state$selection2 = state.selection,
|
|
438
|
+
from = _state$selection2.from,
|
|
439
|
+
to = _state$selection2.to,
|
|
438
440
|
schemaNodes = state.schema.nodes;
|
|
439
441
|
if (newAdf.type === 'blockCard') {
|
|
440
442
|
var _node$attrs, _newAdf$attrs;
|
|
@@ -458,6 +460,28 @@ var updateCardViaDatasource = exports.updateCardViaDatasource = function updateC
|
|
|
458
460
|
if (isColumnChange || isUrlChange) {
|
|
459
461
|
tr.setNodeMarkup(from, schemaNodes.blockCard, _objectSpread(_objectSpread({}, node.attrs), newAdf.attrs));
|
|
460
462
|
}
|
|
463
|
+
} else if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar') && node.type.isText) {
|
|
464
|
+
// url to datasource
|
|
465
|
+
var link;
|
|
466
|
+
state.doc.nodesBetween(from, to, function (node, pos) {
|
|
467
|
+
// get the actual start position of a link within the node
|
|
468
|
+
var linkMark = node.marks.find(function (mark) {
|
|
469
|
+
return mark.type === state.schema.marks.link;
|
|
470
|
+
});
|
|
471
|
+
if (linkMark) {
|
|
472
|
+
link = {
|
|
473
|
+
url: linkMark.attrs.href,
|
|
474
|
+
text: node.text,
|
|
475
|
+
pos: pos
|
|
476
|
+
};
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
479
|
+
return true;
|
|
480
|
+
});
|
|
481
|
+
if (link) {
|
|
482
|
+
var newNode = schemaNodes.blockCard.createChecked(newAdf.attrs);
|
|
483
|
+
tr.replaceWith(link.pos, link.pos + (link.text || link.url).length, [newNode]);
|
|
484
|
+
}
|
|
461
485
|
} else {
|
|
462
486
|
// inline or blockCard to datasource
|
|
463
487
|
tr.setNodeMarkup(from, schemaNodes.blockCard, newAdf.attrs);
|
|
@@ -13,6 +13,7 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
13
13
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
14
|
var _table = _interopRequireDefault(require("@atlaskit/icon/glyph/table"));
|
|
15
15
|
var _linkDatasource = require("@atlaskit/link-datasource");
|
|
16
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
17
|
var _primitives = require("@atlaskit/primitives");
|
|
17
18
|
var _doc = require("../pm-plugins/doc");
|
|
18
19
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
@@ -51,7 +52,24 @@ var DatasourceAppearanceButtonWithCardContext = function DatasourceAppearanceBut
|
|
|
51
52
|
}]
|
|
52
53
|
}, url);
|
|
53
54
|
var selection = editorState.selection;
|
|
54
|
-
var existingNode
|
|
55
|
+
var existingNode;
|
|
56
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
57
|
+
// Check if the selection contains a link mark
|
|
58
|
+
var $pos = editorState.doc.resolve(selection.from);
|
|
59
|
+
var isLinkMark = $pos.marks().some(function (mark) {
|
|
60
|
+
return mark.type === editorState.schema.marks.link;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// When selection is a TextNode and a link Mark is present return that node
|
|
64
|
+
if (selection instanceof _state.NodeSelection) {
|
|
65
|
+
existingNode = selection.node;
|
|
66
|
+
} else if (isLinkMark) {
|
|
67
|
+
var _editorState$doc$node;
|
|
68
|
+
existingNode = (_editorState$doc$node = editorState.doc.nodeAt(selection.from)) !== null && _editorState$doc$node !== void 0 ? _editorState$doc$node : undefined;
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
existingNode = selection instanceof _state.NodeSelection ? selection.node : undefined;
|
|
72
|
+
}
|
|
55
73
|
if (existingNode) {
|
|
56
74
|
(0, _doc.updateCardViaDatasource)(editorState, existingNode, newAdf, editorView, undefined, true);
|
|
57
75
|
}
|
|
@@ -11,6 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
13
|
var _linkDatasource = require("@atlaskit/link-datasource");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
15
|
var _actions = require("../../pm-plugins/actions");
|
|
15
16
|
var _doc = require("../../pm-plugins/doc");
|
|
16
17
|
var _useFetchDatasourceInfo = require("../useFetchDatasourceInfo");
|
|
@@ -19,20 +20,37 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
19
20
|
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; }
|
|
20
21
|
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; }
|
|
21
22
|
var DatasourceModal = exports.DatasourceModal = function DatasourceModal(_ref) {
|
|
22
|
-
var _existingNode
|
|
23
|
+
var _existingNode, _existingNode2, _existingNode3;
|
|
23
24
|
var view = _ref.view,
|
|
24
25
|
modalType = _ref.modalType,
|
|
25
26
|
cardContext = _ref.cardContext;
|
|
26
27
|
var dispatch = view.dispatch,
|
|
27
28
|
state = view.state;
|
|
28
29
|
var selection = state.selection;
|
|
29
|
-
var existingNode
|
|
30
|
-
|
|
30
|
+
var existingNode;
|
|
31
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
32
|
+
// Check if the selection contains a link mark
|
|
33
|
+
var $pos = state.doc.resolve(selection.from);
|
|
34
|
+
var isLinkMark = $pos.marks().some(function (mark) {
|
|
35
|
+
return mark.type === state.schema.marks.link;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// When selection is a TextNode and a link Mark is present return that node
|
|
39
|
+
if (selection instanceof _state.NodeSelection) {
|
|
40
|
+
existingNode = selection.node;
|
|
41
|
+
} else if (isLinkMark) {
|
|
42
|
+
var _state$doc$nodeAt;
|
|
43
|
+
existingNode = (_state$doc$nodeAt = state.doc.nodeAt(selection.from)) !== null && _state$doc$nodeAt !== void 0 ? _state$doc$nodeAt : undefined;
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
existingNode = selection instanceof _state.NodeSelection ? selection.node : undefined;
|
|
47
|
+
}
|
|
48
|
+
var isRegularCardNode = !!(existingNode && !((_existingNode = existingNode) !== null && _existingNode !== void 0 && (_existingNode = _existingNode.attrs) !== null && _existingNode !== void 0 && _existingNode.datasource));
|
|
31
49
|
var _useFetchDatasourceIn = (0, _useFetchDatasourceInfo.useFetchDatasourceInfo)({
|
|
32
50
|
isRegularCardNode: isRegularCardNode,
|
|
33
|
-
url: existingNode === null ||
|
|
51
|
+
url: (_existingNode2 = existingNode) === null || _existingNode2 === void 0 ? void 0 : _existingNode2.attrs.url,
|
|
34
52
|
cardContext: cardContext,
|
|
35
|
-
nodeParameters: existingNode === null ||
|
|
53
|
+
nodeParameters: (_existingNode3 = existingNode) === null || _existingNode3 === void 0 || (_existingNode3 = _existingNode3.attrs) === null || _existingNode3 === void 0 || (_existingNode3 = _existingNode3.datasource) === null || _existingNode3 === void 0 ? void 0 : _existingNode3.parameters
|
|
36
54
|
}),
|
|
37
55
|
parameters = _useFetchDatasourceIn.parameters,
|
|
38
56
|
ready = _useFetchDatasourceIn.ready;
|
|
@@ -56,11 +74,11 @@ var DatasourceModal = exports.DatasourceModal = function DatasourceModal(_ref) {
|
|
|
56
74
|
}
|
|
57
75
|
}, [existingNode, view]);
|
|
58
76
|
if (modalType === 'jira') {
|
|
59
|
-
var
|
|
77
|
+
var _existingNode4, _tableView$properties, _existingNode5;
|
|
60
78
|
if (!ready) {
|
|
61
79
|
return null;
|
|
62
80
|
}
|
|
63
|
-
var _ref2 = (existingNode === null ||
|
|
81
|
+
var _ref2 = ((_existingNode4 = existingNode) === null || _existingNode4 === void 0 || (_existingNode4 = _existingNode4.attrs) === null || _existingNode4 === void 0 ? void 0 : _existingNode4.datasource) || {},
|
|
64
82
|
_ref2$id = _ref2.id,
|
|
65
83
|
datasourceId = _ref2$id === void 0 ? _linkDatasource.JIRA_LIST_OF_LINKS_DATASOURCE_ID : _ref2$id,
|
|
66
84
|
_ref2$views = _ref2.views,
|
|
@@ -79,14 +97,14 @@ var DatasourceModal = exports.DatasourceModal = function DatasourceModal(_ref) {
|
|
|
79
97
|
,
|
|
80
98
|
visibleColumnKeys: visibleColumnKeys,
|
|
81
99
|
parameters: parameters,
|
|
82
|
-
url: existingNode === null ||
|
|
100
|
+
url: (_existingNode5 = existingNode) === null || _existingNode5 === void 0 ? void 0 : _existingNode5.attrs.url,
|
|
83
101
|
onCancel: onClose,
|
|
84
102
|
onInsert: onInsert
|
|
85
103
|
}));
|
|
86
104
|
}
|
|
87
105
|
if (modalType === 'assets') {
|
|
88
|
-
var
|
|
89
|
-
var _ref5 = (existingNode === null ||
|
|
106
|
+
var _existingNode6, _tableView$properties2;
|
|
107
|
+
var _ref5 = ((_existingNode6 = existingNode) === null || _existingNode6 === void 0 || (_existingNode6 = _existingNode6.attrs) === null || _existingNode6 === void 0 ? void 0 : _existingNode6.datasource) || {},
|
|
90
108
|
_ref5$id = _ref5.id,
|
|
91
109
|
_datasourceId = _ref5$id === void 0 ? _linkDatasource.ASSETS_LIST_OF_LINKS_DATASOURCE_ID : _ref5$id,
|
|
92
110
|
_parameters = _ref5.parameters,
|
|
@@ -16,7 +16,9 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
16
16
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
17
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
20
|
var _primitives = require("@atlaskit/primitives");
|
|
21
|
+
var _DatasourceAppearanceButton = require("./DatasourceAppearanceButton");
|
|
20
22
|
var _EditDatasourceButton = require("./EditDatasourceButton");
|
|
21
23
|
var _LinkToolbarAppearance = require("./LinkToolbarAppearance");
|
|
22
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -175,6 +177,12 @@ var HyperlinkToolbarAppearance = exports.HyperlinkToolbarAppearance = /*#__PURE_
|
|
|
175
177
|
platform: platform,
|
|
176
178
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
177
179
|
cardActions: cardActions
|
|
180
|
+
}), (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar') && /*#__PURE__*/_react.default.createElement(_DatasourceAppearanceButton.DatasourceAppearanceButton, {
|
|
181
|
+
intl: intl,
|
|
182
|
+
url: url,
|
|
183
|
+
editorState: editorState,
|
|
184
|
+
editorView: editorView,
|
|
185
|
+
editorAnalyticsApi: editorAnalyticsApi
|
|
178
186
|
}));
|
|
179
187
|
}
|
|
180
188
|
}]);
|
|
@@ -410,7 +410,8 @@ export const updateCardViaDatasource = (state, node, newAdf, view, sourceEvent,
|
|
|
410
410
|
const {
|
|
411
411
|
tr,
|
|
412
412
|
selection: {
|
|
413
|
-
from
|
|
413
|
+
from,
|
|
414
|
+
to
|
|
414
415
|
},
|
|
415
416
|
schema: {
|
|
416
417
|
nodes: schemaNodes
|
|
@@ -433,6 +434,26 @@ export const updateCardViaDatasource = (state, node, newAdf, view, sourceEvent,
|
|
|
433
434
|
...newAdf.attrs
|
|
434
435
|
});
|
|
435
436
|
}
|
|
437
|
+
} else if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && node.type.isText) {
|
|
438
|
+
// url to datasource
|
|
439
|
+
let link;
|
|
440
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
441
|
+
// get the actual start position of a link within the node
|
|
442
|
+
const linkMark = node.marks.find(mark => mark.type === state.schema.marks.link);
|
|
443
|
+
if (linkMark) {
|
|
444
|
+
link = {
|
|
445
|
+
url: linkMark.attrs.href,
|
|
446
|
+
text: node.text,
|
|
447
|
+
pos
|
|
448
|
+
};
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
return true;
|
|
452
|
+
});
|
|
453
|
+
if (link) {
|
|
454
|
+
const newNode = schemaNodes.blockCard.createChecked(newAdf.attrs);
|
|
455
|
+
tr.replaceWith(link.pos, link.pos + (link.text || link.url).length, [newNode]);
|
|
456
|
+
}
|
|
436
457
|
} else {
|
|
437
458
|
// inline or blockCard to datasource
|
|
438
459
|
tr.setNodeMarkup(from, schemaNodes.blockCard, newAdf.attrs);
|
|
@@ -7,6 +7,7 @@ import { canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
|
7
7
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import TableIcon from '@atlaskit/icon/glyph/table';
|
|
9
9
|
import { buildDatasourceAdf } from '@atlaskit/link-datasource';
|
|
10
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { Flex } from '@atlaskit/primitives';
|
|
11
12
|
import { updateCardViaDatasource } from '../pm-plugins/doc';
|
|
12
13
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
@@ -47,7 +48,22 @@ const DatasourceAppearanceButtonWithCardContext = ({
|
|
|
47
48
|
const {
|
|
48
49
|
selection
|
|
49
50
|
} = editorState;
|
|
50
|
-
|
|
51
|
+
let existingNode;
|
|
52
|
+
if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
53
|
+
// Check if the selection contains a link mark
|
|
54
|
+
const $pos = editorState.doc.resolve(selection.from);
|
|
55
|
+
const isLinkMark = $pos.marks().some(mark => mark.type === editorState.schema.marks.link);
|
|
56
|
+
|
|
57
|
+
// When selection is a TextNode and a link Mark is present return that node
|
|
58
|
+
if (selection instanceof NodeSelection) {
|
|
59
|
+
existingNode = selection.node;
|
|
60
|
+
} else if (isLinkMark) {
|
|
61
|
+
var _editorState$doc$node;
|
|
62
|
+
existingNode = (_editorState$doc$node = editorState.doc.nodeAt(selection.from)) !== null && _editorState$doc$node !== void 0 ? _editorState$doc$node : undefined;
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
existingNode = selection instanceof NodeSelection ? selection.node : undefined;
|
|
66
|
+
}
|
|
51
67
|
if (existingNode) {
|
|
52
68
|
updateCardViaDatasource(editorState, existingNode, newAdf, editorView, undefined, true);
|
|
53
69
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, AssetsConfigModal, JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
|
|
4
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { hideDatasourceModal } from '../../pm-plugins/actions';
|
|
5
6
|
import { insertDatasource, updateCardViaDatasource } from '../../pm-plugins/doc';
|
|
6
7
|
import { useFetchDatasourceInfo } from '../useFetchDatasourceInfo';
|
|
@@ -9,7 +10,7 @@ export const DatasourceModal = ({
|
|
|
9
10
|
modalType,
|
|
10
11
|
cardContext
|
|
11
12
|
}) => {
|
|
12
|
-
var _existingNode$attrs,
|
|
13
|
+
var _existingNode, _existingNode$attrs, _existingNode2, _existingNode3, _existingNode3$attrs, _existingNode3$attrs$;
|
|
13
14
|
const {
|
|
14
15
|
dispatch,
|
|
15
16
|
state
|
|
@@ -17,16 +18,31 @@ export const DatasourceModal = ({
|
|
|
17
18
|
const {
|
|
18
19
|
selection
|
|
19
20
|
} = state;
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
let existingNode;
|
|
22
|
+
if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
23
|
+
// Check if the selection contains a link mark
|
|
24
|
+
const $pos = state.doc.resolve(selection.from);
|
|
25
|
+
const isLinkMark = $pos.marks().some(mark => mark.type === state.schema.marks.link);
|
|
26
|
+
|
|
27
|
+
// When selection is a TextNode and a link Mark is present return that node
|
|
28
|
+
if (selection instanceof NodeSelection) {
|
|
29
|
+
existingNode = selection.node;
|
|
30
|
+
} else if (isLinkMark) {
|
|
31
|
+
var _state$doc$nodeAt;
|
|
32
|
+
existingNode = (_state$doc$nodeAt = state.doc.nodeAt(selection.from)) !== null && _state$doc$nodeAt !== void 0 ? _state$doc$nodeAt : undefined;
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
existingNode = selection instanceof NodeSelection ? selection.node : undefined;
|
|
36
|
+
}
|
|
37
|
+
const isRegularCardNode = !!(existingNode && !((_existingNode = existingNode) !== null && _existingNode !== void 0 && (_existingNode$attrs = _existingNode.attrs) !== null && _existingNode$attrs !== void 0 && _existingNode$attrs.datasource));
|
|
22
38
|
const {
|
|
23
39
|
parameters,
|
|
24
40
|
ready
|
|
25
41
|
} = useFetchDatasourceInfo({
|
|
26
42
|
isRegularCardNode,
|
|
27
|
-
url: existingNode === null ||
|
|
43
|
+
url: (_existingNode2 = existingNode) === null || _existingNode2 === void 0 ? void 0 : _existingNode2.attrs.url,
|
|
28
44
|
cardContext,
|
|
29
|
-
nodeParameters: existingNode === null ||
|
|
45
|
+
nodeParameters: (_existingNode3 = existingNode) === null || _existingNode3 === void 0 ? void 0 : (_existingNode3$attrs = _existingNode3.attrs) === null || _existingNode3$attrs === void 0 ? void 0 : (_existingNode3$attrs$ = _existingNode3$attrs.datasource) === null || _existingNode3$attrs$ === void 0 ? void 0 : _existingNode3$attrs$.parameters
|
|
30
46
|
});
|
|
31
47
|
const onClose = useCallback(() => {
|
|
32
48
|
dispatch(hideDatasourceModal(view.state.tr));
|
|
@@ -48,14 +64,14 @@ export const DatasourceModal = ({
|
|
|
48
64
|
}
|
|
49
65
|
}, [existingNode, view]);
|
|
50
66
|
if (modalType === 'jira') {
|
|
51
|
-
var
|
|
67
|
+
var _existingNode4, _existingNode4$attrs, _tableView$properties, _existingNode5;
|
|
52
68
|
if (!ready) {
|
|
53
69
|
return null;
|
|
54
70
|
}
|
|
55
71
|
const {
|
|
56
72
|
id: datasourceId = JIRA_LIST_OF_LINKS_DATASOURCE_ID,
|
|
57
73
|
views = []
|
|
58
|
-
} = (existingNode === null ||
|
|
74
|
+
} = ((_existingNode4 = existingNode) === null || _existingNode4 === void 0 ? void 0 : (_existingNode4$attrs = _existingNode4.attrs) === null || _existingNode4$attrs === void 0 ? void 0 : _existingNode4$attrs.datasource) || {};
|
|
59
75
|
const [tableView] = views;
|
|
60
76
|
const visibleColumnKeys = tableView === null || tableView === void 0 ? void 0 : (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns.map(column => column.key);
|
|
61
77
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -66,18 +82,18 @@ export const DatasourceModal = ({
|
|
|
66
82
|
,
|
|
67
83
|
visibleColumnKeys: visibleColumnKeys,
|
|
68
84
|
parameters: parameters,
|
|
69
|
-
url: existingNode === null ||
|
|
85
|
+
url: (_existingNode5 = existingNode) === null || _existingNode5 === void 0 ? void 0 : _existingNode5.attrs.url,
|
|
70
86
|
onCancel: onClose,
|
|
71
87
|
onInsert: onInsert
|
|
72
88
|
}));
|
|
73
89
|
}
|
|
74
90
|
if (modalType === 'assets') {
|
|
75
|
-
var
|
|
91
|
+
var _existingNode6, _existingNode6$attrs, _tableView$properties2;
|
|
76
92
|
const {
|
|
77
93
|
id: datasourceId = ASSETS_LIST_OF_LINKS_DATASOURCE_ID,
|
|
78
94
|
parameters,
|
|
79
95
|
views = []
|
|
80
|
-
} = (existingNode === null ||
|
|
96
|
+
} = ((_existingNode6 = existingNode) === null || _existingNode6 === void 0 ? void 0 : (_existingNode6$attrs = _existingNode6.attrs) === null || _existingNode6$attrs === void 0 ? void 0 : _existingNode6$attrs.datasource) || {};
|
|
81
97
|
const [tableView] = views;
|
|
82
98
|
const visibleColumnKeys = tableView === null || tableView === void 0 ? void 0 : (_tableView$properties2 = tableView.properties) === null || _tableView$properties2 === void 0 ? void 0 : _tableView$properties2.columns.map(column => column.key);
|
|
83
99
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { Flex } from '@atlaskit/primitives';
|
|
5
|
+
import { DatasourceAppearanceButton } from './DatasourceAppearanceButton';
|
|
4
6
|
import { EditDatasourceButton } from './EditDatasourceButton';
|
|
5
7
|
import { LinkToolbarAppearance } from './LinkToolbarAppearance';
|
|
6
8
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -90,6 +92,12 @@ export class HyperlinkToolbarAppearance extends Component {
|
|
|
90
92
|
platform: platform,
|
|
91
93
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
92
94
|
cardActions: cardActions
|
|
95
|
+
}), getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
|
|
96
|
+
intl: intl,
|
|
97
|
+
url: url,
|
|
98
|
+
editorState: editorState,
|
|
99
|
+
editorView: editorView,
|
|
100
|
+
editorAnalyticsApi: editorAnalyticsApi
|
|
93
101
|
}));
|
|
94
102
|
}
|
|
95
103
|
}
|
|
@@ -427,7 +427,9 @@ export var getLinkNodeType = function getLinkNodeType(appearance, linkNodes) {
|
|
|
427
427
|
// Apply an update made from a datasource ui interaction
|
|
428
428
|
export var updateCardViaDatasource = function updateCardViaDatasource(state, node, newAdf, view, sourceEvent, isDeletingConfig) {
|
|
429
429
|
var tr = state.tr,
|
|
430
|
-
|
|
430
|
+
_state$selection2 = state.selection,
|
|
431
|
+
from = _state$selection2.from,
|
|
432
|
+
to = _state$selection2.to,
|
|
431
433
|
schemaNodes = state.schema.nodes;
|
|
432
434
|
if (newAdf.type === 'blockCard') {
|
|
433
435
|
var _node$attrs, _newAdf$attrs;
|
|
@@ -451,6 +453,28 @@ export var updateCardViaDatasource = function updateCardViaDatasource(state, nod
|
|
|
451
453
|
if (isColumnChange || isUrlChange) {
|
|
452
454
|
tr.setNodeMarkup(from, schemaNodes.blockCard, _objectSpread(_objectSpread({}, node.attrs), newAdf.attrs));
|
|
453
455
|
}
|
|
456
|
+
} else if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && node.type.isText) {
|
|
457
|
+
// url to datasource
|
|
458
|
+
var link;
|
|
459
|
+
state.doc.nodesBetween(from, to, function (node, pos) {
|
|
460
|
+
// get the actual start position of a link within the node
|
|
461
|
+
var linkMark = node.marks.find(function (mark) {
|
|
462
|
+
return mark.type === state.schema.marks.link;
|
|
463
|
+
});
|
|
464
|
+
if (linkMark) {
|
|
465
|
+
link = {
|
|
466
|
+
url: linkMark.attrs.href,
|
|
467
|
+
text: node.text,
|
|
468
|
+
pos: pos
|
|
469
|
+
};
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
return true;
|
|
473
|
+
});
|
|
474
|
+
if (link) {
|
|
475
|
+
var newNode = schemaNodes.blockCard.createChecked(newAdf.attrs);
|
|
476
|
+
tr.replaceWith(link.pos, link.pos + (link.text || link.url).length, [newNode]);
|
|
477
|
+
}
|
|
454
478
|
} else {
|
|
455
479
|
// inline or blockCard to datasource
|
|
456
480
|
tr.setNodeMarkup(from, schemaNodes.blockCard, newAdf.attrs);
|
|
@@ -7,6 +7,7 @@ import { canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
|
7
7
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import TableIcon from '@atlaskit/icon/glyph/table';
|
|
9
9
|
import { buildDatasourceAdf } from '@atlaskit/link-datasource';
|
|
10
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { Flex } from '@atlaskit/primitives';
|
|
11
12
|
import { updateCardViaDatasource } from '../pm-plugins/doc';
|
|
12
13
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
@@ -43,7 +44,24 @@ var DatasourceAppearanceButtonWithCardContext = function DatasourceAppearanceBut
|
|
|
43
44
|
}]
|
|
44
45
|
}, url);
|
|
45
46
|
var selection = editorState.selection;
|
|
46
|
-
var existingNode
|
|
47
|
+
var existingNode;
|
|
48
|
+
if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
49
|
+
// Check if the selection contains a link mark
|
|
50
|
+
var $pos = editorState.doc.resolve(selection.from);
|
|
51
|
+
var isLinkMark = $pos.marks().some(function (mark) {
|
|
52
|
+
return mark.type === editorState.schema.marks.link;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// When selection is a TextNode and a link Mark is present return that node
|
|
56
|
+
if (selection instanceof NodeSelection) {
|
|
57
|
+
existingNode = selection.node;
|
|
58
|
+
} else if (isLinkMark) {
|
|
59
|
+
var _editorState$doc$node;
|
|
60
|
+
existingNode = (_editorState$doc$node = editorState.doc.nodeAt(selection.from)) !== null && _editorState$doc$node !== void 0 ? _editorState$doc$node : undefined;
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
existingNode = selection instanceof NodeSelection ? selection.node : undefined;
|
|
64
|
+
}
|
|
47
65
|
if (existingNode) {
|
|
48
66
|
updateCardViaDatasource(editorState, existingNode, newAdf, editorView, undefined, true);
|
|
49
67
|
}
|
|
@@ -5,24 +5,42 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
import React, { useCallback } from 'react';
|
|
6
6
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, AssetsConfigModal, JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
|
|
8
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { hideDatasourceModal } from '../../pm-plugins/actions';
|
|
9
10
|
import { insertDatasource, updateCardViaDatasource } from '../../pm-plugins/doc';
|
|
10
11
|
import { useFetchDatasourceInfo } from '../useFetchDatasourceInfo';
|
|
11
12
|
export var DatasourceModal = function DatasourceModal(_ref) {
|
|
12
|
-
var _existingNode
|
|
13
|
+
var _existingNode, _existingNode2, _existingNode3;
|
|
13
14
|
var view = _ref.view,
|
|
14
15
|
modalType = _ref.modalType,
|
|
15
16
|
cardContext = _ref.cardContext;
|
|
16
17
|
var dispatch = view.dispatch,
|
|
17
18
|
state = view.state;
|
|
18
19
|
var selection = state.selection;
|
|
19
|
-
var existingNode
|
|
20
|
-
|
|
20
|
+
var existingNode;
|
|
21
|
+
if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar')) {
|
|
22
|
+
// Check if the selection contains a link mark
|
|
23
|
+
var $pos = state.doc.resolve(selection.from);
|
|
24
|
+
var isLinkMark = $pos.marks().some(function (mark) {
|
|
25
|
+
return mark.type === state.schema.marks.link;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// When selection is a TextNode and a link Mark is present return that node
|
|
29
|
+
if (selection instanceof NodeSelection) {
|
|
30
|
+
existingNode = selection.node;
|
|
31
|
+
} else if (isLinkMark) {
|
|
32
|
+
var _state$doc$nodeAt;
|
|
33
|
+
existingNode = (_state$doc$nodeAt = state.doc.nodeAt(selection.from)) !== null && _state$doc$nodeAt !== void 0 ? _state$doc$nodeAt : undefined;
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
existingNode = selection instanceof NodeSelection ? selection.node : undefined;
|
|
37
|
+
}
|
|
38
|
+
var isRegularCardNode = !!(existingNode && !((_existingNode = existingNode) !== null && _existingNode !== void 0 && (_existingNode = _existingNode.attrs) !== null && _existingNode !== void 0 && _existingNode.datasource));
|
|
21
39
|
var _useFetchDatasourceIn = useFetchDatasourceInfo({
|
|
22
40
|
isRegularCardNode: isRegularCardNode,
|
|
23
|
-
url: existingNode === null ||
|
|
41
|
+
url: (_existingNode2 = existingNode) === null || _existingNode2 === void 0 ? void 0 : _existingNode2.attrs.url,
|
|
24
42
|
cardContext: cardContext,
|
|
25
|
-
nodeParameters: existingNode === null ||
|
|
43
|
+
nodeParameters: (_existingNode3 = existingNode) === null || _existingNode3 === void 0 || (_existingNode3 = _existingNode3.attrs) === null || _existingNode3 === void 0 || (_existingNode3 = _existingNode3.datasource) === null || _existingNode3 === void 0 ? void 0 : _existingNode3.parameters
|
|
26
44
|
}),
|
|
27
45
|
parameters = _useFetchDatasourceIn.parameters,
|
|
28
46
|
ready = _useFetchDatasourceIn.ready;
|
|
@@ -46,11 +64,11 @@ export var DatasourceModal = function DatasourceModal(_ref) {
|
|
|
46
64
|
}
|
|
47
65
|
}, [existingNode, view]);
|
|
48
66
|
if (modalType === 'jira') {
|
|
49
|
-
var
|
|
67
|
+
var _existingNode4, _tableView$properties, _existingNode5;
|
|
50
68
|
if (!ready) {
|
|
51
69
|
return null;
|
|
52
70
|
}
|
|
53
|
-
var _ref2 = (existingNode === null ||
|
|
71
|
+
var _ref2 = ((_existingNode4 = existingNode) === null || _existingNode4 === void 0 || (_existingNode4 = _existingNode4.attrs) === null || _existingNode4 === void 0 ? void 0 : _existingNode4.datasource) || {},
|
|
54
72
|
_ref2$id = _ref2.id,
|
|
55
73
|
datasourceId = _ref2$id === void 0 ? JIRA_LIST_OF_LINKS_DATASOURCE_ID : _ref2$id,
|
|
56
74
|
_ref2$views = _ref2.views,
|
|
@@ -69,14 +87,14 @@ export var DatasourceModal = function DatasourceModal(_ref) {
|
|
|
69
87
|
,
|
|
70
88
|
visibleColumnKeys: visibleColumnKeys,
|
|
71
89
|
parameters: parameters,
|
|
72
|
-
url: existingNode === null ||
|
|
90
|
+
url: (_existingNode5 = existingNode) === null || _existingNode5 === void 0 ? void 0 : _existingNode5.attrs.url,
|
|
73
91
|
onCancel: onClose,
|
|
74
92
|
onInsert: onInsert
|
|
75
93
|
}));
|
|
76
94
|
}
|
|
77
95
|
if (modalType === 'assets') {
|
|
78
|
-
var
|
|
79
|
-
var _ref5 = (existingNode === null ||
|
|
96
|
+
var _existingNode6, _tableView$properties2;
|
|
97
|
+
var _ref5 = ((_existingNode6 = existingNode) === null || _existingNode6 === void 0 || (_existingNode6 = _existingNode6.attrs) === null || _existingNode6 === void 0 ? void 0 : _existingNode6.datasource) || {},
|
|
80
98
|
_ref5$id = _ref5.id,
|
|
81
99
|
_datasourceId = _ref5$id === void 0 ? ASSETS_LIST_OF_LINKS_DATASOURCE_ID : _ref5$id,
|
|
82
100
|
_parameters = _ref5.parameters,
|
|
@@ -10,7 +10,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
10
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
12
|
import React, { Component } from 'react';
|
|
13
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { Flex } from '@atlaskit/primitives';
|
|
15
|
+
import { DatasourceAppearanceButton } from './DatasourceAppearanceButton';
|
|
14
16
|
import { EditDatasourceButton } from './EditDatasourceButton';
|
|
15
17
|
import { LinkToolbarAppearance } from './LinkToolbarAppearance';
|
|
16
18
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -165,6 +167,12 @@ export var HyperlinkToolbarAppearance = /*#__PURE__*/function (_Component) {
|
|
|
165
167
|
platform: platform,
|
|
166
168
|
editorAnalyticsApi: editorAnalyticsApi,
|
|
167
169
|
cardActions: cardActions
|
|
170
|
+
}), getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
|
|
171
|
+
intl: intl,
|
|
172
|
+
url: url,
|
|
173
|
+
editorState: editorState,
|
|
174
|
+
editorView: editorView,
|
|
175
|
+
editorAnalyticsApi: editorAnalyticsApi
|
|
168
176
|
}));
|
|
169
177
|
}
|
|
170
178
|
}]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"@atlaskit/linking-common": "^5.3.0",
|
|
54
54
|
"@atlaskit/linking-types": "^8.6.0",
|
|
55
55
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
56
|
-
"@atlaskit/primitives": "^
|
|
56
|
+
"@atlaskit/primitives": "^4.0.0",
|
|
57
57
|
"@atlaskit/smart-card": "^26.48.0",
|
|
58
58
|
"@atlaskit/theme": "^12.6.0",
|
|
59
|
-
"@atlaskit/tokens": "^1.
|
|
59
|
+
"@atlaskit/tokens": "^1.39.0",
|
|
60
60
|
"@babel/runtime": "^7.0.0",
|
|
61
61
|
"@emotion/react": "^11.7.1",
|
|
62
62
|
"lodash": "^4.17.21",
|