-
-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathCall.ts
More file actions
39 lines (34 loc) · 862 Bytes
/
Call.ts
File metadata and controls
39 lines (34 loc) · 862 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
33
34
35
36
37
38
39
import {
Action,
ActionReturnValue,
ActionPreferences,
Graph,
TypedSelection,
} from "../typings/Types";
import { ensureSingleTarget } from "../util/targetUtils";
export default class Call implements Action {
getTargetPreferences: () => ActionPreferences[] = () => [
{ insideOutsideType: "inside" },
{ insideOutsideType: "inside" },
];
constructor(private graph: Graph) {
this.run = this.run.bind(this);
}
async run([sources, destinations]: [
TypedSelection[],
TypedSelection[]
]): Promise<ActionReturnValue> {
ensureSingleTarget(sources);
const { returnValue: texts } = await this.graph.actions.getText.run(
[sources],
{
showDecorations: false,
}
);
return this.graph.actions.wrapWithPairedDelimiter.run(
[destinations],
texts[0] + "(",
")"
);
}
}