fix: drag paragraph block from note to edgeless (#10242)
This commit is contained in:
@@ -30,7 +30,7 @@ import { getSnapshotRect } from '../utils.js';
|
|||||||
export class PreviewHelper {
|
export class PreviewHelper {
|
||||||
private readonly _calculateQuery = (
|
private readonly _calculateQuery = (
|
||||||
selectedIds: string[],
|
selectedIds: string[],
|
||||||
mode: 'page' | 'edgeless'
|
mode: 'block' | 'gfx'
|
||||||
): Query => {
|
): Query => {
|
||||||
const ids: Array<{ id: string; viewType: BlockViewType }> = selectedIds.map(
|
const ids: Array<{ id: string; viewType: BlockViewType }> = selectedIds.map(
|
||||||
id => ({
|
id => ({
|
||||||
@@ -59,7 +59,7 @@ export class PreviewHelper {
|
|||||||
|
|
||||||
const children = model.children ?? [];
|
const children = model.children ?? [];
|
||||||
if (
|
if (
|
||||||
mode === 'edgeless' &&
|
mode === 'gfx' &&
|
||||||
matchModels(model, [RootBlockModel, SurfaceBlockModel])
|
matchModels(model, [RootBlockModel, SurfaceBlockModel])
|
||||||
) {
|
) {
|
||||||
children.forEach(child => {
|
children.forEach(child => {
|
||||||
@@ -86,12 +86,12 @@ export class PreviewHelper {
|
|||||||
getPreviewStd = (
|
getPreviewStd = (
|
||||||
blockIds: string[],
|
blockIds: string[],
|
||||||
snapshot: SliceSnapshot,
|
snapshot: SliceSnapshot,
|
||||||
mode: 'edgeless' | 'page'
|
mode: 'block' | 'gfx'
|
||||||
) => {
|
) => {
|
||||||
const widget = this.widget;
|
const widget = this.widget;
|
||||||
const std = widget.std;
|
const std = widget.std;
|
||||||
const sourceGfx = std.get(GfxControllerIdentifier);
|
const sourceGfx = std.get(GfxControllerIdentifier);
|
||||||
const isEdgeless = mode === 'edgeless';
|
const isEdgeless = mode === 'gfx';
|
||||||
blockIds = blockIds.slice();
|
blockIds = blockIds.slice();
|
||||||
|
|
||||||
if (isEdgeless) {
|
if (isEdgeless) {
|
||||||
@@ -195,7 +195,7 @@ export class PreviewHelper {
|
|||||||
blockIds: string[];
|
blockIds: string[];
|
||||||
snapshot: SliceSnapshot;
|
snapshot: SliceSnapshot;
|
||||||
container: HTMLElement;
|
container: HTMLElement;
|
||||||
mode: 'page' | 'edgeless';
|
mode: 'block' | 'gfx';
|
||||||
}): void => {
|
}): void => {
|
||||||
const { blockIds, snapshot, container, mode } = options;
|
const { blockIds, snapshot, container, mode } = options;
|
||||||
const { previewStd, width, height, scale } = this.getPreviewStd(
|
const { previewStd, width, height, scale } = this.getPreviewStd(
|
||||||
|
|||||||
@@ -1067,16 +1067,12 @@ export class DragEventWatcher {
|
|||||||
schema.safeValidate(block.flavour, 'affine:note')
|
schema.safeValidate(block.flavour, 'affine:note')
|
||||||
);
|
);
|
||||||
// create note to wrap the snapshot
|
// create note to wrap the snapshot
|
||||||
const pos = this.gfx.viewport.toModelCoordFromClientCoord([
|
|
||||||
point.x,
|
|
||||||
point.y,
|
|
||||||
]);
|
|
||||||
const noteId = store.addBlock(
|
const noteId = store.addBlock(
|
||||||
'affine:note',
|
'affine:note',
|
||||||
{
|
{
|
||||||
xywh: new Bound(
|
xywh: new Bound(
|
||||||
pos[0],
|
point.x,
|
||||||
pos[1],
|
point.y,
|
||||||
DEFAULT_NOTE_WIDTH,
|
DEFAULT_NOTE_WIDTH,
|
||||||
DEFAULT_NOTE_HEIGHT
|
DEFAULT_NOTE_HEIGHT
|
||||||
).serialize(),
|
).serialize(),
|
||||||
@@ -1263,13 +1259,13 @@ export class DragEventWatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { snapshot } = source.data.bsEntity;
|
const { snapshot, fromMode } = source.data.bsEntity;
|
||||||
|
|
||||||
this.previewHelper.renderDragPreview({
|
this.previewHelper.renderDragPreview({
|
||||||
blockIds: source.data?.bsEntity?.modelIds,
|
blockIds: source.data?.bsEntity?.modelIds,
|
||||||
snapshot,
|
snapshot,
|
||||||
container,
|
container,
|
||||||
mode: this.mode ?? 'page',
|
mode: fromMode ?? 'block',
|
||||||
});
|
});
|
||||||
|
|
||||||
setOffset({ x: 0, y: 0 });
|
setOffset({ x: 0, y: 0 });
|
||||||
|
|||||||
Reference in New Issue
Block a user