mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 19:53:48 +08: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:
+23
-19
@@ -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[] = [
|
const AIMenuItems: AffineSlashMenuItem[] = [
|
||||||
{ groupName: 'AFFiNE AI' },
|
{ 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 }) =>
|
...AIItems.filter(({ name }) =>
|
||||||
['Fix spelling', 'Fix grammar'].includes(name)
|
['Fix spelling', 'Fix grammar'].includes(name)
|
||||||
).map(item => ({
|
).map(item => ({
|
||||||
@@ -128,8 +129,11 @@ export function setupSlashMenuEntry(slashMenu: AffineSlashMenuWidget) {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const menu = slashMenu.config.items.slice();
|
const basicGroupEnd = menu.findIndex(
|
||||||
menu.unshift(...AIMenuItems);
|
item => 'groupName' in item && item.groupName === 'List'
|
||||||
|
);
|
||||||
|
// insert ai item after basic group
|
||||||
|
menu.splice(basicGroupEnd, 0, ...AIMenuItems);
|
||||||
|
|
||||||
slashMenu.config = {
|
slashMenu.config = {
|
||||||
...AffineSlashMenuWidget.DEFAULT_CONFIG,
|
...AffineSlashMenuWidget.DEFAULT_CONFIG,
|
||||||
|
|||||||
Reference in New Issue
Block a user