fix(editor): paste when select multiple block texts (#10227)

[BS-2512](https://linear.app/affine-design/issue/BS-2512/选中多段粘贴,多段只有第一段会被replace,这个bug还在)
This commit is contained in:
donteatfriedrice
2025-02-18 12:13:55 +00:00
parent 176e0a1950
commit 15e9acefc2
4 changed files with 236 additions and 2 deletions

View File

@@ -61,8 +61,20 @@ export class PageClipboard extends ReadOnlyClipboard {
this._std.store.captureSync();
this._std.command
.chain()
.try(cmd => [
cmd.pipe(getTextSelectionCommand),
.try<{}>(cmd => [
cmd.pipe(getTextSelectionCommand).pipe((ctx, next) => {
const { currentTextSelection } = ctx;
if (!currentTextSelection) {
return;
}
const { from, to } = currentTextSelection;
if (to && from.blockId !== to.blockId) {
this._std.command.exec(deleteTextCommand, {
currentTextSelection,
});
}
return next();
}),
cmd
.pipe(getSelectedModelsCommand)
.pipe(clearAndSelectFirstModelCommand)