feat: bump blocksuite (#5812)

This commit is contained in:
Flrande
2024-02-08 08:18:03 +08:00
committed by LongYinan
parent fec406f7e8
commit a6420fcd76
14 changed files with 180 additions and 150 deletions

View File

@@ -3,8 +3,8 @@
"private": true,
"type": "module",
"devDependencies": {
"@blocksuite/global": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/store": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/global": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/store": "0.12.0-canary-202402062232-9a8554c",
"react": "18.2.0",
"react-dom": "18.2.0",
"vitest": "1.1.3"

View File

@@ -13,9 +13,9 @@
"@affine/debug": "workspace:*",
"@affine/env": "workspace:*",
"@affine/templates": "workspace:*",
"@blocksuite/blocks": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/global": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/store": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/blocks": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/global": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/store": "0.12.0-canary-202402062232-9a8554c",
"jotai": "^2.5.1",
"jotai-effect": "^0.2.3",
"nanoid": "^5.0.3",
@@ -26,8 +26,8 @@
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine/templates": "workspace:*",
"@blocksuite/lit": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/presets": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/lit": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/presets": "0.12.0-canary-202402062232-9a8554c",
"async-call-rpc": "^6.3.1",
"react": "^18.2.0",
"rxjs": "^7.8.1",

View File

@@ -32,14 +32,14 @@
}
},
"dependencies": {
"@blocksuite/global": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/global": "0.12.0-canary-202402062232-9a8554c",
"idb": "^8.0.0",
"nanoid": "^5.0.3",
"y-provider": "workspace:*"
},
"devDependencies": {
"@blocksuite/blocks": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/store": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/blocks": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/store": "0.12.0-canary-202402062232-9a8554c",
"fake-indexeddb": "^5.0.0",
"vite": "^5.0.6",
"vite-plugin-dts": "3.7.0",

View File

@@ -24,7 +24,7 @@
"build": "vite build"
},
"devDependencies": {
"@blocksuite/store": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/store": "0.12.0-canary-202402062232-9a8554c",
"vite": "^5.0.6",
"vite-plugin-dts": "3.7.0",
"vitest": "1.1.3",

View File

@@ -73,12 +73,12 @@
"uuid": "^9.0.1"
},
"devDependencies": {
"@blocksuite/blocks": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/global": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/blocks": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/global": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/icons": "2.1.44",
"@blocksuite/lit": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/presets": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/store": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/lit": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/presets": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/store": "0.12.0-canary-202402062232-9a8554c",
"@storybook/addon-actions": "^7.5.3",
"@storybook/addon-essentials": "^7.5.3",
"@storybook/addon-interactions": "^7.5.3",

View File

@@ -26,14 +26,14 @@
"@affine/templates": "workspace:*",
"@affine/workspace": "workspace:*",
"@affine/workspace-impl": "workspace:*",
"@blocksuite/block-std": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/blocks": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/global": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/block-std": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/blocks": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/global": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/icons": "2.1.44",
"@blocksuite/inline": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/lit": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/presets": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/store": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/inline": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/lit": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/presets": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/store": "0.12.0-canary-202402062232-9a8554c",
"@dnd-kit/core": "^6.0.8",
"@dnd-kit/sortable": "^8.0.0",
"@emotion/cache": "^11.11.0",

View File

@@ -111,7 +111,6 @@ const getOrCreateShellWorkspace = (workspaceId: string) => {
const blobStorage = createAffineCloudBlobStorage(workspaceId);
workspace = new Workspace({
id: workspaceId,
providerCreators: [],
blobStorages: [
() => ({
crud: blobStorage,

View File

@@ -48,7 +48,7 @@ interface BlocksuiteEditorContainerProps {
// mimic the interface of the webcomponent and expose slots & host
type BlocksuiteEditorContainerRef = Pick<
(typeof AffineEditorContainer)['prototype'],
'mode' | 'page' | 'model' | 'slots' | 'host'
'mode' | 'page' | 'slots' | 'host'
> &
HTMLDivElement;

View File

@@ -37,24 +37,14 @@ export type EditorProps = {
className?: string;
};
/**
* TODO: Defined async cache to support suspense, instead of reflect symbol to provider persistent error cache.
*/
const PAGE_LOAD_KEY = Symbol('PAGE_LOAD');
const PAGE_ROOT_KEY = Symbol('PAGE_ROOT');
function usePageRoot(page: Page) {
let load$ = Reflect.get(page, PAGE_LOAD_KEY);
if (!load$) {
load$ = page.load();
Reflect.set(page, PAGE_LOAD_KEY, load$);
if (!page.ready) {
use(page.load());
}
use(load$);
if (!page.root) {
let root$: Promise<void> | undefined = Reflect.get(page, PAGE_ROOT_KEY);
if (!root$) {
root$ = new Promise((resolve, reject) => {
use(
new Promise<void>((resolve, reject) => {
const disposable = page.slots.rootAdded.once(() => {
resolve();
});
@@ -62,10 +52,8 @@ function usePageRoot(page: Page) {
disposable.dispose();
reject(new NoPageRootError(page));
}, 20 * 1000);
});
Reflect.set(page, PAGE_ROOT_KEY, root$);
}
use(root$);
})
);
}
return page.root;

View File

@@ -1,9 +1,12 @@
import type { BlockSpec } from '@blocksuite/block-std';
import type { ParagraphService } from '@blocksuite/blocks';
import type { PageService, ParagraphService } from '@blocksuite/blocks';
import {
AttachmentService,
CanvasTextFonts,
DocEditorBlockSpecs,
DocPageService,
EdgelessEditorBlockSpecs,
EdgelessPageService,
} from '@blocksuite/blocks';
import bytes from 'bytes';
import { html, unsafeStatic } from 'lit/static-html.js';
@@ -17,6 +20,31 @@ class CustomAttachmentService extends AttachmentService {
}
}
function customLoadFonts(service: PageService): void {
const officialDomains = new Set(['affine.pro', 'affine.fail']);
if (!officialDomains.has(window.location.host)) {
const fonts = CanvasTextFonts.map(font => ({
...font,
// self-hosted fonts are served from /assets
url: '/assets' + new URL(font.url).pathname.split('/').pop(),
}));
service.fontLoader.load(fonts);
} else {
service.fontLoader.load(CanvasTextFonts);
}
}
class CustomDocPageService extends DocPageService {
override loadFonts(): void {
customLoadFonts(this);
}
}
class CustomEdgelessPageService extends EdgelessPageService {
override loadFonts(): void {
customLoadFonts(this);
}
}
type AffineReference = HTMLElementTagNameMap['affine-reference'];
type PageReferenceRenderer = (reference: AffineReference) => React.ReactElement;
@@ -76,6 +104,12 @@ export const docModeSpecs = DocEditorBlockSpecs.map(spec => {
service: CustomAttachmentService,
};
}
if (spec.schema.model.flavour === 'affine:page') {
return {
...spec,
service: CustomDocPageService,
};
}
return spec;
});
export const edgelessModeSpecs = EdgelessEditorBlockSpecs.map(spec => {
@@ -85,5 +119,11 @@ export const edgelessModeSpecs = EdgelessEditorBlockSpecs.map(spec => {
service: CustomAttachmentService,
};
}
if (spec.schema.model.flavour === 'affine:page') {
return {
...spec,
service: CustomEdgelessPageService,
};
}
return spec;
});

View File

@@ -25,10 +25,10 @@
"@affine-test/kit": "workspace:*",
"@affine/env": "workspace:*",
"@affine/native": "workspace:*",
"@blocksuite/blocks": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/lit": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/presets": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/store": "0.12.0-canary-202402010557-e8d6e1d",
"@blocksuite/blocks": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/lit": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/presets": "0.12.0-canary-202402062232-9a8554c",
"@blocksuite/store": "0.12.0-canary-202402062232-9a8554c",
"@electron-forge/cli": "^7.2.0",
"@electron-forge/core": "^7.2.0",
"@electron-forge/core-utils": "^7.2.0",