From 7dac0d0a2e7a3547afcad55921650a34a2691cf3 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Tue, 18 Jul 2023 14:51:18 +0200 Subject: [PATCH 1/2] Document some basic concepts Closes #4084 --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index dfdb2b829e..923f5fe26e 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,32 @@ You will get: It is recommended to develop against the `dev` version, and in production to use the `min` version. +## Concepts + +Monaco editor is best known for being the text editor that powers VS Code. However, it’s a bit more nuanced. Some basic understanding about the underlying concepts is needed to use Monaco editor effectively. + +### Models + +Models are at the heart of Monaco editor. It’s what you interact with when managing content. A model represents a file that has been opened. This could represent a file that exists on a file system, but it doesn’t have to. For example, the model holds the text content, determines the language of the content, and tracks the edit history of the content. + +### URIs + +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, it’s URI will be `inmemory://model/1`. The number increases as more models are created. + +### Editors + +An editor is a user facing view of the model. This is what gets attached to the DOM and what your users see visually. Typical editor operations are displaying a model, managing the view state, or executing actions or commands. + +### Providers + +Providers provide smart editor features, also known as IntelliSense. For example, this includes completion and hover information. It is not the same as, but often maps to [language server protocol](https://microsoft.github.io/language-server-protocol) features. + +Providers work on models. Some IntelliSense depends on the file URI. For example, for TypeScript to resolve imports, or for JSON IntelliSense to determine which JSON schema to apply to which model. So it’s important to choose proper model URIs. + +### Disposables + +Many Monaco related objects often implement the `.dispose()` method. This method is intended to perform cleanups when a resource is no longer needed. For example, calling `model.dispose()` will unregister it, freeing up the URI for a new model. And editors are typically disposed when changing to another view. + ## Documentation - Learn how to integrate the editor with these [complete samples](./samples/). From 09a944d5d8e1d98a7fdfe3ffd21a76851e5288d6 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Tue, 18 Jul 2023 21:27:36 +0200 Subject: [PATCH 2/2] Process feedback --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 923f5fe26e..eee79f7786 100644 --- a/README.md +++ b/README.md @@ -33,15 +33,15 @@ It is recommended to develop against the `dev` version, and in production to use ## Concepts -Monaco editor is best known for being the text editor that powers VS Code. However, it’s a bit more nuanced. Some basic understanding about the underlying concepts is needed to use Monaco editor effectively. +Monaco editor is best known for being the text editor that powers VS Code. However, it's a bit more nuanced. Some basic understanding about the underlying concepts is needed to use Monaco editor effectively. ### Models -Models are at the heart of Monaco editor. It’s what you interact with when managing content. A model represents a file that has been opened. This could represent a file that exists on a file system, but it doesn’t have to. For example, the model holds the text content, determines the language of the content, and tracks the edit history of the content. +Models are at the heart of Monaco editor. It's what you interact with when managing content. A model represents a file that has been opened. This could represent a file that exists on a file system, but it doesn't have to. For example, the model holds the text content, determines the language of the content, and tracks the edit history of the content. ### URIs -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, it’s URI will be `inmemory://model/1`. The number increases as more models are created. +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. ### Editors @@ -49,13 +49,13 @@ An editor is a user facing view of the model. This is what gets attached to the ### Providers -Providers provide smart editor features, also known as IntelliSense. For example, this includes completion and hover information. It is not the same as, but often maps to [language server protocol](https://microsoft.github.io/language-server-protocol) features. +Providers provide smart editor features. For example, this includes completion and hover information. It is not the same as, but often maps to [language server protocol](https://microsoft.github.io/language-server-protocol) features. -Providers work on models. Some IntelliSense depends on the file URI. For example, for TypeScript to resolve imports, or for JSON IntelliSense to determine which JSON schema to apply to which model. So it’s important to choose proper model URIs. +Providers work on models. Some smart features depends on the file URI. For example, for TypeScript to resolve imports, or for JSON IntelliSense to determine which JSON schema to apply to which model. So it's important to choose proper model URIs. ### Disposables -Many Monaco related objects often implement the `.dispose()` method. This method is intended to perform cleanups when a resource is no longer needed. For example, calling `model.dispose()` will unregister it, freeing up the URI for a new model. And editors are typically disposed when changing to another view. +Many Monaco related objects often implement the `.dispose()` method. This method is intended to perform cleanups when a resource is no longer needed. For example, calling `model.dispose()` will unregister it, freeing up the URI for a new model. Editors should be disposed to free up resources and remove their model listeners. ## Documentation