mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-16 18:06:17 +02:00
Cleanup tests
This commit is contained in:
parent
83239b2d36
commit
9d3ec0ffdc
@ -25,7 +25,7 @@ import { Layout } from "../../../settings/enums/Layout";
|
||||
import TimelinePanel from "../../structures/TimelinePanel";
|
||||
import { type E2EStatus } from "../../../utils/ShieldUtils";
|
||||
import EditorStateTransfer from "../../../utils/EditorStateTransfer";
|
||||
import RoomContext, { TimelineRenderingType } from "../../../contexts/RoomContext";
|
||||
import RoomContext from "../../../contexts/RoomContext";
|
||||
import dis from "../../../dispatcher/dispatcher";
|
||||
import { _t } from "../../../languageHandler";
|
||||
import { type ActionPayload } from "../../../dispatcher/payloads";
|
||||
|
||||
@ -6,7 +6,13 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import React, { createRef, type KeyboardEvent, type SyntheticEvent, type RefAttributes, ReactElement } from "react";
|
||||
import React, {
|
||||
createRef,
|
||||
type KeyboardEvent,
|
||||
type SyntheticEvent,
|
||||
type RefAttributes,
|
||||
type ReactElement,
|
||||
} from "react";
|
||||
import {
|
||||
type MatrixEvent,
|
||||
type IEventRelation,
|
||||
|
||||
@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
|
||||
import classNames from "classnames";
|
||||
import { type IEventRelation } from "matrix-js-sdk/src/matrix";
|
||||
import React, { type JSX, type RefObject, type ReactNode } from "react";
|
||||
import React, { type JSX, type RefObject, type ReactNode, useContext } from "react";
|
||||
|
||||
import { useComposerFunctions } from "../hooks/useComposerFunctions";
|
||||
import { useIsFocused } from "../hooks/useIsFocused";
|
||||
@ -19,6 +19,7 @@ import { type ComposerFunctions } from "../types";
|
||||
import { Editor } from "./Editor";
|
||||
import { WysiwygAutocomplete } from "./WysiwygAutocomplete";
|
||||
import { useSettingValue } from "../../../../../hooks/useSettings";
|
||||
import { RoomUploadContext } from "../../../../../viewmodels/room/RoomUploadViewModel";
|
||||
|
||||
interface PlainTextComposerProps {
|
||||
disabled?: boolean;
|
||||
@ -46,6 +47,7 @@ export function PlainTextComposer({
|
||||
eventRelation,
|
||||
}: PlainTextComposerProps): JSX.Element {
|
||||
const isAutoReplaceEmojiEnabled = useSettingValue("MessageComposerInput.autoReplaceEmoji");
|
||||
const uploadContext = useContext(RoomUploadContext);
|
||||
const {
|
||||
ref: editorRef,
|
||||
autocompleteRef,
|
||||
@ -61,7 +63,7 @@ export function PlainTextComposer({
|
||||
handleMention,
|
||||
handleAtRoomMention,
|
||||
handleEmoji,
|
||||
} = usePlainTextListeners(initialContent, onChange, onSend, isAutoReplaceEmojiEnabled);
|
||||
} = usePlainTextListeners(initialContent, onChange, onSend, isAutoReplaceEmojiEnabled, uploadContext || undefined);
|
||||
const composerFunctions = useComposerFunctions(editorRef, setContent);
|
||||
usePlainTextInitialization(initialContent, editorRef);
|
||||
useSetCursorPosition(disabled, editorRef);
|
||||
|
||||
@ -15,7 +15,7 @@ import type Autocomplete from "../../Autocomplete";
|
||||
import { handleClipboardEvent, handleEventWithAutocomplete, isEventToHandleAsClipboardEvent } from "./utils";
|
||||
import { useSuggestion } from "./useSuggestion";
|
||||
import { isNotNull, isNotUndefined } from "../../../../../Typeguards";
|
||||
import { useRoomUploadViewModel } from "../../../../../viewmodels/room/RoomUploadViewModel.tsx";
|
||||
import { RoomUploadViewModel, useRoomUploadViewModel } from "../../../../../viewmodels/room/RoomUploadViewModel.tsx";
|
||||
|
||||
function isDivElement(target: EventTarget): target is HTMLDivElement {
|
||||
return target instanceof HTMLDivElement;
|
||||
@ -45,6 +45,7 @@ export function usePlainTextListeners(
|
||||
onChange?: (content: string) => void,
|
||||
onSend?: () => void,
|
||||
isAutoReplaceEmojiEnabled?: boolean,
|
||||
roomUploadVM?: RoomUploadViewModel,
|
||||
): {
|
||||
ref: RefObject<HTMLDivElement | null>;
|
||||
autocompleteRef: RefObject<Autocomplete | null>;
|
||||
@ -61,8 +62,6 @@ export function usePlainTextListeners(
|
||||
onSelect: (this: void, event: SyntheticEvent<HTMLDivElement>) => void;
|
||||
suggestion: MappedSuggestion | null;
|
||||
} {
|
||||
const roomUploadVM = useRoomUploadViewModel();
|
||||
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const autocompleteRef = useRef<Autocomplete>(null);
|
||||
const [content, setContent] = useState<string | undefined>(initialContent);
|
||||
@ -116,7 +115,7 @@ export function usePlainTextListeners(
|
||||
const { nativeEvent } = event;
|
||||
let imagePasteWasHandled = false;
|
||||
|
||||
if (isEventToHandleAsClipboardEvent(nativeEvent)) {
|
||||
if (roomUploadVM && isEventToHandleAsClipboardEvent(nativeEvent)) {
|
||||
const data =
|
||||
nativeEvent instanceof ClipboardEvent ? nativeEvent.clipboardData : nativeEvent.dataTransfer;
|
||||
imagePasteWasHandled = handleClipboardEvent(nativeEvent, data, roomUploadVM);
|
||||
|
||||
@ -659,8 +659,8 @@ export function mkMessage({
|
||||
|
||||
export function mkStubRoom(
|
||||
roomId: string | null | undefined = null,
|
||||
name: string | undefined,
|
||||
client: MatrixClient | undefined,
|
||||
name?: string | undefined,
|
||||
client?: MatrixClient | undefined,
|
||||
state?: RoomState | undefined,
|
||||
): Room {
|
||||
const stubTimeline = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user