Repository navigation
Description
Refs: #176316
- anyOS Henning Dieterichs (@hediet)
- anyOS Connor Peet (@connor4312)
- anyOS roblourens
Authors: Joyce Er (@joyceerhl) Alexandru Dima (@alexdima)
Complexity: 4
We've added support for GlyphMarginWidgets in the code editor. This allows decoration authors in core only (not extension authors) to handle clicks on glyph margin decorations by passing in a DOM node that has attached listeners.
Test: please take a look at the IGlyphMarginWidget interface and the new methods for adding, layouting, and removing widgets. Verify that the methods and properties make sense, are properly documented, and behave as expected.
edit from hediet: Try out the new API in the monaco editor playground!
Refs:
vscode/src/vs/editor/browser/editorBrowser.ts
Lines 255 to 271 in f907729
/** * A glyph margin widget renders in the editor glyph margin. */ export interface IGlyphMarginWidget { /** * Get a unique identifier of the glyph widget. */ getId(): string; /** * Get the dom node of the glyph widget. */ getDomNode(): HTMLElement; /** * Get the placement of the glyph widget. */ getPosition(): IGlyphMarginWidgetPosition; } vscode/src/vs/editor/browser/editorBrowser.ts
Lines 1029 to 1041 in f907729
/** * Add a glyph margin widget. Widgets must have unique ids, otherwise they will be overwritten. */ addGlyphMarginWidget(widget: IGlyphMarginWidget): void; /** * Layout/Reposition a glyph margin widget. This is a ping to the editor to call widget.getPosition() * and update appropriately. */ layoutGlyphMarginWidget(widget: IGlyphMarginWidget): void; /** * Remove a glyph margin widget. */ removeGlyphMarginWidget(widget: IGlyphMarginWidget): void;
Activity
hediet commentedon Jun 26, 2023
This looks like an ideal use case to try the monaco editor playground!
https://microsoft.github.io/monaco-editor/playground.html?source=v0.40.0-dev.20230626#example-creating-the-editor-hello-world
hediet commentedon Jun 27, 2023
Works nicely!
Just some notes/thoughts:
removeGlyphMarginWidget,layoutGlyphMarginWidgetcould be replaced by an "onChange" event and I don't thinkgetIdis needed).