@bigbinary/neeto-editor-frontend 2.2.1 → 2.2.3

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 (79) hide show
  1. package/dist/.ready +1 -1
  2. package/dist/Editor.js +7 -7
  3. package/dist/EditorContent.js +4 -4
  4. package/dist/FormikEditor.js +7 -7
  5. package/dist/Menu.js +5 -5
  6. package/dist/{chunk-CRUXOawK.js → chunk-B5LsYrmv.js} +4 -4
  7. package/dist/{chunk-CRUXOawK.js.map → chunk-B5LsYrmv.js.map} +1 -1
  8. package/dist/{chunk-lEnpEBRB.js → chunk-BozdxlzB.js} +5 -5
  9. package/dist/{chunk-lEnpEBRB.js.map → chunk-BozdxlzB.js.map} +1 -1
  10. package/dist/{chunk-BpMZjml2.js → chunk-C9H9LYpP.js} +2 -2
  11. package/dist/chunk-C9H9LYpP.js.map +1 -0
  12. package/dist/{chunk-YhV82e9I.js → chunk-CcLntzzh.js} +4 -4
  13. package/dist/{chunk-YhV82e9I.js.map → chunk-CcLntzzh.js.map} +1 -1
  14. package/dist/{chunk-BNyLNMnb.js → chunk-DGsiNcMa.js} +3 -3
  15. package/dist/{chunk-BNyLNMnb.js.map → chunk-DGsiNcMa.js.map} +1 -1
  16. package/dist/{chunk-DYRpf9PJ.js → chunk-DPx9v04U.js} +3 -3
  17. package/dist/{chunk-DYRpf9PJ.js.map → chunk-DPx9v04U.js.map} +1 -1
  18. package/dist/{chunk-7ioLE0kx.js → chunk-DcxOAiAp.js} +2 -2
  19. package/dist/{chunk-7ioLE0kx.js.map → chunk-DcxOAiAp.js.map} +1 -1
  20. package/dist/{chunk-DN9pYQV5.js → chunk-DqSrbxqC.js} +2 -2
  21. package/dist/{chunk-DN9pYQV5.js.map → chunk-DqSrbxqC.js.map} +1 -1
  22. package/dist/{chunk-Br5h7rjn.js → chunk-GA-wADEN.js} +3 -3
  23. package/dist/{chunk-Br5h7rjn.js.map → chunk-GA-wADEN.js.map} +1 -1
  24. package/dist/{chunk-DfH1lF5p.js → chunk-LtUevT4I.js} +2 -2
  25. package/dist/{chunk-DfH1lF5p.js.map → chunk-LtUevT4I.js.map} +1 -1
  26. package/dist/{chunk-sn8HEeT6.js → chunk-yBvbLjSM.js} +4 -4
  27. package/dist/{chunk-sn8HEeT6.js.map → chunk-yBvbLjSM.js.map} +1 -1
  28. package/dist/cjs/Editor.cjs.js +7 -7
  29. package/dist/cjs/EditorContent.cjs.js +4 -4
  30. package/dist/cjs/FormikEditor.cjs.js +7 -7
  31. package/dist/cjs/Menu.cjs.js +5 -5
  32. package/dist/cjs/{chunk-V1V-Gqfy.cjs.js → chunk-C-I6s_l9.cjs.js} +3 -3
  33. package/dist/cjs/{chunk-V1V-Gqfy.cjs.js.map → chunk-C-I6s_l9.cjs.js.map} +1 -1
  34. package/dist/cjs/{chunk-DRnP2LQe.cjs.js → chunk-CJIIbW7G.cjs.js} +2 -2
  35. package/dist/cjs/{chunk-DRnP2LQe.cjs.js.map → chunk-CJIIbW7G.cjs.js.map} +1 -1
  36. package/dist/cjs/{chunk-CQLQEN5P.cjs.js → chunk-CU6dMPZV.cjs.js} +2 -2
  37. package/dist/cjs/{chunk-CQLQEN5P.cjs.js.map → chunk-CU6dMPZV.cjs.js.map} +1 -1
  38. package/dist/cjs/{chunk-BPJBeVDI.cjs.js → chunk-C_XHzWXy.cjs.js} +2 -2
  39. package/dist/cjs/chunk-C_XHzWXy.cjs.js.map +1 -0
  40. package/dist/cjs/{chunk-bfmPXyQJ.cjs.js → chunk-CddQ0UHU.cjs.js} +3 -3
  41. package/dist/cjs/{chunk-bfmPXyQJ.cjs.js.map → chunk-CddQ0UHU.cjs.js.map} +1 -1
  42. package/dist/cjs/{chunk-78VpxO0R.cjs.js → chunk-CkSG3yNC.cjs.js} +4 -4
  43. package/dist/cjs/{chunk-78VpxO0R.cjs.js.map → chunk-CkSG3yNC.cjs.js.map} +1 -1
  44. package/dist/cjs/{chunk-CwY6UgZq.cjs.js → chunk-CxKWZyHq.cjs.js} +3 -3
  45. package/dist/cjs/{chunk-CwY6UgZq.cjs.js.map → chunk-CxKWZyHq.cjs.js.map} +1 -1
  46. package/dist/cjs/{chunk-j4T5BDua.cjs.js → chunk-Df33Mipq.cjs.js} +5 -5
  47. package/dist/cjs/{chunk-j4T5BDua.cjs.js.map → chunk-Df33Mipq.cjs.js.map} +1 -1
  48. package/dist/cjs/{chunk-bxP1kilM.cjs.js → chunk-Dwv-JqJN.cjs.js} +2 -2
  49. package/dist/cjs/{chunk-bxP1kilM.cjs.js.map → chunk-Dwv-JqJN.cjs.js.map} +1 -1
  50. package/dist/cjs/{chunk-CBswWnmM.cjs.js → chunk-Niprqtd_.cjs.js} +3 -3
  51. package/dist/cjs/{chunk-CBswWnmM.cjs.js.map → chunk-Niprqtd_.cjs.js.map} +1 -1
  52. package/dist/cjs/{chunk-QnVNXaqt.cjs.js → chunk-hjJXR4bM.cjs.js} +4 -4
  53. package/dist/cjs/{chunk-QnVNXaqt.cjs.js.map → chunk-hjJXR4bM.cjs.js.map} +1 -1
  54. package/dist/cjs/index.cjs.js +9 -9
  55. package/dist/cjs/utils.cjs.js +6 -6
  56. package/dist/cjs/v2/Editor.cjs.js +869 -233
  57. package/dist/cjs/v2/Editor.cjs.js.map +1 -1
  58. package/dist/cjs/v2/EditorContent.cjs.js +4 -4
  59. package/dist/cjs/v2/FormikEditor.cjs.js +6 -6
  60. package/dist/cjs/v2/Menu.cjs.js +4 -4
  61. package/dist/cjs/v2/index.cjs.js +8 -8
  62. package/dist/cjs/v2/utils.cjs.js +6 -6
  63. package/dist/editor-stats.html +19 -1
  64. package/dist/index.js +9 -9
  65. package/dist/utils.js +6 -6
  66. package/dist/v2/Editor.js +869 -233
  67. package/dist/v2/Editor.js.map +1 -1
  68. package/dist/v2/EditorContent.js +4 -4
  69. package/dist/v2/FormikEditor.js +6 -6
  70. package/dist/v2/Menu.js +4 -4
  71. package/dist/v2/editor-content-styles.js +1 -1
  72. package/dist/v2/editor-content.min.css +1 -1
  73. package/dist/v2/index.js +8 -8
  74. package/dist/v2/styles.css +1 -1
  75. package/dist/v2/styles.js +1 -1
  76. package/dist/v2/utils.js +6 -6
  77. package/package.json +4 -3
  78. package/dist/chunk-BpMZjml2.js.map +0 -1
  79. package/dist/cjs/chunk-BPJBeVDI.cjs.js.map +0 -1
@@ -6,22 +6,22 @@ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
6
6
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
7
7
  var React = require('react');
8
8
  var neetoAtoms = require('@bigbinary/neeto-atoms');
9
- var useEditorStore = require('../chunk-CwY6UgZq.cjs.js');
9
+ var useEditorStore = require('../chunk-CxKWZyHq.cjs.js');
10
10
  var classnames = require('classnames');
11
11
  var neetoCist = require('@bigbinary/neeto-cist');
12
12
  var reactUtils = require('@bigbinary/neeto-commons-frontend/v2/react-utils');
13
13
  var ReactDOM$1 = require('react-dom');
14
- var getVideoDimension = require('../chunk-j4T5BDua.cjs.js');
14
+ var getVideoDimension = require('../chunk-Df33Mipq.cjs.js');
15
15
  var constants = require('../chunk-BxKa_XOs.cjs.js');
16
- var markdown = require('../chunk-BPJBeVDI.cjs.js');
16
+ var markdown = require('../chunk-C_XHzWXy.cjs.js');
17
17
  require('../chunk-CQ-j2kAX.cjs.js');
18
18
  var ramda = require('ramda');
19
19
  var ReactDOM = require('react-dom/server');
20
- var common = require('../chunk-CQLQEN5P.cjs.js');
20
+ var common = require('../chunk-CU6dMPZV.cjs.js');
21
21
  var jsxRuntime = require('react/jsx-runtime');
22
- var v2_Menu = require('../chunk-QnVNXaqt.cjs.js');
22
+ var v2_Menu = require('../chunk-hjJXR4bM.cjs.js');
23
23
  var Megaphone = require('@bigbinary/neeto-icons/misc/Megaphone');
24
- var index = require('../chunk-DRnP2LQe.cjs.js');
24
+ var index = require('../chunk-CJIIbW7G.cjs.js');
25
25
  var lucideReact = require('lucide-react');
26
26
  var CopyToClipboardButton = require('@bigbinary/neeto-molecules/v2/CopyToClipboardButton');
27
27
  var reactI18next = require('react-i18next');
@@ -2419,237 +2419,565 @@ var SelectionDecoration = getVideoDimension.src_default$4.extend({
2419
2419
  }
2420
2420
  });
2421
2421
 
