There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(core): unable to copy the selected ai answer content across multiple lines (#11806)
yoyoyohamapidcfc92347f06
diff --git a/packages/frontend/core/src/blocksuite/ai/components/text-renderer.ts b/packages/frontend/core/src/blocksuite/ai/components/text-renderer.tsindex f14bb3f9d7..32f336923b 100644--- a/packages/frontend/core/src/blocksuite/ai/components/text-renderer.ts+++ b/packages/frontend/core/src/blocksuite/ai/components/text-renderer.ts@@ -358,6 +358,7 @@ export const createTextRenderer: () => AffineAIPanelWidgetConfig['answerRenderer'] = (host, options) => {return (answer, state) => {return html`<text-renderer+ contenteditable="false".host=${host}.answer=${answer}.state=${state}diff --git a/tests/affine-cloud-copilot/e2e/basic/chat.spec.ts b/tests/affine-cloud-copilot/e2e/basic/chat.spec.tsindex cd0c1f5de3..632f7ac0e9 100644--- a/tests/affine-cloud-copilot/e2e/basic/chat.spec.ts+++ b/tests/affine-cloud-copilot/e2e/basic/chat.spec.ts@@ -1,3 +1,4 @@+import { copyByKeyboard } from '@affine-test/kit/utils/keyboard';import { expect } from '@playwright/test';import { test } from '../base/base-test';@@ -330,7 +331,6 @@ test.describe('AIBasic/Chat', () => {await utils.chatPanel.clearChat(page);await utils.chatPanel.waitForHistory(page, []);});-test('should support copying answer', async ({loggedInPage: page,utils,@@ -360,6 +360,58 @@ test.describe('AIBasic/Chat', () => {}).toPass({ timeout: 5000 });});+ test('should support copying selected answer content', async ({+ loggedInPage: page,+ utils,+ }) => {+ await utils.chatPanel.openChatPanel(page);+ await utils.chatPanel.makeChat(+ page,+ 'Help me write a two-line love poem, return two paragraphs for me.'+ );+ await utils.chatPanel.waitForHistory(page, [+ {+ role: 'user',+ content:+ 'Help me write a two-line love poem, return two paragraphs for me.',+ },+ {+ role: 'assistant',+ status: 'success',+ },+ ]);++ await expect(async () => {+ const { content, message } =+ await utils.chatPanel.getLatestAssistantMessage(page);+ // Select multiple rich text+ const firstParagraph = await message+ .locator('affine-paragraph rich-text v-text')+ .first()+ .boundingBox();+ const lastParagraph = await message+ .locator('affine-paragraph rich-text v-text')+ .last()+ .boundingBox();++ if (firstParagraph && lastParagraph) {+ await page.mouse.move(firstParagraph.x, firstParagraph.y);+ await page.mouse.down();+ await page.mouse.move(+ lastParagraph.x + lastParagraph.width,+ lastParagraph.y + lastParagraph.height+ );+ await page.mouse.up();+ }++ await copyByKeyboard(page);+ const clipboardText = await page.evaluate(() =>+ navigator.clipboard.readText()+ );+ expect(clipboardText).toBe(content);+ }).toPass({ timeout: 5000 });+ });+test('chat with ask ai input in page mode', async ({loggedInPage: page,utils,diff --git a/tests/affine-cloud-copilot/e2e/utils/editor-utils.ts b/tests/affine-cloud-copilot/e2e/utils/editor-utils.tsindex 3608ce32eb..c3a5bda722 100644--- a/tests/affine-cloud-copilot/e2e/utils/editor-utils.ts+++ b/tests/affine-cloud-copilot/e2e/utils/editor-utils.ts@@ -319,7 +319,8 @@ export class EditorUtils {) {// Create tagconst tags = await page.getByTestId('explorer-tags');- await tags.getByTestId('explorer-bar-add-favorite-button').click();+ await tags.hover();+ await tags.getByTestId('explorer-bar-add-tag-button').click();const input = await page.getByTestId('rename-modal-input');await input.focus();await input.pressSequentially(tagName);