Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monaco editor - Follow link hook

Fellow coders,

I'm having a hard time to find a hook into the 'ctrl+click' (follow link) editor option.

On the demo page the link is opened in a new tab: https://microsoft.github.io/monaco-editor/index.html

After a thorough google search which came up with nothing I searched through the api but only found the context actions which do not include the follow link or ctrl+click action.

I would like to parse the filepath and fire some custom methods of my own instead of opening in a new tab.

Any of you guys found a clue where to add/modify the behavoir?

Thank you in advance.

like image 362
Sjoerd Avatar asked Mar 02 '26 05:03

Sjoerd


1 Answers

You can override the IOpenerService's Open method, something like this:

var openerService = {
    open: function (resource, options) {
        // do something here, resource will contain the Uri
    }
};

var editor = monaco.editor.create(document.getElementById('container'),
    {
        automaticLayout: true, language: 'plaintext'
    },
    {
        openerService: openerService
    }
);
like image 195
Simon Mourier Avatar answered Mar 07 '26 09:03

Simon Mourier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!