mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 19:16:29 +08:00
fix(editor): hide edgeless only note in synced doc block (#10277)
Closes: [BS-2616](https://linear.app/affine-design/issue/BS-2616/embed-view-%E5%B1%95%E7%A4%BA%E4%B8%8D%E8%AF%A5%E5%87%BA%E7%8E%B0%E7%9A%84-note-%E5%86%85%E5%AE%B9)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';
|
||||
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||
import { BlockComponent } from '@blocksuite/block-std';
|
||||
import { css, html } from 'lit';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
|
||||
import { ReadOnlyClipboard } from '../clipboard/readonly-clipboard';
|
||||
|
||||
@@ -24,8 +27,21 @@ export class PreviewRootBlockComponent extends BlockComponent {
|
||||
}
|
||||
|
||||
override renderBlock() {
|
||||
return html`<div class="affine-preview-root">
|
||||
${this.host.renderChildren(this.model)}
|
||||
</div>`;
|
||||
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.displayMode && note.displayMode === NoteDisplayMode.EdgelessOnly;
|
||||
// Should remove deprecated `hidden` property in the future
|
||||
return !(isNote && displayOnEdgeless);
|
||||
});
|
||||
|
||||
return html`<div class="affine-preview-root">${children} ${widgets}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user