@atlaskit/editor-plugin-card 0.2.5 → 0.3.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 +12 -0
- package/dist/cjs/pm-plugins/analytics/events-from-tr.js +3 -3
- package/dist/cjs/pm-plugins/doc.js +9 -9
- package/dist/cjs/pm-plugins/keymap.js +7 -7
- package/dist/cjs/pm-plugins/main.js +9 -9
- package/dist/cjs/pm-plugins/mountHyperlink.js +22 -2
- package/dist/cjs/pm-plugins/plugin-key.js +2 -2
- package/dist/cjs/toolbar.js +39 -17
- package/dist/cjs/ui/CardContextProvider.js +45 -0
- package/dist/cjs/ui/DatasourceModal/index.js +2 -2
- package/dist/cjs/ui/EditLinkToolbar.js +2 -2
- package/dist/cjs/ui/EditorAnalyticsContext.js +32 -0
- package/dist/cjs/ui/EditorSmartCardEventsNext.js +3 -14
- package/dist/cjs/ui/LayoutButton/utils.js +2 -2
- package/dist/cjs/ui/LinkToolbarAppearance.js +3 -3
- package/dist/cjs/ui/ResizableEmbedCard.js +4 -4
- package/dist/cjs/ui/ToolbarViewedEvent.js +73 -0
- package/dist/cjs/utils.js +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/pm-plugins/analytics/events-from-tr.js +1 -1
- package/dist/es2019/pm-plugins/doc.js +2 -2
- package/dist/es2019/pm-plugins/keymap.js +3 -3
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/es2019/pm-plugins/mountHyperlink.js +18 -1
- package/dist/es2019/pm-plugins/plugin-key.js +1 -1
- package/dist/es2019/toolbar.js +23 -3
- package/dist/es2019/ui/CardContextProvider.js +19 -0
- package/dist/es2019/ui/DatasourceModal/index.js +1 -1
- package/dist/es2019/ui/EditLinkToolbar.js +1 -1
- package/dist/es2019/ui/EditorAnalyticsContext.js +25 -0
- package/dist/es2019/ui/EditorSmartCardEventsNext.js +4 -15
- package/dist/es2019/ui/LayoutButton/utils.js +1 -1
- package/dist/es2019/ui/LinkToolbarAppearance.js +1 -1
- package/dist/es2019/ui/ResizableEmbedCard.js +1 -1
- package/dist/es2019/ui/ToolbarViewedEvent.js +62 -0
- package/dist/es2019/utils.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/pm-plugins/analytics/events-from-tr.js +1 -1
- package/dist/esm/pm-plugins/doc.js +2 -2
- package/dist/esm/pm-plugins/keymap.js +3 -3
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/esm/pm-plugins/mountHyperlink.js +22 -2
- package/dist/esm/pm-plugins/plugin-key.js +1 -1
- package/dist/esm/toolbar.js +26 -4
- package/dist/esm/ui/CardContextProvider.js +36 -0
- package/dist/esm/ui/DatasourceModal/index.js +1 -1
- package/dist/esm/ui/EditLinkToolbar.js +1 -1
- package/dist/esm/ui/EditorAnalyticsContext.js +24 -0
- package/dist/esm/ui/EditorSmartCardEventsNext.js +4 -15
- package/dist/esm/ui/LayoutButton/utils.js +1 -1
- package/dist/esm/ui/LinkToolbarAppearance.js +1 -1
- package/dist/esm/ui/ResizableEmbedCard.js +1 -1
- package/dist/esm/ui/ToolbarViewedEvent.js +62 -0
- package/dist/esm/utils.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/nodeviews/datasource.d.ts +2 -2
- package/dist/types/nodeviews/embedCard.d.ts +1 -1
- package/dist/types/nodeviews/genericCard.d.ts +2 -2
- package/dist/types/pm-plugins/actions.d.ts +1 -1
- package/dist/types/pm-plugins/analytics/events-from-tr.d.ts +1 -1
- package/dist/types/pm-plugins/analytics/types.d.ts +1 -1
- package/dist/types/pm-plugins/analytics/utils.d.ts +2 -2
- package/dist/types/pm-plugins/doc.d.ts +3 -3
- package/dist/types/pm-plugins/plugin-key.d.ts +1 -1
- package/dist/types/pm-plugins/shouldReplaceLink.d.ts +1 -1
- package/dist/types/pm-plugins/util/resolve.d.ts +1 -1
- package/dist/types/pm-plugins/util/state.d.ts +1 -1
- package/dist/types/ui/CardContextProvider.d.ts +19 -0
- package/dist/types/ui/DatasourceModal/ModalWithState.d.ts +1 -1
- package/dist/types/ui/DatasourceModal/index.d.ts +1 -1
- package/dist/types/ui/EditLinkToolbar.d.ts +2 -2
- package/dist/types/ui/EditorAnalyticsContext.d.ts +10 -0
- package/dist/types/ui/EditorSmartCardEvents.d.ts +1 -1
- package/dist/types/ui/EditorSmartCardEventsNext.d.ts +1 -1
- package/dist/types/ui/HyperlinkToolbarAppearance.d.ts +2 -2
- package/dist/types/ui/LayoutButton/types.d.ts +1 -1
- package/dist/types/ui/LayoutButton/utils.d.ts +1 -1
- package/dist/types/ui/LinkToolbarAppearance.d.ts +2 -2
- package/dist/types/ui/ToolbarViewedEvent.d.ts +11 -0
- package/dist/types/utils.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/datasource.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/genericCard.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/analytics/events-from-tr.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/analytics/types.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/analytics/utils.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/doc.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/plugin-key.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/shouldReplaceLink.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/util/resolve.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/util/state.d.ts +1 -1
- package/dist/types-ts4.5/ui/CardContextProvider.d.ts +19 -0
- package/dist/types-ts4.5/ui/DatasourceModal/ModalWithState.d.ts +1 -1
- package/dist/types-ts4.5/ui/DatasourceModal/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/EditLinkToolbar.d.ts +2 -2
- package/dist/types-ts4.5/ui/EditorAnalyticsContext.d.ts +10 -0
- package/dist/types-ts4.5/ui/EditorSmartCardEvents.d.ts +1 -1
- package/dist/types-ts4.5/ui/EditorSmartCardEventsNext.d.ts +1 -1
- package/dist/types-ts4.5/ui/HyperlinkToolbarAppearance.d.ts +2 -2
- package/dist/types-ts4.5/ui/LayoutButton/types.d.ts +1 -1
- package/dist/types-ts4.5/ui/LayoutButton/utils.d.ts +1 -1
- package/dist/types-ts4.5/ui/LinkToolbarAppearance.d.ts +2 -2
- package/dist/types-ts4.5/ui/ToolbarViewedEvent.d.ts +11 -0
- package/dist/types-ts4.5/utils.d.ts +2 -2
- package/package.json +10 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4e6f1bf8511`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4e6f1bf8511) - [ED-19233] Import prosemirror libraries from internal facade package
|
|
8
|
+
|
|
9
|
+
## 0.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`632edbf1930`](https://bitbucket.org/atlassian/atlassian-frontend/commits/632edbf1930) - Updates card plugin floating toolbar to fire an analytic event when viewed.
|
|
14
|
+
|
|
3
15
|
## 0.2.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -9,11 +9,11 @@ exports.findChangedLinks = void 0;
|
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
|
-
var _prosemirrorTransform = require("prosemirror-transform");
|
|
13
12
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
14
13
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
15
14
|
var _card = require("@atlaskit/editor-common/card");
|
|
16
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
17
17
|
var _pluginKey = require("../plugin-key");
|
|
18
18
|
var _state = require("../util/state");
|
|
19
19
|
var _utils2 = require("./utils");
|
|
@@ -61,7 +61,7 @@ var findChangedLinks = function findChangedLinks(tr, state) {
|
|
|
61
61
|
* because there are no "changed tokens" only marks added/removed
|
|
62
62
|
* So have to check these manually
|
|
63
63
|
*/
|
|
64
|
-
if (step instanceof
|
|
64
|
+
if (step instanceof _transform.AddMarkStep) {
|
|
65
65
|
var addMarkStep = step;
|
|
66
66
|
if ((0, _utils.isLinkMark)(addMarkStep.mark, schema)) {
|
|
67
67
|
/**
|
|
@@ -75,7 +75,7 @@ var findChangedLinks = function findChangedLinks(tr, state) {
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
if (step instanceof
|
|
78
|
+
if (step instanceof _transform.RemoveMarkStep) {
|
|
79
79
|
var removeMarkStep = step;
|
|
80
80
|
if ((0, _utils.isLinkMark)(removeMarkStep.mark, schema)) {
|
|
81
81
|
removedInStep.push({
|
|
@@ -8,12 +8,12 @@ exports.updateExistingDatasource = exports.updateCard = exports.setSelectedCardA
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
11
|
-
var _prosemirrorHistory = require("prosemirror-history");
|
|
12
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
13
11
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
14
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
15
13
|
var _card = require("@atlaskit/editor-common/card");
|
|
16
14
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
|
+
var _history = require("@atlaskit/editor-prosemirror/history");
|
|
16
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
17
17
|
var _utils2 = require("../utils");
|
|
18
18
|
var _actions = require("./actions");
|
|
19
19
|
var _pluginKey = require("./plugin-key");
|
|
@@ -122,7 +122,7 @@ var replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, cardData,
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
if (dispatch) {
|
|
125
|
-
dispatch((0, _actions.resolveCard)(url)((0,
|
|
125
|
+
dispatch((0, _actions.resolveCard)(url)((0, _history.closeHistory)(tr)));
|
|
126
126
|
}
|
|
127
127
|
return true;
|
|
128
128
|
};
|
|
@@ -259,7 +259,7 @@ var changeSelectedCardToLink = function changeSelectedCardToLink(text, href, sen
|
|
|
259
259
|
} else {
|
|
260
260
|
tr = cardToLinkWithTransaction(state, text, href);
|
|
261
261
|
}
|
|
262
|
-
var selectedNode = state.selection instanceof
|
|
262
|
+
var selectedNode = state.selection instanceof _state.NodeSelection && state.selection.node;
|
|
263
263
|
if (sendAnalytics) {
|
|
264
264
|
if (selectedNode) {
|
|
265
265
|
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
|
|
@@ -307,7 +307,7 @@ var changeSelectedCardToLinkFallback = function changeSelectedCardToLinkFallback
|
|
|
307
307
|
exports.changeSelectedCardToLinkFallback = changeSelectedCardToLinkFallback;
|
|
308
308
|
var updateCard = function updateCard(href, sourceEvent) {
|
|
309
309
|
return function (state, dispatch) {
|
|
310
|
-
var selectedNode = state.selection instanceof
|
|
310
|
+
var selectedNode = state.selection instanceof _state.NodeSelection && state.selection.node;
|
|
311
311
|
if (!selectedNode) {
|
|
312
312
|
return false;
|
|
313
313
|
}
|
|
@@ -322,7 +322,7 @@ var updateCard = function updateCard(href, sourceEvent) {
|
|
|
322
322
|
};
|
|
323
323
|
exports.updateCard = updateCard;
|
|
324
324
|
function cardToLinkWithTransaction(state, text, href) {
|
|
325
|
-
var selectedNode = state.selection instanceof
|
|
325
|
+
var selectedNode = state.selection instanceof _state.NodeSelection && state.selection.node;
|
|
326
326
|
if (!selectedNode) {
|
|
327
327
|
return state.tr;
|
|
328
328
|
}
|
|
@@ -342,7 +342,7 @@ function cardNodeToLinkWithTransaction(state, text, href, node, pos) {
|
|
|
342
342
|
}
|
|
343
343
|
var changeSelectedCardToText = function changeSelectedCardToText(text, editorAnalyticsApi) {
|
|
344
344
|
return function (state, dispatch) {
|
|
345
|
-
var selectedNode = state.selection instanceof
|
|
345
|
+
var selectedNode = state.selection instanceof _state.NodeSelection && state.selection.node;
|
|
346
346
|
if (!selectedNode) {
|
|
347
347
|
return false;
|
|
348
348
|
}
|
|
@@ -362,7 +362,7 @@ exports.changeSelectedCardToText = changeSelectedCardToText;
|
|
|
362
362
|
var setSelectedCardAppearance = function setSelectedCardAppearance(appearance, editorAnalyticsApi) {
|
|
363
363
|
return function (state, dispatch) {
|
|
364
364
|
var _previousNode$type;
|
|
365
|
-
var selectedNode = state.selection instanceof
|
|
365
|
+
var selectedNode = state.selection instanceof _state.NodeSelection && state.selection.node;
|
|
366
366
|
if (!selectedNode) {
|
|
367
367
|
// When there is no selected node, we insert a new one
|
|
368
368
|
// and replace the existing blue link
|
|
@@ -392,7 +392,7 @@ var setSelectedCardAppearance = function setSelectedCardAppearance(appearance, e
|
|
|
392
392
|
if (tr.doc.nodeSize - 2 === to) {
|
|
393
393
|
tr.insertText(' ', to);
|
|
394
394
|
}
|
|
395
|
-
tr.setSelection(
|
|
395
|
+
tr.setSelection(_state.TextSelection.create(tr.doc, to + 1));
|
|
396
396
|
var previousNodePos = from - 1 > 0 ? from - 1 : 0;
|
|
397
397
|
var previousNode = tr.doc.nodeAt(previousNodePos);
|
|
398
398
|
if ((previousNode === null || previousNode === void 0 ? void 0 : (_previousNode$type = previousNode.type) === null || _previousNode$type === void 0 ? void 0 : _previousNode$type.name) === 'paragraph') {
|
|
@@ -4,18 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.cardKeymap = cardKeymap;
|
|
7
|
-
var _prosemirrorKeymap = require("prosemirror-keymap");
|
|
8
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
-
var _prosemirrorUtils = require("prosemirror-utils");
|
|
10
7
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
11
8
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
|
+
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
10
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
12
12
|
var lookupPixel = 10;
|
|
13
13
|
var getClosestInlineCardPos = function getClosestInlineCardPos(state, editorView, direction) {
|
|
14
14
|
var _editorView$posAtCoor;
|
|
15
15
|
var selection = state.selection;
|
|
16
16
|
var parent = selection.$from.parent;
|
|
17
17
|
var inlineCardType = state.schema.nodes.inlineCard;
|
|
18
|
-
if (!(0,
|
|
18
|
+
if (!(0, _utils2.flatten)(parent, false).some(function (_ref) {
|
|
19
19
|
var node = _ref.node;
|
|
20
20
|
return node.type === inlineCardType;
|
|
21
21
|
})) {
|
|
@@ -29,7 +29,7 @@ var getClosestInlineCardPos = function getClosestInlineCardPos(state, editorView
|
|
|
29
29
|
if (nearPos) {
|
|
30
30
|
var newNode = state.doc.nodeAt(nearPos);
|
|
31
31
|
if (newNode) {
|
|
32
|
-
if (newNode.type !== inlineCardType || (0,
|
|
32
|
+
if (newNode.type !== inlineCardType || (0, _utils2.findChildren)(parent, function (node) {
|
|
33
33
|
return node === newNode;
|
|
34
34
|
}, false).length === 0 || newNode === selection.node) {
|
|
35
35
|
return null;
|
|
@@ -46,7 +46,7 @@ var selectAboveBelowInlineCard = function selectAboveBelowInlineCard(direction)
|
|
|
46
46
|
}
|
|
47
47
|
var pos = getClosestInlineCardPos(state, editorView, direction);
|
|
48
48
|
if (pos) {
|
|
49
|
-
dispatch(state.tr.setSelection(new
|
|
49
|
+
dispatch(state.tr.setSelection(new _state.NodeSelection(state.doc.resolve(pos))));
|
|
50
50
|
return true;
|
|
51
51
|
}
|
|
52
52
|
return false;
|
|
@@ -60,5 +60,5 @@ function cardKeymap(featureFlags) {
|
|
|
60
60
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveUp.common, selectAboveBelowInlineCard('up'), list);
|
|
61
61
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveDown.common, selectAboveBelowInlineCard('down'), list);
|
|
62
62
|
}
|
|
63
|
-
return (0,
|
|
63
|
+
return (0, _keymap.keymap)(list);
|
|
64
64
|
}
|
|
@@ -12,13 +12,13 @@ Object.defineProperty(exports, "pluginKey", {
|
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
16
|
-
var _prosemirrorUtils = require("prosemirror-utils");
|
|
17
15
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
18
16
|
var _reactNodeView = require("@atlaskit/editor-common/react-node-view");
|
|
19
17
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
20
18
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
21
19
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
20
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
21
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
22
22
|
var _blockCard = require("../nodeviews/blockCard");
|
|
23
23
|
var _datasource = require("../nodeviews/datasource");
|
|
24
24
|
var _embedCard = require("../nodeviews/embedCard");
|
|
@@ -28,7 +28,7 @@ var _analytics = require("./analytics");
|
|
|
28
28
|
var _pluginKey = require("./plugin-key");
|
|
29
29
|
var _reducers = _interopRequireDefault(require("./reducers"));
|
|
30
30
|
var _resolve = require("./util/resolve");
|
|
31
|
-
var
|
|
31
|
+
var _state2 = require("./util/state");
|
|
32
32
|
var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
33
33
|
return function (pmPluginFactoryParams) {
|
|
34
34
|
var lpAnalyticsEventsNext = pmPluginFactoryParams.featureFlags.lpAnalyticsEventsNext;
|
|
@@ -67,7 +67,7 @@ var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
67
67
|
apply: function apply(tr, pluginState, prevEditorState) {
|
|
68
68
|
// Update all the positions of outstanding requests and
|
|
69
69
|
// cards in the plugin state.
|
|
70
|
-
var pluginStateWithUpdatedPos = (0,
|
|
70
|
+
var pluginStateWithUpdatedPos = (0, _state2.getPluginStateWithUpdatedPos)(pluginState, tr);
|
|
71
71
|
|
|
72
72
|
// apply any actions
|
|
73
73
|
var meta = tr.getMeta(_pluginKey.pluginKey);
|
|
@@ -93,17 +93,17 @@ var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
93
93
|
return {
|
|
94
94
|
update: function update(view, prevState) {
|
|
95
95
|
var _selection$node;
|
|
96
|
-
var currentState = (0,
|
|
97
|
-
var oldState = (0,
|
|
96
|
+
var currentState = (0, _state2.getPluginState)(view.state);
|
|
97
|
+
var oldState = (0, _state2.getPluginState)(prevState);
|
|
98
98
|
var state = view.state,
|
|
99
99
|
dispatch = view.dispatch;
|
|
100
100
|
var selection = state.selection,
|
|
101
101
|
tr = state.tr,
|
|
102
102
|
schema = state.schema;
|
|
103
|
-
var isBlockCardSelected = selection instanceof
|
|
103
|
+
var isBlockCardSelected = selection instanceof _state.NodeSelection && ((_selection$node = selection.node) === null || _selection$node === void 0 ? void 0 : _selection$node.type) === schema.nodes.blockCard;
|
|
104
104
|
if (isBlockCardSelected) {
|
|
105
105
|
var _findDomRefAtPos, _node$attrs;
|
|
106
|
-
var datasourceTableRef = (_findDomRefAtPos = (0,
|
|
106
|
+
var datasourceTableRef = (_findDomRefAtPos = (0, _utils2.findDomRefAtPos)(selection.from, domAtPos)) === null || _findDomRefAtPos === void 0 ? void 0 : _findDomRefAtPos.querySelector(".".concat(_styles.DATASOURCE_INNER_CONTAINER_CLASSNAME));
|
|
107
107
|
var node = selection.node;
|
|
108
108
|
var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.datasource);
|
|
109
109
|
var shouldUpdateTableRef = datasourceTableRef && (currentState === null || currentState === void 0 ? void 0 : currentState.datasourceTableRef) !== datasourceTableRef;
|
|
@@ -125,7 +125,7 @@ var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
125
125
|
}
|
|
126
126
|
if (currentState && currentState.provider) {
|
|
127
127
|
// Find requests in this state that weren't in the old one.
|
|
128
|
-
var newRequests = (0,
|
|
128
|
+
var newRequests = (0, _state2.getNewRequests)(oldState, currentState);
|
|
129
129
|
// Ask the CardProvider to resolve all new requests.
|
|
130
130
|
var provider = currentState.provider;
|
|
131
131
|
newRequests.forEach(function (request) {
|
|
@@ -5,9 +5,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.mountHyperlinkPlugin = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
9
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
12
|
var _HyperlinkToolbarAppearance = require("../ui/HyperlinkToolbarAppearance");
|
|
13
|
+
var _ToolbarViewedEvent = require("../ui/ToolbarViewedEvent");
|
|
14
|
+
var getToolbarViewedItem = function getToolbarViewedItem(link) {
|
|
15
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.editor.toolbar-viewed-event')) {
|
|
16
|
+
return [{
|
|
17
|
+
type: 'custom',
|
|
18
|
+
fallback: [],
|
|
19
|
+
render: function render(editorView) {
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement(_ToolbarViewedEvent.ToolbarViewedEvent, {
|
|
21
|
+
key: "edit.link.menu.viewed",
|
|
22
|
+
url: link,
|
|
23
|
+
display: "url",
|
|
24
|
+
editorView: editorView
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}];
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
};
|
|
11
31
|
var mountHyperlinkPlugin = function mountHyperlinkPlugin(pluginInjectionApi, options) {
|
|
12
32
|
return new _safePlugin.SafePlugin({
|
|
13
33
|
view: function view(editorView) {
|
|
@@ -15,7 +35,7 @@ var mountHyperlinkPlugin = function mountHyperlinkPlugin(pluginInjectionApi, opt
|
|
|
15
35
|
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
16
36
|
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.hyperlink) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.actions) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.prependToolbarButtons({
|
|
17
37
|
items: function items(state, intl, providerFactory, link) {
|
|
18
|
-
return [{
|
|
38
|
+
return [].concat((0, _toConsumableArray2.default)(getToolbarViewedItem(link)), [{
|
|
19
39
|
type: 'custom',
|
|
20
40
|
fallback: [],
|
|
21
41
|
render: function render(editorView) {
|
|
@@ -33,7 +53,7 @@ var mountHyperlinkPlugin = function mountHyperlinkPlugin(pluginInjectionApi, opt
|
|
|
33
53
|
cardActions: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions
|
|
34
54
|
});
|
|
35
55
|
}
|
|
36
|
-
}];
|
|
56
|
+
}]);
|
|
37
57
|
},
|
|
38
58
|
onEscapeCallback: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.card.actions.hideLinkToolbar,
|
|
39
59
|
onInsertLinkCallback: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.card.actions.queueCardsFromChangedTr,
|
|
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.pluginKey = void 0;
|
|
7
|
-
var
|
|
8
|
-
var pluginKey = new
|
|
7
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
var pluginKey = new _state.PluginKey('cardPlugin');
|
|
9
9
|
exports.pluginKey = pluginKey;
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -9,31 +9,33 @@ exports.visitCardLink = exports.removeCard = exports.openLinkSettings = exports.
|
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
13
|
-
var _prosemirrorUtils = require("prosemirror-utils");
|
|
14
12
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
15
13
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
16
14
|
var _card = require("@atlaskit/editor-common/card");
|
|
17
15
|
var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
|
|
18
16
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
19
17
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
18
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
19
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
20
20
|
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
21
21
|
var _settings = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/settings"));
|
|
22
22
|
var _unlink = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/unlink"));
|
|
23
23
|
var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
|
|
24
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
24
25
|
var _doc = require("./pm-plugins/doc");
|
|
25
26
|
var _main = require("./pm-plugins/main");
|
|
26
27
|
var _EditLinkToolbar = require("./ui/EditLinkToolbar");
|
|
27
28
|
var _LinkToolbarAppearance = require("./ui/LinkToolbarAppearance");
|
|
28
29
|
var _SmallerEditIcon = require("./ui/SmallerEditIcon");
|
|
29
|
-
var
|
|
30
|
+
var _ToolbarViewedEvent = require("./ui/ToolbarViewedEvent");
|
|
31
|
+
var _utils3 = require("./utils");
|
|
30
32
|
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); }
|
|
31
33
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
32
34
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
35
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
34
36
|
var removeCard = function removeCard(editorAnalyticsApi) {
|
|
35
37
|
return (0, _card.commandWithMetadata)(function (state, dispatch) {
|
|
36
|
-
if (!(state.selection instanceof
|
|
38
|
+
if (!(state.selection instanceof _state.NodeSelection)) {
|
|
37
39
|
return false;
|
|
38
40
|
}
|
|
39
41
|
var type = state.selection.node.type.name;
|
|
@@ -49,7 +51,7 @@ var removeCard = function removeCard(editorAnalyticsApi) {
|
|
|
49
51
|
};
|
|
50
52
|
if (dispatch) {
|
|
51
53
|
var tr = state.tr;
|
|
52
|
-
(0,
|
|
54
|
+
(0, _utils2.removeSelectedNode)(tr);
|
|
53
55
|
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(payload)(tr);
|
|
54
56
|
dispatch(tr);
|
|
55
57
|
}
|
|
@@ -61,11 +63,11 @@ var removeCard = function removeCard(editorAnalyticsApi) {
|
|
|
61
63
|
exports.removeCard = removeCard;
|
|
62
64
|
var visitCardLink = function visitCardLink(editorAnalyticsApi) {
|
|
63
65
|
return function (state, dispatch) {
|
|
64
|
-
if (!(state.selection instanceof
|
|
66
|
+
if (!(state.selection instanceof _state.NodeSelection)) {
|
|
65
67
|
return false;
|
|
66
68
|
}
|
|
67
69
|
var type = state.selection.node.type;
|
|
68
|
-
var _titleUrlPairFromNode = (0,
|
|
70
|
+
var _titleUrlPairFromNode = (0, _utils3.titleUrlPairFromNode)(state.selection.node),
|
|
69
71
|
url = _titleUrlPairFromNode.url;
|
|
70
72
|
|
|
71
73
|
// All card links should open in the same tab per https://product-fabric.atlassian.net/browse/MS-1583.
|
|
@@ -82,7 +84,7 @@ var visitCardLink = function visitCardLink(editorAnalyticsApi) {
|
|
|
82
84
|
exports.visitCardLink = visitCardLink;
|
|
83
85
|
var openLinkSettings = function openLinkSettings(editorAnalyticsApi) {
|
|
84
86
|
return function (state, dispatch) {
|
|
85
|
-
if (!(state.selection instanceof
|
|
87
|
+
if (!(state.selection instanceof _state.NodeSelection)) {
|
|
86
88
|
return false;
|
|
87
89
|
}
|
|
88
90
|
window.open('https://id.atlassian.com/manage-profile/link-preferences');
|
|
@@ -104,14 +106,14 @@ var floatingToolbar = function floatingToolbar(cardOptions, featureFlags, platfo
|
|
|
104
106
|
embedCard = _state$schema$nodes.embedCard;
|
|
105
107
|
var nodeType = [inlineCard, blockCard, embedCard];
|
|
106
108
|
var pluginState = _main.pluginKey.getState(state);
|
|
107
|
-
if (!(state.selection instanceof
|
|
109
|
+
if (!(state.selection instanceof _state.NodeSelection)) {
|
|
108
110
|
return;
|
|
109
111
|
}
|
|
110
112
|
var selectedNode = state.selection.node;
|
|
111
113
|
if (!selectedNode) {
|
|
112
114
|
return;
|
|
113
115
|
}
|
|
114
|
-
var isEmbedCard = (0,
|
|
116
|
+
var isEmbedCard = (0, _utils3.appearanceForNodeType)(selectedNode.type) === 'embed';
|
|
115
117
|
|
|
116
118
|
/* add an offset to embeds due to extra padding */
|
|
117
119
|
var toolbarOffset = isEmbedCard ? {
|
|
@@ -136,7 +138,7 @@ var floatingToolbar = function floatingToolbar(cardOptions, featureFlags, platfo
|
|
|
136
138
|
preventPopupOverflow: preventPopupOverflow
|
|
137
139
|
}, toolbarOffset), {}, {
|
|
138
140
|
getDomRef: function getDomRef(view) {
|
|
139
|
-
var element = (0,
|
|
141
|
+
var element = (0, _utils2.findDomRefAtPos)(view.state.selection.from, view.domAtPos.bind(view));
|
|
140
142
|
if (!element) {
|
|
141
143
|
return undefined;
|
|
142
144
|
}
|
|
@@ -153,7 +155,7 @@ var floatingToolbar = function floatingToolbar(cardOptions, featureFlags, platfo
|
|
|
153
155
|
};
|
|
154
156
|
exports.floatingToolbar = floatingToolbar;
|
|
155
157
|
var unlinkCard = function unlinkCard(node, state, editorAnalyticsApi) {
|
|
156
|
-
var displayInfo = (0,
|
|
158
|
+
var displayInfo = (0, _utils3.displayInfoForCard)(node, (0, _utils3.findCardInfo)(state));
|
|
157
159
|
var text = displayInfo.title || displayInfo.url;
|
|
158
160
|
if (text) {
|
|
159
161
|
return (0, _card.commandWithMetadata)((0, _doc.changeSelectedCardToText)(text, editorAnalyticsApi), {
|
|
@@ -172,10 +174,30 @@ var withToolbarMetadata = function withToolbarMetadata(command) {
|
|
|
172
174
|
inputMethod: _analytics.INPUT_METHOD.FLOATING_TB
|
|
173
175
|
});
|
|
174
176
|
};
|
|
177
|
+
var getToolbarViewedItem = function getToolbarViewedItem(url, display) {
|
|
178
|
+
if (!url) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.editor.toolbar-viewed-event')) {
|
|
182
|
+
return [{
|
|
183
|
+
type: 'custom',
|
|
184
|
+
fallback: [],
|
|
185
|
+
render: function render(editorView) {
|
|
186
|
+
return /*#__PURE__*/_react.default.createElement(_ToolbarViewedEvent.ToolbarViewedEvent, {
|
|
187
|
+
key: "edit.link.menu.viewed",
|
|
188
|
+
url: url,
|
|
189
|
+
display: display,
|
|
190
|
+
editorView: editorView
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}];
|
|
194
|
+
}
|
|
195
|
+
return [];
|
|
196
|
+
};
|
|
175
197
|
var generateToolbarItems = function generateToolbarItems(state, featureFlags, intl, providerFactory, cardOptions, platform, linkPicker, pluginInjectionApi) {
|
|
176
198
|
return function (node) {
|
|
177
199
|
var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5, _node$attrs, _node$attrs2, _node$attrs2$datasour;
|
|
178
|
-
var _titleUrlPairFromNode2 = (0,
|
|
200
|
+
var _titleUrlPairFromNode2 = (0, _utils3.titleUrlPairFromNode)(node),
|
|
179
201
|
url = _titleUrlPairFromNode2.url;
|
|
180
202
|
var _ref = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.analytics) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
|
|
181
203
|
editorAnalyticsApi = _ref.actions;
|
|
@@ -183,7 +205,7 @@ var generateToolbarItems = function generateToolbarItems(state, featureFlags, in
|
|
|
183
205
|
if (url && !(0, _adfSchema.isSafeUrl)(url)) {
|
|
184
206
|
return [];
|
|
185
207
|
} else {
|
|
186
|
-
var _displayInfoForCard = (0,
|
|
208
|
+
var _displayInfoForCard = (0, _utils3.displayInfoForCard)(node, (0, _utils3.findCardInfo)(state)),
|
|
187
209
|
title = _displayInfoForCard.title;
|
|
188
210
|
metadata = {
|
|
189
211
|
url: url,
|
|
@@ -191,7 +213,7 @@ var generateToolbarItems = function generateToolbarItems(state, featureFlags, in
|
|
|
191
213
|
};
|
|
192
214
|
}
|
|
193
215
|
var pluginState = _main.pluginKey.getState(state);
|
|
194
|
-
var currentAppearance = (0,
|
|
216
|
+
var currentAppearance = (0, _utils3.appearanceForNodeType)(node.type);
|
|
195
217
|
var _ref2 = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.decorations) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {},
|
|
196
218
|
hoverDecoration = _ref2.hoverDecoration;
|
|
197
219
|
var isDatasource = currentAppearance === 'block' && (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.datasource);
|
|
@@ -271,7 +293,7 @@ var generateToolbarItems = function generateToolbarItems(state, featureFlags, in
|
|
|
271
293
|
// This code will be executed only for appearances such as "inline", "block" & "embed"
|
|
272
294
|
// For url appearance, please see HyperlinkToolbarAppearanceProps
|
|
273
295
|
if (currentAppearance) {
|
|
274
|
-
toolbarItems.unshift({
|
|
296
|
+
toolbarItems.unshift.apply(toolbarItems, (0, _toConsumableArray2.default)(getToolbarViewedItem(url, currentAppearance)).concat([{
|
|
275
297
|
type: 'custom',
|
|
276
298
|
fallback: [],
|
|
277
299
|
render: function render(editorView) {
|
|
@@ -291,7 +313,7 @@ var generateToolbarItems = function generateToolbarItems(state, featureFlags, in
|
|
|
291
313
|
}
|
|
292
314
|
}, {
|
|
293
315
|
type: 'separator'
|
|
294
|
-
});
|
|
316
|
+
}]));
|
|
295
317
|
}
|
|
296
318
|
return toolbarItems;
|
|
297
319
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.CardContextProvider = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
11
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
17
|
+
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; } }
|
|
18
|
+
/**
|
|
19
|
+
* Provides the link provider context via the legacy context adapter
|
|
20
|
+
* and children render function
|
|
21
|
+
*/
|
|
22
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
23
|
+
var CardContextProvider = /*#__PURE__*/function (_React$Component) {
|
|
24
|
+
(0, _inherits2.default)(CardContextProvider, _React$Component);
|
|
25
|
+
var _super = _createSuper(CardContextProvider);
|
|
26
|
+
function CardContextProvider() {
|
|
27
|
+
(0, _classCallCheck2.default)(this, CardContextProvider);
|
|
28
|
+
return _super.apply(this, arguments);
|
|
29
|
+
}
|
|
30
|
+
(0, _createClass2.default)(CardContextProvider, [{
|
|
31
|
+
key: "render",
|
|
32
|
+
value: function render() {
|
|
33
|
+
var _this$context$context;
|
|
34
|
+
var cardContext = this.context.contextAdapter ? (_this$context$context = this.context.contextAdapter.card) === null || _this$context$context === void 0 ? void 0 : _this$context$context.value : undefined;
|
|
35
|
+
return this.props.children({
|
|
36
|
+
cardContext: cardContext
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}]);
|
|
40
|
+
return CardContextProvider;
|
|
41
|
+
}(_react.default.Component);
|
|
42
|
+
exports.CardContextProvider = CardContextProvider;
|
|
43
|
+
(0, _defineProperty2.default)(CardContextProvider, "contextTypes", {
|
|
44
|
+
contextAdapter: _propTypes.default.object
|
|
45
|
+
});
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.DatasourceModal = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var
|
|
11
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
12
|
var _linkDatasource = require("@atlaskit/link-datasource");
|
|
13
13
|
var _actions = require("../../pm-plugins/actions");
|
|
14
14
|
var _doc = require("../../pm-plugins/doc");
|
|
@@ -20,7 +20,7 @@ var DatasourceModal = function DatasourceModal(_ref) {
|
|
|
20
20
|
var dispatch = view.dispatch,
|
|
21
21
|
state = view.state;
|
|
22
22
|
var selection = state.selection;
|
|
23
|
-
var existingNode = selection instanceof
|
|
23
|
+
var existingNode = selection instanceof _state.NodeSelection ? selection.node : undefined;
|
|
24
24
|
var onClose = (0, _react.useCallback)(function () {
|
|
25
25
|
dispatch((0, _actions.hideDatasourceModal)(state.tr));
|
|
26
26
|
}, [dispatch, state.tr]);
|
|
@@ -15,13 +15,13 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
15
15
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
17
|
var _react = _interopRequireDefault(require("react"));
|
|
18
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
19
18
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
20
19
|
var _card = require("@atlaskit/editor-common/card");
|
|
21
20
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
22
21
|
var _link = require("@atlaskit/editor-common/link");
|
|
23
22
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
24
23
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
24
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
25
25
|
var _linkDatasource = require("@atlaskit/link-datasource");
|
|
26
26
|
var _actions = require("../pm-plugins/actions");
|
|
27
27
|
var _doc = require("../pm-plugins/doc");
|
|
@@ -161,7 +161,7 @@ exports.EditLinkToolbar = EditLinkToolbar;
|
|
|
161
161
|
var editLink = function editLink(editorAnalyticsApi) {
|
|
162
162
|
return function (state, dispatch) {
|
|
163
163
|
var type = 'hyperlink';
|
|
164
|
-
if (state.selection instanceof
|
|
164
|
+
if (state.selection instanceof _state.NodeSelection) {
|
|
165
165
|
type = state.selection.node.type.name;
|
|
166
166
|
}
|
|
167
167
|
if (dispatch) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.EditorAnalyticsContext = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
10
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
|
+
var _state = require("../pm-plugins/util/state");
|
|
12
|
+
/**
|
|
13
|
+
* Provides location attribute to child events
|
|
14
|
+
*/
|
|
15
|
+
var EditorAnalyticsContext = function EditorAnalyticsContext(_ref) {
|
|
16
|
+
var _getPluginState;
|
|
17
|
+
var editorView = _ref.editorView,
|
|
18
|
+
children = _ref.children;
|
|
19
|
+
var editorAppearance = editorView ? (_getPluginState = (0, _state.getPluginState)(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.editorAppearance : undefined;
|
|
20
|
+
var analyticsEditorAppearance = (0, _utils.getAnalyticsEditorAppearance)(editorAppearance);
|
|
21
|
+
var analyticsData = {
|
|
22
|
+
attributes: {
|
|
23
|
+
location: analyticsEditorAppearance
|
|
24
|
+
},
|
|
25
|
+
// Below is added for the future implementation of Linking Platform namespaced analytic context
|
|
26
|
+
location: analyticsEditorAppearance
|
|
27
|
+
};
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_analyticsNext.AnalyticsContext, {
|
|
29
|
+
data: analyticsData
|
|
30
|
+
}, children);
|
|
31
|
+
};
|
|
32
|
+
exports.EditorAnalyticsContext = EditorAnalyticsContext;
|
|
@@ -16,10 +16,9 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
16
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
17
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
18
18
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
19
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
20
19
|
var _linkAnalytics = require("@atlaskit/link-analytics");
|
|
21
20
|
var _actions = require("../pm-plugins/actions");
|
|
22
|
-
var
|
|
21
|
+
var _EditorAnalyticsContext = require("./EditorAnalyticsContext");
|
|
23
22
|
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); }
|
|
24
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
24
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
@@ -180,7 +179,6 @@ var EditorSmartCardEventsNext = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
180
179
|
(0, _createClass2.default)(EditorSmartCardEventsNext, [{
|
|
181
180
|
key: "render",
|
|
182
181
|
value: function render() {
|
|
183
|
-
var _getPluginState;
|
|
184
182
|
var cardContext = this.context.contextAdapter.card;
|
|
185
183
|
|
|
186
184
|
/**
|
|
@@ -191,19 +189,10 @@ var EditorSmartCardEventsNext = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
191
189
|
if (!cardContext) {
|
|
192
190
|
return null;
|
|
193
191
|
}
|
|
194
|
-
var editorAppearance = (_getPluginState = (0, _state.getPluginState)(this.props.editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.editorAppearance;
|
|
195
|
-
var analyticsEditorAppearance = (0, _utils.getAnalyticsEditorAppearance)(editorAppearance);
|
|
196
|
-
var analyticsData = {
|
|
197
|
-
attributes: {
|
|
198
|
-
location: analyticsEditorAppearance
|
|
199
|
-
},
|
|
200
|
-
// Below is added for the future implementation of Linking Platform namespaced analytic context
|
|
201
|
-
location: analyticsEditorAppearance
|
|
202
|
-
};
|
|
203
192
|
return /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
|
|
204
193
|
value: cardContext.value
|
|
205
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
206
|
-
|
|
194
|
+
}, /*#__PURE__*/_react.default.createElement(_EditorAnalyticsContext.EditorAnalyticsContext, {
|
|
195
|
+
editorView: this.props.editorView
|
|
207
196
|
}, /*#__PURE__*/_react.default.createElement(EventsBinding, this.props)));
|
|
208
197
|
}
|
|
209
198
|
}]);
|