Skip to content

Commit

Permalink
fix(drag-patch): fix no cursor shown on drag folder over editor in v0…
Browse files Browse the repository at this point in the history
….14.8+
  • Loading branch information
aidenlx committed May 3, 2022
1 parent 8071260 commit beb8c5e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "alx-folder-note",
"name": "AidenLx's Folder Note",
"version": "0.16.3",
"minAppVersion": "0.13.24",
"minAppVersion": "0.14.8",
"description": "Add description, summary and more info to folders with folder notes.",
"author": "AidenLx",
"authorUrl": "https://github.com/aidenlx",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"fast-deep-equal": "^3.1.3",
"gray-matter": "^4.0.3",
"monkey-around": "^2.3.0",
"obsidian": "github:obsidianmd/obsidian-api",
"obsidian": "^0.14.8",
"path-browserify": "^1.0.1",
"prettier": "^2.6.1",
"release-it": "^14.13.1",
Expand Down
18 changes: 17 additions & 1 deletion src/drag-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "obsidian";
import { around } from "monkey-around";
import {
ClipboardManager,
DragManager,
MarkdownView,
Platform,
TFolder,
Expand All @@ -17,6 +18,7 @@ declare global {
declare module "obsidian" {
interface App {
dragManager: DragManager;
getObsidianUrl(file: TFile): string;
}
interface DragInfo {
source?: string;
Expand Down Expand Up @@ -106,6 +108,20 @@ const PatchDragManager = (plugin: ALxFolderNote) => {
if (!editMode)
throw new Error("Failed to patch clipboard manager: no edit view found");

plugin.register(
around(app.dragManager.constructor.prototype as DragManager, {
dragFolder: (next) =>
function (this: DragManager, evt, folder, source, ...args) {
let note;
if ((note = getFolderNote(folder))) {
const url = app.getObsidianUrl(note);
evt.dataTransfer!.setData("text/plain", url);
evt.dataTransfer!.setData("text/uri-list", url);
}
return next.call(this, evt, folder, source, ...args);
},
}),
);
plugin.register(
around(
editMode.clipboardManager.constructor.prototype as ClipboardManager,
Expand All @@ -119,7 +135,7 @@ const PatchDragManager = (plugin: ALxFolderNote) => {
draggable.file instanceof TFolder &&
getFolderNote(draggable.file)
) {
evt.preventDefault();
// evt.preventDefault();
VD(evt, "link");
this.app.dragManager.setAction(
i18next.t("interface.drag-and-drop.insert-link-here"),
Expand Down
21 changes: 20 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ __metadata:
fast-deep-equal: ^3.1.3
gray-matter: ^4.0.3
monkey-around: ^2.3.0
obsidian: "github:obsidianmd/obsidian-api"
obsidian: ^0.14.8
path-browserify: ^1.0.1
prettier: ^2.6.1
release-it: ^14.13.1
Expand Down Expand Up @@ -4395,6 +4395,13 @@ __metadata:
languageName: node
linkType: hard

"moment@npm:2.29.2":
version: 2.29.2
resolution: "moment@npm:2.29.2"
checksum: ee850b5776485e2af0775ceb3cfebaa7d7638f0a750fe0678fcae24c310749f96c1938808384bd422a55e5703834a71fcb09c8a1d36d9cf847f6ed0205d7a3e5
languageName: node
linkType: hard

"monkey-around@npm:^2.3.0":
version: 2.3.0
resolution: "monkey-around@npm:2.3.0"
Expand Down Expand Up @@ -4595,6 +4602,18 @@ __metadata:
languageName: node
linkType: hard

"obsidian@npm:^0.14.8":
version: 0.14.8
resolution: "obsidian@npm:0.14.8"
dependencies:
"@codemirror/state": ^0.19.6
"@codemirror/view": ^0.19.31
"@types/codemirror": 0.0.108
moment: 2.29.2
checksum: 8bbaf676e7c9d4cd33d3fef76518a0bbe395e6cc5bae522d1b0c8d9cadd38a501caa940f41cd76da0e97efd704cfd0124c85c9cfa79bedb6f63dae829b5183c0
languageName: node
linkType: hard

"once@npm:^1.3.0, once@npm:^1.3.1, once@npm:^1.4.0":
version: 1.4.0
resolution: "once@npm:1.4.0::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2Fonce%2F-%2Fonce-1.4.0.tgz"
Expand Down

0 comments on commit beb8c5e

Please sign in to comment.