![]() You can use a CustomTextEditor for any text based file types. The main difference between these is how they define their document model.Ī CustomTextEditorProvider uses VS Code's standard TextDocument as its data model. There are two classes of custom editors: custom text editors and custom editors. In this case, there is still just a single TextDocument since there is still just a single copy of the resource in the workspace, but there are now two webviews for that resource. For example, imagine that you open a file that has a CustomTextEditorProvider and then run the View: Split editor command. CustomReadonlyEditorProvider and CustomEditorProvider on the other hand let you provide your own document model, which lets them be used for non-text file formats.Ĭustom editors have a single document model per resource but there may be multiple editor instances (views) of this document. A CustomTextEditorProvider uses VS Code's standard TextDocument as its document model and all changes to the file are expressed using VS Code's standard text editing APIs. ![]() This model is how your extension understands the resource (file) it is working with. The other part of a custom editor is the document model. Check out our webview documentation for more information on webviews and best practices for working with them. Webviews cannot access the VS Code API directly but they can talk with extensions by passing messages back and forth. This lets you build the user interface of your custom editor using standard HTML, CSS, and JavaScript. The view side of a custom editor is implemented using a webview. There are two parts to a custom editor: the view that users interact with and the document model that your extension uses to interact with the underlying resource. LinksĪ custom editor is an alternative view that is shown in place of VS Code's standard text editor for specific resources. Custom editors build on a lot of VS Code concepts-such as webviews and text documents-so it may be a bit overwhelming if you are learning all of these new ideas at the same time.īut if you're feeling ready and are thinking about all the cool custom editors you are going to build, then let's get started! Be sure to download the custom editor extension sample so you can follow along with the documentation and see how the custom editor API comes together. Then for each of these custom editor types, we'll cover the basics of building a well behaved custom editor.Īlthough custom editors are a powerful new extension point, implementing a basic custom editor is not actually that difficult! Still, if you are working on your first VS Code extension, you may want to consider holding off on diving into custom editors until you are more familiar with the basics of the VS Code API. We'll take a look at the two types of custom editors and how they differ, as well as which one is right for your use case. This document provides an overview of the custom editor API and the basics of implementing a custom editor. Building fully customizable editing experiences for binary or text files.Offering alternative visual renderings for data files such as CSV or JSON or XML.Creating WYSIWYG editors for languages such as Markdown or XAML. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |