Repository navigation
Expand file tree
/
Copy pathNewTodoFileExtension.ts
More file actions
52 lines (42 loc) · 1.73 KB
/
Copy pathNewTodoFileExtension.ts
File metadata and controls
52 lines (42 loc) · 1.73 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
namespace myplugin.example {
import files = phasereditor2d.files;
/**
* Contributes a "Todo File" entry to the editor's New File wizard.
*
* Once registered, the user can create a ".todo" file from:
* - the Files view "New..." context menu,
* - the New File dialog (Ctrl+Alt+N),
* - the New File toolbar button.
*
* The created file is opened automatically in the TodoEditor.
*
* This is the same mechanism used by the built-in editors (Scene File,
* Asset Pack File, etc.). It requires the bundled phasereditor2d.files.d.ts
* declarations, since the extension class lives in the phasereditor2d.files
* plugin (not in colibri).
*/
export class NewTodoFileExtension extends files.ui.dialogs.NewFileContentExtension {
constructor() {
super({
dialogName: "Todo File",
dialogIconDescriptor: colibri.ColibriPlugin.getInstance().getIconDescriptor(colibri.ICON_FILE),
initialFileName: "tasks",
fileExtension: "todo",
});
}
getCreateFileContentFunc(): (args: files.ui.dialogs.ICreateFileContentArgs) => string {
return () => {
const model = new TodoModel();
model.addTask(new TodoTask(
"My first task",
"Select this task and edit it in the Inspector view.",
"todo"));
return JSON.stringify(model.toJSON(), null, 4);
};
}
getInitialFileLocation() {
// Default to the folder of the most recently edited .todo file.
return super.findInitialFileLocationBasedOnContentType(CONTENT_TYPE_TODO);
}
}
}