You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
Repository navigation
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
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
@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.
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.
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.
Activity
marijnh commentedon Jul 26, 2019
What kind of style do you need to add to the widget wrapper node?
dhyey35 commentedon Jul 26, 2019
@marijnh A real life use case can be found here Firefox DevTools Editor.css. The
overflow: hiddenstyle has been applied to avoid scrolling problems when a line widget is dynamically resized.marijnh commentedon Jul 29, 2019
Wouldn't making your widget itself
width: 100%; overflow: hiddenhave a similar effect?chriscoyier commentedon Dec 12, 2019
This came up for me just today. Mostly I like the default
overflowon.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 setoverflow: visible;on that one line widget, but have no selector to do so with.marijnh commentedon Dec 13, 2019
Would a
classNameoption toaddLineWidgethelp?chriscoyier commentedon Dec 13, 2019
It would!
Right now I'm querying the DOM after using
addLineWidgetto find the widget that contains the specific children and then adding an additional class toCodeMirror-linewidgetwhich is a little janky. I even have to do a littlesetTimeoutbefore doing it for it to work correctly for some reason. Doing it right in the API would be awesome.Add a className option to addLineWidget
marijnh commentedon Dec 16, 2019
Implemented in attached patch.
chriscoyier commentedon Dec 16, 2019
Works perfectly and solves my needs, thanks 🙏
Add a className option to addLineWidget
Add a className option to addLineWidget
Update from master (#1)
Update/5.58.2 (#1)
Add a className option to addLineWidget