2422
- function ownKeys$b(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; }
2423
- function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), true).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2424
- function _callSuper$1(t, o, e) { return o = _getPrototypeOf__default.default(o), _possibleConstructorReturn__default.default(t, _isNativeReflectConstruct$1() ? Reflect.construct(o, e || [], _getPrototypeOf__default.default(t).constructor) : o.apply(t, e)); }
2425
- function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); }
2426
- var Menu = /*#__PURE__*/function (_React$Component) {
2427
- function Menu(props) {
2428
- var _this;
2429
- _classCallCheck__default.default(this, Menu);
2430
- _this = _callSuper$1(this, Menu, [props]);
2431
- _defineProperty__default.default(_this, "keydownHandler", function (event) {
2432
- var listeners = {
2433
- Enter: _this.enterHandler,
2434
- ArrowUp: _this.upHandler,
2435
- ArrowDown: _this.downHandler,
2436
- ArrowLeft: _this.leftArrowHandler,
2437
- ArrowRight: _this.rightArrowHandler
2438
- };
2439
- if (event.key in listeners) listeners[event.key](event);
2440
- });
2441
- _defineProperty__default.default(_this, "selectItem", function (index) {
2442
- var _this$props = _this.props,
2443
- items = _this$props.items,
2444
- editor = _this$props.editor,
2445
- range = _this$props.range;
2446
- var selectedItem = items[index];
2447
- var hasCommand = selectedItem && selectedItem.command;
2448
- if (hasCommand) selectedItem.command({
2449
- editor: editor,
2450
- range: range
2451
- });
2452
- });
2453
- _defineProperty__default.default(_this, "upHandler", function () {
2454
- var items = _this.props.items;
2455
- var selectedIndex = _this.state.selectedIndex;
2456
- _this.setState({
2457
- selectedIndex: (selectedIndex + items.length - 1) % items.length
2458
- });
2459
- });
2460
- _defineProperty__default.default(_this, "downHandler", function () {
2461
- var items = _this.props.items;
2462
- var selectedIndex = _this.state.selectedIndex;
2463
- _this.setState({
2464
- selectedIndex: (selectedIndex + 1) % items.length
2465
- });
2466
- });
2467
- _defineProperty__default.default(_this, "enterHandler", function () {
2468
- var selectedIndex = _this.state.selectedIndex;
2469
- _this.selectItem(selectedIndex);
2470
- });
2471
- _defineProperty__default.default(_this, "leftArrowHandler", function () {
2472
- var _this$props2 = _this.props,
2473
- menuIndex = _this$props2.menuIndex,
2474
- setActiveMenuIndex = _this$props2.setActiveMenuIndex;
2475
- if (menuIndex > 0) setActiveMenuIndex(menuIndex - 1);
2476
- });
2477
- _defineProperty__default.default(_this, "rightArrowHandler", function () {
2478
- var _this$props3 = _this.props,
2479
- menuIndex = _this$props3.menuIndex,
2480
- setActiveMenuIndex = _this$props3.setActiveMenuIndex,
2481
- items = _this$props3.items;
2482
- var selectedIndex = _this.state.selectedIndex;
2483
- var selectedItem = items[selectedIndex];
2484
- var hasSubItems = selectedItem && !neetoCist.isNotPresent(selectedItem.items);
2485
- if (hasSubItems) setActiveMenuIndex(menuIndex + 1);
2486
- });
2487
- _this.state = {
2488
- selectedIndex: 0
2489
- };
2490
- _this.menuRef = /*#__PURE__*/React__default.default.createRef();
2491
- return _this;
2422
+ var top = 'top';
2423
+ var bottom = 'bottom';
2424
+ var right = 'right';
2425
+ var left = 'left';
2426
+ var basePlacements = [top, bottom, right, left];
2427
+ var start = 'start';
2428
+ var end = 'end';
2429
+ var clippingParents = 'clippingParents';
2430
+ var viewport = 'viewport';
2431
+ var popper = 'popper';
2432
+ var reference = 'reference';
2433
+
2434
+ function getNodeName(element) {
2435
+ return element ? (element.nodeName || '').toLowerCase() : null;
2436
+ }
2437
+
2438
+ function getWindow(node) {
2439
+ if (node == null) {
2440
+ return window;
2492
2441
  }
2493
- _inherits__default.default(Menu, _React$Component);
2494
- return _createClass__default.default(Menu, [{
2495
- key: "componentDidMount",
2496
- value: function componentDidMount() {
2497
- var _this$props4 = this.props,
2498
- menuIndex = _this$props4.menuIndex,
2499
- activeMenuIndex = _this$props4.activeMenuIndex;
2500
- var isCurrentMenuActive = menuIndex === activeMenuIndex;
2501
- if (isCurrentMenuActive) {
2502
- document.addEventListener("keydown", this.keydownHandler);
2503
- }
2504
- }
2505
- }, {
2506
- key: "componentWillUnmount",
2507
- value: function componentWillUnmount() {
2508
- document.removeEventListener("keydown", this.keydownHandler);
2442
+
2443
+ if (node.toString() !== '[object Window]') {
2444
+ var ownerDocument = node.ownerDocument;
2445
+ return ownerDocument ? ownerDocument.defaultView || window : window;
2446
+ }
2447
+
2448
+ return node;
2449
+ }
2450
+
2451
+ function isElement(node) {
2452
+ var OwnElement = getWindow(node).Element;
2453
+ return node instanceof OwnElement || node instanceof Element;
2454
+ }
2455
+
2456
+ function isHTMLElement(node) {
2457
+ var OwnElement = getWindow(node).HTMLElement;
2458
+ return node instanceof OwnElement || node instanceof HTMLElement;
2459
+ }
2460
+
2461
+ function isShadowRoot(node) {
2462
+ // IE 11 has no ShadowRoot
2463
+ if (typeof ShadowRoot === 'undefined') {
2464
+ return false;
2465
+ }
2466
+
2467
+ var OwnElement = getWindow(node).ShadowRoot;
2468
+ return node instanceof OwnElement || node instanceof ShadowRoot;
2469
+ }
2470
+
2471
+ function getBasePlacement(placement) {
2472
+ return placement.split('-')[0];
2473
+ }
2474
+
2475
+ var max = Math.max;
2476
+ var min = Math.min;
2477
+ var round = Math.round;
2478
+
2479
+ function getUAString() {
2480
+ var uaData = navigator.userAgentData;
2481
+
2482
+ if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
2483
+ return uaData.brands.map(function (item) {
2484
+ return item.brand + "/" + item.version;
2485
+ }).join(' ');
2486
+ }
2487
+
2488
+ return navigator.userAgent;
2489
+ }
2490
+
2491
+ function isLayoutViewport() {
2492
+ return !/^((?!chrome|android).)*safari/i.test(getUAString());
2493
+ }
2494
+
2495
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
2496
+ if (includeScale === void 0) {
2497
+ includeScale = false;
2498
+ }
2499
+
2500
+ if (isFixedStrategy === void 0) {
2501
+ isFixedStrategy = false;
2502
+ }
2503
+
2504
+ var clientRect = element.getBoundingClientRect();
2505
+ var scaleX = 1;
2506
+ var scaleY = 1;
2507
+
2508
+ if (includeScale && isHTMLElement(element)) {
2509
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
2510
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
2511
+ }
2512
+
2513
+ var _ref = isElement(element) ? getWindow(element) : window,
2514
+ visualViewport = _ref.visualViewport;
2515
+
2516
+ var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
2517
+ var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
2518
+ var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
2519
+ var width = clientRect.width / scaleX;
2520
+ var height = clientRect.height / scaleY;
2521
+ return {
2522
+ width: width,
2523
+ height: height,
2524
+ top: y,
2525
+ right: x + width,
2526
+ bottom: y + height,
2527
+ left: x,
2528
+ x: x,
2529
+ y: y
2530
+ };
2531
+ }
2532
+
2533
+ function contains(parent, child) {
2534
+ var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
2535
+
2536
+ if (parent.contains(child)) {
2537
+ return true;
2538
+ } // then fallback to custom implementation with Shadow DOM support
2539
+ else if (rootNode && isShadowRoot(rootNode)) {
2540
+ var next = child;
2541
+
2542
+ do {
2543
+ if (next && parent.isSameNode(next)) {
2544
+ return true;
2545
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
2546
+
2547
+
2548
+ next = next.parentNode || next.host;
2549
+ } while (next);
2550
+ } // Give up, the result is false
2551
+
2552
+
2553
+ return false;
2554
+ }
2555
+
2556
+ function getComputedStyle(element) {
2557
+ return getWindow(element).getComputedStyle(element);
2558
+ }
2559
+
2560
+ function isTableElement(element) {
2561
+ return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
2562
+ }
2563
+
2564
+ function getDocumentElement(element) {
2565
+ // $FlowFixMe[incompatible-return]: assume body is always available
2566
+ return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
2567
+ element.document) || window.document).documentElement;
2568
+ }
2569
+
2570
+ function getParentNode(element) {
2571
+ if (getNodeName(element) === 'html') {
2572
+ return element;
2573
+ }
2574
+
2575
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
2576
+ // $FlowFixMe[incompatible-return]
2577
+ // $FlowFixMe[prop-missing]
2578
+ element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
2579
+ element.parentNode || ( // DOM Element detected
2580
+ isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
2581
+ // $FlowFixMe[incompatible-call]: HTMLElement is a Node
2582
+ getDocumentElement(element) // fallback
2583
+
2584
+ );
2585
+ }
2586
+
2587
+ function getTrueOffsetParent(element) {
2588
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
2589
+ getComputedStyle(element).position === 'fixed') {
2590
+ return null;
2591
+ }
2592
+
2593
+ return element.offsetParent;
2594
+ } // `.offsetParent` reports `null` for fixed elements, while absolute elements
2595
+ // return the containing block
2596
+
2597
+
2598
+ function getContainingBlock(element) {
2599
+ var isFirefox = /firefox/i.test(getUAString());
2600
+ var isIE = /Trident/i.test(getUAString());
2601
+
2602
+ if (isIE && isHTMLElement(element)) {
2603
+ // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
2604
+ var elementCss = getComputedStyle(element);
2605
+
2606
+ if (elementCss.position === 'fixed') {
2607
+ return null;
2509
2608
  }
2510
- }, {
2511
- key: "componentDidUpdate",
2512
- value: function componentDidUpdate(oldProps) {
2513
- var _this$props5 = this.props,
2514
- items = _this$props5.items,
2515
- menuIndex = _this$props5.menuIndex,
2516
- activeMenuIndex = _this$props5.activeMenuIndex;
2517
- var isCurrentMenuActive = menuIndex === activeMenuIndex;
2518
- if (items !== oldProps.items) this.setState({
2519
- selectedIndex: 0
2520
- });
2521
- getVideoDimension.scrollHandler({
2522
- wrapperRef: this.menuRef,
2523
- index: this.state.selectedIndex
2524
- });
2525
- if (isCurrentMenuActive) {
2526
- document.addEventListener("keydown", this.keydownHandler);
2527
- } else document.removeEventListener("keydown", this.keydownHandler);
2609
+ }
2610
+
2611
+ var currentNode = getParentNode(element);
2612
+
2613
+ if (isShadowRoot(currentNode)) {
2614
+ currentNode = currentNode.host;
2615
+ }
2616
+
2617
+ while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
2618
+ var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
2619
+ // create a containing block.
2620
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2621
+
2622
+ if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
2623
+ return currentNode;
2624
+ } else {
2625
+ currentNode = currentNode.parentNode;
2528
2626
  }
2529
- }, {
2530
- key: "render",
2531
- value: function render() {
2532
- var _this2 = this;
2533
- var _this$props6 = this.props,
2534
- items = _this$props6.items,
2535
- menuIndex = _this$props6.menuIndex,
2536
- activeMenuIndex = _this$props6.activeMenuIndex;
2537
- var selectedIndex = this.state.selectedIndex;
2538
- var isCurrentMenuActive = menuIndex === activeMenuIndex;
2539
- return /*#__PURE__*/jsxRuntime.jsx("div", {
2540
- className: "neeto-editor-slash-commands__wrapper",
2541
- "data-testid": "neeto-editor-slash-commands-wrapper",
2542
- ref: this.menuRef,
2543
- children: items.map(function (item, index) {
2544
- var isLeafNode = neetoCist.isNotPresent(item.items);
2545
- var nodeElement = /*#__PURE__*/React.createElement(MenuItem, {
2546
- index: index,
2547
- item: item,
2548
- key: item.optionName,
2549
- selectItem: function selectItem() {
2550
- return _this2.selectItem(index);
2551
- },
2552
- selectedIndex: isCurrentMenuActive ? selectedIndex : -1,
2553
- onHover: function onHover() {
2554
- return _this2.setState({
2555
- selectedIndex: index
2556
- });
2557
- }
2558
- });
2559
- if (isLeafNode) return nodeElement;
2560
- return /*#__PURE__*/jsxRuntime.jsx(Tippy__default.default, {
2561
- interactive: true,
2562
- placement: "right",
2563
- theme: "light neeto-editor-slash-commands-tippy",
2564
- visible: selectedIndex === index,
2565
- content: /*#__PURE__*/jsxRuntime.jsx(Menu, _objectSpread$b(_objectSpread$b({}, _this2.props), {}, {
2566
- items: item.items,
2567
- menuIndex: menuIndex + 1
2568
- })),
2569
- onCreate: function onCreate(_ref) {
2570
- var popper = _ref.popper;
2571
- return popper.style.width = "max-content";
2572
- },
2573
- onHide: function onHide() {
2574
- _this2.isSubmenuOpened = false;
2575
- },
2576
- onShow: function onShow() {
2577
- _this2.isSubmenuOpened = true;
2578
- },
2579
- children: nodeElement
2580
- }, item.optionName);
2581
- })
2582
- });
2627
+ }
2628
+
2629
+ return null;
2630
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
2631
+ // such as table ancestors and cross browser bugs.
2632
+
2633
+
2634
+ function getOffsetParent(element) {
2635
+ var window = getWindow(element);
2636
+ var offsetParent = getTrueOffsetParent(element);
2637
+
2638
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
2639
+ offsetParent = getTrueOffsetParent(offsetParent);
2640
+ }
2641
+
2642
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
2643
+ return window;
2644
+ }
2645
+
2646
+ return offsetParent || getContainingBlock(element) || window;
2647
+ }
2648
+
2649
+ function getMainAxisFromPlacement(placement) {
2650
+ return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
2651
+ }
2652
+
2653
+ function getFreshSideObject() {
2654
+ return {
2655
+ top: 0,
2656
+ right: 0,
2657
+ bottom: 0,
2658
+ left: 0
2659
+ };
2660
+ }
2661
+
2662
+ function mergePaddingObject(paddingObject) {
2663
+ return Object.assign({}, getFreshSideObject(), paddingObject);
2664
+ }
2665
+
2666
+ function expandToHashMap(value, keys) {
2667
+ return keys.reduce(function (hashMap, key) {
2668
+ hashMap[key] = value;
2669
+ return hashMap;
2670
+ }, {});
2671
+ }
2672
+
2673
+ function getVariation(placement) {
2674
+ return placement.split('-')[1];
2675
+ }
2676
+
2677
+ function getWindowScroll(node) {
2678
+ var win = getWindow(node);
2679
+ var scrollLeft = win.pageXOffset;
2680
+ var scrollTop = win.pageYOffset;
2681
+ return {
2682
+ scrollLeft: scrollLeft,
2683
+ scrollTop: scrollTop
2684
+ };
2685
+ }
2686
+
2687
+ function getWindowScrollBarX(element) {
2688
+ // If <html> has a CSS width greater than the viewport, then this will be
2689
+ // incorrect for RTL.
2690
+ // Popper 1 is broken in this case and never had a bug report so let's assume
2691
+ // it's not an issue. I don't think anyone ever specifies width on <html>
2692
+ // anyway.
2693
+ // Browsers where the left scrollbar doesn't cause an issue report `0` for
2694
+ // this (e.g. Edge 2019, IE11, Safari)
2695
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
2696
+ }
2697
+
2698
+ function getViewportRect(element, strategy) {
2699
+ var win = getWindow(element);
2700
+ var html = getDocumentElement(element);
2701
+ var visualViewport = win.visualViewport;
2702
+ var width = html.clientWidth;
2703
+ var height = html.clientHeight;
2704
+ var x = 0;
2705
+ var y = 0;
2706
+
2707
+ if (visualViewport) {
2708
+ width = visualViewport.width;
2709
+ height = visualViewport.height;
2710
+ var layoutViewport = isLayoutViewport();
2711
+
2712
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
2713
+ x = visualViewport.offsetLeft;
2714
+ y = visualViewport.offsetTop;
2583
2715
  }
2584
- }]);
2585
- }(React__default.default.Component); // eslint-disable-next-line react/display-name
2586
- var MenuItem = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
2587
- var item = _ref2.item,
2588
- selectedIndex = _ref2.selectedIndex,
2589
- index = _ref2.index,
2590
- selectItem = _ref2.selectItem,
2591
- onHover = _ref2.onHover;
2592
- var Icon = item.Icon;
2593
- return /*#__PURE__*/jsxRuntime.jsxs("button", {
2594
- ref: ref,
2595
- "data-testid": "neeto-editor-command-list-item-".concat(index),
2596
- className: classnames__default.default("neeto-editor-slash-commands__item", {
2597
- active: index === selectedIndex
2598
- }),
2599
- onClick: selectItem,
2600
- onMouseEnter: onHover,
2601
- children: [Icon && /*#__PURE__*/jsxRuntime.jsx(Icon, {
2602
- size: 20
2603
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
2604
- className: "neeto-editor-slash-commands__item-content",
2605
- children: /*#__PURE__*/jsxRuntime.jsx("span", {
2606
- className: "neeto-editor-slash-commands__item-title",
2607
- "data-testid": "neeto-editor-command-list-item-block-heading",
2608
- children: item.title
2609
- })
2610
- })]
2716
+ }
2717
+
2718
+ return {
2719
+ width: width,
2720
+ height: height,
2721
+ x: x + getWindowScrollBarX(element),
2722
+ y: y
2723
+ };
2724
+ }
2725
+
2726
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
2727
+
2728
+ function getDocumentRect(element) {
2729
+ var _element$ownerDocumen;
2730
+
2731
+ var html = getDocumentElement(element);
2732
+ var winScroll = getWindowScroll(element);
2733
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
2734
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
2735
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
2736
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
2737
+ var y = -winScroll.scrollTop;
2738
+
2739
+ if (getComputedStyle(body || html).direction === 'rtl') {
2740
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
2741
+ }
2742
+
2743
+ return {
2744
+ width: width,
2745
+ height: height,
2746
+ x: x,
2747
+ y: y
2748
+ };
2749
+ }
2750
+
2751
+ function isScrollParent(element) {
2752
+ // Firefox wants us to check `-x` and `-y` variations as well
2753
+ var _getComputedStyle = getComputedStyle(element),
2754
+ overflow = _getComputedStyle.overflow,
2755
+ overflowX = _getComputedStyle.overflowX,
2756
+ overflowY = _getComputedStyle.overflowY;
2757
+
2758
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
2759
+ }
2760
+
2761
+ function getScrollParent(node) {
2762
+ if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
2763
+ // $FlowFixMe[incompatible-return]: assume body is always available
2764
+ return node.ownerDocument.body;
2765
+ }
2766
+
2767
+ if (isHTMLElement(node) && isScrollParent(node)) {
2768
+ return node;
2769
+ }
2770
+
2771
+ return getScrollParent(getParentNode(node));
2772
+ }
2773
+
2774
+ /*
2775
+ given a DOM element, return the list of all scroll parents, up the list of ancesors
2776
+ until we get to the top window object. This list is what we attach scroll listeners
2777
+ to, because if any of these parent elements scroll, we'll need to re-calculate the
2778
+ reference element's position.
2779
+ */
2780
+
2781
+ function listScrollParents(element, list) {
2782
+ var _element$ownerDocumen;
2783
+
2784
+ if (list === void 0) {
2785
+ list = [];
2786
+ }
2787
+
2788
+ var scrollParent = getScrollParent(element);
2789
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
2790
+ var win = getWindow(scrollParent);
2791
+ var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
2792
+ var updatedList = list.concat(target);
2793
+ return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
2794
+ updatedList.concat(listScrollParents(getParentNode(target)));
2795
+ }
2796
+
2797
+ function rectToClientRect(rect) {
2798
+ return Object.assign({}, rect, {
2799
+ left: rect.x,
2800
+ top: rect.y,
2801
+ right: rect.x + rect.width,
2802
+ bottom: rect.y + rect.height
2611
2803
  });
2612
- });
2804
+ }
2613
2805
 
