Skip to content

Commit 3bb18c7

Browse files
committed
clean further
1 parent 28c3456 commit 3bb18c7

2 files changed

Lines changed: 1 addition & 52 deletions

File tree

apps/obsidian/src/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ import {
1717
openConvertImageToNodeModal,
1818
} from "~/utils/editorMenuUtils";
1919
import { createImageEmbedHoverExtension } from "~/utils/imageEmbedHoverIcon";
20-
import {
21-
createWikilinkDragExtension,
22-
wikilinkDragPostProcessor,
23-
} from "~/utils/wikilinkDragHandler";
20+
import { createWikilinkDragExtension } from "~/utils/wikilinkDragHandler";
2421
import { registerCommands } from "~/utils/registerCommands";
2522
import { DiscourseContextView } from "~/components/DiscourseContextView";
2623
import { VIEW_TYPE_TLDRAW_DG_PREVIEW, FRONTMATTER_KEY } from "~/constants";
@@ -236,9 +233,6 @@ export default class DiscourseGraphPlugin extends Plugin {
236233
}),
237234
);
238235

239-
// Make wikilinks draggable so they can be dropped onto tldraw canvases
240-
this.registerMarkdownPostProcessor(wikilinkDragPostProcessor(this));
241-
242236
// Register editor keydown listener for node tag hotkey
243237
this.setupNodeTagHotkey();
244238
}

apps/obsidian/src/utils/wikilinkDragHandler.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import {
1010
import { TFile } from "obsidian";
1111
import type DiscourseGraphPlugin from "~/index";
1212

13-
const DRAG_ATTR = "data-dg-draggable";
14-
1513
const buildObsidianUrl = (vaultName: string, filePath: string): string => {
1614
return `obsidian://open?vault=${encodeURIComponent(vaultName)}&file=${encodeURIComponent(filePath)}`;
1715
};
@@ -41,49 +39,6 @@ const setDragData = (
4139
e.dataTransfer?.setData("text/plain", url);
4240
};
4341

44-
// --- Reading view ---
45-
46-
const makeReadingLinkDraggable = (
47-
linkEl: HTMLAnchorElement,
48-
plugin: DiscourseGraphPlugin,
49-
): void => {
50-
if (linkEl.hasAttribute(DRAG_ATTR)) return;
51-
linkEl.setAttribute(DRAG_ATTR, "true");
52-
linkEl.draggable = true;
53-
54-
linkEl.addEventListener("dragstart", (e) => {
55-
const href = linkEl.getAttr("data-href") ?? linkEl.getAttr("href");
56-
if (!href) {
57-
e.preventDefault();
58-
return;
59-
}
60-
61-
const file = resolveFileFromLinkText(href, plugin);
62-
if (!file) {
63-
e.preventDefault();
64-
return;
65-
}
66-
67-
setDragData(e, file, plugin);
68-
});
69-
};
70-
71-
/**
72-
* Markdown post-processor that makes wikilinks draggable in Reading view.
73-
*/
74-
export const wikilinkDragPostProcessor = (
75-
plugin: DiscourseGraphPlugin,
76-
): ((el: HTMLElement) => void) => {
77-
return (el: HTMLElement) => {
78-
const links = el.querySelectorAll<HTMLAnchorElement>(
79-
"a.internal-link:not(.internal-embed)",
80-
);
81-
for (const link of links) {
82-
makeReadingLinkDraggable(link, plugin);
83-
}
84-
};
85-
};
86-
8742
// --- Live Preview ---
8843

8944
/**

0 commit comments

Comments
 (0)