refactor(editor): remove assertExists (#10615)

This commit is contained in:
Saul-Mirone
2025-03-05 00:13:08 +00:00
parent a6692f70aa
commit b8ecfbdae6
106 changed files with 863 additions and 517 deletions

View File

@@ -5,7 +5,6 @@ import type {
ListType,
RichText,
} from '@blocksuite/blocks';
import { assertExists } from '@blocksuite/global/utils';
import type { InlineRange, InlineRootElement } from '@blocksuite/inline';
import type { TestAffineEditorContainer } from '@blocksuite/integration-test';
import type { BlockModel } from '@blocksuite/store';
@@ -42,7 +41,9 @@ export const getSelectionRect = async (page: Page): Promise<DOMRect> => {
const rect = await page.evaluate(() => {
return getSelection()?.getRangeAt(0).getBoundingClientRect();
});
assertExists(rect);
if (!rect) {
throw new Error('rect is not found');
}
return rect;
};
@@ -864,7 +865,9 @@ export async function getClipboardSnapshot(page: Page) {
page,
'BLOCKSUITE/SNAPSHOT'
);
assertExists(dataInClipboard);
if (!dataInClipboard) {
throw new Error('dataInClipboard is not found');
}
const json = JSON.parse(dataInClipboard as string);
return json;
}