-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: merge blocksuite source code (#9213)
- Loading branch information
1 parent
2c9ef91
commit 30200ff
Showing
2,031 changed files
with
238,895 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/block-std/gfx'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/block-std'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/blocks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/blocks/schemas'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/global/di'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/global/env'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/global/exceptions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/global'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/global/types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/global/utils'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/inline/consts'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/inline'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/inline/types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@blocksuite/presets'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": ["../../../typedoc.base.json"], | ||
"entryPoints": ["src/index.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
58
blocksuite/affine/block-embed/src/common/adapters/markdown.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; | ||
} |
Oops, something went wrong.