@atlaskit/editor-plugin-card 35.0.1 → 35.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cjs/actions/cardRegistry.js +65 -0
  3. package/dist/cjs/actions/useCardRegistry.js +19 -0
  4. package/dist/cjs/cardPlugin.js +6 -0
  5. package/dist/cjs/nodeviews/blockCard.js +45 -21
  6. package/dist/cjs/nodeviews/embedCard.js +50 -26
  7. package/dist/cjs/nodeviews/inlineCardBase.js +41 -20
  8. package/dist/cjs/nodeviews/inlineCardWithAwareness.js +14 -10
  9. package/dist/cjs/pm-plugins/doc.js +1 -1
  10. package/dist/cjs/pm-plugins/main.js +11 -9
  11. package/dist/cjs/pm-plugins/utils.js +19 -7
  12. package/dist/cjs/ui/EditLinkToolbar.js +5 -3
  13. package/dist/cjs/ui/PasteDisplayAsMenu.js +15 -4
  14. package/dist/cjs/ui/toolbar.js +37 -21
  15. package/dist/es2019/actions/cardRegistry.js +58 -0
  16. package/dist/es2019/actions/useCardRegistry.js +9 -0
  17. package/dist/es2019/cardPlugin.js +6 -0
  18. package/dist/es2019/nodeviews/blockCard.js +42 -16
  19. package/dist/es2019/nodeviews/embedCard.js +42 -16
  20. package/dist/es2019/nodeviews/inlineCardBase.js +43 -22
  21. package/dist/es2019/nodeviews/inlineCardWithAwareness.js +12 -8
  22. package/dist/es2019/pm-plugins/doc.js +1 -1
  23. package/dist/es2019/pm-plugins/main.js +11 -9
  24. package/dist/es2019/pm-plugins/utils.js +15 -5
  25. package/dist/es2019/ui/EditLinkToolbar.js +5 -3
  26. package/dist/es2019/ui/PasteDisplayAsMenu.js +11 -4
  27. package/dist/es2019/ui/toolbar.js +35 -19
  28. package/dist/esm/actions/cardRegistry.js +58 -0
  29. package/dist/esm/actions/useCardRegistry.js +13 -0
  30. package/dist/esm/cardPlugin.js +6 -0
  31. package/dist/esm/nodeviews/blockCard.js +45 -21
  32. package/dist/esm/nodeviews/embedCard.js +50 -26
  33. package/dist/esm/nodeviews/inlineCardBase.js +41 -20
  34. package/dist/esm/nodeviews/inlineCardWithAwareness.js +14 -10
  35. package/dist/esm/pm-plugins/doc.js +1 -1
  36. package/dist/esm/pm-plugins/main.js +11 -9
  37. package/dist/esm/pm-plugins/utils.js +19 -7
  38. package/dist/esm/ui/EditLinkToolbar.js +5 -3
  39. package/dist/esm/ui/PasteDisplayAsMenu.js +15 -4
  40. package/dist/esm/ui/toolbar.js +37 -21
  41. package/dist/types/actions/cardRegistry.d.ts +37 -0
  42. package/dist/types/actions/useCardRegistry.d.ts +3 -0
  43. package/dist/types/nodeviews/blockCard.d.ts +2 -2
  44. package/dist/types/nodeviews/embedCard.d.ts +2 -2
  45. package/dist/types/nodeviews/genericCard.d.ts +2 -4
  46. package/dist/types/pm-plugins/utils.d.ts +2 -1
  47. package/package.json +8 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 35.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`deffb3655ce41`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/deffb3655ce41) -
8
+ Add platform_native_embeds_rollout_all_products alongside the existing non-MAUI rollout gate so
9
+ native embeds can roll out independently across host products.
10
+ - Updated dependencies
11
+
12
+ ## 35.1.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [`f268dee2526f7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f268dee2526f7) -
17
+ Migrate Smart Card registration and removal from transactions to editor actions behind
18
+ `platform_editor_reduce_forced_layout_2`. Remove unused card overlay registration behind
19
+ `platform_editor_reduce_forced_layout_2`.
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+
25
+ ## 35.0.2
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies
30
+
3
31
  ## 35.0.1
4
32
 
5
33
  ### Patch Changes
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createCardRegistry = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
+ /**
12
+ * Creates a registry of resolved cards, for use with editor actions.
13
+ * Registration changes (insertion, deletion, and id/title/url updates) notify subscribers; live position changes do not.
14
+ *
15
+ * @returns A registry object with the following methods:
16
+ * - `getCardRegistrations`: Returns the current registrations, keyed by card ID.
17
+ * - `registerCard`: Adds or updates a card.
18
+ * - `removeCard`: Removes a card by ID.
19
+ * - `subscribe`: Registers a change listener and returns an unsubscribe function.
20
+ */
21
+ var createCardRegistry = exports.createCardRegistry = function createCardRegistry() {
22
+ // Replace registrations on each change to notify subscribers and trigger React updates.
23
+ var registrations = {};
24
+ var listeners = new Set();
25
+ var getCardRegistrations = function getCardRegistrations() {
26
+ return registrations;
27
+ };
28
+ var notify = function notify() {
29
+ Array.from(listeners).forEach(function (listener) {
30
+ return listener();
31
+ });
32
+ };
33
+ var registerCard = function registerCard(info) {
34
+ if (info.getPos() === undefined) {
35
+ return;
36
+ }
37
+ var previous = registrations[info.id];
38
+ if (previous && previous.getPos === info.getPos && previous.title === info.title && previous.url === info.url) {
39
+ return; // Don't mutate registrations if no change
40
+ }
41
+ registrations = _objectSpread(_objectSpread({}, registrations), {}, (0, _defineProperty2.default)({}, info.id, _objectSpread({}, info)));
42
+ notify();
43
+ };
44
+ var removeCard = function removeCard(id) {
45
+ if (!registrations[id]) {
46
+ return;
47
+ }
48
+ var next = _objectSpread({}, registrations);
49
+ delete next[id];
50
+ registrations = next;
51
+ notify();
52
+ };
53
+ var subscribe = function subscribe(listener) {
54
+ listeners.add(listener);
55
+ return function () {
56
+ listeners.delete(listener);
57
+ };
58
+ };
59
+ return {
60
+ registerCard: registerCard,
61
+ removeCard: removeCard,
62
+ subscribe: subscribe,
63
+ getCardRegistrations: getCardRegistrations
64
+ };
65
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useCardRegistry = void 0;
7
+ var _react = require("react");
8
+ var emptySnapshot = function emptySnapshot() {
9
+ return undefined;
10
+ };
11
+ var emptySubscription = function emptySubscription() {
12
+ return function () {};
13
+ };
14
+
15
+ /** Subscribe to resolved card metadata without observing every editor transaction. */
16
+ var useCardRegistry = exports.useCardRegistry = function useCardRegistry(actions) {
17
+ var _actions$subscribeToC, _actions$getCardRegis;
18
+ return (0, _react.useSyncExternalStore)((_actions$subscribeToC = actions === null || actions === void 0 ? void 0 : actions.subscribeToCardRegistry) !== null && _actions$subscribeToC !== void 0 ? _actions$subscribeToC : emptySubscription, (_actions$getCardRegis = actions === null || actions === void 0 ? void 0 : actions.getCardRegistrations) !== null && _actions$getCardRegis !== void 0 ? _actions$getCardRegis : emptySnapshot, emptySnapshot);
19
+ };
@@ -20,6 +20,7 @@ var _context3 = require("@atlaskit/link-provider/context");
20
20
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
21
21
  var _fg = require("@atlaskit/platform-feature-flags/fg");
22
22
  var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
23
+ var _cardRegistry = require("./actions/cardRegistry");
23
24
  var _blockCard = require("./nodeviews/toDOM-fixes/blockCard");
24
25
  var _embedCard = require("./nodeviews/toDOM-fixes/embedCard");
25
26
  var _inlineCard = require("./nodeviews/toDOM-fixes/inlineCard");
@@ -57,6 +58,7 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref2) {
57
58
  var _ref2$config = _ref2.config,
58
59
  options = _ref2$config === void 0 ? {} : _ref2$config,
59
60
  api = _ref2.api;
61
+ var cardRegistry = (0, _cardRegistry.createCardRegistry)();
60
62
  var previousCardProvider;
61
63
  var cardPluginEvents = (0, _createEventsQueue.createEventsQueue)();
62
64
  var isRegisteredSlashCommandEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command');
@@ -215,6 +217,10 @@ var cardPlugin = exports.cardPlugin = function cardPlugin(_ref2) {
215
217
  }
216
218
  },
