How to prevent links from being opened on a PDF in WebViewer?

Here is the code snippet where you can override the function that gets called when a link is being opened:

Webviewer(
  {
    initialDoc: hashFile,
    path: '/lib',
  },
  document.getElementById('viewer')
).then((instance) => {
  const { Actions, Annotations } = instance;
  const onTriggered = Actions.URI.prototype.onTriggered;
  Actions.URI.prototype.onTriggered = function(target, event) {
    if (target instanceof Annotations.Link) {
      return;
    }
    onTriggered.apply(this, arguments);
  };
});