mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-03-27 21:31:49 +01:00
Less jank typing
This commit is contained in:
parent
deba27c24d
commit
4063956d37
1 changed files with 14 additions and 18 deletions
|
@ -12,7 +12,7 @@ import { useAtom, useAtomValue } from 'jotai';
|
||||||
import { isKeyHotkey } from 'is-hotkey';
|
import { isKeyHotkey } from 'is-hotkey';
|
||||||
import { EventType, IContent, MsgType, RelationType, Room, IMentions } from 'matrix-js-sdk';
|
import { EventType, IContent, MsgType, RelationType, Room, IMentions } from 'matrix-js-sdk';
|
||||||
import { ReactEditor } from 'slate-react';
|
import { ReactEditor } from 'slate-react';
|
||||||
import {Transforms, Editor, Descendant} from 'slate';
|
import {Transforms, Editor} from 'slate';
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Dialog,
|
Dialog,
|
||||||
|
@ -96,12 +96,8 @@ import colorMXID from '../../../util/colorMXID';
|
||||||
import {
|
import {
|
||||||
getAllParents,
|
getAllParents,
|
||||||
getMemberDisplayName,
|
getMemberDisplayName,
|
||||||
parseReplyBody,
|
|
||||||
parseReplyFormattedBody,
|
|
||||||
trimReplyFromBody,
|
trimReplyFromBody,
|
||||||
trimReplyFromFormattedBody,
|
|
||||||
} from '../../utils/room';
|
} from '../../utils/room';
|
||||||
import { sanitizeText } from '../../utils/sanitize';
|
|
||||||
import { CommandAutocomplete } from './CommandAutocomplete';
|
import { CommandAutocomplete } from './CommandAutocomplete';
|
||||||
import { Command, SHRUG, TABLEFLIP, UNFLIP, useCommands } from '../../hooks/useCommands';
|
import { Command, SHRUG, TABLEFLIP, UNFLIP, useCommands } from '../../hooks/useCommands';
|
||||||
import { mobileOrTablet } from '../../utils/user-agent';
|
import { mobileOrTablet } from '../../utils/user-agent';
|
||||||
|
@ -109,7 +105,10 @@ import { useElementSizeObserver } from '../../hooks/useElementSizeObserver';
|
||||||
import { ReplyLayout, ThreadIndicator } from '../../components/message';
|
import { ReplyLayout, ThreadIndicator } from '../../components/message';
|
||||||
import { roomToParentsAtom } from '../../state/room/roomToParents';
|
import { roomToParentsAtom } from '../../state/room/roomToParents';
|
||||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||||
import {CustomElement, InlineElement, MentionElement, ParagraphElement} from '../../components/editor/slate';
|
import {
|
||||||
|
CustomElement,
|
||||||
|
MentionElement,
|
||||||
|
} from '../../components/editor/slate';
|
||||||
|
|
||||||
interface RoomInputProps {
|
interface RoomInputProps {
|
||||||
editor: Editor;
|
editor: Editor;
|
||||||
|
@ -298,19 +297,16 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||||
};
|
};
|
||||||
const userIdMentions = new Set<string>();
|
const userIdMentions = new Set<string>();
|
||||||
let mentionsRoom = false;
|
let mentionsRoom = false;
|
||||||
editor.children.forEach((node: any): void => {
|
editor.children.forEach((node: CustomElement): void => {
|
||||||
if (node.type === "paragraph") {
|
node.children?.forEach((child: MentionElement): void => {
|
||||||
node.children.forEach((child: any): void => {
|
if (child.type === "mention") {
|
||||||
if (child.type !== undefined && child.type === "mention") {
|
if(child.name === "@room" && !child.id?.startsWith("@")) {
|
||||||
if(child.name === "@room" && !child.id.startswith("@")) {
|
mentionsRoom = true
|
||||||
// Room mention, not MXID
|
} else {
|
||||||
mentionsRoom = true
|
userIdMentions.add(child.id)
|
||||||
} else {
|
|
||||||
userIdMentions.add(child.id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
const mMentions: IMentions = {}
|
const mMentions: IMentions = {}
|
||||||
if (userIdMentions.size > 0) {
|
if (userIdMentions.size > 0) {
|
||||||
|
|
Loading…
Reference in a new issue