@atlaskit/editor-plugin-card 34.0.0 → 34.0.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/nodeviews/blockCard.js +11 -2
- package/dist/cjs/nodeviews/inlineCardBase.js +16 -2
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +22 -6
- package/dist/cjs/pm-plugins/main.js +8 -1
- package/dist/cjs/pm-plugins/reducers.js +23 -4
- package/dist/cjs/ui/DatasourceAppearanceButton.js +2 -2
- package/dist/cjs/ui/EditToolbarButton/EditToolbarButtonPresentation.js +5 -5
- package/dist/cjs/ui/EditToolbarButton/index.js +5 -5
- package/dist/cjs/ui/HyperlinkToolbarAppearance.js +2 -2
- package/dist/cjs/ui/HyperlinkToolbarAppearanceDropdown.js +2 -2
- package/dist/cjs/ui/InlineCardOverlay/index.js +4 -0
- package/dist/cjs/ui/OpenPreviewButton/index.js +7 -5
- package/dist/cjs/ui/PasteDisplayAsMenu.js +6 -4
- package/dist/es2019/nodeviews/blockCard.js +11 -2
- package/dist/es2019/nodeviews/inlineCardBase.js +16 -2
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +19 -3
- package/dist/es2019/pm-plugins/main.js +8 -1
- package/dist/es2019/pm-plugins/reducers.js +24 -2
- package/dist/es2019/ui/DatasourceAppearanceButton.js +1 -1
- package/dist/es2019/ui/EditToolbarButton/EditToolbarButtonPresentation.js +1 -1
- package/dist/es2019/ui/EditToolbarButton/index.js +1 -1
- package/dist/es2019/ui/HyperlinkToolbarAppearance.js +1 -1
- package/dist/es2019/ui/HyperlinkToolbarAppearanceDropdown.js +1 -1
- package/dist/es2019/ui/InlineCardOverlay/index.js +4 -0
- package/dist/es2019/ui/OpenPreviewButton/index.js +3 -1
- package/dist/es2019/ui/PasteDisplayAsMenu.js +3 -1
- package/dist/esm/nodeviews/blockCard.js +11 -2
- package/dist/esm/nodeviews/inlineCardBase.js +16 -2
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +23 -7
- package/dist/esm/pm-plugins/main.js +8 -1
- package/dist/esm/pm-plugins/reducers.js +23 -4
- package/dist/esm/ui/DatasourceAppearanceButton.js +1 -1
- package/dist/esm/ui/EditToolbarButton/EditToolbarButtonPresentation.js +1 -1
- package/dist/esm/ui/EditToolbarButton/index.js +1 -1
- package/dist/esm/ui/HyperlinkToolbarAppearance.js +1 -1
- package/dist/esm/ui/HyperlinkToolbarAppearanceDropdown.js +1 -1
- package/dist/esm/ui/InlineCardOverlay/index.js +4 -0
- package/dist/esm/ui/OpenPreviewButton/index.js +3 -1
- package/dist/esm/ui/PasteDisplayAsMenu.js +3 -1
- package/dist/types/nodeviews/blockCard.d.ts +1 -0
- package/dist/types/pm-plugins/util/state.d.ts +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/ui/PreAuthValuePropositionModal.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 34.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`fc2f6ea92bf86`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fc2f6ea92bf86) -
|
|
8
|
+
Behind `platform_editor_reduce_memory_leaks`: stop retaining deleted inline and block cards.
|
|
9
|
+
Pending `registerCard` animation frames are cancelled on unmount, resolve-request cancel callbacks
|
|
10
|
+
are dropped once they fire, the `removeOverlay` callback is cleared when its card is removed and
|
|
11
|
+
no longer closes over the node view scope, and the inline card overlay cancels its resize debounce
|
|
12
|
+
on cleanup.
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 34.0.0
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -51,7 +51,7 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
|
|
|
51
51
|
|
|
52
52
|
// don't dispatch immediately since we might be in the middle of
|
|
53
53
|
// rendering a nodeview
|
|
54
|
-
(0, _rafSchd.default)(function () {
|
|
54
|
+
var scheduleRegisterCard = (0, _rafSchd.default)(function () {
|
|
55
55
|
var pos = getPos();
|
|
56
56
|
if (typeof pos !== 'number') {
|
|
57
57
|
return;
|
|
@@ -62,7 +62,11 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
|
|
|
62
62
|
pos: pos,
|
|
63
63
|
id: _this.props.id
|
|
64
64
|
})(view.state.tr));
|
|
65
|
-
})
|
|
65
|
+
});
|
|
66
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
|
|
67
|
+
_this.pendingRegisterCard = scheduleRegisterCard;
|
|
68
|
+
}
|
|
69
|
+
scheduleRegisterCard();
|
|
66
70
|
});
|
|
67
71
|
(0, _defineProperty2.default)(_this, "removeCardDispatched", false);
|
|
68
72
|
(0, _defineProperty2.default)(_this, "gapCursorSpan", function () {
|
|
@@ -94,6 +98,11 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
|
|
|
94
98
|
return (0, _createClass2.default)(BlockCardComponent, [{
|
|
95
99
|
key: "componentWillUnmount",
|
|
96
100
|
value: function componentWillUnmount() {
|
|
101
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
|
|
102
|
+
var _this$pendingRegister;
|
|
103
|
+
(_this$pendingRegister = this.pendingRegisterCard) === null || _this$pendingRegister === void 0 || _this$pendingRegister.cancel();
|
|
104
|
+
this.pendingRegisterCard = undefined;
|
|
105
|
+
}
|
|
97
106
|
this.removeCard();
|
|
98
107
|
}
|
|
99
108
|
}, {
|
|
@@ -43,6 +43,16 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
43
43
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
44
44
|
var refId = (0, _react.useRef)((0, _uuid.v4)());
|
|
45
45
|
var removeCardDispatched = (0, _react.useRef)(false);
|
|
46
|
+
var pendingRegisterCard = (0, _react.useRef)(null);
|
|
47
|
+
(0, _react.useEffect)(function () {
|
|
48
|
+
return function () {
|
|
49
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
|
|
50
|
+
var _pendingRegisterCard$;
|
|
51
|
+
(_pendingRegisterCard$ = pendingRegisterCard.current) === null || _pendingRegisterCard$ === void 0 || _pendingRegisterCard$.cancel();
|
|
52
|
+
pendingRegisterCard.current = null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
46
56
|
var _ref2 = (cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {},
|
|
47
57
|
getSmartlinkState = _ref2.getState;
|
|
48
58
|
var cardState = getSmartlinkState === null || getSmartlinkState === void 0 ? void 0 : getSmartlinkState()[url || ''];
|
|
@@ -74,7 +84,7 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
74
84
|
url = data.url;
|
|
75
85
|
// don't dispatch immediately since we might be in the middle of
|
|
76
86
|
// rendering a nodeview
|
|
77
|
-
(0, _rafSchd.default)(function () {
|
|
87
|
+
var scheduleRegisterCard = (0, _rafSchd.default)(function () {
|
|
78
88
|
// prosemirror-bump-fix
|
|
79
89
|
var pos = getPos();
|
|
80
90
|
if (typeof pos !== 'number') {
|
|
@@ -89,7 +99,11 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
89
99
|
})(tr);
|
|
90
100
|
onRes === null || onRes === void 0 || onRes(tr, title);
|
|
91
101
|
view.dispatch(tr);
|
|
92
|
-
})
|
|
102
|
+
});
|
|
103
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
|
|
104
|
+
pendingRegisterCard.current = scheduleRegisterCard;
|
|
105
|
+
}
|
|
106
|
+
scheduleRegisterCard();
|
|
93
107
|
}, [getPos, view, onRes]);
|
|
94
108
|
var onError = (0, _react.useCallback)(function (data) {
|
|
95
109
|
var url = data.url,
|
|
@@ -14,6 +14,7 @@ var _useSharedPluginStateWithSelector = require("@atlaskit/editor-common/useShar
|
|
|
14
14
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
15
|
var _extractSmartLinkEmbed = require("@atlaskit/link-extractors/extract-smart-link-embed");
|
|
16
16
|
var _isWithinPreviewPanelIframe = require("@atlaskit/linking-common/utils/is-within-preview-panel-iframe");
|
|
17
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
17
18
|
var _smartCard = require("@atlaskit/smart-card");
|
|
18
19
|
var _useSmartLinkDestinationUrl = require("@atlaskit/smart-card/hook/use-smart-link-destination-url");
|
|
19
20
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
@@ -23,6 +24,14 @@ var _AwarenessWrapper = require("../ui/AwarenessWrapper");
|
|
|
23
24
|
var _PreviewInvoker = require("../ui/preview/PreviewInvoker");
|
|
24
25
|
var _inlineCardBase = require("./inlineCardBase");
|
|
25
26
|
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 _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
27
|
+
// Module scope so the stored callback's closure chain cannot reach the
|
|
28
|
+
// component scope (getPos, node, view) via V8 context sharing.
|
|
29
|
+
var createRemoveOverlay = function createRemoveOverlay(setIsInsertedRef) {
|
|
30
|
+
return function () {
|
|
31
|
+
var _setIsInsertedRef$cur;
|
|
32
|
+
return (_setIsInsertedRef$cur = setIsInsertedRef.current) === null || _setIsInsertedRef$cur === void 0 ? void 0 : _setIsInsertedRef$cur.call(setIsInsertedRef, false);
|
|
33
|
+
};
|
|
34
|
+
};
|
|
26
35
|
var selector = function selector(states) {
|
|
27
36
|
var _states$editorViewMod, _states$selectionStat;
|
|
28
37
|
return {
|
|
@@ -54,6 +63,14 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
|
|
|
54
63
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
55
64
|
isInserted = _useState4[0],
|
|
56
65
|
setIsInserted = _useState4[1];
|
|
66
|
+
var setIsInsertedRef = (0, _react.useRef)(setIsInserted);
|
|
67
|
+
(0, _react.useEffect)(function () {
|
|
68
|
+
return function () {
|
|
69
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
|
|
70
|
+
setIsInsertedRef.current = undefined;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}, []);
|
|
57
74
|
var _useState5 = (0, _react.useState)(false),
|
|
58
75
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
59
76
|
isResolvedViewRendered = _useState6[0],
|
|
@@ -62,14 +79,13 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
|
|
|
62
79
|
var destinationUrl = (0, _useSmartLinkDestinationUrl.useSmartLinkDestinationUrl)(node.attrs.url);
|
|
63
80
|
var onResolve = (0, _react.useCallback)(function (tr, title) {
|
|
64
81
|
var metadata = tr.getMeta(_pluginKey.pluginKey);
|
|
82
|
+
var removeOverlay = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks') ? createRemoveOverlay(setIsInsertedRef) : function () {
|
|
83
|
+
return setIsInserted(false);
|
|
84
|
+
};
|
|
65
85
|
if (metadata && metadata.type === 'REGISTER') {
|
|
66
|
-
(0, _actions.registerRemoveOverlay)(
|
|
67
|
-
return setIsInserted(false);
|
|
68
|
-
}, metadata.info)(tr);
|
|
86
|
+
(0, _actions.registerRemoveOverlay)(removeOverlay, metadata.info)(tr);
|
|
69
87
|
} else {
|
|
70
|
-
(0, _actions.registerRemoveOverlay)(
|
|
71
|
-
return setIsInserted(false);
|
|
72
|
-
})(tr);
|
|
88
|
+
(0, _actions.registerRemoveOverlay)(removeOverlay)(tr);
|
|
73
89
|
}
|
|
74
90
|
if (title) {
|
|
75
91
|
setIsResolvedViewRendered(true);
|
|
@@ -15,6 +15,7 @@ var _smartCard = require("@atlaskit/editor-common/styles/smartCard");
|
|
|
15
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
16
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
17
17
|
var _constants = require("@atlaskit/linking-common/constants");
|
|
18
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
18
19
|
var _blockCard = require("../nodeviews/blockCard");
|
|
19
20
|
var _embedCard = require("../nodeviews/embedCard");
|
|
20
21
|
var _inlineCard = require("../nodeviews/inlineCard");
|
|
@@ -239,7 +240,13 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
|
|
|
239
240
|
*/
|
|
240
241
|
var invoke = (0, _rafSchd.default)(function () {
|
|
241
242
|
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$a3, _currentState$embedCa;
|
|
242
|
-
|
|
243
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
|
|
244
|
+
var index = rafCancellationCallbacks.indexOf(invoke.cancel);
|
|
245
|
+
if (index !== -1) {
|
|
246
|
+
rafCancellationCallbacks.splice(index, 1);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
(0, _resolve.resolveWithProvider)(view, _provider, request, options, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, (_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 || (_pluginInjectionApi$a3 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined, currentState === null || currentState === void 0 || (_currentState$embedCa = currentState.embedCardTransformers) === null || _currentState$embedCa === void 0 ? void 0 : _currentState$embedCa.embedCardNodeTransformer);
|
|
243
250
|
});
|
|
244
251
|
rafCancellationCallbacks.push(invoke.cancel);
|
|
245
252
|
invoke();
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
11
12
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
13
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
14
|
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,10 +37,18 @@ var register = function register(state, action) {
|
|
|
36
37
|
});
|
|
37
38
|
};
|
|
38
39
|
var removeCard = function removeCard(state, action) {
|
|
40
|
+
var cards = state.cards.filter(function (card) {
|
|
41
|
+
return card.id !== action.info.id;
|
|
42
|
+
});
|
|
43
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks') && state.removeOverlayCardId !== undefined && state.removeOverlayCardId === action.info.id) {
|
|
44
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
45
|
+
cards: cards,
|
|
46
|
+
removeOverlay: undefined,
|
|
47
|
+
removeOverlayCardId: undefined
|
|
48
|
+
});
|
|
49
|
+
}
|
|
39
50
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
40
|
-
cards:
|
|
41
|
-
return card.id !== action.info.id;
|
|
42
|
-
})
|
|
51
|
+
cards: cards
|
|
43
52
|
});
|
|
44
53
|
};
|
|
45
54
|
var setProvider = function setProvider(state, action) {
|
|
@@ -91,18 +100,28 @@ var hideDatasourceModal = function hideDatasourceModal(state) {
|
|
|
91
100
|
});
|
|
92
101
|
};
|
|
93
102
|
var clearOverlayCandidate = function clearOverlayCandidate(state) {
|
|
103
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
|
|
104
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
105
|
+
overlayCandidatePosition: undefined,
|
|
106
|
+
removeOverlay: undefined,
|
|
107
|
+
removeOverlayCardId: undefined
|
|
108
|
+
});
|
|
109
|
+
}
|
|
94
110
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
95
111
|
overlayCandidatePosition: undefined
|
|
96
112
|
});
|
|
97
113
|
};
|
|
98
114
|
var registerRemoveOverlayOnInsertedLink = function registerRemoveOverlayOnInsertedLink(state, action) {
|
|
115
|
+
var _action$info2;
|
|
99
116
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
100
117
|
cards: action.info ? state.cards.filter(function (card) {
|
|
101
118
|
var _action$info;
|
|
102
119
|
return card.pos !== ((_action$info = action.info) === null || _action$info === void 0 ? void 0 : _action$info.pos);
|
|
103
120
|
}).concat(action.info) : state.cards,
|
|
104
121
|
removeOverlay: action.callback
|
|
105
|
-
})
|
|
122
|
+
}, (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks') ? {
|
|
123
|
+
removeOverlayCardId: (_action$info2 = action.info) === null || _action$info2 === void 0 ? void 0 : _action$info2.id
|
|
124
|
+
} : {});
|
|
106
125
|
};
|
|
107
126
|
var setDatasourceStash = function setDatasourceStash(state, action) {
|
|
108
127
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -13,7 +13,7 @@ var _datasource = require("@atlaskit/editor-common/utils/datasource");
|
|
|
13
13
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
14
|
var _schema = require("@atlaskit/link-datasource/utils/schema");
|
|
15
15
|
var _useSmartLinkContext = require("@atlaskit/link-provider/use-smart-link-context");
|
|
16
|
-
var
|
|
16
|
+
var _flex = require("@atlaskit/primitives/compiled/flex");
|
|
17
17
|
var _doc = require("../pm-plugins/doc");
|
|
18
18
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
19
19
|
var _DatasourceIcon = require("./DatasourceIcon");
|
|
@@ -95,7 +95,7 @@ var DatasourceAppearanceButtonWithCardContext = function DatasourceAppearanceBut
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
var buttonLabel = intl.formatMessage(_card.messages.datasourceAppearanceTitle);
|
|
98
|
-
return (0, _react2.jsx)(
|
|
98
|
+
return (0, _react2.jsx)(_flex.Flex, null, (0, _react2.jsx)(_Button.default, {
|
|
99
99
|
css: buttonStyles,
|
|
100
100
|
title: buttonLabel,
|
|
101
101
|
icon: (0, _react2.jsx)(_DatasourceIcon.DatasourceIcon, {
|
|
@@ -18,7 +18,7 @@ var _DropdownContainer = require("@atlaskit/editor-common/ui-menu/DropdownContai
|
|
|
18
18
|
var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/core/chevron-down"));
|
|
19
19
|
var _edit = _interopRequireDefault(require("@atlaskit/icon/core/edit"));
|
|
20
20
|
var _buttonItem = _interopRequireDefault(require("@atlaskit/menu/button-item"));
|
|
21
|
-
var
|
|
21
|
+
var _flex = require("@atlaskit/primitives/compiled/flex");
|
|
22
22
|
var _utils = require("../../pm-plugins/utils");
|
|
23
23
|
var _editDatasourceAction = require("../editDatasourceAction");
|
|
24
24
|
/**
|
|
@@ -73,7 +73,7 @@ var EditToolbarButtonPresentation = function EditToolbarButtonPresentation(_ref)
|
|
|
73
73
|
switch (editVariant) {
|
|
74
74
|
case 'edit-link':
|
|
75
75
|
{
|
|
76
|
-
return (0, _react2.jsx)(
|
|
76
|
+
return (0, _react2.jsx)(_flex.Flex, {
|
|
77
77
|
gap: "space.050"
|
|
78
78
|
}, (0, _react2.jsx)(_Button.default, {
|
|
79
79
|
testId: "edit-link",
|
|
@@ -91,7 +91,7 @@ var EditToolbarButtonPresentation = function EditToolbarButtonPresentation(_ref)
|
|
|
91
91
|
}
|
|
92
92
|
case 'edit-datasource':
|
|
93
93
|
{
|
|
94
|
-
return (0, _react2.jsx)(
|
|
94
|
+
return (0, _react2.jsx)(_flex.Flex, {
|
|
95
95
|
gap: "space.050"
|
|
96
96
|
}, (0, _react2.jsx)(_Button.default, {
|
|
97
97
|
testId: "edit-datasource",
|
|
@@ -107,7 +107,7 @@ var EditToolbarButtonPresentation = function EditToolbarButtonPresentation(_ref)
|
|
|
107
107
|
}
|
|
108
108
|
case 'edit-dropdown':
|
|
109
109
|
{
|
|
110
|
-
var trigger = (0, _react2.jsx)(
|
|
110
|
+
var trigger = (0, _react2.jsx)(_flex.Flex, {
|
|
111
111
|
gap: "space.050"
|
|
112
112
|
}, (0, _react2.jsx)(_Button.default, {
|
|
113
113
|
testId: "edit-dropdown-trigger",
|
|
@@ -128,7 +128,7 @@ var EditToolbarButtonPresentation = function EditToolbarButtonPresentation(_ref)
|
|
|
128
128
|
, _card.messages.editDropdownTriggerTitle)), !areAnyNewToolbarFlagsEnabled && (0, _react2.jsx)(_Separator.default, {
|
|
129
129
|
areAnyNewToolbarFlagsEnabled: false
|
|
130
130
|
}));
|
|
131
|
-
return (0, _react2.jsx)(
|
|
131
|
+
return (0, _react2.jsx)(_flex.Flex, {
|
|
132
132
|
ref: containerRef
|
|
133
133
|
}, (0, _react2.jsx)(_DropdownContainer.DropdownContainer, {
|
|
134
134
|
mountTo: containerRef.current,
|
|
@@ -19,7 +19,7 @@ var _DropdownContainer = require("@atlaskit/editor-common/ui-menu/DropdownContai
|
|
|
19
19
|
var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/core/chevron-down"));
|
|
20
20
|
var _useSmartLinkContext = require("@atlaskit/link-provider/use-smart-link-context");
|
|
21
21
|
var _buttonItem = _interopRequireDefault(require("@atlaskit/menu/button-item"));
|
|
22
|
-
var
|
|
22
|
+
var _flex = require("@atlaskit/primitives/compiled/flex");
|
|
23
23
|
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
24
24
|
var _utils = require("../../pm-plugins/utils");
|
|
25
25
|
var _editDatasourceAction = require("../editDatasourceAction");
|
|
@@ -100,7 +100,7 @@ var EditToolbarButtonWithCardContext = function EditToolbarButtonWithCardContext
|
|
|
100
100
|
switch (editVariant) {
|
|
101
101
|
case 'edit-link':
|
|
102
102
|
{
|
|
103
|
-
return (0, _react2.jsx)(
|
|
103
|
+
return (0, _react2.jsx)(_flex.Flex, {
|
|
104
104
|
gap: "space.050"
|
|
105
105
|
}, (0, _react2.jsx)(_Button.default, {
|
|
106
106
|
testId: "edit-link",
|
|
@@ -115,7 +115,7 @@ var EditToolbarButtonWithCardContext = function EditToolbarButtonWithCardContext
|
|
|
115
115
|
}
|
|
116
116
|
case 'edit-datasource':
|
|
117
117
|
{
|
|
118
|
-
return (0, _react2.jsx)(
|
|
118
|
+
return (0, _react2.jsx)(_flex.Flex, {
|
|
119
119
|
gap: "space.050"
|
|
120
120
|
}, (0, _react2.jsx)(_Button.default, {
|
|
121
121
|
testId: "edit-datasource",
|
|
@@ -131,7 +131,7 @@ var EditToolbarButtonWithCardContext = function EditToolbarButtonWithCardContext
|
|
|
131
131
|
}
|
|
132
132
|
case 'edit-dropdown':
|
|
133
133
|
{
|
|
134
|
-
var trigger = (0, _react2.jsx)(
|
|
134
|
+
var trigger = (0, _react2.jsx)(_flex.Flex, {
|
|
135
135
|
gap: "space.050"
|
|
136
136
|
}, (0, _react2.jsx)(_Button.default, {
|
|
137
137
|
testId: "edit-dropdown-trigger",
|
|
@@ -152,7 +152,7 @@ var EditToolbarButtonWithCardContext = function EditToolbarButtonWithCardContext
|
|
|
152
152
|
, _card.messages.editDropdownTriggerTitle)), !(0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') && (0, _react2.jsx)(_Separator.default, {
|
|
153
153
|
areAnyNewToolbarFlagsEnabled: false
|
|
154
154
|
}));
|
|
155
|
-
return (0, _react2.jsx)(
|
|
155
|
+
return (0, _react2.jsx)(_flex.Flex, {
|
|
156
156
|
ref: containerRef
|
|
157
157
|
}, (0, _react2.jsx)(_DropdownContainer.DropdownContainer, {
|
|
158
158
|
mountTo: containerRef.current,
|
|
@@ -13,7 +13,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
13
13
|
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
14
14
|
var _Separator = _interopRequireDefault(require("@atlaskit/editor-common/FloatingToolbar/Separator"));
|
|
15
15
|
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
16
|
-
var
|
|
16
|
+
var _flex = require("@atlaskit/primitives/compiled/flex");
|
|
17
17
|
var _DatasourceAppearanceButton = require("./DatasourceAppearanceButton");
|
|
18
18
|
var _LinkToolbarAppearance = require("./LinkToolbarAppearance");
|
|
19
19
|
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 _t5 in e) "default" !== _t5 && {}.hasOwnProperty.call(e, _t5) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t5)) && (i.get || i.set) ? o(f, _t5, i) : f[_t5] = e[_t5]); return f; })(e, t); }
|
|
@@ -138,7 +138,7 @@ function HyperlinkToolbarAppearance(props) {
|
|
|
138
138
|
return null;
|
|
139
139
|
}
|
|
140
140
|
var areAnyNewToolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean((_props$editorPluginAp2 = props.editorPluginApi) === null || _props$editorPluginAp2 === void 0 ? void 0 : _props$editorPluginAp2.toolbar));
|
|
141
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
141
|
+
return /*#__PURE__*/_react.default.createElement(_flex.Flex, null, /*#__PURE__*/_react.default.createElement(_LinkToolbarAppearance.LinkToolbarAppearance, {
|
|
142
142
|
key: "link-appearance",
|
|
143
143
|
url: url,
|
|
144
144
|
intl: intl,
|
|
@@ -17,7 +17,7 @@ var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
|
17
17
|
var _types = require("@atlaskit/editor-common/ui-menu/ArrowKeyNavigationProvider/types");
|
|
18
18
|
var _DropdownContainer = require("@atlaskit/editor-common/ui-menu/DropdownContainer");
|
|
19
19
|
var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/core/chevron-down"));
|
|
20
|
-
var
|
|
20
|
+
var _flex = require("@atlaskit/primitives/compiled/flex");
|
|
21
21
|
var _LinkToolbarAppearanceDropdown = require("./LinkToolbarAppearanceDropdown");
|
|
22
22
|
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 _t5 in e) "default" !== _t5 && {}.hasOwnProperty.call(e, _t5) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t5)) && (i.get || i.set) ? o(f, _t5, i) : f[_t5] = e[_t5]); return f; })(e, t); }
|
|
23
23
|
var CustomHyperlinkDropdown = function CustomHyperlinkDropdown(props) {
|
|
@@ -185,7 +185,7 @@ var CustomHyperlinkDropdown = function CustomHyperlinkDropdown(props) {
|
|
|
185
185
|
}),
|
|
186
186
|
areAnyNewToolbarFlagsEnabled: areAnyNewToolbarFlagsEnabled
|
|
187
187
|
}, title);
|
|
188
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
188
|
+
return /*#__PURE__*/_react.default.createElement(_flex.Flex, {
|
|
189
189
|
ref: containerRef,
|
|
190
190
|
gap: "space.075"
|
|
191
191
|
}, /*#__PURE__*/_react.default.createElement(_DropdownContainer.DropdownContainer, {
|
|
@@ -17,6 +17,7 @@ var _reactIntl = require("react-intl");
|
|
|
17
17
|
var _card = require("@atlaskit/editor-common/messages/card");
|
|
18
18
|
var _whitespace = require("@atlaskit/editor-common/whitespace/whitespace");
|
|
19
19
|
var _customize = _interopRequireDefault(require("@atlaskit/icon/core/customize"));
|
|
20
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
20
21
|
var _useSmartLinkDestinationUrl = require("@atlaskit/smart-card/hook/use-smart-link-destination-url");
|
|
21
22
|
var _utils = require("./utils");
|
|
22
23
|
var _excluded = ["children", "isSelected", "isVisible", "testId", "url"];
|
|
@@ -221,6 +222,9 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
|
221
222
|
observer.observe(parent);
|
|
222
223
|
return function () {
|
|
223
224
|
observer.disconnect();
|
|
225
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
|
|
226
|
+
updateOverlay.cancel();
|
|
227
|
+
}
|
|
224
228
|
};
|
|
225
229
|
}, [isVisible, setVisibility]);
|
|
226
230
|
var destinationUrl = (_useSmartLinkDestinat = (0, _useSmartLinkDestinationUrl.useSmartLinkDestinationUrl)(url)) !== null && _useSmartLinkDestinat !== void 0 ? _useSmartLinkDestinat : url;
|
|
@@ -13,7 +13,9 @@ var _link = require("@atlaskit/editor-common/messages/link");
|
|
|
13
13
|
var _panelRight = _interopRequireDefault(require("@atlaskit/icon/core/panel-right"));
|
|
14
14
|
var _extractSmartLinkEmbed = require("@atlaskit/link-extractors/extract-smart-link-embed");
|
|
15
15
|
var _useSmartLinkContext2 = require("@atlaskit/link-provider/use-smart-link-context");
|
|
16
|
-
var
|
|
16
|
+
var _box = require("@atlaskit/primitives/compiled/box");
|
|
17
|
+
var _flex = require("@atlaskit/primitives/compiled/flex");
|
|
18
|
+
var _inline = require("@atlaskit/primitives/compiled/inline");
|
|
17
19
|
var _smartCard = require("@atlaskit/smart-card");
|
|
18
20
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
19
21
|
var _utils = require("../../pm-plugins/utils");
|
|
@@ -71,24 +73,24 @@ var OpenPreviewPanelToolbarButton = exports.OpenPreviewPanelToolbarButton = func
|
|
|
71
73
|
/*#__PURE__*/
|
|
72
74
|
// This is a hack required for Jira until areToolbarFlagsEnabled are enabled to ensure the icon has padding
|
|
73
75
|
// Padding is removed when areToolbarFlagsEnabled for a button with icon only in platform/packages/editor/editor-common/src/ui/FloatingToolbar/Button.tsx
|
|
74
|
-
_react.default.createElement(
|
|
76
|
+
_react.default.createElement(_inline.Inline, {
|
|
75
77
|
as: "span",
|
|
76
78
|
space: "space.050",
|
|
77
79
|
alignBlock: "center"
|
|
78
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
80
|
+
}, /*#__PURE__*/_react.default.createElement(_box.Box, {
|
|
79
81
|
as: "span",
|
|
80
82
|
"aria-hidden": true,
|
|
81
83
|
role: "presentation"
|
|
82
84
|
}), /*#__PURE__*/_react.default.createElement(_panelRight.default, {
|
|
83
85
|
label: "",
|
|
84
86
|
spacing: "spacious"
|
|
85
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
87
|
+
}), /*#__PURE__*/_react.default.createElement(_box.Box, {
|
|
86
88
|
as: "span",
|
|
87
89
|
"aria-hidden": true,
|
|
88
90
|
role: "presentation"
|
|
89
91
|
}));
|
|
90
92
|
if (openPreviewPanel && isPanelAvailable) {
|
|
91
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
93
|
+
return /*#__PURE__*/_react.default.createElement(_flex.Flex, {
|
|
92
94
|
gap: "space.050"
|
|
93
95
|
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
94
96
|
testId: "open-preview-panel-floating-toolbar-button",
|
|
@@ -30,7 +30,9 @@ var _smartLinkCard = _interopRequireDefault(require("@atlaskit/icon/core/smart-l
|
|
|
30
30
|
var _smartLinkEmbed = _interopRequireDefault(require("@atlaskit/icon/core/smart-link-embed"));
|
|
31
31
|
var _smartLinkInline = _interopRequireDefault(require("@atlaskit/icon/core/smart-link-inline"));
|
|
32
32
|
var _useSmartCardContext = require("@atlaskit/link-provider/use-smart-card-context");
|
|
33
|
-
var
|
|
33
|
+
var _box = require("@atlaskit/primitives/compiled/box");
|
|
34
|
+
var _flex = require("@atlaskit/primitives/compiled/flex");
|
|
35
|
+
var _pressable = require("@atlaskit/primitives/compiled/pressable");
|
|
34
36
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
35
37
|
var _doc = require("../pm-plugins/doc");
|
|
36
38
|
var _currentPastedSmartLink = require("./currentPastedSmartLink");
|
|
@@ -62,12 +64,12 @@ var AppearanceOptionIconButton = function AppearanceOptionIconButton(_ref) {
|
|
|
62
64
|
label = _ref.label,
|
|
63
65
|
Icon = _ref.Icon,
|
|
64
66
|
onClick = _ref.onClick;
|
|
65
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(_box.Box, {
|
|
66
68
|
xcss: styles.iconWrapper
|
|
67
69
|
}, /*#__PURE__*/_react.default.createElement(_toolbarTooltip.ToolbarTooltip, {
|
|
68
70
|
content: label,
|
|
69
71
|
position: "bottom"
|
|
70
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
72
|
+
}, /*#__PURE__*/_react.default.createElement(_pressable.Pressable, {
|
|
71
73
|
xcss: (0, _css.cx)(styles.iconButton, isDisabled && styles.iconButtonDisabled, !isDisabled && currentAppearance === appearance && styles.iconButtonSelected),
|
|
72
74
|
"aria-label": label,
|
|
73
75
|
"aria-pressed": currentAppearance === appearance,
|
|
@@ -344,7 +346,7 @@ var PasteDisplayAsMenuHorizontalView = function PasteDisplayAsMenuHorizontalView
|
|
|
344
346
|
var isEmbedSupported =
|
|
345
347
|
// Whatever was pasted already displays this way, so the option must stay selectable.
|
|
346
348
|
currentAppearance === 'embed' || Boolean(isEmbedSupportedFromAppearanceContext || isEmbedSupportedFromSelection);
|
|
347
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
349
|
+
return /*#__PURE__*/_react.default.createElement(_flex.Flex, {
|
|
348
350
|
xcss: styles.appearanceBox,
|
|
349
351
|
gap: "space.050"
|
|
350
352
|
}, /*#__PURE__*/_react.default.createElement(AppearanceOptionIconButton, {
|
|
@@ -38,7 +38,7 @@ export class BlockCardComponent extends React.PureComponent {
|
|
|
38
38
|
|
|
39
39
|
// don't dispatch immediately since we might be in the middle of
|
|
40
40
|
// rendering a nodeview
|
|
41
|
-
rafSchedule(() => {
|
|
41
|
+
const scheduleRegisterCard = rafSchedule(() => {
|
|
42
42
|
const pos = getPos();
|
|
43
43
|
if (typeof pos !== 'number') {
|
|
44
44
|
return;
|
|
@@ -49,7 +49,11 @@ export class BlockCardComponent extends React.PureComponent {
|
|
|
49
49
|
pos,
|
|
50
50
|
id: this.props.id
|
|
51
51
|
})(view.state.tr));
|
|
52
|
-
})
|
|
52
|
+
});
|
|
53
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
54
|
+
this.pendingRegisterCard = scheduleRegisterCard;
|
|
55
|
+
}
|
|
56
|
+
scheduleRegisterCard();
|
|
53
57
|
});
|
|
54
58
|
_defineProperty(this, "removeCardDispatched", false);
|
|
55
59
|
_defineProperty(this, "gapCursorSpan", () => {
|
|
@@ -78,6 +82,11 @@ export class BlockCardComponent extends React.PureComponent {
|
|
|
78
82
|
findOverflowScrollParent(props.view.dom) || undefined;
|
|
79
83
|
}
|
|
80
84
|
componentWillUnmount() {
|
|
85
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
86
|
+
var _this$pendingRegister;
|
|
87
|
+
(_this$pendingRegister = this.pendingRegisterCard) === null || _this$pendingRegister === void 0 ? void 0 : _this$pendingRegister.cancel();
|
|
88
|
+
this.pendingRegisterCard = undefined;
|
|
89
|
+
}
|
|
81
90
|
this.removeCard();
|
|
82
91
|
}
|
|
83
92
|
removeCard() {
|
|
@@ -35,6 +35,16 @@ export const InlineCard = /*#__PURE__*/memo(({
|
|
|
35
35
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
36
36
|
const refId = useRef(uuid());
|
|
37
37
|
const removeCardDispatched = useRef(false);
|
|
38
|
+
const pendingRegisterCard = useRef(null);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
return () => {
|
|
41
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
42
|
+
var _pendingRegisterCard$;
|
|
43
|
+
(_pendingRegisterCard$ = pendingRegisterCard.current) === null || _pendingRegisterCard$ === void 0 ? void 0 : _pendingRegisterCard$.cancel();
|
|
44
|
+
pendingRegisterCard.current = null;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}, []);
|
|
38
48
|
const {
|
|
39
49
|
getState: getSmartlinkState
|
|
40
50
|
} = (cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {};
|
|
@@ -69,7 +79,7 @@ export const InlineCard = /*#__PURE__*/memo(({
|
|
|
69
79
|
} = data;
|
|
70
80
|
// don't dispatch immediately since we might be in the middle of
|
|
71
81
|
// rendering a nodeview
|
|
72
|
-
rafSchedule(() => {
|
|
82
|
+
const scheduleRegisterCard = rafSchedule(() => {
|
|
73
83
|
// prosemirror-bump-fix
|
|
74
84
|
const pos = getPos();
|
|
75
85
|
if (typeof pos !== 'number') {
|
|
@@ -84,7 +94,11 @@ export const InlineCard = /*#__PURE__*/memo(({
|
|
|
84
94
|
})(tr);
|
|
85
95
|
onRes === null || onRes === void 0 ? void 0 : onRes(tr, title);
|
|
86
96
|
view.dispatch(tr);
|
|
87
|
-
})
|
|
97
|
+
});
|
|
98
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
99
|
+
pendingRegisterCard.current = scheduleRegisterCard;
|
|
100
|
+
}
|
|
101
|
+
scheduleRegisterCard();
|
|
88
102
|
}, [getPos, view, onRes]);
|
|
89
103
|
const onError = useCallback(data => {
|
|
90
104
|
const {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
1
|
+
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { ACTION_SUBJECT_ID, EVENT_TYPE, ACTION, ACTION_SUBJECT } from '@atlaskit/editor-common/analytics/types/enums';
|
|
3
3
|
import HoverLinkOverlay from '@atlaskit/editor-common/HoverLinkOverlay';
|
|
4
4
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/useSharedPluginStateWithSelector';
|
|
5
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { extractSmartLinkEmbed } from '@atlaskit/link-extractors/extract-smart-link-embed';
|
|
7
7
|
import { isWithinPreviewPanelIFrame } from '@atlaskit/linking-common/utils/is-within-preview-panel-iframe';
|
|
8
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
9
|
import { getObjectAri, getObjectName, getObjectIconUrl } from '@atlaskit/smart-card';
|
|
9
10
|
import { useSmartLinkDestinationUrl } from '@atlaskit/smart-card/hook/use-smart-link-destination-url';
|
|
10
11
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -13,6 +14,12 @@ import { pluginKey } from '../pm-plugins/plugin-key';
|
|
|
13
14
|
import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
14
15
|
import { PreviewInvoker } from '../ui/preview/PreviewInvoker';
|
|
15
16
|
import { InlineCard } from './inlineCardBase';
|
|
17
|
+
// Module scope so the stored callback's closure chain cannot reach the
|
|
18
|
+
// component scope (getPos, node, view) via V8 context sharing.
|
|
19
|
+
const createRemoveOverlay = setIsInsertedRef => () => {
|
|
20
|
+
var _setIsInsertedRef$cur;
|
|
21
|
+
return (_setIsInsertedRef$cur = setIsInsertedRef.current) === null || _setIsInsertedRef$cur === void 0 ? void 0 : _setIsInsertedRef$cur.call(setIsInsertedRef, false);
|
|
22
|
+
};
|
|
16
23
|
const selector = states => {
|
|
17
24
|
var _states$editorViewMod, _states$selectionStat;
|
|
18
25
|
return {
|
|
@@ -39,15 +46,24 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
|
39
46
|
var _pluginInjectionApi$c;
|
|
40
47
|
const [isHovered, setIsHovered] = useState(false);
|
|
41
48
|
const [isInserted, setIsInserted] = useState(false);
|
|
49
|
+
const setIsInsertedRef = useRef(setIsInserted);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
return () => {
|
|
52
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
53
|
+
setIsInsertedRef.current = undefined;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
42
57
|
const [isResolvedViewRendered, setIsResolvedViewRendered] = useState(false);
|
|
43
58
|
const editorAppearance = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.card.sharedState.currentState()) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.editorAppearance;
|
|
44
59
|
const destinationUrl = useSmartLinkDestinationUrl(node.attrs.url);
|
|
45
60
|
const onResolve = useCallback((tr, title) => {
|
|
46
61
|
const metadata = tr.getMeta(pluginKey);
|
|
62
|
+
const removeOverlay = isExperimentEnabled('platform_editor_reduce_memory_leaks') ? createRemoveOverlay(setIsInsertedRef) : () => setIsInserted(false);
|
|
47
63
|
if (metadata && metadata.type === 'REGISTER') {
|
|
48
|
-
registerRemoveOverlay(
|
|
64
|
+
registerRemoveOverlay(removeOverlay, metadata.info)(tr);
|
|
49
65
|
} else {
|
|
50
|
-
registerRemoveOverlay(
|
|
66
|
+
registerRemoveOverlay(removeOverlay)(tr);
|
|
51
67
|
}
|
|
52
68
|
if (title) {
|
|
53
69
|
setIsResolvedViewRendered(true);
|
|
@@ -6,6 +6,7 @@ import { DATASOURCE_INNER_CONTAINER_CLASSNAME } from '@atlaskit/editor-common/st
|
|
|
6
6
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
8
8
|
import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common/constants';
|
|
9
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
9
10
|
import { blockCardNodeView } from '../nodeviews/blockCard';
|
|
10
11
|
import { embedCardNodeView } from '../nodeviews/embedCard';
|
|
11
12
|
import { InlineCardNodeView } from '../nodeviews/inlineCard';
|
|
@@ -236,7 +237,13 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
236
237
|
*/
|
|
237
238
|
const invoke = rafSchedule(() => {
|
|
238
239
|
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$a3, _pluginInjectionApi$a4, _currentState$embedCa;
|
|
239
|
-
|
|
240
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
241
|
+
const index = rafCancellationCallbacks.indexOf(invoke.cancel);
|
|
242
|
+
if (index !== -1) {
|
|
243
|
+
rafCancellationCallbacks.splice(index, 1);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
resolveWithProvider(view, provider, request, options, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, (_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : (_pluginInjectionApi$a4 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined, currentState === null || currentState === void 0 ? void 0 : (_currentState$embedCa = currentState.embedCardTransformers) === null || _currentState$embedCa === void 0 ? void 0 : _currentState$embedCa.embedCardNodeTransformer);
|
|
240
247
|
});
|
|
241
248
|
rafCancellationCallbacks.push(invoke.cancel);
|
|
242
249
|
invoke();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
1
2
|
const queue = (state, action) => {
|
|
2
3
|
return {
|
|
3
4
|
...state,
|
|
@@ -23,9 +24,18 @@ const register = (state, action) => {
|
|
|
23
24
|
};
|
|
24
25
|
};
|
|
25
26
|
const removeCard = (state, action) => {
|
|
27
|
+
const cards = state.cards.filter(card => card.id !== action.info.id);
|
|
28
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks') && state.removeOverlayCardId !== undefined && state.removeOverlayCardId === action.info.id) {
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
31
|
+
cards,
|
|
32
|
+
removeOverlay: undefined,
|
|
33
|
+
removeOverlayCardId: undefined
|
|
34
|
+
};
|
|
35
|
+
}
|
|
26
36
|
return {
|
|
27
37
|
...state,
|
|
28
|
-
cards
|
|
38
|
+
cards
|
|
29
39
|
};
|
|
30
40
|
};
|
|
31
41
|
const setProvider = (state, action) => {
|
|
@@ -89,19 +99,31 @@ const hideDatasourceModal = state => {
|
|
|
89
99
|
};
|
|
90
100
|
};
|
|
91
101
|
const clearOverlayCandidate = state => {
|
|
102
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
103
|
+
return {
|
|
104
|
+
...state,
|
|
105
|
+
overlayCandidatePosition: undefined,
|
|
106
|
+
removeOverlay: undefined,
|
|
107
|
+
removeOverlayCardId: undefined
|
|
108
|
+
};
|
|
109
|
+
}
|
|
92
110
|
return {
|
|
93
111
|
...state,
|
|
94
112
|
overlayCandidatePosition: undefined
|
|
95
113
|
};
|
|
96
114
|
};
|
|
97
115
|
const registerRemoveOverlayOnInsertedLink = (state, action) => {
|
|
116
|
+
var _action$info2;
|
|
98
117
|
return {
|
|
99
118
|
...state,
|
|
100
119
|
cards: action.info ? state.cards.filter(card => {
|
|
101
120
|
var _action$info;
|
|
102
121
|
return card.pos !== ((_action$info = action.info) === null || _action$info === void 0 ? void 0 : _action$info.pos);
|
|
103
122
|
}).concat(action.info) : state.cards,
|
|
104
|
-
removeOverlay: action.callback
|
|
123
|
+
removeOverlay: action.callback,
|
|
124
|
+
...(isExperimentEnabled('platform_editor_reduce_memory_leaks') ? {
|
|
125
|
+
removeOverlayCardId: (_action$info2 = action.info) === null || _action$info2 === void 0 ? void 0 : _action$info2.id
|
|
126
|
+
} : {})
|
|
105
127
|
};
|
|
106
128
|
};
|
|
107
129
|
const setDatasourceStash = (state, action) => {
|
|
@@ -12,7 +12,7 @@ import { canRenderDatasource } from '@atlaskit/editor-common/utils/datasource';
|
|
|
12
12
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
13
|
import { buildDatasourceAdf } from '@atlaskit/link-datasource/utils/schema';
|
|
14
14
|
import { useSmartLinkContext } from '@atlaskit/link-provider/use-smart-link-context';
|
|
15
|
-
import { Flex } from '@atlaskit/primitives/compiled';
|
|
15
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
16
16
|
import { updateCardViaDatasource } from '../pm-plugins/doc';
|
|
17
17
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
18
18
|
import { DatasourceIcon } from './DatasourceIcon';
|
|
@@ -16,7 +16,7 @@ import { DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu
|
|
|
16
16
|
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
17
17
|
import EditIcon from '@atlaskit/icon/core/edit';
|
|
18
18
|
import ButtonItem from '@atlaskit/menu/button-item';
|
|
19
|
-
import { Flex } from '@atlaskit/primitives/compiled';
|
|
19
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
20
20
|
import { focusEditorView } from '../../pm-plugins/utils';
|
|
21
21
|
import { editDatasource } from '../editDatasourceAction';
|
|
22
22
|
const dropdownExpandContainer = css({
|
|
@@ -16,7 +16,7 @@ import { DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu
|
|
|
16
16
|
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
17
17
|
import { useSmartLinkContext } from '@atlaskit/link-provider/use-smart-link-context';
|
|
18
18
|
import ButtonItem from '@atlaskit/menu/button-item';
|
|
19
|
-
import { Flex } from '@atlaskit/primitives/compiled';
|
|
19
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
20
20
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
21
21
|
import { focusEditorView, isDatasourceConfigEditable } from '../../pm-plugins/utils';
|
|
22
22
|
import { editDatasource } from '../editDatasourceAction';
|
|
@@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics/types/enums';
|
|
3
3
|
import Separator from '@atlaskit/editor-common/FloatingToolbar/Separator';
|
|
4
4
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
5
|
-
import { Flex } from '@atlaskit/primitives/compiled';
|
|
5
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
6
6
|
import { DatasourceAppearanceButton } from './DatasourceAppearanceButton';
|
|
7
7
|
import { LinkToolbarAppearance } from './LinkToolbarAppearance';
|
|
8
8
|
export function HyperlinkToolbarAppearance(props) {
|
|
@@ -6,7 +6,7 @@ import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-che
|
|
|
6
6
|
import { ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu/ArrowKeyNavigationProvider/types';
|
|
7
7
|
import { DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu/DropdownContainer';
|
|
8
8
|
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
9
|
-
import { Flex } from '@atlaskit/primitives/compiled';
|
|
9
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
10
10
|
import { LinkAppearanceMenu } from './LinkToolbarAppearanceDropdown';
|
|
11
11
|
const CustomHyperlinkDropdown = props => {
|
|
12
12
|
var _props$editorPluginAp, _props$cardOptions3, _props$editorPluginAp6, _props$editorPluginAp7;
|
|
@@ -15,6 +15,7 @@ import { useIntl } from 'react-intl';
|
|
|
15
15
|
import { messages } from '@atlaskit/editor-common/messages/card';
|
|
16
16
|
import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace/whitespace';
|
|
17
17
|
import CustomizeIcon from '@atlaskit/icon/core/customize';
|
|
18
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
18
19
|
import { useSmartLinkDestinationUrl } from '@atlaskit/smart-card/hook/use-smart-link-destination-url';
|
|
19
20
|
import { getChildElement, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
|
|
20
21
|
const DEBOUNCE_IN_MS = 5;
|
|
@@ -205,6 +206,9 @@ const InlineCardOverlay = ({
|
|
|
205
206
|
observer.observe(parent);
|
|
206
207
|
return () => {
|
|
207
208
|
observer.disconnect();
|
|
209
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
210
|
+
updateOverlay.cancel();
|
|
211
|
+
}
|
|
208
212
|
};
|
|
209
213
|
}, [isVisible, setVisibility]);
|
|
210
214
|
const destinationUrl = (_useSmartLinkDestinat = useSmartLinkDestinationUrl(url)) !== null && _useSmartLinkDestinat !== void 0 ? _useSmartLinkDestinat : url;
|
|
@@ -5,7 +5,9 @@ import { linkMessages } from '@atlaskit/editor-common/messages/link';
|
|
|
5
5
|
import PanelRightIcon from '@atlaskit/icon/core/panel-right';
|
|
6
6
|
import { extractSmartLinkEmbed } from '@atlaskit/link-extractors/extract-smart-link-embed';
|
|
7
7
|
import { useSmartLinkContext } from '@atlaskit/link-provider/use-smart-link-context';
|
|
8
|
-
import {
|
|
8
|
+
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
9
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
10
|
+
import { Inline } from '@atlaskit/primitives/compiled/inline';
|
|
9
11
|
import { getObjectAri, getObjectIconUrl, getObjectName } from '@atlaskit/smart-card';
|
|
10
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
13
|
import { getResolvedAttributesFromStore } from '../../pm-plugins/utils';
|
|
@@ -20,7 +20,9 @@ import SmartLinkCardIcon from '@atlaskit/icon/core/smart-link-card';
|
|
|
20
20
|
import SmartLinkEmbedIcon from '@atlaskit/icon/core/smart-link-embed';
|
|
21
21
|
import SmartLinkInlineIcon from '@atlaskit/icon/core/smart-link-inline';
|
|
22
22
|
import { useSmartCardContext } from '@atlaskit/link-provider/use-smart-card-context';
|
|
23
|
-
import { Box
|
|
23
|
+
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
24
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
25
|
+
import { Pressable } from '@atlaskit/primitives/compiled/pressable';
|
|
24
26
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
25
27
|
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
26
28
|
import { getSingleSmartLinkUrlFromSlice } from './currentPastedSmartLink';
|
|
@@ -46,7 +46,7 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
46
46
|
|
|
47
47
|
// don't dispatch immediately since we might be in the middle of
|
|
48
48
|
// rendering a nodeview
|
|
49
|
-
rafSchedule(function () {
|
|
49
|
+
var scheduleRegisterCard = rafSchedule(function () {
|
|
50
50
|
var pos = getPos();
|
|
51
51
|
if (typeof pos !== 'number') {
|
|
52
52
|
return;
|
|
@@ -57,7 +57,11 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
57
57
|
pos: pos,
|
|
58
58
|
id: _this.props.id
|
|
59
59
|
})(view.state.tr));
|
|
60
|
-
})
|
|
60
|
+
});
|
|
61
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
62
|
+
_this.pendingRegisterCard = scheduleRegisterCard;
|
|
63
|
+
}
|
|
64
|
+
scheduleRegisterCard();
|
|
61
65
|
});
|
|
62
66
|
_defineProperty(_this, "removeCardDispatched", false);
|
|
63
67
|
_defineProperty(_this, "gapCursorSpan", function () {
|
|
@@ -89,6 +93,11 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
89
93
|
return _createClass(BlockCardComponent, [{
|
|
90
94
|
key: "componentWillUnmount",
|
|
91
95
|
value: function componentWillUnmount() {
|
|
96
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
97
|
+
var _this$pendingRegister;
|
|
98
|
+
(_this$pendingRegister = this.pendingRegisterCard) === null || _this$pendingRegister === void 0 || _this$pendingRegister.cancel();
|
|
99
|
+
this.pendingRegisterCard = undefined;
|
|
100
|
+
}
|
|
92
101
|
this.removeCard();
|
|
93
102
|
}
|
|
94
103
|
}, {
|
|
@@ -33,6 +33,16 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
|
|
|
33
33
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
34
34
|
var refId = useRef(uuid());
|
|
35
35
|
var removeCardDispatched = useRef(false);
|
|
36
|
+
var pendingRegisterCard = useRef(null);
|
|
37
|
+
useEffect(function () {
|
|
38
|
+
return function () {
|
|
39
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
40
|
+
var _pendingRegisterCard$;
|
|
41
|
+
(_pendingRegisterCard$ = pendingRegisterCard.current) === null || _pendingRegisterCard$ === void 0 || _pendingRegisterCard$.cancel();
|
|
42
|
+
pendingRegisterCard.current = null;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
36
46
|
var _ref2 = (cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {},
|
|
37
47
|
getSmartlinkState = _ref2.getState;
|
|
38
48
|
var cardState = getSmartlinkState === null || getSmartlinkState === void 0 ? void 0 : getSmartlinkState()[url || ''];
|
|
@@ -64,7 +74,7 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
|
|
|
64
74
|
url = data.url;
|
|
65
75
|
// don't dispatch immediately since we might be in the middle of
|
|
66
76
|
// rendering a nodeview
|
|
67
|
-
rafSchedule(function () {
|
|
77
|
+
var scheduleRegisterCard = rafSchedule(function () {
|
|
68
78
|
// prosemirror-bump-fix
|
|
69
79
|
var pos = getPos();
|
|
70
80
|
if (typeof pos !== 'number') {
|
|
@@ -79,7 +89,11 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
|
|
|
79
89
|
})(tr);
|
|
80
90
|
onRes === null || onRes === void 0 || onRes(tr, title);
|
|
81
91
|
view.dispatch(tr);
|
|
82
|
-
})
|
|
92
|
+
});
|
|
93
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
94
|
+
pendingRegisterCard.current = scheduleRegisterCard;
|
|
95
|
+
}
|
|
96
|
+
scheduleRegisterCard();
|
|
83
97
|
}, [getPos, view, onRes]);
|
|
84
98
|
var onError = useCallback(function (data) {
|
|
85
99
|
var url = data.url,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { ACTION_SUBJECT_ID, EVENT_TYPE, ACTION, ACTION_SUBJECT } from '@atlaskit/editor-common/analytics/types/enums';
|
|
4
4
|
import HoverLinkOverlay from '@atlaskit/editor-common/HoverLinkOverlay';
|
|
5
5
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/useSharedPluginStateWithSelector';
|
|
6
6
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { extractSmartLinkEmbed } from '@atlaskit/link-extractors/extract-smart-link-embed';
|
|
8
8
|
import { isWithinPreviewPanelIFrame } from '@atlaskit/linking-common/utils/is-within-preview-panel-iframe';
|
|
9
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
9
10
|
import { getObjectAri, getObjectName, getObjectIconUrl } from '@atlaskit/smart-card';
|
|
10
11
|
import { useSmartLinkDestinationUrl } from '@atlaskit/smart-card/hook/use-smart-link-destination-url';
|
|
11
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -14,6 +15,14 @@ import { pluginKey } from '../pm-plugins/plugin-key';
|
|
|
14
15
|
import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
15
16
|
import { PreviewInvoker } from '../ui/preview/PreviewInvoker';
|
|
16
17
|
import { InlineCard } from './inlineCardBase';
|
|
18
|
+
// Module scope so the stored callback's closure chain cannot reach the
|
|
19
|
+
// component scope (getPos, node, view) via V8 context sharing.
|
|
20
|
+
var createRemoveOverlay = function createRemoveOverlay(setIsInsertedRef) {
|
|
21
|
+
return function () {
|
|
22
|
+
var _setIsInsertedRef$cur;
|
|
23
|
+
return (_setIsInsertedRef$cur = setIsInsertedRef.current) === null || _setIsInsertedRef$cur === void 0 ? void 0 : _setIsInsertedRef$cur.call(setIsInsertedRef, false);
|
|
24
|
+
};
|
|
25
|
+
};
|
|
17
26
|
var selector = function selector(states) {
|
|
18
27
|
var _states$editorViewMod, _states$selectionStat;
|
|
19
28
|
return {
|
|
@@ -45,6 +54,14 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
45
54
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
46
55
|
isInserted = _useState4[0],
|
|
47
56
|
setIsInserted = _useState4[1];
|
|
57
|
+
var setIsInsertedRef = useRef(setIsInserted);
|
|
58
|
+
useEffect(function () {
|
|
59
|
+
return function () {
|
|
60
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
61
|
+
setIsInsertedRef.current = undefined;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}, []);
|
|
48
65
|
var _useState5 = useState(false),
|
|
49
66
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
50
67
|
isResolvedViewRendered = _useState6[0],
|
|
@@ -53,14 +70,13 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
53
70
|
var destinationUrl = useSmartLinkDestinationUrl(node.attrs.url);
|
|
54
71
|
var onResolve = useCallback(function (tr, title) {
|
|
55
72
|
var metadata = tr.getMeta(pluginKey);
|
|
73
|
+
var removeOverlay = isExperimentEnabled('platform_editor_reduce_memory_leaks') ? createRemoveOverlay(setIsInsertedRef) : function () {
|
|
74
|
+
return setIsInserted(false);
|
|
75
|
+
};
|
|
56
76
|
if (metadata && metadata.type === 'REGISTER') {
|
|
57
|
-
registerRemoveOverlay(
|
|
58
|
-
return setIsInserted(false);
|
|
59
|
-
}, metadata.info)(tr);
|
|
77
|
+
registerRemoveOverlay(removeOverlay, metadata.info)(tr);
|
|
60
78
|
} else {
|
|
61
|
-
registerRemoveOverlay(
|
|
62
|
-
return setIsInserted(false);
|
|
63
|
-
})(tr);
|
|
79
|
+
registerRemoveOverlay(removeOverlay)(tr);
|
|
64
80
|
}
|
|
65
81
|
if (title) {
|
|
66
82
|
setIsResolvedViewRendered(true);
|
|
@@ -10,6 +10,7 @@ import { DATASOURCE_INNER_CONTAINER_CLASSNAME } from '@atlaskit/editor-common/st
|
|
|
10
10
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
11
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
12
12
|
import { DATASOURCE_DEFAULT_LAYOUT } from '@atlaskit/linking-common/constants';
|
|
13
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
13
14
|
import { blockCardNodeView } from '../nodeviews/blockCard';
|
|
14
15
|
import { embedCardNodeView } from '../nodeviews/embedCard';
|
|
15
16
|
import { InlineCardNodeView } from '../nodeviews/inlineCard';
|
|
@@ -232,7 +233,13 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
|
|
|
232
233
|
*/
|
|
233
234
|
var invoke = rafSchedule(function () {
|
|
234
235
|
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$a3, _currentState$embedCa;
|
|
235
|
-
|
|
236
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
237
|
+
var index = rafCancellationCallbacks.indexOf(invoke.cancel);
|
|
238
|
+
if (index !== -1) {
|
|
239
|
+
rafCancellationCallbacks.splice(index, 1);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
resolveWithProvider(view, _provider, request, options, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, (_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 || (_pluginInjectionApi$a3 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined, currentState === null || currentState === void 0 || (_currentState$embedCa = currentState.embedCardTransformers) === null || _currentState$embedCa === void 0 ? void 0 : _currentState$embedCa.embedCardNodeTransformer);
|
|
236
243
|
});
|
|
237
244
|
rafCancellationCallbacks.push(invoke.cancel);
|
|
238
245
|
invoke();
|
|
@@ -5,6 +5,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
5
5
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
9
|
var queue = function queue(state, action) {
|
|
9
10
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
10
11
|
requests: state.requests.concat(action.requests)
|
|
@@ -29,10 +30,18 @@ var register = function register(state, action) {
|
|
|
29
30
|
});
|
|
30
31
|
};
|
|
31
32
|
var removeCard = function removeCard(state, action) {
|
|
33
|
+
var cards = state.cards.filter(function (card) {
|
|
34
|
+
return card.id !== action.info.id;
|
|
35
|
+
});
|
|
36
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks') && state.removeOverlayCardId !== undefined && state.removeOverlayCardId === action.info.id) {
|
|
37
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
38
|
+
cards: cards,
|
|
39
|
+
removeOverlay: undefined,
|
|
40
|
+
removeOverlayCardId: undefined
|
|
41
|
+
});
|
|
42
|
+
}
|
|
32
43
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
33
|
-
cards:
|
|
34
|
-
return card.id !== action.info.id;
|
|
35
|
-
})
|
|
44
|
+
cards: cards
|
|
36
45
|
});
|
|
37
46
|
};
|
|
38
47
|
var setProvider = function setProvider(state, action) {
|
|
@@ -84,18 +93,28 @@ var hideDatasourceModal = function hideDatasourceModal(state) {
|
|
|
84
93
|
});
|
|
85
94
|
};
|
|
86
95
|
var clearOverlayCandidate = function clearOverlayCandidate(state) {
|
|
96
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
97
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
98
|
+
overlayCandidatePosition: undefined,
|
|
99
|
+
removeOverlay: undefined,
|
|
100
|
+
removeOverlayCardId: undefined
|
|
101
|
+
});
|
|
102
|
+
}
|
|
87
103
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
88
104
|
overlayCandidatePosition: undefined
|
|
89
105
|
});
|
|
90
106
|
};
|
|
91
107
|
var registerRemoveOverlayOnInsertedLink = function registerRemoveOverlayOnInsertedLink(state, action) {
|
|
108
|
+
var _action$info2;
|
|
92
109
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
93
110
|
cards: action.info ? state.cards.filter(function (card) {
|
|
94
111
|
var _action$info;
|
|
95
112
|
return card.pos !== ((_action$info = action.info) === null || _action$info === void 0 ? void 0 : _action$info.pos);
|
|
96
113
|
}).concat(action.info) : state.cards,
|
|
97
114
|
removeOverlay: action.callback
|
|
98
|
-
})
|
|
115
|
+
}, isExperimentEnabled('platform_editor_reduce_memory_leaks') ? {
|
|
116
|
+
removeOverlayCardId: (_action$info2 = action.info) === null || _action$info2 === void 0 ? void 0 : _action$info2.id
|
|
117
|
+
} : {});
|
|
99
118
|
};
|
|
100
119
|
var setDatasourceStash = function setDatasourceStash(state, action) {
|
|
101
120
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -12,7 +12,7 @@ import { canRenderDatasource } from '@atlaskit/editor-common/utils/datasource';
|
|
|
12
12
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
13
|
import { buildDatasourceAdf } from '@atlaskit/link-datasource/utils/schema';
|
|
14
14
|
import { useSmartLinkContext } from '@atlaskit/link-provider/use-smart-link-context';
|
|
15
|
-
import { Flex } from '@atlaskit/primitives/compiled';
|
|
15
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
16
16
|
import { updateCardViaDatasource } from '../pm-plugins/doc';
|
|
17
17
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
18
18
|
import { DatasourceIcon } from './DatasourceIcon';
|
|
@@ -17,7 +17,7 @@ import { DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu
|
|
|
17
17
|
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
18
18
|
import EditIcon from '@atlaskit/icon/core/edit';
|
|
19
19
|
import ButtonItem from '@atlaskit/menu/button-item';
|
|
20
|
-
import { Flex } from '@atlaskit/primitives/compiled';
|
|
20
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
21
21
|
import { focusEditorView } from '../../pm-plugins/utils';
|
|
22
22
|
import { editDatasource } from '../editDatasourceAction';
|
|
23
23
|
var dropdownExpandContainer = css({
|
|
@@ -19,7 +19,7 @@ import { DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu
|
|
|
19
19
|
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
20
20
|
import { useSmartLinkContext } from '@atlaskit/link-provider/use-smart-link-context';
|
|
21
21
|
import ButtonItem from '@atlaskit/menu/button-item';
|
|
22
|
-
import { Flex } from '@atlaskit/primitives/compiled';
|
|
22
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
23
23
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
24
24
|
import { focusEditorView, isDatasourceConfigEditable } from '../../pm-plugins/utils';
|
|
25
25
|
import { editDatasource } from '../editDatasourceAction';
|
|
@@ -5,7 +5,7 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
5
5
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics/types/enums';
|
|
6
6
|
import Separator from '@atlaskit/editor-common/FloatingToolbar/Separator';
|
|
7
7
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
8
|
-
import { Flex } from '@atlaskit/primitives/compiled';
|
|
8
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
9
9
|
import { DatasourceAppearanceButton } from './DatasourceAppearanceButton';
|
|
10
10
|
import { LinkToolbarAppearance } from './LinkToolbarAppearance';
|
|
11
11
|
export function HyperlinkToolbarAppearance(props) {
|
|
@@ -9,7 +9,7 @@ import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-che
|
|
|
9
9
|
import { ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu/ArrowKeyNavigationProvider/types';
|
|
10
10
|
import { DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu/DropdownContainer';
|
|
11
11
|
import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
|
|
12
|
-
import { Flex } from '@atlaskit/primitives/compiled';
|
|
12
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
13
13
|
import { LinkAppearanceMenu } from './LinkToolbarAppearanceDropdown';
|
|
14
14
|
var CustomHyperlinkDropdown = function CustomHyperlinkDropdown(props) {
|
|
15
15
|
var _props$editorPluginAp, _props$cardOptions3, _props$editorPluginAp3, _props$editorPluginAp4;
|
|
@@ -19,6 +19,7 @@ import { useIntl } from 'react-intl';
|
|
|
19
19
|
import { messages } from '@atlaskit/editor-common/messages/card';
|
|
20
20
|
import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace/whitespace';
|
|
21
21
|
import CustomizeIcon from '@atlaskit/icon/core/customize';
|
|
22
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
22
23
|
import { useSmartLinkDestinationUrl } from '@atlaskit/smart-card/hook/use-smart-link-destination-url';
|
|
23
24
|
import { getChildElement, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
|
|
24
25
|
var DEBOUNCE_IN_MS = 5;
|
|
@@ -214,6 +215,9 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
|
214
215
|
observer.observe(parent);
|
|
215
216
|
return function () {
|
|
216
217
|
observer.disconnect();
|
|
218
|
+
if (isExperimentEnabled('platform_editor_reduce_memory_leaks')) {
|
|
219
|
+
updateOverlay.cancel();
|
|
220
|
+
}
|
|
217
221
|
};
|
|
218
222
|
}, [isVisible, setVisibility]);
|
|
219
223
|
var destinationUrl = (_useSmartLinkDestinat = useSmartLinkDestinationUrl(url)) !== null && _useSmartLinkDestinat !== void 0 ? _useSmartLinkDestinat : url;
|
|
@@ -8,7 +8,9 @@ import { linkMessages } from '@atlaskit/editor-common/messages/link';
|
|
|
8
8
|
import PanelRightIcon from '@atlaskit/icon/core/panel-right';
|
|
9
9
|
import { extractSmartLinkEmbed } from '@atlaskit/link-extractors/extract-smart-link-embed';
|
|
10
10
|
import { useSmartLinkContext } from '@atlaskit/link-provider/use-smart-link-context';
|
|
11
|
-
import {
|
|
11
|
+
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
12
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
13
|
+
import { Inline } from '@atlaskit/primitives/compiled/inline';
|
|
12
14
|
import { getObjectAri, getObjectIconUrl, getObjectName } from '@atlaskit/smart-card';
|
|
13
15
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
16
|
import { getResolvedAttributesFromStore } from '../../pm-plugins/utils';
|
|
@@ -22,7 +22,9 @@ import SmartLinkCardIcon from '@atlaskit/icon/core/smart-link-card';
|
|
|
22
22
|
import SmartLinkEmbedIcon from '@atlaskit/icon/core/smart-link-embed';
|
|
23
23
|
import SmartLinkInlineIcon from '@atlaskit/icon/core/smart-link-inline';
|
|
24
24
|
import { useSmartCardContext } from '@atlaskit/link-provider/use-smart-card-context';
|
|
25
|
-
import { Box
|
|
25
|
+
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
26
|
+
import { Flex } from '@atlaskit/primitives/compiled/flex';
|
|
27
|
+
import { Pressable } from '@atlaskit/primitives/compiled/pressable';
|
|
26
28
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
27
29
|
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
28
30
|
import { getSingleSmartLinkUrlFromSlice } from './currentPastedSmartLink';
|
|
@@ -32,6 +32,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
|
|
|
32
32
|
overlayCandidatePosition?: number;
|
|
33
33
|
provider: CardProvider | null;
|
|
34
34
|
removeOverlay?: () => void;
|
|
35
|
+
removeOverlayCardId?: string;
|
|
35
36
|
requests: {
|
|
36
37
|
analyticsAction?: ACTION;
|
|
37
38
|
appearance: CardAppearance;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin';
|
|
3
3
|
import type { CardPlugin } from '../cardPluginType';
|
|
4
4
|
import type { EditorCardPluginEvents } from './analytics/create-events-queue';
|
|
5
5
|
import type { CardPluginEvent } from './analytics/types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "34.0.
|
|
3
|
+
"version": "34.0.1",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@atlaskit/custom-steps": "^1.1.0",
|
|
29
29
|
"@atlaskit/editor-card-provider": "^8.1.0",
|
|
30
30
|
"@atlaskit/editor-plugin-analytics": "^28.0.0",
|
|
31
|
-
"@atlaskit/editor-plugin-annotation": "^28.
|
|
31
|
+
"@atlaskit/editor-plugin-annotation": "^28.1.0",
|
|
32
32
|
"@atlaskit/editor-plugin-base": "^29.0.0",
|
|
33
33
|
"@atlaskit/editor-plugin-connectivity": "^28.0.0",
|
|
34
34
|
"@atlaskit/editor-plugin-decorations": "^28.0.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@atlaskit/primitives": "^22.6.0",
|
|
65
65
|
"@atlaskit/prosemirror-history": "^1.3.0",
|
|
66
66
|
"@atlaskit/smart-card": "^46.7.0",
|
|
67
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
67
|
+
"@atlaskit/tmp-editor-statsig": "^241.0.0",
|
|
68
68
|
"@atlaskit/tokens": "^20.6.0",
|
|
69
69
|
"@babel/runtime": "^7.0.0",
|
|
70
70
|
"@emotion/react": "^11.7.1",
|