@atlaskit/editor-plugin-card 18.0.20 → 18.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/cjs/cardPlugin.js +43 -24
- package/dist/cjs/ui/PasteDisplayAsMenu.js +49 -4
- package/dist/es2019/cardPlugin.js +21 -3
- package/dist/es2019/ui/PasteDisplayAsMenu.js +62 -37
- package/dist/esm/cardPlugin.js +41 -24
- package/dist/esm/ui/PasteDisplayAsMenu.js +47 -2
- package/dist/types/ui/PasteDisplayAsMenu.d.ts +7 -2
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 18.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 18.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`779a0020403de`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/779a0020403de) -
|
|
14
|
+
Add async hidden support to paste menu registered components, including timeout/error handling and
|
|
15
|
+
single Smart Link URL context from the paste options toolbar. Use Smart Card access checks to hide
|
|
16
|
+
Smart Link Display as options and AI Add Summary / Ask Rovo paste actions for inaccessible
|
|
17
|
+
single-link pastes in Confluence.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 18.0.20
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/cjs/cardPlugin.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
@@ -9,11 +10,12 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
10
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
var _react =
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
14
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
15
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
15
16
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
17
|
var _linkDatasource = require("@atlaskit/link-datasource");
|
|
18
|
+
var _context3 = require("@atlaskit/link-provider/context");
|
|
17
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
20
|
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
19
21
|
var _blockCard = require("./nodeviews/toDOM-fixes/blockCard");
|
|
@@ -32,18 +34,32 @@ var _EditorSmartCardEvents = require("./ui/EditorSmartCardEvents");
|
|
|
32
34
|
var _LayoutButton = _interopRequireDefault(require("./ui/LayoutButton"));
|
|
33
35
|
var _PasteDisplayAsMenu = require("./ui/PasteDisplayAsMenu");
|
|
34
36
|
var _toolbar = require("./ui/toolbar");
|
|
37
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
35
38
|
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; }
|
|
36
39
|
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; } // Ignored via go/ees005
|
|
37
40
|
// eslint-disable-next-line import/no-named-as-default
|
|
38
|
-
var
|
|
41
|
+
var PasteMenuSmartCardClientSync = function PasteMenuSmartCardClientSync(_ref) {
|
|
42
|
+
var _smartCardContext$con2;
|
|
43
|
+
var clientRef = _ref.clientRef;
|
|
44
|
+
var smartCardContext = (0, _react.useContext)(_context3.SmartCardContext);
|
|
45
|
+
(0, _react.useEffect)(function () {
|
|
46
|
+
var _smartCardContext$con;
|
|
47
|
+
clientRef.current = smartCardContext === null || smartCardContext === void 0 || (_smartCardContext$con = smartCardContext.connections) === null || _smartCardContext$con === void 0 ? void 0 : _smartCardContext$con.client;
|
|
48
|
+
}, [clientRef, smartCardContext === null || smartCardContext === void 0 || (_smartCardContext$con2 = smartCardContext.connections) === null || _smartCardContext$con2 === void 0 ? void 0 : _smartCardContext$con2.client]);
|
|
49
|
+
return null;
|
|
50
|
+
};
|
|
51
|
+
var cardPlugin = exports.cardPlugin = function cardPlugin(_ref2) {
|
|
39
52
|
var _api$base, _options$lpLinkPicker;
|
|
40
|
-
var
|
|
41
|
-
options =
|
|
42
|
-
api =
|
|
53
|
+
var _ref2$config = _ref2.config,
|
|
54
|
+
options = _ref2$config === void 0 ? {} : _ref2$config,
|
|
55
|
+
api = _ref2.api;
|
|
43
56
|
var previousCardProvider;
|
|
44
57
|
var cardPluginEvents = (0, _createEventsQueue.createEventsQueue)();
|
|
45
58
|
var instanceEmbedCardTransformers = options.embedCardTransformers;
|
|
46
59
|
var editorViewForPasteMenu;
|
|
60
|
+
var pasteMenuSmartCardClientRef = {
|
|
61
|
+
current: undefined
|
|
62
|
+
};
|
|
47
63
|
var pasteMenuVariant = (0, _expVal.expValNoExposure)('platform_editor_paste_actions_menu_v2', 'variant', 'control');
|
|
48
64
|
var shouldRegisterPasteDisplayAsMenu = options.enablePasteDisplayAsMenu && ['hasSpellingAndGrammar', 'hasAltAiActions'].includes(pasteMenuVariant);
|
|
49
65
|
if (shouldRegisterPasteDisplayAsMenu) {
|
|
@@ -54,13 +70,14 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
|
|
|
54
70
|
allowEmbeds: options.onlyInlineCards ? false : options.allowEmbeds,
|
|
55
71
|
getEditorView: function getEditorView() {
|
|
56
72
|
return editorViewForPasteMenu;
|
|
57
|
-
}
|
|
73
|
+
},
|
|
74
|
+
smartCardClientRef: pasteMenuSmartCardClientRef
|
|
58
75
|
}));
|
|
59
76
|
}
|
|
60
|
-
api === null || api === void 0 || (_api$base = api.base) === null || _api$base === void 0 || _api$base.actions.registerMarks(function (
|
|
61
|
-
var tr =
|
|
62
|
-
node =
|
|
63
|
-
pos =
|
|
77
|
+
api === null || api === void 0 || (_api$base = api.base) === null || _api$base === void 0 || _api$base.actions.registerMarks(function (_ref3) {
|
|
78
|
+
var tr = _ref3.tr,
|
|
79
|
+
node = _ref3.node,
|
|
80
|
+
pos = _ref3.pos;
|
|
64
81
|
var doc = tr.doc;
|
|
65
82
|
var schema = doc.type.schema;
|
|
66
83
|
var inlineCardNodeType = schema.nodes.inlineCard;
|
|
@@ -130,24 +147,26 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
|
|
|
130
147
|
}];
|
|
131
148
|
plugins.push({
|
|
132
149
|
name: 'cardKeymap',
|
|
133
|
-
plugin: function plugin(
|
|
134
|
-
var featureFlags =
|
|
150
|
+
plugin: function plugin(_ref4) {
|
|
151
|
+
var featureFlags = _ref4.featureFlags;
|
|
135
152
|
return (0, _keymap.cardKeymap)(featureFlags);
|
|
136
153
|
}
|
|
137
154
|
});
|
|
138
155
|
return plugins;
|
|
139
156
|
},
|
|
140
|
-
contentComponent: function contentComponent(
|
|
141
|
-
var editorView =
|
|
142
|
-
popupsMountPoint =
|
|
143
|
-
popupsScrollableElement =
|
|
144
|
-
popupsBoundariesElement =
|
|
157
|
+
contentComponent: function contentComponent(_ref5) {
|
|
158
|
+
var editorView = _ref5.editorView,
|
|
159
|
+
popupsMountPoint = _ref5.popupsMountPoint,
|
|
160
|
+
popupsScrollableElement = _ref5.popupsScrollableElement,
|
|
161
|
+
popupsBoundariesElement = _ref5.popupsBoundariesElement;
|
|
145
162
|
if (!editorView) {
|
|
146
163
|
return null;
|
|
147
164
|
}
|
|
148
165
|
editorViewForPasteMenu = editorView;
|
|
149
166
|
var breakoutEnabled = options.editorAppearance === 'full-page';
|
|
150
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(
|
|
167
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, shouldRegisterPasteDisplayAsMenu && /*#__PURE__*/_react.default.createElement(PasteMenuSmartCardClientSync, {
|
|
168
|
+
clientRef: pasteMenuSmartCardClientRef
|
|
169
|
+
}), /*#__PURE__*/_react.default.createElement(_EditorSmartCardEvents.EditorSmartCardEvents, {
|
|
151
170
|
editorView: editorView
|
|
152
171
|
}), /*#__PURE__*/_react.default.createElement(_EditorLinkingPlatformAnalytics.EditorLinkingPlatformAnalytics, {
|
|
153
172
|
cardPluginEvents: cardPluginEvents,
|
|
@@ -165,8 +184,8 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
|
|
|
165
184
|
},
|
|
166
185
|
commands: {
|
|
167
186
|
queueCardsFromRange: function queueCardsFromRange(from, to, source, analyticsAction, normalizeLinkText, sourceEvent, appearance) {
|
|
168
|
-
return function (
|
|
169
|
-
var tr =
|
|
187
|
+
return function (_ref6) {
|
|
188
|
+
var tr = _ref6.tr;
|
|
170
189
|
return (0, _doc.queueCardsFromRange)(
|
|
171
190
|
// Synthesise the minimal EditorState shape the impl actually reads.
|
|
172
191
|
{
|
|
@@ -195,8 +214,8 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
|
|
|
195
214
|
return _context.abrupt("return", false);
|
|
196
215
|
case 2:
|
|
197
216
|
previousCardProvider = provider;
|
|
198
|
-
return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (
|
|
199
|
-
var tr =
|
|
217
|
+
return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref7) {
|
|
218
|
+
var tr = _ref7.tr;
|
|
200
219
|
return (0, _actions.setProvider)(provider)(tr);
|
|
201
220
|
})) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false);
|
|
202
221
|
case 3:
|
|
@@ -304,8 +323,8 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
|
|
|
304
323
|
},
|
|
305
324
|
pluginsOptions: {
|
|
306
325
|
floatingToolbar: (0, _toolbar.floatingToolbar)(options, (_options$lpLinkPicker = options.lpLinkPicker) !== null && _options$lpLinkPicker !== void 0 ? _options$lpLinkPicker : false, options.linkPicker, api, options.disableFloatingToolbar),
|
|
307
|
-
quickInsert: function quickInsert(
|
|
308
|
-
var formatMessage =
|
|
326
|
+
quickInsert: function quickInsert(_ref8) {
|
|
327
|
+
var formatMessage = _ref8.formatMessage;
|
|
309
328
|
var quickInsertArray = [];
|
|
310
329
|
if (!options.allowDatasource) {
|
|
311
330
|
return quickInsertArray;
|
|
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
exports.setAppearanceSelection = exports.normalizeSelectionToLinkRangeForUrlAppearance = exports.getPasteDisplayAsMenuComponents = exports.getFirstLinkRangeInSelection = exports.SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION_KEY = void 0;
|
|
10
10
|
require("./PasteDisplayAsMenu.compiled.css");
|
|
11
11
|
var _runtime = require("@compiled/react/runtime");
|
|
12
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
13
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
15
|
var _reactIntl = require("react-intl");
|
|
14
16
|
var _css = require("@atlaskit/css");
|
|
@@ -24,13 +26,13 @@ var _minus = _interopRequireDefault(require("@atlaskit/icon/core/minus"));
|
|
|
24
26
|
var _smartLinkCard = _interopRequireDefault(require("@atlaskit/icon/core/smart-link-card"));
|
|
25
27
|
var _smartLinkEmbed = _interopRequireDefault(require("@atlaskit/icon/core/smart-link-embed"));
|
|
26
28
|
var _smartLinkInline = _interopRequireDefault(require("@atlaskit/icon/core/smart-link-inline"));
|
|
27
|
-
var
|
|
29
|
+
var _context2 = require("@atlaskit/link-provider/context");
|
|
28
30
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
29
31
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
30
32
|
var _doc = require("../pm-plugins/doc");
|
|
31
33
|
var _currentPastedSmartLink = require("./currentPastedSmartLink");
|
|
32
34
|
var _pasteDisplayAsUtils = require("./pasteDisplayAsUtils");
|
|
33
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var
|
|
35
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
34
36
|
var SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION_KEY = exports.SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION_KEY = 'smart-link-display-as-paste-menu-section';
|
|
35
37
|
|
|
36
38
|
// Subset of `PasteMenuRuleFactories` we structurally consume here — kept local
|
|
@@ -191,7 +193,7 @@ var PasteDisplayAsMenuHorizontalView = function PasteDisplayAsMenuHorizontalView
|
|
|
191
193
|
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
192
194
|
editorView = _useEditorToolbar.editorView;
|
|
193
195
|
var toolbarDropdownMenu = (0, _editorToolbar.useToolbarDropdownMenu)();
|
|
194
|
-
var smartCardContext = (0,
|
|
196
|
+
var smartCardContext = (0, _context2.useSmartCardContext)();
|
|
195
197
|
var frameRef = (0, _react.useRef)(null);
|
|
196
198
|
var isApplyingRef = (0, _react.useRef)(false);
|
|
197
199
|
var apiWithPasteOptionsToolbar = api;
|
|
@@ -334,7 +336,49 @@ var getPasteDisplayAsMenuComponents = exports.getPasteDisplayAsMenuComponents =
|
|
|
334
336
|
var api = _ref0.api,
|
|
335
337
|
allowBlockCards = _ref0.allowBlockCards,
|
|
336
338
|
allowEmbeds = _ref0.allowEmbeds,
|
|
337
|
-
getEditorView = _ref0.getEditorView
|
|
339
|
+
getEditorView = _ref0.getEditorView,
|
|
340
|
+
smartCardClientRef = _ref0.smartCardClientRef;
|
|
341
|
+
var smartlinkAsyncHidden = /*#__PURE__*/function () {
|
|
342
|
+
var _ref1 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(context) {
|
|
343
|
+
var pastedUrl, isEnabled, smartCardClient, _response$meta, response, _t;
|
|
344
|
+
return _regenerator.default.wrap(function (_context) {
|
|
345
|
+
while (1) switch (_context.prev = _context.next) {
|
|
346
|
+
case 0:
|
|
347
|
+
pastedUrl = context.pastedUrl;
|
|
348
|
+
if (pastedUrl) {
|
|
349
|
+
_context.next = 1;
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
return _context.abrupt("return", false);
|
|
353
|
+
case 1:
|
|
354
|
+
isEnabled = (0, _expValEquals.expValEquals)('confluence_editor_paste_3p_link_actions_menu', 'isEnabled', true);
|
|
355
|
+
smartCardClient = smartCardClientRef === null || smartCardClientRef === void 0 ? void 0 : smartCardClientRef.current;
|
|
356
|
+
if (!(!isEnabled || !smartCardClient)) {
|
|
357
|
+
_context.next = 2;
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
return _context.abrupt("return", true);
|
|
361
|
+
case 2:
|
|
362
|
+
_context.prev = 2;
|
|
363
|
+
_context.next = 3;
|
|
364
|
+
return smartCardClient.fetchData(pastedUrl);
|
|
365
|
+
case 3:
|
|
366
|
+
response = _context.sent;
|
|
367
|
+
return _context.abrupt("return", ((_response$meta = response.meta) === null || _response$meta === void 0 ? void 0 : _response$meta.access) !== 'granted');
|
|
368
|
+
case 4:
|
|
369
|
+
_context.prev = 4;
|
|
370
|
+
_t = _context["catch"](2);
|
|
371
|
+
return _context.abrupt("return", true);
|
|
372
|
+
case 5:
|
|
373
|
+
case "end":
|
|
374
|
+
return _context.stop();
|
|
375
|
+
}
|
|
376
|
+
}, _callee, null, [[2, 4]]);
|
|
377
|
+
}));
|
|
378
|
+
return function smartlinkAsyncHidden(_x) {
|
|
379
|
+
return _ref1.apply(this, arguments);
|
|
380
|
+
};
|
|
381
|
+
}();
|
|
338
382
|
return [{
|
|
339
383
|
type: 'menu-section',
|
|
340
384
|
key: SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION_KEY,
|
|
@@ -343,6 +387,7 @@ var getPasteDisplayAsMenuComponents = exports.getPasteDisplayAsMenuComponents =
|
|
|
343
387
|
key: _toolbar.PASTE_MENU.key,
|
|
344
388
|
rank: 60
|
|
345
389
|
}],
|
|
390
|
+
isAsyncHidden: smartlinkAsyncHidden,
|
|
346
391
|
isHidden: function isHidden() {
|
|
347
392
|
var _apiWithPasteOptionsT, _apiWithPasteOptionsT2;
|
|
348
393
|
if (!(0, _expValEquals.expValEquals)('confluence_editor_paste_3p_link_actions_menu', 'isEnabled', true)) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext, useEffect } from 'react';
|
|
2
2
|
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
3
3
|
import { IconDatasourceAssetsObjects, IconDatasourceConfluenceSearch, IconDatasourceJiraIssue } from '@atlaskit/editor-common/quick-insert';
|
|
4
4
|
import { canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, CONFLUENCE_SEARCH_DATASOURCE_ID } from '@atlaskit/link-datasource';
|
|
6
|
+
import { SmartCardContext } from '@atlaskit/link-provider/context';
|
|
6
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { expValNoExposure } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
8
9
|
import { blockCardSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/blockCard';
|
|
@@ -23,6 +24,17 @@ import { EditorSmartCardEvents } from './ui/EditorSmartCardEvents';
|
|
|
23
24
|
import LayoutButton from './ui/LayoutButton';
|
|
24
25
|
import { getPasteDisplayAsMenuComponents } from './ui/PasteDisplayAsMenu';
|
|
25
26
|
import { floatingToolbar, getEndingToolbarItems, getStartingToolbarItems } from './ui/toolbar';
|
|
27
|
+
const PasteMenuSmartCardClientSync = ({
|
|
28
|
+
clientRef
|
|
29
|
+
}) => {
|
|
30
|
+
var _smartCardContext$con2;
|
|
31
|
+
const smartCardContext = useContext(SmartCardContext);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
var _smartCardContext$con;
|
|
34
|
+
clientRef.current = smartCardContext === null || smartCardContext === void 0 ? void 0 : (_smartCardContext$con = smartCardContext.connections) === null || _smartCardContext$con === void 0 ? void 0 : _smartCardContext$con.client;
|
|
35
|
+
}, [clientRef, smartCardContext === null || smartCardContext === void 0 ? void 0 : (_smartCardContext$con2 = smartCardContext.connections) === null || _smartCardContext$con2 === void 0 ? void 0 : _smartCardContext$con2.client]);
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
26
38
|
export const cardPlugin = ({
|
|
27
39
|
config: options = {},
|
|
28
40
|
api
|
|
@@ -32,6 +44,9 @@ export const cardPlugin = ({
|
|
|
32
44
|
const cardPluginEvents = createEventsQueue();
|
|
33
45
|
let instanceEmbedCardTransformers = options.embedCardTransformers;
|
|
34
46
|
let editorViewForPasteMenu;
|
|
47
|
+
const pasteMenuSmartCardClientRef = {
|
|
48
|
+
current: undefined
|
|
49
|
+
};
|
|
35
50
|
const pasteMenuVariant = expValNoExposure('platform_editor_paste_actions_menu_v2', 'variant', 'control');
|
|
36
51
|
const shouldRegisterPasteDisplayAsMenu = options.enablePasteDisplayAsMenu && ['hasSpellingAndGrammar', 'hasAltAiActions'].includes(pasteMenuVariant);
|
|
37
52
|
if (shouldRegisterPasteDisplayAsMenu) {
|
|
@@ -40,7 +55,8 @@ export const cardPlugin = ({
|
|
|
40
55
|
api,
|
|
41
56
|
allowBlockCards: options.onlyInlineCards ? false : (_options$allowBlockCa = options.allowBlockCards) !== null && _options$allowBlockCa !== void 0 ? _options$allowBlockCa : true,
|
|
42
57
|
allowEmbeds: options.onlyInlineCards ? false : options.allowEmbeds,
|
|
43
|
-
getEditorView: () => editorViewForPasteMenu
|
|
58
|
+
getEditorView: () => editorViewForPasteMenu,
|
|
59
|
+
smartCardClientRef: pasteMenuSmartCardClientRef
|
|
44
60
|
}));
|
|
45
61
|
}
|
|
46
62
|
api === null || api === void 0 ? void 0 : (_api$base = api.base) === null || _api$base === void 0 ? void 0 : _api$base.actions.registerMarks(({
|
|
@@ -143,7 +159,9 @@ export const cardPlugin = ({
|
|
|
143
159
|
}
|
|
144
160
|
editorViewForPasteMenu = editorView;
|
|
145
161
|
const breakoutEnabled = options.editorAppearance === 'full-page';
|
|
146
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
162
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, shouldRegisterPasteDisplayAsMenu && /*#__PURE__*/React.createElement(PasteMenuSmartCardClientSync, {
|
|
163
|
+
clientRef: pasteMenuSmartCardClientRef
|
|
164
|
+
}), /*#__PURE__*/React.createElement(EditorSmartCardEvents, {
|
|
147
165
|
editorView: editorView
|
|
148
166
|
}), /*#__PURE__*/React.createElement(EditorLinkingPlatformAnalytics, {
|
|
149
167
|
cardPluginEvents: cardPluginEvents,
|
|
@@ -16,7 +16,7 @@ import MinusIcon from '@atlaskit/icon/core/minus';
|
|
|
16
16
|
import SmartLinkCardIcon from '@atlaskit/icon/core/smart-link-card';
|
|
17
17
|
import SmartLinkEmbedIcon from '@atlaskit/icon/core/smart-link-embed';
|
|
18
18
|
import SmartLinkInlineIcon from '@atlaskit/icon/core/smart-link-inline';
|
|
19
|
-
import { useSmartCardContext } from '@atlaskit/link-provider';
|
|
19
|
+
import { useSmartCardContext } from '@atlaskit/link-provider/context';
|
|
20
20
|
import { Box, Flex, Pressable } from '@atlaskit/primitives/compiled';
|
|
21
21
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
22
22
|
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
@@ -335,45 +335,70 @@ export const getPasteDisplayAsMenuComponents = ({
|
|
|
335
335
|
api,
|
|
336
336
|
allowBlockCards,
|
|
337
337
|
allowEmbeds,
|
|
338
|
-
getEditorView
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
isHidden: () => {
|
|
348
|
-
var _apiWithPasteOptionsT, _apiWithPasteOptionsT2;
|
|
349
|
-
if (!expValEquals('confluence_editor_paste_3p_link_actions_menu', 'isEnabled', true)) {
|
|
350
|
-
return true;
|
|
338
|
+
getEditorView,
|
|
339
|
+
smartCardClientRef
|
|
340
|
+
}) => {
|
|
341
|
+
const smartlinkAsyncHidden = async context => {
|
|
342
|
+
const {
|
|
343
|
+
pastedUrl
|
|
344
|
+
} = context;
|
|
345
|
+
if (!pastedUrl) {
|
|
346
|
+
return false;
|
|
351
347
|
}
|
|
352
|
-
const
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
if (!editorView || !pasteRange) {
|
|
348
|
+
const isEnabled = expValEquals('confluence_editor_paste_3p_link_actions_menu', 'isEnabled', true);
|
|
349
|
+
const smartCardClient = smartCardClientRef === null || smartCardClientRef === void 0 ? void 0 : smartCardClientRef.current;
|
|
350
|
+
if (!isEnabled || !smartCardClient) {
|
|
356
351
|
return true;
|
|
357
352
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
353
|
+
try {
|
|
354
|
+
var _response$meta;
|
|
355
|
+
const response = await smartCardClient.fetchData(pastedUrl);
|
|
356
|
+
return ((_response$meta = response.meta) === null || _response$meta === void 0 ? void 0 : _response$meta.access) !== 'granted';
|
|
357
|
+
} catch {
|
|
358
|
+
// Network / auth errors → hide
|
|
363
359
|
return true;
|
|
364
360
|
}
|
|
361
|
+
};
|
|
362
|
+
return [{
|
|
363
|
+
type: 'menu-section',
|
|
364
|
+
key: SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION_KEY,
|
|
365
|
+
parents: [{
|
|
366
|
+
type: PASTE_MENU.type,
|
|
367
|
+
key: PASTE_MENU.key,
|
|
368
|
+
rank: 60
|
|
369
|
+
}],
|
|
370
|
+
isAsyncHidden: smartlinkAsyncHidden,
|
|
371
|
+
isHidden: () => {
|
|
372
|
+
var _apiWithPasteOptionsT, _apiWithPasteOptionsT2;
|
|
373
|
+
if (!expValEquals('confluence_editor_paste_3p_link_actions_menu', 'isEnabled', true)) {
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
const apiWithPasteOptionsToolbar = api;
|
|
377
|
+
const pasteRange = apiWithPasteOptionsToolbar === null || apiWithPasteOptionsToolbar === void 0 ? void 0 : (_apiWithPasteOptionsT = apiWithPasteOptionsToolbar.pasteOptionsToolbarPlugin) === null || _apiWithPasteOptionsT === void 0 ? void 0 : _apiWithPasteOptionsT.sharedState.currentState();
|
|
378
|
+
const editorView = getEditorView();
|
|
379
|
+
if (!editorView || !pasteRange) {
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
365
382
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
383
|
+
// Slice-shape check — delegated to the toolbar plugin's shared
|
|
384
|
+
// `notSingleLinkRule` via the structural cast (see note above).
|
|
385
|
+
const rules = apiWithPasteOptionsToolbar === null || apiWithPasteOptionsToolbar === void 0 ? void 0 : (_apiWithPasteOptionsT2 = apiWithPasteOptionsToolbar.pasteOptionsToolbarPlugin) === null || _apiWithPasteOptionsT2 === void 0 ? void 0 : _apiWithPasteOptionsT2.actions.getPasteMenuRules();
|
|
386
|
+
if (!rules || rules.notSingleLinkRule()) {
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Fallback: plain-text URL paste that the card plugin already resolved into a card node in the doc.
|
|
391
|
+
const urlFromCard = getCardUrlAtPasteRange({
|
|
392
|
+
editorView,
|
|
393
|
+
pasteStartPos: pasteRange.pasteStartPos,
|
|
394
|
+
pasteEndPos: pasteRange.pasteEndPos
|
|
395
|
+
});
|
|
396
|
+
return !urlFromCard;
|
|
397
|
+
},
|
|
398
|
+
component: () => /*#__PURE__*/React.createElement(PasteDisplayAsMenuSection, {
|
|
399
|
+
api: api,
|
|
400
|
+
allowBlockCards: allowBlockCards,
|
|
401
|
+
allowEmbeds: allowEmbeds
|
|
402
|
+
})
|
|
403
|
+
}];
|
|
404
|
+
};
|
package/dist/esm/cardPlugin.js
CHANGED
|
@@ -4,11 +4,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
5
|
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; }
|
|
6
6
|
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; }
|
|
7
|
-
import React from 'react';
|
|
7
|
+
import React, { useContext, useEffect } from 'react';
|
|
8
8
|
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
9
|
import { IconDatasourceAssetsObjects, IconDatasourceConfluenceSearch, IconDatasourceJiraIssue } from '@atlaskit/editor-common/quick-insert';
|
|
10
10
|
import { canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
11
11
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, CONFLUENCE_SEARCH_DATASOURCE_ID } from '@atlaskit/link-datasource';
|
|
12
|
+
import { SmartCardContext } from '@atlaskit/link-provider/context';
|
|
12
13
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { expValNoExposure } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
14
15
|
import { blockCardSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/blockCard';
|
|
@@ -29,15 +30,28 @@ import { EditorSmartCardEvents } from './ui/EditorSmartCardEvents';
|
|
|
29
30
|
import LayoutButton from './ui/LayoutButton';
|
|
30
31
|
import { getPasteDisplayAsMenuComponents } from './ui/PasteDisplayAsMenu';
|
|
31
32
|
import { floatingToolbar, getEndingToolbarItems, getStartingToolbarItems } from './ui/toolbar';
|
|
32
|
-
|
|
33
|
+
var PasteMenuSmartCardClientSync = function PasteMenuSmartCardClientSync(_ref) {
|
|
34
|
+
var _smartCardContext$con2;
|
|
35
|
+
var clientRef = _ref.clientRef;
|
|
36
|
+
var smartCardContext = useContext(SmartCardContext);
|
|
37
|
+
useEffect(function () {
|
|
38
|
+
var _smartCardContext$con;
|
|
39
|
+
clientRef.current = smartCardContext === null || smartCardContext === void 0 || (_smartCardContext$con = smartCardContext.connections) === null || _smartCardContext$con === void 0 ? void 0 : _smartCardContext$con.client;
|
|
40
|
+
}, [clientRef, smartCardContext === null || smartCardContext === void 0 || (_smartCardContext$con2 = smartCardContext.connections) === null || _smartCardContext$con2 === void 0 ? void 0 : _smartCardContext$con2.client]);
|
|
41
|
+
return null;
|
|
42
|
+
};
|
|
43
|
+
export var cardPlugin = function cardPlugin(_ref2) {
|
|
33
44
|
var _api$base, _options$lpLinkPicker;
|
|
34
|
-
var
|
|
35
|
-
options =
|
|
36
|
-
api =
|
|
45
|
+
var _ref2$config = _ref2.config,
|
|
46
|
+
options = _ref2$config === void 0 ? {} : _ref2$config,
|
|
47
|
+
api = _ref2.api;
|
|
37
48
|
var previousCardProvider;
|
|
38
49
|
var cardPluginEvents = createEventsQueue();
|
|
39
50
|
var instanceEmbedCardTransformers = options.embedCardTransformers;
|
|
40
51
|
var editorViewForPasteMenu;
|
|
52
|
+
var pasteMenuSmartCardClientRef = {
|
|
53
|
+
current: undefined
|
|
54
|
+
};
|
|
41
55
|
var pasteMenuVariant = expValNoExposure('platform_editor_paste_actions_menu_v2', 'variant', 'control');
|
|
42
56
|
var shouldRegisterPasteDisplayAsMenu = options.enablePasteDisplayAsMenu && ['hasSpellingAndGrammar', 'hasAltAiActions'].includes(pasteMenuVariant);
|
|
43
57
|
if (shouldRegisterPasteDisplayAsMenu) {
|
|
@@ -48,13 +62,14 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
48
62
|
allowEmbeds: options.onlyInlineCards ? false : options.allowEmbeds,
|
|
49
63
|
getEditorView: function getEditorView() {
|
|
50
64
|
return editorViewForPasteMenu;
|
|
51
|
-
}
|
|
65
|
+
},
|
|
66
|
+
smartCardClientRef: pasteMenuSmartCardClientRef
|
|
52
67
|
}));
|
|
53
68
|
}
|
|
54
|
-
api === null || api === void 0 || (_api$base = api.base) === null || _api$base === void 0 || _api$base.actions.registerMarks(function (
|
|
55
|
-
var tr =
|
|
56
|
-
node =
|
|
57
|
-
pos =
|
|
69
|
+
api === null || api === void 0 || (_api$base = api.base) === null || _api$base === void 0 || _api$base.actions.registerMarks(function (_ref3) {
|
|
70
|
+
var tr = _ref3.tr,
|
|
71
|
+
node = _ref3.node,
|
|
72
|
+
pos = _ref3.pos;
|
|
58
73
|
var doc = tr.doc;
|
|
59
74
|
var schema = doc.type.schema;
|
|
60
75
|
var inlineCardNodeType = schema.nodes.inlineCard;
|
|
@@ -124,24 +139,26 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
124
139
|
}];
|
|
125
140
|
plugins.push({
|
|
126
141
|
name: 'cardKeymap',
|
|
127
|
-
plugin: function plugin(
|
|
128
|
-
var featureFlags =
|
|
142
|
+
plugin: function plugin(_ref4) {
|
|
143
|
+
var featureFlags = _ref4.featureFlags;
|
|
129
144
|
return cardKeymap(featureFlags);
|
|
130
145
|
}
|
|
131
146
|
});
|
|
132
147
|
return plugins;
|
|
133
148
|
},
|
|
134
|
-
contentComponent: function contentComponent(
|
|
135
|
-
var editorView =
|
|
136
|
-
popupsMountPoint =
|
|
137
|
-
popupsScrollableElement =
|
|
138
|
-
popupsBoundariesElement =
|
|
149
|
+
contentComponent: function contentComponent(_ref5) {
|
|
150
|
+
var editorView = _ref5.editorView,
|
|
151
|
+
popupsMountPoint = _ref5.popupsMountPoint,
|
|
152
|
+
popupsScrollableElement = _ref5.popupsScrollableElement,
|
|
153
|
+
popupsBoundariesElement = _ref5.popupsBoundariesElement;
|
|
139
154
|
if (!editorView) {
|
|
140
155
|
return null;
|
|
141
156
|
}
|
|
142
157
|
editorViewForPasteMenu = editorView;
|
|
143
158
|
var breakoutEnabled = options.editorAppearance === 'full-page';
|
|
144
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
159
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, shouldRegisterPasteDisplayAsMenu && /*#__PURE__*/React.createElement(PasteMenuSmartCardClientSync, {
|
|
160
|
+
clientRef: pasteMenuSmartCardClientRef
|
|
161
|
+
}), /*#__PURE__*/React.createElement(EditorSmartCardEvents, {
|
|
145
162
|
editorView: editorView
|
|
146
163
|
}), /*#__PURE__*/React.createElement(EditorLinkingPlatformAnalytics, {
|
|
147
164
|
cardPluginEvents: cardPluginEvents,
|
|
@@ -159,8 +176,8 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
159
176
|
},
|
|
160
177
|
commands: {
|
|
161
178
|
queueCardsFromRange: function queueCardsFromRange(from, to, source, analyticsAction, normalizeLinkText, sourceEvent, appearance) {
|
|
162
|
-
return function (
|
|
163
|
-
var tr =
|
|
179
|
+
return function (_ref6) {
|
|
180
|
+
var tr = _ref6.tr;
|
|
164
181
|
return _queueCardsFromRange(
|
|
165
182
|
// Synthesise the minimal EditorState shape the impl actually reads.
|
|
166
183
|
{
|
|
@@ -189,8 +206,8 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
189
206
|
return _context.abrupt("return", false);
|
|
190
207
|
case 2:
|
|
191
208
|
previousCardProvider = provider;
|
|
192
|
-
return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (
|
|
193
|
-
var tr =
|
|
209
|
+
return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref7) {
|
|
210
|
+
var tr = _ref7.tr;
|
|
194
211
|
return _setProvider(provider)(tr);
|
|
195
212
|
})) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false);
|
|
196
213
|
case 3:
|
|
@@ -298,8 +315,8 @@ export var cardPlugin = function cardPlugin(_ref) {
|
|
|
298
315
|
},
|
|
299
316
|
pluginsOptions: {
|
|
300
317
|
floatingToolbar: floatingToolbar(options, (_options$lpLinkPicker = options.lpLinkPicker) !== null && _options$lpLinkPicker !== void 0 ? _options$lpLinkPicker : false, options.linkPicker, api, options.disableFloatingToolbar),
|
|
301
|
-
quickInsert: function quickInsert(
|
|
302
|
-
var formatMessage =
|
|
318
|
+
quickInsert: function quickInsert(_ref8) {
|
|
319
|
+
var formatMessage = _ref8.formatMessage;
|
|
303
320
|
var quickInsertArray = [];
|
|
304
321
|
if (!options.allowDatasource) {
|
|
305
322
|
return quickInsertArray;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* PasteDisplayAsMenu.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
3
|
import "./PasteDisplayAsMenu.compiled.css";
|
|
3
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
6
|
import React, { useCallback, useEffect, useRef } from 'react';
|
|
5
7
|
import { useIntl } from 'react-intl';
|
|
6
8
|
import { cx } from '@atlaskit/css';
|
|
@@ -16,7 +18,7 @@ import MinusIcon from '@atlaskit/icon/core/minus';
|
|
|
16
18
|
import SmartLinkCardIcon from '@atlaskit/icon/core/smart-link-card';
|
|
17
19
|
import SmartLinkEmbedIcon from '@atlaskit/icon/core/smart-link-embed';
|
|
18
20
|
import SmartLinkInlineIcon from '@atlaskit/icon/core/smart-link-inline';
|
|
19
|
-
import { useSmartCardContext } from '@atlaskit/link-provider';
|
|
21
|
+
import { useSmartCardContext } from '@atlaskit/link-provider/context';
|
|
20
22
|
import { Box, Flex, Pressable } from '@atlaskit/primitives/compiled';
|
|
21
23
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
22
24
|
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
@@ -325,7 +327,49 @@ export var getPasteDisplayAsMenuComponents = function getPasteDisplayAsMenuCompo
|
|
|
325
327
|
var api = _ref0.api,
|
|
326
328
|
allowBlockCards = _ref0.allowBlockCards,
|
|
327
329
|
allowEmbeds = _ref0.allowEmbeds,
|
|
328
|
-
getEditorView = _ref0.getEditorView
|
|
330
|
+
getEditorView = _ref0.getEditorView,
|
|
331
|
+
smartCardClientRef = _ref0.smartCardClientRef;
|
|
332
|
+
var smartlinkAsyncHidden = /*#__PURE__*/function () {
|
|
333
|
+
var _ref1 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(context) {
|
|
334
|
+
var pastedUrl, isEnabled, smartCardClient, _response$meta, response, _t;
|
|
335
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
336
|
+
while (1) switch (_context.prev = _context.next) {
|
|
337
|
+
case 0:
|
|
338
|
+
pastedUrl = context.pastedUrl;
|
|
339
|
+
if (pastedUrl) {
|
|
340
|
+
_context.next = 1;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
return _context.abrupt("return", false);
|
|
344
|
+
case 1:
|
|
345
|
+
isEnabled = expValEquals('confluence_editor_paste_3p_link_actions_menu', 'isEnabled', true);
|
|
346
|
+
smartCardClient = smartCardClientRef === null || smartCardClientRef === void 0 ? void 0 : smartCardClientRef.current;
|
|
347
|
+
if (!(!isEnabled || !smartCardClient)) {
|
|
348
|
+
_context.next = 2;
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
return _context.abrupt("return", true);
|
|
352
|
+
case 2:
|
|
353
|
+
_context.prev = 2;
|
|
354
|
+
_context.next = 3;
|
|
355
|
+
return smartCardClient.fetchData(pastedUrl);
|
|
356
|
+
case 3:
|
|
357
|
+
response = _context.sent;
|
|
358
|
+
return _context.abrupt("return", ((_response$meta = response.meta) === null || _response$meta === void 0 ? void 0 : _response$meta.access) !== 'granted');
|
|
359
|
+
case 4:
|
|
360
|
+
_context.prev = 4;
|
|
361
|
+
_t = _context["catch"](2);
|
|
362
|
+
return _context.abrupt("return", true);
|
|
363
|
+
case 5:
|
|
364
|
+
case "end":
|
|
365
|
+
return _context.stop();
|
|
366
|
+
}
|
|
367
|
+
}, _callee, null, [[2, 4]]);
|
|
368
|
+
}));
|
|
369
|
+
return function smartlinkAsyncHidden(_x) {
|
|
370
|
+
return _ref1.apply(this, arguments);
|
|
371
|
+
};
|
|
372
|
+
}();
|
|
329
373
|
return [{
|
|
330
374
|
type: 'menu-section',
|
|
331
375
|
key: SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION_KEY,
|
|
@@ -334,6 +378,7 @@ export var getPasteDisplayAsMenuComponents = function getPasteDisplayAsMenuCompo
|
|
|
334
378
|
key: PASTE_MENU.key,
|
|
335
379
|
rank: 60
|
|
336
380
|
}],
|
|
381
|
+
isAsyncHidden: smartlinkAsyncHidden,
|
|
337
382
|
isHidden: function isHidden() {
|
|
338
383
|
var _apiWithPasteOptionsT, _apiWithPasteOptionsT2;
|
|
339
384
|
if (!expValEquals('confluence_editor_paste_3p_link_actions_menu', 'isEnabled', true)) {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { type MutableRefObject } from 'react';
|
|
1
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model';
|
|
4
|
+
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model/types';
|
|
5
|
+
import { type CardContext } from '@atlaskit/link-provider/context';
|
|
4
6
|
import type { CardPlugin } from '../cardPluginType';
|
|
5
7
|
export declare const SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION_KEY = "smart-link-display-as-paste-menu-section";
|
|
8
|
+
type SmartCardClient = CardContext['connections']['client'];
|
|
6
9
|
export declare const setAppearanceSelection: ({ editorView, pasteStartPos, pasteEndPos, targetPos, }: {
|
|
7
10
|
editorView: EditorView;
|
|
8
11
|
pasteEndPos: number;
|
|
@@ -17,9 +20,11 @@ export declare const normalizeSelectionToLinkRangeForUrlAppearance: ({ editorVie
|
|
|
17
20
|
editorView: EditorView;
|
|
18
21
|
targetPos: number | undefined;
|
|
19
22
|
}) => void;
|
|
20
|
-
export declare const getPasteDisplayAsMenuComponents: ({ api, allowBlockCards, allowEmbeds, getEditorView, }: {
|
|
23
|
+
export declare const getPasteDisplayAsMenuComponents: ({ api, allowBlockCards, allowEmbeds, getEditorView, smartCardClientRef, }: {
|
|
21
24
|
allowBlockCards: boolean;
|
|
22
25
|
allowEmbeds?: boolean;
|
|
23
26
|
api: ExtractInjectionAPI<CardPlugin> | undefined;
|
|
24
27
|
getEditorView: () => EditorView | undefined;
|
|
28
|
+
smartCardClientRef: MutableRefObject<SmartCardClient | undefined>;
|
|
25
29
|
}) => RegisterComponent[];
|
|
30
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.1.1",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"atlaskit:src": "src/index.ts",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atlaskit/adf-schema": "^56.
|
|
24
|
+
"@atlaskit/adf-schema": "^56.1.0",
|
|
25
25
|
"@atlaskit/analytics-next": "^12.2.0",
|
|
26
26
|
"@atlaskit/button": "^24.3.0",
|
|
27
27
|
"@atlaskit/css": "^1.0.0",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"@atlaskit/editor-toolbar": "^2.1.0",
|
|
46
46
|
"@atlaskit/frontend-utilities": "^4.1.0",
|
|
47
47
|
"@atlaskit/icon": "^36.2.0",
|
|
48
|
+
"@atlaskit/json-ld-types": "^2.0.0",
|
|
48
49
|
"@atlaskit/link": "^4.1.0",
|
|
49
50
|
"@atlaskit/link-analytics": "^12.1.0",
|
|
50
51
|
"@atlaskit/link-client-extension": "^7.1.0",
|
|
@@ -55,11 +56,11 @@
|
|
|
55
56
|
"@atlaskit/menu": "^9.1.0",
|
|
56
57
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
57
58
|
"@atlaskit/platform-feature-flags-react": "^1.1.0",
|
|
58
|
-
"@atlaskit/primitives": "^20.
|
|
59
|
+
"@atlaskit/primitives": "^20.5.0",
|
|
59
60
|
"@atlaskit/prosemirror-history": "^1.0.0",
|
|
60
|
-
"@atlaskit/smart-card": "^45.
|
|
61
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
62
|
-
"@atlaskit/tokens": "^15.
|
|
61
|
+
"@atlaskit/smart-card": "^45.8.0",
|
|
62
|
+
"@atlaskit/tmp-editor-statsig": "^123.0.0",
|
|
63
|
+
"@atlaskit/tokens": "^15.5.0",
|
|
63
64
|
"@babel/runtime": "^7.0.0",
|
|
64
65
|
"@emotion/react": "^11.7.1",
|
|
65
66
|
"lodash": "^4.17.21",
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
"uuid": "^3.1.0"
|
|
69
70
|
},
|
|
70
71
|
"peerDependencies": {
|
|
71
|
-
"@atlaskit/editor-common": "^116.
|
|
72
|
+
"@atlaskit/editor-common": "^116.24.0",
|
|
72
73
|
"@atlaskit/link-provider": "^5.2.0",
|
|
73
74
|
"react": "^18.2.0",
|
|
74
75
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|