Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Add option to doc.addLineWidget to add custom classes #5952

Closed

Description

@dhyey35

Custom styling the div node with class .CodeMirror-linewidget is not possible right now as all the line widget's have same class name and there is no way to apply separate styles to each line widgets at the .CodeMirror-linewidget` ( of course applying custom style to child nodes is possible ). Also the node returned by addLineWidget cannot be used as it can change if another line widget is added to the same line.

Ideally addLineWidget should allow adding custom class name to the line widget so we can target it by .CodeMirror-linewidget.my-custom-class

Activity

  1. marijnh commented on Jul 26, 2019

    @marijnh
    Member

    What kind of style do you need to add to the widget wrapper node?

  2. dhyey35 commented on Jul 26, 2019

    @dhyey35
    Author

    @marijnh A real life use case can be found here Firefox DevTools Editor.css. The overflow: hidden style has been applied to avoid scrolling problems when a line widget is dynamically resized.

  3. marijnh commented on Jul 29, 2019

    @marijnh
    Member

    Wouldn't making your widget itself width: 100%; overflow: hidden have a similar effect?

  4. chriscoyier commented on Dec 12, 2019

    @chriscoyier
    Contributor

    This came up for me just today. Mostly I like the default overflow on .CodeMirror-linewidget, but there is one particular line widget in which I want to style a child with absolute positioning (which collapses the parent line widget) and I need to set overflow: visible; on that one line widget, but have no selector to do so with.

  5. marijnh commented on Dec 13, 2019

    @marijnh
    Member

    Would a className option to addLineWidget help?

  6. chriscoyier commented on Dec 13, 2019

    @chriscoyier
    Contributor

    It would!

    Right now I'm querying the DOM after using addLineWidget to find the widget that contains the specific children and then adding an additional class to CodeMirror-linewidget which is a little janky. I even have to do a little setTimeout before doing it for it to work correctly for some reason. Doing it right in the API would be awesome.

  7. marijnh commented on Dec 16, 2019

    @marijnh
    Member

    Implemented in attached patch.

  8. chriscoyier commented on Dec 16, 2019

    @chriscoyier
    Contributor

    Works perfectly and solves my needs, thanks 🙏

  9. added a commit that references this issue on Jan 6, 2020
  10. added a commit that references this issue on Jan 21, 2020
  11. added a commit that references this issue on Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions