Pass editor view as parameter to markerDOM function #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fold-editorView"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'd like to configure fold indicators based on another StateField I have active. I've messed around with CSS solutions and other ways of getting this info to the markers but I think just passing the view to the
markerDOMfunction may be the best solution, so we can do something likeIn my specific case I want to hide the markers so that they only show when that range is folded or the user is hovered over/has a selection in a foldable block. I could do that by returning a different DOM element or adding a CSS class or something.
I hope that makes sense!
I think I would otherwise put view as the first parameter (as it is in most other functions), but I don't want to introduce a breaking change just for this.
Your use case sounds like it would require the widgets to be re-rendered when some editor state changes. But they wouldn't be—these may be left in the DOM across any change that doesn't remove the marker. Isn't is more robust to put the information you need into the marker object and make sure it is replaced with a marker with different data when appropriate?
Thanks for the quick reply, first of all!
That sounds fine to me, I guess my question would be where would I do that? The only information I have when the marker is created is whether it is open or not, right?
Admittedly now that I write it out I'm not even sure this PR would do the job either - having access to the view still wouldn't give me the necessary information to be able to associate a marker with a specific foldable block.
Oh indeed, I was thinking about gutter markers in general—in this case, the fold gutter is regenerating its marker set on every change, so you really don't want to do anything expensive in them, or anything that makes them unique enough to require re-renders all the time.
I can imagine using the view in such a method to attach some kind of event handlers to markers, but since pointer interaction on these is already handled by the library, I don't think that is very useful here.
Given how the fold gutter works, I don't think markers that depend on the folded (or foldable) content are realistic. You can try to build something like that, but you'd have to set up an entirely custom gutter.
Pull request closed