@blocksuite/global
Advanced tools
Comparing version 0.4.0-20230123235526-9112dad to 0.4.0-20230124211050-22f6e52
@@ -13,3 +13,7 @@ export { isFirefox, isWeb, caretRangeFromPoint } from './utils/web.js'; | ||
flavour: Key; | ||
}, expected: Key[]): boolean; | ||
}, expected: readonly Key[]): boolean; | ||
export declare const nonTextBlock: (keyof BlockSuiteInternal.BlockModels)[]; | ||
export declare const isNonTextBlock: <Key extends "affine:paragraph" | "affine:page" | "affine:list" | "affine:frame" | "affine:code" | "affine:divider" | "affine:embed" | "affine:surface" | "affine:database" = "affine:paragraph" | "affine:page" | "affine:list" | "affine:frame" | "affine:code" | "affine:divider" | "affine:embed" | "affine:surface" | "affine:database">(model: { | ||
flavour: Key; | ||
}) => boolean; | ||
type Allowed = null | undefined | boolean | number | string | Record<string, unknown> | unknown[]; | ||
@@ -16,0 +20,0 @@ export declare function assertEquals<T extends Allowed, U extends T>(val: T, expected: U): asserts val is U; |
@@ -22,2 +22,9 @@ export { isFirefox, isWeb, caretRangeFromPoint } from './utils/web.js'; | ||
} | ||
export const nonTextBlock = [ | ||
'affine:database', | ||
'affine:divider', | ||
'affine:embed', | ||
'affine:code', | ||
]; | ||
export const isNonTextBlock = (model) => matchFlavours(model, nonTextBlock); | ||
export function assertEquals(val, expected) { | ||
@@ -24,0 +31,0 @@ const a = isPrimitive(val); |
@@ -67,2 +67,3 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
enable_set_remote_flag: boolean; | ||
enable_database: boolean; | ||
enable_drag_handle: boolean; | ||
@@ -168,2 +169,3 @@ enable_surface: boolean; | ||
SurfaceBlockModel, | ||
DatabaseBlockModel, | ||
} from '@blocksuite/blocks'; | ||
@@ -179,4 +181,4 @@ | ||
'affine:embed': EmbedBlockModel; | ||
// 'affine:shape': ShapeBlockModel, | ||
'affine:surface': SurfaceBlockModel; | ||
'affine:database': DatabaseBlockModel; | ||
}; | ||
@@ -230,2 +232,9 @@ } | ||
import type { ColorStyle, TDShapeType } from '@blocksuite/blocks'; | ||
interface DatabaseBlockModel { | ||
columns: BlockSuiteInternal.ColumnTypes[]; | ||
title: string; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
@@ -235,2 +244,3 @@ interface SurfaceBlockModel {} | ||
export type ALL = { | ||
'affine:database': DatabaseBlockModel; | ||
'affine:paragraph': ParagraphBlockModel; | ||
@@ -237,0 +247,0 @@ 'affine:page': PageBlockModel; |
{ | ||
"name": "@blocksuite/global", | ||
"version": "0.4.0-20230123235526-9112dad", | ||
"version": "0.4.0-20230124211050-22f6e52", | ||
"types": "./index.d.ts", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -31,3 +31,3 @@ export { isFirefox, isWeb, caretRangeFromPoint } from './utils/web.js'; | ||
model: { flavour: Key }, | ||
expected: Key[] | ||
expected: readonly Key[] | ||
): boolean /* model is BlockModels[Key] */ { | ||
@@ -37,2 +37,16 @@ return expected.includes(model.flavour as Key); | ||
export const nonTextBlock: (keyof BlockSuiteInternal.BlockModels)[] = [ | ||
'affine:database', | ||
'affine:divider', | ||
'affine:embed', | ||
'affine:code', | ||
]; | ||
export const isNonTextBlock = < | ||
Key extends keyof BlockSuiteInternal.BlockModels & | ||
string = keyof BlockSuiteInternal.BlockModels & string | ||
>(model: { | ||
flavour: Key; | ||
}) => matchFlavours(model, nonTextBlock); | ||
type Allowed = | ||
@@ -39,0 +53,0 @@ | null |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
215745
2504