Skip to content

Commit a1c4053

Browse files
committed
Add getFileInfo for file information
1 parent 4ad0c4a commit a1c4053

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Add `markedit-api` to your (TypeScript) project's devDependencies:
1919
```json
2020
{
2121
"devDependencies": {
22-
"markedit-api": "https://github.com/MarkEdit-app/MarkEdit-api#v0.6.0"
22+
"markedit-api": "https://github.com/MarkEdit-app/MarkEdit-api#v0.7.0"
2323
}
2424
}
2525
```
@@ -44,6 +44,8 @@ interface MarkEdit {
4444
lezer: { common, highlight, markdown, lr };
4545
// Get notified when the editor is initialized.
4646
onEditorReady(listener: (editorView: EditorView) => void): void;
47+
// Get information of the current file.
48+
getFileInfo(): Promise<FileInfo | undefined>;
4749
// Add an extension to MarkEdit.
4850
addExtension(extension: Extension): void;
4951
// Add a Markdown config to MarkEdit.

markedit.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ export interface MarkEdit {
9797
*/
9898
onEditorReady(listener: (editorView: EditorView) => void): void;
9999

100+
/**
101+
* Get information of the current file.
102+
* @returns The file information, or undefined for unsaved new drafts.
103+
*/
104+
getFileInfo(): Promise<FileInfo | undefined>;
105+
100106
/**
101107
* Add an extension to MarkEdit.
102108
* @param extension CodeMirror extension.
@@ -210,6 +216,16 @@ export interface TextEditable {
210216
redo(): void;
211217
}
212218

219+
/**
220+
* Information of a file in the file system.
221+
*/
222+
export type FileInfo = {
223+
filePath: string;
224+
fileSize: number;
225+
creationDate: Date;
226+
modificationDate: Date;
227+
};
228+
213229
/**
214230
* Represents a portion of text.
215231
*/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "markedit-api",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Type definitions for the latest MakrEdit API.",
55
"main": "main.ts",
66
"types": "markedit.d.ts",

0 commit comments

Comments
 (0)