2614
- function ownKeys$a(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; }
2615
- function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2616
- function _callSuper(t, o, e) { return o = _getPrototypeOf__default.default(o), _possibleConstructorReturn__default.default(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf__default.default(t).constructor) : o.apply(t, e)); }
2617
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2618
- var CommandsList = /*#__PURE__*/function (_React$Component) {
2619
- function CommandsList() {
2620
- var _this;
2621
- _classCallCheck__default.default(this, CommandsList);
2622
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2623
- args[_key] = arguments[_key];
2624
- }
2625
- _this = _callSuper(this, CommandsList, [].concat(args));
2626
- _defineProperty__default.default(_this, "state", {
2627
- activeMenuIndex: 0
2628
- });
2629
- _defineProperty__default.default(_this, "onKeyDown", function (_ref) {
2630
- var event = _ref.event;
2631
- return ["Enter", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(event.key);
2632
- });
2633
- _defineProperty__default.default(_this, "setActiveMenuIndex", function (index) {
2634
- return _this.setState({
2635
- activeMenuIndex: index
2636
- });
2637
- });
2638
- return _this;
2806
+ function getInnerBoundingClientRect(element, strategy) {
2807
+ var rect = getBoundingClientRect(element, false, strategy === 'fixed');
2808
+ rect.top = rect.top + element.clientTop;
2809
+ rect.left = rect.left + element.clientLeft;
2810
+ rect.bottom = rect.top + element.clientHeight;
2811
+ rect.right = rect.left + element.clientWidth;
2812
+ rect.width = element.clientWidth;
2813
+ rect.height = element.clientHeight;
2814
+ rect.x = rect.left;
2815
+ rect.y = rect.top;
2816
+ return rect;
2817
+ }
2818
+
2819
+ function getClientRectFromMixedType(element, clippingParent, strategy) {
2820
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2821
+ } // A "clipping parent" is an overflowable container with the characteristic of
2822
+ // clipping (or hiding) overflowing elements with a position different from
2823
+ // `initial`
2824
+
2825
+
2826
+ function getClippingParents(element) {
2827
+ var clippingParents = listScrollParents(getParentNode(element));
2828
+ var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
2829
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
2830
+
2831
+ if (!isElement(clipperElement)) {
2832
+ return [];
2833
+ } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
2834
+
2835
+
2836
+ return clippingParents.filter(function (clippingParent) {
2837
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
2838
+ });
2839
+ } // Gets the maximum area that the element is visible in due to any number of
2840
+ // clipping parents
2841
+
2842
+
2843
+ function getClippingRect(element, boundary, rootBoundary, strategy) {
2844
+ var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
2845
+ var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
2846
+ var firstClippingParent = clippingParents[0];
2847
+ var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
2848
+ var rect = getClientRectFromMixedType(element, clippingParent, strategy);
2849
+ accRect.top = max(rect.top, accRect.top);
2850
+ accRect.right = min(rect.right, accRect.right);
2851
+ accRect.bottom = min(rect.bottom, accRect.bottom);
2852
+ accRect.left = max(rect.left, accRect.left);
2853
+ return accRect;
2854
+ }, getClientRectFromMixedType(element, firstClippingParent, strategy));
2855
+ clippingRect.width = clippingRect.right - clippingRect.left;
2856
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
2857
+ clippingRect.x = clippingRect.left;
2858
+ clippingRect.y = clippingRect.top;
2859
+ return clippingRect;
2860
+ }
2861
+
2862
+ function computeOffsets(_ref) {
2863
+ var reference = _ref.reference,
2864
+ element = _ref.element,
2865
+ placement = _ref.placement;
2866
+ var basePlacement = placement ? getBasePlacement(placement) : null;
2867
+ var variation = placement ? getVariation(placement) : null;
2868
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
2869
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
2870
+ var offsets;
2871
+
2872
+ switch (basePlacement) {
2873
+ case top:
2874
+ offsets = {
2875
+ x: commonX,
2876
+ y: reference.y - element.height
2877
+ };
2878
+ break;
2879
+
2880
+ case bottom:
2881
+ offsets = {
2882
+ x: commonX,
2883
+ y: reference.y + reference.height
2884
+ };
2885
+ break;
2886
+
2887
+ case right:
2888
+ offsets = {
2889
+ x: reference.x + reference.width,
2890
+ y: commonY
2891
+ };
2892
+ break;
2893
+
2894
+ case left:
2895
+ offsets = {
2896
+ x: reference.x - element.width,
2897
+ y: commonY
2898
+ };
2899
+ break;
2900
+
2901
+ default:
2902
+ offsets = {
2903
+ x: reference.x,
2904
+ y: reference.y
2905
+ };
2639
2906
  }
2640
- _inherits__default.default(CommandsList, _React$Component);
2641
- return _createClass__default.default(CommandsList, [{
2642
- key: "render",
2643
- value: function render() {
2644
- return /*#__PURE__*/jsxRuntime.jsx(Menu, _objectSpread$a(_objectSpread$a({}, this.props), {}, {
2645
- activeMenuIndex: this.state.activeMenuIndex,
2646
- items: this.props.items,
2647
- menuIndex: 0,
2648
- setActiveMenuIndex: this.setActiveMenuIndex
2649
- }));
2907
+
2908
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
2909
+
2910
+ if (mainAxis != null) {
2911
+ var len = mainAxis === 'y' ? 'height' : 'width';
2912
+
2913
+ switch (variation) {
2914
+ case start:
2915
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
2916
+ break;
2917
+
2918
+ case end:
2919
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
2920
+ break;
2650
2921
  }
2651
- }]);
2652
- }(React__default.default.Component);
2922
+ }
2923
+
2924
+ return offsets;
2925
+ }
2926
+
2927
+ function detectOverflow(state, options) {
2928
+ if (options === void 0) {
2929
+ options = {};
2930
+ }
2931
+
2932
+ var _options = options,
2933
+ _options$placement = _options.placement,
2934
+ placement = _options$placement === void 0 ? state.placement : _options$placement,
2935
+ _options$strategy = _options.strategy,
2936
+ strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
2937
+ _options$boundary = _options.boundary,
2938
+ boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
2939
+ _options$rootBoundary = _options.rootBoundary,
2940
+ rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
2941
+ _options$elementConte = _options.elementContext,
2942
+ elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
2943
+ _options$altBoundary = _options.altBoundary,
2944
+ altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
2945
+ _options$padding = _options.padding,
2946
+ padding = _options$padding === void 0 ? 0 : _options$padding;
2947
+ var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
2948
+ var altContext = elementContext === popper ? reference : popper;
2949
+ var popperRect = state.rects.popper;
2950
+ var element = state.elements[altBoundary ? altContext : elementContext];
2951
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
2952
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
2953
+ var popperOffsets = computeOffsets({
2954
+ reference: referenceClientRect,
2955
+ element: popperRect,
2956
+ placement: placement
2957
+ });
2958
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
2959
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
2960
+ // 0 or negative = within the clipping rect
2961
+
2962
+ var overflowOffsets = {
2963
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
2964
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
2965
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
2966
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
2967
+ };
2968
+ var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
2969
+
2970
+ if (elementContext === popper && offsetData) {
2971
+ var offset = offsetData[placement];
2972
+ Object.keys(overflowOffsets).forEach(function (key) {
2973
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
2974
+ var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
2975
+ overflowOffsets[key] += offset[axis] * multiply;
2976
+ });
2977
+ }
2978
+
2979
+ return overflowOffsets;
2980
+ }
2653
2981
 
