1
1
---
2
- title : ' Overview '
3
- sidebar_position : 2
2
+ title : ' Dnd '
3
+ sidebar_position : 1
4
4
---
5
5
6
6
import useBaseUrl from ' @docusaurus/useBaseUrl' ;
@@ -10,35 +10,85 @@ import DockviewExternalDnd from '@site/sandboxes/externaldnd-dockview/src/app';
10
10
11
11
import { DocRef } from ' @site/src/components/ui/reference/docRef' ;
12
12
13
- Dockview supports a wide variety of built-in Drag and Drop possibilities .
13
+ The dock makes heavy use of drag and drop functionalities .
14
14
15
- <h4 >Position a tab between two other tabs</h4 >
15
+ <DocRef declaration = " DockviewApi"
16
+ methods = { [
17
+ ' onWillDragPanel' , ' onWillDragGroup' ,
18
+ ' onWillDrop' , ' onDidDrop' , ' onWillShowOverlay'
19
+ ]}
20
+ />
16
21
17
- <div style = { {display:' flex' , justifyContent: ' center' }} >
18
- <img style = { { height: ' 50px' }} src = { useBaseUrl (' /img/add_to_tab.svg' )} />
19
- </div >
20
22
21
- < h4 >Position a tab at the end of a list of tabs</ h4 >
23
+ # Drag And Drop
22
24
23
- <div style = { {display:' flex' , justifyContent: ' center' }} >
24
- <img style = { { height: ' 50px' }} src = { useBaseUrl (' /img/add_to_empty_space.svg' )} />
25
- </div >
25
+ You can override the conditions of the far edge overlays through the ` rootOverlayModel ` prop.
26
26
27
- <h4 >Merge one group with another group</h4 >
27
+ ``` tsx
28
+ <DockviewReact
29
+ { ... props }
30
+ rootOverlayModel = { {
31
+ size: { value: 100 , type: ' pixels' },
32
+ activationSize: { value: 5 , type: ' percentage' },
33
+ }}
34
+ />
35
+ ```
28
36
29
- <div style = { {display:' flex' , justifyContent: ' center' }} >
30
- <img style = { { height: ' 50px' }} src = { useBaseUrl (' /img/add_to_group.svg' )} />
31
- </div >
37
+ ## Extended behaviours
32
38
33
- < h4 >Move both Tabs and Groups in relation to another group</ h4 >
39
+ For interaction with the Drag events directly the component exposes some method to help determine whether external drag events should be interacted with or not.
34
40
41
+ ``` tsx
42
+ /**
43
+ * called when an ondrop event which does not originate from the dockview libray and
44
+ * passes the showDndOverlay condition occurs
45
+ **/
46
+ const onDidDrop = (event : DockviewDropEvent ) => {
47
+ const { group } = event ;
35
48
36
- <div style = { {display:' flex' , justifyContent: ' center' }} >
37
- <img style = { { height: ' 300px' }} src = { useBaseUrl (' /img/drop_positions.svg' )} />
38
- </div >
49
+ event .api .addPanel ({
50
+ id: ' test' ,
51
+ component: ' default' ,
52
+ position: {
53
+ referencePanel: group .activePanel .id ,
54
+ direction: ' within' ,
55
+ },
56
+ });
57
+ };
39
58
40
- <h4 >Move both Tabs and Groups in relation to the container</h4 >
59
+ /**
60
+ * called for drag over events which do not originate from the dockview library
61
+ * allowing the developer to decide where the overlay should be shown for a
62
+ * particular drag event
63
+ **/
64
+ const showDndOverlay = (event : DockviewDndOverlayEvent ) => {
65
+ return true ;
66
+ };
41
67
42
- <div style = { {display:' flex' , justifyContent: ' center' }} >
43
- <img style = { { height: ' 300px' }} src = { useBaseUrl (' /img/magnet_drop_positions.svg' )} />
44
- </div >
68
+ return (
69
+ <DockviewReact
70
+ components = { components }
71
+ onReady = { onReady }
72
+ className = " dockview-theme-abyss"
73
+ onDidDrop = { onDidDrop }
74
+ showDndOverlay = { showDndOverlay }
75
+ />
76
+ );
77
+ ```
78
+
79
+ ## Intercepting Drag Events
80
+
81
+ You can intercept drag events to attach your own metadata using the ` onWillDragPanel ` and ` onWillDragGroup ` api methods.
82
+
83
+ <MultiFrameworkContainer sandboxId = " dnd-dockview" react = { DndDockview } />
84
+
85
+ ## Third Party Dnd Libraries
86
+
87
+ This shows a simple example of a third-party library used inside a panel that relies on drag
88
+ and drop functionalities. This examples serves to show that ` dockview ` doesn't interfer with
89
+ any drag and drop logic for other controls.
90
+
91
+ <MultiFrameworkContainer
92
+ sandboxId = " externaldnd-dockview"
93
+ react = { DockviewExternalDnd }
94
+ />
0 commit comments