refactor(core): improve editor gap appendParagraph function (#8567)

close AF-1257

Every time we clicked on an empty space at the bottom, a new Paragraph block was created.
Now we change it so that if there is already an empty Paragraph block at the bottom, we focus it instead of creating a new one.
This commit is contained in:
JimmFly
2024-10-24 10:53:18 +00:00
parent 6d7c0d45ce
commit 10963da706
3 changed files with 83 additions and 7 deletions

View File

@@ -64,3 +64,25 @@ test('link page is useable', async ({ page }) => {
page.locator('.doc-title-container:has-text("page1")')
).toBeVisible();
});
test('append paragraph when click editor gap', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await clickNewPageButton(page);
await waitForEditorLoad(page);
const title = getBlockSuiteEditorTitle(page);
await title.pressSequentially('test title');
await page.keyboard.press('ArrowDown');
await page.keyboard.insertText('test content');
const paragraph = page.locator('affine-paragraph');
const numParagraphs = await paragraph.count();
await page.locator('[data-testid=page-editor-blank]').click();
expect(await paragraph.count()).toBe(numParagraphs + 1);
// click the gap again, should not append another paragraph
await page.locator('[data-testid=page-editor-blank]').click();
expect(await paragraph.count()).toBe(numParagraphs + 1);
});