mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-25 15:17:28 -04:00
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:
parent
129db6925c
commit
d67d77f442
11 changed files with 383 additions and 95 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue