My project involves lots of CM Widgets, and some drag-and-drop code requires that I get the
ClientRect of those widgets periodically.
I can’t find much documentation for the
CodeMirror-measure element, but it’s presenting some behavior that is problematic. As far as I can tell, it may contain line content for the longest offscreen lines in the doc - whether or not they’re in the viewport - presumably to keep the scrollbars accurate.
However, it’s positioned at the top of the editor with
visibility:hidden, meaning that calling
getBoundingClientRect() on the widest widget that’s offscreen will return a
ClientRect as if it’s (a) onscreen and (b) positioned at the top of the viewport. This wreaks havoc with the drag-and-drop code, since offscreen widgets are calculating as if they’re onscreen!
So I have two questions:
- Is the use of this element documented somewhere? If I understand it better, I can probably work around it.
- Is there any reason that it has to be positioned inside the viewport (or the editor window itself)? Simply moving it outside the viewport would prevent any conflicts with DND code.
Thanks in advance!