# Get the Active Editor Instance in Obsidian With API
## Notes
```javascript
const leaf = app.workspace.activeLeaf;
if (!leaf || !leaf.view || !leaf.view.editor) {
new Notice("🔴error: no active editor");
return;
}
const editor = leaf.view.editor;
```