Skip to content

Commit 97769b3

Browse files
committed
Add pasteboard APIs
1 parent a1c4053 commit 97769b3

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

README.md

Lines changed: 5 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.7.0"
22+
"markedit-api": "https://github.com/MarkEdit-app/MarkEdit-api#v0.8.0"
2323
}
2424
}
2525
```
@@ -46,6 +46,10 @@ interface MarkEdit {
4646
onEditorReady(listener: (editorView: EditorView) => void): void;
4747
// Get information of the current file.
4848
getFileInfo(): Promise<FileInfo | undefined>;
49+
// Get all items from the native pasteboard.
50+
getPasteboardItems(): Promise<PasteboardItem[]>;
51+
// Get the string from the native pasteboard.
52+
getPasteboardString(): Promise<string | undefined>;
4953
// Add an extension to MarkEdit.
5054
addExtension(extension: Extension): void;
5155
// Add a Markdown config to MarkEdit.

markedit.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ export interface MarkEdit {
103103
*/
104104
getFileInfo(): Promise<FileInfo | undefined>;
105105

106+
/**
107+
* Get all items from the native pasteboard.
108+
* @returns The items from the native (general) pasteboard.
109+
*/
110+
getPasteboardItems(): Promise<PasteboardItem[]>;
111+
112+
/**
113+
* Get the string from the native pasteboard.
114+
* @returns The string from the native (general) pasteboard, if applicable.
115+
*/
116+
getPasteboardString(): Promise<string | undefined>;
117+
106118
/**
107119
* Add an extension to MarkEdit.
108120
* @param extension CodeMirror extension.
@@ -226,6 +238,26 @@ export type FileInfo = {
226238
modificationDate: Date;
227239
};
228240

241+
/**
242+
* Represents a native pasteboard item.
243+
*/
244+
export type PasteboardItem = {
245+
/**
246+
* Type name, such as `public.utf8-plain-text`.
247+
*/
248+
type: string;
249+
250+
/**
251+
* Base64 representation of the pasteboard data.
252+
*/
253+
data: string;
254+
255+
/**
256+
* String representation of the pasteboard data, if applicable.
257+
*/
258+
string?: string;
259+
};
260+
229261
/**
230262
* Represents a portion of text.
231263
*/

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.7.0",
3+
"version": "0.8.0",
44
"description": "Type definitions for the latest MakrEdit API.",
55
"main": "main.ts",
66
"types": "markedit.d.ts",

0 commit comments

Comments
 (0)