@bigbinary/neeto-editor-frontend 2.2.2 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.ready +1 -1
- package/dist/Attachments.js +3 -3
- package/dist/Editor.js +10 -10
- package/dist/EditorContent.js +4 -4
- package/dist/FormikEditor.js +10 -10
- package/dist/Menu.js +7 -7
- package/dist/{chunk-BfQ_Kj4i.js → chunk-AexVHCkr.js} +4 -4
- package/dist/{chunk-BfQ_Kj4i.js.map → chunk-AexVHCkr.js.map} +1 -1
- package/dist/{chunk-CRUXOawK.js → chunk-B5LsYrmv.js} +4 -4
- package/dist/{chunk-CRUXOawK.js.map → chunk-B5LsYrmv.js.map} +1 -1
- package/dist/chunk-BHi0J28T.js +1970 -0
- package/dist/chunk-BHi0J28T.js.map +1 -0
- package/dist/{chunk-CxFTIgDS.js → chunk-BIgc5m-h.js} +2 -2
- package/dist/{chunk-CxFTIgDS.js.map → chunk-BIgc5m-h.js.map} +1 -1
- package/dist/{chunk-BNyLNMnb.js → chunk-Bktpw5vs.js} +5 -5
- package/dist/{chunk-BNyLNMnb.js.map → chunk-Bktpw5vs.js.map} +1 -1
- package/dist/{chunk-lEnpEBRB.js → chunk-BozdxlzB.js} +5 -5
- package/dist/{chunk-lEnpEBRB.js.map → chunk-BozdxlzB.js.map} +1 -1
- package/dist/{chunk-BpMZjml2.js → chunk-C9H9LYpP.js} +2 -2
- package/dist/chunk-C9H9LYpP.js.map +1 -0
- package/dist/{chunk-DhFieQe2.js → chunk-CLjWv4gG.js} +4 -4
- package/dist/{chunk-DhFieQe2.js.map → chunk-CLjWv4gG.js.map} +1 -1
- package/dist/{chunk-D_Lgx0N7.js → chunk-C_4zmIBQ.js} +2 -2
- package/dist/{chunk-D_Lgx0N7.js.map → chunk-C_4zmIBQ.js.map} +1 -1
- package/dist/{chunk-YhV82e9I.js → chunk-CivYrffM.js} +6 -6
- package/dist/{chunk-YhV82e9I.js.map → chunk-CivYrffM.js.map} +1 -1
- package/dist/{chunk-BV_wep_Y.js → chunk-D37Dlp9s.js} +4 -4
- package/dist/{chunk-BV_wep_Y.js.map → chunk-D37Dlp9s.js.map} +1 -1
- package/dist/{chunk-DYRpf9PJ.js → chunk-DPx9v04U.js} +3 -3
- package/dist/{chunk-DYRpf9PJ.js.map → chunk-DPx9v04U.js.map} +1 -1
- package/dist/{chunk-7ioLE0kx.js → chunk-DcxOAiAp.js} +2 -2
- package/dist/{chunk-7ioLE0kx.js.map → chunk-DcxOAiAp.js.map} +1 -1
- package/dist/{chunk-DN9pYQV5.js → chunk-DqSrbxqC.js} +2 -2
- package/dist/{chunk-DN9pYQV5.js.map → chunk-DqSrbxqC.js.map} +1 -1
- package/dist/{chunk-BGx6BSFw.js → chunk-DwQ7NJtm.js} +4 -4
- package/dist/{chunk-BGx6BSFw.js.map → chunk-DwQ7NJtm.js.map} +1 -1
- package/dist/{chunk-Br5h7rjn.js → chunk-GA-wADEN.js} +3 -3
- package/dist/{chunk-Br5h7rjn.js.map → chunk-GA-wADEN.js.map} +1 -1
- package/dist/{chunk-DfH1lF5p.js → chunk-LtUevT4I.js} +2 -2
- package/dist/{chunk-DfH1lF5p.js.map → chunk-LtUevT4I.js.map} +1 -1
- package/dist/{chunk-sn8HEeT6.js → chunk-yBvbLjSM.js} +4 -4
- package/dist/{chunk-sn8HEeT6.js.map → chunk-yBvbLjSM.js.map} +1 -1
- package/dist/cjs/Attachments.cjs.js +3 -3
- package/dist/cjs/Editor.cjs.js +10 -10
- package/dist/cjs/EditorContent.cjs.js +4 -4
- package/dist/cjs/FormikEditor.cjs.js +10 -10
- package/dist/cjs/Menu.cjs.js +7 -7
- package/dist/cjs/{chunk-BAse0j9m.cjs.js → chunk-BfHU_Ynq.cjs.js} +4 -4
- package/dist/cjs/{chunk-BAse0j9m.cjs.js.map → chunk-BfHU_Ynq.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-QnVNXaqt.cjs.js → chunk-CAaxrndK.cjs.js} +6 -6
- package/dist/cjs/{chunk-QnVNXaqt.cjs.js.map → chunk-CAaxrndK.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-DRnP2LQe.cjs.js → chunk-CJIIbW7G.cjs.js} +2 -2
- package/dist/cjs/{chunk-DRnP2LQe.cjs.js.map → chunk-CJIIbW7G.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-V1V-Gqfy.cjs.js → chunk-CKbuSSOi.cjs.js} +5 -5
- package/dist/cjs/{chunk-V1V-Gqfy.cjs.js.map → chunk-CKbuSSOi.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-CQLQEN5P.cjs.js → chunk-CU6dMPZV.cjs.js} +2 -2
- package/dist/cjs/{chunk-CQLQEN5P.cjs.js.map → chunk-CU6dMPZV.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-BPJBeVDI.cjs.js → chunk-C_XHzWXy.cjs.js} +2 -2
- package/dist/cjs/chunk-C_XHzWXy.cjs.js.map +1 -0
- package/dist/cjs/{chunk-bfmPXyQJ.cjs.js → chunk-CddQ0UHU.cjs.js} +3 -3
- package/dist/cjs/{chunk-bfmPXyQJ.cjs.js.map → chunk-CddQ0UHU.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-BPLEmkMA.cjs.js → chunk-CfiRFXt2.cjs.js} +2 -2
- package/dist/cjs/{chunk-BPLEmkMA.cjs.js.map → chunk-CfiRFXt2.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-78VpxO0R.cjs.js → chunk-CkSG3yNC.cjs.js} +4 -4
- package/dist/cjs/{chunk-78VpxO0R.cjs.js.map → chunk-CkSG3yNC.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-CHk_Gq2n.cjs.js → chunk-CpQ8t9br.cjs.js} +2 -2
- package/dist/cjs/{chunk-CHk_Gq2n.cjs.js.map → chunk-CpQ8t9br.cjs.js.map} +1 -1
- package/dist/cjs/chunk-Cr0FBhRs.cjs.js +1990 -0
- package/dist/cjs/chunk-Cr0FBhRs.cjs.js.map +1 -0
- package/dist/cjs/{chunk-DGPpvE8O.cjs.js → chunk-Ct6vCCZ0.cjs.js} +4 -4
- package/dist/cjs/{chunk-DGPpvE8O.cjs.js.map → chunk-Ct6vCCZ0.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-CwY6UgZq.cjs.js → chunk-CxKWZyHq.cjs.js} +3 -3
- package/dist/cjs/{chunk-CwY6UgZq.cjs.js.map → chunk-CxKWZyHq.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-j4T5BDua.cjs.js → chunk-Df33Mipq.cjs.js} +5 -5
- package/dist/cjs/{chunk-j4T5BDua.cjs.js.map → chunk-Df33Mipq.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-D86ONI5s.cjs.js → chunk-Df43FB6u.cjs.js} +4 -4
- package/dist/cjs/{chunk-D86ONI5s.cjs.js.map → chunk-Df43FB6u.cjs.js.map} +1 -1
- package/dist/cjs/{chunk--47DtZYn.cjs.js → chunk-DuwgLqpD.cjs.js} +4 -4
- package/dist/cjs/{chunk--47DtZYn.cjs.js.map → chunk-DuwgLqpD.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-bxP1kilM.cjs.js → chunk-Dwv-JqJN.cjs.js} +2 -2
- package/dist/cjs/{chunk-bxP1kilM.cjs.js.map → chunk-Dwv-JqJN.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-CBswWnmM.cjs.js → chunk-Niprqtd_.cjs.js} +3 -3
- package/dist/cjs/{chunk-CBswWnmM.cjs.js.map → chunk-Niprqtd_.cjs.js.map} +1 -1
- package/dist/cjs/index.cjs.js +12 -12
- package/dist/cjs/utils.cjs.js +6 -6
- package/dist/cjs/v2/Attachments.cjs.js +3 -3
- package/dist/cjs/v2/Editor.cjs.js +872 -236
- package/dist/cjs/v2/Editor.cjs.js.map +1 -1
- package/dist/cjs/v2/EditorContent.cjs.js +4 -4
- package/dist/cjs/v2/FormikEditor.cjs.js +9 -9
- package/dist/cjs/v2/Menu.cjs.js +6 -6
- package/dist/cjs/v2/index.cjs.js +11 -11
- package/dist/cjs/v2/utils.cjs.js +6 -6
- package/dist/editor-stats.html +1 -19
- package/dist/index.js +12 -12
- package/dist/utils.js +6 -6
- package/dist/v2/Attachments.js +3 -3
- package/dist/v2/Editor.js +872 -236
- package/dist/v2/Editor.js.map +1 -1
- package/dist/v2/EditorContent.js +4 -4
- package/dist/v2/FormikEditor.js +9 -9
- package/dist/v2/Menu.js +6 -6
- package/dist/v2/index.js +11 -11
- package/dist/v2/styles.css +1 -1
- package/dist/v2/styles.js +1 -1
- package/dist/v2/utils.js +6 -6
- package/package.json +6 -4
- package/dist/chunk-BpMZjml2.js.map +0 -1
- package/dist/chunk-OP-lX765.js +0 -8654
- package/dist/chunk-OP-lX765.js.map +0 -1
- package/dist/cjs/chunk-BPJBeVDI.cjs.js.map +0 -1
- package/dist/cjs/chunk-Bde8Sbb1.cjs.js +0 -8674
- package/dist/cjs/chunk-Bde8Sbb1.cjs.js.map +0 -1
package/dist/v2/Editor.js
CHANGED
|
@@ -4,22 +4,22 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
5
|
import React__default, { memo, useState, useRef, useCallback, useEffect, createElement, forwardRef, useImperativeHandle } from 'react';
|
|
6
6
|
import { DropdownMenu, Input, Button, Spinner, Tooltip, Toastr, Avatar, Typography, Select, Dialog, Checkbox as Checkbox$1, Label } from '@bigbinary/neeto-atoms';
|
|
7
|
-
import { a as useEditorState, E as Extension, N as NodeViewWrapper, b as NodeViewContent, c as Node, R as ReactNodeViewRenderer, m as mergeAttributes, D as DecorationSet, d as Decoration, f as ReactRenderer, e as emojiPickerApi, h as markInputRule, I as InputRule, r as resetFocussedNode, i as highlightFocussedNode,
|
|
7
|
+
import { a as useEditorState, E as Extension, N as NodeViewWrapper, b as NodeViewContent, c as Node, R as ReactNodeViewRenderer, m as mergeAttributes, D as DecorationSet, d as Decoration, f as ReactRenderer, e as emojiPickerApi, h as markInputRule, I as InputRule, r as resetFocussedNode, i as highlightFocussedNode, ap as isInTable, aq as selectedRect, ar as findTable, as as TableMap, at as addRow, P as PasteRule, B as BubbleMenu, j as getMarkType, k as getMarkRange, l as useEditor, n as EditorContent, o as EditorView } from '../chunk-B5LsYrmv.js';
|
|
8
8
|
import classnames from 'classnames';
|
|
9
9
|
import { isNotPresent, findBy, isNotEmpty, isPresent, noop, slugify } from '@bigbinary/neeto-cist';
|
|
10
10
|
import { useOnClickOutside, withT, useFuncDebounce } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
|
|
11
11
|
import { createPortal } from 'react-dom';
|
|
12
|
-
import { B as BulletList$1, s as src_default, a as src_default$1, R as Resizable, b as src_default$2, L as Link$1, c as scrollHandler, d as src_default$3, O as OrderedList$1, e as src_default$4, f as fuzzySearch, T as Table$2, g as TaskList, h as TaskItem, i as getVariableDisplay, j as getVideoDimension, C as CharacterCount, k as src_default$5, l as src_default$6, m as safeSplitBlock, n as safeListKeymap, o as TextStyle, p as src_default$7, F as Focus, q as src_default$8, r as TableRow, t as TableHeader, u as TableCell, v as Color, w as ListItem, x as src_default$9, y as src_default$a, z as useFetchKbArticles, K as useEditorWarnings, N as useDeletedArticles } from '../chunk-
|
|
12
|
+
import { B as BulletList$1, s as src_default, a as src_default$1, R as Resizable, b as src_default$2, L as Link$1, c as scrollHandler, d as src_default$3, O as OrderedList$1, e as src_default$4, f as fuzzySearch, T as Table$2, g as TaskList, h as TaskItem, i as getVariableDisplay, j as getVideoDimension, C as CharacterCount, k as src_default$5, l as src_default$6, m as safeSplitBlock, n as safeListKeymap, o as TextStyle, p as src_default$7, F as Focus, q as src_default$8, r as TableRow, t as TableHeader, u as TableCell, v as Color, w as ListItem, x as src_default$9, y as src_default$a, z as useFetchKbArticles, K as useEditorWarnings, N as useDeletedArticles } from '../chunk-BozdxlzB.js';
|
|
13
13
|
import { D as DIRECT_UPLOAD_ENDPOINT, E as EDITOR_OPTIONS, C as COMBINED_REGEX, a as EDITOR_SIZES } from '../chunk-UwzgbfZD.js';
|
|
14
|
-
import { S as Slice, F as Fragment$1 } from '../chunk-
|
|
14
|
+
import { S as Slice, F as Fragment$1 } from '../chunk-C9H9LYpP.js';
|
|
15
15
|
import '../chunk-CNIDH-FD.js';
|
|
16
16
|
import { is, intersection, difference, union, isEmpty, isNil, mergeRight, assoc, equals } from 'ramda';
|
|
17
17
|
import ReactDOM from 'react-dom/server';
|
|
18
|
-
import { l as lowlight, d as decodeHtmlEntities, r as removeEmptyTags } from '../chunk-
|
|
18
|
+
import { l as lowlight, d as decodeHtmlEntities, r as removeEmptyTags } from '../chunk-LtUevT4I.js';
|
|
19
19
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
20
|
-
import { C as CALLOUT_TYPES, E as EmojiPickerMenu, g as getSuggestionAppendTo, v as validateUrl, b as buildLevelsFromOptions, c as getLinkPopoverPosition, L as LINK_VALIDATION_SCHEMA, d as validateAndFormatUrl, D as DEFAULT_EDITOR_OPTIONS, e as getEditorStyles, M as Menu$3, f as MenuDynamicVariables, h as MediaUploader, j as LinkAddPopOver, k as transformPastedHTML, l as handlePaste, m as clipboardTextParser, s as setInitialPosition } from '../chunk-
|
|
20
|
+
import { C as CALLOUT_TYPES, E as EmojiPickerMenu, g as getSuggestionAppendTo, v as validateUrl, b as buildLevelsFromOptions, c as getLinkPopoverPosition, L as LINK_VALIDATION_SCHEMA, d as validateAndFormatUrl, D as DEFAULT_EDITOR_OPTIONS, e as getEditorStyles, M as Menu$3, f as MenuDynamicVariables, h as MediaUploader, j as LinkAddPopOver, k as transformPastedHTML, l as handlePaste, m as clipboardTextParser, s as setInitialPosition } from '../chunk-CivYrffM.js';
|
|
21
21
|
import Megaphone from '@bigbinary/neeto-icons/misc/Megaphone';
|
|
22
|
-
import { g as PluginKey, P as Plugin, S as Selection, T as TextSelection } from '../chunk-
|
|
22
|
+
import { g as PluginKey, P as Plugin, S as Selection, T as TextSelection } from '../chunk-DqSrbxqC.js';
|
|
23
23
|
import { ChevronDown, Highlighter, X, Ratio, Ellipsis, AlignLeft, AlignCenter, AlignRight, RectangleHorizontal, RectangleVertical, Square, SquareDashed, Trash2, Minus as Minus$1, Plus, BookOpen, Pencil } from 'lucide-react';
|
|
24
24
|
import CopyToClipboardButton from '@bigbinary/neeto-molecules/v2/CopyToClipboardButton';
|
|
25
25
|
import { useTranslation } from 'react-i18next';
|
|
@@ -34,7 +34,7 @@ import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
|
|
|
34
34
|
import _inherits from '@babel/runtime/helpers/inherits';
|
|
35
35
|
import { init, SearchIndex } from 'emoji-mart';
|
|
36
36
|
import { globalProps } from '@bigbinary/neeto-commons-frontend/v2/initializers';
|
|
37
|
-
import { D as DirectUpload } from '../chunk-
|
|
37
|
+
import { D as DirectUpload } from '../chunk-BHi0J28T.js';
|
|
38
38
|
import Tippy from '@tippyjs/react';
|
|
39
39
|
import TextP from '@bigbinary/neeto-icons/TextP';
|
|
40
40
|
import TextH1 from '@bigbinary/neeto-icons/TextH1';
|
|
@@ -60,11 +60,11 @@ import Link$2 from '@bigbinary/neeto-icons/Link';
|
|
|
60
60
|
import Attachment from '@bigbinary/neeto-icons/Attachment';
|
|
61
61
|
import MessageSquare from '@bigbinary/neeto-icons/MessageSquare';
|
|
62
62
|
import File from '@bigbinary/neeto-icons/File';
|
|
63
|
-
import { h as DEFAULT_ASPECT_RATIO } from '../chunk-
|
|
63
|
+
import { h as DEFAULT_ASPECT_RATIO } from '../chunk-BIgc5m-h.js';
|
|
64
64
|
import _typeof from '@babel/runtime/helpers/typeof';
|
|
65
65
|
import Search from '@bigbinary/neeto-molecules/v2/Search';
|
|
66
66
|
import { Form, Input as Input$1 } from '@bigbinary/neeto-atoms/formik';
|
|
67
|
-
import { A as Attachments } from '../chunk-
|
|
67
|
+
import { A as Attachments } from '../chunk-DwQ7NJtm.js';
|
|
68
68
|
import 'axios';
|
|
69
69
|
import '@bigbinary/neeto-commons-frontend/react-utils';
|
|
70
70
|
import 'zustand';
|
|
@@ -2371,237 +2371,565 @@ var SelectionDecoration = src_default$4.extend({
|
|
|
2371
2371
|
}
|
|
2372
2372
|
});
|
|
2373
2373
|
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
var
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
_defineProperty(_this, "selectItem", function (index) {
|
|
2394
|
-
var _this$props = _this.props,
|
|
2395
|
-
items = _this$props.items,
|
|
2396
|
-
editor = _this$props.editor,
|
|
2397
|
-
range = _this$props.range;
|
|
2398
|
-
var selectedItem = items[index];
|
|
2399
|
-
var hasCommand = selectedItem && selectedItem.command;
|
|
2400
|
-
if (hasCommand) selectedItem.command({
|
|
2401
|
-
editor: editor,
|
|
2402
|
-
range: range
|
|
2403
|
-
});
|
|
2404
|
-
});
|
|
2405
|
-
_defineProperty(_this, "upHandler", function () {
|
|
2406
|
-
var items = _this.props.items;
|
|
2407
|
-
var selectedIndex = _this.state.selectedIndex;
|
|
2408
|
-
_this.setState({
|
|
2409
|
-
selectedIndex: (selectedIndex + items.length - 1) % items.length
|
|
2410
|
-
});
|
|
2411
|
-
});
|
|
2412
|
-
_defineProperty(_this, "downHandler", function () {
|
|
2413
|
-
var items = _this.props.items;
|
|
2414
|
-
var selectedIndex = _this.state.selectedIndex;
|
|
2415
|
-
_this.setState({
|
|
2416
|
-
selectedIndex: (selectedIndex + 1) % items.length
|
|
2417
|
-
});
|
|
2418
|
-
});
|
|
2419
|
-
_defineProperty(_this, "enterHandler", function () {
|
|
2420
|
-
var selectedIndex = _this.state.selectedIndex;
|
|
2421
|
-
_this.selectItem(selectedIndex);
|
|
2422
|
-
});
|
|
2423
|
-
_defineProperty(_this, "leftArrowHandler", function () {
|
|
2424
|
-
var _this$props2 = _this.props,
|
|
2425
|
-
menuIndex = _this$props2.menuIndex,
|
|
2426
|
-
setActiveMenuIndex = _this$props2.setActiveMenuIndex;
|
|
2427
|
-
if (menuIndex > 0) setActiveMenuIndex(menuIndex - 1);
|
|
2428
|
-
});
|
|
2429
|
-
_defineProperty(_this, "rightArrowHandler", function () {
|
|
2430
|
-
var _this$props3 = _this.props,
|
|
2431
|
-
menuIndex = _this$props3.menuIndex,
|
|
2432
|
-
setActiveMenuIndex = _this$props3.setActiveMenuIndex,
|
|
2433
|
-
items = _this$props3.items;
|
|
2434
|
-
var selectedIndex = _this.state.selectedIndex;
|
|
2435
|
-
var selectedItem = items[selectedIndex];
|
|
2436
|
-
var hasSubItems = selectedItem && !isNotPresent(selectedItem.items);
|
|
2437
|
-
if (hasSubItems) setActiveMenuIndex(menuIndex + 1);
|
|
2438
|
-
});
|
|
2439
|
-
_this.state = {
|
|
2440
|
-
selectedIndex: 0
|
|
2441
|
-
};
|
|
2442
|
-
_this.menuRef = /*#__PURE__*/React__default.createRef();
|
|
2443
|
-
return _this;
|
|
2374
|
+
var top = 'top';
|
|
2375
|
+
var bottom = 'bottom';
|
|
2376
|
+
var right = 'right';
|
|
2377
|
+
var left = 'left';
|
|
2378
|
+
var basePlacements = [top, bottom, right, left];
|
|
2379
|
+
var start = 'start';
|
|
2380
|
+
var end = 'end';
|
|
2381
|
+
var clippingParents = 'clippingParents';
|
|
2382
|
+
var viewport = 'viewport';
|
|
2383
|
+
var popper = 'popper';
|
|
2384
|
+
var reference = 'reference';
|
|
2385
|
+
|
|
2386
|
+
function getNodeName(element) {
|
|
2387
|
+
return element ? (element.nodeName || '').toLowerCase() : null;
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
function getWindow(node) {
|
|
2391
|
+
if (node == null) {
|
|
2392
|
+
return window;
|
|
2444
2393
|
}
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2394
|
+
|
|
2395
|
+
if (node.toString() !== '[object Window]') {
|
|
2396
|
+
var ownerDocument = node.ownerDocument;
|
|
2397
|
+
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
return node;
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
function isElement(node) {
|
|
2404
|
+
var OwnElement = getWindow(node).Element;
|
|
2405
|
+
return node instanceof OwnElement || node instanceof Element;
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
function isHTMLElement(node) {
|
|
2409
|
+
var OwnElement = getWindow(node).HTMLElement;
|
|
2410
|
+
return node instanceof OwnElement || node instanceof HTMLElement;
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
function isShadowRoot(node) {
|
|
2414
|
+
// IE 11 has no ShadowRoot
|
|
2415
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
2416
|
+
return false;
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
var OwnElement = getWindow(node).ShadowRoot;
|
|
2420
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
function getBasePlacement(placement) {
|
|
2424
|
+
return placement.split('-')[0];
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
var max = Math.max;
|
|
2428
|
+
var min = Math.min;
|
|
2429
|
+
var round = Math.round;
|
|
2430
|
+
|
|
2431
|
+
function getUAString() {
|
|
2432
|
+
var uaData = navigator.userAgentData;
|
|
2433
|
+
|
|
2434
|
+
if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
|
|
2435
|
+
return uaData.brands.map(function (item) {
|
|
2436
|
+
return item.brand + "/" + item.version;
|
|
2437
|
+
}).join(' ');
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
return navigator.userAgent;
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
function isLayoutViewport() {
|
|
2444
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
2448
|
+
if (includeScale === void 0) {
|
|
2449
|
+
includeScale = false;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
if (isFixedStrategy === void 0) {
|
|
2453
|
+
isFixedStrategy = false;
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
var clientRect = element.getBoundingClientRect();
|
|
2457
|
+
var scaleX = 1;
|
|
2458
|
+
var scaleY = 1;
|
|
2459
|
+
|
|
2460
|
+
if (includeScale && isHTMLElement(element)) {
|
|
2461
|
+
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
2462
|
+
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
var _ref = isElement(element) ? getWindow(element) : window,
|
|
2466
|
+
visualViewport = _ref.visualViewport;
|
|
2467
|
+
|
|
2468
|
+
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
2469
|
+
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
|
2470
|
+
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
|
2471
|
+
var width = clientRect.width / scaleX;
|
|
2472
|
+
var height = clientRect.height / scaleY;
|
|
2473
|
+
return {
|
|
2474
|
+
width: width,
|
|
2475
|
+
height: height,
|
|
2476
|
+
top: y,
|
|
2477
|
+
right: x + width,
|
|
2478
|
+
bottom: y + height,
|
|
2479
|
+
left: x,
|
|
2480
|
+
x: x,
|
|
2481
|
+
y: y
|
|
2482
|
+
};
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
function contains(parent, child) {
|
|
2486
|
+
var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
|
|
2487
|
+
|
|
2488
|
+
if (parent.contains(child)) {
|
|
2489
|
+
return true;
|
|
2490
|
+
} // then fallback to custom implementation with Shadow DOM support
|
|
2491
|
+
else if (rootNode && isShadowRoot(rootNode)) {
|
|
2492
|
+
var next = child;
|
|
2493
|
+
|
|
2494
|
+
do {
|
|
2495
|
+
if (next && parent.isSameNode(next)) {
|
|
2496
|
+
return true;
|
|
2497
|
+
} // $FlowFixMe[prop-missing]: need a better way to handle this...
|
|
2498
|
+
|
|
2499
|
+
|
|
2500
|
+
next = next.parentNode || next.host;
|
|
2501
|
+
} while (next);
|
|
2502
|
+
} // Give up, the result is false
|
|
2503
|
+
|
|
2504
|
+
|
|
2505
|
+
return false;
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
function getComputedStyle(element) {
|
|
2509
|
+
return getWindow(element).getComputedStyle(element);
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
function isTableElement(element) {
|
|
2513
|
+
return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
function getDocumentElement(element) {
|
|
2517
|
+
// $FlowFixMe[incompatible-return]: assume body is always available
|
|
2518
|
+
return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
|
|
2519
|
+
element.document) || window.document).documentElement;
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
function getParentNode(element) {
|
|
2523
|
+
if (getNodeName(element) === 'html') {
|
|
2524
|
+
return element;
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|
2528
|
+
// $FlowFixMe[incompatible-return]
|
|
2529
|
+
// $FlowFixMe[prop-missing]
|
|
2530
|
+
element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
2531
|
+
element.parentNode || ( // DOM Element detected
|
|
2532
|
+
isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
|
|
2533
|
+
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
|
|
2534
|
+
getDocumentElement(element) // fallback
|
|
2535
|
+
|
|
2536
|
+
);
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
function getTrueOffsetParent(element) {
|
|
2540
|
+
if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
|
|
2541
|
+
getComputedStyle(element).position === 'fixed') {
|
|
2542
|
+
return null;
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
return element.offsetParent;
|
|
2546
|
+
} // `.offsetParent` reports `null` for fixed elements, while absolute elements
|
|
2547
|
+
// return the containing block
|
|
2548
|
+
|
|
2549
|
+
|
|
2550
|
+
function getContainingBlock(element) {
|
|
2551
|
+
var isFirefox = /firefox/i.test(getUAString());
|
|
2552
|
+
var isIE = /Trident/i.test(getUAString());
|
|
2553
|
+
|
|
2554
|
+
if (isIE && isHTMLElement(element)) {
|
|
2555
|
+
// In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
|
|
2556
|
+
var elementCss = getComputedStyle(element);
|
|
2557
|
+
|
|
2558
|
+
if (elementCss.position === 'fixed') {
|
|
2559
|
+
return null;
|
|
2461
2560
|
}
|
|
2462
|
-
}
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
} else document.removeEventListener("keydown", this.keydownHandler);
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
var currentNode = getParentNode(element);
|
|
2564
|
+
|
|
2565
|
+
if (isShadowRoot(currentNode)) {
|
|
2566
|
+
currentNode = currentNode.host;
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
|
|
2570
|
+
var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
|
|
2571
|
+
// create a containing block.
|
|
2572
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
2573
|
+
|
|
2574
|
+
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') {
|
|
2575
|
+
return currentNode;
|
|
2576
|
+
} else {
|
|
2577
|
+
currentNode = currentNode.parentNode;
|
|
2480
2578
|
}
|
|
2481
|
-
}
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
return null;
|
|
2582
|
+
} // Gets the closest ancestor positioned element. Handles some edge cases,
|
|
2583
|
+
// such as table ancestors and cross browser bugs.
|
|
2584
|
+
|
|
2585
|
+
|
|
2586
|
+
function getOffsetParent(element) {
|
|
2587
|
+
var window = getWindow(element);
|
|
2588
|
+
var offsetParent = getTrueOffsetParent(element);
|
|
2589
|
+
|
|
2590
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
|
2591
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
|
|
2595
|
+
return window;
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2598
|
+
return offsetParent || getContainingBlock(element) || window;
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
function getMainAxisFromPlacement(placement) {
|
|
2602
|
+
return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
function getFreshSideObject() {
|
|
2606
|
+
return {
|
|
2607
|
+
top: 0,
|
|
2608
|
+
right: 0,
|
|
2609
|
+
bottom: 0,
|
|
2610
|
+
left: 0
|
|
2611
|
+
};
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
function mergePaddingObject(paddingObject) {
|
|
2615
|
+
return Object.assign({}, getFreshSideObject(), paddingObject);
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
function expandToHashMap(value, keys) {
|
|
2619
|
+
return keys.reduce(function (hashMap, key) {
|
|
2620
|
+
hashMap[key] = value;
|
|
2621
|
+
return hashMap;
|
|
2622
|
+
}, {});
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
function getVariation(placement) {
|
|
2626
|
+
return placement.split('-')[1];
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2629
|
+
function getWindowScroll(node) {
|
|
2630
|
+
var win = getWindow(node);
|
|
2631
|
+
var scrollLeft = win.pageXOffset;
|
|
2632
|
+
var scrollTop = win.pageYOffset;
|
|
2633
|
+
return {
|
|
2634
|
+
scrollLeft: scrollLeft,
|
|
2635
|
+
scrollTop: scrollTop
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
function getWindowScrollBarX(element) {
|
|
2640
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
2641
|
+
// incorrect for RTL.
|
|
2642
|
+
// Popper 1 is broken in this case and never had a bug report so let's assume
|
|
2643
|
+
// it's not an issue. I don't think anyone ever specifies width on <html>
|
|
2644
|
+
// anyway.
|
|
2645
|
+
// Browsers where the left scrollbar doesn't cause an issue report `0` for
|
|
2646
|
+
// this (e.g. Edge 2019, IE11, Safari)
|
|
2647
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
function getViewportRect(element, strategy) {
|
|
2651
|
+
var win = getWindow(element);
|
|
2652
|
+
var html = getDocumentElement(element);
|
|
2653
|
+
var visualViewport = win.visualViewport;
|
|
2654
|
+
var width = html.clientWidth;
|
|
2655
|
+
var height = html.clientHeight;
|
|
2656
|
+
var x = 0;
|
|
2657
|
+
var y = 0;
|
|
2658
|
+
|
|
2659
|
+
if (visualViewport) {
|
|
2660
|
+
width = visualViewport.width;
|
|
2661
|
+
height = visualViewport.height;
|
|
2662
|
+
var layoutViewport = isLayoutViewport();
|
|
2663
|
+
|
|
2664
|
+
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
2665
|
+
x = visualViewport.offsetLeft;
|
|
2666
|
+
y = visualViewport.offsetTop;
|
|
2535
2667
|
}
|
|
2536
|
-
}
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
return {
|
|
2671
|
+
width: width,
|
|
2672
|
+
height: height,
|
|
2673
|
+
x: x + getWindowScrollBarX(element),
|
|
2674
|
+
y: y
|
|
2675
|
+
};
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
|
2679
|
+
|
|
2680
|
+
function getDocumentRect(element) {
|
|
2681
|
+
var _element$ownerDocumen;
|
|
2682
|
+
|
|
2683
|
+
var html = getDocumentElement(element);
|
|
2684
|
+
var winScroll = getWindowScroll(element);
|
|
2685
|
+
var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
|
2686
|
+
var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
2687
|
+
var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
2688
|
+
var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
|
2689
|
+
var y = -winScroll.scrollTop;
|
|
2690
|
+
|
|
2691
|
+
if (getComputedStyle(body || html).direction === 'rtl') {
|
|
2692
|
+
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
return {
|
|
2696
|
+
width: width,
|
|
2697
|
+
height: height,
|
|
2698
|
+
x: x,
|
|
2699
|
+
y: y
|
|
2700
|
+
};
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
function isScrollParent(element) {
|
|
2704
|
+
// Firefox wants us to check `-x` and `-y` variations as well
|
|
2705
|
+
var _getComputedStyle = getComputedStyle(element),
|
|
2706
|
+
overflow = _getComputedStyle.overflow,
|
|
2707
|
+
overflowX = _getComputedStyle.overflowX,
|
|
2708
|
+
overflowY = _getComputedStyle.overflowY;
|
|
2709
|
+
|
|
2710
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
function getScrollParent(node) {
|
|
2714
|
+
if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
|
|
2715
|
+
// $FlowFixMe[incompatible-return]: assume body is always available
|
|
2716
|
+
return node.ownerDocument.body;
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
if (isHTMLElement(node) && isScrollParent(node)) {
|
|
2720
|
+
return node;
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
return getScrollParent(getParentNode(node));
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
/*
|
|
2727
|
+
given a DOM element, return the list of all scroll parents, up the list of ancesors
|
|
2728
|
+
until we get to the top window object. This list is what we attach scroll listeners
|
|
2729
|
+
to, because if any of these parent elements scroll, we'll need to re-calculate the
|
|
2730
|
+
reference element's position.
|
|
2731
|
+
*/
|
|
2732
|
+
|
|
2733
|
+
function listScrollParents(element, list) {
|
|
2734
|
+
var _element$ownerDocumen;
|
|
2735
|
+
|
|
2736
|
+
if (list === void 0) {
|
|
2737
|
+
list = [];
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
var scrollParent = getScrollParent(element);
|
|
2741
|
+
var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
|
2742
|
+
var win = getWindow(scrollParent);
|
|
2743
|
+
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
2744
|
+
var updatedList = list.concat(target);
|
|
2745
|
+
return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
|
|
2746
|
+
updatedList.concat(listScrollParents(getParentNode(target)));
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
function rectToClientRect(rect) {
|
|
2750
|
+
return Object.assign({}, rect, {
|
|
2751
|
+
left: rect.x,
|
|
2752
|
+
top: rect.y,
|
|
2753
|
+
right: rect.x + rect.width,
|
|
2754
|
+
bottom: rect.y + rect.height
|
|
2563
2755
|
});
|
|
2564
|
-
}
|
|
2756
|
+
}
|
|
2565
2757
|
|
|
2566
|
-
function
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2758
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
2759
|
+
var rect = getBoundingClientRect(element, false, strategy === 'fixed');
|
|
2760
|
+
rect.top = rect.top + element.clientTop;
|
|
2761
|
+
rect.left = rect.left + element.clientLeft;
|
|
2762
|
+
rect.bottom = rect.top + element.clientHeight;
|
|
2763
|
+
rect.right = rect.left + element.clientWidth;
|
|
2764
|
+
rect.width = element.clientWidth;
|
|
2765
|
+
rect.height = element.clientHeight;
|
|
2766
|
+
rect.x = rect.left;
|
|
2767
|
+
rect.y = rect.top;
|
|
2768
|
+
return rect;
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
function getClientRectFromMixedType(element, clippingParent, strategy) {
|
|
2772
|
+
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
2773
|
+
} // A "clipping parent" is an overflowable container with the characteristic of
|
|
2774
|
+
// clipping (or hiding) overflowing elements with a position different from
|
|
2775
|
+
// `initial`
|
|
2776
|
+
|
|
2777
|
+
|
|
2778
|
+
function getClippingParents(element) {
|
|
2779
|
+
var clippingParents = listScrollParents(getParentNode(element));
|
|
2780
|
+
var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
|
|
2781
|
+
var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
|
2782
|
+
|
|
2783
|
+
if (!isElement(clipperElement)) {
|
|
2784
|
+
return [];
|
|
2785
|
+
} // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
|
|
2786
|
+
|
|
2787
|
+
|
|
2788
|
+
return clippingParents.filter(function (clippingParent) {
|
|
2789
|
+
return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
|
|
2790
|
+
});
|
|
2791
|
+
} // Gets the maximum area that the element is visible in due to any number of
|
|
2792
|
+
// clipping parents
|
|
2793
|
+
|
|
2794
|
+
|
|
2795
|
+
function getClippingRect(element, boundary, rootBoundary, strategy) {
|
|
2796
|
+
var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
|
|
2797
|
+
var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
|
|
2798
|
+
var firstClippingParent = clippingParents[0];
|
|
2799
|
+
var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
|
|
2800
|
+
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
|
2801
|
+
accRect.top = max(rect.top, accRect.top);
|
|
2802
|
+
accRect.right = min(rect.right, accRect.right);
|
|
2803
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
2804
|
+
accRect.left = max(rect.left, accRect.left);
|
|
2805
|
+
return accRect;
|
|
2806
|
+
}, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
|
2807
|
+
clippingRect.width = clippingRect.right - clippingRect.left;
|
|
2808
|
+
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
|
2809
|
+
clippingRect.x = clippingRect.left;
|
|
2810
|
+
clippingRect.y = clippingRect.top;
|
|
2811
|
+
return clippingRect;
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
function computeOffsets(_ref) {
|
|
2815
|
+
var reference = _ref.reference,
|
|
2816
|
+
element = _ref.element,
|
|
2817
|
+
placement = _ref.placement;
|
|
2818
|
+
var basePlacement = placement ? getBasePlacement(placement) : null;
|
|
2819
|
+
var variation = placement ? getVariation(placement) : null;
|
|
2820
|
+
var commonX = reference.x + reference.width / 2 - element.width / 2;
|
|
2821
|
+
var commonY = reference.y + reference.height / 2 - element.height / 2;
|
|
2822
|
+
var offsets;
|
|
2823
|
+
|
|
2824
|
+
switch (basePlacement) {
|
|
2825
|
+
case top:
|
|
2826
|
+
offsets = {
|
|
2827
|
+
x: commonX,
|
|
2828
|
+
y: reference.y - element.height
|
|
2829
|
+
};
|
|
2830
|
+
break;
|
|
2831
|
+
|
|
2832
|
+
case bottom:
|
|
2833
|
+
offsets = {
|
|
2834
|
+
x: commonX,
|
|
2835
|
+
y: reference.y + reference.height
|
|
2836
|
+
};
|
|
2837
|
+
break;
|
|
2838
|
+
|
|
2839
|
+
case right:
|
|
2840
|
+
offsets = {
|
|
2841
|
+
x: reference.x + reference.width,
|
|
2842
|
+
y: commonY
|
|
2843
|
+
};
|
|
2844
|
+
break;
|
|
2845
|
+
|
|
2846
|
+
case left:
|
|
2847
|
+
offsets = {
|
|
2848
|
+
x: reference.x - element.width,
|
|
2849
|
+
y: commonY
|
|
2850
|
+
};
|
|
2851
|
+
break;
|
|
2852
|
+
|
|
2853
|
+
default:
|
|
2854
|
+
offsets = {
|
|
2855
|
+
x: reference.x,
|
|
2856
|
+
y: reference.y
|
|
2857
|
+
};
|
|
2591
2858
|
}
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2859
|
+
|
|
2860
|
+
var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
|
2861
|
+
|
|
2862
|
+
if (mainAxis != null) {
|
|
2863
|
+
var len = mainAxis === 'y' ? 'height' : 'width';
|
|
2864
|
+
|
|
2865
|
+
switch (variation) {
|
|
2866
|
+
case start:
|
|
2867
|
+
offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
|
|
2868
|
+
break;
|
|
2869
|
+
|
|
2870
|
+
case end:
|
|
2871
|
+
offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
|
|
2872
|
+
break;
|
|
2602
2873
|
}
|
|
2603
|
-
}
|
|
2604
|
-
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
return offsets;
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2879
|
+
function detectOverflow(state, options) {
|
|
2880
|
+
if (options === void 0) {
|
|
2881
|
+
options = {};
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
var _options = options,
|
|
2885
|
+
_options$placement = _options.placement,
|
|
2886
|
+
placement = _options$placement === void 0 ? state.placement : _options$placement,
|
|
2887
|
+
_options$strategy = _options.strategy,
|
|
2888
|
+
strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
|
|
2889
|
+
_options$boundary = _options.boundary,
|
|
2890
|
+
boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
|
|
2891
|
+
_options$rootBoundary = _options.rootBoundary,
|
|
2892
|
+
rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
|
|
2893
|
+
_options$elementConte = _options.elementContext,
|
|
2894
|
+
elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
|
|
2895
|
+
_options$altBoundary = _options.altBoundary,
|
|
2896
|
+
altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
|
|
2897
|
+
_options$padding = _options.padding,
|
|
2898
|
+
padding = _options$padding === void 0 ? 0 : _options$padding;
|
|
2899
|
+
var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
|
2900
|
+
var altContext = elementContext === popper ? reference : popper;
|
|
2901
|
+
var popperRect = state.rects.popper;
|
|
2902
|
+
var element = state.elements[altBoundary ? altContext : elementContext];
|
|
2903
|
+
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
|
2904
|
+
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
|
2905
|
+
var popperOffsets = computeOffsets({
|
|
2906
|
+
reference: referenceClientRect,
|
|
2907
|
+
element: popperRect,
|
|
2908
|
+
placement: placement
|
|
2909
|
+
});
|
|
2910
|
+
var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
|
|
2911
|
+
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
|
|
2912
|
+
// 0 or negative = within the clipping rect
|
|
2913
|
+
|
|
2914
|
+
var overflowOffsets = {
|
|
2915
|
+
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
2916
|
+
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
2917
|
+
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
2918
|
+
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
2919
|
+
};
|
|
2920
|
+
var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
|
|
2921
|
+
|
|
2922
|
+
if (elementContext === popper && offsetData) {
|
|
2923
|
+
var offset = offsetData[placement];
|
|
2924
|
+
Object.keys(overflowOffsets).forEach(function (key) {
|
|
2925
|
+
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
|
2926
|
+
var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
|
|
2927
|
+
overflowOffsets[key] += offset[axis] * multiply;
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2931
|
+
return overflowOffsets;
|
|
2932
|
+
}
|
|
2605
2933
|
|
|
2606
2934
|
var MENU_ITEMS = [{
|
|
2607
2935
|
optionName: EDITOR_OPTIONS.PARAGRAPH,
|
|
@@ -2904,9 +3232,12 @@ var NO_RESULT_MENU_ITEM = {
|
|
|
2904
3232
|
editor.chain().focus().deleteRange(range).run();
|
|
2905
3233
|
}
|
|
2906
3234
|
};
|
|
3235
|
+
var MENU_MAX_HEIGHT = 384;
|
|
3236
|
+
var MENU_BOUNDARY_PADDING = 8;
|
|
3237
|
+
var MENU_MAX_HEIGHT_CSS_VARIABLE = "--neeto-editor-slash-commands-max-height";
|
|
2907
3238
|
|
|
2908
|
-
function ownKeys$
|
|
2909
|
-
function _objectSpread$
|
|
3239
|
+
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; }
|
|
3240
|
+
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(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; }
|
|
2910
3241
|
var imageCommand = function imageCommand(setMediaUploader) {
|
|
2911
3242
|
return function (_ref) {
|
|
2912
3243
|
var editor = _ref.editor,
|
|
@@ -2954,6 +3285,15 @@ var neetoKbArticleCommand = function neetoKbArticleCommand(setIsNeetoKbArticleAc
|
|
|
2954
3285
|
editor.chain().focus().deleteRange(range).run();
|
|
2955
3286
|
};
|
|
2956
3287
|
};
|
|
3288
|
+
var getOppositePlacement = function getOppositePlacement(placement) {
|
|
3289
|
+
return placement.replace(/^(top|bottom)/, function (side) {
|
|
3290
|
+
return side === "top" ? "bottom" : "top";
|
|
3291
|
+
});
|
|
3292
|
+
};
|
|
3293
|
+
var getOffsetDistance = function getOffsetDistance(state, placement) {
|
|
3294
|
+
var _state$modifiersData$, _state$modifiersData$2;
|
|
3295
|
+
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);
|
|
3296
|
+
};
|
|
2957
3297
|
var buildCommandItems = function buildCommandItems(_ref6) {
|
|
2958
3298
|
var options = _ref6.options,
|
|
2959
3299
|
addonCommands = _ref6.addonCommands,
|
|
@@ -2980,7 +3320,7 @@ var buildCommandItems = function buildCommandItems(_ref6) {
|
|
|
2980
3320
|
return options.includes(optionName);
|
|
2981
3321
|
});
|
|
2982
3322
|
var adddonCommandItems = addonCommands.map(function (command) {
|
|
2983
|
-
return _objectSpread$
|
|
3323
|
+
return _objectSpread$b(_objectSpread$b({}, command), {}, {
|
|
2984
3324
|
title: command.label,
|
|
2985
3325
|
Icon: command.icon
|
|
2986
3326
|
});
|
|
@@ -2988,6 +3328,296 @@ var buildCommandItems = function buildCommandItems(_ref6) {
|
|
|
2988
3328
|
return [].concat(_toConsumableArray(permittedCommandItems), _toConsumableArray(adddonCommandItems));
|
|
2989
3329
|
};
|
|
2990
3330
|
|
|
3331
|
+
// Replaces Popper's flip for the slash commands menu. When the menu fits on
|
|
3332
|
+
// neither side, flip keeps the preferred side and lets the menu overflow, so on
|
|
3333
|
+
// short screens it gets cut off. Here we pick the side with more room instead
|
|
3334
|
+
// and cap the menu's height to the space available on that side.
|
|
3335
|
+
var fitToAvailableHeight = {
|
|
3336
|
+
name: "fitToAvailableHeight",
|
|
3337
|
+
enabled: true,
|
|
3338
|
+
phase: "main",
|
|
3339
|
+
requiresIfExists: ["offset"],
|
|
3340
|
+
fn: function fn(_ref8) {
|
|
3341
|
+
var state = _ref8.state,
|
|
3342
|
+
name = _ref8.name;
|
|
3343
|
+
if (state.modifiersData[name]._skip) return;
|
|
3344
|
+
var menu = state.elements.popper.querySelector(".neeto-editor-slash-commands__wrapper");
|
|
3345
|
+
if (!menu) return;
|
|
3346
|
+
var _detectOverflow = detectOverflow(state, {
|
|
3347
|
+
elementContext: "reference",
|
|
3348
|
+
altBoundary: true,
|
|
3349
|
+
padding: MENU_BOUNDARY_PADDING
|
|
3350
|
+
}),
|
|
3351
|
+
top = _detectOverflow.top,
|
|
3352
|
+
bottom = _detectOverflow.bottom;
|
|
3353
|
+
var isVertical = /^(top|bottom)/.test(state.placement);
|
|
3354
|
+
var menuChromeHeight = state.rects.popper.height - menu.offsetHeight;
|
|
3355
|
+
var menuContentHeight = Math.min(menu.scrollHeight, MENU_MAX_HEIGHT);
|
|
3356
|
+
var placement = state.placement;
|
|
3357
|
+
var availableHeight = state.rects.reference.height - top - bottom;
|
|
3358
|
+
if (isVertical) {
|
|
3359
|
+
var preferredPlacement = state.options.placement;
|
|
3360
|
+
var oppositePlacement = getOppositePlacement(preferredPlacement);
|
|
3361
|
+
var getSpace = function getSpace(candidatePlacement) {
|
|
3362
|
+
return (candidatePlacement.startsWith("top") ? -top : -bottom) - getOffsetDistance(state, candidatePlacement);
|
|
3363
|
+
};
|
|
3364
|
+
var preferredSpace = getSpace(preferredPlacement);
|
|
3365
|
+
var oppositeSpace = getSpace(oppositePlacement);
|
|
3366
|
+
var menuHeight = menuChromeHeight + menuContentHeight;
|
|
3367
|
+
var shouldUseOpposite = menuHeight > preferredSpace && (menuHeight <= oppositeSpace || oppositeSpace > preferredSpace);
|
|
3368
|
+
placement = shouldUseOpposite ? oppositePlacement : preferredPlacement;
|
|
3369
|
+
availableHeight = shouldUseOpposite ? oppositeSpace : preferredSpace;
|
|
3370
|
+
}
|
|
3371
|
+
var menuMaxHeight = Math.max(Math.floor(availableHeight - menuChromeHeight), 0);
|
|
3372
|
+
state.elements.popper.style.setProperty(MENU_MAX_HEIGHT_CSS_VARIABLE, "".concat(menuMaxHeight, "px"));
|
|
3373
|
+
var popperHeight = menuChromeHeight + Math.min(menuContentHeight, menuMaxHeight);
|
|
3374
|
+
if (placement === state.placement && popperHeight === state.rects.popper.height) {
|
|
3375
|
+
return;
|
|
3376
|
+
}
|
|
3377
|
+
state.modifiersData[name]._skip = true;
|
|
3378
|
+
state.placement = placement;
|
|
3379
|
+
state.rects.popper = _objectSpread$b(_objectSpread$b({}, state.rects.popper), {}, {
|
|
3380
|
+
height: popperHeight
|
|
3381
|
+
});
|
|
3382
|
+
state.reset = true;
|
|
3383
|
+
}
|
|
3384
|
+
};
|
|
3385
|
+
|
|
3386
|
+
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; }
|
|
3387
|
+
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(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; }
|
|
3388
|
+
function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
3389
|
+
function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
3390
|
+
var Menu = /*#__PURE__*/function (_React$Component) {
|
|
3391
|
+
function Menu(props) {
|
|
3392
|
+
var _this;
|
|
3393
|
+
_classCallCheck(this, Menu);
|
|
3394
|
+
_this = _callSuper$1(this, Menu, [props]);
|
|
3395
|
+
_defineProperty(_this, "keydownHandler", function (event) {
|
|
3396
|
+
var listeners = {
|
|
3397
|
+
Enter: _this.enterHandler,
|
|
3398
|
+
ArrowUp: _this.upHandler,
|
|
3399
|
+
ArrowDown: _this.downHandler,
|
|
3400
|
+
ArrowLeft: _this.leftArrowHandler,
|
|
3401
|
+
ArrowRight: _this.rightArrowHandler
|
|
3402
|
+
};
|
|
3403
|
+
if (event.key in listeners) listeners[event.key](event);
|
|
3404
|
+
});
|
|
3405
|
+
_defineProperty(_this, "selectItem", function (index) {
|
|
3406
|
+
var _this$props = _this.props,
|
|
3407
|
+
items = _this$props.items,
|
|
3408
|
+
editor = _this$props.editor,
|
|
3409
|
+
range = _this$props.range;
|
|
3410
|
+
var selectedItem = items[index];
|
|
3411
|
+
var hasCommand = selectedItem && selectedItem.command;
|
|
3412
|
+
if (hasCommand) selectedItem.command({
|
|
3413
|
+
editor: editor,
|
|
3414
|
+
range: range
|
|
3415
|
+
});
|
|
3416
|
+
});
|
|
3417
|
+
_defineProperty(_this, "upHandler", function () {
|
|
3418
|
+
var items = _this.props.items;
|
|
3419
|
+
var selectedIndex = _this.state.selectedIndex;
|
|
3420
|
+
_this.setState({
|
|
3421
|
+
selectedIndex: (selectedIndex + items.length - 1) % items.length
|
|
3422
|
+
});
|
|
3423
|
+
});
|
|
3424
|
+
_defineProperty(_this, "downHandler", function () {
|
|
3425
|
+
var items = _this.props.items;
|
|
3426
|
+
var selectedIndex = _this.state.selectedIndex;
|
|
3427
|
+
_this.setState({
|
|
3428
|
+
selectedIndex: (selectedIndex + 1) % items.length
|
|
3429
|
+
});
|
|
3430
|
+
});
|
|
3431
|
+
_defineProperty(_this, "enterHandler", function () {
|
|
3432
|
+
var selectedIndex = _this.state.selectedIndex;
|
|
3433
|
+
_this.selectItem(selectedIndex);
|
|
3434
|
+
});
|
|
3435
|
+
_defineProperty(_this, "leftArrowHandler", function () {
|
|
3436
|
+
var _this$props2 = _this.props,
|
|
3437
|
+
menuIndex = _this$props2.menuIndex,
|
|
3438
|
+
setActiveMenuIndex = _this$props2.setActiveMenuIndex;
|
|
3439
|
+
if (menuIndex > 0) setActiveMenuIndex(menuIndex - 1);
|
|
3440
|
+
});
|
|
3441
|
+
_defineProperty(_this, "rightArrowHandler", function () {
|
|
3442
|
+
var _this$props3 = _this.props,
|
|
3443
|
+
menuIndex = _this$props3.menuIndex,
|
|
3444
|
+
setActiveMenuIndex = _this$props3.setActiveMenuIndex,
|
|
3445
|
+
items = _this$props3.items;
|
|
3446
|
+
var selectedIndex = _this.state.selectedIndex;
|
|
3447
|
+
var selectedItem = items[selectedIndex];
|
|
3448
|
+
var hasSubItems = selectedItem && !isNotPresent(selectedItem.items);
|
|
3449
|
+
if (hasSubItems) setActiveMenuIndex(menuIndex + 1);
|
|
3450
|
+
});
|
|
3451
|
+
_this.state = {
|
|
3452
|
+
selectedIndex: 0
|
|
3453
|
+
};
|
|
3454
|
+
_this.menuRef = /*#__PURE__*/React__default.createRef();
|
|
3455
|
+
return _this;
|
|
3456
|
+
}
|
|
3457
|
+
_inherits(Menu, _React$Component);
|
|
3458
|
+
return _createClass(Menu, [{
|
|
3459
|
+
key: "componentDidMount",
|
|
3460
|
+
value: function componentDidMount() {
|
|
3461
|
+
var _this$props4 = this.props,
|
|
3462
|
+
menuIndex = _this$props4.menuIndex,
|
|
3463
|
+
activeMenuIndex = _this$props4.activeMenuIndex;
|
|
3464
|
+
var isCurrentMenuActive = menuIndex === activeMenuIndex;
|
|
3465
|
+
if (isCurrentMenuActive) {
|
|
3466
|
+
document.addEventListener("keydown", this.keydownHandler);
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
}, {
|
|
3470
|
+
key: "componentWillUnmount",
|
|
3471
|
+
value: function componentWillUnmount() {
|
|
3472
|
+
document.removeEventListener("keydown", this.keydownHandler);
|
|
3473
|
+
}
|
|
3474
|
+
}, {
|
|
3475
|
+
key: "componentDidUpdate",
|
|
3476
|
+
value: function componentDidUpdate(oldProps) {
|
|
3477
|
+
var _this$props5 = this.props,
|
|
3478
|
+
items = _this$props5.items,
|
|
3479
|
+
menuIndex = _this$props5.menuIndex,
|
|
3480
|
+
activeMenuIndex = _this$props5.activeMenuIndex;
|
|
3481
|
+
var isCurrentMenuActive = menuIndex === activeMenuIndex;
|
|
3482
|
+
if (items !== oldProps.items) this.setState({
|
|
3483
|
+
selectedIndex: 0
|
|
3484
|
+
});
|
|
3485
|
+
scrollHandler({
|
|
3486
|
+
wrapperRef: this.menuRef,
|
|
3487
|
+
index: this.state.selectedIndex
|
|
3488
|
+
});
|
|
3489
|
+
if (isCurrentMenuActive) {
|
|
3490
|
+
document.addEventListener("keydown", this.keydownHandler);
|
|
3491
|
+
} else document.removeEventListener("keydown", this.keydownHandler);
|
|
3492
|
+
}
|
|
3493
|
+
}, {
|
|
3494
|
+
key: "render",
|
|
3495
|
+
value: function render() {
|
|
3496
|
+
var _this2 = this;
|
|
3497
|
+
var _this$props6 = this.props,
|
|
3498
|
+
items = _this$props6.items,
|
|
3499
|
+
menuIndex = _this$props6.menuIndex,
|
|
3500
|
+
activeMenuIndex = _this$props6.activeMenuIndex;
|
|
3501
|
+
var selectedIndex = this.state.selectedIndex;
|
|
3502
|
+
var isCurrentMenuActive = menuIndex === activeMenuIndex;
|
|
3503
|
+
return /*#__PURE__*/jsx("div", {
|
|
3504
|
+
className: "neeto-editor-slash-commands__wrapper",
|
|
3505
|
+
"data-testid": "neeto-editor-slash-commands-wrapper",
|
|
3506
|
+
ref: this.menuRef,
|
|
3507
|
+
children: items.map(function (item, index) {
|
|
3508
|
+
var isLeafNode = isNotPresent(item.items);
|
|
3509
|
+
var nodeElement = /*#__PURE__*/createElement(MenuItem, {
|
|
3510
|
+
index: index,
|
|
3511
|
+
item: item,
|
|
3512
|
+
key: item.optionName,
|
|
3513
|
+
selectItem: function selectItem() {
|
|
3514
|
+
return _this2.selectItem(index);
|
|
3515
|
+
},
|
|
3516
|
+
selectedIndex: isCurrentMenuActive ? selectedIndex : -1,
|
|
3517
|
+
onHover: function onHover() {
|
|
3518
|
+
return _this2.setState({
|
|
3519
|
+
selectedIndex: index
|
|
3520
|
+
});
|
|
3521
|
+
}
|
|
3522
|
+
});
|
|
3523
|
+
if (isLeafNode) return nodeElement;
|
|
3524
|
+
return /*#__PURE__*/jsx(Tippy, {
|
|
3525
|
+
interactive: true,
|
|
3526
|
+
placement: "right",
|
|
3527
|
+
popperOptions: {
|
|
3528
|
+
modifiers: [fitToAvailableHeight]
|
|
3529
|
+
},
|
|
3530
|
+
theme: "light neeto-editor-slash-commands-tippy",
|
|
3531
|
+
visible: selectedIndex === index,
|
|
3532
|
+
content: /*#__PURE__*/jsx(Menu, _objectSpread$a(_objectSpread$a({}, _this2.props), {}, {
|
|
3533
|
+
items: item.items,
|
|
3534
|
+
menuIndex: menuIndex + 1
|
|
3535
|
+
})),
|
|
3536
|
+
onCreate: function onCreate(_ref) {
|
|
3537
|
+
var popper = _ref.popper;
|
|
3538
|
+
return popper.style.width = "max-content";
|
|
3539
|
+
},
|
|
3540
|
+
onHide: function onHide() {
|
|
3541
|
+
_this2.isSubmenuOpened = false;
|
|
3542
|
+
},
|
|
3543
|
+
onShow: function onShow() {
|
|
3544
|
+
_this2.isSubmenuOpened = true;
|
|
3545
|
+
},
|
|
3546
|
+
children: nodeElement
|
|
3547
|
+
}, item.optionName);
|
|
3548
|
+
})
|
|
3549
|
+
});
|
|
3550
|
+
}
|
|
3551
|
+
}]);
|
|
3552
|
+
}(React__default.Component); // eslint-disable-next-line react/display-name
|
|
3553
|
+
var MenuItem = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
3554
|
+
var item = _ref2.item,
|
|
3555
|
+
selectedIndex = _ref2.selectedIndex,
|
|
3556
|
+
index = _ref2.index,
|
|
3557
|
+
selectItem = _ref2.selectItem,
|
|
3558
|
+
onHover = _ref2.onHover;
|
|
3559
|
+
var Icon = item.Icon;
|
|
3560
|
+
return /*#__PURE__*/jsxs("button", {
|
|
3561
|
+
ref: ref,
|
|
3562
|
+
"data-testid": "neeto-editor-command-list-item-".concat(index),
|
|
3563
|
+
className: classnames("neeto-editor-slash-commands__item", {
|
|
3564
|
+
active: index === selectedIndex
|
|
3565
|
+
}),
|
|
3566
|
+
onClick: selectItem,
|
|
3567
|
+
onMouseEnter: onHover,
|
|
3568
|
+
children: [Icon && /*#__PURE__*/jsx(Icon, {
|
|
3569
|
+
size: 20
|
|
3570
|
+
}), /*#__PURE__*/jsx("span", {
|
|
3571
|
+
className: "neeto-editor-slash-commands__item-content",
|
|
3572
|
+
children: /*#__PURE__*/jsx("span", {
|
|
3573
|
+
className: "neeto-editor-slash-commands__item-title",
|
|
3574
|
+
"data-testid": "neeto-editor-command-list-item-block-heading",
|
|
3575
|
+
children: item.title
|
|
3576
|
+
})
|
|
3577
|
+
})]
|
|
3578
|
+
});
|
|
3579
|
+
});
|
|
3580
|
+
|
|
3581
|
+
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; }
|
|
3582
|
+
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(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; }
|
|
3583
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
3584
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
3585
|
+
var CommandsList = /*#__PURE__*/function (_React$Component) {
|
|
3586
|
+
function CommandsList() {
|
|
3587
|
+
var _this;
|
|
3588
|
+
_classCallCheck(this, CommandsList);
|
|
3589
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3590
|
+
args[_key] = arguments[_key];
|
|
3591
|
+
}
|
|
3592
|
+
_this = _callSuper(this, CommandsList, [].concat(args));
|
|
3593
|
+
_defineProperty(_this, "state", {
|
|
3594
|
+
activeMenuIndex: 0
|
|
3595
|
+
});
|
|
3596
|
+
_defineProperty(_this, "onKeyDown", function (_ref) {
|
|
3597
|
+
var event = _ref.event;
|
|
3598
|
+
return ["Enter", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(event.key);
|
|
3599
|
+
});
|
|
3600
|
+
_defineProperty(_this, "setActiveMenuIndex", function (index) {
|
|
3601
|
+
return _this.setState({
|
|
3602
|
+
activeMenuIndex: index
|
|
3603
|
+
});
|
|
3604
|
+
});
|
|
3605
|
+
return _this;
|
|
3606
|
+
}
|
|
3607
|
+
_inherits(CommandsList, _React$Component);
|
|
3608
|
+
return _createClass(CommandsList, [{
|
|
3609
|
+
key: "render",
|
|
3610
|
+
value: function render() {
|
|
3611
|
+
return /*#__PURE__*/jsx(Menu, _objectSpread$9(_objectSpread$9({}, this.props), {}, {
|
|
3612
|
+
activeMenuIndex: this.state.activeMenuIndex,
|
|
3613
|
+
items: this.props.items,
|
|
3614
|
+
menuIndex: 0,
|
|
3615
|
+
setActiveMenuIndex: this.setActiveMenuIndex
|
|
3616
|
+
}));
|
|
3617
|
+
}
|
|
3618
|
+
}]);
|
|
3619
|
+
}(React__default.Component);
|
|
3620
|
+
|
|
2991
3621
|
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; }
|
|
2992
3622
|
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(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; }
|
|
2993
3623
|
var CommandsPluginKey = new PluginKey("commands");
|
|
@@ -3056,7 +3686,13 @@ var SlashCommands = {
|
|
|
3056
3686
|
arrow: false,
|
|
3057
3687
|
zIndex: 99999,
|
|
3058
3688
|
role: "dropdown",
|
|
3059
|
-
theme: "light neeto-editor-slash-commands-tippy"
|
|
3689
|
+
theme: "light neeto-editor-slash-commands-tippy",
|
|
3690
|
+
popperOptions: {
|
|
3691
|
+
modifiers: [{
|
|
3692
|
+
name: "flip",
|
|
3693
|
+
enabled: false
|
|
3694
|
+
}, fitToAvailableHeight]
|
|
3695
|
+
}
|
|
3060
3696
|
});
|
|
3061
3697
|
highlightFocussedNode();
|
|
3062
3698
|
},
|