Skip to content

Commit

Permalink
✨ feat: 支持拖放文档树项目 close #16
Browse files Browse the repository at this point in the history
  • Loading branch information
frostime committed Aug 26, 2024
1 parent e85d681 commit 1f2dd43
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Changelog

## v1.3.0

- ✨ feat: 支持传入变量如当前文档id [#14](https://github.com/frostime/sy-bookmark-plus/issues/14)
- 相关用法已更新 README
- ✨ feat: 支持从文档树中直接拖入文档加入书签中 [#16](https://github.com/frostime/sy-bookmark-plus/issues/16)

## v1.2.3

- ⚡ perf: 适配优化移动端 [#13](https://github.com/frostime/sy-bookmark-plus/issues/13)
Expand Down
19 changes: 19 additions & 0 deletions src/components/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ const Group: Component<Props> = (props) => {
event.preventDefault();
event.dataTransfer.dropEffect = "copy";
setIsDragOver(true);
} else if (type.startsWith(Constants.SIYUAN_DROP_FILE)) {
event.preventDefault();
event.dataTransfer.dropEffect = "copy";
setIsDragOver(true);
} else if (type === 'bookmark/item') {
event.preventDefault();
event.dataTransfer.dropEffect = "move";
Expand All @@ -358,6 +362,21 @@ const Group: Component<Props> = (props) => {
const info = meta.split(Constants.ZWSP);
const nodeId = info[2];
addItemByBlockId(nodeId);
} else if (type.startsWith(Constants.SIYUAN_DROP_FILE)) {
const ele: HTMLElement = window.siyuan.dragElement;
if (ele && ele.innerText) {
const blockid = ele.innerText;
//if '/', it might be the box other than document
if (blockid && blockid !== '/') {
addItemByBlockId(blockid);
}
//Clean up the effect of dragging element
const item: HTMLElement = document.querySelector(`.file-tree.sy__tree li[data-node-id="${blockid}"]`);
if (item) {
item.style.opacity = "1";
}
window.siyuan.dragElement = undefined;
}
} else if (type === 'bookmark/item') {
model.moveItem(itemMoving());
}
Expand Down
1 change: 1 addition & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ declare interface Window {
ws: any;
languages: any;
emojis: any;
dragElement?: HTMLDivElement;
};
Lute: {
Caret: string;
Expand Down

0 comments on commit 1f2dd43

Please sign in to comment.