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
1147
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 to 0.5.0-20230227215422-5b7fc14

src/types.ts

32

index.d.ts

@@ -72,2 +72,6 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any

enable_slash_menu: boolean;
/**
* Block selection can trigger format bar
*/
enable_block_selection_format_bar: boolean;
enable_edgeless_toolbar: boolean;

@@ -88,27 +92,2 @@ readonly: Record<string, boolean>;

}
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;
};
}

@@ -129,2 +108,3 @@

declare namespace BlockSuiteModelProps {
import type { Text } from '@blocksuite/store';
interface CodeBlockModel {

@@ -155,3 +135,3 @@ language: string;

interface PageBlockModel {
title: string;
title: Text;
}

@@ -158,0 +138,0 @@

{
"name": "@blocksuite/global",
"version": "0.4.1",
"version": "0.5.0-20230227215422-5b7fc14",
"types": "./index.d.ts",
"type": "module",
"scripts": {
"test:unit": "vitest --run",
"test:unit:coverage": "vitest run --coverage",
"test:unit:ui": "vitest --ui",
"build": "tsc"
},
"sideEffects": false,
"exports": {
".": "./index.d.ts",
"./database": "./dist/database.js",
"./utils": "./dist/utils.js",
"./debug": "./dist/debug.js",
"./error": "./dist/error.js",
"./config": "./dist/config/index.js"
"./database": "./src/database.ts",
"./types": "./src/types.ts",
"./utils": "./src/utils.ts",
"./debug": "./src/debug.ts",
"./config": "./src/config/index.ts",
"./error": "./src/error.ts"
},

@@ -19,2 +26,10 @@ "author": "toeverything",

"access": "public",
"exports": {
".": "./index.d.ts",
"./database": "./dist/database.js",
"./utils": "./dist/utils.js",
"./debug": "./dist/debug.js",
"./error": "./dist/error.js",
"./config": "./dist/config/index.js"
},
"files": [

@@ -39,9 +54,3 @@ "dist",

}
},
"scripts": {
"test:unit": "vitest --run",
"test:unit:coverage": "vitest run --coverage",
"test:unit:ui": "vitest --ui",
"build": "tsc"
}
}
}
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;

@@ -30,1 +30,2 @@ export const ALLOW_DEFAULT = true;

export const BLOCK_CHILDREN_CONTAINER_PADDING_LEFT = 26;
export const DRAG_HANDLE_OFFSET_LEFT = 20;

@@ -6,6 +6,6 @@ export const plate = {

hoverBackground: '#f1f3ff',
cardHoverBackground: '#f1f3ff',
codeBackground: '#f2f5f9',
codeBlockBackground: '#fafbfd',
blockHubBackground: '#fbfbfc',
blockHubHoverBackground: '#f8f9ff',
textColor: '#3a4c5c',

@@ -45,4 +45,4 @@ edgelessTextColor: '#3a4c5c',

{
name: 'blockHubHoverBackground',
cssProperty: '--affine-block-hub-hover-background',
name: 'cardHoverBackground',
cssProperty: '--affine-card-hover-background',
},

@@ -49,0 +49,0 @@ { name: 'textColor', cssProperty: '--affine-text-color' },

@@ -202,5 +202,5 @@ import type { TemplateResult } from 'lit/html.js';

name: 'Divider',
description: 'A visually divide block.',
description: 'A visual divider.',
icon: DividerIcon,
toolTip: 'Drag to insert Divider',
toolTip: 'A visual divider',
},

@@ -216,3 +216,3 @@ ];

icon: BulletedListIcon,
toolTip: 'Drag to insert Bulleted List.',
toolTip: 'Drag to insert Bulleted List',
},

@@ -223,5 +223,5 @@ {

name: 'Numbered List',
description: '1. A list with numbering.',
description: 'A list with numbering.',
icon: NumberedListIcon,
toolTip: 'Drag to insert Numbered List.',
toolTip: 'Drag to insert Numbered List',
},

@@ -234,3 +234,3 @@ {

icon: TodoIcon,
toolTip: 'Drag to insert To-do List.',
toolTip: 'Drag to insert To-do List',
},

@@ -246,4 +246,4 @@ ];

icon: ImageIcon,
toolTip: 'Drag to insert Image.',
toolTip: 'Drag to insert Image',
},
];

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

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

@@ -14,5 +18,8 @@ export { DisposableGroup, flattenDisposable } from './utils/disposable.js';

export function assertExists<T>(val: T | null | undefined): asserts val is T {
export function assertExists<T>(
val: T | null | undefined,
message = 'val does not exist'
): asserts val is T {
if (val === null || val === undefined) {
throw new Error('val does not exist');
throw new Error(message);
}

@@ -27,13 +34,23 @@ }

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',

@@ -46,7 +63,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);

@@ -53,0 +69,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