-
Notifications
You must be signed in to change notification settings - Fork 761
feat: add expand and collapse all columns to notebook actions menu #4550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mscolnick
merged 12 commits into
marimo-team:main
from
bjoaquinc:new-keyboard-shortcuts
Apr 16, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c36c110
Added a file for the collapse and expand all columns hooks
bjoaquinc c5a5c27
Added buttons for collapsedAllColumns and expandAllColumns
bjoaquinc 06ef136
Merge branch 'marimo-team:main' into new-keyboard-shortcuts
bjoaquinc f4d9c49
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e9ab976
Updated all functions, files, and buttons to Sections instead of Columns
bjoaquinc b1fce02
Switched from useCallback to useEvent to avoid old state or stale dep…
bjoaquinc 7a59046
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 881af18
Consolidated the hooks into one useSectionCollapse function
bjoaquinc 552f6f3
Merge branch 'new-keyboard-shortcuts' of github.com:bjoaquinc/marimo …
bjoaquinc 4be4af6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a764792
Consolidated the hooks into one function that takes in an action of c…
bjoaquinc db98f46
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
frontend/src/components/editor/actions/useSectionCollapse.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* Copyright 2024 Marimo. All rights reserved. */ | ||
| import { useCellActions } from "@/core/cells/cells"; | ||
| import { getNotebook } from "@/core/cells/cells"; | ||
| import { canCollapseOutline } from "@/core/dom/outline"; | ||
| import useEvent from "react-use-event-hook"; | ||
|
|
||
| /** | ||
| * Hooks to collapse and expand all sections in the notebook. | ||
| */ | ||
|
|
||
| export const useSectionCollapse = () => { | ||
| const { collapseCell, expandCell } = useCellActions(); | ||
|
|
||
| const processAllSections = async (action: "collapse" | "expand") => { | ||
| const notebook = getNotebook(); | ||
| const cellIds = notebook.cellIds.inOrderIds; | ||
|
|
||
| // Find all markdown cells that aren't already hidden | ||
| for (const cellId of cellIds) { | ||
| const outline = notebook.cellRuntime[cellId].outline; | ||
| // Check if the cell is a markdown cell with a TOC outline | ||
| if (!outline) { | ||
| continue; | ||
| } | ||
| // Check if the cell is a collapsible header | ||
| if (!canCollapseOutline(outline)) { | ||
| continue; | ||
| } | ||
| // Collapse or expand the cell based on the action | ||
| action === "collapse" ? collapseCell({ cellId }) : expandCell({ cellId }); | ||
| } | ||
| }; | ||
|
|
||
| return { | ||
| collapseAllSections: useEvent(() => processAllSections("collapse")), | ||
| expandAllSections: useEvent(() => processAllSections("expand")), | ||
| }; | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.