Open MahmadSharaf opened 4 months ago
I've had this request before. I don't know how to do it properly. It worked at one time, and then it stopped. There have been some suggestions on how to debug it, which I tried, but didn't manage to get anything working. It's also harder because I don't even have an android phone to test.
Okay, let me try
Okay, what I have deduced so far:
Solutions I tried in so far with no luck:
async onload() {
...
...
...
// Wait for Obsidian to load everything, so we make sure that the "Insert attachment" is created by Obsidian
this.app.workspace.onLayoutReady(() => {
// Get the command
const attachFileCommandDefinition = this.app.commands?.commands?.["editor:attach-file"];
// Store the original callback
const attachFileCallback = attachFileCommandDefinition?.editorCallback;
// Check if the callback is stored as expected
if (typeof attachFileCallback === "function") {
// Override the existing command with the new callback
this.app.commands.removeCommand(attachFileCommandDefinition .id);
this.addCommand({
id: "editor:insert-attachment",
name: "Insert Attachment",
editorCallback: newCallback,
});
}
}
I am sharing the progress, in case you have any hint on how to proceed. Meanwhile, I am looking into it.
maybe some inspiration here? https://github.com/trganda/obsidian-attachment-management/blob/main/src/main.ts
Yes, I installed it, but unfortunately it doesn't support attachments via the command. But I will look into that direction, I might get inspired from other plugins.
It is not a mobile related problem. The plugin doesn't handle "Insert attachment" command in general.
this might be the key insight
Maybe you can find a solution from this project (inspired by yours),https://github.com/seebin/obsidian-minio-uploader-plugin
So, I have spent some more time investigating this popular request. I would like to support it, however, unfortunately, my existing code path is frankly a pigs breakfast. While it would be easy to make "something happen" it would be a lot harder to support all of the configuration options that are present in the existing upload mechanism. This would require me to refactor it substantially. Perhaps I am just looking for justifications for my laziness, but another issue came to mind. In the existing cut and paste insert workflow, the user has implicitly decided exactly where in the note that the image/file to be uploaded should go - that's where the cursor is at in the current note. If I understand the workflow for mobile, its a bit different. This would enable it to be added from the share menu, or from the camera roll, etc. In this case, I don't know where in which note to actually put the link.
For those of you following this issue - do you have any desired behavior, or insight into to how it actually should work? Remember, I don't need or use this feature, so I don't have any clue how you might want it to work. Please do explain.
Thank you for giving it another shot.
Here is my mobile workflow:
The problem is that the plugin doesn't intercept this action. Also, the mobile app doesn't support Copy/Paste or Drag and Drop actions.
What I tried so far, knowing that I have no JS experience nor Obsidian API:
I hope you would have a much better luck, and be able to implement this feature.
Hello there,
I wonder if it is possible that the plugin supports uploading attachments from mobile.