@atlaskit/editor-plugin-card 1.0.2 → 1.0.4
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 +13 -0
- package/dist/cjs/pm-plugins/actions.js +13 -1
- package/dist/cjs/pm-plugins/doc.js +19 -4
- package/dist/cjs/pm-plugins/main.js +1 -0
- package/dist/cjs/pm-plugins/reducers.js +24 -0
- package/dist/cjs/ui/DatasourceAppearanceButton.js +5 -2
- package/dist/es2019/pm-plugins/actions.js +8 -0
- package/dist/es2019/pm-plugins/doc.js +21 -6
- package/dist/es2019/pm-plugins/main.js +1 -0
- package/dist/es2019/pm-plugins/reducers.js +25 -0
- package/dist/es2019/ui/DatasourceAppearanceButton.js +5 -2
- package/dist/esm/pm-plugins/actions.js +12 -0
- package/dist/esm/pm-plugins/doc.js +21 -6
- package/dist/esm/pm-plugins/main.js +1 -0
- package/dist/esm/pm-plugins/reducers.js +24 -0
- package/dist/esm/ui/DatasourceAppearanceButton.js +5 -2
- package/dist/types/pm-plugins/actions.d.ts +6 -0
- package/dist/types/pm-plugins/doc.d.ts +1 -1
- package/dist/types/pm-plugins/util/state.d.ts +5 -0
- package/dist/types/types.d.ts +22 -1
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/doc.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/util/state.d.ts +5 -0
- package/dist/types-ts4.5/types.d.ts +22 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 1.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#75549](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75549) [`cdb2d5721cce`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cdb2d5721cce) - Fix an issue where view switching from toolbar was causing js error.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 1.0.3
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#72875](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/72875) [`0d1e8b03af0b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0d1e8b03af0b) - Adding datasource stash to save datasource views when switching to inline/block and then back to datasource view
|
|
15
|
+
|
|
3
16
|
## 1.0.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.showLinkToolbar = exports.showDatasourceModal = exports.setProvider = exports.setDatasourceTableRef = exports.setCardLayoutAndDatasourceTableRef = exports.setCardLayout = exports.resolveCard = exports.registerSmartCardEvents = exports.registerRemoveOverlay = exports.registerCard = exports.queueCards = exports.hideLinkToolbar = exports.hideDatasourceModal = exports.clearOverlayCandidate = exports.cardAction = void 0;
|
|
6
|
+
exports.showLinkToolbar = exports.showDatasourceModal = exports.setProvider = exports.setDatasourceTableRef = exports.setDatasourceStash = exports.setCardLayoutAndDatasourceTableRef = exports.setCardLayout = exports.resolveCard = exports.removeDatasourceStash = exports.registerSmartCardEvents = exports.registerRemoveOverlay = exports.registerCard = exports.queueCards = exports.hideLinkToolbar = exports.hideDatasourceModal = exports.clearOverlayCandidate = exports.cardAction = void 0;
|
|
7
7
|
var _pluginKey = require("./plugin-key");
|
|
8
8
|
var cardAction = exports.cardAction = function cardAction(tr, action) {
|
|
9
9
|
return tr.setMeta(_pluginKey.pluginKey, action);
|
|
@@ -110,4 +110,16 @@ var clearOverlayCandidate = exports.clearOverlayCandidate = function clearOverla
|
|
|
110
110
|
return cardAction(tr, {
|
|
111
111
|
type: 'CLEAR_OVERLAY_CANDIDATE'
|
|
112
112
|
});
|
|
113
|
+
};
|
|
114
|
+
var setDatasourceStash = exports.setDatasourceStash = function setDatasourceStash(tr, datasourceStash) {
|
|
115
|
+
return cardAction(tr, {
|
|
116
|
+
type: 'SET_DATASOURCE_STASH',
|
|
117
|
+
datasourceStash: datasourceStash
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
var removeDatasourceStash = exports.removeDatasourceStash = function removeDatasourceStash(tr, url) {
|
|
121
|
+
return cardAction(tr, {
|
|
122
|
+
type: 'REMOVE_DATASOURCE_STASH',
|
|
123
|
+
url: url
|
|
124
|
+
});
|
|
113
125
|
};
|
|
@@ -251,13 +251,14 @@ var convertHyperlinkToSmartCard = exports.convertHyperlinkToSmartCard = function
|
|
|
251
251
|
};
|
|
252
252
|
var changeSelectedCardToLink = exports.changeSelectedCardToLink = function changeSelectedCardToLink(text, href, sendAnalytics, node, pos, editorAnalyticsApi) {
|
|
253
253
|
return function (state, dispatch) {
|
|
254
|
+
var selectedNode = state.selection instanceof _state.NodeSelection ? state.selection.node : undefined;
|
|
254
255
|
var tr;
|
|
255
256
|
if (node && pos) {
|
|
256
257
|
tr = cardNodeToLinkWithTransaction(state, text, href, node, pos);
|
|
257
258
|
} else {
|
|
258
259
|
tr = cardToLinkWithTransaction(state, text, href);
|
|
259
260
|
}
|
|
260
|
-
|
|
261
|
+
updateDatasourceStash(tr, selectedNode);
|
|
261
262
|
if (sendAnalytics) {
|
|
262
263
|
if (selectedNode) {
|
|
263
264
|
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
@@ -356,7 +357,7 @@ var changeSelectedCardToText = exports.changeSelectedCardToText = function chang
|
|
|
356
357
|
var setSelectedCardAppearance = exports.setSelectedCardAppearance = function setSelectedCardAppearance(appearance, editorAnalyticsApi) {
|
|
357
358
|
return function (state, dispatch) {
|
|
358
359
|
var _previousNode$type;
|
|
359
|
-
var selectedNode = state.selection instanceof _state.NodeSelection
|
|
360
|
+
var selectedNode = state.selection instanceof _state.NodeSelection ? state.selection.node : undefined;
|
|
360
361
|
if (!selectedNode) {
|
|
361
362
|
// When there is no selected node, we insert a new one
|
|
362
363
|
// and replace the existing blue link
|
|
@@ -389,6 +390,7 @@ var setSelectedCardAppearance = exports.setSelectedCardAppearance = function set
|
|
|
389
390
|
to = _state$selection.to;
|
|
390
391
|
var nodeType = getLinkNodeType(appearance, state.schema.nodes);
|
|
391
392
|
var tr = state.tr.setNodeMarkup(from, nodeType, attrs, selectedNode.marks);
|
|
393
|
+
updateDatasourceStash(tr, selectedNode);
|
|
392
394
|
|
|
393
395
|
// When the selected card is the last element in the doc we add a new paragraph after it for consistent replacement
|
|
394
396
|
if (tr.doc.nodeSize - 2 === to) {
|
|
@@ -430,7 +432,7 @@ var getLinkNodeType = exports.getLinkNodeType = function getLinkNodeType(appeara
|
|
|
430
432
|
};
|
|
431
433
|
|
|
432
434
|
// Apply an update made from a datasource ui interaction
|
|
433
|
-
var updateCardViaDatasource = exports.updateCardViaDatasource = function updateCardViaDatasource(state, node, newAdf, view, sourceEvent) {
|
|
435
|
+
var updateCardViaDatasource = exports.updateCardViaDatasource = function updateCardViaDatasource(state, node, newAdf, view, sourceEvent, isDeletingConfig) {
|
|
434
436
|
var tr = state.tr,
|
|
435
437
|
from = state.selection.from,
|
|
436
438
|
schemaNodes = state.schema.nodes;
|
|
@@ -468,7 +470,11 @@ var updateCardViaDatasource = exports.updateCardViaDatasource = function updateC
|
|
|
468
470
|
action: _analytics.ACTION.UPDATED,
|
|
469
471
|
sourceEvent: sourceEvent
|
|
470
472
|
});
|
|
471
|
-
|
|
473
|
+
if (isDeletingConfig) {
|
|
474
|
+
(0, _actions.removeDatasourceStash)(tr, node.attrs.url);
|
|
475
|
+
} else {
|
|
476
|
+
(0, _actions.hideDatasourceModal)(tr);
|
|
477
|
+
}
|
|
472
478
|
view.dispatch(tr.scrollIntoView());
|
|
473
479
|
};
|
|
474
480
|
var insertDatasource = exports.insertDatasource = function insertDatasource(state, adf, view, sourceEvent) {
|
|
@@ -505,4 +511,13 @@ var getAttrsForAppearance = exports.getAttrsForAppearance = function getAttrsFor
|
|
|
505
511
|
};
|
|
506
512
|
}
|
|
507
513
|
return selectedNode.attrs;
|
|
514
|
+
};
|
|
515
|
+
var updateDatasourceStash = function updateDatasourceStash(tr, selectedNode) {
|
|
516
|
+
var _selectedNode$attrs;
|
|
517
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar') && selectedNode !== null && selectedNode !== void 0 && (_selectedNode$attrs = selectedNode.attrs) !== null && _selectedNode$attrs !== void 0 && _selectedNode$attrs.datasource && !(0, _utils2.isDatasourceConfigEditable)(selectedNode.attrs.datasource.id)) {
|
|
518
|
+
(0, _actions.setDatasourceStash)(tr, {
|
|
519
|
+
url: selectedNode.attrs.url,
|
|
520
|
+
views: selectedNode.attrs.datasource.views
|
|
521
|
+
});
|
|
522
|
+
}
|
|
508
523
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = void 0;
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
8
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
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; }
|
|
10
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; }
|
|
11
15
|
var queue = function queue(state, action) {
|
|
@@ -84,6 +88,22 @@ var registerRemoveOverlayOnInsertedLink = function registerRemoveOverlayOnInsert
|
|
|
84
88
|
removeOverlay: action.callback
|
|
85
89
|
});
|
|
86
90
|
};
|
|
91
|
+
var setDatasourceStash = function setDatasourceStash(state, action) {
|
|
92
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
93
|
+
datasourceStash: _objectSpread(_objectSpread({}, state.datasourceStash), {}, (0, _defineProperty2.default)({}, action.datasourceStash.url, {
|
|
94
|
+
views: action.datasourceStash.views
|
|
95
|
+
}))
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
var removeDatasourceStash = function removeDatasourceStash(state, action) {
|
|
99
|
+
var _state$datasourceStas = state.datasourceStash,
|
|
100
|
+
_action$url = action.url,
|
|
101
|
+
_ = _state$datasourceStas[_action$url],
|
|
102
|
+
datasourceStash = (0, _objectWithoutProperties2.default)(_state$datasourceStas, [_action$url].map(_toPropertyKey));
|
|
103
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
104
|
+
datasourceStash: datasourceStash
|
|
105
|
+
});
|
|
106
|
+
};
|
|
87
107
|
var _default = exports.default = function _default(state, action) {
|
|
88
108
|
switch (action.type) {
|
|
89
109
|
case 'QUEUE':
|
|
@@ -113,5 +133,9 @@ var _default = exports.default = function _default(state, action) {
|
|
|
113
133
|
return clearOverlayCandidate(state);
|
|
114
134
|
case 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK':
|
|
115
135
|
return registerRemoveOverlayOnInsertedLink(state, action);
|
|
136
|
+
case 'SET_DATASOURCE_STASH':
|
|
137
|
+
return setDatasourceStash(state, action);
|
|
138
|
+
case 'REMOVE_DATASOURCE_STASH':
|
|
139
|
+
return removeDatasourceStash(state, action);
|
|
116
140
|
}
|
|
117
141
|
};
|
|
@@ -15,6 +15,7 @@ var _table = _interopRequireDefault(require("@atlaskit/icon/glyph/table"));
|
|
|
15
15
|
var _linkDatasource = require("@atlaskit/link-datasource");
|
|
16
16
|
var _primitives = require("@atlaskit/primitives");
|
|
17
17
|
var _doc = require("../pm-plugins/doc");
|
|
18
|
+
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
18
19
|
var _CardContextProvider = require("./CardContextProvider");
|
|
19
20
|
var _useFetchDatasourceInfo = require("./useFetchDatasourceInfo");
|
|
20
21
|
/** @jsx jsx */
|
|
@@ -37,20 +38,22 @@ var DatasourceAppearanceButtonWithCardContext = function DatasourceAppearanceBut
|
|
|
37
38
|
datasourceId = _useFetchDatasourceIn.datasourceId,
|
|
38
39
|
parameters = _useFetchDatasourceIn.parameters;
|
|
39
40
|
var onChangeAppearance = (0, _react.useCallback)(function () {
|
|
41
|
+
var _state$datasourceStas, _state$datasourceStas2;
|
|
40
42
|
if (!editorView || !datasourceId || !parameters) {
|
|
41
43
|
return;
|
|
42
44
|
}
|
|
45
|
+
var state = _pluginKey.pluginKey.getState(editorState);
|
|
43
46
|
var newAdf = (0, _linkDatasource.buildDatasourceAdf)({
|
|
44
47
|
id: datasourceId,
|
|
45
48
|
parameters: parameters,
|
|
46
|
-
views: [{
|
|
49
|
+
views: (_state$datasourceStas = state === null || state === void 0 || (_state$datasourceStas2 = state.datasourceStash[url]) === null || _state$datasourceStas2 === void 0 ? void 0 : _state$datasourceStas2.views) !== null && _state$datasourceStas !== void 0 ? _state$datasourceStas : [{
|
|
47
50
|
type: 'table'
|
|
48
51
|
}]
|
|
49
52
|
}, url);
|
|
50
53
|
var selection = editorState.selection;
|
|
51
54
|
var existingNode = selection instanceof _state.NodeSelection ? selection.node : undefined;
|
|
52
55
|
if (existingNode) {
|
|
53
|
-
(0, _doc.updateCardViaDatasource)(editorState, existingNode, newAdf, editorView, undefined);
|
|
56
|
+
(0, _doc.updateCardViaDatasource)(editorState, existingNode, newAdf, editorView, undefined, true);
|
|
54
57
|
}
|
|
55
58
|
}, [parameters, datasourceId, editorState, editorView, url]);
|
|
56
59
|
if (!parameters || !datasourceId || !(0, _utils.canRenderDatasource)(datasourceId)) {
|
|
@@ -57,4 +57,12 @@ export const hideDatasourceModal = tr => cardAction(tr, {
|
|
|
57
57
|
});
|
|
58
58
|
export const clearOverlayCandidate = tr => cardAction(tr, {
|
|
59
59
|
type: 'CLEAR_OVERLAY_CANDIDATE'
|
|
60
|
+
});
|
|
61
|
+
export const setDatasourceStash = (tr, datasourceStash) => cardAction(tr, {
|
|
62
|
+
type: 'SET_DATASOURCE_STASH',
|
|
63
|
+
datasourceStash
|
|
64
|
+
});
|
|
65
|
+
export const removeDatasourceStash = (tr, url) => cardAction(tr, {
|
|
66
|
+
type: 'REMOVE_DATASOURCE_STASH',
|
|
67
|
+
url
|
|
60
68
|
});
|
|
@@ -6,8 +6,8 @@ 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, selectedCardAppearance } from '../utils';
|
|
10
|
-
import { hideDatasourceModal, queueCards, resolveCard } from './actions';
|
|
9
|
+
import { appearanceForNodeType, isDatasourceConfigEditable, selectedCardAppearance } from '../utils';
|
|
10
|
+
import { hideDatasourceModal, queueCards, removeDatasourceStash, resolveCard, setDatasourceStash } from './actions';
|
|
11
11
|
import { pluginKey } from './plugin-key';
|
|
12
12
|
import { shouldReplaceLink } from './shouldReplaceLink';
|
|
13
13
|
/**
|
|
@@ -228,13 +228,14 @@ export const convertHyperlinkToSmartCard = (state, source, appearance, normalize
|
|
|
228
228
|
return queueCards(requests)(state.tr);
|
|
229
229
|
};
|
|
230
230
|
export const changeSelectedCardToLink = (text, href, sendAnalytics, node, pos, editorAnalyticsApi) => (state, dispatch) => {
|
|
231
|
+
const selectedNode = state.selection instanceof NodeSelection ? state.selection.node : undefined;
|
|
231
232
|
let tr;
|
|
232
233
|
if (node && pos) {
|
|
233
234
|
tr = cardNodeToLinkWithTransaction(state, text, href, node, pos);
|
|
234
235
|
} else {
|
|
235
236
|
tr = cardToLinkWithTransaction(state, text, href);
|
|
236
237
|
}
|
|
237
|
-
|
|
238
|
+
updateDatasourceStash(tr, selectedNode);
|
|
238
239
|
if (sendAnalytics) {
|
|
239
240
|
if (selectedNode) {
|
|
240
241
|
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
|
|
@@ -329,7 +330,7 @@ export const changeSelectedCardToText = (text, editorAnalyticsApi) => (state, di
|
|
|
329
330
|
};
|
|
330
331
|
export const setSelectedCardAppearance = (appearance, editorAnalyticsApi) => (state, dispatch) => {
|
|
331
332
|
var _previousNode$type;
|
|
332
|
-
const selectedNode = state.selection instanceof NodeSelection
|
|
333
|
+
const selectedNode = state.selection instanceof NodeSelection ? state.selection.node : undefined;
|
|
333
334
|
if (!selectedNode) {
|
|
334
335
|
// When there is no selected node, we insert a new one
|
|
335
336
|
// and replace the existing blue link
|
|
@@ -364,6 +365,7 @@ export const setSelectedCardAppearance = (appearance, editorAnalyticsApi) => (st
|
|
|
364
365
|
} = state.selection;
|
|
365
366
|
const nodeType = getLinkNodeType(appearance, state.schema.nodes);
|
|
366
367
|
const tr = state.tr.setNodeMarkup(from, nodeType, attrs, selectedNode.marks);
|
|
368
|
+
updateDatasourceStash(tr, selectedNode);
|
|
367
369
|
|
|
368
370
|
// When the selected card is the last element in the doc we add a new paragraph after it for consistent replacement
|
|
369
371
|
if (tr.doc.nodeSize - 2 === to) {
|
|
@@ -404,7 +406,7 @@ export const getLinkNodeType = (appearance, linkNodes) => {
|
|
|
404
406
|
};
|
|
405
407
|
|
|
406
408
|
// Apply an update made from a datasource ui interaction
|
|
407
|
-
export const updateCardViaDatasource = (state, node, newAdf, view, sourceEvent) => {
|
|
409
|
+
export const updateCardViaDatasource = (state, node, newAdf, view, sourceEvent, isDeletingConfig) => {
|
|
408
410
|
const {
|
|
409
411
|
tr,
|
|
410
412
|
selection: {
|
|
@@ -443,7 +445,11 @@ export const updateCardViaDatasource = (state, node, newAdf, view, sourceEvent)
|
|
|
443
445
|
action: ACTION.UPDATED,
|
|
444
446
|
sourceEvent
|
|
445
447
|
});
|
|
446
|
-
|
|
448
|
+
if (isDeletingConfig) {
|
|
449
|
+
removeDatasourceStash(tr, node.attrs.url);
|
|
450
|
+
} else {
|
|
451
|
+
hideDatasourceModal(tr);
|
|
452
|
+
}
|
|
447
453
|
view.dispatch(tr.scrollIntoView());
|
|
448
454
|
};
|
|
449
455
|
export const insertDatasource = (state, adf, view, sourceEvent) => {
|
|
@@ -489,4 +495,13 @@ export const getAttrsForAppearance = (appearance, selectedNode) => {
|
|
|
489
495
|
};
|
|
490
496
|
}
|
|
491
497
|
return selectedNode.attrs;
|
|
498
|
+
};
|
|
499
|
+
const updateDatasourceStash = (tr, selectedNode) => {
|
|
500
|
+
var _selectedNode$attrs;
|
|
501
|
+
if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && selectedNode !== null && selectedNode !== void 0 && (_selectedNode$attrs = selectedNode.attrs) !== null && _selectedNode$attrs !== void 0 && _selectedNode$attrs.datasource && !isDatasourceConfigEditable(selectedNode.attrs.datasource.id)) {
|
|
502
|
+
setDatasourceStash(tr, {
|
|
503
|
+
url: selectedNode.attrs.url,
|
|
504
|
+
views: selectedNode.attrs.datasource.views
|
|
505
|
+
});
|
|
506
|
+
}
|
|
492
507
|
};
|
|
@@ -85,6 +85,27 @@ const registerRemoveOverlayOnInsertedLink = (state, action) => {
|
|
|
85
85
|
removeOverlay: action.callback
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
|
+
const setDatasourceStash = (state, action) => {
|
|
89
|
+
return {
|
|
90
|
+
...state,
|
|
91
|
+
datasourceStash: {
|
|
92
|
+
...state.datasourceStash,
|
|
93
|
+
[action.datasourceStash.url]: {
|
|
94
|
+
views: action.datasourceStash.views
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const removeDatasourceStash = (state, action) => {
|
|
100
|
+
const {
|
|
101
|
+
[action.url]: _,
|
|
102
|
+
...datasourceStash
|
|
103
|
+
} = state.datasourceStash;
|
|
104
|
+
return {
|
|
105
|
+
...state,
|
|
106
|
+
datasourceStash
|
|
107
|
+
};
|
|
108
|
+
};
|
|
88
109
|
export default ((state, action) => {
|
|
89
110
|
switch (action.type) {
|
|
90
111
|
case 'QUEUE':
|
|
@@ -114,5 +135,9 @@ export default ((state, action) => {
|
|
|
114
135
|
return clearOverlayCandidate(state);
|
|
115
136
|
case 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK':
|
|
116
137
|
return registerRemoveOverlayOnInsertedLink(state, action);
|
|
138
|
+
case 'SET_DATASOURCE_STASH':
|
|
139
|
+
return setDatasourceStash(state, action);
|
|
140
|
+
case 'REMOVE_DATASOURCE_STASH':
|
|
141
|
+
return removeDatasourceStash(state, action);
|
|
117
142
|
}
|
|
118
143
|
});
|
|
@@ -9,6 +9,7 @@ import TableIcon from '@atlaskit/icon/glyph/table';
|
|
|
9
9
|
import { buildDatasourceAdf } from '@atlaskit/link-datasource';
|
|
10
10
|
import { Flex } from '@atlaskit/primitives';
|
|
11
11
|
import { updateCardViaDatasource } from '../pm-plugins/doc';
|
|
12
|
+
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
12
13
|
import { CardContextProvider } from './CardContextProvider';
|
|
13
14
|
import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
|
|
14
15
|
const buttonStyles = css({
|
|
@@ -31,13 +32,15 @@ const DatasourceAppearanceButtonWithCardContext = ({
|
|
|
31
32
|
cardContext
|
|
32
33
|
});
|
|
33
34
|
const onChangeAppearance = useCallback(() => {
|
|
35
|
+
var _state$datasourceStas, _state$datasourceStas2;
|
|
34
36
|
if (!editorView || !datasourceId || !parameters) {
|
|
35
37
|
return;
|
|
36
38
|
}
|
|
39
|
+
const state = pluginKey.getState(editorState);
|
|
37
40
|
const newAdf = buildDatasourceAdf({
|
|
38
41
|
id: datasourceId,
|
|
39
42
|
parameters,
|
|
40
|
-
views: [{
|
|
43
|
+
views: (_state$datasourceStas = state === null || state === void 0 ? void 0 : (_state$datasourceStas2 = state.datasourceStash[url]) === null || _state$datasourceStas2 === void 0 ? void 0 : _state$datasourceStas2.views) !== null && _state$datasourceStas !== void 0 ? _state$datasourceStas : [{
|
|
41
44
|
type: 'table'
|
|
42
45
|
}]
|
|
43
46
|
}, url);
|
|
@@ -46,7 +49,7 @@ const DatasourceAppearanceButtonWithCardContext = ({
|
|
|
46
49
|
} = editorState;
|
|
47
50
|
const existingNode = selection instanceof NodeSelection ? selection.node : undefined;
|
|
48
51
|
if (existingNode) {
|
|
49
|
-
updateCardViaDatasource(editorState, existingNode, newAdf, editorView, undefined);
|
|
52
|
+
updateCardViaDatasource(editorState, existingNode, newAdf, editorView, undefined, true);
|
|
50
53
|
}
|
|
51
54
|
}, [parameters, datasourceId, editorState, editorView, url]);
|
|
52
55
|
if (!parameters || !datasourceId || !canRenderDatasource(datasourceId)) {
|
|
@@ -104,4 +104,16 @@ export var clearOverlayCandidate = function clearOverlayCandidate(tr) {
|
|
|
104
104
|
return cardAction(tr, {
|
|
105
105
|
type: 'CLEAR_OVERLAY_CANDIDATE'
|
|
106
106
|
});
|
|
107
|
+
};
|
|
108
|
+
export var setDatasourceStash = function setDatasourceStash(tr, datasourceStash) {
|
|
109
|
+
return cardAction(tr, {
|
|
110
|
+
type: 'SET_DATASOURCE_STASH',
|
|
111
|
+
datasourceStash: datasourceStash
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
export var removeDatasourceStash = function removeDatasourceStash(tr, url) {
|
|
115
|
+
return cardAction(tr, {
|
|
116
|
+
type: 'REMOVE_DATASOURCE_STASH',
|
|
117
|
+
url: url
|
|
118
|
+
});
|
|
107
119
|
};
|
|
@@ -10,8 +10,8 @@ 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, selectedCardAppearance } from '../utils';
|
|
14
|
-
import { hideDatasourceModal, queueCards, resolveCard } from './actions';
|
|
13
|
+
import { appearanceForNodeType, isDatasourceConfigEditable, selectedCardAppearance } from '../utils';
|
|
14
|
+
import { hideDatasourceModal, queueCards, removeDatasourceStash, resolveCard, setDatasourceStash } from './actions';
|
|
15
15
|
import { pluginKey } from './plugin-key';
|
|
16
16
|
import { shouldReplaceLink } from './shouldReplaceLink';
|
|
17
17
|
/**
|
|
@@ -244,13 +244,14 @@ export var convertHyperlinkToSmartCard = function convertHyperlinkToSmartCard(st
|
|
|
244
244
|
};
|
|
245
245
|
export var changeSelectedCardToLink = function changeSelectedCardToLink(text, href, sendAnalytics, node, pos, editorAnalyticsApi) {
|
|
246
246
|
return function (state, dispatch) {
|
|
247
|
+
var selectedNode = state.selection instanceof NodeSelection ? state.selection.node : undefined;
|
|
247
248
|
var tr;
|
|
248
249
|
if (node && pos) {
|
|
249
250
|
tr = cardNodeToLinkWithTransaction(state, text, href, node, pos);
|
|
250
251
|
} else {
|
|
251
252
|
tr = cardToLinkWithTransaction(state, text, href);
|
|
252
253
|
}
|
|
253
|
-
|
|
254
|
+
updateDatasourceStash(tr, selectedNode);
|
|
254
255
|
if (sendAnalytics) {
|
|
255
256
|
if (selectedNode) {
|
|
256
257
|
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
@@ -349,7 +350,7 @@ export var changeSelectedCardToText = function changeSelectedCardToText(text, ed
|
|
|
349
350
|
export var setSelectedCardAppearance = function setSelectedCardAppearance(appearance, editorAnalyticsApi) {
|
|
350
351
|
return function (state, dispatch) {
|
|
351
352
|
var _previousNode$type;
|
|
352
|
-
var selectedNode = state.selection instanceof NodeSelection
|
|
353
|
+
var selectedNode = state.selection instanceof NodeSelection ? state.selection.node : undefined;
|
|
353
354
|
if (!selectedNode) {
|
|
354
355
|
// When there is no selected node, we insert a new one
|
|
355
356
|
// and replace the existing blue link
|
|
@@ -382,6 +383,7 @@ export var setSelectedCardAppearance = function setSelectedCardAppearance(appear
|
|
|
382
383
|
to = _state$selection.to;
|
|
383
384
|
var nodeType = getLinkNodeType(appearance, state.schema.nodes);
|
|
384
385
|
var tr = state.tr.setNodeMarkup(from, nodeType, attrs, selectedNode.marks);
|
|
386
|
+
updateDatasourceStash(tr, selectedNode);
|
|
385
387
|
|
|
386
388
|
// When the selected card is the last element in the doc we add a new paragraph after it for consistent replacement
|
|
387
389
|
if (tr.doc.nodeSize - 2 === to) {
|
|
@@ -423,7 +425,7 @@ export var getLinkNodeType = function getLinkNodeType(appearance, linkNodes) {
|
|
|
423
425
|
};
|
|
424
426
|
|
|
425
427
|
// Apply an update made from a datasource ui interaction
|
|
426
|
-
export var updateCardViaDatasource = function updateCardViaDatasource(state, node, newAdf, view, sourceEvent) {
|
|
428
|
+
export var updateCardViaDatasource = function updateCardViaDatasource(state, node, newAdf, view, sourceEvent, isDeletingConfig) {
|
|
427
429
|
var tr = state.tr,
|
|
428
430
|
from = state.selection.from,
|
|
429
431
|
schemaNodes = state.schema.nodes;
|
|
@@ -461,7 +463,11 @@ export var updateCardViaDatasource = function updateCardViaDatasource(state, nod
|
|
|
461
463
|
action: ACTION.UPDATED,
|
|
462
464
|
sourceEvent: sourceEvent
|
|
463
465
|
});
|
|
464
|
-
|
|
466
|
+
if (isDeletingConfig) {
|
|
467
|
+
removeDatasourceStash(tr, node.attrs.url);
|
|
468
|
+
} else {
|
|
469
|
+
hideDatasourceModal(tr);
|
|
470
|
+
}
|
|
465
471
|
view.dispatch(tr.scrollIntoView());
|
|
466
472
|
};
|
|
467
473
|
export var insertDatasource = function insertDatasource(state, adf, view, sourceEvent) {
|
|
@@ -498,4 +504,13 @@ export var getAttrsForAppearance = function getAttrsForAppearance(appearance, se
|
|
|
498
504
|
};
|
|
499
505
|
}
|
|
500
506
|
return selectedNode.attrs;
|
|
507
|
+
};
|
|
508
|
+
var updateDatasourceStash = function updateDatasourceStash(tr, selectedNode) {
|
|
509
|
+
var _selectedNode$attrs;
|
|
510
|
+
if (getBooleanFF('platform.linking-platform.enable-datasource-appearance-toolbar') && selectedNode !== null && selectedNode !== void 0 && (_selectedNode$attrs = selectedNode.attrs) !== null && _selectedNode$attrs !== void 0 && _selectedNode$attrs.datasource && !isDatasourceConfigEditable(selectedNode.attrs.datasource.id)) {
|
|
511
|
+
setDatasourceStash(tr, {
|
|
512
|
+
url: selectedNode.attrs.url,
|
|
513
|
+
views: selectedNode.attrs.datasource.views
|
|
514
|
+
});
|
|
515
|
+
}
|
|
501
516
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
5
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
2
6
|
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
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
8
|
var queue = function queue(state, action) {
|
|
@@ -77,6 +81,22 @@ var registerRemoveOverlayOnInsertedLink = function registerRemoveOverlayOnInsert
|
|
|
77
81
|
removeOverlay: action.callback
|
|
78
82
|
});
|
|
79
83
|
};
|
|
84
|
+
var setDatasourceStash = function setDatasourceStash(state, action) {
|
|
85
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
86
|
+
datasourceStash: _objectSpread(_objectSpread({}, state.datasourceStash), {}, _defineProperty({}, action.datasourceStash.url, {
|
|
87
|
+
views: action.datasourceStash.views
|
|
88
|
+
}))
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
var removeDatasourceStash = function removeDatasourceStash(state, action) {
|
|
92
|
+
var _state$datasourceStas = state.datasourceStash,
|
|
93
|
+
_action$url = action.url,
|
|
94
|
+
_ = _state$datasourceStas[_action$url],
|
|
95
|
+
datasourceStash = _objectWithoutProperties(_state$datasourceStas, [_action$url].map(_toPropertyKey));
|
|
96
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
97
|
+
datasourceStash: datasourceStash
|
|
98
|
+
});
|
|
99
|
+
};
|
|
80
100
|
export default (function (state, action) {
|
|
81
101
|
switch (action.type) {
|
|
82
102
|
case 'QUEUE':
|
|
@@ -106,5 +126,9 @@ export default (function (state, action) {
|
|
|
106
126
|
return clearOverlayCandidate(state);
|
|
107
127
|
case 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK':
|
|
108
128
|
return registerRemoveOverlayOnInsertedLink(state, action);
|
|
129
|
+
case 'SET_DATASOURCE_STASH':
|
|
130
|
+
return setDatasourceStash(state, action);
|
|
131
|
+
case 'REMOVE_DATASOURCE_STASH':
|
|
132
|
+
return removeDatasourceStash(state, action);
|
|
109
133
|
}
|
|
110
134
|
});
|
|
@@ -9,6 +9,7 @@ import TableIcon from '@atlaskit/icon/glyph/table';
|
|
|
9
9
|
import { buildDatasourceAdf } from '@atlaskit/link-datasource';
|
|
10
10
|
import { Flex } from '@atlaskit/primitives';
|
|
11
11
|
import { updateCardViaDatasource } from '../pm-plugins/doc';
|
|
12
|
+
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
12
13
|
import { CardContextProvider } from './CardContextProvider';
|
|
13
14
|
import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
|
|
14
15
|
var buttonStyles = css({
|
|
@@ -29,20 +30,22 @@ var DatasourceAppearanceButtonWithCardContext = function DatasourceAppearanceBut
|
|
|
29
30
|
datasourceId = _useFetchDatasourceIn.datasourceId,
|
|
30
31
|
parameters = _useFetchDatasourceIn.parameters;
|
|
31
32
|
var onChangeAppearance = useCallback(function () {
|
|
33
|
+
var _state$datasourceStas, _state$datasourceStas2;
|
|
32
34
|
if (!editorView || !datasourceId || !parameters) {
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
37
|
+
var state = pluginKey.getState(editorState);
|
|
35
38
|
var newAdf = buildDatasourceAdf({
|
|
36
39
|
id: datasourceId,
|
|
37
40
|
parameters: parameters,
|
|
38
|
-
views: [{
|
|
41
|
+
views: (_state$datasourceStas = state === null || state === void 0 || (_state$datasourceStas2 = state.datasourceStash[url]) === null || _state$datasourceStas2 === void 0 ? void 0 : _state$datasourceStas2.views) !== null && _state$datasourceStas !== void 0 ? _state$datasourceStas : [{
|
|
39
42
|
type: 'table'
|
|
40
43
|
}]
|
|
41
44
|
}, url);
|
|
42
45
|
var selection = editorState.selection;
|
|
43
46
|
var existingNode = selection instanceof NodeSelection ? selection.node : undefined;
|
|
44
47
|
if (existingNode) {
|
|
45
|
-
updateCardViaDatasource(editorState, existingNode, newAdf, editorView, undefined);
|
|
48
|
+
updateCardViaDatasource(editorState, existingNode, newAdf, editorView, undefined, true);
|
|
46
49
|
}
|
|
47
50
|
}, [parameters, datasourceId, editorState, editorView, url]);
|
|
48
51
|
if (!parameters || !datasourceId || !canRenderDatasource(datasourceId)) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
2
2
|
import type { DatasourceModalType } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import type { DatasourceAdfView } from '@atlaskit/linking-common';
|
|
4
5
|
import type { SmartLinkEvents } from '@atlaskit/smart-card';
|
|
5
6
|
import type { CardInfo, CardPluginAction, Request } from '../types';
|
|
6
7
|
import type { DatasourceTableLayout } from '../ui/LayoutButton/types';
|
|
@@ -22,3 +23,8 @@ export declare const hideLinkToolbar: (tr: Transaction) => Transaction;
|
|
|
22
23
|
export declare const showDatasourceModal: (modalType: DatasourceModalType) => (tr: Transaction) => Transaction;
|
|
23
24
|
export declare const hideDatasourceModal: (tr: Transaction) => Transaction;
|
|
24
25
|
export declare const clearOverlayCandidate: (tr: Transaction) => Transaction;
|
|
26
|
+
export declare const setDatasourceStash: (tr: Transaction, datasourceStash: {
|
|
27
|
+
url: string;
|
|
28
|
+
views: DatasourceAdfView[];
|
|
29
|
+
}) => Transaction;
|
|
30
|
+
export declare const removeDatasourceStash: (tr: Transaction, url: string) => Transaction;
|
|
@@ -23,7 +23,7 @@ export type LinkNodes = {
|
|
|
23
23
|
[key in 'inlineCard' | 'blockCard' | 'embedCard']: NodeType;
|
|
24
24
|
};
|
|
25
25
|
export declare const getLinkNodeType: (appearance: CardAppearance, linkNodes: LinkNodes) => NodeType;
|
|
26
|
-
export declare const updateCardViaDatasource: (state: EditorState, node: Node, newAdf: DatasourceAdf | InlineCardAdf, view: EditorView, sourceEvent?: UIAnalyticsEvent) => void;
|
|
26
|
+
export declare const updateCardViaDatasource: (state: EditorState, node: Node, newAdf: DatasourceAdf | InlineCardAdf, view: EditorView, sourceEvent?: UIAnalyticsEvent, isDeletingConfig?: boolean) => void;
|
|
27
27
|
export declare const insertDatasource: (state: EditorState, adf: DatasourceAdf | InlineCardAdf, view: EditorView, sourceEvent?: UIAnalyticsEvent) => void;
|
|
28
28
|
/**
|
|
29
29
|
* Get attributes for new Card Appearance
|
|
@@ -19,6 +19,11 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
|
|
|
19
19
|
url?: string | undefined;
|
|
20
20
|
}[];
|
|
21
21
|
provider: import("@atlaskit/editor-common/provider-factory").CardProvider | null;
|
|
22
|
+
datasourceStash: {
|
|
23
|
+
[x: string]: {
|
|
24
|
+
views: import("@atlaskit/linking-common").DatasourceAdfTableView[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
22
27
|
showLinkingToolbar: boolean;
|
|
23
28
|
smartLinkEvents?: import("@atlaskit/smart-card").SmartLinkEvents | undefined;
|
|
24
29
|
editorAppearance?: import("@atlaskit/editor-common/types").EditorAppearance | undefined;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ACTION } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import type { CardOptions, CardReplacementInputMethod } from '@atlaskit/editor-common/card';
|
|
4
4
|
import type { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
5
5
|
import type { DatasourceModalType, EditorAppearance, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { DatasourceAdfView } from '@atlaskit/linking-common';
|
|
6
7
|
import type { SmartLinkEvents } from '@atlaskit/smart-card';
|
|
7
8
|
import type { EditorCardPluginEvents } from './analytics/create-events-queue';
|
|
8
9
|
import type { CardPluginEvent } from './analytics/types';
|
|
@@ -65,10 +66,18 @@ export type Request = {
|
|
|
65
66
|
*/
|
|
66
67
|
sourceEvent?: UIAnalyticsEvent | null | undefined;
|
|
67
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* Each key in the stash is URL.
|
|
71
|
+
* For any given URL we might temporarily stash some user preferences, like view settings for the datasource.
|
|
72
|
+
*/
|
|
73
|
+
type DatasourceStash = Record<string, {
|
|
74
|
+
views: DatasourceAdfView[];
|
|
75
|
+
}>;
|
|
68
76
|
export type CardPluginState = {
|
|
69
77
|
requests: Request[];
|
|
70
78
|
provider: CardProvider | null;
|
|
71
79
|
cards: CardInfo[];
|
|
80
|
+
datasourceStash: DatasourceStash;
|
|
72
81
|
showLinkingToolbar: boolean;
|
|
73
82
|
smartLinkEvents?: SmartLinkEvents;
|
|
74
83
|
editorAppearance?: EditorAppearance;
|
|
@@ -144,4 +153,16 @@ export type RegisterRemoveOverlayOnInsertedLink = {
|
|
|
144
153
|
type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK';
|
|
145
154
|
callback: () => void;
|
|
146
155
|
};
|
|
147
|
-
export type
|
|
156
|
+
export type SetDatasourceStash = {
|
|
157
|
+
type: 'SET_DATASOURCE_STASH';
|
|
158
|
+
datasourceStash: {
|
|
159
|
+
url: string;
|
|
160
|
+
views: DatasourceAdfView[];
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
export type RemoveDatasourceStash = {
|
|
164
|
+
type: 'REMOVE_DATASOURCE_STASH';
|
|
165
|
+
url: string;
|
|
166
|
+
};
|
|
167
|
+
export type CardPluginAction = SetProvider | Queue | Resolve | Register | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
|
|
168
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
2
2
|
import type { DatasourceModalType } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import type { DatasourceAdfView } from '@atlaskit/linking-common';
|
|
4
5
|
import type { SmartLinkEvents } from '@atlaskit/smart-card';
|
|
5
6
|
import type { CardInfo, CardPluginAction, Request } from '../types';
|
|
6
7
|
import type { DatasourceTableLayout } from '../ui/LayoutButton/types';
|
|
@@ -22,3 +23,8 @@ export declare const hideLinkToolbar: (tr: Transaction) => Transaction;
|
|
|
22
23
|
export declare const showDatasourceModal: (modalType: DatasourceModalType) => (tr: Transaction) => Transaction;
|
|
23
24
|
export declare const hideDatasourceModal: (tr: Transaction) => Transaction;
|
|
24
25
|
export declare const clearOverlayCandidate: (tr: Transaction) => Transaction;
|
|
26
|
+
export declare const setDatasourceStash: (tr: Transaction, datasourceStash: {
|
|
27
|
+
url: string;
|
|
28
|
+
views: DatasourceAdfView[];
|
|
29
|
+
}) => Transaction;
|
|
30
|
+
export declare const removeDatasourceStash: (tr: Transaction, url: string) => Transaction;
|
|
@@ -23,7 +23,7 @@ export type LinkNodes = {
|
|
|
23
23
|
[key in 'inlineCard' | 'blockCard' | 'embedCard']: NodeType;
|
|
24
24
|
};
|
|
25
25
|
export declare const getLinkNodeType: (appearance: CardAppearance, linkNodes: LinkNodes) => NodeType;
|
|
26
|
-
export declare const updateCardViaDatasource: (state: EditorState, node: Node, newAdf: DatasourceAdf | InlineCardAdf, view: EditorView, sourceEvent?: UIAnalyticsEvent) => void;
|
|
26
|
+
export declare const updateCardViaDatasource: (state: EditorState, node: Node, newAdf: DatasourceAdf | InlineCardAdf, view: EditorView, sourceEvent?: UIAnalyticsEvent, isDeletingConfig?: boolean) => void;
|
|
27
27
|
export declare const insertDatasource: (state: EditorState, adf: DatasourceAdf | InlineCardAdf, view: EditorView, sourceEvent?: UIAnalyticsEvent) => void;
|
|
28
28
|
/**
|
|
29
29
|
* Get attributes for new Card Appearance
|
|
@@ -19,6 +19,11 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
|
|
|
19
19
|
url?: string | undefined;
|
|
20
20
|
}[];
|
|
21
21
|
provider: import("@atlaskit/editor-common/provider-factory").CardProvider | null;
|
|
22
|
+
datasourceStash: {
|
|
23
|
+
[x: string]: {
|
|
24
|
+
views: import("@atlaskit/linking-common").DatasourceAdfTableView[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
22
27
|
showLinkingToolbar: boolean;
|
|
23
28
|
smartLinkEvents?: import("@atlaskit/smart-card").SmartLinkEvents | undefined;
|
|
24
29
|
editorAppearance?: import("@atlaskit/editor-common/types").EditorAppearance | undefined;
|
|
@@ -3,6 +3,7 @@ import type { ACTION } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import type { CardOptions, CardReplacementInputMethod } from '@atlaskit/editor-common/card';
|
|
4
4
|
import type { CardAppearance, CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
5
5
|
import type { DatasourceModalType, EditorAppearance, LinkPickerOptions } from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { DatasourceAdfView } from '@atlaskit/linking-common';
|
|
6
7
|
import type { SmartLinkEvents } from '@atlaskit/smart-card';
|
|
7
8
|
import type { EditorCardPluginEvents } from './analytics/create-events-queue';
|
|
8
9
|
import type { CardPluginEvent } from './analytics/types';
|
|
@@ -65,10 +66,18 @@ export type Request = {
|
|
|
65
66
|
*/
|
|
66
67
|
sourceEvent?: UIAnalyticsEvent | null | undefined;
|
|
67
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* Each key in the stash is URL.
|
|
71
|
+
* For any given URL we might temporarily stash some user preferences, like view settings for the datasource.
|
|
72
|
+
*/
|
|
73
|
+
type DatasourceStash = Record<string, {
|
|
74
|
+
views: DatasourceAdfView[];
|
|
75
|
+
}>;
|
|
68
76
|
export type CardPluginState = {
|
|
69
77
|
requests: Request[];
|
|
70
78
|
provider: CardProvider | null;
|
|
71
79
|
cards: CardInfo[];
|
|
80
|
+
datasourceStash: DatasourceStash;
|
|
72
81
|
showLinkingToolbar: boolean;
|
|
73
82
|
smartLinkEvents?: SmartLinkEvents;
|
|
74
83
|
editorAppearance?: EditorAppearance;
|
|
@@ -144,4 +153,16 @@ export type RegisterRemoveOverlayOnInsertedLink = {
|
|
|
144
153
|
type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK';
|
|
145
154
|
callback: () => void;
|
|
146
155
|
};
|
|
147
|
-
export type
|
|
156
|
+
export type SetDatasourceStash = {
|
|
157
|
+
type: 'SET_DATASOURCE_STASH';
|
|
158
|
+
datasourceStash: {
|
|
159
|
+
url: string;
|
|
160
|
+
views: DatasourceAdfView[];
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
export type RemoveDatasourceStash = {
|
|
164
|
+
type: 'REMOVE_DATASOURCE_STASH';
|
|
165
|
+
url: string;
|
|
166
|
+
};
|
|
167
|
+
export type CardPluginAction = SetProvider | Queue | Resolve | Register | ShowLinkToolbar | HideLinkToolbar | ShowDatasourceModal | HideDatasourceModal | RegisterSmartCardEvents | SetDatasourceTableRef | SetCardLayout | SetCardLayoutAndDatasourceTableRef | ClearOverlayCandidate | RegisterRemoveOverlayOnInsertedLink | SetDatasourceStash | RemoveDatasourceStash;
|
|
168
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,28 +35,28 @@
|
|
|
35
35
|
"@atlaskit/adf-schema": "^35.5.1",
|
|
36
36
|
"@atlaskit/analytics-next": "^9.2.0",
|
|
37
37
|
"@atlaskit/custom-steps": "^0.0.13",
|
|
38
|
-
"@atlaskit/editor-common": "^78.
|
|
38
|
+
"@atlaskit/editor-common": "^78.4.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
40
40
|
"@atlaskit/editor-plugin-decorations": "^1.0.0",
|
|
41
41
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
42
|
-
"@atlaskit/editor-plugin-floating-toolbar": "^1.
|
|
42
|
+
"@atlaskit/editor-plugin-floating-toolbar": "^1.2.0",
|
|
43
43
|
"@atlaskit/editor-plugin-grid": "^1.0.0",
|
|
44
44
|
"@atlaskit/editor-plugin-hyperlink": "^1.0.0",
|
|
45
45
|
"@atlaskit/editor-plugin-width": "^1.0.0",
|
|
46
46
|
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
47
47
|
"@atlaskit/editor-shared-styles": "^2.9.0",
|
|
48
48
|
"@atlaskit/frontend-utilities": "^2.7.0",
|
|
49
|
-
"@atlaskit/icon": "^22.
|
|
49
|
+
"@atlaskit/icon": "^22.1.0",
|
|
50
50
|
"@atlaskit/link-analytics": "^8.3.0",
|
|
51
51
|
"@atlaskit/link-client-extension": "^1.8.0",
|
|
52
52
|
"@atlaskit/link-datasource": "^1.22.0",
|
|
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": "^2.
|
|
56
|
+
"@atlaskit/primitives": "^2.1.0",
|
|
57
57
|
"@atlaskit/smart-card": "^26.47.0",
|
|
58
58
|
"@atlaskit/theme": "^12.6.0",
|
|
59
|
-
"@atlaskit/tokens": "^1.
|
|
59
|
+
"@atlaskit/tokens": "^1.38.0",
|
|
60
60
|
"@babel/runtime": "^7.0.0",
|
|
61
61
|
"@emotion/react": "^11.7.1",
|
|
62
62
|
"lodash": "^4.17.21",
|