-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathcanvas.ts
More file actions
66 lines (50 loc) · 1.42 KB
/
Copy pathcanvas.ts
File metadata and controls
66 lines (50 loc) · 1.42 KB
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
import { Sections, Events } from 'types';
import { BaseEventHandle } from './base';
type HandleEditArgs = {
id?: string;
path: string;
value: unknown;
};
class CanvasHandleEvents extends BaseEventHandle {
constructor() {
super();
this.reorder = this.reorder.bind(this);
}
add = (sectionType: Sections) => {
this.emit(Events.CANVAS_ADD_SECTION, sectionType);
};
remove = (sectionId: string) => {
this.emit(Events.CANVAS_REMOVE_SECTION, sectionId);
};
loadImportFile = () => {
this.emit(Events.CANVAS_IMPORT_README_FILE);
};
import = (event: React.ChangeEvent<HTMLInputElement>) => {
this.emit(Events.CANVAS_IMPORT_README, event);
};
clear = () => {
this.emit(Events.CANVAS_CLEAR_SECTIONS);
};
edit = ({ path, ...rest }: HandleEditArgs) => {
this.emit(Events.CANVAS_EDIT_SECTION, {
...rest,
path: `props.${path}`,
});
};
duplicate = (sectionId: string) => {
this.emit(Events.CANVAS_DUPLICATE_SECTION, sectionId);
};
reorder = (order: string[]) => {
this.emit(Events.CANVAS_REORDER_SECTIONS, order);
};
currentSection = (sectionId: string) => {
this.emit(Events.CANVAS_SET_CURRENT_SECTION, sectionId);
};
up = (sectionId: string) => {
this.emit(Events.CANVAS_MOVE_SECTION_UP, sectionId);
};
down = (sectionId: string) => {
this.emit(Events.CANVAS_MOVE_SECTION_DOWN, sectionId);
};
}
export { CanvasHandleEvents };