217
219
  actions: {
220
+ registerCard: cardRegistry.registerCard,
221
+ removeRegisteredCard: cardRegistry.removeCard,
222
+ getCardRegistrations: cardRegistry.getCardRegistrations,
223
+ subscribeToCardRegistry: cardRegistry.subscribe,
218
224
  setProvider: function () {
219
225
  var _setProvider2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(providerPromise) {
220
226
  var _api$core$actions$exe;
@@ -52,16 +52,32 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
52
52
  // don't dispatch immediately since we might be in the middle of
53
53
  // rendering a nodeview
54
54
  var scheduleRegisterCard = (0, _rafSchd.default)(function () {
55
- var pos = getPos();
56
- if (typeof pos !== 'number') {
57
- return;
55
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2')) {
56
+ var _pluginInjectionApi$c;
57
+ if (_this.removeCardDispatched || getPos() === undefined) {
58
+ return;
59
+ }
60
+ var _this$props2 = _this.props,
61
+ pluginInjectionApi = _this$props2.pluginInjectionApi,
62
+ id = _this$props2.id;
63
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card.actions) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.registerCard({
64
+ id: id,
65
+ title: title,
66
+ url: url,
67
+ getPos: getPos
68
+ });
69
+ } else {
70
+ var pos = getPos();
71
+ if (typeof pos !== 'number') {
72
+ return;
73
+ }
74
+ view.dispatch((0, _actions.registerCard)({
75
+ title: title,
76
+ url: url,
77
+ pos: pos,
78
+ id: _this.props.id
79
+ })(view.state.tr));
58
80
  }
59
- view.dispatch((0, _actions.registerCard)({
60
- title: title,
61
- url: url,
62
- pos: pos,
63
- id: _this.props.id
64
- })(view.state.tr));
65
81
  });
66
82
  if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
67
83
  _this.pendingRegisterCard = scheduleRegisterCard;
@@ -112,22 +128,30 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
112
128
  return;
113
129
  }
114
130
  this.removeCardDispatched = true;
115
- var tr = this.props.view.state.tr;
116
- (0, _actions.removeCard)({
117
- id: this.props.id
118
- })(tr);
119
- this.props.view.dispatch(tr);
131
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2')) {
132
+ var _pluginInjectionApi$c2;
133
+ var _this$props3 = this.props,
134
+ pluginInjectionApi = _this$props3.pluginInjectionApi,
135
+ id = _this$props3.id;
136
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card.actions) === null || _pluginInjectionApi$c2 === void 0 || _pluginInjectionApi$c2.removeRegisteredCard(id);
137
+ } else {
138
+ var tr = this.props.view.state.tr;
139
+ (0, _actions.removeCard)({
140
+ id: this.props.id
141
+ })(tr);
142
+ this.props.view.dispatch(tr);
143
+ }
120
144
  }
121
145
  }, {
122
146
  key: "render",
123
147
  value: function render() {
124
- var _this$props2 = this.props,
125
- node = _this$props2.node,
126
- cardContext = _this$props2.cardContext,
127
- actionOptions = _this$props2.actionOptions,
128
- onClick = _this$props2.onClick,
129
- CompetitorPrompt = _this$props2.CompetitorPrompt,
130
- isPageSSRed = _this$props2.isPageSSRed;
148
+ var _this$props4 = this.props,
149
+ node = _this$props4.node,
150
+ cardContext = _this$props4.cardContext,
151
+ actionOptions = _this$props4.actionOptions,
152
+ onClick = _this$props4.onClick,
153
+ CompetitorPrompt = _this$props4.CompetitorPrompt,
154
+ isPageSSRed = _this$props4.isPageSSRed;
131
155
  var _node$attrs = node.attrs,
132
156
  url = _node$attrs.url,
133
157
  data = _node$attrs.data;
@@ -187,16 +187,32 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
187
187
  // don't dispatch immediately since we might be in the middle of
188
188
  // rendering a nodeview
189
189
  (0, _rafSchd.default)(function () {
190
- var pos = _this.getPosSafely();
191
- if (pos === undefined) {
192
- return;
190
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2')) {
191
+ var _pluginInjectionApi$c;
192
+ if (_this.removeCardDispatched || _this.getPosSafely() === undefined) {
193
+ return;
194
+ }
195
+ var _this$props = _this.props,
196
+ pluginInjectionApi = _this$props.pluginInjectionApi,
197
+ id = _this$props.id;
198
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card.actions) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.registerCard({
199
+ id: id,
200
+ title: title,
201
+ url: url,
202
+ getPos: _this.getPosSafely
203
+ });
204
+ } else {
205
+ var pos = _this.getPosSafely();
206
+ if (pos === undefined) {
207
+ return;
208
+ }
209
+ return view.dispatch((0, _actions.registerCard)({
210
+ title: title,
211
+ url: url,
212
+ pos: pos,
213
+ id: _this.props.id
214
+ })(view.state.tr));
193
215
  }
194
- return view.dispatch((0, _actions.registerCard)({
195
- title: title,
196
- url: url,
197
- pos: pos,
198
- id: _this.props.id
199
- })(view.state.tr));
200
216
  })();
201
217
  try {
202
218
  var _this$props$cardConte, _this$props$cardConte2;
@@ -331,27 +347,35 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
331
347
  return;
332
348
  }
333
349
  this.removeCardDispatched = true;
334
- var tr = this.props.view.state.tr;
335
- (0, _actions.removeCard)({
336
- id: this.props.id
337
- })(tr);
338
- this.props.view.dispatch(tr);
350
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2')) {
351
+ var _pluginInjectionApi$c2;
352
+ var _this$props2 = this.props,
353
+ pluginInjectionApi = _this$props2.pluginInjectionApi,
354
+ id = _this$props2.id;
355
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card.actions) === null || _pluginInjectionApi$c2 === void 0 || _pluginInjectionApi$c2.removeRegisteredCard(id);
356
+ } else {
357
+ var tr = this.props.view.state.tr;
358
+ (0, _actions.removeCard)({
359
+ id: this.props.id
360
+ })(tr);
361
+ this.props.view.dispatch(tr);
362
+ }
339
363
  }
340
364
  }, {
341
365
  key: "render",
342
366
  value: function render() {
343
- var _this$props = this.props,
344
- node = _this$props.node,
345
- allowResizing = _this$props.allowResizing,
346
- fullWidthMode = _this$props.fullWidthMode,
347
- view = _this$props.view,
348
- dispatchAnalyticsEvent = _this$props.dispatchAnalyticsEvent,
349
- getPos = _this$props.getPos,
350
- pluginInjectionApi = _this$props.pluginInjectionApi,
351
- actionOptions = _this$props.actionOptions,
352
- onClick = _this$props.onClick,
353
- CompetitorPrompt = _this$props.CompetitorPrompt,
354
- isPageSSRed = _this$props.isPageSSRed;
367
+ var _this$props3 = this.props,
368
+ node = _this$props3.node,
369
+ allowResizing = _this$props3.allowResizing,
370
+ fullWidthMode = _this$props3.fullWidthMode,
371
+ view = _this$props3.view,
372
+ dispatchAnalyticsEvent = _this$props3.dispatchAnalyticsEvent,
373
+ getPos = _this$props3.getPos,
374
+ pluginInjectionApi = _this$props3.pluginInjectionApi,
375
+ actionOptions = _this$props3.actionOptions,
376
+ onClick = _this$props3.onClick,
377
+ CompetitorPrompt = _this$props3.CompetitorPrompt,
378
+ isPageSSRed = _this$props3.isPageSSRed;
355
379
  var _node$attrs = node.attrs,
356
380
  url = _node$attrs.url,
357
381
  pctWidth = _node$attrs.width,
@@ -53,6 +53,9 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
53
53
  }
54
54
  };
55
55
  }, []);
56
+ var cardActions = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.card.actions;
57
+ var registerResolvedCard = cardActions === null || cardActions === void 0 ? void 0 : cardActions.registerCard;
58
+ var removeRegisteredCard = cardActions === null || cardActions === void 0 ? void 0 : cardActions.removeRegisteredCard;
56
59
  var _ref2 = (cardContext === null || cardContext === void 0 || (_cardContext$value = cardContext.value) === null || _cardContext$value === void 0 ? void 0 : _cardContext$value.store) || {},
57
60
  getSmartlinkState = _ref2.getState;
58
61
  var cardState = getSmartlinkState === null || getSmartlinkState === void 0 ? void 0 : getSmartlinkState()[url || ''];
@@ -64,13 +67,17 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
64
67
  return;
65
68
  }
66
69
  removeCardDispatched.current = true;
67
- var tr = view.state.tr;
68
- (0, _actions.removeCard)({
69
- id: id
70
- })(tr);
71
- view.dispatch(tr);
70
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2')) {
71
+ removeRegisteredCard === null || removeRegisteredCard === void 0 || removeRegisteredCard(id);
72
+ } else {
73
+ var tr = view.state.tr;
74
+ (0, _actions.removeCard)({
75
+ id: id
76
+ })(tr);
77
+ view.dispatch(tr);
78
+ }
72
79
  };
73
- }, [getPos, view]);
80
+ }, [getPos, (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2') ? undefined : view, (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2') ? removeRegisteredCard : undefined]);
74
81
  var scrollContainer = (0, _react.useMemo)(function () {
75
82
  return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2') && (0, _isIntersectionObserverSupported.isIntersectionObserverSupported)() ? undefined :
76
83
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -85,26 +92,40 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
85
92
  // don't dispatch immediately since we might be in the middle of
86
93
  // rendering a nodeview
87
94
  var scheduleRegisterCard = (0, _rafSchd.default)(function () {
88
- // prosemirror-bump-fix
89
- var pos = getPos();
90
- if (typeof pos !== 'number') {
91
- return;
95
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2')) {
96
+ if (removeCardDispatched.current || getPos() === undefined) {
97
+ return;
98
+ }
99
+ var id = refId.current;
100
+ registerResolvedCard === null || registerResolvedCard === void 0 || registerResolvedCard({
101
+ id: id,
102
+ title: title,
103
+ url: url,
104
+ getPos: getPos
105
+ });
106
+ onRes === null || onRes === void 0 || onRes(undefined, title);
107
+ } else {
108
+ // prosemirror-bump-fix
109
+ var pos = getPos();
110
+ if (typeof pos !== 'number') {
111
+ return;
112
+ }
113
+ var tr = view.state.tr;
114
+ (0, _actions.registerCard)({
115
+ title: title,
116
+ url: url,
117
+ pos: pos,
118
+ id: refId.current
119
+ })(tr);
120
+ onRes === null || onRes === void 0 || onRes(tr, title);
121
+ view.dispatch(tr);
92
122
  }
93
- var tr = view.state.tr;
94
- (0, _actions.registerCard)({
95
- title: title,
96
- url: url,
97
- pos: pos,
98
- id: refId.current
99
- })(tr);
100
- onRes === null || onRes === void 0 || onRes(tr, title);
101
- view.dispatch(tr);
102
123
  });
103
124
  if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks')) {
104
125
  pendingRegisterCard.current = scheduleRegisterCard;
105
126
  }
106
127
  scheduleRegisterCard();
107
- }, [getPos, view, onRes]);
128
+ }, [getPos, (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2') ? undefined : view, onRes, (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2') ? registerResolvedCard : undefined]);
108
129
  var onError = (0, _react.useCallback)(function (data) {
109
130
  var url = data.url,
110
131
  err = data.err;
@@ -77,25 +77,29 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
77
77
  setIsResolvedViewRendered = _useState6[1];
78
78
  var editorAppearance = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card.sharedState.currentState()) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.editorAppearance;
79
79
  var destinationUrl = (0, _useSmartLinkDestinationUrl.useSmartLinkDestinationUrl)(node.attrs.url);
80
+
81
+ // Remove tr: Transaction | undefined parameter with platform_editor_reduce_forced_layout_2 cleanup.
80
82
  var onResolve = (0, _react.useCallback)(function (tr, title) {
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
- };
85
- if (metadata && metadata.type === 'REGISTER') {
86
- (0, _actions.registerRemoveOverlay)(removeOverlay, metadata.info)(tr);
87
- } else {
88
- (0, _actions.registerRemoveOverlay)(removeOverlay)(tr);
83
+ if (tr) {
84
+ var metadata = tr.getMeta(_pluginKey.pluginKey);
85
+ var removeOverlay = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_memory_leaks') ? createRemoveOverlay(setIsInsertedRef) : function () {
86
+ return setIsInserted(false);
87
+ };
88
+ if (metadata && metadata.type === 'REGISTER') {
89
+ (0, _actions.registerRemoveOverlay)(removeOverlay, metadata.info)(tr);
90
+ } else {
91
+ (0, _actions.registerRemoveOverlay)(removeOverlay)(tr);
92
+ }
89
93
  }
90
94
  if (title) {
91
95
  setIsResolvedViewRendered(true);
92
96
  }
93
97
  }, []);
