Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(core): add commands to menu from blocks (#1997)

Seamusbd92f08a97b3
diff --git a/js/app/packages/app/component/GlobalHotkeys.tsx b/js/app/packages/app/component/GlobalHotkeys.tsx
index f0027c5561..3e9b2bb3ca 100644
--- a/js/app/packages/app/component/GlobalHotkeys.tsx
+++ b/js/app/packages/app/component/GlobalHotkeys.tsx
@@ -86,6 +86,7 @@ export default function GlobalShortcuts() {
return CommandState.isOpen() ? 'Close command menu' : 'Open command menu';
},
keyDownHandler: () => {
+ console.log('## CMD K - global');
handleCommandMenu();
return true;
},
diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsx
index 23f15a8a9a..6abc9a9c34 100644
--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx
+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx
@@ -431,16 +431,14 @@ const SidebarLink = (props: SidebarLinkProps) => {
{props.label}
</span>
- <div class="text-[0.625rem] text-ink-extra-muted/50 rounded-sm ml-auto border border-edge-muted px-1.5 py-0.25 -my-1 group-data-[slim=true]/sidebar:invisible">
+ <div class="text-[0.625rem] text-ink-extra-muted/50 rounded-sm ml-auto border border-edge-muted px-2 py-0.5 -my-1 group-data-[slim=true]/sidebar:invisible">
<div class="flex gap-1">
<Show when={!props.standaloneHotkey}>
- <>
- <Hotkey shortcut={GO_TO_LEADER_KEY} lowercase />
- <Hotkey shortcut={props.hotkey} lowercase />
- </>
+ <Hotkey shortcut={GO_TO_LEADER_KEY} />
+ <Hotkey shortcut={props.hotkey} />
</Show>
<Show when={props.standaloneHotkey}>
- <Hotkey shortcut={props.hotkey} lowercase />
+ <Hotkey shortcut={props.hotkey} />
</Show>
</div>
</div>
diff --git a/js/app/packages/app/component/command/CommandMenu.tsx b/js/app/packages/app/component/command/CommandMenu.tsx
index b858de50d2..83f688dfb1 100644
--- a/js/app/packages/app/component/command/CommandMenu.tsx
+++ b/js/app/packages/app/component/command/CommandMenu.tsx
@@ -605,14 +605,19 @@ function CategoryFilterTabs() {
}
}}
>
- <Tabs.List class="p-1.5">
- <div class="text-sm border border-edge-muted rounded-xs inline-block overflow-hidden">
+ <Tabs.List class="p-1.5 border-b border-edge-muted/50">
+ <div class="text-sm rounded-xs overflow-clip border border-edge-muted inline-block">
<div class="flex">
<For each={CATEGORIES}>
{(category) => (
<Tabs.Trigger
value={category.id}
- class="relative text-ink-muted px-2 py-1 text-xs font-medium block data-[selected]:text-ink data-[selected]:bg-ink/10 hover:text-ink hover:bg-ink/15 data-[selected]:hover:bg-ink/20 transition-colors duration-150 border-r border-edge-muted last:border-r-0"
+ class={cn(
+ 'border-r-1 border-edge-muted last:border-r-0',
+ 'relative text-ink-muted/70 px-2.5 py-1 text-xs font-medium block hover:bg-ink/6 hover:text-ink',
+ CommandState.categoryFilter() === category.id &&
+ 'text-ink bg-edge/50'
+ )}
tabIndex={-1}
>
{category.label}
diff --git a/js/app/packages/app/component/command/useCommandItems.ts b/js/app/packages/app/component/command/useCommandItems.ts
index 142c145873..8627c11d15 100644
--- a/js/app/packages/app/component/command/useCommandItems.ts
+++ b/js/app/packages/app/component/command/useCommandItems.ts
@@ -108,6 +108,7 @@ function useCommandsList(): () => CommandItem[] {
sortByScopeLevel: false,
hideShadowedCommands: false,
hideCommandsWithoutHotkeys: false,
+ ignoreInputFocused: true,
});
return createMemo(() => {
diff --git a/js/app/packages/app/component/next-soup/actions/index.ts b/js/app/packages/app/component/next-soup/actions/index.ts
index 1cec9259e8..f78b0fa290 100644
--- a/js/app/packages/app/component/next-soup/actions/index.ts
+++ b/js/app/packages/app/component/next-soup/actions/index.ts
@@ -8,3 +8,4 @@ export { makeCopyBranchNameAction } from './make-copy-branch-name-action';
export { makeShareAction } from './make-share-action';
export { useEntityActionHotkeys } from './use-entity-action-hotkeys';
+export { useBlockEntityCommands } from './use-block-entity-commands';
diff --git a/js/app/packages/app/component/next-soup/actions/use-block-entity-commands.ts b/js/app/packages/app/component/next-soup/actions/use-block-entity-commands.ts
new file mode 100644
index 0000000000..ec173780e4
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/actions/use-block-entity-commands.ts
@@ -0,0 +1,337 @@
+import { useBlockId } from '@core/block';
+import { useQuickAccess } from '@core/context/quickAccess';
+import { useUserId } from '@core/context/user';
+import { HotkeyTags } from '@core/hotkey/constants';
+import { createHotkeyGroup, registerHotkey } from '@core/hotkey/hotkeys';
+import { TOKENS } from '@core/hotkey/tokens';
+import { useAllProperties } from '@app/component/property-edit-modal/hooks/useAllProperties';
+import { openPropertyEditor } from '@app/component/property-edit-modal/state/propertyEditor';
+import { SYSTEM_PROPERTY_IDS } from '@core/component/Properties/constants';
+import type {
+ Property,
+ PropertyDefinitionDomain,
+} from '@core/component/Properties/types';
+import { blockHotkeyScopeSignal } from '@core/signal/blockElement';
+import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
+import { CommandState } from '@app/component/command';
+import { isTaskEntity, type EntityData } from '@entity';
+import { createEffect, onCleanup } from 'solid-js';
+import {
+ makeCopyAction,
+ makeCopyBranchNameAction,
+ makeCopyLinkAction,
+ makeDeleteAction,
+ makeMarkDoneAction,
+ makeMoveToProjectAction,
+ makeRenameAction,
+} from './index';
+
+/**
+ * Common manipulations scoped to the current block's hotkey scope.
+ * Note: several of these do not register with an actual hot key so that they
+ * can be found by the command menu.
+ */
+export const useBlockEntityCommands = () => {
+ const blockId = useBlockId();
+ const quickAccess = useQuickAccess();
+ const userId = useUserId();
+ const notificationSource = useGlobalNotificationSource();
+
+ const markDone = makeMarkDoneAction({
+ userId: () => userId(),
+ notificationSource: () => notificationSource,
+ });
+
+ const deleteAction = makeDeleteAction({
+ userId: () => userId(),
+ });
+
+ const renameAction = makeRenameAction({
+ userId: () => userId(),
+ });
+
+ const copyAction = makeCopyAction();
+ const moveToProjectAction = makeMoveToProjectAction();
+ const copyLinkAction = makeCopyLinkAction();
+ const copyBranchNameAction = makeCopyBranchNameAction();
+
+ const allProperties = useAllProperties();
+
+ const propertyById = (propertyId: string) =>
+ allProperties().find(({ id }) => id === propertyId);
+
+ const status = () => propertyById(SYSTEM_PROPERTY_IDS.STATUS);
+ const priority = () => propertyById(SYSTEM_PROPERTY_IDS.PRIORITY);
+ const assignees = () => propertyById(SYSTEM_PROPERTY_IDS.ASSIGNEES);
+
+ const getEntity = (): EntityData | undefined => {
+ const item = quickAccess.getById(blockId);
+ if (item?.kind === 'entity') return item.data;
+ return undefined;
+ };
+
+ const openPropertyEditorIfSelected = (
+ mode: 'selector' | 'direct' = 'selector',
+ property?: Property | PropertyDefinitionDomain
+ ) => {
+ const entity = getEntity();
+ if (entity) {
+ openPropertyEditor([entity], mode, property);
+ }
+ };
+
+ createEffect(() => {
+ const scopeId = blockHotkeyScopeSignal.get();
+ if (!scopeId) return;
+
+ const group = createHotkeyGroup();
+
+ registerHotkey({
+ scopeId,
+ description: 'Mark done',
+ keyDownHandler: () => {
+ const entity = getEntity();
+ if (!entity) return false;
+ if (!markDone.canExecute(entity)) return false;
+ markDone.execute([entity]);
+ return true;
+ },
+ condition: () => {
+ const entity = getEntity();
+ return entity !== undefined && markDone.canExecute(entity);
+ },
+ displayPriority: 10,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
+ registerHotkey({
+ scopeId,
+ description: 'Delete item',
+ keyDownHandler: () => {
+ const entity = getEntity();
+ if (!entity) return false;
+ if (!deleteAction.canExecute(entity)) return false;
+ deleteAction.execute([entity]);
+ return true;
+ },
+ condition: () => {
+ const entity = getEntity();
+ return entity !== undefined && deleteAction.canExecute(entity);
+ },
+ displayPriority: 10,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
+ registerHotkey({
+ hotkey: ['r'],
+ hotkeyToken: TOKENS.entity.action.rename,
+ scopeId,
+ description: 'Rename item',
+ keyDownHandler: () => {
+ const entity = getEntity();
+ if (!entity) return false;
+ if (!renameAction.canExecute(entity)) return false;
+ renameAction.execute([entity]);
+ return true;
+ },
+ condition: () => {
+ const entity = getEntity();
+ return entity !== undefined && renameAction.canExecute(entity);
+ },
+ displayPriority: 10,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
+ registerHotkey({
+ scopeId,
+ description: 'Duplicate item',
+ keyDownHandler: () => {
+ const entity = getEntity();
+ if (!entity) return false;
+ if (!copyAction.canExecute(entity)) return false;
+ copyAction.execute([entity]);
+ return true;
+ },
+ condition: () => {
+ const entity = getEntity();
+ return entity !== undefined && copyAction.canExecute(entity);
+ },
+ displayPriority: 10,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
+ // Move to folder - 'm'
+ registerHotkey({
+ hotkey: ['m'],
+ hotkeyToken: TOKENS.entity.action.moveToFolder,
+ scopeId,
+ description: 'Move to folder',
+ keyDownHandler: (e) => {
+ const entity = getEntity();
+ if (!entity) return false;
+ e?.AT_TARGET;
+ if (!moveToProjectAction.canExecute(entity)) return false;
+ moveToProjectAction.execute([entity]);
+ return true;
+ },
+ condition: () => {
+ const entity = getEntity();
+ return entity !== undefined && moveToProjectAction.canExecute(entity);
+ },
+ displayPriority: 10,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
+ // Copy link - 'shift+cmd+c'
+ registerHotkey({
+ hotkey: ['shift+cmd+c'],
+ hotkeyToken: TOKENS.entity.action.copyLink,
+ scopeId,
+ description: 'Copy link',
+ keyDownHandler: () => {
+ const entity = getEntity();
+ if (!entity) return true;
+ if (!copyLinkAction.canExecute(entity)) return true;
+ copyLinkAction.execute([entity]);
+ return true;
+ },
+ condition: () => {
+ const entity = getEntity();
+ return entity !== undefined && copyLinkAction.canExecute(entity);
+ },
+ displayPriority: 10,
+ runWithInputFocused: true,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
+ // Copy branch name - 'shift+cmd+b'
+ registerHotkey({
+ hotkey: ['shift+cmd+b'],
+ hotkeyToken: TOKENS.entity.action.copyBranchName,
+ scopeId,
+ description: 'Copy branch name',
+ keyDownHandler: () => {
+ const entity = getEntity();
+ if (!entity) return false;
+ if (!copyBranchNameAction.canExecute(entity)) return false;
+ copyBranchNameAction.execute([entity]);
+ return true;
+ },
+ condition: () => {
+ const entity = getEntity();
+ return entity !== undefined && copyBranchNameAction.canExecute(entity);
+ },
+ displayPriority: 10,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
+ // Open property selector - 'shift+cmd+o'
+ registerHotkey({
+ hotkey: ['shift+cmd+o'],
+ hotkeyToken: TOKENS.entity.action.properties,
+ scopeId,
+ description: 'Open property editor',
+ keyDownHandler: () => {
+ openPropertyEditorIfSelected('selector');
+ return true;
+ },
+ condition: () => {
+ const entity = getEntity();
+ return entity !== undefined && isTaskEntity(entity);
+ },
+ displayPriority: 10,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
+ // Set priority - 'shift+cmd+p'
+ registerHotkey({
+ hotkey: ['shift+cmd+p'],
+ hotkeyToken: TOKENS.entity.action.priority,
+ scopeId,
+ description: 'Set priority',
+ keyDownHandler: () => {
+ openPropertyEditorIfSelected('direct', priority());
+ return true;
+ },
+ condition: () => {
+ const entity = getEntity();
+ return (
+ entity !== undefined && isTaskEntity(entity) && Boolean(priority())
+ );
+ },
+ displayPriority: 10,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
+ // Set assignee - 'shift+cmd+a'
+ registerHotkey({
+ hotkey: ['shift+cmd+a'],
+ hotkeyToken: TOKENS.entity.action.assignee,
+ scopeId,
+ description: 'Set assignee',
+ keyDownHandler: () => {
+ openPropertyEditorIfSelected('direct', assignees());
+ return true;
+ },
+ condition: () => {
+ const entity = getEntity();
+ return (
+ entity !== undefined && isTaskEntity(entity) && Boolean(assignees())
+ );
+ },
+ displayPriority: 10,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
+ // Set status - 'shift+cmd+s'
+ registerHotkey({
+ hotkey: ['shift+cmd+s'],
+ hotkeyToken: TOKENS.entity.action.status,
+ scopeId,
+ description: 'Set status',
+ keyDownHandler: () => {
+ openPropertyEditorIfSelected('direct', status());
+ return true;
+ },
+ condition: () => {
+ const entity = getEntity();
+ return (
+ entity !== undefined && isTaskEntity(entity) && Boolean(status())
+ );
+ },
+ displayPriority: 10,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
+ // CMD+K — open entity action mode for this block
+ const cmdKReg = registerHotkey({
+ scopeId,
+ hotkey: 'cmd+k',
+ description: () =>
+ CommandState.isOpen() ? 'Close command menu' : 'Open command menu',
+ condition: () => {
+ const entity = getEntity();
+ return !CommandState.isOpen() && entity !== undefined;
+ },
+ keyDownHandler: (e) => {
+ e?.preventDefault();
+ const entity = getEntity();
+ if (entity) {
+ CommandState.openForEntityAction([entity]);
+ } else {
+ CommandState.toggle();
+ }
+ return true;
+ },
+ displayPriority: 10,
+ handlerPriority: 1,
+ hide: CommandState.isOpen,
+ runWithInputFocused: true,
+ });
+
+ onCleanup(() => {
+ cmdKReg.dispose();
+ group.dispose();
+ });
+ });
+};
diff --git a/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts b/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
index 650ebb061e..e95eb5f950 100644
--- a/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
+++ b/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
@@ -1,7 +1,7 @@
import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import { HotkeyTags } from '@core/hotkey/constants';
import { TOKENS } from '@core/hotkey/tokens';
-import type { EntityData } from '@entity';
+import { isTaskEntity, type EntityData } from '@entity';
import type { SoupState } from '../create-soup-state';
import {
makeCopyAction,
@@ -16,6 +16,13 @@ import {
import { isShareableEntityType } from '@app/component/global-share-modal/GlobalShareModal';
import { useUserId } from '@core/context/user';
import { createHotkeyGroup, registerHotkey } from '@core/hotkey/hotkeys';
+import { useAllProperties } from '@app/component/property-edit-modal/hooks/useAllProperties';
+import { openPropertyEditor } from '@app/component/property-edit-modal/state/propertyEditor';
+import type {
+ Property,
+ PropertyDefinitionDomain,
+} from '@core/component/Properties/types';
+import { SYSTEM_PROPERTY_IDS } from '@core/component/Properties/constants';
import type { SplitHandle } from '@app/component/split-layout/layoutManager';
import { openEntityInSplitFromUnifiedList } from '@app/component/next-soup/utils';
import { onCleanup } from 'solid-js';
@@ -26,12 +33,14 @@ type UseEntityActionHotkeysOptions = {
soup: SoupState;
splitHandle?: SplitHandle;
condition?: () => boolean;
+ /** Fallback entity getter used when soup has no selection/focus (e.g., block views) */
+ getEntityFallback?: () => EntityData | undefined;
};
export const useEntityActionHotkeys = (
options: UseEntityActionHotkeysOptions
) => {
- const { scopeId, soup, splitHandle, condition } = options;
+ const { scopeId, soup, splitHandle, condition, getEntityFallback } = options;
const userId = useUserId();
const notificationSource = useGlobalNotificationSource();
@@ -69,7 +78,15 @@ export const useEntityActionHotkeys = (
}
const focused = soup.focus.item();
- return focused ? [focused] : [];
+ if (focused) return [focused];
+
+ // Fallback: use provided entity getter (e.g., for block views)
+ if (getEntityFallback) {
+ const entity = getEntityFallback();
+ if (entity) return [entity];
+ }
+
+ return [];
};
const openNextEntity = (entity: EntityData) => {
@@ -79,6 +96,24 @@ export const useEntityActionHotkeys = (
openEntityInSplitFromUnifiedList(entity, { splitHandle });
};
+ // Property editor setup
+ const allProperties = useAllProperties();
+ const propertyById = (propertyId: string) =>
+ allProperties().find(({ id }) => id === propertyId);
+ const status = () => propertyById(SYSTEM_PROPERTY_IDS.STATUS);
+ const priority = () => propertyById(SYSTEM_PROPERTY_IDS.PRIORITY);
+ const assignees = () => propertyById(SYSTEM_PROPERTY_IDS.ASSIGNEES);
+
+ const openPropertyEditorIfSelected = (
+ mode: 'selector' | 'direct' = 'selector',
+ property?: Property | PropertyDefinitionDomain
+ ) => {
+ const entities = getEntitiesForAction();
+ if (entities.length > 0) {
+ openPropertyEditor(entities, mode, property);
+ }
+ };
+
const group = createHotkeyGroup();
// Mark Done - 'e', not included in Hotkey Group so that we can use it from inside of blocks
@@ -275,5 +310,95 @@ export const useEntityActionHotkeys = (
tags: [HotkeyTags.SelectionModification],
}).withGroup(group);
+ // Open property selector - shift+cmd+o
+ registerHotkey({
+ hotkey: ['shift+cmd+o'],
+ hotkeyToken: TOKENS.entity.action.properties,
+ tags: [HotkeyTags.SelectionModification],
+ displayPriority: 10,
+ description: 'Open property editor',
+ keyDownHandler: () => {
+ openPropertyEditorIfSelected('selector');
+ return true;
+ },
+ condition: () => {
+ if (condition && !condition()) return false;
+ const entities = getEntitiesForAction();
+ return entities.length > 0 && entities.every(isTaskEntity);
+ },
+ scopeId,
+ }).withGroup(group);
+
+ // Set priority - shift+cmd+p
+ registerHotkey({
+ hotkey: ['shift+cmd+p'],
+ hotkeyToken: TOKENS.entity.action.priority,
+ tags: [HotkeyTags.SelectionModification],
+ displayPriority: 10,
+ description: 'Set priority',
+ keyDownHandler: () => {
+ openPropertyEditorIfSelected('direct', priority());
+ return true;
+ },
+ condition: () => {
+ if (condition && !condition()) return false;
+ const entities = getEntitiesForAction();
+ return (
+ entities.length > 0 &&
+ entities.every(isTaskEntity) &&
+ Boolean(priority())
+ );
+ },
+ scopeId,
+ }).withGroup(group);
+
+ // Set assignee - shift+cmd+a
+ registerHotkey({
+ hotkey: ['shift+cmd+a'],
+ hotkeyToken: TOKENS.entity.action.assignee,
+ tags: [HotkeyTags.SelectionModification],
+ displayPriority: 10,
+ description: 'Set assignee',
+ keyDownHandler: () => {
+ openPropertyEditorIfSelected('direct', assignees());
+ return true;
+ },
+ condition: () => {
+ if (condition && !condition()) return false;
+ const entities = getEntitiesForAction();
+ return (
+ entities.length > 0 &&
+ entities.every(isTaskEntity) &&
+ Boolean(assignees())
+ );
+ },
+ scopeId,
+ }).withGroup(group);
+
+ // Set status - shift+cmd+s
+ registerHotkey({
+ hotkey: ['shift+cmd+s'],
+ hotkeyToken: TOKENS.entity.action.status,
+ tags: [HotkeyTags.SelectionModification],
+ displayPriority: 10,
+ description: 'Set status',
+ keyDownHandler: () => {
+ openPropertyEditorIfSelected('direct', status());
+ return true;
+ },
+ condition: () => {
+ if (condition && !condition()) return false;
+ const entities = getEntitiesForAction();
+ return (
+ entities.length > 0 && entities.every(isTaskEntity) && Boolean(status())
+ );
+ },
+ scopeId,
+ }).withGroup(group);
+
onCleanup(() => group.dispose());
+
+ return {
+ openPropertyEditor: openPropertyEditorIfSelected,
+ };
};
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
index aa11676995..a04623292c 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
@@ -76,7 +76,7 @@ import { SoupChatInput } from '@app/component/SoupChatInput';
import { ENABLE_UNIFIED_LIST_AI_INPUT } from '@core/constant/featureFlags';
import { isMobile } from '@core/mobile/isMobile';
import type { SystemSortOption } from '@app/component/next-soup/soup-view/sort-options';
-import { usePropertyEditorHotkeys } from '@app/component/property-edit-modal/hooks/usePropertyEditorHotkeys';
+
import type { SoupItemsQueryFilters } from '@queries/soup/items';
import type { FilterID } from '@app/component/next-soup/filters';
import {
@@ -366,16 +366,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
splitHandle: panel.handle,
});
- // Property editor
- const propertyHotkeys = usePropertyEditorHotkeys({
- scopeId: scopeId(),
- soup,
- });
-
- onCleanup(() => {
- propertyHotkeys.disposeHotkeys();
- });
-
// Register soup view hotkeys (jump navigation, enter, escape, cmd+k, etc.)
const { applyTabPreset } = useApplyPreset();
const currentView = () => {
diff --git a/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts b/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts
index 8b3f640cf3..1a9d14e2c0 100644
--- a/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts
@@ -232,9 +232,11 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {
description: () => {
return CommandState.isOpen() ? 'Close command menu' : 'Open command menu';
},
+ hotkeyToken: TOKENS.global.commandMenu,
hotkey: 'cmd+k',
condition: () => !CommandState.isOpen(),
keyDownHandler: (e) => {
+ console.log('## CMD K - soup view');
e?.preventDefault();
const multiSelectEntities = soup.selection.selected();
diff --git a/js/app/packages/block-canvas/component/Block.tsx b/js/app/packages/block-canvas/component/Block.tsx
index a597fdbc4c..2f25ff64d0 100644
--- a/js/app/packages/block-canvas/component/Block.tsx
+++ b/js/app/packages/block-canvas/component/Block.tsx
@@ -6,6 +6,7 @@ import {
useIsNestedBlock,
} from '@core/block';
import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
+import { useBlockEntityCommands } from '@app/component/next-soup/actions';
import { blockFileSignal, blockHandleSignal } from '@core/signal/load';
import { isErr } from '@core/util/maybeResult';
import type { IDocumentStorageServiceFile } from '@filesystem/file';
@@ -75,6 +76,7 @@ export type BlockCanvasProps = {
};
export default function BlockCanvas(props: BlockCanvasProps) {
+ useBlockEntityCommands();
const documentId = useBlockId();
const isNestedBlock = useIsNestedBlock();
const nestedContext = useBlockNestedContext<'canvas'>();
diff --git a/js/app/packages/block-channel/component/Block.tsx b/js/app/packages/block-channel/component/Block.tsx
index 44f3ce286a..ef1f6f4e63 100644
--- a/js/app/packages/block-channel/component/Block.tsx
+++ b/js/app/packages/block-channel/component/Block.tsx
@@ -2,6 +2,7 @@ import { useBlockId } from '@core/block';
import { useChannelName } from '@core/context/channels';
import { EntityPermissionsGate } from '@core/component/EntityPermissionsGate';
import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
+import { useBlockEntityCommands } from '@app/component/next-soup/actions';
import { type JSXElement, onMount, Suspense } from 'solid-js';
import { Channel as NewChannel } from '@channel/Channel/Channel';
import { URL_PARAMS } from '@block-channel/constants';
@@ -28,6 +29,7 @@ type IncomingParams = Record<string, string>;
export type BlockChannelProps = IncomingParams & {};
export default function BlockChannel(props: BlockChannelProps) {
+ useBlockEntityCommands();
const channelId = useBlockId();
if (ENABLE_NEW_CHANNELS) {
diff --git a/js/app/packages/block-chat/component/Block.tsx b/js/app/packages/block-chat/component/Block.tsx
index 93f8626838..8d44c8bdfc 100644
--- a/js/app/packages/block-chat/component/Block.tsx
+++ b/js/app/packages/block-chat/component/Block.tsx
@@ -2,6 +2,7 @@ import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import { DEFAULT_CHAT_NAME } from '@block-chat/definition';
import { useBlockId } from '@core/block';
import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
+import { useBlockEntityCommands } from '@app/component/next-soup/actions';
import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';
import { DebouncedNotificationReadMarker } from '@notifications';
import { Show } from 'solid-js';
@@ -10,6 +11,7 @@ import { Chat } from './Chat';
import { ModalsProvider } from './ModalsProvider';
export default function ChatBlock() {
+ useBlockEntityCommands();
const blockId = useBlockId();
const notificationSource = useGlobalNotificationSource();
const name = useBlockDocumentName(DEFAULT_CHAT_NAME);
diff --git a/js/app/packages/block-code/component/Block.tsx b/js/app/packages/block-code/component/Block.tsx
index 957aa7ee97..ff60c2c74c 100644
--- a/js/app/packages/block-code/component/Block.tsx
+++ b/js/app/packages/block-code/component/Block.tsx
@@ -1,4 +1,5 @@
import { useIsNestedBlock } from '@core/block';
+import { useBlockEntityCommands } from '@app/component/next-soup/actions';
import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
import { blockMetadataSignal } from '@core/signal/load';
import { createEffect, createMemo, createSignal, on, Show } from 'solid-js';
@@ -12,6 +13,7 @@ import { TopBar } from './TopBar';
export type CodeBlockMode = 'code' | 'render';
export default function BlockCode() {
+ useBlockEntityCommands();
const isNestedBlock = useIsNestedBlock();
const blockMetadata = blockMetadataSignal.get;
const isHtmlFile = createMemo(() =>
diff --git a/js/app/packages/block-email/component/Block.tsx b/js/app/packages/block-email/component/Block.tsx
index 91b8a76af0..1c54e03075 100644
--- a/js/app/packages/block-email/component/Block.tsx
+++ b/js/app/packages/block-email/component/Block.tsx
@@ -2,6 +2,7 @@ import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import { useMaybePreviewPanel } from '@app/component/PreviewPanel';
import { withAnalytics } from '@coparse/analytics';
import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
+import { useBlockEntityCommands } from '@app/component/next-soup/actions';
import { EmailDebouncedReadMarker } from '@notifications';
import { createMemo, onMount, Show, Suspense } from 'solid-js';
import { blockDataSignal } from '../signal/emailBlockData';
@@ -11,6 +12,7 @@ import { useThreadQuery } from '@queries/email/thread';
const { track, TrackingEvents } = withAnalytics();
export default function BlockEmail() {
+ useBlockEntityCommands();
const blockData = blockDataSignal.get;
const notificationSource = useGlobalNotificationSource();
const isPreview = !!useMaybePreviewPanel();
diff --git a/js/app/packages/block-image/component/Block.tsx b/js/app/packages/block-image/component/Block.tsx
index 2fed948fae..2516d80581 100644
--- a/js/app/packages/block-image/component/Block.tsx
+++ b/js/app/packages/block-image/component/Block.tsx
@@ -1,6 +1,7 @@
import { withAnalytics } from '@coparse/analytics';
import { useBlockId } from '@core/block';
import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
+import { useBlockEntityCommands } from '@app/component/next-soup/actions';
import { blockAcceptedFileExtensionToMimeType } from '@core/constant/allBlocks';
import { blockFileSignal, blockMetadataSignal } from '@core/signal/load';
import { setCopiedItem } from '@core/state/clipboard';
@@ -11,6 +12,7 @@ import { TopBar } from './TopBar';
const { track, TrackingEvents } = withAnalytics();
export default function BlockImage() {
+ useBlockEntityCommands();
const documentId = useBlockId();
const [imageUrl, setImageUrl] = createSignal<string>();
diff --git a/js/app/packages/block-md/component/Block.tsx b/js/app/packages/block-md/component/Block.tsx
index 2271984200..6e56d89b7f 100644
--- a/js/app/packages/block-md/component/Block.tsx
+++ b/js/app/packages/block-md/component/Block.tsx
@@ -2,6 +2,7 @@ import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import { withAnalytics } from '@coparse/analytics';
import { useBlockId } from '@core/block';
import { CustomScrollbar } from '@core/component/CustomScrollbar';
+import { useBlockEntityCommands } from '@app/component/next-soup/actions';
import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
import { DocumentDebouncedNotificationReadMarker } from '@notifications';
import { useInstructionsMdIdQuery } from '@queries/storage/instructions-md';
@@ -15,6 +16,7 @@ import { InstructionsTopBar, TopBar } from './TopBar';
const { track, TrackingEvents } = withAnalytics();
export default function BlockMarkdown() {
+ useBlockEntityCommands();
const [scrollRef, setScrollRef] = createSignal<HTMLDivElement>();
const blockId = useBlockId();
const instructionsMdId = useInstructionsMdIdQuery();
diff --git a/js/app/packages/block-pdf/component/Block.tsx b/js/app/packages/block-pdf/component/Block.tsx
index 7dfa5332c3..b8844c8400 100644
--- a/js/app/packages/block-pdf/component/Block.tsx
+++ b/js/app/packages/block-pdf/component/Block.tsx
@@ -9,6 +9,7 @@ import { showTabBarSignal } from '@block-pdf/signal/placeables';
import { withAnalytics } from '@coparse/analytics';
import { useIsNestedBlock } from '@core/block';
import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
+import { useBlockEntityCommands } from '@app/component/next-soup/actions';
import { blockHandleSignal, blockMetadataSignal } from '@core/signal/load';
import { createCallback } from '@solid-primitives/rootless';
import { debounce, leading } from '@solid-primitives/scheduled';
@@ -67,6 +68,7 @@ function onKeyPress(e: KeyboardEvent) {
}
export default function BlockPdf() {
+ useBlockEntityCommands();
const isNestedBlock = useIsNestedBlock();
const showTabBar = showTabBarSignal.get;
diff --git a/js/app/packages/block-project/component/Block.tsx b/js/app/packages/block-project/component/Block.tsx
index a788cef8a7..7162cb45c2 100644
--- a/js/app/packages/block-project/component/Block.tsx
+++ b/js/app/packages/block-project/component/Block.tsx
@@ -4,6 +4,7 @@ import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import { getIsSpecialProject } from '@block-project/isSpecial';
import { useBlockId } from '@core/block';
import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
+import { useBlockEntityCommands } from '@app/component/next-soup/actions';
import { FileDropOverlay } from '@core/component/FileDropOverlay';
import { ENABLE_PROJECT_VIEW_PREVIEW } from '@core/constant/featureFlags';
import { fileFolderDrop } from '@core/directive/fileFolderDrop';
@@ -37,6 +38,7 @@ false && fileSelector;
const PROJECT_ENTITY_TYPES = ['document', 'task', 'chat', 'project'];
const Block: Component = () => {
+ useBlockEntityCommands();
const [isDragging, setIsDragging] = createSignal(false);
const projectId = useBlockId();
const isSpecialProject = getIsSpecialProject(projectId);
diff --git a/js/app/packages/block-video/component/Block.tsx b/js/app/packages/block-video/component/Block.tsx
index 854e41f855..7f1dacd58b 100644
--- a/js/app/packages/block-video/component/Block.tsx
+++ b/js/app/packages/block-video/component/Block.tsx
@@ -1,5 +1,6 @@
import { withAnalytics } from '@coparse/analytics';
import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
+import { useBlockEntityCommands } from '@app/component/next-soup/actions';
import { toast } from 'core/component/Toast/Toast';
import { createEffect, createSignal, Show } from 'solid-js';
import { blockData } from '../signal/blockData';
@@ -9,6 +10,7 @@ import { TopBar } from './TopBar';
const { track, TrackingEvents } = withAnalytics();
export default function BlockVideo() {
+ useBlockEntityCommands();
return (
<DocumentBlockContainer>
<div class="w-full h-full bg-panel select-none overscroll-none overflow-hidden flex flex-col relative">
diff --git a/js/app/packages/core/hotkey/getCommands.ts b/js/app/packages/core/hotkey/getCommands.ts
index 5ab0be70a9..7326497236 100644
--- a/js/app/packages/core/hotkey/getCommands.ts
+++ b/js/app/packages/core/hotkey/getCommands.ts
@@ -13,6 +13,8 @@ type sortAndFilterOptions = {
hideCommandsWithoutHotkeys?: boolean;
// shows only commands from the specified scope, not from all scopes
limitToCurrentScope?: boolean;
+ // skips the runWithInputFocused filter — use for the command menu where all commands should be shown regardless of input focus
+ ignoreInputFocused?: boolean;
};
// This is reactive on active scope (if scope not specified), activeElement, and commmand conditions.
@@ -88,7 +90,8 @@ const filterCommands = (displayOptions: sortAndFilterOptions) => {
return (
(command.hotkeys || !displayOptions.hideCommandsWithoutHotkeys) &&
(!command.condition || command.condition()) &&
- (!isEditableInput(activeElement() as HTMLElement) ||
+ (displayOptions.ignoreInputFocused ||
+ !isEditableInput(activeElement() as HTMLElement) ||
command.runWithInputFocused) &&
hideValue !== true
);