mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
chore(infra): remove blocksuite from infra (#9353)
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import type { SurfaceBlockProps } from '@blocksuite/affine/block-std/gfx';
|
||||
import {
|
||||
NoteDisplayMode,
|
||||
type NoteProps,
|
||||
type ParagraphProps,
|
||||
type RootBlockProps,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { type Doc, Text } from '@blocksuite/affine/store';
|
||||
|
||||
export interface DocProps {
|
||||
page?: Partial<RootBlockProps>;
|
||||
surface?: Partial<SurfaceBlockProps>;
|
||||
note?: Partial<NoteProps>;
|
||||
paragraph?: Partial<ParagraphProps>;
|
||||
}
|
||||
|
||||
export function initEmptyDoc(doc: Doc, title?: string) {
|
||||
doc.load(() => {
|
||||
initDocFromProps(doc, {
|
||||
page: {
|
||||
title: new Text(title),
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function initDocFromProps(doc: Doc, props?: DocProps) {
|
||||
doc.load(() => {
|
||||
const pageBlockId = doc.addBlock(
|
||||
'affine:page',
|
||||
props?.page || { title: new Text('') }
|
||||
);
|
||||
doc.addBlock('affine:surface' as never, props?.surface || {}, pageBlockId);
|
||||
const noteBlockId = doc.addBlock(
|
||||
'affine:note',
|
||||
{
|
||||
...props?.note,
|
||||
displayMode: NoteDisplayMode.DocAndEdgeless,
|
||||
},
|
||||
pageBlockId
|
||||
);
|
||||
doc.addBlock('affine:paragraph', props?.paragraph || {}, noteBlockId);
|
||||
doc.history.clear();
|
||||
});
|
||||
}
|
||||
@@ -88,9 +88,9 @@ export const CloudQuotaModal = () => {
|
||||
currentWorkspace.engine.blob.singleBlobSizeLimit = workspaceQuota.blobLimit;
|
||||
|
||||
const disposable =
|
||||
currentWorkspace.engine.blob.onAbortLargeBlob.on(onAbortLargeBlob);
|
||||
currentWorkspace.engine.blob.onAbortLargeBlob(onAbortLargeBlob);
|
||||
return () => {
|
||||
disposable?.dispose();
|
||||
disposable();
|
||||
};
|
||||
}, [currentWorkspace.engine.blob, onAbortLargeBlob, workspaceQuota]);
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@ export const LocalQuotaModal = () => {
|
||||
}, [setOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
const disposable = currentWorkspace.engine.blob.onAbortLargeBlob.on(() => {
|
||||
const disposable = currentWorkspace.engine.blob.onAbortLargeBlob(() => {
|
||||
setOpen(true);
|
||||
});
|
||||
return () => {
|
||||
disposable?.dispose();
|
||||
disposable();
|
||||
};
|
||||
}, [currentWorkspace.engine.blob.onAbortLargeBlob, setOpen]);
|
||||
}, [currentWorkspace.engine.blob, setOpen]);
|
||||
|
||||
return (
|
||||
<ConfirmModal
|
||||
|
||||
@@ -67,12 +67,13 @@ import {
|
||||
import { Bound } from '@blocksuite/affine/global/utils';
|
||||
import { type BlockSnapshot, Text } from '@blocksuite/affine/store';
|
||||
import type { ReferenceParams } from '@blocksuite/affine-model';
|
||||
import { type DocProps, type FrameworkProvider } from '@toeverything/infra';
|
||||
import { type FrameworkProvider } from '@toeverything/infra';
|
||||
import { type TemplateResult } from 'lit';
|
||||
import { customElement } from 'lit/decorators.js';
|
||||
import { literal } from 'lit/static-html.js';
|
||||
import { pick } from 'lodash-es';
|
||||
|
||||
import type { DocProps } from '../../../../../blocksuite/initialization';
|
||||
import { generateUrl } from '../../../../hooks/affine/use-share-url';
|
||||
import { createKeyboardToolbarConfig } from './widgets/keyboard-toolbar';
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { toast } from '@affine/component';
|
||||
import type { DocProps } from '@affine/core/blocksuite/initialization';
|
||||
import { AppSidebarService } from '@affine/core/modules/app-sidebar';
|
||||
import { DocsService } from '@affine/core/modules/doc';
|
||||
import { EditorSettingService } from '@affine/core/modules/editor-setting';
|
||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||
import { type DocMode } from '@blocksuite/affine/blocks';
|
||||
import type { DocCollection } from '@blocksuite/affine/store';
|
||||
import { type DocProps, useServices } from '@toeverything/infra';
|
||||
import { useServices } from '@toeverything/infra';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
export const usePageHelper = (docCollection: DocCollection) => {
|
||||
|
||||
@@ -3,13 +3,12 @@ import { Unreachable } from '@affine/env/constant';
|
||||
import type { DocMode } from '@blocksuite/affine/blocks';
|
||||
import type { DeltaInsert } from '@blocksuite/affine/inline';
|
||||
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
|
||||
import { ObjectPool, Service } from '@toeverything/infra';
|
||||
|
||||
import {
|
||||
type DocProps,
|
||||
initDocFromProps,
|
||||
ObjectPool,
|
||||
Service,
|
||||
} from '@toeverything/infra';
|
||||
|
||||
} from '../../../blocksuite/initialization';
|
||||
import type { Doc } from '../entities/doc';
|
||||
import { DocPropertyList } from '../entities/property-list';
|
||||
import { DocRecordList } from '../entities/record-list';
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Text } from '@blocksuite/affine/store';
|
||||
import type { DocProps } from '@toeverything/infra';
|
||||
import { initDocFromProps, LiveData, Service } from '@toeverything/infra';
|
||||
import { LiveData, Service } from '@toeverything/infra';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
type DocProps,
|
||||
initDocFromProps,
|
||||
} from '../../../blocksuite/initialization';
|
||||
import type { DocsService } from '../../doc';
|
||||
import type { EditorSettingService } from '../../editor-setting';
|
||||
import type { JournalStore } from '../store/journal';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { track } from '@affine/track';
|
||||
import { Text } from '@blocksuite/affine/store';
|
||||
import type { DocProps } from '@toeverything/infra';
|
||||
import { Service } from '@toeverything/infra';
|
||||
|
||||
import type { DocProps } from '../../../blocksuite/initialization';
|
||||
import type { DocsService } from '../../doc';
|
||||
import { EditorSettingService } from '../../editor-setting';
|
||||
import type { WorkbenchService } from '../../workbench';
|
||||
|
||||
Reference in New Issue
Block a user