fix: drop indicator in center peek (#10136)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import type { Rect } from '@blocksuite/global/utils';
|
import type { Rect } from '@blocksuite/global/utils';
|
||||||
import { css, html, LitElement } from 'lit';
|
import { css, html, LitElement } from 'lit';
|
||||||
import { property } from 'lit/decorators.js';
|
import { property, state } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
export class DropIndicator extends LitElement {
|
export class DropIndicator extends LitElement {
|
||||||
@@ -31,6 +31,7 @@ export class DropIndicator extends LitElement {
|
|||||||
height: `${height}px`,
|
height: `${height}px`,
|
||||||
top: `${top}px`,
|
top: `${top}px`,
|
||||||
left: `${left}px`,
|
left: `${left}px`,
|
||||||
|
zIndex: this.zIndex,
|
||||||
});
|
});
|
||||||
|
|
||||||
return html`<div class="affine-drop-indicator" style=${style}></div>`;
|
return html`<div class="affine-drop-indicator" style=${style}></div>`;
|
||||||
@@ -38,6 +39,9 @@ export class DropIndicator extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor rect: Rect | null = null;
|
accessor rect: Rect | null = null;
|
||||||
|
|
||||||
|
@state()
|
||||||
|
accessor zIndex = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
|||||||
@@ -120,8 +120,19 @@ export class DragEventWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly _createDropIndicator = () => {
|
private readonly _createDropIndicator = () => {
|
||||||
|
let topElement: HTMLElement = this.widget;
|
||||||
|
const body = this.widget.ownerDocument.body;
|
||||||
|
|
||||||
|
while (topElement && topElement.parentElement !== body) {
|
||||||
|
topElement = topElement.parentElement!;
|
||||||
|
}
|
||||||
|
const zIndex = topElement
|
||||||
|
? (parseInt(window.getComputedStyle(topElement).zIndex) || 1) + 1
|
||||||
|
: 2;
|
||||||
|
|
||||||
if (!this.dropIndicator) {
|
if (!this.dropIndicator) {
|
||||||
this.dropIndicator = new DropIndicator();
|
this.dropIndicator = new DropIndicator();
|
||||||
|
this.dropIndicator.zIndex = zIndex;
|
||||||
this.widget.ownerDocument.body.append(this.dropIndicator);
|
this.widget.ownerDocument.body.append(this.dropIndicator);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1232,7 +1243,7 @@ export class DragEventWatcher {
|
|||||||
onDrop: () => {
|
onDrop: () => {
|
||||||
this._cleanup();
|
this._cleanup();
|
||||||
},
|
},
|
||||||
setDragPreview: ({ source, container }) => {
|
setDragPreview: ({ source, container, setOffset }) => {
|
||||||
if (
|
if (
|
||||||
!source.data?.bsEntity?.modelIds.length ||
|
!source.data?.bsEntity?.modelIds.length ||
|
||||||
!source.data.bsEntity.snapshot
|
!source.data.bsEntity.snapshot
|
||||||
@@ -1248,6 +1259,8 @@ export class DragEventWatcher {
|
|||||||
container,
|
container,
|
||||||
mode: this.mode ?? 'page',
|
mode: this.mode ?? 'page',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setOffset({ x: 0, y: 0 });
|
||||||
},
|
},
|
||||||
setDragData: () => {
|
setDragData: () => {
|
||||||
const { fromMode, snapshot } = this._getDraggedSnapshot();
|
const { fromMode, snapshot } = this._getDraggedSnapshot();
|
||||||
|
|||||||
Reference in New Issue
Block a user