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

View File

@@ -1,6 +1,6 @@
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
import { type BlockModel, Blocks, BlockViewType } from '@blocksuite/store';
import { type BlockModel, Blocks, type BlockViewType } from '@blocksuite/store';
import { consume, provide } from '@lit/context';
import { computed } from '@preact/signals-core';
import { nothing, type TemplateResult } from 'lit';
@@ -187,9 +187,9 @@ export class BlockComponent<
private _renderViewType(content: unknown) {
return choose(this.viewType, [
[BlockViewType.Display, () => content],
[BlockViewType.Hidden, () => nothing],
[BlockViewType.Bypass, () => this.renderChildren(this.model)],
['display', () => content],
['hidden', () => nothing],
['bypass', () => this.renderChildren(this.model)],
]);
}
@@ -310,7 +310,7 @@ export class BlockComponent<
accessor doc!: Blocks;
@property({ attribute: false })
accessor viewType: BlockViewType = BlockViewType.Display;
accessor viewType: BlockViewType = 'display';
@property({
attribute: false,

View File

@@ -4,7 +4,7 @@ import {
handleError,
} from '@blocksuite/global/exceptions';
import { SignalWatcher, Slot, WithDisposable } from '@blocksuite/global/utils';
import { type BlockModel, Blocks, BlockViewType } from '@blocksuite/store';
import { type BlockModel, Blocks } from '@blocksuite/store';
import { createContext, provide } from '@lit/context';
import { css, LitElement, nothing, type TemplateResult } from 'lit';
import { property } from 'lit/decorators.js';
@@ -44,7 +44,7 @@ export class EditorHost extends SignalWatcher(
private readonly _renderModel = (model: BlockModel): TemplateResult => {
const { flavour } = model;
const block = this.doc.getBlock(model.id);
if (!block || block.blockViewType === BlockViewType.Hidden) {
if (!block || block.blockViewType === 'hidden') {
return html`${nothing}`;
}
const schema = this.doc.schema.flavourSchemaMap.get(flavour);