fix(editor): should keep order of note after sliced by scissor (#12034)

Close [BS-3175](https://linear.app/affine-design/issue/BS-3175/剪刀剪出来的段落,排序应该紧跟原段落,而不是排到所有段落最后)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Bug Fixes**
  - Improved the accuracy of new note insertion, ensuring new notes are added immediately after the anchor note in the correct order.

- **Tests**
  - Enhanced end-to-end tests for note slicing, including more interactions and assertions to verify correct note order and display modes after slicing.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
L-Sun
2025-04-29 10:36:54 +00:00
parent 1ea73456ca
commit 081974e824
2 changed files with 29 additions and 10 deletions
@@ -155,11 +155,14 @@ export class NoteSlicer extends WidgetComponent<RootBlockModel> {
const doc = this.doc;
const {
index: originIndex,
index: originalIndex,
xywh,
background,
displayMode,
} = this._anchorNote.props;
const originalNoteIndex = this._anchorNote.parent?.children.findIndex(
child => child === this._anchorNote
);
const { children } = this._anchorNote;
const {
collapse: _,
@@ -180,10 +183,11 @@ export class NoteSlicer extends WidgetComponent<RootBlockModel> {
background,
displayMode,
xywh: serializeXYWH(x, newY + NEW_NOTE_GAP, width, DEFAULT_NOTE_HEIGHT),
index: originIndex + 1,
index: originalIndex + 1,
edgeless: restOfEdgeless,
},
doc.root?.id
doc.root?.id,
originalNoteIndex ? originalNoteIndex + 1 : undefined
);
doc.moveBlocks(resetBlocks, doc.getModelById(newNoteId) as NoteBlockModel);