Skip to content

Test: glyph margin widgets #186210

Closed
Closed

Description

@joyceerhl

Refs: #176316

Authors: Joyce Er (@joyceerhl) Alexandru Dima (@alexdima)
Complexity: 4

Create Issue


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:

  • /**
    * 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;
    }
  • /**
    * 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

  1. hediet commented on Jun 26, 2023

    @hediet
    Member
  2. hediet commented on Jun 27, 2023

    @hediet
    Member

    Works nicely!

    Just some notes/thoughts:

    • Why does a widget have a range and not just a position? Can you add some docs there?
    • You followed the same API that Content and Overlay widgets have, but I think that API is quite outdated (addGlyphMarginWidget should return a disposable instead of having removeGlyphMarginWidget, layoutGlyphMarginWidget could be replaced by an "onChange" event and I don't think getId is needed).
      • Personally, I'd prefer a more modern API over consistency for the monaco editor (and would eventually refactor the other APIs as well), but I can understand the other side as well
    • Just curious, for what feature did you add GlyphMarginWidgets?
  3. removed their assignment
    on Jun 27, 2023
  4. locked and limited conversation to collaborators on Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions