Newer
Older
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
import React from "react";
import { Tool } from "../structures/editor/tools/tool";
import { ToolBar } from "./toolbar";
export class Editor extends React.Component {
state: {
currentTool: Tool;
previousTool: Tool;
};
constructor(props: any) {
super(props);
}
/**
* Sets current tool. Select events not triggered if already selected.
* @param tool New tool to select.
*/
public setTool(tool: Tool) {
if (this.state.currentTool == tool) {
return;
}
this.setState({ currentTool: tool });
}
/**
* If exists, sets previously selected tool as current tool.
*/
public setPreviousTool() {
if (this.state.previousTool === undefined) {
return;
}
this.setTool(this.state.previousTool);
}
/**
* @returns Tool that is currently selected.
*/
public getCurrentTool(): Tool {
return this.state.currentTool;
}
render(): React.ReactNode {
return (
<div id="ks-editor">
<ToolBar editor={this}></ToolBar>
</div>
);
}
}