mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix(core): disable space ai guidance for non-paragraph block (#11847)
### TL;DR Disable space ai guidance for non-paragraph block > CLOSE AI-67
This commit is contained in:
@@ -27,7 +27,12 @@ export function setupSpaceAIEntry(panel: AffineAIPanelWidget) {
|
|||||||
const selection = host.selection.find(TextSelection);
|
const selection = host.selection.find(TextSelection);
|
||||||
if (selection && selection.isCollapsed() && selection.from.index === 0) {
|
if (selection && selection.isCollapsed() && selection.from.index === 0) {
|
||||||
const block = host.view.getBlock(selection.blockId);
|
const block = host.view.getBlock(selection.blockId);
|
||||||
if (!block?.model?.text || block.model.text?.length > 0) return;
|
if (
|
||||||
|
!block?.model?.text ||
|
||||||
|
block.model.text?.length > 0 ||
|
||||||
|
block.model.flavour !== 'affine:paragraph'
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
handleInlineAskAIAction(host);
|
handleInlineAskAIAction(host);
|
||||||
|
|||||||
@@ -15,4 +15,24 @@ test.describe('AIBasic/Guidance', () => {
|
|||||||
await page.keyboard.press('Space');
|
await page.keyboard.press('Space');
|
||||||
await expect(page.locator('affine-ai-panel-widget')).toBeVisible();
|
await expect(page.locator('affine-ai-panel-widget')).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not show AI panel when space is pressed on non-empty paragraph', async ({
|
||||||
|
page,
|
||||||
|
utils,
|
||||||
|
}) => {
|
||||||
|
await utils.editor.focusToEditor(page);
|
||||||
|
await page.keyboard.insertText('HelloWorld');
|
||||||
|
await page.keyboard.press('Space');
|
||||||
|
await expect(page.locator('affine-ai-panel-widget')).not.toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not show AI panel when space is pressed on non-paragraph block', async ({
|
||||||
|
page,
|
||||||
|
utils,
|
||||||
|
}) => {
|
||||||
|
await utils.editor.focusToEditor(page);
|
||||||
|
await page.keyboard.insertText('```js');
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await expect(page.locator('affine-ai-panel-widget')).not.toBeVisible();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user