-
-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: should only generate new id when cross doc (#9009)
Closes: [BS-2162](https://linear.app/affine-design/issue/BS-2162/把-note-里的内容拖拽出来变成游离态,这个也成了复制)
- Loading branch information
1 parent
a35ff22
commit 2c68ec0
Showing
4 changed files
with
20 additions
and
17 deletions.
There are no files selected for viewing
14 changes: 0 additions & 14 deletions
14
packages/blocks/src/root-block/widgets/drag-handle/middleware/copy-embed-doc.ts
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
packages/blocks/src/root-block/widgets/drag-handle/middleware/new-id-cross-doc.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { BlockStdScope } from '@blocksuite/block-std'; | ||
import type { JobMiddleware } from '@blocksuite/store'; | ||
|
||
export const newIdCrossDoc = | ||
(std: BlockStdScope): JobMiddleware => | ||
({ slots, collection }) => { | ||
let samePage = false; | ||
slots.beforeImport.on(payload => { | ||
if (payload.type === 'slice') { | ||
samePage = payload.snapshot.pageId === std.doc.id; | ||
} | ||
if (payload.type === 'block' && !samePage) { | ||
payload.snapshot.id = collection.idGenerator(); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters