fix: remove bs shared and components in affine (#9792)

This commit is contained in:
Saul-Mirone
2025-01-20 09:41:06 +00:00
parent 1560880abd
commit fa5e6e1f45
24 changed files with 44 additions and 80 deletions

View File

@@ -1,8 +1,4 @@
import {
type DocMode,
type NoteBlockModel,
NoteDisplayMode,
} from '@blocksuite/affine/blocks';
import { type DocMode, getLastNoteBlock } from '@blocksuite/affine/blocks';
import { Slot } from '@blocksuite/affine/global/utils';
import type {
AffineEditorContainer,
@@ -10,7 +6,7 @@ import type {
EdgelessEditor,
PageEditor,
} from '@blocksuite/affine/presets';
import { type BlockModel, type Store } from '@blocksuite/affine/store';
import { type Store } from '@blocksuite/affine/store';
import clsx from 'clsx';
import type React from 'react';
import {
@@ -189,32 +185,3 @@ export const BlocksuiteEditorContainer = forwardRef<
</div>
);
});
// copy from '@blocksuite/affine-shared/utils'
export function getLastNoteBlock(doc: Store) {
let note: NoteBlockModel | null = null;
if (!doc.root) return null;
const { children } = doc.root;
for (let i = children.length - 1; i >= 0; i--) {
const child = children[i];
if (
matchFlavours(child, ['affine:note']) &&
child.displayMode !== NoteDisplayMode.EdgelessOnly
) {
note = child as NoteBlockModel;
break;
}
}
return note;
}
export function matchFlavours<Key extends (keyof BlockSuite.BlockModels)[]>(
model: BlockModel | null,
expected: Key
): model is BlockSuite.BlockModels[Key[number]] {
return (
!!model &&
expected.some(
key => (model.flavour as keyof BlockSuite.BlockModels) === key
)
);
}

View File

@@ -12,7 +12,7 @@ import type {
DatabaseBlockModel,
MenuOptions,
} from '@blocksuite/affine/blocks';
import { menu } from '@blocksuite/affine-components/context-menu';
import { menu } from '@blocksuite/affine/blocks';
import { LinkIcon } from '@blocksuite/icons/lit';
import type { FrameworkProvider } from '@toeverything/infra';

View File

@@ -18,6 +18,7 @@ import type {
DocDisplayMetaExtension,
DocDisplayMetaParams,
RootBlockConfig,
Signal,
SpecBuilder,
TelemetryEventMap,
ThemeExtension,
@@ -25,21 +26,18 @@ import type {
import {
CodeBlockSpec,
ColorScheme,
createSignalFromObservable,
DocDisplayMetaProvider,
EditorSettingExtension,
ImageBlockSpec,
ParagraphBlockSpec,
referenceToNode,
SpecProvider,
TelemetryProvider,
ThemeExtensionIdentifier,
} from '@blocksuite/affine/blocks';
import type { Container } from '@blocksuite/affine/global/di';
import type { ExtensionType } from '@blocksuite/affine/store';
import {
createSignalFromObservable,
referenceToNode,
type Signal,
SpecProvider,
} from '@blocksuite/affine-shared/utils';
import { LinkedPageIcon, PageIcon } from '@blocksuite/icons/lit';
import { type FrameworkProvider } from '@toeverything/infra';
import type { TemplateResult } from 'lit';

View File

@@ -12,8 +12,7 @@ import type {
GfxBlockElementModel,
GfxPrimitiveElementModel,
} from '@blocksuite/affine/block-std/gfx';
import { type MenuContext } from '@blocksuite/affine/blocks';
import type { MenuItemGroup } from '@blocksuite/affine-components/toolbar';
import type { MenuContext, MenuItemGroup } from '@blocksuite/affine/blocks';
import { LinkIcon } from '@blocksuite/icons/lit';
import type { FrameworkProvider } from '@toeverything/infra';

View File

@@ -1,6 +1,6 @@
import type { AffineTextAttributes } from '@blocksuite/affine/blocks';
import type { DeltaInsert } from '@blocksuite/affine/inline';
import { Text, type Workspace } from '@blocksuite/affine/store';
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import { useCallback } from 'react';
export function useReferenceLinkHelper(docCollection: Workspace) {