-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamplePlugin.ts
More file actions
73 lines (57 loc) · 2.38 KB
/
Copy pathExamplePlugin.ts
File metadata and controls
73 lines (57 loc) · 2.38 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
67
68
69
70
71
72
73
/// <reference path="../../types/colibri.d.ts" />
namespace myplugin.example {
export const CAT_EXAMPLE = "myplugin.example";
export const CMD_HELLO = "myplugin.example.hello";
export class ExamplePlugin extends colibri.Plugin {
private static _instance = new ExamplePlugin();
static getInstance() {
return this._instance;
}
constructor() {
super("myplugin.example");
}
registerExtensions(reg: colibri.ExtensionRegistry) {
// Contribute a custom command to the editor.
reg.addExtension(new colibri.ui.ide.commands.CommandExtension(manager => {
manager.addCategory({
id: CAT_EXAMPLE,
name: "Example Plugin"
});
manager.add({
command: {
id: CMD_HELLO,
category: CAT_EXAMPLE,
name: "Hello From Plugin",
tooltip: "Example custom command contributed by a third-party plugin."
},
handler: {
executeFunc: args => {
alert("Hello from myplugin.example!");
}
},
keys: {
control: true,
alt: true,
key: "H"
}
});
}));
// Register the ".todo" content type so the editor can recognize it.
reg.addExtension(new colibri.core.ContentTypeExtension(
[new colibri.core.ContentTypeResolverByExtension(
"myplugin.example.TodoContentTypeResolver",
[["todo", CONTENT_TYPE_TODO]])],
5));
// Register the custom Todo editor.
reg.addExtension(new colibri.ui.ide.EditorExtension([
TodoEditor.getFactory()
]));
// Add a "Todo File" entry to the New File wizard / Files view "New..." menu.
reg.addExtension(new NewTodoFileExtension());
// Register the Todo editor commands.
reg.addExtension(new colibri.ui.ide.commands.CommandExtension(
TodoEditor.registerCommands));
}
}
colibri.Platform.addPlugin(ExamplePlugin.getInstance());
}