2654
2982
  var MENU_ITEMS = [{
2655
2983
  optionName: constants.EDITOR_OPTIONS.PARAGRAPH,
@@ -2952,9 +3280,12 @@ var NO_RESULT_MENU_ITEM = {
2952
3280
  editor.chain().focus().deleteRange(range).run();
2953
3281
  }
2954
3282
  };
3283
+ var MENU_MAX_HEIGHT = 384;
3284
+ var MENU_BOUNDARY_PADDING = 8;
3285
+ var MENU_MAX_HEIGHT_CSS_VARIABLE = "--neeto-editor-slash-commands-max-height";
2955
3286
 
2956
- function ownKeys$9(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; }
2957
- function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), true).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3287
+ function ownKeys$b(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; }
3288
+ function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), true).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2958
3289
  var imageCommand = function imageCommand(setMediaUploader) {
2959
3290
  return function (_ref) {
2960
3291
  var editor = _ref.editor,
@@ -3002,6 +3333,15 @@ var neetoKbArticleCommand = function neetoKbArticleCommand(setIsNeetoKbArticleAc
3002
3333
  editor.chain().focus().deleteRange(range).run();
3003
3334
  };
3004
3335
  };
3336
+ var getOppositePlacement = function getOppositePlacement(placement) {
3337
+ return placement.replace(/^(top|bottom)/, function (side) {
3338
+ return side === "top" ? "bottom" : "top";
3339
+ });
3340
+ };
3341
+ var getOffsetDistance = function getOffsetDistance(state, placement) {
3342
+ var _state$modifiersData$, _state$modifiersData$2;
3343
+ return Math.abs((_state$modifiersData$ = (_state$modifiersData$2 = state.modifiersData.offset) === null || _state$modifiersData$2 === void 0 || (_state$modifiersData$2 = _state$modifiersData$2[placement]) === null || _state$modifiersData$2 === void 0 ? void 0 : _state$modifiersData$2.y) !== null && _state$modifiersData$ !== void 0 ? _state$modifiersData$ : 0);
3344
+ };
3005
3345
  var buildCommandItems = function buildCommandItems(_ref6) {
3006
3346
  var options = _ref6.options,
3007
3347
  addonCommands = _ref6.addonCommands,
@@ -3028,7 +3368,7 @@ var buildCommandItems = function buildCommandItems(_ref6) {
3028
3368
  return options.includes(optionName);
3029
3369
  });
3030
3370
  var adddonCommandItems = addonCommands.map(function (command) {
3031
- return _objectSpread$9(_objectSpread$9({}, command), {}, {
3371
+ return _objectSpread$b(_objectSpread$b({}, command), {}, {
3032
3372
  title: command.label,
3033
3373
  Icon: command.icon
3034
3374
  });
@@ -3036,6 +3376,296 @@ var buildCommandItems = function buildCommandItems(_ref6) {
3036
3376
  return [].concat(_toConsumableArray__default.default(permittedCommandItems), _toConsumableArray__default.default(adddonCommandItems));
3037
3377
  };
3038
3378
 
3379
+ // Replaces Popper's flip for the slash commands menu. When the menu fits on
3380
+ // neither side, flip keeps the preferred side and lets the menu overflow, so on
3381
+ // short screens it gets cut off. Here we pick the side with more room instead
3382
+ // and cap the menu's height to the space available on that side.
3383
+ var fitToAvailableHeight = {
3384
+ name: "fitToAvailableHeight",
3385
+ enabled: true,
3386
+ phase: "main",
3387
+ requiresIfExists: ["offset"],
3388
+ fn: function fn(_ref8) {
3389
+ var state = _ref8.state,
3390
+ name = _ref8.name;
3391
+ if (state.modifiersData[name]._skip) return;
3392
+ var menu = state.elements.popper.querySelector(".neeto-editor-slash-commands__wrapper");
3393
+ if (!menu) return;
3394
+ var _detectOverflow = detectOverflow(state, {
3395
+ elementContext: "reference",
3396
+ altBoundary: true,
3397
+ padding: MENU_BOUNDARY_PADDING
3398
+ }),
3399
+ top = _detectOverflow.top,
3400
+ bottom = _detectOverflow.bottom;
3401
+ var isVertical = /^(top|bottom)/.test(state.placement);
3402
+ var menuChromeHeight = state.rects.popper.height - menu.offsetHeight;
3403
+ var menuContentHeight = Math.min(menu.scrollHeight, MENU_MAX_HEIGHT);
3404
+ var placement = state.placement;
3405
+ var availableHeight = state.rects.reference.height - top - bottom;
3406
+ if (isVertical) {
3407
+ var preferredPlacement = state.options.placement;
3408
+ var oppositePlacement = getOppositePlacement(preferredPlacement);
3409
+ var getSpace = function getSpace(candidatePlacement) {
3410
+ return (candidatePlacement.startsWith("top") ? -top : -bottom) - getOffsetDistance(state, candidatePlacement);
3411
+ };
3412
+ var preferredSpace = getSpace(preferredPlacement);
3413
+ var oppositeSpace = getSpace(oppositePlacement);
3414
+ var menuHeight = menuChromeHeight + menuContentHeight;
3415
+ var shouldUseOpposite = menuHeight > preferredSpace && (menuHeight <= oppositeSpace || oppositeSpace > preferredSpace);
3416
+ placement = shouldUseOpposite ? oppositePlacement : preferredPlacement;
3417
+ availableHeight = shouldUseOpposite ? oppositeSpace : preferredSpace;
3418
+ }
3419
+ var menuMaxHeight = Math.max(Math.floor(availableHeight - menuChromeHeight), 0);
3420
+ state.elements.popper.style.setProperty(MENU_MAX_HEIGHT_CSS_VARIABLE, "".concat(menuMaxHeight, "px"));
3421
+ var popperHeight = menuChromeHeight + Math.min(menuContentHeight, menuMaxHeight);
3422
+ if (placement === state.placement && popperHeight === state.rects.popper.height) {
3423
+ return;
3424
+ }
3425
+ state.modifiersData[name]._skip = true;
3426
+ state.placement = placement;
3427
+ state.rects.popper = _objectSpread$b(_objectSpread$b({}, state.rects.popper), {}, {
3428
+ height: popperHeight
3429
+ });
3430
+ state.reset = true;
3431
+ }
3432
+ };
3433
+
3434
+ function ownKeys$a(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; }
3435
+ function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3436
+ function _callSuper$1(t, o, e) { return o = _getPrototypeOf__default.default(o), _possibleConstructorReturn__default.default(t, _isNativeReflectConstruct$1() ? Reflect.construct(o, e || [], _getPrototypeOf__default.default(t).constructor) : o.apply(t, e)); }
3437
+ function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); }
3438
+ var Menu = /*#__PURE__*/function (_React$Component) {
3439
+ function Menu(props) {
3440
+ var _this;
3441
+ _classCallCheck__default.default(this, Menu);
3442
+ _this = _callSuper$1(this, Menu, [props]);
3443
+ _defineProperty__default.default(_this, "keydownHandler", function (event) {
3444
+ var listeners = {
3445
+ Enter: _this.enterHandler,
3446
+ ArrowUp: _this.upHandler,
3447
+ ArrowDown: _this.downHandler,
3448
+ ArrowLeft: _this.leftArrowHandler,
3449
+ ArrowRight: _this.rightArrowHandler
3450
+ };
3451
+ if (event.key in listeners) listeners[event.key](event);
3452
+ });
3453
+ _defineProperty__default.default(_this, "selectItem", function (index) {
3454
+ var _this$props = _this.props,
3455
+ items = _this$props.items,
3456
+ editor = _this$props.editor,
3457
+ range = _this$props.range;
3458
+ var selectedItem = items[index];
3459
+ var hasCommand = selectedItem && selectedItem.command;
3460
+ if (hasCommand) selectedItem.command({
3461
+ editor: editor,
3462
+ range: range
3463
+ });
3464
+ });
3465
+ _defineProperty__default.default(_this, "upHandler", function () {
3466
+ var items = _this.props.items;
3467
+ var selectedIndex = _this.state.selectedIndex;
3468
+ _this.setState({
3469
+ selectedIndex: (selectedIndex + items.length - 1) % items.length
3470
+ });
3471
+ });
3472
+ _defineProperty__default.default(_this, "downHandler", function () {
3473
+ var items = _this.props.items;
3474
+ var selectedIndex = _this.state.selectedIndex;
3475
+ _this.setState({
3476
+ selectedIndex: (selectedIndex + 1) % items.length
3477
+ });
3478
+ });
3479
+ _defineProperty__default.default(_this, "enterHandler", function () {
3480
+ var selectedIndex = _this.state.selectedIndex;
3481
+ _this.selectItem(selectedIndex);
3482
+ });
3483
+ _defineProperty__default.default(_this, "leftArrowHandler", function () {
3484
+ var _this$props2 = _this.props,
3485
+ menuIndex = _this$props2.menuIndex,
3486
+ setActiveMenuIndex = _this$props2.setActiveMenuIndex;
3487
+ if (menuIndex > 0) setActiveMenuIndex(menuIndex - 1);
3488
+ });
3489
+ _defineProperty__default.default(_this, "rightArrowHandler", function () {
3490
+ var _this$props3 = _this.props,
3491
+ menuIndex = _this$props3.menuIndex,
3492
+ setActiveMenuIndex = _this$props3.setActiveMenuIndex,
3493
+ items = _this$props3.items;
3494
+ var selectedIndex = _this.state.selectedIndex;
3495
+ var selectedItem = items[selectedIndex];
3496
+ var hasSubItems = selectedItem && !neetoCist.isNotPresent(selectedItem.items);
3497
+ if (hasSubItems) setActiveMenuIndex(menuIndex + 1);
3498
+ });
3499
+ _this.state = {
3500
+ selectedIndex: 0
3501
+ };
3502
+ _this.menuRef = /*#__PURE__*/React__default.default.createRef();
3503
+ return _this;
3504
+ }
3505
+ _inherits__default.default(Menu, _React$Component);
3506
+ return _createClass__default.default(Menu, [{
3507
+ key: "componentDidMount",
3508
+ value: function componentDidMount() {
3509
+ var _this$props4 = this.props,
3510
+ menuIndex = _this$props4.menuIndex,
3511
+ activeMenuIndex = _this$props4.activeMenuIndex;
3512
+ var isCurrentMenuActive = menuIndex === activeMenuIndex;
3513
+ if (isCurrentMenuActive) {
3514
+ document.addEventListener("keydown", this.keydownHandler);
3515
+ }
3516
+ }
3517
+ }, {
3518
+ key: "componentWillUnmount",
3519
+ value: function componentWillUnmount() {
3520
+ document.removeEventListener("keydown", this.keydownHandler);
3521
+ }
3522
+ }, {
3523
+ key: "componentDidUpdate",
3524
+ value: function componentDidUpdate(oldProps) {
3525
+ var _this$props5 = this.props,
3526
+ items = _this$props5.items,
3527
+ menuIndex = _this$props5.menuIndex,
3528
+ activeMenuIndex = _this$props5.activeMenuIndex;
3529
+ var isCurrentMenuActive = menuIndex === activeMenuIndex;
3530
+ if (items !== oldProps.items) this.setState({
3531
+ selectedIndex: 0
3532
+ });
3533
+ getVideoDimension.scrollHandler({
3534
+ wrapperRef: this.menuRef,
3535
+ index: this.state.selectedIndex
3536
+ });
3537
+ if (isCurrentMenuActive) {
3538
+ document.addEventListener("keydown", this.keydownHandler);
3539
+ } else document.removeEventListener("keydown", this.keydownHandler);
3540
+ }
3541
+ }, {
3542
+ key: "render",
3543
+ value: function render() {
3544
+ var _this2 = this;
3545
+ var _this$props6 = this.props,
3546
+ items = _this$props6.items,
3547
+ menuIndex = _this$props6.menuIndex,
3548
+ activeMenuIndex = _this$props6.activeMenuIndex;
3549
+ var selectedIndex = this.state.selectedIndex;
3550
+ var isCurrentMenuActive = menuIndex === activeMenuIndex;
3551
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
3552
+ className: "neeto-editor-slash-commands__wrapper",
3553
+ "data-testid": "neeto-editor-slash-commands-wrapper",
3554
+ ref: this.menuRef,
3555
+ children: items.map(function (item, index) {
3556
+ var isLeafNode = neetoCist.isNotPresent(item.items);
3557
+ var nodeElement = /*#__PURE__*/React.createElement(MenuItem, {
3558
+ index: index,
3559
+ item: item,
3560
+ key: item.optionName,
3561
+ selectItem: function selectItem() {
3562
+ return _this2.selectItem(index);
3563
+ },
3564
+ selectedIndex: isCurrentMenuActive ? selectedIndex : -1,
3565
+ onHover: function onHover() {
3566
+ return _this2.setState({
3567
+ selectedIndex: index
3568
+ });
3569
+ }
3570
+ });
3571
+ if (isLeafNode) return nodeElement;
3572
+ return /*#__PURE__*/jsxRuntime.jsx(Tippy__default.default, {
3573
+ interactive: true,
3574
+ placement: "right",
3575
+ popperOptions: {
3576
+ modifiers: [fitToAvailableHeight]
3577
+ },
3578
+ theme: "light neeto-editor-slash-commands-tippy",
3579
+ visible: selectedIndex === index,
3580
+ content: /*#__PURE__*/jsxRuntime.jsx(Menu, _objectSpread$a(_objectSpread$a({}, _this2.props), {}, {
3581
+ items: item.items,
3582
+ menuIndex: menuIndex + 1
3583
+ })),
3584
+ onCreate: function onCreate(_ref) {
3585
+ var popper = _ref.popper;
3586
+ return popper.style.width = "max-content";
3587
+ },
3588
+ onHide: function onHide() {
3589
+ _this2.isSubmenuOpened = false;
3590
+ },
3591
+ onShow: function onShow() {
3592
+ _this2.isSubmenuOpened = true;
3593
+ },
3594
+ children: nodeElement
3595
+ }, item.optionName);
3596
+ })
3597
+ });
3598
+ }
3599
+ }]);
3600
+ }(React__default.default.Component); // eslint-disable-next-line react/display-name
3601
+ var MenuItem = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
3602
+ var item = _ref2.item,
3603
+ selectedIndex = _ref2.selectedIndex,
3604
+ index = _ref2.index,
3605
+ selectItem = _ref2.selectItem,
3606
+ onHover = _ref2.onHover;
3607
+ var Icon = item.Icon;
3608
+ return /*#__PURE__*/jsxRuntime.jsxs("button", {
3609
+ ref: ref,
3610
+ "data-testid": "neeto-editor-command-list-item-".concat(index),
3611
+ className: classnames__default.default("neeto-editor-slash-commands__item", {
3612
+ active: index === selectedIndex
3613
+ }),
3614
+ onClick: selectItem,
3615
+ onMouseEnter: onHover,
3616
+ children: [Icon && /*#__PURE__*/jsxRuntime.jsx(Icon, {
3617
+ size: 20
3618
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
3619
+ className: "neeto-editor-slash-commands__item-content",
3620
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
3621
+ className: "neeto-editor-slash-commands__item-title",
3622
+ "data-testid": "neeto-editor-command-list-item-block-heading",
3623
+ children: item.title
3624
+ })
3625
+ })]
3626
+ });
3627
+ });
3628
+
3629
+ function ownKeys$9(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; }
3630
+ function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), true).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3631
+ function _callSuper(t, o, e) { return o = _getPrototypeOf__default.default(o), _possibleConstructorReturn__default.default(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf__default.default(t).constructor) : o.apply(t, e)); }
3632
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3633
+ var CommandsList = /*#__PURE__*/function (_React$Component) {
3634
+ function CommandsList() {
3635
+ var _this;
3636
+ _classCallCheck__default.default(this, CommandsList);
3637
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3638
+ args[_key] = arguments[_key];
3639
+ }
3640
+ _this = _callSuper(this, CommandsList, [].concat(args));
3641
+ _defineProperty__default.default(_this, "state", {
3642
+ activeMenuIndex: 0
3643
+ });
3644
+ _defineProperty__default.default(_this, "onKeyDown", function (_ref) {
3645
+ var event = _ref.event;
3646
+ return ["Enter", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(event.key);
3647
+ });
3648
+ _defineProperty__default.default(_this, "setActiveMenuIndex", function (index) {
3649
+ return _this.setState({
3650
+ activeMenuIndex: index
3651
+ });
3652
+ });
3653
+ return _this;
3654
+ }
3655
+ _inherits__default.default(CommandsList, _React$Component);
3656
+ return _createClass__default.default(CommandsList, [{
3657
+ key: "render",
3658
+ value: function render() {
3659
+ return /*#__PURE__*/jsxRuntime.jsx(Menu, _objectSpread$9(_objectSpread$9({}, this.props), {}, {
3660
+ activeMenuIndex: this.state.activeMenuIndex,
3661
+ items: this.props.items,
3662
+ menuIndex: 0,
3663
+ setActiveMenuIndex: this.setActiveMenuIndex
3664
+ }));
3665
+ }
3666
+ }]);
3667
+ }(React__default.default.Component);
3668
+
3039
3669
  function ownKeys$8(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; }
3040
3670
  function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), true).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3041
3671
  var CommandsPluginKey = new index.PluginKey("commands");
@@ -3104,7 +3734,13 @@ var SlashCommands = {
3104
3734
  arrow: false,
3105
3735
  zIndex: 99999,
3106
3736
  role: "dropdown",
3107
- theme: "light neeto-editor-slash-commands-tippy"
3737
+ theme: "light neeto-editor-slash-commands-tippy",
3738
+ popperOptions: {
3739
+ modifiers: [{
3740
+ name: "flip",
3741
+ enabled: false
3742
+ }, fitToAvailableHeight]
3743
+ }
3108
3744
  });
3109
3745
  useEditorStore.highlightFocussedNode();
3110
3746
  },