Skip to content

Commit

Permalink
chore: merge blocksuite source code (#9213)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul-Mirone authored Dec 20, 2024
1 parent 2c9ef91 commit 30200ff
Show file tree
Hide file tree
Showing 2,031 changed files with 238,895 additions and 236 deletions.
100 changes: 100 additions & 0 deletions blocksuite/affine/all/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"name": "@blocksuite/affine",
"description": "BlockSuite for Affine",
"type": "module",
"scripts": {
"build": "tsc --build --verbose",
"test:unit": "nx vite:test --run --passWithNoTests",
"test:unit:coverage": "nx vite:test --run --coverage",
"test:e2e": "playwright test"
},
"sideEffects": false,
"keywords": [],
"author": "toeverything",
"license": "MIT",
"dependencies": {
"@blocksuite/block-std": "workspace:*",
"@blocksuite/blocks": "workspace:*",
"@blocksuite/global": "workspace:*",
"@blocksuite/inline": "workspace:*",
"@blocksuite/presets": "workspace:*",
"@blocksuite/store": "workspace:*"
},
"exports": {
".": "./src/index.ts",
"./effects": "./src/effects.ts",
"./block-std": "./src/block-std/index.ts",
"./block-std/gfx": "./src/block-std/gfx.ts",
"./global": "./src/global/index.ts",
"./global/utils": "./src/global/utils.ts",
"./global/env": "./src/global/env.ts",
"./global/exceptions": "./src/global/exceptions.ts",
"./global/di": "./src/global/di.ts",
"./global/types": "./src/global/types.ts",
"./store": "./src/store/index.ts",
"./inline": "./src/inline/index.ts",
"./inline/consts": "./src/inline/consts.ts",
"./inline/types": "./src/inline/types.ts",
"./presets": "./src/presets/index.ts",
"./blocks": "./src/blocks/index.ts",
"./blocks/schemas": "./src/blocks/schemas.ts"
},
"typesVersions": {
"*": {
"effects": [
"dist/effects.d.ts"
],
"block-std": [
"dist/block-std/index.d.ts"
],
"block-std/gfx": [
"dist/block-std/gfx.d.ts"
],
"global": [
"dist/global/index.d.ts"
],
"global/utils": [
"dist/global/utils.d.ts"
],
"global/env": [
"dist/global/env.d.ts"
],
"global/exceptions": [
"dist/global/exceptions.d.ts"
],
"global/di": [
"dist/global/di.d.ts"
],
"global/types": [
"dist/global/types.d.ts"
],
"store": [
"dist/store/index.d.ts"
],
"inline": [
"dist/inline/index.d.ts"
],
"inline/consts": [
"dist/inline/consts.d.ts"
],
"inline/types": [
"dist/inline/types.d.ts"
],
"presets": [
"dist/presets/index.d.ts"
],
"blocks": [
"dist/blocks/index.d.ts"
],
"blocks/schemas": [
"dist/blocks/schemas.d.ts"
]
}
},
"files": [
"src",
"dist",
"!src/__tests__",
"!dist/__tests__"
]
}
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/block-std/gfx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/block-std/gfx';
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/block-std/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/block-std';
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/blocks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/blocks';
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/blocks/schemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/blocks/schemas';
7 changes: 7 additions & 0 deletions blocksuite/affine/all/src/effects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { effects as blocksEffects } from '@blocksuite/blocks/effects';
import { effects as presetsEffects } from '@blocksuite/presets/effects';

export function effects() {
blocksEffects();
presetsEffects();
}
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/global/di.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/global/di';
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/global/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/global/env';
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/global/exceptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/global/exceptions';
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/global/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/global';
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/global/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/global/types';
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/global/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/global/utils';
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/inline/consts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/inline/consts';
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/inline/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/inline';
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/inline/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/inline/types';
1 change: 1 addition & 0 deletions blocksuite/affine/all/src/presets/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@blocksuite/presets';
5 changes: 5 additions & 0 deletions blocksuite/affine/all/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* eslint-disable @typescript-eslint/no-restricted-imports */

