feat: support dragging the block to reorder (#6285)

* feat: support dragging the block to reorder

* feat: render feedback widget

* feat: add drag to move translation

* fix: the feedback widget doesn't update after node changed

* feat: render table placeholder

* feat: implement auto scroll when dragging to edge

* chore: add back the drop images/files feature

* chore: code refactor

* feat: exclude image and file block

* feat: exclude image gallery and database block
This commit is contained in:
Lucas 2024-09-16 17:01:02 +08:00 committed by GitHub
parent 129db6925c
commit d67d77f442
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 383 additions and 95 deletions

View file

@ -171,7 +171,7 @@ class _DocumentPageState extends State<DocumentPage>
.getDropTargetRenderData(details.globalPosition);
if (data != null &&
data.dropTarget != null &&
data.dropPath != null &&
// We implement custom Drop logic for image blocks, this is
// how we can exclude them from the Drop Target
@ -184,14 +184,28 @@ class _DocumentPageState extends State<DocumentPage>
}
},
onDragDone: (details) async {
state.editorState!.selectionService.removeDropTarget();
final editorState = state.editorState;
if (editorState == null) {
return;
}
final data = state.editorState!.selectionService
editorState.selectionService.removeDropTarget();
final data = editorState.selectionService
.getDropTargetRenderData(details.globalPosition);
if (data != null) {
if (data.cursorNode != null) {
if (_excludeFromDropTarget.contains(data.cursorNode?.type)) {
final cursorNode = data.cursorNode;
final dropPath = data.dropPath;
if (cursorNode != null && dropPath != null) {
if (_excludeFromDropTarget.contains(cursorNode.type)) {
return;
}
final node = editorState.getNodeAtPath(dropPath);
if (node == null) {
return;
}
@ -209,14 +223,15 @@ class _DocumentPageState extends State<DocumentPage>
}
}
await editorState!.dropImages(
data.dropTarget!,
await editorState.dropImages(
node,
imageFiles,
widget.view.id,
isLocalMode,
);
await editorState!.dropFiles(
data.dropTarget!,
await editorState.dropFiles(
node,
otherFiles,
widget.view.id,
isLocalMode,