mirror of
https://github.com/usememos/memos.git
synced 2025-12-16 13:48:41 +08:00
36 lines
896 B
TypeScript
36 lines
896 B
TypeScript
/**
|
|
* Command type for slash commands in the editor
|
|
*/
|
|
export interface Command {
|
|
name: string;
|
|
run: () => string;
|
|
cursorOffset?: number;
|
|
}
|
|
|
|
export const editorCommands: Command[] = [
|
|
{
|
|
name: "todo",
|
|
run: () => "- [ ] ",
|
|
cursorOffset: 6, // Places cursor after "- [ ] " to start typing task
|
|
},
|
|
{
|
|
name: "code",
|
|
run: () => "```\n\n```",
|
|
cursorOffset: 4, // Places cursor on empty line between code fences
|
|
},
|
|
{
|
|
name: "link",
|
|
run: () => "[text](url)",
|
|
cursorOffset: 1, // Places cursor after "[" to type link text
|
|
},
|
|
{
|
|
name: "table",
|
|
run: () => "| Header | Header |\n| ------ | ------ |\n| Cell | Cell |",
|
|
cursorOffset: 1, // Places cursor after first "|" to edit first header
|
|
},
|
|
{
|
|
name: "highlight",
|
|
run: () => "==text==",
|
|
cursorOffset: 2, // Places cursor between "==" markers to type highlighted text
|
|
},
|
|
];
|