Skip to content

Commit

Permalink
Add pasteboard APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanzhong committed Jan 23, 2025
1 parent a1c4053 commit 97769b3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Add `markedit-api` to your (TypeScript) project's devDependencies:
```json
{
"devDependencies": {
"markedit-api": "https://github.com/MarkEdit-app/MarkEdit-api#v0.7.0"
"markedit-api": "https://github.com/MarkEdit-app/MarkEdit-api#v0.8.0"
}
}
```
Expand All @@ -46,6 +46,10 @@ interface MarkEdit {
onEditorReady(listener: (editorView: EditorView) => void): void;
// Get information of the current file.
getFileInfo(): Promise<FileInfo | undefined>;
// Get all items from the native pasteboard.
getPasteboardItems(): Promise<PasteboardItem[]>;
// Get the string from the native pasteboard.
getPasteboardString(): Promise<string | undefined>;
// Add an extension to MarkEdit.
addExtension(extension: Extension): void;
// Add a Markdown config to MarkEdit.
Expand Down
32 changes: 32 additions & 0 deletions markedit.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ export interface MarkEdit {
*/
getFileInfo(): Promise<FileInfo | undefined>;

/**
* Get all items from the native pasteboard.
* @returns The items from the native (general) pasteboard.
*/
getPasteboardItems(): Promise<PasteboardItem[]>;

/**
* Get the string from the native pasteboard.
* @returns The string from the native (general) pasteboard, if applicable.
*/
getPasteboardString(): Promise<string | undefined>;

/**
* Add an extension to MarkEdit.
* @param extension CodeMirror extension.
Expand Down Expand Up @@ -226,6 +238,26 @@ export type FileInfo = {
modificationDate: Date;
};

/**
* Represents a native pasteboard item.
*/
export type PasteboardItem = {
/**
* Type name, such as `public.utf8-plain-text`.
*/
type: string;

/**
* Base64 representation of the pasteboard data.
*/
data: string;

/**
* String representation of the pasteboard data, if applicable.
*/
string?: string;
};

/**
* Represents a portion of text.
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "markedit-api",
"version": "0.7.0",
"version": "0.8.0",
"description": "Type definitions for the latest MakrEdit API.",
"main": "main.ts",
"types": "markedit.d.ts",
Expand Down

0 comments on commit 97769b3

Please sign in to comment.