refactor(editor): reorg code structure of store package (#9525)

This commit is contained in:
Saul-Mirone
2025-01-05 12:49:02 +00:00
parent 1180e9bc15
commit 3d168ba2d2
55 changed files with 618 additions and 635 deletions
@@ -13,7 +13,6 @@ import {
type BlockModel,
type Blocks,
type BlockSnapshot,
BlockViewType,
type DraftModel,
type Query,
Slice,
@@ -194,7 +193,7 @@ async function renderNoteContent(
});
const query: Query = {
mode: 'strict',
match: ids.map(id => ({ id, viewType: BlockViewType.Display })),
match: ids.map(id => ({ id, viewType: 'display' })),
};
const previewDoc = doc.doc.getBlocks({ query });
const previewSpec = SpecProvider.getInstance().getSpec('page:preview');
@@ -25,12 +25,7 @@ import {
} from '@blocksuite/block-std';
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
import { assertExists, Bound, getCommonBound } from '@blocksuite/global/utils';
import {
BlockViewType,
type GetBlocksOptions,
type Query,
Text,
} from '@blocksuite/store';
import { type GetBlocksOptions, type Query, Text } from '@blocksuite/store';
import { computed } from '@preact/signals-core';
import { html, type PropertyValues } from 'lit';
import { query, state } from 'lit/decorators.js';
@@ -106,7 +101,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
props: {
displayMode: NoteDisplayMode.EdgelessOnly,
},
viewType: BlockViewType.Hidden,
viewType: 'hidden',
},
],
};
@@ -18,7 +18,7 @@ import {
ShadowlessElement,
} from '@blocksuite/block-std';
import { deserializeXYWH, WithDisposable } from '@blocksuite/global/utils';
import { type BlockModel, BlockViewType, type Query } from '@blocksuite/store';
import { type BlockModel, type Query } from '@blocksuite/store';
import { css, nothing } from 'lit';
import { property } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js';
@@ -48,7 +48,7 @@ export class SurfaceRefNotePortal extends WithDisposable(ShadowlessElement) {
mode: 'include',
match: Array.from(ancestors).map(id => ({
id,
viewType: BlockViewType.Display,
viewType: 'display',
})),
};
this.query = query;
@@ -5,7 +5,7 @@ import {
type DndEventState,
} from '@blocksuite/block-std';
import { Point } from '@blocksuite/global/utils';
import { BlockViewType, type Query } from '@blocksuite/store';
import type { BlockViewType, Query } from '@blocksuite/store';
import { DragPreview } from '../components/drag-preview.js';
import type { AffineDragHandleWidget } from '../drag-handle.js';
@@ -24,7 +24,7 @@ export class PreviewHelper {
const ids: Array<{ id: string; viewType: BlockViewType }> = selectedIds.map(
id => ({
id,
viewType: BlockViewType.Display,
viewType: 'display',
})
);
@@ -33,7 +33,7 @@ export class PreviewHelper {
let parent: string | null = block;
do {
if (!selectedIds.includes(parent)) {
ids.push({ viewType: BlockViewType.Bypass, id: parent });
ids.push({ viewType: 'bypass', id: parent });
}
parent = this.widget.doc.getParent(parent)?.id ?? null;
} while (parent && !ids.map(({ id }) => id).includes(parent));
@@ -43,7 +43,7 @@ export class PreviewHelper {
const addChildren = (id: string) => {
const children = this.widget.doc.getBlock(id)?.model.children ?? [];
children.forEach(child => {
ids.push({ viewType: BlockViewType.Display, id: child.id });
ids.push({ viewType: 'display', id: child.id });
addChildren(child.id);
});
};