3

Hi I'm trying out the Monaco editor and have noticed that some parts of the API ask for an optional URI or path. Examples:

The URI object documentation doesnt appear to have much info as to what its role in the editor is. Can anyone shed any light on to the use case of URIs in monaco. It seems like an option to provide content is always provided / required (so it doesnt seem to be dynamically reading from the provided URI).

Thanks!

Walter Ennis
  • 51
  • 1
  • 4

2 Answers2

0

I also wondered myself and the best guess I have is that these URIs are stored internally to find a resource (mostly models) by that value. Usually you don't need that, but some functionality only takes a URI, which internally is used to lookup a model, I think.

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
0

As mentioned here:

Each model is identified by a URI. This is why it's not possible for two models to have the same URI. Ideally when you represent content in Monaco editor, you should think of a virtual file system that matches the files your users are editing. For example, you could use file:/// as a base path. If a model is created without a URI, its URI will be inmemory://model/1. The number increases as more models are created.

Amir2mi
  • 896
  • 9
  • 13