94
98
  var markMostRecentlyInsertedLink = (0, _react.useCallback)(function (isLinkMostRecentlyInserted) {
95
- if (isOverlayEnabled) {
99
+ if (isOverlayEnabled && !(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2')) {
96
100
  setIsInserted(isLinkMostRecentlyInserted);
97
101
  }
98
- }, [isOverlayEnabled]);
102
+ }, [(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2') ? undefined : isOverlayEnabled]);
99
103
  var setOverlayHoveredStyles = (0, _react.useCallback)(function (isHovered) {
100
104
  if (isOverlayEnabled) {
101
105
  setIsHovered(isHovered);
@@ -85,7 +85,7 @@ var replaceQueuedUrlWithCard = exports.replaceQueuedUrlWithCard = function repla
85
85
 
86
86
  // If an embed card transformer is provided and the resolved card is an embedCard,
87
87
  // attempt to transform it into an alternative node representation first.
88
- if (cardData.type === 'embedCard' && embedCardNodeTransformer && (0, _fg.fg)('platform_native_embeds_rollout_non_maui_experience')) {
88
+ if (cardData.type === 'embedCard' && embedCardNodeTransformer && ((0, _fg.fg)('platform_native_embeds_rollout_non_maui_experience') || (0, _fg.fg)('platform_native_embeds_rollout_all_products'))) {
89
89
  var transformResult = embedCardNodeTransformer(schema, cardData.attrs);
90
90
  // The transformer may return a Promise for async transformations (e.g. short-link expansion).
91
91
  // When async, we snapshot the current requests and positions now (before any dispatch),
@@ -35,14 +35,16 @@ var LOCAL_STORAGE_DISCOVERY_KEY_SMART_LINK = 'smart-link-upgrade-pulse';
35
35
  // Only the first resolved inline smart link is needed for PO spotlight targeting
36
36
  var MAX_RESOLVED_INLINE_SMART_LINKS = 1;
37
37
  var handleAwarenessOverlay = function handleAwarenessOverlay(view) {
38
- var currentState = (0, _state2.getPluginState)(view.state);
39
- var overlayCandidatePos = currentState === null || currentState === void 0 ? void 0 : currentState.overlayCandidatePosition;
40
- if (overlayCandidatePos) {
41
- var _currentState$removeO;
42
- (_currentState$removeO = currentState.removeOverlay) === null || _currentState$removeO === void 0 || _currentState$removeO.call(currentState);
43
- var tr = view.state.tr;
44
- (0, _actions.clearOverlayCandidate)(tr);
45
- view.dispatch(tr);
38
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2')) {
39
+ var currentState = (0, _state2.getPluginState)(view.state);
40
+ var overlayCandidatePos = currentState === null || currentState === void 0 ? void 0 : currentState.overlayCandidatePosition;
41
+ if (overlayCandidatePos) {
42
+ var _currentState$removeO;
43
+ (_currentState$removeO = currentState.removeOverlay) === null || _currentState$removeO === void 0 || _currentState$removeO.call(currentState);
44
+ var tr = view.state.tr;
45
+ (0, _actions.clearOverlayCandidate)(tr);
46
+ view.dispatch(tr);
47
+ }
46
48
  }
47
49
  };
48
50
  var createPlugin = exports.createPlugin = function createPlugin(options, pluginInjectionApi) {
@@ -158,7 +160,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pluginI
158
160
  var linkPosition = pluginState.requests[0].pos;
159
161
  var canBeUpgradedToBlock = allowBlockCards && (0, _utils3.isBlockSupportedAtPosition)(linkPosition, prevEditorState, 'inline');
160
162
  var canBeUpgradedToEmbed = allowEmbeds && (0, _utils3.isEmbedSupportedAtPosition)(linkPosition, prevEditorState, 'inline');
161
- if (canBeUpgradedToBlock || canBeUpgradedToEmbed) {
163
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2') && (canBeUpgradedToBlock || canBeUpgradedToEmbed)) {
162
164
  newState.overlayCandidatePosition = linkPosition;
163
165
  }
164
166
  if (!isSmartLinkPulseDiscovered && canBeUpgradedToEmbed) {
@@ -12,6 +12,7 @@ var _getResolvedAttributes = require("@atlaskit/link-analytics/get-resolved-attr
12
12
  var _assetsModal = require("@atlaskit/link-datasource/assets-modal");
13
13
  var _confluenceSearchModal = require("@atlaskit/link-datasource/confluence-search-modal");
14
14
  var _jiraIssuesModal = require("@atlaskit/link-datasource/jira-issues-modal");
15
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
15
16
  var _pluginKey = require("./plugin-key");
16
17
  var appearanceForNodeType = exports.appearanceForNodeType = function appearanceForNodeType(spec) {
17
18
  if (spec.name === 'inlineCard') {
@@ -50,14 +51,25 @@ var mergeCardInfo = exports.mergeCardInfo = function mergeCardInfo(titleUrlPair,
50
51
  var displayInfoForCard = exports.displayInfoForCard = function displayInfoForCard(node, info) {
51
52
  return mergeCardInfo(titleUrlPairFromNode(node), info);
52
53
  };
53
- var findCardInfo = exports.findCardInfo = function findCardInfo(state) {
54
- var pluginState = _pluginKey.pluginKey.getState(state);
55
- if (!pluginState) {
56
- return undefined;
54
+ var findCardInfo = exports.findCardInfo = function findCardInfo(state, cardActions) {
55
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2')) {
56
+ var _cardActions$getCardR, _cardActions$getCardR2;
57
+ var registrations = (_cardActions$getCardR = cardActions === null || cardActions === void 0 || (_cardActions$getCardR2 = cardActions.getCardRegistrations) === null || _cardActions$getCardR2 === void 0 ? void 0 : _cardActions$getCardR2.call(cardActions)) !== null && _cardActions$getCardR !== void 0 ? _cardActions$getCardR : {};
58
+ var card = Object.values(registrations).find(function (registration) {
59
+ return registration.getPos() === state.selection.from;
60
+ });
61
+ return card ? {
62
+ id: card.id,
63
+ title: card.title,
64
+ url: card.url,
65
+ pos: state.selection.from
66
+ } : undefined;
67
+ } else {
68
+ var pluginState = _pluginKey.pluginKey.getState(state);
69
+ return pluginState === null || pluginState === void 0 ? void 0 : pluginState.cards.find(function (cardInfo) {
70
+ return cardInfo.pos === state.selection.from;
71
+ });
57
72
  }
58
- return pluginState.cards.find(function (cardInfo) {
59
- return cardInfo.pos === state.selection.from;
60
- });
61
73
  };
62
74
  var isAppearanceSupportedInParent = function isAppearanceSupportedInParent(currentNodePosition, editorState, fragment, currentAppearance) {
63
75
  var resolvedPosition = editorState.doc.resolve(currentNodePosition);
@@ -20,6 +20,7 @@ var _linkSearchConstants = require("@atlaskit/editor-common/link-search-constant
20
20
  var _HyperlinkAddToolbar = require("@atlaskit/editor-common/link/HyperlinkAddToolbar");
21
21
  var _linkToolbar = require("@atlaskit/editor-common/messages/link-toolbar");
22
22
  var _state = require("@atlaskit/editor-prosemirror/state");
23
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
23
24
  var _actions = require("../pm-plugins/actions");
24
25
  var _doc = require("../pm-plugins/doc");
25
26
  var _utils2 = require("../pm-plugins/utils");
@@ -170,7 +171,7 @@ var buildEditLinkToolbar = exports.buildEditLinkToolbar = function buildEditLink
170
171
  if (!view || !providerFactory) {
171
172
  return null;
172
173
  }
173
- var displayInfo = (0, _utils2.displayInfoForCard)(node, (0, _utils2.findCardInfo)(view.state));
174
+ var displayInfo = (0, _utils2.displayInfoForCard)(node, (0, _utils2.findCardInfo)(view.state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.card.actions));
174
175
  return /*#__PURE__*/_react.default.createElement(EditLinkToolbar, {
175
176
  key: idx,
176
177
  view: view,
@@ -184,8 +185,9 @@ var buildEditLinkToolbar = exports.buildEditLinkToolbar = function buildEditLink
184
185
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
185
186
  ,
186
187
  onSubmit: function onSubmit(newHref, newText, inputMethod, analytic) {
187
- var urlChanged = newHref !== displayInfo.url;
188
- var titleChanged = newText !== displayInfo.title;
188
+ var currentDisplayInfo = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2') ? (0, _utils2.displayInfoForCard)(node, (0, _utils2.findCardInfo)(view.state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.card.actions)) : displayInfo;
189
+ var urlChanged = newHref !== currentDisplayInfo.url;
190
+ var titleChanged = newText !== currentDisplayInfo.title;
189
191
 
190
192
  // If the title is changed in a smartlink, convert to standard blue hyperlink
191
193
  // (even if the url was also changed) - we don't want to lose the custom title.
@@ -30,10 +30,13 @@ 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 _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
34
+ var _conditionalHooksFactory = require("@atlaskit/platform-feature-flags-react/conditional-hooks-factory/conditional-hooks-factory");
33
35
  var _box = require("@atlaskit/primitives/compiled/box");
34
36
  var _flex = require("@atlaskit/primitives/compiled/flex");
35
37
  var _pressable = require("@atlaskit/primitives/compiled/pressable");
36
38
  var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
39
+ var _useCardRegistry = require("../actions/useCardRegistry");
37
40
  var _doc = require("../pm-plugins/doc");
38
41
  var _currentPastedSmartLink = require("./currentPastedSmartLink");
39
42
  var _nativeEmbedNode = require("./nativeEmbedNode");
@@ -204,6 +207,17 @@ var normalizeSelectionToLinkRangeForUrlAppearance = exports.normalizeSelectionTo
204
207
  var linkRangeSelectionTr = editorView.state.tr.setSelection(_state.TextSelection.create(editorView.state.doc, firstLinkRange.from, firstLinkRange.to));
205
208
  editorView.dispatch(linkRangeSelectionTr);
206
209
  };
210
+ // Remove with platform_editor_reduce_forced_layout_2 cleanup; call useCardRegistry(api?.card?.actions) directly.
211
+ var useCardState = (0, _conditionalHooksFactory.conditionalHooksFactory)(function () {
212
+ return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2');
213
+ }, function useRegisteredCardState(api) {
214
+ var _api$card;
215
+ return (0, _useCardRegistry.useCardRegistry)(api === null || api === void 0 || (_api$card = api.card) === null || _api$card === void 0 ? void 0 : _api$card.actions);
216
+ }, function useLegacyCardState(api) {
217
+ return (0, _useSharedPluginStateWithSelector.useSharedPluginStateWithSelector)(api, ['card'], function (states) {
218
+ return states.cardState;
219
+ });
220
+ });
207
221
  var PasteDisplayAsMenuHorizontalView = function PasteDisplayAsMenuHorizontalView(_ref8) {
208
222
  var _smartCardContext$val, _cardAtPasteRange$app, _smartCardContext$val2;
209
223
  var api = _ref8.api,
@@ -224,10 +238,7 @@ var PasteDisplayAsMenuHorizontalView = function PasteDisplayAsMenuHorizontalView
224
238
  pasteStartPos: pluginState.pasteStartPos
225
239
  } : undefined;
226
240
  });
227
- // Subscribe to card state so the menu re-renders when resolved card metadata updates.
228
- (0, _useSharedPluginStateWithSelector.useSharedPluginStateWithSelector)(api, ['card'], function (states) {
229
- return states.cardState;
230
- });
241
+ useCardState(api);
231
242
  var pastedLinkUrlFromSlice = (0, _currentPastedSmartLink.getSingleSmartLinkUrlFromSlice)(getCurrentPastedSlice(api));
232
243
  var pastedLinkUrlFromCard = editorView && pasteRange ? getCardUrlAtPasteRange({
233
244
  editorView: editorView,