naturalcrit / homebrewery

Create authentic looking D&D homebrews using only markdown
https://homebrewery.naturalcrit.com
MIT License
1.09k stars 326 forks source link

Collapsible Sections #629

Closed KippKipper closed 2 years ago

KippKipper commented 6 years ago

Over the past month, I have been using Hombrewery a lot. I think it would be nice to collapse sections of my brew that I don't use so that it is easier to scroll to the 25 page or find the section I want to edit. 25 pages seem like a wall of text to scroll through to find anything. I have had to split up my brew into manageable chapters so that it was easier to edit it.

Thank you for the homebrewery, this is my feedback.

Gazook89 commented 3 years ago

Old issue/feature request, but would like to +1 this. I was thinking that in the editor pane it would be nice to set this up like:

\page [Page Title]

A user could collapse portions of the markup in the editor pane by maybe double clicking the \page line, and the \page line would also have a user-entered title so that it is easy to find which page they need.

ericscheid commented 3 years ago

CodeMirror has collapsing built in by the looks of things, so this shouldn't be too complicated.

I would limit it to \page boundaries and maybe # Headings down to some depth, but not other objects.

https://codemirror.net/demo/folding.html

calculuschild commented 3 years ago

Looks like we would need to edit shared/Naturalcrit/codeEditor/codeEditor.jsx and add these options to componentDidMount:

foldGutter: {
                rangeFinder: function(startPos) //given a starting line of code, return null if this doesn't start a foldable block, or return line number where this foldable block ends. startPos.line is the starting line number.
            },
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
ericscheid commented 3 years ago

Oh .. integration with #1147 might prove weird - that is currently deferred to #1093 V3 Renderer because it might break brews where \page does not occur at line start.

Suggestion: implement #629 but only fold \page if at line-start .. rendering would unaffected (yay), folding is available (yay), and the fact a given \page doesn't fold because it isn't at line-start might encourage editorial clean-up.

snctfd commented 3 years ago

Any updates on this? Navigating my project is becoming a bit of a nightmare :s

calculuschild commented 3 years ago

@snctfd Not yet, although we have been making a lot of changes to the editor panel lately so we might get to it sooner than later.

Feel free to send us a PR if you want to contribute too.

jeddai commented 3 years ago

I've got some pretty big brews as well and definitely agree it would be a helpful addition -- I'm going to start working on this!

calculuschild commented 3 years ago

@jeddai Great! New PRs are always welcome!

jeddai commented 3 years ago

I would limit it to \page boundaries and maybe # Headings down to some depth, but not other objects.

@ericscheid could it make sense to include xml folding for things like <style> blocks?

calculuschild commented 3 years ago

I agree with @ericscheid that we should (at least to start) limit this to \page separators. Especially since with v3 we are actively trying to discourage literal XML/HTML blocks in favor of our custom Markdown syntax. Similarly, styles should all be contained within the Style tab rather than using <style> tags.

ericscheid commented 3 years ago

Agree. First step collapsing on \page markers.

Collapsing on headers would be problematic, as they might occur within {{curly-blocks}}.

If anything, being able to collapse {{curly-blocks}} would be the second step.

calculuschild commented 2 years ago

Fixed by #1792