Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

chore: adjust order of slash menu items (#7278)

L-Sun0d711667a860
diff --git a/packages/frontend/core/src/blocksuite/presets/ai/entries/slash-menu/setup-slash-menu.ts b/packages/frontend/core/src/blocksuite/presets/ai/entries/slash-menu/setup-slash-menu.ts
index 14ef788cf1..6a6ffdbbfa 100644
--- a/packages/frontend/core/src/blocksuite/presets/ai/entries/slash-menu/setup-slash-menu.ts
+++ b/packages/frontend/core/src/blocksuite/presets/ai/entries/slash-menu/setup-slash-menu.ts
@@ -76,25 +76,26 @@ export function setupSlashMenuEntry(slashMenu: AffineSlashMenuWidget) {
};
};
- const AIMenuItems: AffineSlashMenuItem[] = [
- { groupName: 'AFFiNE AI' },
- {
- name: 'Ask AI',
- icon: AIStarIcon,
- showWhen: showWhenWrapper(),
- action: ({ rootElement }) => {
- const view = rootElement.host.view;
- const affineAIPanelWidget = view.getWidget(
- AFFINE_AI_PANEL_WIDGET,
- rootElement.model.id
- ) as AffineAIPanelWidget;
- assertExists(affineAIPanelWidget);
- assertExists(AIProvider.actions.chat);
- assertExists(affineAIPanelWidget.host);
- handleInlineAskAIAction(affineAIPanelWidget.host);
- },
+ const menu = slashMenu.config.items.slice();
+ menu.unshift({
+ name: 'Ask AI',
+ icon: AIStarIcon,
+ showWhen: showWhenWrapper(),
+ action: ({ rootElement }) => {
+ const view = rootElement.host.view;
+ const affineAIPanelWidget = view.getWidget(
+ AFFINE_AI_PANEL_WIDGET,
+ rootElement.model.id
+ ) as AffineAIPanelWidget;
+ assertExists(affineAIPanelWidget);
+ assertExists(AIProvider.actions.chat);
+ assertExists(affineAIPanelWidget.host);
+ handleInlineAskAIAction(affineAIPanelWidget.host);
},
+ });
+ const AIMenuItems: AffineSlashMenuItem[] = [
+ { groupName: 'AFFiNE AI' },
...AIItems.filter(({ name }) =>
['Fix spelling', 'Fix grammar'].includes(name)
).map(item => ({
@@ -128,8 +129,11 @@ export function setupSlashMenuEntry(slashMenu: AffineSlashMenuWidget) {
},
];
- const menu = slashMenu.config.items.slice();
- menu.unshift(...AIMenuItems);
+ const basicGroupEnd = menu.findIndex(
+ item => 'groupName' in item && item.groupName === 'List'
+ );
+ // insert ai item after basic group
+ menu.splice(basicGroupEnd, 0, ...AIMenuItems);
slashMenu.config = {
...AffineSlashMenuWidget.DEFAULT_CONFIG,