-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEditorActions.ts
68 lines (46 loc) · 2.08 KB
/
EditorActions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { action } from "typesafe-actions";
import { YarnNode } from "./YarnNode";
/** Types of messages that can be sent from the editor to the extension */
export enum YarnEditorMessageTypes {
/** Called when a node is being opened in a VSCode text editor */
OpenNode = "OpenNode",
/** Set a specific node */
SetNode = "SetNode",
/** Set all nodes */
SetNodes = "SetNodes",
/** Delete a specific node */
DeleteNode = "DeleteNode",
/** Create a new node */
CreateNewNode = "CreateNewNode",
/** Set the color for a node */
SetNodeColor = "SetNodeColor",
/** Set the position for a node */
SetNodePosition = "SetNodePosition",
/** Change a node's title */
RenameNode = "RenameNode",
/** Add/remove a tag from a node */
ToggleTagOnNode = "ToggleTagOnNode",
/** Prompt the user for new tags and add them to the node */
PromptForNewTags = "PromptForNewTags",
/** Add a specific tag to the node */
AddTagToNode = "AddTagToNode",
}
export const setNodes = (nodes: YarnNode[]) =>
action(YarnEditorMessageTypes.SetNodes, { nodes });
export const setNode = (node: YarnNode) =>
action(YarnEditorMessageTypes.SetNode, { node });
export const openNode = (nodeId: string) =>
action(YarnEditorMessageTypes.OpenNode, { nodeId });
export const deleteNode = (nodeTitle: string) =>
action(YarnEditorMessageTypes.DeleteNode, { nodeTitle });
export const createNewNode = () => action(YarnEditorMessageTypes.CreateNewNode);
export const setNodeColor = (nodeTitle: string, colorIndex: number) =>
action(YarnEditorMessageTypes.SetNodeColor, { nodeTitle, colorIndex });
export const setNodePosition = (nodeTitle: string, x: number, y: number) =>
action(YarnEditorMessageTypes.SetNodePosition, { nodeTitle, x, y });
export const renameNode = (nodeTitle: string) =>
action(YarnEditorMessageTypes.RenameNode, { nodeTitle });
export const toggleTagOnNode = (nodeTitle: string, tag: string) =>
action(YarnEditorMessageTypes.ToggleTagOnNode, { nodeTitle, tag });
export const promptForNewTags = (nodeTitle: string) =>
action(YarnEditorMessageTypes.PromptForNewTags, { nodeTitle });