mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 12:06:35 +08:00
fix(editor): overflow of embed github card in edgeless note (#10442)
This PR fixes the overflow of the `embed-github-card` inside edgeless notes. https://github.com/user-attachments/assets/21775d0f-e4c8-4fcc-86d8-aafb27033358
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { setTimeout } from 'node:timers/promises';
|
||||
|
||||
import type { Page } from '@playwright/test';
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
export async function waitForLogMessage(
|
||||
@@ -36,3 +36,37 @@ export async function removeWithRetry(
|
||||
// Add a return statement here to ensure that a value is always returned
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function isContainedInBoundingBox(
|
||||
container: Locator,
|
||||
element: Locator,
|
||||
includeDescendant = false
|
||||
) {
|
||||
const containerBox = await container.boundingBox();
|
||||
if (!containerBox) {
|
||||
throw new Error('Container bounding box not found');
|
||||
}
|
||||
const { x: cx, y: cy, width: cw, height: ch } = containerBox;
|
||||
|
||||
const inside = async (el: Locator): Promise<boolean> => {
|
||||
const elBox = await el.boundingBox();
|
||||
if (!elBox) {
|
||||
throw new Error('Element bounding box not found');
|
||||
}
|
||||
const { x, y, width, height } = elBox;
|
||||
|
||||
return x >= cx && x + width <= cx + cw && y >= cy && y + height <= cy + ch;
|
||||
};
|
||||
|
||||
let isInside = await inside(element);
|
||||
if (!isInside) return false;
|
||||
|
||||
if (includeDescendant) {
|
||||
const children = await element.locator('*:visible').all();
|
||||
for (const child of children) {
|
||||
isInside = await inside(child);
|
||||
if (!isInside) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user