Skip to content

Commit

Permalink
fix(core): frame props are not consistently applied
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegDev1 committed Feb 7, 2025
1 parent 5abf953 commit d396ee6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,12 @@ export class EdgelessAutoCompletePanel extends WithDisposable(LitElement) {
const { service, surfaceBlockModel } = edgeless;
const frameMgr = service.frame;
const frameIndex = service.frames.length + 1;
const id = this.crud.addBlock(
'affine:frame',
{
title: new Y.Text(`Frame ${frameIndex}`),
xywh: serializeXYWH(...xywh),
presentationIndex: frameMgr.generatePresentationIndex(),
},
surfaceBlockModel
);
const props = this.std.get(EditPropsStore).applyLastProps('affine:frame', {
title: new Y.Text(`Frame ${frameIndex}`),
xywh: serializeXYWH(...xywh),
presentationIndex: frameMgr.generatePresentationIndex(),
});
const id = this.crud.addBlock('affine:frame', props, surfaceBlockModel);
edgeless.doc.captureSync();
const frame = this.crud.getElementById(id);
if (!frame) return;
Expand Down
22 changes: 15 additions & 7 deletions blocksuite/blocks/src/root-block/edgeless/frame-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ import type { Store } from '@blocksuite/store';
import { Text } from '@blocksuite/store';
import * as Y from 'yjs';

import type { FrameBlockModel, NoteBlockModel } from '../../index.js';
import {
EditPropsStore,
type FrameBlockModel,
type NoteBlockModel,
} from '../../index.js';
import { areSetsEqual } from './utils/misc.js';
import { isFrameBlock } from './utils/query.js';

Expand Down Expand Up @@ -194,16 +198,20 @@ export class EdgelessFrameManager extends GfxExtension {

private _addFrameBlock(bound: Bound) {
const surfaceModel = this.gfx.surface as SurfaceBlockModel;
const id = this.gfx.doc.addBlock(
'affine:frame',
{
const props = this.gfx.std
.get(EditPropsStore)
.applyLastProps('affine:frame', {
title: new Text(new Y.Text(`Frame ${this.frames.length + 1}`)),
xywh: bound.serialize(),
index: this.gfx.layer.generateIndex(true),
presentationIndex: this.generatePresentationIndex(),
},
surfaceModel
);
});
const nProps = {
...props,
index: this.gfx.layer.generateIndex(),
};

const id = this.gfx.doc.addBlock('affine:frame', nProps, surfaceModel);
const frameModel = this.gfx.getElementById(id);

if (!frameModel || !isFrameBlock(frameModel)) {
Expand Down

0 comments on commit d396ee6

Please sign in to comment.