// oxlint-disable-next-line
// @ts-ignore FIXME: typecheck error
export * from '@blocksuite/store';
29 changes: 29 additions & 0 deletions blocksuite/affine/all/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src/",
"outDir": "./dist/",
"noEmit": false
},
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
},
{
"path": "../../blocks"
},
{
"path": "../../presets"
}
]
}
4 changes: 4 additions & 0 deletions blocksuite/affine/all/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["../../../typedoc.base.json"],
"entryPoints": ["src/index.ts"]
}
30 changes: 30 additions & 0 deletions blocksuite/affine/all/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
esbuild: {
target: 'es2018',
},
test: {
globalSetup: '../../../scripts/vitest-global.ts',
include: ['src/__tests__/**/*.unit.spec.ts'],
testTimeout: 1000,
coverage: {
provider: 'istanbul', // or 'c8'
reporter: ['lcov'],
reportsDirectory: '../../../.coverage/affine',
},
/**
* Custom handler for console.log in tests.
*
* Return `false` to ignore the log.
*/
onConsoleLog(log, type) {
if (log.includes('https://lit.dev/msg/dev-mode')) {
return false;
}
console.warn(`Unexpected ${type} log`, log);
throw new Error(log);
},
environment: 'happy-dom',
},
});
43 changes: 43 additions & 0 deletions blocksuite/affine/block-embed/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "@blocksuite/affine-block-embed",
"description": "Embed blocks for BlockSuite.",
"type": "module",
"scripts": {
"build": "tsc",
"test:unit": "nx vite:test --run --passWithNoTests",
"test:unit:coverage": "nx vite:test --run --coverage",
"test:e2e": "playwright test"
},
"sideEffects": false,
"keywords": [],
"author": "toeverything",
"license": "MIT",
"dependencies": {
"@blocksuite/affine-block-surface": "workspace:*",
"@blocksuite/affine-components": "workspace:*",
"@blocksuite/affine-model": "workspace:*",
"@blocksuite/affine-shared": "workspace:*",
"@blocksuite/block-std": "workspace:*",
"@blocksuite/global": "workspace:*",
"@blocksuite/icons": "^2.1.75",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.1",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
"zod": "^3.23.8"
},
"exports": {
".": "./src/index.ts",
"./effects": "./src/effects.ts"
},
"files": [
"src",
"dist",
"!src/__tests__",
"!dist/__tests__"
]
}
66 changes: 66 additions & 0 deletions blocksuite/affine/block-embed/src/common/adapters/html.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import type { BlockHtmlAdapterMatcher } from '@blocksuite/affine-shared/adapters';

export function createEmbedBlockHtmlAdapterMatcher(
flavour: string,
{
toMatch = () => false,
fromMatch = o => o.node.flavour === flavour,
toBlockSnapshot = {},
fromBlockSnapshot = {
enter: (o, context) => {
const { walkerContext } = context;
// Parse as link
if (
typeof o.node.props.title !== 'string' ||
typeof o.node.props.url !== 'string'
) {
return;
}

walkerContext
.openNode(
{
type: 'element',
tagName: 'div',
properties: {
className: ['affine-paragraph-block-container'],
},
children: [],
},
'children'
)
.openNode(
{
type: 'element',
tagName: 'a',
properties: {
href: o.node.props.url,
},
children: [
{
type: 'text',
value: o.node.props.title,
},
],
},
'children'
)
.closeNode()
.closeNode();
},
},
}: {
toMatch?: BlockHtmlAdapterMatcher['toMatch'];
fromMatch?: BlockHtmlAdapterMatcher['fromMatch'];
toBlockSnapshot?: BlockHtmlAdapterMatcher['toBlockSnapshot'];
fromBlockSnapshot?: BlockHtmlAdapterMatcher['fromBlockSnapshot'];
} = Object.create(null)
): BlockHtmlAdapterMatcher {
return {
flavour,
toMatch,
fromMatch,
toBlockSnapshot,
fromBlockSnapshot,
};
}
58 changes: 58 additions & 0 deletions blocksuite/affine/block-embed/src/common/adapters/markdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import type { BlockMarkdownAdapterMatcher } from '@blocksuite/affine-shared/adapters';

export function createEmbedBlockMarkdownAdapterMatcher(
flavour: string,
{
toMatch = () => false,
fromMatch = o => o.node.flavour === flavour,
toBlockSnapshot = {},
fromBlockSnapshot = {
enter: (o, context) => {
const { walkerContext } = context;
// Parse as link
if (
typeof o.node.props.title !== 'string' ||
typeof o.node.props.url !== 'string'
) {
return;
}
walkerContext
.openNode(
{
type: 'paragraph',
children: [],
},
'children'
)
.openNode(
{
type: 'link',
url: o.node.props.url,
children: [
{
type: 'text',
value: o.node.props.title,
},
],
},
'children'
)
.closeNode()
.closeNode();
},
},
}: {
toMatch?: BlockMarkdownAdapterMatcher['toMatch'];
fromMatch?: BlockMarkdownAdapterMatcher['fromMatch'];
toBlockSnapshot?: BlockMarkdownAdapterMatcher['toBlockSnapshot'];
fromBlockSnapshot?: BlockMarkdownAdapterMatcher['fromBlockSnapshot'];
} = {}
): BlockMarkdownAdapterMatcher {
return {
flavour,
toMatch,
fromMatch,
toBlockSnapshot,
fromBlockSnapshot,
};
}
Loading

0 comments on commit 30200ff

Please sign in to comment.