mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 04:51:49 +08:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user