Skip to content

Commit af64a66

Browse files
committed
docs: add canDropToRoot
1 parent 4187e6e commit af64a66

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

apps/docs/v1/api.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ The main function of this library. React hook. The arguments are as follows:
5454
| onChange<a id="onchange"/>| `(newData)=>void`|Callback on data change|
5555
| canDrag<a id="candrag"/> | `(stat)=>boolean, null, undefined, void` | Whether a node draggable. Returning `null, undefined, void` means inheriting the parent node. |
5656
| canDrop<a id="candrop"/> | `(stat, index)=>boolean, null, undefined, void` | Whether a node droppable. Returning `null, undefined, void` means inheriting the parent node. The parameter `index` may be empty. If it is not empty, it indicates the position. |
57+
| canDropToRoot<a id="candroptoroot"/> | `(index)=>boolean` | whether the tree root can be dropped. The parameter `index` indicates the position. |
5758
| customDragImage<a id="customdragimage"/> | `(event, stat)=> void` | Called `event.dataTransfer.setDragImage` to custom drag image. [Reference](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage). |
5859
|onDragStart<a id="ondragstart"/>| `(event, stat)=> void` ||
5960
|onExternalDragOver<a id="onexternaldragover"/>|`(event)=>boolean`|Called when drag from external. Must return a Boolean value to indicate whether to handle this drag.|
@@ -103,7 +104,7 @@ walkTreeDataGenerator(
103104
(node, { parent, parents, siblings, index, skipChildren, exitWalk }) => {
104105
// ...
105106
},
106-
"children"
107+
"children",
107108
);
108109
```
109110

@@ -117,7 +118,7 @@ let foundNode = findTreeData(
117118
(node, { parent, parents, siblings, index, skipChildren, exitWalk }) => {
118119
// return node.id === 1;
119120
},
120-
"children"
121+
"children",
121122
);
122123
```
123124

@@ -131,7 +132,7 @@ let nodes = filterTreeData(
131132
(node, { parent, parents, siblings, index, skipChildren, exitWalk }) => {
132133
// return node.id > 1;
133134
},
134-
"children"
135+
"children",
135136
);
136137
```
137138

@@ -200,14 +201,14 @@ walkFlatData(
200201
flatData,
201202
(
202203
node,
203-
{ parent, parents, index, treeIndex, id, pid, skipChildren, exitWalk }
204+
{ parent, parents, index, treeIndex, id, pid, skipChildren, exitWalk },
204205
) => {
205206
// ...
206207
},
207208
{
208209
idKey: "id",
209210
parentIdKey: "parent_id",
210-
}
211+
},
211212
);
212213
```
213214

apps/docs/zh/v1/api.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const {/* return */} = useHeTree({/* options */}) // prettier-ignore
5454
| onChange<a id="onchange"/>| `(newData)=>void`|数据发生改变时调用.|
5555
| canDrag<a id="candrag"/> | `(stat)=>boolean, null, undefined, void` | 节点是否可拖拽. 返回`null, undefined, void`表示继承父节点. |
5656
| canDrop<a id="candrop"/> | `(stat, index)=>boolean, null, undefined, void` | 节点是否可放入. 返回`null, undefined, void`表示继承父节点. 参数`index`可能为空, 不为空时表示将要放入节点的子级的位置. |
57+
| canDropToRoot<a id="candroptoroot"/> | `(index)=>boolean` | 树最外层是否可放入. 参数`index`表示要放入的位置. |
5758
| customDragImage<a id="customdragimage"/> | `(event, stat)=> void` | 调用`event.dataTransfer.setDragImage`自定义 drag image. [参考](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage). |
5859
|onDragStart<a id="ondragstart"/>| `(event, stat)=> void` |当拖拽开始时|
5960
|onExternalDragOver<a id="onexternaldragover"/>|`(event)=>boolean`|当拖拽来自外部时调用. 你必选返回布尔值表示是否处理此拖拽.|
@@ -103,7 +104,7 @@ walkTreeDataGenerator(
103104
(node, { parent, parents, siblings, index, skipChildren, exitWalk }) => {
104105
// ...
105106
},
106-
"children"
107+
"children",
107108
);
108109
```
109110

@@ -117,7 +118,7 @@ let foundNode = findTreeData(
117118
(node, { parent, parents, siblings, index, skipChildren, exitWalk }) => {
118119
// return node.id === 1;
119120
},
120-
"children"
121+
"children",
121122
);
122123
```
123124

@@ -131,7 +132,7 @@ let nodes = filterTreeData(
131132
(node, { parent, parents, siblings, index, skipChildren, exitWalk }) => {
132133
// return node.id > 1;
133134
},
134-
"children"
135+
"children",
135136
);
136137
```
137138

@@ -200,14 +201,14 @@ walkFlatData(
200201
flatData,
201202
(
202203
node,
203-
{ parent, parents, index, treeIndex, id, pid, skipChildren, exitWalk }
204+
{ parent, parents, index, treeIndex, id, pid, skipChildren, exitWalk },
204205
) => {
205206
// ...
206207
},
207208
{
208209
idKey: "id",
209210
parentIdKey: "parent_id",
210-
}
211+
},
211212
);
212213
```
213214

apps/docs/zh/v1/guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ renderNodeBox: ({ stat, attrs, isPlaceholder }) => (
174174

175175
- [`canDrag`](api#candrag), 节点是否可拖拽.
176176
- [`canDrop`](api#candrop), 节点是否可放入.
177-
- [`canDropToRoot`](api#candroptoroot), 树根是否可放入.
177+
- [`canDropToRoot`](api#candroptoroot), 树最外层是否可放入.
178178

179179
<<< @/../dev/src/pages/draggable_droppable.tsx{16-18}
180180
<DemoIframe url="/draggable_droppable" />

0 commit comments

Comments
 (0)