mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
refactor(editor): reorg code structure of store package (#9525)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user