@atlaskit/editor-plugin-expand 2.10.1 → 2.10.2

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 (33) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/legacyExpand/nodeviews/index.js +33 -14
  3. package/dist/cjs/legacyExpand/plugin.js +3 -2
  4. package/dist/cjs/legacyExpand/pm-plugins/main.js +5 -2
  5. package/dist/cjs/singlePlayerExpand/node-views/index.js +39 -8
  6. package/dist/cjs/singlePlayerExpand/plugin.js +3 -2
  7. package/dist/cjs/singlePlayerExpand/pm-plugins/main.js +5 -2
  8. package/dist/cjs/singlePlayerExpand/ui/NodeView.js +1 -15
  9. package/dist/es2019/legacyExpand/nodeviews/index.js +24 -8
  10. package/dist/es2019/legacyExpand/plugin.js +3 -2
  11. package/dist/es2019/legacyExpand/pm-plugins/main.js +3 -1
  12. package/dist/es2019/singlePlayerExpand/node-views/index.js +35 -6
  13. package/dist/es2019/singlePlayerExpand/plugin.js +3 -2
  14. package/dist/es2019/singlePlayerExpand/pm-plugins/main.js +3 -1
  15. package/dist/es2019/singlePlayerExpand/ui/NodeView.js +0 -13
  16. package/dist/esm/legacyExpand/nodeviews/index.js +33 -14
  17. package/dist/esm/legacyExpand/plugin.js +3 -2
  18. package/dist/esm/legacyExpand/pm-plugins/main.js +5 -2
  19. package/dist/esm/singlePlayerExpand/node-views/index.js +40 -9
  20. package/dist/esm/singlePlayerExpand/plugin.js +3 -2
  21. package/dist/esm/singlePlayerExpand/pm-plugins/main.js +5 -2
  22. package/dist/esm/singlePlayerExpand/ui/NodeView.js +0 -13
  23. package/dist/types/legacyExpand/nodeviews/index.d.ts +6 -2
  24. package/dist/types/legacyExpand/pm-plugins/main.d.ts +2 -1
  25. package/dist/types/singlePlayerExpand/node-views/index.d.ts +7 -2
  26. package/dist/types/singlePlayerExpand/pm-plugins/main.d.ts +2 -1
  27. package/dist/types/singlePlayerExpand/ui/NodeView.d.ts +0 -1
  28. package/dist/types-ts4.5/legacyExpand/nodeviews/index.d.ts +6 -2
  29. package/dist/types-ts4.5/legacyExpand/pm-plugins/main.d.ts +2 -1
  30. package/dist/types-ts4.5/singlePlayerExpand/node-views/index.d.ts +7 -2
  31. package/dist/types-ts4.5/singlePlayerExpand/pm-plugins/main.d.ts +2 -1
  32. package/dist/types-ts4.5/singlePlayerExpand/ui/NodeView.d.ts +0 -1
  33. package/package.json +9 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-expand
2
2
 
