mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +08:00
1f45cc5dec
**Directory Structure Changes** - Renamed multiple block-related directories by removing the "block-" prefix: - `block-attachment` → `attachment` - `block-bookmark` → `bookmark` - `block-callout` → `callout` - `block-code` → `code` - `block-data-view` → `data-view` - `block-database` → `database` - `block-divider` → `divider` - `block-edgeless-text` → `edgeless-text` - `block-embed` → `embed`
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';
|
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
|
import { BlockComponent } from '@blocksuite/std';
|
|
import { css, html } from 'lit';
|
|
import { repeat } from 'lit/directives/repeat.js';
|
|
|
|
export class PreviewRootBlockComponent extends BlockComponent {
|
|
static override styles = css`
|
|
affine-preview-root {
|
|
display: block;
|
|
}
|
|
`;
|
|
|
|
override connectedCallback() {
|
|
super.connectedCallback();
|
|
}
|
|
|
|
override disconnectedCallback() {
|
|
super.disconnectedCallback();
|
|
}
|
|
|
|
override renderBlock() {
|
|
const widgets = html`${repeat(
|
|
Object.entries(this.widgets),
|
|
([id]) => id,
|
|
([_, widget]) => widget
|
|
)}`;
|
|
|
|
const children = this.renderChildren(this.model, child => {
|
|
const isNote = matchModels(child, [NoteBlockModel]);
|
|
const note = child as NoteBlockModel;
|
|
const displayOnEdgeless =
|
|
!!note.props.displayMode &&
|
|
note.props.displayMode === NoteDisplayMode.EdgelessOnly;
|
|
// Should remove deprecated `hidden` property in the future
|
|
return !(isNote && displayOnEdgeless);
|
|
});
|
|
|
|
return html`<div class="affine-preview-root">${children} ${widgets}</div>`;
|
|
}
|
|
}
|