Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blocksuite/global

Package Overview
Dependencies
Maintainers
5
Versions
1150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blocksuite/global - npm Package Compare versions

Comparing version 0.4.1-20230225180029-daf8dec to 0.4.1-20230226175811-d32fc6d

src/types.ts

25

index.d.ts

@@ -91,27 +91,2 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any

}
import type {
// Model
CodeBlockModel,
DatabaseBlockModel,
DividerBlockModel,
EmbedBlockModel,
FrameBlockModel,
ListBlockModel,
PageBlockModel,
ParagraphBlockModel,
SurfaceBlockModel,
} from '@blocksuite/blocks/models';
export type BlockModels = {
'affine:paragraph': ParagraphBlockModel;
'affine:page': PageBlockModel;
'affine:list': ListBlockModel;
'affine:frame': FrameBlockModel;
'affine:code': CodeBlockModel;
'affine:divider': DividerBlockModel;
'affine:embed': EmbedBlockModel;
'affine:surface': SurfaceBlockModel;
'affine:database': DatabaseBlockModel;
};
}

@@ -118,0 +93,0 @@

3

package.json
{
"name": "@blocksuite/global",
"version": "0.4.1-20230225180029-daf8dec",
"version": "0.4.1-20230226175811-d32fc6d",
"types": "./index.d.ts",

@@ -16,2 +16,3 @@ "type": "module",

"./database": "./src/database.ts",
"./types": "./src/types.ts",
"./utils": "./src/utils.ts",

@@ -18,0 +19,0 @@ "./debug": "./src/debug.ts",

export * from './consts/affine-style-consts.js';
export * from './consts/blockhub.js';
export const BLOCK_ID_ATTR = 'data-block-id' as const;
export const BLOCK_SERVICE_LOADING_ATTR = 'data-service-loading' as const;
export const BLOCK_ID_ATTR = 'data-block-id';
export const BLOCK_SERVICE_LOADING_ATTR = 'data-service-loading';
export const PREVENT_DEFAULT = false;

@@ -7,0 +7,0 @@ export const ALLOW_DEFAULT = true;

@@ -0,1 +1,5 @@

import type { BaseBlockModel } from '@blocksuite/store';
import type { BlockModels } from './types.js';
export type { Disposable } from './utils/disposable.js';

@@ -26,13 +30,23 @@ export { DisposableGroup, flattenDisposable } from './utils/disposable.js';

export function matchFlavours<
Key extends keyof BlockSuiteInternal.BlockModels &
string = keyof BlockSuiteInternal.BlockModels & string
>(
model: { flavour: Key },
expected: readonly Key[]
): boolean /* model is BlockModels[Key] */ {
return expected.includes(model.flavour as Key);
type BlockModelKey = keyof BlockModels;
type Flavours<T> = T extends BlockModelKey[] ? BlockModels[T[number]] : never;
type Writeable<T> = { -readonly [P in keyof T]: T[P] };
export function matchFlavours<Key extends Readonly<Array<string>>>(
model: BaseBlockModel,
expected: Key
): model is Flavours<Writeable<Key>> {
return expected.includes(model.flavour);
}
// export function matchFlavours<
// Key extends keyof BlockModels &
// string = keyof BlockModels & string
// >(
// model: { flavour: Key },
// expected: readonly Key[]
// ): model is BlockModels[Key] {
// return expected.includes(model.flavour as Key);
// }
export const nonTextBlock: (keyof BlockSuiteInternal.BlockModels)[] = [
export const nonTextBlock: (keyof BlockModels)[] = [
'affine:database',

@@ -45,7 +59,6 @@ 'affine:divider',

export const isNonTextBlock = <
Key extends keyof BlockSuiteInternal.BlockModels &
string = keyof BlockSuiteInternal.BlockModels & string
>(model: {
flavour: Key;
}) => matchFlavours(model, nonTextBlock);
Key extends keyof BlockModels & string = keyof BlockModels & string
>(
model: BaseBlockModel
) => matchFlavours(model, nonTextBlock);

@@ -52,0 +65,0 @@ type Allowed =

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc