-
Notifications
You must be signed in to change notification settings - Fork 4
ENG-1640 Add custom sidebar commands, starting with Create Node #971
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
maparent
merged 15 commits into
main
from
eng-1640-add-custom-sidebar-commands-starting-with-create-node
Apr 24, 2026
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6531061
ENG-1640: First stab
maparent 55137d4
Add command menu
maparent 779480e
Disable if command exists
maparent 035c048
linting
maparent 6be9ee9
WIP
maparent f949fbb
merge error
maparent 386e70c
styling
maparent 32bd784
naming
maparent a5251e2
lint
maparent 6d63f0d
clean command name
maparent e524d43
As requested in review
maparent 39315fe
memoization comment from Devin; linting fixes
maparent e750993
More review comments
maparent 6315f40
restrict css scope (Devin)
maparent 79d061a
commands come before pages
maparent 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import React from "react"; | ||
| import { Popover, Position, Button, Menu, MenuItem } from "@blueprintjs/core"; | ||
| import { OnloadArgs } from "roamjs-components/types"; | ||
| import { createDiscourseNodeFromCommand } from "~/utils/registerCommandPaletteCommands"; | ||
|
|
||
| export const cleanCommandName = (name: string): string => { | ||
| if (name.startsWith("{") && name.endsWith("}")) | ||
| name = name.substring(1, name.length - 1); | ||
| name = name.trim(); | ||
| // sentence case | ||
| name = name.charAt(0).toUpperCase() + name.slice(1); | ||
| return name; | ||
| }; | ||
|
|
||
| export const commands: Record< | ||
| string, | ||
| (onloadArgs: OnloadArgs) => Promise<void> | ||
| > = { | ||
| /* eslint-disable @typescript-eslint/require-await */ | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| "{create node}": async (onloadArgs: OnloadArgs) => { | ||
| createDiscourseNodeFromCommand(onloadArgs.extensionAPI); | ||
| // typescript-eslint/naming-convention | ||
| }, | ||
| /* eslint-enable @typescript-eslint/require-await */ | ||
| }; | ||
|
|
||
| export const SidebarCommandPopover = ({ | ||
| onSelect, | ||
| }: { | ||
| onSelect: (value: string) => void; | ||
| }) => { | ||
| return ( | ||
| <Popover | ||
| content={ | ||
| <Menu> | ||
| {Object.keys(commands).map((commandName) => ( | ||
| <MenuItem | ||
| key={commandName} | ||
| text={commandName} | ||
| onClick={() => onSelect(commandName)} | ||
| /> | ||
| ))} | ||
| </Menu> | ||
| } | ||
| position={Position.BOTTOM_LEFT} | ||
| > | ||
| <Button icon="cog" small minimal title="Commands" /> | ||
| </Popover> | ||
| ); | ||
| }; | ||
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
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
Oops, something went wrong.
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.