3
+ ## 2.10.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#163321](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/163321)
8
+ [`9cbf3468984dc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9cbf3468984dc) -
9
+ ED-25609: migrates expand plugin ReactDOM references to portalprovider
10
+ - Updated dependencies
11
+
3
12
  ## 2.10.1
4
13
 
5
14
  ### Patch Changes
@@ -11,6 +11,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _react = _interopRequireDefault(require("react"));
13
13
  var _reactDom = _interopRequireDefault(require("react-dom"));
14
+ var _v = _interopRequireDefault(require("uuid/v4"));
14
15
  var _w3cKeyname = require("w3c-keyname");
15
16
  var _selection = require("@atlaskit/editor-common/selection");
16
17
  var _styles = require("@atlaskit/editor-common/styles");
@@ -61,12 +62,12 @@ var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditabl
61
62
  }, 0]];
62
63
  };
63
64
  var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
64
- function ExpandNodeView(_node, view, getPos, getIntl, isMobile, selectNearNode, api) {
65
+ function ExpandNodeView(_node, view, getPos, getIntl, isMobile, selectNearNode, api, nodeViewPortalProviderAPI) {
65
66
  var _this = this,
66
67
  _api$editorDisabled;
67
- var allowInteractiveExpand = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
68
- var __livePage = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
69
- var cleanUpEditorDisabledOnChange = arguments.length > 9 ? arguments[9] : undefined;
68
+ var allowInteractiveExpand = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : true;
69
+ var __livePage = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
70
+ var cleanUpEditorDisabledOnChange = arguments.length > 10 ? arguments[10] : undefined;
70
71
  (0, _classCallCheck2.default)(this, ExpandNodeView);
71
72
  (0, _defineProperty2.default)(this, "allowInteractiveExpand", true);
72
73
  (0, _defineProperty2.default)(this, "isMobile", false);
@@ -412,6 +413,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
412
413
  var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(_node, this.__livePage, this.intl, api === null || api === void 0 || (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 || (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.editorDisabled)),
413
414
  dom = _DOMSerializer$render.dom,
414
415
  contentDOM = _DOMSerializer$render.contentDOM;
416
+ this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
415
417
  this.allowInteractiveExpand = allowInteractiveExpand;
416
418
  this.getPos = getPos;
417
419
  this.view = view;
@@ -424,6 +426,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
424
426
  this.input = this.dom.querySelector(".".concat(_styles.expandClassNames.titleInput));
425
427
  this.titleContainer = this.dom.querySelector(".".concat(_styles.expandClassNames.titleContainer));
426
428
  this.content = this.dom.querySelector(".".concat(_styles.expandClassNames.content));
429
+ this.renderKey = (0, _v.default)();
427
430
  this.renderIcon(this.intl);
428
431
  this.initHandlers();
429
432
  }
@@ -475,16 +478,27 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
475
478
  }, {
476
479
  key: "renderIcon",
477
480
  value: function renderIcon(intl, node) {
481
+ var _this3 = this;
478
482
  if (!this.icon) {
479
483
  return;
480
484
  }
481
485
  var _ref = node && node.attrs || this.node.attrs,
482
486
  __expanded = _ref.__expanded;
483
- _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_ExpandIconButton.ExpandIconButton, {
484
- intl: intl,
485
- allowInteractiveExpand: this.allowInteractiveExpand,
486
- expanded: this.__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') ? !__expanded : __expanded
487
- }), this.icon);
487
+ if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
488
+ this.nodeViewPortalProviderAPI.render(function () {
489
+ return /*#__PURE__*/_react.default.createElement(_ExpandIconButton.ExpandIconButton, {
490
+ intl: intl,
491
+ allowInteractiveExpand: _this3.allowInteractiveExpand,
492
+ expanded: _this3.__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') ? !__expanded : __expanded
493
+ });
494
+ }, this.icon, this.renderKey);
495
+ } else {
496
+ _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_ExpandIconButton.ExpandIconButton, {
497
+ intl: intl,
498
+ allowInteractiveExpand: this.allowInteractiveExpand,
499
+ expanded: this.__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence') ? !__expanded : __expanded
500
+ }), this.icon);
501
+ }
488
502
  }
489
503
  }, {
490
504
  key: "stopEvent",
@@ -508,7 +522,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
508
522
  }, {
509
523
  key: "update",
510
524
  value: function update(node, _decorations) {
511
- var _this3 = this;
525
+ var _this4 = this;
512
526
  if (this.node.type === node.type) {
513
527
  if (this.node.attrs.__expanded !== node.attrs.__expanded) {
514
528
  // Instead of re-rendering the view on an expand toggle
@@ -527,8 +541,8 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
527
541
  // since we're intentionally being less aggressive about re-rendering.
528
542
  // We also apply a rAF to avoid abrupt continuous replacement of the title.
529
543
  window.requestAnimationFrame(function () {
530
- if (_this3.input && _this3.node.attrs.title !== _this3.input.value) {
531
- _this3.input.value = _this3.node.attrs.title;
544
+ if (_this4.input && _this4.node.attrs.title !== _this4.input.value) {
545
+ _this4.input.value = _this4.node.attrs.title;
532
546
  }
533
547
  });
534
548
  this.node = node;
@@ -561,7 +575,11 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
561
575
  if (this.icon) {
562
576
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
563
577
  this.icon.removeEventListener('keydown', this.handleIconKeyDown);
564
- _reactDom.default.unmountComponentAtNode(this.icon);
578
+ if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
579
+ this.nodeViewPortalProviderAPI.remove(this.renderKey);
580
+ } else {
581
+ _reactDom.default.unmountComponentAtNode(this.icon);
582
+ }
565
583
  }
566
584
  (_this$decorationClean2 = this.decorationCleanup) === null || _this$decorationClean2 === void 0 || _this$decorationClean2.call(this);
567
585
  if (this.cleanUpEditorDisabledOnChange) {
@@ -584,11 +602,12 @@ function _default(_ref2) {
584
602
  var getIntl = _ref2.getIntl,
585
603
  isMobile = _ref2.isMobile,
586
604
  api = _ref2.api,
605
+ nodeViewPortalProviderAPI = _ref2.nodeViewPortalProviderAPI,
587
606
  _ref2$allowInteractiv = _ref2.allowInteractiveExpand,
588
607
  allowInteractiveExpand = _ref2$allowInteractiv === void 0 ? true : _ref2$allowInteractiv,
589
608
  __livePage = _ref2.__livePage;
590
609
  return function (node, view, getPos) {
591
610
  var _api$selection;
592
- return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.actions) === null || _api$selection === void 0 ? void 0 : _api$selection.selectNearNode, api, allowInteractiveExpand, __livePage);
611
+ return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.actions) === null || _api$selection === void 0 ? void 0 : _api$selection.selectNearNode, api, nodeViewPortalProviderAPI, allowInteractiveExpand, __livePage);
593
612
  };
594
613
  }
@@ -53,8 +53,9 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
53
53
  plugin: function plugin(_ref2) {
54
54
  var _options$allowInterac;
55
55
  var dispatch = _ref2.dispatch,
56
- getIntl = _ref2.getIntl;
57
- return (0, _main.createPlugin)(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true, options.__livePage);
56
+ getIntl = _ref2.getIntl,
57
+ nodeViewPortalProviderAPI = _ref2.nodeViewPortalProviderAPI;
58
+ return (0, _main.createPlugin)(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, nodeViewPortalProviderAPI, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true, options.__livePage);
58
59
  }
59
60
  }, {
60
61
  name: 'expandKeymap',
@@ -25,8 +25,9 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
25
25
  var appearance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'full-page';
26
26
  var useLongPressSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
27
27
  var api = arguments.length > 4 ? arguments[4] : undefined;
28
- var allowInteractiveExpand = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
29
- var __livePage = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
28
+ var nodeViewPortalProviderAPI = arguments.length > 5 ? arguments[5] : undefined;
29
+ var allowInteractiveExpand = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
30
+ var __livePage = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
30
31
  var state = (0, _pluginFactory.createPluginState)(dispatch, {});
31
32
  var isMobile = false;
32
33
  return new _safePlugin.SafePlugin({
@@ -38,6 +39,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
38
39
  getIntl: getIntl,
39
40
  isMobile: isMobile,
40
41
  api: api,
42
+ nodeViewPortalProviderAPI: nodeViewPortalProviderAPI,
41
43
  allowInteractiveExpand: allowInteractiveExpand,
42
44
  __livePage: __livePage
43
45
  }),
@@ -45,6 +47,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
45
47
  getIntl: getIntl,
46
48
  isMobile: isMobile,
47
49
  api: api,
50
+ nodeViewPortalProviderAPI: nodeViewPortalProviderAPI,
48
51
  allowInteractiveExpand: allowInteractiveExpand,
49
52
  __livePage: __livePage
50
53
  })
@@ -9,7 +9,9 @@ exports.default = _default;
9
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ var _react = _interopRequireDefault(require("react"));
12
13
  var _reactDom = _interopRequireDefault(require("react-dom"));
14
+ var _v = _interopRequireDefault(require("uuid/v4"));
13
15
  var _w3cKeyname = require("w3c-keyname");
14
16
  var _expand = require("@atlaskit/editor-common/expand");
15
17
  var _selection = require("@atlaskit/editor-common/selection");
@@ -18,16 +20,18 @@ var _utils = require("@atlaskit/editor-common/utils");
18
20
  var _history = require("@atlaskit/editor-prosemirror/history");
19
21
  var _model = require("@atlaskit/editor-prosemirror/model");
20
22
  var _state = require("@atlaskit/editor-prosemirror/state");
23
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
24
  var _commands = require("../commands");
25
+ var _ExpandButton = require("../ui/ExpandButton");
22
26
  var _NodeView = require("../ui/NodeView");
23
27
  var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
24
- function ExpandNodeView(_node, view, getPos, getIntl, isMobile, selectNearNode, api) {
28
+ function ExpandNodeView(_node, view, getPos, getIntl, isMobile, selectNearNode, api, nodeViewPortalProviderAPI) {
25
29
  var _this = this,
26
30
  _api$editorDisabled,
27
31
  _this$api6;
28
- var allowInteractiveExpand = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
29
- var __livePage = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
30
- var cleanUpEditorDisabledOnChange = arguments.length > 9 ? arguments[9] : undefined;
32
+ var allowInteractiveExpand = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : true;
33
+ var __livePage = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
34
+ var cleanUpEditorDisabledOnChange = arguments.length > 10 ? arguments[10] : undefined;
31
35
  (0, _classCallCheck2.default)(this, ExpandNodeView);
32
36
  (0, _defineProperty2.default)(this, "allowInteractiveExpand", true);
33
37
  (0, _defineProperty2.default)(this, "isMobile", false);
@@ -359,10 +363,31 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
359
363
  }
360
364
  return contentEditable;
361
365
  });
366
+ (0, _defineProperty2.default)(this, "renderIcon", function (icon, expanded) {
367
+ if (!icon) {
368
+ return;
369
+ }
370
+ if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
371
+ _this.nodeViewPortalProviderAPI.render(function () {
372
+ return /*#__PURE__*/_react.default.createElement(_ExpandButton.ExpandButton, {
373
+ intl: _this.intl,
374
+ allowInteractiveExpand: _this.allowInteractiveExpand,
375
+ expanded: expanded
376
+ });
377
+ }, icon, _this.renderKey);
378
+ } else {
379
+ _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_ExpandButton.ExpandButton, {
380
+ intl: _this.intl,
381
+ allowInteractiveExpand: _this.allowInteractiveExpand,
382
+ expanded: expanded
383
+ }), icon);
384
+ }
385
+ });
362
386
  this.selectNearNode = selectNearNode;
363
387
  this.__livePage = __livePage;
364
388
  this.cleanUpEditorDisabledOnChange = cleanUpEditorDisabledOnChange;
365
389
  this.intl = getIntl();
390
+ this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
366
391
  this.allowInteractiveExpand = allowInteractiveExpand;
367
392
  this.getPos = getPos;
368
393
  this.view = view;
@@ -377,11 +402,12 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
377
402
  this.icon = this.dom.querySelector(".".concat(_styles.expandClassNames.icon));
378
403
  this.input = this.dom.querySelector(".".concat(_styles.expandClassNames.titleInput));
379
404
  this.titleContainer = this.dom.querySelector(".".concat(_styles.expandClassNames.titleContainer));
405
+ this.renderKey = (0, _v.default)();
380
406
  this.content = this.dom.querySelector(".".concat(_styles.expandClassNames.content));
381
407
  if (!_expand.expandedState.has(this.node)) {
382
408
  _expand.expandedState.set(this.node, false);
383
409
  }
384
- (0, _NodeView.renderIcon)(this.icon, this.allowInteractiveExpand, !(0, _expand.isExpandCollapsed)(this.node), this.intl);
410
+ this.renderIcon(this.icon, !(0, _expand.isExpandCollapsed)(this.node));
385
411
  if (!this.input || !this.titleContainer || !this.icon) {
386
412
  return;
387
413
  }
@@ -470,7 +496,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
470
496
  var _expandedState$get;
471
497
  this.dom.className = (0, _NodeView.buildExpandClassName)(node.type.name, expanded);
472
498
  // Re-render the icon to update the aria-expanded attribute
473
- (0, _NodeView.renderIcon)(this.icon ? this.icon : null, this.allowInteractiveExpand, (_expandedState$get = _expand.expandedState.get(node)) !== null && _expandedState$get !== void 0 ? _expandedState$get : false, this.intl);
499
+ this.renderIcon(this.icon ? this.icon : null, (_expandedState$get = _expand.expandedState.get(node)) !== null && _expandedState$get !== void 0 ? _expandedState$get : false);
474
500
  }
475
501
  this.updateExpandBodyContentEditable();
476
502
  }
@@ -500,7 +526,11 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
500
526
  if (this.cleanUpEditorDisabledOnChange) {
501
527
  this.cleanUpEditorDisabledOnChange();
502
528
  }
503
- _reactDom.default.unmountComponentAtNode(this.icon);
529
+ if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
530
+ this.nodeViewPortalProviderAPI.remove(this.renderKey);
531
+ } else {
532
+ _reactDom.default.unmountComponentAtNode(this.icon);
533
+ }
504
534
  }
505
535
  }]);
506
536
  return ExpandNodeView;
@@ -509,11 +539,12 @@ function _default(_ref) {
509
539
  var getIntl = _ref.getIntl,
510
540
  isMobile = _ref.isMobile,
511
541
  api = _ref.api,
542
+ nodeViewPortalProviderAPI = _ref.nodeViewPortalProviderAPI,
512
543
  _ref$allowInteractive = _ref.allowInteractiveExpand,
513
544
  allowInteractiveExpand = _ref$allowInteractive === void 0 ? true : _ref$allowInteractive,
514
545
  __livePage = _ref.__livePage;
515
546
  return function (node, view, getPos) {
516
547
  var _api$selection;
517
- return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.actions) === null || _api$selection === void 0 ? void 0 : _api$selection.selectNearNode, api, allowInteractiveExpand, __livePage);
548
+ return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.actions) === null || _api$selection === void 0 ? void 0 : _api$selection.selectNearNode, api, nodeViewPortalProviderAPI, allowInteractiveExpand, __livePage);
518
549
  };
519
550
  }
@@ -46,8 +46,9 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
46
46
  plugin: function plugin(_ref2) {
47
47
  var _options$allowInterac;
48
48
  var dispatch = _ref2.dispatch,
49
- getIntl = _ref2.getIntl;
50
- return (0, _main.createPlugin)(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true, options.__livePage);
49
+ getIntl = _ref2.getIntl,
50
+ nodeViewPortalProviderAPI = _ref2.nodeViewPortalProviderAPI;
51
+ return (0, _main.createPlugin)(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, nodeViewPortalProviderAPI, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true, options.__livePage);
51
52
  }
52
53
  }, {
53
54
  name: 'expandKeymap',
@@ -25,8 +25,9 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
25
25
  var appearance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'full-page';
26
26
  var useLongPressSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
27
27
  var api = arguments.length > 4 ? arguments[4] : undefined;
28
- var allowInteractiveExpand = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
29
- var __livePage = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
28
+ var nodeViewPortalProviderAPI = arguments.length > 5 ? arguments[5] : undefined;
29
+ var allowInteractiveExpand = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
30
+ var __livePage = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
30
31
  var isMobile = false;
31
32
  return new _safePlugin.SafePlugin({
32
33
  key: pluginKey,
@@ -36,6 +37,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
36
37
  getIntl: getIntl,
37
38
  isMobile: isMobile,
38
39
  api: api,
40
+ nodeViewPortalProviderAPI: nodeViewPortalProviderAPI,
39
41
  allowInteractiveExpand: allowInteractiveExpand,
40
42
  __livePage: __livePage
41
43
  }),
@@ -43,6 +45,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
43
45
  getIntl: getIntl,
44
46
  isMobile: isMobile,
45
47
  api: api,
48
+ nodeViewPortalProviderAPI: nodeViewPortalProviderAPI,
46
49
  allowInteractiveExpand: allowInteractiveExpand,
47
50
  __livePage: __livePage
48
51
  })
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
- exports.toDOM = exports.renderIcon = exports.buildExpandClassName = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _reactDom = _interopRequireDefault(require("react-dom"));
6
+ exports.toDOM = exports.buildExpandClassName = void 0;
10
7
  var _expand = require("@atlaskit/editor-common/expand");
11
8
  var _styles = require("@atlaskit/editor-common/styles");
12
9
  var _ui = require("@atlaskit/editor-common/ui");
13
- var _ExpandButton = require("../ui/ExpandButton");
14
10
  var buildExpandClassName = exports.buildExpandClassName = function buildExpandClassName(type, expanded) {
15
11
  return "".concat(_styles.expandClassNames.prefix, " ").concat(_styles.expandClassNames.type(type), " ").concat(expanded ? _styles.expandClassNames.expanded : '');
16
12
  };
@@ -49,14 +45,4 @@ var toDOM = exports.toDOM = function toDOM(node, __livePage, intl, titleReadOnly
49
45
  class: _styles.expandClassNames.content,
50
46
  contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
51
47
  }, 0]];
52
- };
53
- var renderIcon = exports.renderIcon = function renderIcon(icon, allowInteractiveExpand, expanded, intl) {
54
- if (!icon) {
55
- return;
56
- }
57
- _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_ExpandButton.ExpandButton, {
58
- intl: intl,
59
- allowInteractiveExpand: allowInteractiveExpand,
60
- expanded: expanded
61
- }), icon);
62
48
  };
@@ -1,6 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import ReactDOM from 'react-dom';
4
+ import uuid from 'uuid/v4';
4
5
  import { keyName } from 'w3c-keyname';
5
6
  import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
6
7
  import { expandClassNames } from '@atlaskit/editor-common/styles';
@@ -49,7 +50,7 @@ const toDOM = (node, __livePage, intl, titleReadOnly, contentEditable) => ['div'
49
50
  contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
50
51
  }, 0]];
51
52
  export class ExpandNodeView {
52
- constructor(_node, view, getPos, getIntl, isMobile, selectNearNode, api, allowInteractiveExpand = true, __livePage = false, cleanUpEditorDisabledOnChange) {
53
+ constructor(_node, view, getPos, getIntl, isMobile, selectNearNode, api, nodeViewPortalProviderAPI, allowInteractiveExpand = true, __livePage = false, cleanUpEditorDisabledOnChange) {
53
54
  var _api$editorDisabled, _api$editorDisabled$s;
54
55
  _defineProperty(this, "allowInteractiveExpand", true);
55
56
  _defineProperty(this, "isMobile", false);
@@ -414,6 +415,7 @@ export class ExpandNodeView {
414
415
  dom,
415
416
  contentDOM
416
417
  } = DOMSerializer.renderSpec(document, toDOM(_node, this.__livePage, this.intl, api === null || api === void 0 ? void 0 : (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 ? void 0 : (_api$editorDisabled$s = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled$s === void 0 ? void 0 : _api$editorDisabled$s.editorDisabled));
418
+ this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
417
419
  this.allowInteractiveExpand = allowInteractiveExpand;
418
420
  this.getPos = getPos;
419
421
  this.view = view;
@@ -426,6 +428,7 @@ export class ExpandNodeView {
426
428
  this.input = this.dom.querySelector(`.${expandClassNames.titleInput}`);
427
429
  this.titleContainer = this.dom.querySelector(`.${expandClassNames.titleContainer}`);
428
430
  this.content = this.dom.querySelector(`.${expandClassNames.content}`);
431
+ this.renderKey = uuid();
429
432
  this.renderIcon(this.intl);
430
433
  this.initHandlers();
431
434
  }
@@ -478,11 +481,19 @@ export class ExpandNodeView {
478
481
  let {
479
482
  __expanded
480
483
  } = node && node.attrs || this.node.attrs;
481
- ReactDOM.render( /*#__PURE__*/React.createElement(ExpandIconButton, {
482
- intl: intl,
483
- allowInteractiveExpand: this.allowInteractiveExpand,
484
- expanded: this.__livePage && fg('platform.editor.live-pages-expand-divergence') ? !__expanded : __expanded
485
- }), this.icon);
484
+ if (fg('platform_editor_react18_plugin_portalprovider')) {
485
+ this.nodeViewPortalProviderAPI.render(() => /*#__PURE__*/React.createElement(ExpandIconButton, {
486
+ intl: intl,
487
+ allowInteractiveExpand: this.allowInteractiveExpand,
488
+ expanded: this.__livePage && fg('platform.editor.live-pages-expand-divergence') ? !__expanded : __expanded
489
+ }), this.icon, this.renderKey);
490
+ } else {
491
+ ReactDOM.render( /*#__PURE__*/React.createElement(ExpandIconButton, {
492
+ intl: intl,
493
+ allowInteractiveExpand: this.allowInteractiveExpand,
494
+ expanded: this.__livePage && fg('platform.editor.live-pages-expand-divergence') ? !__expanded : __expanded
495
+ }), this.icon);
496
+ }
486
497
  }
487
498
  stopEvent(event) {
488
499
  const target = event.target;
@@ -550,7 +561,11 @@ export class ExpandNodeView {
550
561
  if (this.icon) {
551
562
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
552
563
  this.icon.removeEventListener('keydown', this.handleIconKeyDown);
553
- ReactDOM.unmountComponentAtNode(this.icon);
564
+ if (fg('platform_editor_react18_plugin_portalprovider')) {
565
+ this.nodeViewPortalProviderAPI.remove(this.renderKey);
566
+ } else {
567
+ ReactDOM.unmountComponentAtNode(this.icon);
568
+ }
554
569
  }
555
570
  (_this$decorationClean2 = this.decorationCleanup) === null || _this$decorationClean2 === void 0 ? void 0 : _this$decorationClean2.call(this);
556
571
  if (this.cleanUpEditorDisabledOnChange) {
@@ -571,11 +586,12 @@ export default function ({
571
586
  getIntl,
572
587
  isMobile,
573
588
  api,
589
+ nodeViewPortalProviderAPI,
574
590
  allowInteractiveExpand = true,
575
591
  __livePage
576
592
  }) {
577
593
  return (node, view, getPos) => {
578
594
  var _api$selection, _api$selection$action;
579
- return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : (_api$selection$action = _api$selection.actions) === null || _api$selection$action === void 0 ? void 0 : _api$selection$action.selectNearNode, api, allowInteractiveExpand, __livePage);
595
+ return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : (_api$selection$action = _api$selection.actions) === null || _api$selection$action === void 0 ? void 0 : _api$selection$action.selectNearNode, api, nodeViewPortalProviderAPI, allowInteractiveExpand, __livePage);
580
596
  };
581
597
  }
@@ -39,10 +39,11 @@ export const expandPlugin = ({
39
39
  name: 'expand',
40
40
  plugin: ({
41
41
  dispatch,
42
- getIntl
42
+ getIntl,
43
+ nodeViewPortalProviderAPI
43
44
  }) => {
44
45
  var _options$allowInterac;
45
- return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true, options.__livePage);
46
+ return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, nodeViewPortalProviderAPI, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true, options.__livePage);
46
47
  }
47
48
  }, {
48
49
  name: 'expandKeymap',
@@ -12,7 +12,7 @@ export function containsClass(element, className) {
12
12
  var _element$classList;
13
13
  return Boolean(element === null || element === void 0 ? void 0 : (_element$classList = element.classList) === null || _element$classList === void 0 ? void 0 : _element$classList.contains(className));
14
14
  }
15
- export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLongPressSelection = false, api, allowInteractiveExpand = true, __livePage = false) => {
15
+ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLongPressSelection = false, api, nodeViewPortalProviderAPI, allowInteractiveExpand = true, __livePage = false) => {
16
16
  const state = createPluginState(dispatch, {});
17
17
  const isMobile = false;
18
18
  return new SafePlugin({
@@ -24,6 +24,7 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
24
24
  getIntl,
25
25
  isMobile,
26
26
  api,
27
+ nodeViewPortalProviderAPI,
27
28
  allowInteractiveExpand,
28
29
  __livePage
29
30
  }),
@@ -31,6 +32,7 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
31
32
  getIntl,
32
33
  isMobile,
33
34
  api,
35
+ nodeViewPortalProviderAPI,
34
36
  allowInteractiveExpand,
35
37
  __livePage
36
38
  })
@@ -1,5 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import React from 'react';
2
3
  import ReactDOM from 'react-dom';
4
+ import uuid from 'uuid/v4';
3
5
  import { keyName } from 'w3c-keyname';
4
6
  import { expandedState, isExpandCollapsed } from '@atlaskit/editor-common/expand';
5
7
  import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
@@ -8,10 +10,12 @@ import { closestElement, isEmptyNode } from '@atlaskit/editor-common/utils';
8
10
  import { redo, undo } from '@atlaskit/editor-prosemirror/history';
9
11
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
10
12
  import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
11
14
  import { deleteExpand, setSelectionInsideExpand, toggleExpandExpanded, updateExpandTitle } from '../commands';
12
- import { buildExpandClassName, renderIcon, toDOM } from '../ui/NodeView';
15
+ import { ExpandButton } from '../ui/ExpandButton';
16
+ import { buildExpandClassName, toDOM } from '../ui/NodeView';
13
17
  export class ExpandNodeView {
14
- constructor(_node, view, getPos, getIntl, isMobile, selectNearNode, api, allowInteractiveExpand = true, __livePage = false, cleanUpEditorDisabledOnChange) {
18
+ constructor(_node, view, getPos, getIntl, isMobile, selectNearNode, api, nodeViewPortalProviderAPI, allowInteractiveExpand = true, __livePage = false, cleanUpEditorDisabledOnChange) {
15
19
  var _api$editorDisabled, _api$editorDisabled$s, _this$api6;
16
20
  _defineProperty(this, "allowInteractiveExpand", true);
17
21
  _defineProperty(this, "isMobile", false);
@@ -360,10 +364,29 @@ export class ExpandNodeView {
360
364
  }
361
365
  return contentEditable;
362
366
  });
367
+ _defineProperty(this, "renderIcon", (icon, expanded) => {
368
+ if (!icon) {
369
+ return;
370
+ }
371
+ if (fg('platform_editor_react18_plugin_portalprovider')) {
372
+ this.nodeViewPortalProviderAPI.render(() => /*#__PURE__*/React.createElement(ExpandButton, {
373
+ intl: this.intl,
374
+ allowInteractiveExpand: this.allowInteractiveExpand,
375
+ expanded: expanded
376
+ }), icon, this.renderKey);
377
+ } else {
378
+ ReactDOM.render( /*#__PURE__*/React.createElement(ExpandButton, {
379
+ intl: this.intl,
380
+ allowInteractiveExpand: this.allowInteractiveExpand,
381
+ expanded: expanded
382
+ }), icon);
383
+ }
384
+ });
363
385
  this.selectNearNode = selectNearNode;
364
386
  this.__livePage = __livePage;
365
387
  this.cleanUpEditorDisabledOnChange = cleanUpEditorDisabledOnChange;
366
388
  this.intl = getIntl();
389
+ this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
367
390
  this.allowInteractiveExpand = allowInteractiveExpand;
368
391
  this.getPos = getPos;
369
392
  this.view = view;
@@ -379,11 +402,12 @@ export class ExpandNodeView {
379
402
  this.icon = this.dom.querySelector(`.${expandClassNames.icon}`);
380
403
  this.input = this.dom.querySelector(`.${expandClassNames.titleInput}`);
381
404
  this.titleContainer = this.dom.querySelector(`.${expandClassNames.titleContainer}`);
405
+ this.renderKey = uuid();
382
406
  this.content = this.dom.querySelector(`.${expandClassNames.content}`);
383
407
  if (!expandedState.has(this.node)) {
384
408
  expandedState.set(this.node, false);
385
409
  }
386
- renderIcon(this.icon, this.allowInteractiveExpand, !isExpandCollapsed(this.node), this.intl);
410
+ this.renderIcon(this.icon, !isExpandCollapsed(this.node));
387
411
  if (!this.input || !this.titleContainer || !this.icon) {
388
412
  return;
389
413
  }
@@ -463,7 +487,7 @@ export class ExpandNodeView {
463
487
  var _expandedState$get;
464
488
  this.dom.className = buildExpandClassName(node.type.name, expanded);
465
489
  // Re-render the icon to update the aria-expanded attribute
466
- renderIcon(this.icon ? this.icon : null, this.allowInteractiveExpand, (_expandedState$get = expandedState.get(node)) !== null && _expandedState$get !== void 0 ? _expandedState$get : false, this.intl);
490
+ this.renderIcon(this.icon ? this.icon : null, (_expandedState$get = expandedState.get(node)) !== null && _expandedState$get !== void 0 ? _expandedState$get : false);
467
491
  }
468
492
  this.updateExpandBodyContentEditable();
469
493
  }
@@ -489,18 +513,23 @@ export class ExpandNodeView {
489
513
  if (this.cleanUpEditorDisabledOnChange) {
490
514
  this.cleanUpEditorDisabledOnChange();
491
515
  }
492
- ReactDOM.unmountComponentAtNode(this.icon);
516
+ if (fg('platform_editor_react18_plugin_portalprovider')) {
517
+ this.nodeViewPortalProviderAPI.remove(this.renderKey);
518
+ } else {
519
+ ReactDOM.unmountComponentAtNode(this.icon);
520
+ }
493
521
  }
494
522
  }
495
523
  export default function ({
496
524
  getIntl,
497
525
  isMobile,
498
526
  api,
527
+ nodeViewPortalProviderAPI,
499
528
  allowInteractiveExpand = true,
500
529
  __livePage
501
530
  }) {
502
531
  return (node, view, getPos) => {
503
532
  var _api$selection, _api$selection$action;
504
- return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : (_api$selection$action = _api$selection.actions) === null || _api$selection$action === void 0 ? void 0 : _api$selection$action.selectNearNode, api, allowInteractiveExpand, __livePage);
533
+ return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : (_api$selection$action = _api$selection.actions) === null || _api$selection$action === void 0 ? void 0 : _api$selection$action.selectNearNode, api, nodeViewPortalProviderAPI, allowInteractiveExpand, __livePage);
505
534
  };
506
535
  }
@@ -38,10 +38,11 @@ export const expandPlugin = ({
38
38
  name: 'expand',
39
39
  plugin: ({
40
40
  dispatch,
41
- getIntl
41
+ getIntl,
42
+ nodeViewPortalProviderAPI
42
43
  }) => {
43
44
  var _options$allowInterac;
44
- return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true, options.__livePage);
45
+ return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, nodeViewPortalProviderAPI, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true, options.__livePage);
45
46
  }
46
47
  }, {
47
48
  name: 'expandKeymap',
@@ -11,7 +11,7 @@ export function containsClass(element, className) {
11
11
  var _element$classList;
12
12
  return Boolean(element === null || element === void 0 ? void 0 : (_element$classList = element.classList) === null || _element$classList === void 0 ? void 0 : _element$classList.contains(className));
13
13
  }
14
- export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLongPressSelection = false, api, allowInteractiveExpand = true, __livePage = false) => {
14
+ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLongPressSelection = false, api, nodeViewPortalProviderAPI, allowInteractiveExpand = true, __livePage = false) => {
15
15
  const isMobile = false;
16
16
  return new SafePlugin({
17
17
  key: pluginKey,
@@ -21,6 +21,7 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
21
21
  getIntl,
22
22
  isMobile,
23
23
  api,
24
+ nodeViewPortalProviderAPI,
24
25
  allowInteractiveExpand,
25
26
  __livePage
26
27
  }),
@@ -28,6 +29,7 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
28
29
  getIntl,
29
30
  isMobile,
30
31
  api,
32
+ nodeViewPortalProviderAPI,
31
33
  allowInteractiveExpand,
32
34
  __livePage
33
35
  })