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

@@ -1,6 +1,5 @@
import type { InsertToPosition } from '@blocksuite/affine-shared/utils';
import { Point, Rect } from '@blocksuite/global/gfx';
import { assertExists } from '@blocksuite/global/utils';
import { computed } from '@preact/signals-core';
import type { ReactiveController } from 'lit';
@@ -137,7 +136,6 @@ export class KanbanDragController implements ReactiveController {
const scrollContainer = this.host.querySelector(
'.affine-data-view-kanban-groups'
) as HTMLElement;
assertExists(scrollContainer);
return scrollContainer;
}
@@ -213,7 +211,10 @@ const createDropPreview = () => {
card?: KanbanCard
) {
const target = card ?? group.querySelector('.add-card');
assertExists(target);
if (!target) {
console.error('`target` is not found');
return;
}
if (target.previousElementSibling === self || target === self) {
div.remove();
return;

View File

@@ -1,5 +1,4 @@
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { assertExists } from '@blocksuite/global/utils';
import type { ReactiveController } from 'lit';
import type {
@@ -611,7 +610,7 @@ function getNextGroupFocusElement(
selection.selectionType === 'cell'
? getFocusCell(viewElement, selection)
: getSelectedCards(viewElement, selection)[0];
assertExists(element);
if (!element) return;
const rect = element.getBoundingClientRect();
const nextCards = Array.from(
nextGroup.querySelectorAll('affine-data-view-kanban-card')

View File

@@ -1,9 +1,5 @@
import { ShadowlessElement } from '@blocksuite/block-std';
import {
assertExists,
SignalWatcher,
WithDisposable,
} from '@blocksuite/global/utils';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
import { computed } from '@preact/signals-core';
import { css } from 'lit';
import { property, state } from 'lit/decorators.js';
@@ -102,7 +98,6 @@ export class DatabaseCellContainer extends SignalWatcher(
get table() {
const table = this.closest('affine-database-table');
assertExists(table);
return table;
}