mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 22:37:04 +08:00
refactor(editor): merge get surface util (#9371)
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
EdgelessLegacySlotIdentifier,
|
||||
type ElementRenderer,
|
||||
elementRenderers,
|
||||
getSurfaceBlock,
|
||||
type SurfaceBlockModel,
|
||||
type SurfaceContext,
|
||||
} from '@blocksuite/affine-block-surface';
|
||||
@@ -30,7 +31,6 @@ import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import { Bound, getCommonBound } from '@blocksuite/global/utils';
|
||||
import { effect } from '@preact/signals-core';
|
||||
|
||||
import { getSurfaceBlock } from '../../surface-ref-block/utils.js';
|
||||
import { RootService } from '../root-service.js';
|
||||
import { GfxBlockModel } from './block-model.js';
|
||||
import type { EdgelessFrameManager } from './frame-manager.js';
|
||||
|
||||
@@ -2,9 +2,10 @@ import type {
|
||||
SurfaceBlockComponent,
|
||||
SurfaceBlockModel,
|
||||
} from '@blocksuite/affine-block-surface';
|
||||
import { Overlay } from '@blocksuite/affine-block-surface';
|
||||
import { getSurfaceBlock, Overlay } from '@blocksuite/affine-block-surface';
|
||||
import type { ConnectorElementModel } from '@blocksuite/affine-model';
|
||||
import type { GfxController } from '@blocksuite/block-std/gfx';
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import { Bound, Point } from '@blocksuite/global/utils';
|
||||
|
||||
import { isConnectable } from '../utils/query.js';
|
||||
@@ -52,9 +53,13 @@ export class EdgelessSnapManager extends Overlay {
|
||||
};
|
||||
|
||||
private get _surface() {
|
||||
const surfaceModel = this.gfx.doc.getBlockByFlavour(
|
||||
'affine:surface'
|
||||
)[0] as SurfaceBlockModel;
|
||||
const surfaceModel = getSurfaceBlock(this.gfx.doc);
|
||||
if (!surfaceModel) {
|
||||
throw new BlockSuiteError(
|
||||
ErrorCode.ValueNotExists,
|
||||
'Surface block not found in doc when creating snap manager'
|
||||
);
|
||||
}
|
||||
|
||||
return this.gfx.std.view.getBlock(surfaceModel.id) as SurfaceBlockComponent;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { addSiblingAttachmentBlocks } from '@blocksuite/affine-block-attachment';
|
||||
import { getSurfaceBlock } from '@blocksuite/affine-block-surface';
|
||||
import {
|
||||
getInlineEditorByModel,
|
||||
insertContent,
|
||||
@@ -61,7 +62,6 @@ import { cssVarV2 } from '@toeverything/theme/v2';
|
||||
import type { TemplateResult } from 'lit';
|
||||
|
||||
import { toggleEmbedCardCreateModal } from '../../../_common/components/embed-card/modal/embed-card-create-modal.js';
|
||||
import { getSurfaceBlock } from '../../../surface-ref-block/utils.js';
|
||||
import type { PageRootBlockComponent } from '../../page/page-root-block.js';
|
||||
import { formatDate, formatTime } from '../../utils/misc.js';
|
||||
import type { AffineLinkedDocWidget } from '../linked-doc/index.js';
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
LoomIcon,
|
||||
YoutubeIcon,
|
||||
} from '@blocksuite/affine-block-embed';
|
||||
import { getSurfaceBlock } from '@blocksuite/affine-block-surface';
|
||||
import {
|
||||
ArrowDownBigIcon,
|
||||
ArrowUpBigIcon,
|
||||
@@ -51,7 +52,6 @@ import type { TemplateResult } from 'lit';
|
||||
|
||||
import { toggleEmbedCardCreateModal } from '../../../_common/components/embed-card/modal/embed-card-create-modal.js';
|
||||
import type { DataViewBlockComponent } from '../../../data-view-block/index.js';
|
||||
import { getSurfaceBlock } from '../../../surface-ref-block/utils.js';
|
||||
import type { RootBlockComponent } from '../../types.js';
|
||||
import { formatDate, formatTime } from '../../utils/misc.js';
|
||||
import type { AffineLinkedDocWidget } from '../linked-doc/index.js';
|
||||
|
||||
Reference in New Issue
Block a user