mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-09-11 11:47:00 +03:00
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:
parent
7c0a686cd9
commit
0d711667a8
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user