Skip to content

Commit 19aa488

Browse files
committed
docs: add ready event to README.md
1 parent ac3ac6c commit 19aa488

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ To use `svelte-codemirror-editor`, you need to import the package and use it as
4747

4848
## Events
4949

50-
| Event | Type | Description |
51-
| -------- | -------- | ----------------------------- |
52-
| `change` | `string` | Trigger when the code changes |
50+
| Event | Type | Description |
51+
| -------- | ------------ | ------------------------------------------------------------------------------- |
52+
| `change` | `string` | Trigger when the code changes. |
53+
| `ready` | `EditorView` | Trigger when the editor is ready. Allows to retrieve the `EditorView` instance. |
5354

5455
## Usage with vite / svelte-kit
5556

@@ -118,6 +119,17 @@ const config = {
118119
/>
119120
```
120121

122+
### Get EditorView instance
123+
124+
```svelte
125+
<script lang="ts">
126+
import CodeMirror from "svelte-codemirror-editor";
127+
let view: EditorView;
128+
</script>
129+
130+
<CodeMirror on:ready={(e) => view = e.detail} />
131+
```
132+
121133
## License
122134

123135
[MIT](LICENSE)

0 commit comments

Comments
 (0)