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

Before -> After
<p float="left">
  <img src="https://github.com/toeverything/AFFiNE/assets/20479050/b3937947-7c7c-4463-ae05-87b8f2694989" width="45%" />
  <img src="https://github.com/toeverything/AFFiNE/assets/20479050/e886c20d-e436-4190-aebf-a6b7d711b61e" width="45%" />
</p>
This commit is contained in:
L-Sun 2024-06-20 02:33:18 +00:00
parent 7c0a686cd9
commit 0d711667a8
No known key found for this signature in database
GPG Key ID: 4B5C21CB76DF6E92

View File

@ -76,25 +76,26 @@ export function setupSlashMenuEntry(slashMenu: AffineSlashMenuWidget) {
};
};
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' },
{
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);
},
},
...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,