feat(#2): disable commands
parent
12544fcd30
commit
a9105d24ab
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"src/components/views/auth/AuthFooter.tsx": "src/components/views/auth/VectorAuthFooter.tsx",
|
||||
"src/components/views/auth/AuthHeaderLogo.tsx": "src/components/views/auth/VectorAuthHeaderLogo.tsx",
|
||||
"src/components/views/auth/AuthPage.tsx": "src/components/views/auth/VectorAuthPage.tsx"
|
||||
"src/components/views/auth/AuthPage.tsx": "src/components/views/auth/VectorAuthPage.tsx",
|
||||
"src/components/views/rooms/Autocomplete.tsx": "src/components/views/rooms/Autocomplete.tsx",
|
||||
"src/editor/commands.tsx": "src/editor/commands.tsx"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
import React from "react";
|
||||
|
||||
export const generateCompletionDomId = (n: number): string => `mx_Autocomplete_Completion_${n}`;
|
||||
|
||||
export default class Autocomplete extends React.PureComponent {
|
||||
public constructor(props: {} | Readonly<{}>) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
// list of completionResults, each containing completions
|
||||
completions: [],
|
||||
|
||||
// array of completions, so we can look up current selection by offset quickly
|
||||
completionList: [],
|
||||
|
||||
// how far down the completion list we are (THIS IS 1-INDEXED!)
|
||||
selectionOffset: 1,
|
||||
|
||||
// whether we should show completions if they're available
|
||||
shouldShowCompletions: true,
|
||||
|
||||
hide: false,
|
||||
|
||||
forceComplete: false,
|
||||
};
|
||||
}
|
||||
|
||||
public render(): React.ReactNode {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
import { IContent, MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { Command, getCommand } from "matrix-react-sdk/src/SlashCommands";
|
||||
import EditorModel from "matrix-react-sdk/src/editor/model";
|
||||
import { Type } from "matrix-react-sdk/src/editor/parts";
|
||||
|
||||
export function isSlashCommand(model: EditorModel): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getSlashCommand(model: EditorModel): [Command | undefined, string | undefined, string] {
|
||||
const commandText = model.parts.reduce((text, part) => {
|
||||
// use mxid to textify user pills in a command and room alias/id for room pills
|
||||
if (part.type === Type.UserPill || part.type === Type.RoomPill) {
|
||||
return text + part.resourceId;
|
||||
}
|
||||
return text + part.text;
|
||||
}, "");
|
||||
const { cmd, args } = getCommand(commandText);
|
||||
return [cmd, args, commandText];
|
||||
}
|
||||
|
||||
export async function runSlashCommand(
|
||||
matrixClient: MatrixClient,
|
||||
cmd: Command,
|
||||
args: string | undefined,
|
||||
roomId: string,
|
||||
threadId: string | null,
|
||||
): Promise<[content: IContent | null, success: boolean]> {
|
||||
return [null, false];
|
||||
}
|
||||
|
||||
export async function shouldSendAnyway(commandText: string): Promise<boolean> {
|
||||
return true;
|
||||
}
|
Loading…
Reference in New Issue