mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-24 18:02:47 +08:00
fix(editor): can not create surface block comment (#13115)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved comment handling to ensure elements from all selections are considered, regardless of surface ID. * Enhanced preview generation for comments to include all relevant selections without surface-based filtering. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -123,8 +123,7 @@ export class BlockElementCommentManager extends LifeCycleWatcher {
|
|||||||
const gfx = this.std.get(GfxControllerIdentifier);
|
const gfx = this.std.get(GfxControllerIdentifier);
|
||||||
const elementsFromSurfaceSelection = selections
|
const elementsFromSurfaceSelection = selections
|
||||||
.filter(s => s instanceof SurfaceSelection)
|
.filter(s => s instanceof SurfaceSelection)
|
||||||
.flatMap(({ blockId, elements }) => {
|
.flatMap(({ elements }) => {
|
||||||
if (blockId !== gfx.surface?.id) return [];
|
|
||||||
return elements
|
return elements
|
||||||
.map(id => gfx.getElementById<GfxModel>(id))
|
.map(id => gfx.getElementById<GfxModel>(id))
|
||||||
.filter(m => m !== null);
|
.filter(m => m !== null);
|
||||||
|
|||||||
@@ -50,10 +50,7 @@ function getPreviewFromSelections(
|
|||||||
} else if (selection instanceof ImageSelection) {
|
} else if (selection instanceof ImageSelection) {
|
||||||
// Return <"Image"> for ImageSelection
|
// Return <"Image"> for ImageSelection
|
||||||
previews.push('<Image>');
|
previews.push('<Image>');
|
||||||
} else if (
|
} else if (selection instanceof SurfaceSelection) {
|
||||||
selection instanceof SurfaceSelection &&
|
|
||||||
gfx.surface?.id === selection.blockId
|
|
||||||
) {
|
|
||||||
selection.elements.forEach(elementId => {
|
selection.elements.forEach(elementId => {
|
||||||
const model = gfx.getElementById(elementId);
|
const model = gfx.getElementById(elementId);
|
||||||
if (model instanceof GfxPrimitiveElementModel) {
|
if (model instanceof GfxPrimitiveElementModel) {
|
||||||
|
|||||||
Reference in New Issue
Block a user