Skip to content

Commit 3be9d26

Browse files
committed
fixup! ✨(frontend) integrate new Blocknote AI feature
1 parent 25c23f9 commit 3be9d26

File tree

2 files changed

+86
-22
lines changed

2 files changed

+86
-22
lines changed
Lines changed: 6 additions & 0 deletions
Loading

src/frontend/apps/impress/src/features/docs/doc-editor/components/AI/AIUI.tsx

Lines changed: 80 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,105 @@ import {
66
} from '@blocknote/xl-ai';
77
import '@blocknote/xl-ai/style.css';
88
import { useTranslation } from 'react-i18next';
9-
import { css } from 'styled-components';
9+
import { createGlobalStyle, css } from 'styled-components';
1010

11-
import { Box, Text } from '@/components';
11+
import { Box, Icon, Text } from '@/components';
1212
import { useCunninghamTheme } from '@/cunningham';
1313

1414
import IconAI from '../../assets/IconAI.svg';
15+
import IconWandStar from '../../assets/wand_stars.svg';
1516
import {
1617
DocsBlockNoteEditor,
1718
DocsBlockSchema,
1819
DocsInlineContentSchema,
1920
DocsStyleSchema,
2021
} from '../../types';
2122

23+
const AIMenuStyle = createGlobalStyle`
24+
#ai-suggestion-menu .bn-suggestion-menu-item-small .bn-mt-suggestion-menu-item-section[data-position=left] svg {
25+
height: 18px;
26+
width: 18px;
27+
}
28+
`;
29+
2230
export function AIMenu() {
2331
return (
24-
<AIMenuDefault
25-
items={(editor: DocsBlockNoteEditor, aiResponseStatus) => {
26-
if (aiResponseStatus === 'user-input') {
27-
if (editor.getSelection()) {
28-
const aiMenuItems = getDefaultAIMenuItems(
29-
editor,
30-
aiResponseStatus,
31-
).filter((item) => ['simplify'].indexOf(item.key) === -1);
32+
<>
33+
<AIMenuStyle />
34+
<AIMenuDefault
35+
items={(editor: DocsBlockNoteEditor, aiResponseStatus) => {
36+
if (aiResponseStatus === 'user-input') {
37+
let aiMenuItems = getDefaultAIMenuItems(editor, aiResponseStatus);
3238

33-
return aiMenuItems;
34-
} else {
35-
const aiMenuItems = getDefaultAIMenuItems(
36-
editor,
37-
aiResponseStatus,
38-
).filter(
39-
(item) =>
40-
['action_items', 'write_anything'].indexOf(item.key) === -1,
39+
if (editor.getSelection()) {
40+
aiMenuItems = aiMenuItems.filter(
41+
(item) => ['simplify'].indexOf(item.key) === -1,
42+
);
43+
44+
aiMenuItems = aiMenuItems.map((item) => {
45+
if (item.key === 'improve_writing') {
46+
return {
47+
...item,
48+
icon: <IconWandStar />,
49+
};
50+
} else if (item.key === 'translate') {
51+
return {
52+
...item,
53+
icon: (
54+
<Icon
55+
iconName="translate"
56+
$color="inherit"
57+
$size="18px"
58+
/>
59+
),
60+
};
61+
}
62+
63+
return item;
64+
});
65+
} else {
66+
aiMenuItems = aiMenuItems.filter(
67+
(item) =>
68+
['action_items', 'write_anything'].indexOf(item.key) === -1,
69+
);
70+
}
71+
72+
console.log(
73+
'AI ser state ',
74+
getDefaultAIMenuItems(editor, aiResponseStatus),
4175
);
4276

4377
return aiMenuItems;
78+
} else if (aiResponseStatus === 'user-reviewing') {
79+
return getDefaultAIMenuItems(editor, aiResponseStatus).map(
80+
(item) => {
81+
if (item.key === 'accept') {
82+
return {
83+
...item,
84+
icon: (
85+
<Icon
86+
iconName="check_circle"
87+
$color="inherit"
88+
$size="18px"
89+
/>
90+
),
91+
};
92+
}
93+
return item;
94+
},
95+
);
4496
}
45-
}
4697

47-
return getDefaultAIMenuItems(editor, aiResponseStatus);
48-
}}
49-
/>
98+
console.log(
99+
'AI tete state ',
100+
aiResponseStatus,
101+
getDefaultAIMenuItems(editor, aiResponseStatus),
102+
);
103+
104+
return getDefaultAIMenuItems(editor, aiResponseStatus);
105+
}}
106+
/>
107+
</>
50108
);
51109
}
52110

0 commit comments

Comments
 (0)