mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 16:46:22 +08:00
refactor(editor): remove assertExists (#10615)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import { html, LitElement, type TemplateResult } from 'lit';
|
||||
import { property } from 'lit/decorators.js';
|
||||
import { styleMap } from 'lit/directives/style-map.js';
|
||||
@@ -14,12 +13,19 @@ export class VLine extends LitElement {
|
||||
const rootElement = this.closest(
|
||||
`[${INLINE_ROOT_ATTR}]`
|
||||
) as InlineRootElement;
|
||||
assertExists(rootElement, 'v-line must be inside a v-root');
|
||||
if (!rootElement) {
|
||||
throw new BlockSuiteError(
|
||||
BlockSuiteError.ErrorCode.ValueNotExists,
|
||||
'v-line must be inside a v-root'
|
||||
);
|
||||
}
|
||||
const inlineEditor = rootElement.inlineEditor;
|
||||
assertExists(
|
||||
inlineEditor,
|
||||
'v-line must be inside a v-root with inline-editor'
|
||||
);
|
||||
if (!inlineEditor) {
|
||||
throw new BlockSuiteError(
|
||||
BlockSuiteError.ErrorCode.ValueNotExists,
|
||||
'v-line must be inside a v-root with inline-editor'
|
||||
);
|
||||
}
|
||||
|
||||
return inlineEditor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user