mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-12 23:56:36 +08:00
fix(editor): support copying single image from edgeless and pasting to page (#12709)
Closes: [BS-3586](https://linear.app/affine-design/issue/BS-3586/复制白板图片,然后粘贴到-page,图片失败) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Copying a single selected image in edgeless mode now places the image directly onto the system clipboard as a native image blob for smoother pasting. - **Bug Fixes** - Enhanced clipboard handling to better manage image and text data inclusion, with improved fallback for snapshot HTML. - **Tests** - Added an end-to-end test verifying image copy-paste functionality between edgeless and page editor modes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import { test } from '@affine-test/kit/playwright';
|
||||
import { importFile } from '@affine-test/kit/utils/attachment';
|
||||
import { pasteContent } from '@affine-test/kit/utils/clipboard';
|
||||
import {
|
||||
clickEdgelessModeButton,
|
||||
clickPageModeButton,
|
||||
clickView,
|
||||
getCodeBlockIds,
|
||||
getParagraphIds,
|
||||
locateEditorContainer,
|
||||
toViewCoord,
|
||||
} from '@affine-test/kit/utils/editor';
|
||||
import {
|
||||
copyByKeyboard,
|
||||
@@ -470,3 +473,36 @@ test.describe('paste in readonly mode', () => {
|
||||
await verifyParagraphContent(page, 0, 'This is a test paragraph');
|
||||
});
|
||||
});
|
||||
|
||||
test('should copy single image from edgeless and paste to page', async ({
|
||||
page,
|
||||
}) => {
|
||||
await clickEdgelessModeButton(page);
|
||||
|
||||
const button = page.locator('edgeless-mindmap-tool-button');
|
||||
await button.click();
|
||||
|
||||
const menu = page.locator('edgeless-mindmap-menu');
|
||||
const mediaItem = menu.locator('.media-item');
|
||||
await mediaItem.click();
|
||||
|
||||
await importFile(page, 'large-image.png', async () => {
|
||||
await toViewCoord(page, [100, 250]);
|
||||
await clickView(page, [100, 250]);
|
||||
});
|
||||
|
||||
const image = page.locator('affine-edgeless-image').first();
|
||||
await image.click();
|
||||
|
||||
await copyByKeyboard(page);
|
||||
|
||||
await clickPageModeButton(page);
|
||||
await waitForEditorLoad(page);
|
||||
|
||||
const container = locateEditorContainer(page);
|
||||
await container.click();
|
||||
|
||||
await pasteByKeyboard(page);
|
||||
|
||||
await expect(page.locator('affine-page-image')).toBeVisible();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user