-
-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathClear.ts
More file actions
32 lines (26 loc) · 856 Bytes
/
Clear.ts
File metadata and controls
32 lines (26 loc) · 856 Bytes
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
import {
Action,
ActionPreferences,
ActionReturnValue,
Graph,
TypedSelection,
} from "../typings/Types";
import { ensureSingleEditor } from "../util/targetUtils";
import { setSelectionsAndFocusEditor } from "../util/setSelectionsAndFocusEditor";
export default class Clear implements Action {
getTargetPreferences: () => ActionPreferences[] = () => [{ insideOutsideType: "inside" }];
constructor(private graph: Graph) {
this.run = this.run.bind(this);
}
async run([targets]: [TypedSelection[]]): Promise<ActionReturnValue> {
const editor = ensureSingleEditor(targets);
const { thatMark } = await this.graph.actions.remove.run([targets]);
if (thatMark != null) {
await setSelectionsAndFocusEditor(
editor,
thatMark.map(({ selection }) => selection)
);
}
return { thatMark };
}
}