mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 04:51:49 +08:00
chore: add empty text assert
This commit is contained in:
@@ -9,10 +9,10 @@ import {
|
|||||||
BlockDecoration,
|
BlockDecoration,
|
||||||
MapOperation,
|
MapOperation,
|
||||||
} from '@toeverything/datasource/jwt';
|
} from '@toeverything/datasource/jwt';
|
||||||
|
import { cloneDeep } from '@toeverything/utils';
|
||||||
import type { EventData } from '../block';
|
import type { EventData } from '../block';
|
||||||
import { AsyncBlock } from '../block';
|
import { AsyncBlock } from '../block';
|
||||||
import type { Editor } from '../editor';
|
import type { Editor } from '../editor';
|
||||||
import { cloneDeep } from '@toeverything/utils';
|
|
||||||
import { SelectBlock } from '../selection';
|
import { SelectBlock } from '../selection';
|
||||||
|
|
||||||
export interface CreateView {
|
export interface CreateView {
|
||||||
@@ -114,7 +114,21 @@ export abstract class BaseView {
|
|||||||
// Whether the component is empty
|
// Whether the component is empty
|
||||||
isEmpty(block: AsyncBlock): boolean {
|
isEmpty(block: AsyncBlock): boolean {
|
||||||
const text = block.getProperty('text');
|
const text = block.getProperty('text');
|
||||||
return !text?.value?.[0]?.text;
|
const result = !text?.value?.[0]?.text;
|
||||||
|
|
||||||
|
// Assert that the text is really empty
|
||||||
|
if (
|
||||||
|
result &&
|
||||||
|
block.getProperty('text')?.value.some(content => content.text)
|
||||||
|
) {
|
||||||
|
console.warn(
|
||||||
|
'Assertion isEmpty error! The block has an empty start fragment, but it is not empty',
|
||||||
|
block
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Assert end
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelProperties(block: AsyncBlock, selectInfo: any): DefaultColumnsValue {
|
getSelProperties(block: AsyncBlock, selectInfo: any): DefaultColumnsValue {
|
||||||
|
|||||||
Reference in New Issue
Block a user