From e39ff4dc72142aca197bf18a1d75bc7a5b477f62 Mon Sep 17 00:00:00 2001 From: Gnohz Gniy <0x00eeee@gmail.com> Date: Sun, 15 Sep 2024 17:18:41 +0800 Subject: [PATCH] Expose onEditorReady function --- README.md | 4 +++- main.ts | 2 +- markedit.d.ts | 8 +++++++- package.json | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ff9dcfe..06fe091 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Add `markedit-api` to your (TypeScript) project's devDependencies: ```json { "devDependencies": { - "markedit-api": "https://github.com/MarkEdit-app/MarkEdit-api#v0.3.0" + "markedit-api": "https://github.com/MarkEdit-app/MarkEdit-api#v0.4.0" } } ``` @@ -40,6 +40,8 @@ interface MarkEdit { codemirror: { view, state, language, commands, search }; // Lezer modules used by MarkEdit. lezer: { common, highlight, markdown, lr }; + // Get notified when the editor is initialized. + onEditorReady: (listener: (editorView: EditorView) => void) => void; // Add an extension to MarkEdit. addExtension: (extension: Extension) => void; // Add a Markdown config to MarkEdit. diff --git a/main.ts b/main.ts index 8fde85a..baa8c32 100644 --- a/main.ts +++ b/main.ts @@ -1 +1 @@ -export const MarkEdit = {}; +export const MarkEdit = { /* stub */ }; diff --git a/markedit.d.ts b/markedit.d.ts index e3d4eb7..d3ef4ab 100644 --- a/markedit.d.ts +++ b/markedit.d.ts @@ -79,7 +79,13 @@ export interface MarkEdit { * The `@lezer/lr` module. */ lr: typeof lezerLr; - }, + }; + + /** + * Get notified when the editor is initialized. + * @param listener The callback function with the initialized editor instance. + */ + onEditorReady: (listener: (editorView: EditorView) => void) => void; /** * Add an extension to MarkEdit. diff --git a/package.json b/package.json index dc15ff6..42eda78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "markedit-api", - "version": "0.3.0", + "version": "0.4.0", "description": "Type definitions for the latest MakrEdit API.", "main": "main.ts", "types": "markedit.d.ts",