chore: merge blocksuite source code (#9213)

This commit is contained in:
Mirone
2024-12-20 15:38:06 +08:00
committed by GitHub
parent 2c9ef916f4
commit 30200ff86d
2031 changed files with 238888 additions and 229 deletions
@@ -0,0 +1,29 @@
import type { BlockModel, Doc, DraftModel } from '@blocksuite/store';
import { minimatch } from 'minimatch';
export function matchFlavours<Key extends (keyof BlockSuite.BlockModels)[]>(
model: DraftModel | null,
expected: Key
): model is BlockSuite.BlockModels[Key[number]] {
return (
!!model &&
expected.some(key =>
minimatch(model.flavour as keyof BlockSuite.BlockModels, key)
)
);
}
export function isInsideBlockByFlavour(
doc: Doc,
block: BlockModel | string,
flavour: string
): boolean {
const parent = doc.getParent(block);
if (parent === null) {
return false;
}
if (flavour === parent.flavour) {
return true;
}
return isInsideBlockByFlavour(doc, parent, flavour);
}