@selfcommunity/react-ui 0.7.0-alpha.333 → 0.7.0-alpha.334
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.
|
@@ -7,12 +7,12 @@ const react_core_1 = require("@selfcommunity/react-core");
|
|
|
7
7
|
const lexical_1 = require("lexical");
|
|
8
8
|
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
9
9
|
const utils_1 = require("@lexical/utils");
|
|
10
|
-
const react_dom_1 = require("react-dom");
|
|
11
10
|
const MentionNode_1 = require("../nodes/MentionNode");
|
|
12
11
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
13
12
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
14
13
|
const material_1 = require("@mui/material");
|
|
15
14
|
const styles_1 = require("@mui/material/styles");
|
|
15
|
+
const ClickAwayListener_1 = tslib_1.__importDefault(require("@mui/material/ClickAwayListener"));
|
|
16
16
|
const PUNCTUATION = '\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;';
|
|
17
17
|
const NAME = '\\b[A-Z][^\\s' + PUNCTUATION + ']';
|
|
18
18
|
const DocumentMentionsRegex = {
|
|
@@ -528,7 +528,9 @@ function useMentions(editor, anchorClassName = null) {
|
|
|
528
528
|
if (resolution === null || editor === null) {
|
|
529
529
|
return null;
|
|
530
530
|
}
|
|
531
|
-
return (
|
|
531
|
+
return (react_1.default.createElement(ClickAwayListener_1.default, { onClickAway: closeTypeahead },
|
|
532
|
+
react_1.default.createElement(material_1.Portal, { container: anchorElementRef.current },
|
|
533
|
+
react_1.default.createElement(Root, { close: closeTypeahead, resolution: resolution, editor: editor, className: classes.root }))));
|
|
532
534
|
}
|
|
533
535
|
function MentionsPlugin() {
|
|
534
536
|
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
@@ -3,12 +3,12 @@ import { useIsomorphicLayoutEffect } from '@selfcommunity/react-core';
|
|
|
3
3
|
import { $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_LOW, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND } from 'lexical';
|
|
4
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
5
5
|
import { mergeRegister } from '@lexical/utils';
|
|
6
|
-
import { createPortal } from 'react-dom';
|
|
7
6
|
import { createMentionNode, MentionNode } from '../nodes/MentionNode';
|
|
8
7
|
import { http, Endpoints } from '@selfcommunity/api-services';
|
|
9
8
|
import classNames from 'classnames';
|
|
10
|
-
import { Avatar } from '@mui/material';
|
|
9
|
+
import { Avatar, Portal } from '@mui/material';
|
|
11
10
|
import { styled } from '@mui/material/styles';
|
|
11
|
+
import ClickAwayListener from '@mui/material/ClickAwayListener';
|
|
12
12
|
const PUNCTUATION = '\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;';
|
|
13
13
|
const NAME = '\\b[A-Z][^\\s' + PUNCTUATION + ']';
|
|
14
14
|
const DocumentMentionsRegex = {
|
|
@@ -521,7 +521,9 @@ function useMentions(editor, anchorClassName = null) {
|
|
|
521
521
|
if (resolution === null || editor === null) {
|
|
522
522
|
return null;
|
|
523
523
|
}
|
|
524
|
-
return
|
|
524
|
+
return (React.createElement(ClickAwayListener, { onClickAway: closeTypeahead },
|
|
525
|
+
React.createElement(Portal, { container: anchorElementRef.current },
|
|
526
|
+
React.createElement(Root, { close: closeTypeahead, resolution: resolution, editor: editor, className: classes.root }))));
|
|
525
527
|
}
|
|
526
528
|
export default function MentionsPlugin() {
|
|
527
529
|
const [editor] = useLexicalComposerContext();
|