mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 02:26:21 +08:00
chore: bump blocksuite (#7235)
## Features - https://github.com/toeverything/BlockSuite/pull/7340 @pengx17 - https://github.com/toeverything/BlockSuite/pull/7334 @EYHN - https://github.com/toeverything/BlockSuite/pull/7339 @donteatfriedrice - https://github.com/toeverything/BlockSuite/pull/7328 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/7324 @Flrande - https://github.com/toeverything/BlockSuite/pull/7297 @pengx17 - https://github.com/toeverything/BlockSuite/pull/7318 @CatsJuice ## Bugfix - https://github.com/toeverything/BlockSuite/pull/7343 @Saul-Mirone - https://github.com/toeverything/BlockSuite/pull/7345 @donteatfriedrice - https://github.com/toeverything/BlockSuite/pull/7341 @donteatfriedrice - https://github.com/toeverything/BlockSuite/pull/7342 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/7329 @CatsJuice - https://github.com/toeverything/BlockSuite/pull/7337 @fundon - https://github.com/toeverything/BlockSuite/pull/7333 @fundon - https://github.com/toeverything/BlockSuite/pull/7326 @akumatus - https://github.com/toeverything/BlockSuite/pull/7325 @Flrande - https://github.com/toeverything/BlockSuite/pull/7323 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/7312 @golok727 - https://github.com/toeverything/BlockSuite/pull/7317 @CatsJuice - https://github.com/toeverything/BlockSuite/pull/7319 @akumatus ## Refactor - https://github.com/toeverything/BlockSuite/pull/7327 @Flrande - https://github.com/toeverything/BlockSuite/pull/7320 @Flrande ## Misc - https://github.com/toeverything/BlockSuite/pull/7303 @fundon - https://github.com/toeverything/BlockSuite/pull/7321 @Saul-Mirone
This commit is contained in:
@@ -12,6 +12,7 @@ export async function buildShowcaseWorkspace(
|
||||
workspaceName: string
|
||||
) {
|
||||
const meta = await workspacesService.create(flavour, async docCollection => {
|
||||
docCollection.meta.initialize();
|
||||
docCollection.meta.setName(workspaceName);
|
||||
const blob = await (await fetch(onboardingUrl)).blob();
|
||||
|
||||
@@ -58,6 +59,7 @@ export async function createFirstAppData(workspacesService: WorkspacesService) {
|
||||
const workspaceMetadata = await workspacesService.create(
|
||||
WorkspaceFlavour.LOCAL,
|
||||
async workspace => {
|
||||
workspace.meta.initialize();
|
||||
workspace.meta.setName(DEFAULT_WORKSPACE_NAME);
|
||||
const page = workspace.createDoc();
|
||||
defaultPageId = page.id;
|
||||
|
||||
@@ -247,6 +247,7 @@ export const CreateWorkspaceModal = ({
|
||||
const { id } = await workspacesService.create(
|
||||
workspaceFlavour,
|
||||
async workspace => {
|
||||
workspace.meta.initialize();
|
||||
workspace.meta.setName(name);
|
||||
const page = workspace.createDoc();
|
||||
defaultDocId = page.id;
|
||||
|
||||
+7
-4
@@ -1,6 +1,6 @@
|
||||
import { mixpanel } from '@affine/core/utils';
|
||||
import type { BlockSpec } from '@blocksuite/block-std';
|
||||
import type { RootService } from '@blocksuite/blocks';
|
||||
import type { RootService, TelemetryEventMap } from '@blocksuite/blocks';
|
||||
import {
|
||||
AffineCanvasTextFonts,
|
||||
EdgelessRootService,
|
||||
@@ -30,9 +30,12 @@ function withAffineRootService(Service: typeof RootService) {
|
||||
customLoadFonts(this);
|
||||
}
|
||||
|
||||
telemetryService = {
|
||||
track: (event: string, data: Record<string, unknown>) => {
|
||||
mixpanel.track(event, data);
|
||||
override telemetryService = {
|
||||
track: <T extends keyof TelemetryEventMap>(
|
||||
eventName: T,
|
||||
props: TelemetryEventMap[T]
|
||||
) => {
|
||||
mixpanel.track(eventName, props);
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ schema.register(AffineSchemas);
|
||||
beforeEach(async () => {
|
||||
vi.useFakeTimers({ toFake: ['requestIdleCallback'] });
|
||||
docCollection = new DocCollection({ id: 'test', schema });
|
||||
docCollection.meta.initialize();
|
||||
const initPage = async (page: Doc) => {
|
||||
page.load();
|
||||
expect(page).not.toBeNull();
|
||||
|
||||
@@ -9,12 +9,12 @@ export function useAllBlockSuiteDocMeta(
|
||||
docCollection: DocCollection
|
||||
): DocMeta[] {
|
||||
if (!weakMap.has(docCollection)) {
|
||||
const baseAtom = atom<DocMeta[]>(docCollection.meta.docMetas);
|
||||
const baseAtom = atom<DocMeta[]>([...docCollection.meta.docMetas]);
|
||||
weakMap.set(docCollection, baseAtom);
|
||||
baseAtom.onMount = set => {
|
||||
set(docCollection.meta.docMetas);
|
||||
set([...docCollection.meta.docMetas]);
|
||||
const dispose = docCollection.meta.docMetaUpdated.on(() => {
|
||||
set(docCollection.meta.docMetas);
|
||||
set([...docCollection.meta.docMetas]);
|
||||
});
|
||||
return () => {
|
||||
dispose.dispose();
|
||||
|
||||
@@ -6,10 +6,12 @@ import { useDocCollectionPage } from './use-block-suite-workspace-page';
|
||||
|
||||
const weakMap = new WeakMap<Doc, Atom<string[]>>();
|
||||
function getPageBacklinks(page: Doc): string[] {
|
||||
return page.collection.indexer.backlink
|
||||
.getBacklink(page.id)
|
||||
.map(linkNode => linkNode.pageId)
|
||||
.filter(id => id !== page.id);
|
||||
return (
|
||||
page.collection.indexer.backlink
|
||||
?.getBacklink(page.id)
|
||||
.map(linkNode => linkNode.pageId)
|
||||
.filter(id => id !== page.id) ?? []
|
||||
);
|
||||
}
|
||||
|
||||
const getPageBacklinksAtom = (page: Doc | null) => {
|
||||
@@ -24,13 +26,13 @@ const getPageBacklinksAtom = (page: Doc | null) => {
|
||||
page.slots.ready.on(() => {
|
||||
set(getPageBacklinks(page));
|
||||
}),
|
||||
page.collection.indexer.backlink.slots.indexUpdated.on(() => {
|
||||
page.collection.indexer.backlink?.slots.indexUpdated.on(() => {
|
||||
set(getPageBacklinks(page));
|
||||
}),
|
||||
];
|
||||
set(getPageBacklinks(page));
|
||||
return () => {
|
||||
disposables.forEach(disposable => disposable.dispose());
|
||||
disposables.forEach(disposable => disposable?.dispose());
|
||||
};
|
||||
};
|
||||
weakMap.set(page, baseAtom);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useDocCollectionPage } from './use-block-suite-workspace-page';
|
||||
const weakMap = new WeakMap<Doc, Atom<string[]>>();
|
||||
function getPageReferences(page: Doc): string[] {
|
||||
return Object.values(
|
||||
page.collection.indexer.backlink.linkIndexMap[page.id] ?? {}
|
||||
page.collection.indexer.backlink?.linkIndexMap[page.id] ?? {}
|
||||
).flatMap(linkNodes => linkNodes.map(linkNode => linkNode.pageId));
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ const getPageReferencesAtom = (page: Doc | null) => {
|
||||
page.slots.ready.on(() => {
|
||||
set(getPageReferences(page));
|
||||
}),
|
||||
page.collection.indexer.backlink.slots.indexUpdated.on(() => {
|
||||
page.collection.indexer.backlink?.slots.indexUpdated.on(() => {
|
||||
set(getPageReferences(page));
|
||||
}),
|
||||
];
|
||||
set(getPageReferences(page));
|
||||
return () => {
|
||||
disposables.forEach(disposable => disposable.dispose());
|
||||
disposables.forEach(disposable => disposable?.dispose());
|
||||
};
|
||||
};
|
||||
weakMap.set(page, baseAtom);
|
||||
|
||||
@@ -23,6 +23,7 @@ export async function configureTestingEnvironment() {
|
||||
metadata: await workspaceManager.create(
|
||||
WorkspaceFlavour.LOCAL,
|
||||
async ws => {
|
||||
ws.meta.initialize();
|
||||
const initDoc = async (page: BlockSuiteDoc) => {
|
||||
page.load();
|
||||
const pageBlockId = page.addBlock('affine:page', {
|
||||
|
||||
Reference in New Issue
Block a user