@atlaskit/editor-plugin-card 4.5.16 → 4.5.18
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/nodeviews/blockCard.js +19 -6
- package/dist/cjs/nodeviews/embedCard.js +16 -1
- package/dist/cjs/nodeviews/inlineCard.js +17 -5
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +18 -3
- package/dist/cjs/pm-plugins/actions.js +12 -3
- package/dist/cjs/pm-plugins/doc.js +5 -25
- package/dist/cjs/pm-plugins/reducers.js +13 -0
- package/dist/cjs/pm-plugins/util/resolve.js +2 -8
- package/dist/cjs/pm-plugins/utils.js +1 -4
- package/dist/cjs/ui/EditLinkToolbar.js +2 -8
- package/dist/cjs/ui/ResizableEmbedCard.js +1 -1
- package/dist/cjs/ui/analytics/events-from-tr.js +0 -3
- package/dist/cjs/ui/analytics/utils.js +1 -4
- package/dist/cjs/ui/editDatasourceAction.js +1 -4
- package/dist/cjs/ui/toolbar.js +7 -28
- package/dist/es2019/nodeviews/blockCard.js +20 -7
- package/dist/es2019/nodeviews/embedCard.js +17 -2
- package/dist/es2019/nodeviews/inlineCard.js +21 -7
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +12 -1
- package/dist/es2019/pm-plugins/actions.js +7 -2
- package/dist/es2019/pm-plugins/doc.js +7 -33
- package/dist/es2019/pm-plugins/reducers.js +12 -0
- package/dist/es2019/pm-plugins/util/resolve.js +2 -8
- package/dist/es2019/pm-plugins/utils.js +2 -8
- package/dist/es2019/ui/EditLinkToolbar.js +2 -8
- package/dist/es2019/ui/ResizableEmbedCard.js +1 -1
- package/dist/es2019/ui/analytics/events-from-tr.js +0 -3
- package/dist/es2019/ui/analytics/utils.js +1 -4
- package/dist/es2019/ui/editDatasourceAction.js +1 -4
- package/dist/es2019/ui/toolbar.js +7 -28
- package/dist/esm/nodeviews/blockCard.js +20 -7
- package/dist/esm/nodeviews/embedCard.js +17 -2
- package/dist/esm/nodeviews/inlineCard.js +19 -7
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +18 -3
- package/dist/esm/pm-plugins/actions.js +11 -2
- package/dist/esm/pm-plugins/doc.js +5 -25
- package/dist/esm/pm-plugins/reducers.js +13 -0
- package/dist/esm/pm-plugins/util/resolve.js +2 -8
- package/dist/esm/pm-plugins/utils.js +1 -4
- package/dist/esm/ui/EditLinkToolbar.js +2 -8
- package/dist/esm/ui/ResizableEmbedCard.js +1 -1
- package/dist/esm/ui/analytics/events-from-tr.js +0 -3
- package/dist/esm/ui/analytics/utils.js +1 -4
- package/dist/esm/ui/editDatasourceAction.js +1 -4
- package/dist/esm/ui/toolbar.js +7 -28
- package/dist/types/nodeviews/blockCard.d.ts +8 -2
- package/dist/types/nodeviews/embedCard.d.ts +8 -2
- package/dist/types/nodeviews/genericCard.d.ts +3 -1
- package/dist/types/pm-plugins/actions.d.ts +2 -1
- package/dist/types/pm-plugins/util/state.d.ts +1 -0
- package/dist/types/types/index.d.ts +7 -1
- package/dist/types/ui/datasourceErrorBoundary.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/blockCard.d.ts +8 -2
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +8 -2
- package/dist/types-ts4.5/nodeviews/genericCard.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/util/state.d.ts +1 -0
- package/dist/types-ts4.5/types/index.d.ts +7 -1
- package/dist/types-ts4.5/ui/datasourceErrorBoundary.d.ts +1 -1
- package/package.json +26 -22
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
14
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
15
|
var _react = _interopRequireDefault(require("react"));
|
|
16
16
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
17
|
+
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
17
18
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
18
19
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
19
20
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
@@ -54,7 +55,8 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
|
|
|
54
55
|
view.dispatch((0, _actions.registerCard)({
|
|
55
56
|
title: title,
|
|
56
57
|
url: url,
|
|
57
|
-
pos: pos
|
|
58
|
+
pos: pos,
|
|
59
|
+
id: _this.props.id
|
|
58
60
|
})(view.state.tr));
|
|
59
61
|
})();
|
|
60
62
|
});
|
|
@@ -120,6 +122,7 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
120
122
|
args[_key] = arguments[_key];
|
|
121
123
|
}
|
|
122
124
|
_this2 = _callSuper(this, BlockCard, [].concat(args));
|
|
125
|
+
(0, _defineProperty2.default)(_this2, "id", (0, _v.default)());
|
|
123
126
|
(0, _defineProperty2.default)(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
|
|
124
127
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
125
128
|
});
|
|
@@ -177,7 +180,8 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
177
180
|
getPos: this.getPos,
|
|
178
181
|
actionOptions: actionOptions,
|
|
179
182
|
pluginInjectionApi: pluginInjectionApi,
|
|
180
|
-
onClickCallback: onClickCallback
|
|
183
|
+
onClickCallback: onClickCallback,
|
|
184
|
+
id: this.id
|
|
181
185
|
});
|
|
182
186
|
}
|
|
183
187
|
}, {
|
|
@@ -185,6 +189,18 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
185
189
|
value: function destroy() {
|
|
186
190
|
var _this$unsubscribe;
|
|
187
191
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
|
|
192
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
|
|
193
|
+
this.removeCard();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}, {
|
|
197
|
+
key: "removeCard",
|
|
198
|
+
value: function removeCard() {
|
|
199
|
+
var tr = this.view.state.tr;
|
|
200
|
+
(0, _actions.removeCard)({
|
|
201
|
+
id: this.id
|
|
202
|
+
})(tr);
|
|
203
|
+
this.view.dispatch(tr);
|
|
188
204
|
}
|
|
189
205
|
}]);
|
|
190
206
|
}(_reactNodeView.default);
|
|
@@ -195,10 +211,7 @@ var blockCardNodeView = exports.blockCardNodeView = function blockCardNodeView(_
|
|
|
195
211
|
onClickCallback = _ref3.onClickCallback,
|
|
196
212
|
allowDatasource = _ref3.allowDatasource,
|
|
197
213
|
inlineCardViewProducer = _ref3.inlineCardViewProducer;
|
|
198
|
-
return function (node, view, getPos, decorations
|
|
199
|
-
// Ignored via go/ees005
|
|
200
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
201
|
-
) {
|
|
214
|
+
return function (node, view, getPos, decorations) {
|
|
202
215
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
203
216
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher;
|
|
204
217
|
var reactComponentProps = {
|
|
@@ -15,6 +15,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
15
15
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
16
16
|
var _react = _interopRequireDefault(require("react"));
|
|
17
17
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
18
|
+
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
18
19
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
19
20
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
20
21
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
@@ -162,7 +163,8 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
|
|
|
162
163
|
return view.dispatch((0, _actions.registerCard)({
|
|
163
164
|
title: title,
|
|
164
165
|
url: url,
|
|
165
|
-
pos: pos
|
|
166
|
+
pos: pos,
|
|
167
|
+
id: _this.props.id
|
|
166
168
|
})(view.state.tr));
|
|
167
169
|
})();
|
|
168
170
|
try {
|
|
@@ -345,6 +347,7 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
345
347
|
args[_key] = arguments[_key];
|
|
346
348
|
}
|
|
347
349
|
_this2 = _callSuper(this, EmbedCard, [].concat(args));
|
|
350
|
+
(0, _defineProperty2.default)(_this2, "id", (0, _v.default)());
|
|
348
351
|
(0, _defineProperty2.default)(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
|
|
349
352
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
350
353
|
});
|
|
@@ -405,6 +408,18 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
405
408
|
value: function destroy() {
|
|
406
409
|
var _this$unsubscribe;
|
|
407
410
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
|
|
411
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
|
|
412
|
+
this.removeCard();
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}, {
|
|
416
|
+
key: "removeCard",
|
|
417
|
+
value: function removeCard() {
|
|
418
|
+
var tr = this.view.state.tr;
|
|
419
|
+
(0, _actions.removeCard)({
|
|
420
|
+
id: this.id
|
|
421
|
+
})(tr);
|
|
422
|
+
this.view.dispatch(tr);
|
|
408
423
|
}
|
|
409
424
|
}]);
|
|
410
425
|
}(_reactNodeView.default);
|
|
@@ -12,6 +12,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
12
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
15
|
+
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
15
16
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
16
17
|
var _link = require("@atlaskit/editor-common/link");
|
|
17
18
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
@@ -40,6 +41,19 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
40
41
|
var _node$attrs = node.attrs,
|
|
41
42
|
url = _node$attrs.url,
|
|
42
43
|
data = _node$attrs.data;
|
|
44
|
+
var refId = (0, _react.useRef)((0, _v.default)());
|
|
45
|
+
(0, _react.useEffect)(function () {
|
|
46
|
+
var id = refId.current;
|
|
47
|
+
return function () {
|
|
48
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
|
|
49
|
+
var tr = view.state.tr;
|
|
50
|
+
(0, _actions.removeCard)({
|
|
51
|
+
id: id
|
|
52
|
+
})(tr);
|
|
53
|
+
view.dispatch(tr);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}, [getPos, view]);
|
|
43
57
|
var scrollContainer = (0, _react.useMemo)(
|
|
44
58
|
// Ignored via go/ees005
|
|
45
59
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -64,7 +78,8 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
64
78
|
(0, _actions.registerCard)({
|
|
65
79
|
title: title,
|
|
66
80
|
url: url,
|
|
67
|
-
pos: pos
|
|
81
|
+
pos: pos,
|
|
82
|
+
id: refId.current
|
|
68
83
|
})(tr);
|
|
69
84
|
onRes === null || onRes === void 0 || onRes(tr, title);
|
|
70
85
|
view.dispatch(tr);
|
|
@@ -170,10 +185,7 @@ function InlineCardNodeView(props) {
|
|
|
170
185
|
}
|
|
171
186
|
var inlineCardNodeView = exports.inlineCardNodeView = function inlineCardNodeView(_ref2) {
|
|
172
187
|
var inlineCardViewProducer = _ref2.inlineCardViewProducer;
|
|
173
|
-
return function (node, view, getPos, decorations
|
|
174
|
-
// Ignored via go/ees005
|
|
175
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
176
|
-
) {
|
|
188
|
+
return function (node, view, getPos, decorations) {
|
|
177
189
|
return inlineCardViewProducer(node, view, getPos, decorations);
|
|
178
190
|
};
|
|
179
191
|
};
|
|
@@ -8,7 +8,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.InlineCardWithAwareness = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _actions = require("../pm-plugins/actions");
|
|
13
|
+
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
12
14
|
var _AwarenessWrapper = require("../ui/AwarenessWrapper");
|
|
13
15
|
var _inlineCard = require("./inlineCard");
|
|
14
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -38,9 +40,22 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
|
|
|
38
40
|
isResolvedViewRendered = _useState6[0],
|
|
39
41
|
setIsResolvedViewRendered = _useState6[1];
|
|
40
42
|
var onResolve = (0, _react.useCallback)(function (tr, title) {
|
|
41
|
-
(0,
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
|
|
44
|
+
var metadata = tr.getMeta(_pluginKey.pluginKey);
|
|
45
|
+
if (metadata && metadata.type === 'REGISTER') {
|
|
46
|
+
(0, _actions.registerRemoveOverlay)(function () {
|
|
47
|
+
return setIsInserted(false);
|
|
48
|
+
}, metadata.info)(tr);
|
|
49
|
+
} else {
|
|
50
|
+
(0, _actions.registerRemoveOverlay)(function () {
|
|
51
|
+
return setIsInserted(false);
|
|
52
|
+
})(tr);
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
(0, _actions.registerRemoveOverlay)(function () {
|
|
56
|
+
return setIsInserted(false);
|
|
57
|
+
})(tr);
|
|
58
|
+
}
|
|
44
59
|
if (title) {
|
|
45
60
|
setIsResolvedViewRendered(true);
|
|
46
61
|
}
|
|
@@ -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.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;
|
|
6
|
+
exports.showLinkToolbar = exports.showDatasourceModal = exports.setProvider = exports.setDatasourceTableRef = exports.setDatasourceStash = exports.setCardLayoutAndDatasourceTableRef = exports.setCardLayout = exports.resolveCard = exports.removeDatasourceStash = exports.removeCard = 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);
|
|
@@ -32,11 +32,20 @@ var registerCard = exports.registerCard = function registerCard(info) {
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
-
var
|
|
35
|
+
var removeCard = exports.removeCard = function removeCard(info) {
|
|
36
|
+
return function (tr) {
|
|
37
|
+
return cardAction(tr, {
|
|
38
|
+
type: 'REMOVE_CARD',
|
|
39
|
+
info: info
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
var registerRemoveOverlay = exports.registerRemoveOverlay = function registerRemoveOverlay(callback, info) {
|
|
36
44
|
return function (tr) {
|
|
37
45
|
return cardAction(tr, {
|
|
38
46
|
type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK',
|
|
39
|
-
callback: callback
|
|
47
|
+
callback: callback,
|
|
48
|
+
info: info
|
|
40
49
|
});
|
|
41
50
|
};
|
|
42
51
|
};
|
|
@@ -24,8 +24,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
24
24
|
/**
|
|
25
25
|
* Attempt to replace the link into the respective card.
|
|
26
26
|
*/
|
|
27
|
-
// Ignored via go/ees005
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
29
27
|
function replaceLinksToCards(tr, cardAdf, schema, request) {
|
|
30
28
|
var inlineCard = schema.nodes.inlineCard;
|
|
31
29
|
var url = request.url;
|
|
@@ -63,10 +61,7 @@ function replaceLinksToCards(tr, cardAdf, schema, request) {
|
|
|
63
61
|
}
|
|
64
62
|
return $pos.node($pos.depth - 1).type.name;
|
|
65
63
|
}
|
|
66
|
-
var replaceQueuedUrlWithCard = exports.replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, cardData, analyticsAction, editorAnalyticsApi, createAnalyticsEvent
|
|
67
|
-
// Ignored via go/ees005
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
69
|
-
) {
|
|
64
|
+
var replaceQueuedUrlWithCard = exports.replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, cardData, analyticsAction, editorAnalyticsApi, createAnalyticsEvent) {
|
|
70
65
|
return function (editorState, dispatch) {
|
|
71
66
|
var state = _pluginKey.pluginKey.getState(editorState);
|
|
72
67
|
if (!state) {
|
|
@@ -204,10 +199,7 @@ var queueCardsFromChangedTr = exports.queueCardsFromChangedTr = function queueCa
|
|
|
204
199
|
var queueCardFromChangedTr = exports.queueCardFromChangedTr = function queueCardFromChangedTr(state, tr, source, analyticsAction) {
|
|
205
200
|
var normalizeLinkText = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
206
201
|
var sourceEvent = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : undefined;
|
|
207
|
-
var previousAppearance
|
|
208
|
-
// Ignored via go/ees005
|
|
209
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
210
|
-
= arguments.length > 6 ? arguments[6] : undefined;
|
|
202
|
+
var previousAppearance = arguments.length > 6 ? arguments[6] : undefined;
|
|
211
203
|
var schema = state.schema;
|
|
212
204
|
var link = schema.marks.link;
|
|
213
205
|
var requests = [];
|
|
@@ -267,10 +259,7 @@ var convertHyperlinkToSmartCard = exports.convertHyperlinkToSmartCard = function
|
|
|
267
259
|
});
|
|
268
260
|
return (0, _actions.queueCards)(requests)(state.tr);
|
|
269
261
|
};
|
|
270
|
-
var changeSelectedCardToLink = exports.changeSelectedCardToLink = function changeSelectedCardToLink(text, href, sendAnalytics, node, pos, editorAnalyticsApi
|
|
271
|
-
// Ignored via go/ees005
|
|
272
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
273
|
-
) {
|
|
262
|
+
var changeSelectedCardToLink = exports.changeSelectedCardToLink = function changeSelectedCardToLink(text, href, sendAnalytics, node, pos, editorAnalyticsApi) {
|
|
274
263
|
return function (state, dispatch) {
|
|
275
264
|
var selectedNode = state.selection instanceof _state.NodeSelection ? state.selection.node : undefined;
|
|
276
265
|
var tr;
|
|
@@ -299,10 +288,7 @@ var changeSelectedCardToLink = exports.changeSelectedCardToLink = function chang
|
|
|
299
288
|
return true;
|
|
300
289
|
};
|
|
301
290
|
};
|
|
302
|
-
var changeSelectedCardToLinkFallback = exports.changeSelectedCardToLinkFallback = function changeSelectedCardToLinkFallback(text, href, sendAnalytics, node, pos, editorAnalyticsApi
|
|
303
|
-
// Ignored via go/ees005
|
|
304
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
305
|
-
) {
|
|
291
|
+
var changeSelectedCardToLinkFallback = exports.changeSelectedCardToLinkFallback = function changeSelectedCardToLinkFallback(text, href, sendAnalytics, node, pos, editorAnalyticsApi) {
|
|
306
292
|
return function (state, dispatch) {
|
|
307
293
|
var tr;
|
|
308
294
|
if (node && pos) {
|
|
@@ -353,9 +339,6 @@ function cardToLinkWithTransaction(state, text, href) {
|
|
|
353
339
|
})]), false);
|
|
354
340
|
return tr;
|
|
355
341
|
}
|
|
356
|
-
|
|
357
|
-
// Ignored via go/ees005
|
|
358
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
359
342
|
function cardNodeToLinkWithTransaction(state, text, href, node, pos) {
|
|
360
343
|
var link = state.schema.marks.link;
|
|
361
344
|
var url = node.attrs.url || node.attrs.data.url;
|
|
@@ -521,10 +504,7 @@ var updateCardViaDatasource = exports.updateCardViaDatasource = function updateC
|
|
|
521
504
|
}
|
|
522
505
|
view.dispatch(tr.scrollIntoView());
|
|
523
506
|
};
|
|
524
|
-
var insertDatasource = exports.insertDatasource = function insertDatasource(state, adf, view, sourceEvent
|
|
525
|
-
// Ignored via go/ees005
|
|
526
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
527
|
-
) {
|
|
507
|
+
var insertDatasource = exports.insertDatasource = function insertDatasource(state, adf, view, sourceEvent) {
|
|
528
508
|
var tr = state.tr,
|
|
529
509
|
from = state.selection.from,
|
|
530
510
|
schemaNodes = state.schema.nodes;
|
|
@@ -35,6 +35,13 @@ var register = function register(state, action) {
|
|
|
35
35
|
}).concat(action.info)
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
|
+
var removeCard = function removeCard(state, action) {
|
|
39
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
40
|
+
cards: state.cards.filter(function (card) {
|
|
41
|
+
return card.id !== action.info.id;
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
};
|
|
38
45
|
var setProvider = function setProvider(state, action) {
|
|
39
46
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
40
47
|
provider: action.provider
|
|
@@ -85,6 +92,10 @@ var clearOverlayCandidate = function clearOverlayCandidate(state) {
|
|
|
85
92
|
};
|
|
86
93
|
var registerRemoveOverlayOnInsertedLink = function registerRemoveOverlayOnInsertedLink(state, action) {
|
|
87
94
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
95
|
+
cards: action.info ? state.cards.filter(function (card) {
|
|
96
|
+
var _action$info;
|
|
97
|
+
return card.pos !== ((_action$info = action.info) === null || _action$info === void 0 ? void 0 : _action$info.pos);
|
|
98
|
+
}).concat(action.info) : state.cards,
|
|
88
99
|
removeOverlay: action.callback
|
|
89
100
|
});
|
|
90
101
|
};
|
|
@@ -114,6 +125,8 @@ var _default = exports.default = function _default(state, action) {
|
|
|
114
125
|
return resolve(state, action);
|
|
115
126
|
case 'REGISTER':
|
|
116
127
|
return register(state, action);
|
|
128
|
+
case 'REMOVE_CARD':
|
|
129
|
+
return removeCard(state, action);
|
|
117
130
|
case 'REGISTER_EVENTS':
|
|
118
131
|
return registerEvents(state, action);
|
|
119
132
|
case 'SET_DATASOURCE_TABLE_REF':
|
|
@@ -34,10 +34,7 @@ var isFreshlyPastedOnNewLine = function isFreshlyPastedOnNewLine(view) {
|
|
|
34
34
|
// ============================================================================ //
|
|
35
35
|
// Used for all interactions with the EditorCardProvider.
|
|
36
36
|
// ============================================================================ //
|
|
37
|
-
var resolveWithProvider = exports.resolveWithProvider = function resolveWithProvider(view, provider, request, options, editorAnalyticsApi, createAnalyticsEvent
|
|
38
|
-
// Ignored via go/ees005
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
40
|
-
) {
|
|
37
|
+
var resolveWithProvider = exports.resolveWithProvider = function resolveWithProvider(view, provider, request, options, editorAnalyticsApi, createAnalyticsEvent) {
|
|
41
38
|
var isEmbedFriendlyLocation = (0, _platformFeatureFlags.fg)('hardcoded-embeds-only-on-new-line') ? isFreshlyPastedOnNewLine(view) : true;
|
|
42
39
|
|
|
43
40
|
// When user manually changes appearance from blue link to smart link, we should respect that,
|
|
@@ -67,10 +64,7 @@ var updateCardType = function updateCardType(resolvedCard, options) {
|
|
|
67
64
|
resolvedCard.type = 'inlineCard';
|
|
68
65
|
}
|
|
69
66
|
};
|
|
70
|
-
var handleResolved = function handleResolved(view, request, editorAnalyticsApi, createAnalyticsEvent, options
|
|
71
|
-
// Ignored via go/ees005
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
73
|
-
) {
|
|
67
|
+
var handleResolved = function handleResolved(view, request, editorAnalyticsApi, createAnalyticsEvent, options) {
|
|
74
68
|
return function (resolvedCard) {
|
|
75
69
|
updateCardType(resolvedCard, options);
|
|
76
70
|
(0, _doc.replaceQueuedUrlWithCard)(request.url, resolvedCard, request.analyticsAction, editorAnalyticsApi, createAnalyticsEvent)(view.state, view.dispatch);
|
|
@@ -57,10 +57,7 @@ var findCardInfo = exports.findCardInfo = function findCardInfo(state) {
|
|
|
57
57
|
return cardInfo.pos === state.selection.from;
|
|
58
58
|
});
|
|
59
59
|
};
|
|
60
|
-
var isAppearanceSupportedInParent = function isAppearanceSupportedInParent(currentNodePosition, editorState, fragment, currentAppearance
|
|
61
|
-
// Ignored via go/ees005
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
63
|
-
) {
|
|
60
|
+
var isAppearanceSupportedInParent = function isAppearanceSupportedInParent(currentNodePosition, editorState, fragment, currentAppearance) {
|
|
64
61
|
var resolvedPosition = editorState.doc.resolve(currentNodePosition);
|
|
65
62
|
var parent = currentAppearance === 'embed' || currentAppearance === 'block' ? resolvedPosition.node() : resolvedPosition.node(-1);
|
|
66
63
|
return parent && parent.type.validContent(fragment);
|
|
@@ -102,10 +102,7 @@ var EditLinkToolbar = exports.EditLinkToolbar = /*#__PURE__*/function (_React$Co
|
|
|
102
102
|
// via the floating toolbar
|
|
103
103
|
,
|
|
104
104
|
invokeMethod: _analytics.INPUT_METHOD.FLOATING_TB,
|
|
105
|
-
lpLinkPicker: lpLinkPicker
|
|
106
|
-
// Ignored via go/ees005
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
108
|
-
,
|
|
105
|
+
lpLinkPicker: lpLinkPicker,
|
|
109
106
|
onSubmit: function onSubmit(href, title, displayText, inputMethod, analytic) {
|
|
110
107
|
_this.hideLinkToolbar();
|
|
111
108
|
if (_onSubmit) {
|
|
@@ -176,10 +173,7 @@ var buildEditLinkToolbar = exports.buildEditLinkToolbar = function buildEditLink
|
|
|
176
173
|
text: displayInfo.title || '',
|
|
177
174
|
node: node,
|
|
178
175
|
lpLinkPicker: lpLinkPicker,
|
|
179
|
-
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 || (_pluginInjectionApi$f = _pluginInjectionApi$f.actions) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.forceFocusSelector
|
|
180
|
-
// Ignored via go/ees005
|
|
181
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
182
|
-
,
|
|
176
|
+
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 || (_pluginInjectionApi$f = _pluginInjectionApi$f.actions) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.forceFocusSelector,
|
|
183
177
|
onSubmit: function onSubmit(newHref, newText, inputMethod, analytic) {
|
|
184
178
|
var urlChanged = newHref !== displayInfo.url;
|
|
185
179
|
var titleChanged = newText !== displayInfo.title;
|
|
@@ -315,7 +315,7 @@ var ResizableEmbedCard = exports.default = /*#__PURE__*/function (_React$Compone
|
|
|
315
315
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
316
316
|
display: 'block',
|
|
317
317
|
/* Fixes extra padding problem in Firefox */
|
|
318
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
318
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/use-tokens-typography -- Ignored via go/DSP-18766
|
|
319
319
|
fontSize: 0,
|
|
320
320
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/use-tokens-typography -- Ignored via go/DSP-18766
|
|
321
321
|
lineHeight: 0
|
|
@@ -83,9 +83,6 @@ var findChanged = exports.findChanged = function findChanged(tr, state) {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
// Ignored via go/ees005
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
89
86
|
stepMap.forEach(function (oldStart, oldEnd, newStart, newEnd) {
|
|
90
87
|
var _tr$docs2;
|
|
91
88
|
var before = tr.docs[i];
|
|
@@ -92,10 +92,7 @@ var findAtPositions = exports.findAtPositions = function findAtPositions(tr, pos
|
|
|
92
92
|
}
|
|
93
93
|
return entities;
|
|
94
94
|
};
|
|
95
|
-
var findInNodeRange = exports.findInNodeRange = function findInNodeRange(doc, from, to, predicate
|
|
96
|
-
// Ignored via go/ees005
|
|
97
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
98
|
-
) {
|
|
95
|
+
var findInNodeRange = exports.findInNodeRange = function findInNodeRange(doc, from, to, predicate) {
|
|
99
96
|
var entities = [];
|
|
100
97
|
doc.nodesBetween(from, to, function (node, pos) {
|
|
101
98
|
if (predicate(node)) {
|
|
@@ -7,10 +7,7 @@ exports.editDatasource = void 0;
|
|
|
7
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
8
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
9
|
var _actions = require("../pm-plugins/actions");
|
|
10
|
-
var editDatasource = exports.editDatasource = function editDatasource(datasourceId, editorAnalyticsApi, appearance, extensionKey
|
|
11
|
-
// Ignored via go/ees005
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
13
|
-
) {
|
|
10
|
+
var editDatasource = exports.editDatasource = function editDatasource(datasourceId, editorAnalyticsApi, appearance, extensionKey) {
|
|
14
11
|
return function (state, dispatch) {
|
|
15
12
|
var datasourceType = (0, _utils.getDatasourceType)(datasourceId);
|
|
16
13
|
if (dispatch && datasourceType) {
|
package/dist/cjs/ui/toolbar.js
CHANGED
|
@@ -103,10 +103,7 @@ var openLinkSettings = exports.openLinkSettings = function openLinkSettings(edit
|
|
|
103
103
|
return true;
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
|
-
var floatingToolbar = exports.floatingToolbar = function floatingToolbar(cardOptions, lpLinkPicker, linkPickerOptions, pluginInjectionApi, disableFloatingToolbar
|
|
107
|
-
// Ignored via go/ees005
|
|
108
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
109
|
-
) {
|
|
106
|
+
var floatingToolbar = exports.floatingToolbar = function floatingToolbar(cardOptions, lpLinkPicker, linkPickerOptions, pluginInjectionApi, disableFloatingToolbar) {
|
|
110
107
|
return function (state, intl, providerFactory) {
|
|
111
108
|
if (disableFloatingToolbar) {
|
|
112
109
|
return;
|
|
@@ -171,10 +168,7 @@ var unlinkCard = function unlinkCard(node, state, editorAnalyticsApi) {
|
|
|
171
168
|
return false;
|
|
172
169
|
};
|
|
173
170
|
};
|
|
174
|
-
var buildAlignmentOptions = function buildAlignmentOptions(state, intl, widthPluginDependencyApi, analyticsApi, cardOptions
|
|
175
|
-
// Ignored via go/ees005
|
|
176
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
177
|
-
) {
|
|
171
|
+
var buildAlignmentOptions = function buildAlignmentOptions(state, intl, widthPluginDependencyApi, analyticsApi, cardOptions) {
|
|
178
172
|
return (0, _card.buildLayoutButtons)(state, intl, state.schema.nodes.embedCard, widthPluginDependencyApi, analyticsApi, true, true, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowWrapping, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowAlignment);
|
|
179
173
|
};
|
|
180
174
|
var withToolbarMetadata = function withToolbarMetadata(command) {
|
|
@@ -199,10 +193,7 @@ var getToolbarViewedItem = function getToolbarViewedItem(url, display) {
|
|
|
199
193
|
}
|
|
200
194
|
}];
|
|
201
195
|
};
|
|
202
|
-
var generateToolbarItems = function generateToolbarItems(state, intl, providerFactory, cardOptions, lpLinkPicker, linkPicker, pluginInjectionApi
|
|
203
|
-
// Ignored via go/ees005
|
|
204
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
205
|
-
) {
|
|
196
|
+
var generateToolbarItems = function generateToolbarItems(state, intl, providerFactory, cardOptions, lpLinkPicker, linkPicker, pluginInjectionApi) {
|
|
206
197
|
return function (node) {
|
|
207
198
|
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$a2, _node$attrs;
|
|
208
199
|
var _titleUrlPairFromNode2 = (0, _utils3.titleUrlPairFromNode)(node),
|
|
@@ -395,10 +386,7 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
395
386
|
}
|
|
396
387
|
};
|
|
397
388
|
};
|
|
398
|
-
var getUnlinkButtonGroup = function getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi
|
|
399
|
-
// Ignored via go/ees005
|
|
400
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
401
|
-
) {
|
|
389
|
+
var getUnlinkButtonGroup = function getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi) {
|
|
402
390
|
return node.type === inlineCard ? [{
|
|
403
391
|
id: 'editor.link.unlink',
|
|
404
392
|
focusEditoronEnter: true,
|
|
@@ -423,10 +411,7 @@ var getSettingsButton = exports.getSettingsButton = function getSettingsButton(i
|
|
|
423
411
|
target: '_blank'
|
|
424
412
|
};
|
|
425
413
|
};
|
|
426
|
-
var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance
|
|
427
|
-
// Ignored via go/ees005
|
|
428
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
429
|
-
) {
|
|
414
|
+
var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state, cardOptions, currentAppearance) {
|
|
430
415
|
var _node$attrs2;
|
|
431
416
|
var toolbarItems = [];
|
|
432
417
|
var canShowAppearanceSwitch = function canShowAppearanceSwitch() {
|
|
@@ -535,17 +520,11 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
|
|
|
535
520
|
});
|
|
536
521
|
return toolbarItems;
|
|
537
522
|
};
|
|
538
|
-
var shouldRenderToolbarPulse = exports.shouldRenderToolbarPulse = function shouldRenderToolbarPulse(embedEnabled, appearance, status, isDiscoverabilityEnabled
|
|
539
|
-
// Ignored via go/ees005
|
|
540
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
541
|
-
) {
|
|
523
|
+
var shouldRenderToolbarPulse = exports.shouldRenderToolbarPulse = function shouldRenderToolbarPulse(embedEnabled, appearance, status, isDiscoverabilityEnabled) {
|
|
542
524
|
return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled;
|
|
543
525
|
};
|
|
544
526
|
var getStartingToolbarItems = exports.getStartingToolbarItems = function getStartingToolbarItems(options, api) {
|
|
545
|
-
return function (intl, link, onEditLink, metadata
|
|
546
|
-
// Ignored via go/ees005
|
|
547
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
548
|
-
) {
|
|
527
|
+
return function (intl, link, onEditLink, metadata) {
|
|
549
528
|
var editLinkItem = options.allowDatasource ? [{
|
|
550
529
|
type: 'custom',
|
|
551
530
|
fallback: [],
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import rafSchedule from 'raf-schd';
|
|
4
|
+
import uuid from 'uuid/v4';
|
|
4
5
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
5
6
|
import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
6
7
|
import { browser, canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
7
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
9
10
|
import { Datasource } from '../nodeviews/datasource';
|
|
10
|
-
import { registerCard } from '../pm-plugins/actions';
|
|
11
|
+
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
11
12
|
import { isDatasourceNode } from '../pm-plugins/utils';
|
|
12
13
|
import { Card } from './genericCard';
|
|
13
14
|
|
|
@@ -40,7 +41,8 @@ export class BlockCardComponent extends React.PureComponent {
|
|
|
40
41
|
view.dispatch(registerCard({
|
|
41
42
|
title,
|
|
42
43
|
url,
|
|
43
|
-
pos
|
|
44
|
+
pos,
|
|
45
|
+
id: this.props.id
|
|
44
46
|
})(view.state.tr));
|
|
45
47
|
})();
|
|
46
48
|
});
|
|
@@ -99,6 +101,7 @@ const WrappedBlockCard = Card(BlockCardComponent, UnsupportedBlock);
|
|
|
99
101
|
export class BlockCard extends ReactNodeView {
|
|
100
102
|
constructor(...args) {
|
|
101
103
|
super(...args);
|
|
104
|
+
_defineProperty(this, "id", uuid());
|
|
102
105
|
_defineProperty(this, "updateContentEditable", (editorViewModeState, divElement) => {
|
|
103
106
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
104
107
|
});
|
|
@@ -144,12 +147,25 @@ export class BlockCard extends ReactNodeView {
|
|
|
144
147
|
getPos: this.getPos,
|
|
145
148
|
actionOptions: actionOptions,
|
|
146
149
|
pluginInjectionApi: pluginInjectionApi,
|
|
147
|
-
onClickCallback: onClickCallback
|
|
150
|
+
onClickCallback: onClickCallback,
|
|
151
|
+
id: this.id
|
|
148
152
|
});
|
|
149
153
|
}
|
|
150
154
|
destroy() {
|
|
151
155
|
var _this$unsubscribe;
|
|
152
156
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
|
|
157
|
+
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
158
|
+
this.removeCard();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
removeCard() {
|
|
162
|
+
const {
|
|
163
|
+
tr
|
|
164
|
+
} = this.view.state;
|
|
165
|
+
removeCard({
|
|
166
|
+
id: this.id
|
|
167
|
+
})(tr);
|
|
168
|
+
this.view.dispatch(tr);
|
|
153
169
|
}
|
|
154
170
|
}
|
|
155
171
|
export const blockCardNodeView = ({
|
|
@@ -159,10 +175,7 @@ export const blockCardNodeView = ({
|
|
|
159
175
|
onClickCallback,
|
|
160
176
|
allowDatasource,
|
|
161
177
|
inlineCardViewProducer
|
|
162
|
-
}) => (node, view, getPos, decorations
|
|
163
|
-
// Ignored via go/ees005
|
|
164
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
165
|
-
) => {
|
|
178
|
+
}) => (node, view, getPos, decorations) => {
|
|
166
179
|
const {
|
|
167
180
|
portalProviderAPI,
|
|
168
181
|
eventDispatcher
|