Code Monkey home page Code Monkey logo

obsidian-drag-and-drop-blocks's People

Contributors

gitmurf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

obsidian-drag-and-drop-blocks's Issues

Handle list item indentation choice by moving drop zone line to the right to indicate indentation under the bullet above it

It isn't easy to decide where it goes in indent level (whether same level or indented). I need to add a bunch of logic that will sense where your mouse is and then move the drag drop zone horizontal line right or left accordingly to signify whether indented or not. Also by making it an indented child of where it drops to I dont have to deal with the logic of dragging somewhere that may interrupt the list item below it.

Like if you drag under an item that already has children, if I try to drag to the same level as it, then it ruins the children relationship below it because those children are now below the new list item you just dragged. By making it indented always it avoids that issue and then you can just shift-tab to unindent it if you want it at same level. Not perfect but I had to make a decision one way or the other.

pseudometa suggestion:

I think that – at least for the first release – implementing such logic is going a bit far. You could keep it simpler (for now) and simply add an option in the settings:
if you move things under a list, should it keep its original indention or become a child? yes/no

Dragging to an empty file or less lines so the mouse isn't hovered over any line... gets stuck

Reported by Omer via Discord DM.

I have this issue where sometimes when I drag using SHIFT/ALT it doesn't work and this little popup gets stuck (until I go into preview mode and back into edit mode)

MY RESPONSE:

This is good feedback as I should add some checks to help fix this but I think its a corner case because you are dragging into a test file that is completely empty. See how the drag drop horizontal line is still back with your original block you are dragging? Its because your mouse actually isn't hovering over a real line in the other file.

image

Compared to in your video when it did work on your second attempt the drag drop line did activate over there even though your mouse is still low on the page it seemed to pick it up that time.

image

Drag ghost element is sometimes getting stuck in view

Reported by obadiahcruz via Discord DM:

image

Need to clear/hide/remove more often for the drag ghost element along with the horizontal drag drop zone line and the border of the dragged line. I think it is because of error in console stopped it so it didn't finish the removal/cleanup steps.

Add a check that makes it not work for dragging into anything except a standard markdown view edit mode (for now)

Thanks @zsviczian … I have been having a lot of issues like this with a lot of different plugins that have their own views types.

To get it released I am probably going to add a check that makes it not work for dragging into anything except a standard markdown view edit mode.

But excalidraw is the first plugin I plan to “optimize” for in an early update after initial release to the community plugin store.

so many darn corner cases to handle with drag and drop!!

Originally posted by @GitMurf in #30 (comment)

Support drag and drop note/file link

It appears that it already supports drag and drop note header. Based on this, would it be possible to drop note/file link? Specifically, one can use a different hotkey or paste with another option, to be able to paste only the note/file link, without header included?

Installed but there's no functionality

Obsidian v0.12.15 - macOS 10.13.6 High Sierra

I installed the plugin (fetched the repo, ran npm i and npm run build and copied main.js, mainfest.json and styles.css to my .obsidian/plugins/ dir under a new obsidian-frag-and-drop-blocks subdir) and restarted Obsidian.

I can see the "Drag and Drop Block Settings" in the GUI.

But I'm not able to drag blocks as intended. I can't see any difference in behavior from before installing the plugin.

What am I missing or doing wrong?

Thanks!

Does not appear to be working at all

I am not sure if this is just me, but right now the plugin does not seem to be functional.

I can see the handles in the gutter, but when I click and drag them, nothing happens. I cannot actually even drag the handle at all, even though the icon for the handle does appear in the gutter.

I have tried uninstalling all other plugins, but to no avail.

I just installed this recently, and I wonder if there is a breaking change to the API. I've tried downgrading this plugin to previous versions, but unfortunately that did not help either.

I've tried dragging without modifiers, using alt, using shift, using others, nothing makes a difference.

I'm on a Mac, and I'm on Obsidian version 0.16.2 (installer version 0.14.15).

When I turn on the developer tools, I do see two errors related to this plugin. Two packages are marked as deprecated. Unsure if they are the cause or not. I am unable to trigger any other error messages, as when I try to drag and drop blocks by grabbing the handles for a list, nothing happens (including no error in the developer console). The two error messages for the deprecated packages are:

Error: [CM6][obsidian-drag-n-drop-plugin] Using a deprecated package: "@codemirror/gutter".
See the stack trace to find the faulty plugin and file an issue with the plugin author. 
Details: https://discuss.codemirror.net/t/release-0-20-0/4302
    at o (app.js:1:1033613)
    at anonymous (plugin:obsidian-drag-n-drop-plugin:5586:32)
    at e.<anonymous> (app.js:1:1033908)
    at app.js:1:235237
    at Object.next (app.js:1:235342)
    at a (app.js:1:234081)
o @ app.js:1

And second deprecated package:

Error: [CM6][obsidian-drag-n-drop-plugin] Using a deprecated package: "@codemirror/rangeset".
See the stack trace to find the faulty plugin and file an issue with the plugin author. 
Details: https://discuss.codemirror.net/t/release-0-20-0/4302
    at o (app.js:1:1033613)
    at anonymous (plugin:obsidian-drag-n-drop-plugin:10928:34)
    at e.<anonymous> (app.js:1:1033908)
    at app.js:1:235237
    at Object.next (app.js:1:235342)
    at a (app.js:1:234081)
o @ app.js:1

Please let me know if I can help in any way by providing additional information or testing anything. I would be thrilled to get this to work, because I absolutely miss this feature of Roam a lot and would love to be able to use it in Obsidian :). So thanks very much for creating this plugin, and I hope it can get back to working soon!

Dragging from search pane to page

An example of what it normally does and what I'd love it be like...

screencap

I realised I forgot to put the "!" in front to make it a block ref, but maybe you get what I mean.

pre selecting multiple lines of text and then using the drag handle to move it all

Submitted by TFTHacker via Discord

Question 3: I have the following 3 lines:

  • a
  • b
  • c

I select with my mouse lines a through c. I then drag and drop them. but only line A is dragged to new location.

My response: You cannot multi-select. It only drags the single block. Ignores selected text. Obisidan native allows you to drag selected text so you can just do it without using my drag handle.

I don't know what's wrong, but the plugin just doesn't function

I followed the instructions of other people on the forum and downloaded this plugin. I did place these files in the file .obsidian/plugins. (As is shown in the photo) But it just doesn't function. I don't know what's wrong, could you please help me out? Thanks a lot!🥺
image

Dragging properties adds extra character on drop

I have a block in my daily notes for habit tracking that looks like

### Exercise
 Run:: 
 Press:: 
 Dips:: 
 Curls:: 
 Raises:: 

If I drag one of the properties and drop it below another it ends up as

### Exercise
 Run:: 
 Dips:: 
 Curls:: 
		C Press::
 Raises:: 

It seems to have taken the first letter of the item I have dropped under and added to the dragged item.

When dragging over a non valid drop zone hide the horizontal drop zone line

On Macs it isn't as clear as windows that you are dropping in an illegal area. It just shows the green + when good and then nothing when in bad area.

image

image

On windows it is much more obvious:

image

ohhhh yep! that must be a Mac thing. I have a clear Red circle warning showing you its not a legal drop area. I think I can help with this by hiding the purple line when you are not on a valid drop location... would that help make it clearer?

Dragging a header and its sub contents and dropping it within "itself"

See video in Discord reported by TFTHacker

Here are my comments in Discord:

ahhhh thanks for that great video! I will figure out how to fix but the problem is you are dragging it within itself 😉

When you drag heading 1 it grabs its children content (lines 3 and 4 etc.) ... but then you are trying to drop it within itself (between lines 3 and 4).

  1. does that make sense the "issue"?
  2. what would you like to see happen as behavior? I'm inclined to say cancel the event all together and send a Obsidian notification that says something like "You dragged a header and its contents and dropped it within itself which is an un-supported action" ... or something like that?

Settings to define the modifier keys and actions for drag, copy, block ref

Submitted by TFTHacker via Discord

question 2: i do remote desktop from my ipad to a windows pc. the alt/opt+drag drop doesnt work. i think its because the keybaord is odd. this might be edge case, but having experience, it would be nice if the keys are definable in control panel. you will see when you ship. lots of people have with differnt keyboards. So ability to assign the modifier key could save you some headache

relative reference to source file will result in unpredictable behaviour in case the same file name exists in different folders

Instead of the base filename, I would suggest including the entire file path, or at least offer it as an option.

block = `${embedOrLink}[` + `[${mdView.file.basename}#^${blockid}]]`;

Demo

Fail scenario

Because Obsidian's find nearest file resolves to Test 1/Source.md

2021-09-11.10-18-38.mp4

Success scenario

For the same reason as above

2021-09-11.10-24-14.mp4

Suggested solution

Consider using file.path instead when setting the dataTransfer item, I guess here:

evt.dataTransfer.setData("text/plain", block);

Then in this function

You could use the following code to get the right relative filepath:
this.app.metadataCache.fileToLinktext(mdView2.file,mdView.file.path,true)
You will of course need to move up the declaration of mdView2...

0.6.2 not reliable with excalidraw

I played a bit with the latest pre-release.
It sort of works... but is not reliable.

On the video:

  • in the first attempt 2021-10-24 markdown view is active when I initiate the alt+drag action. When I dropped the block reference to Excalidraw for some reason a previous block reference was dropped. Notice how the block in markdown view has a different block reference compared to what was dropped to Excalidraw: bwfoc92 vs. 3q8xcwv.
  • In the second case, starting at 0:00:25, I put my cursor to the 2021-10-23 markdown view, before initiating the alt+drag of the block reference to Excalidraw. In this case, the right block reference arrives, but the letter d and some empty lines appear in the 2021-10-23 markdown view.
  • Finally, starting at 0:00:50, I first drag the block reference to the left, and then to Excalidraw. In this case, everything works as expected. Note that 2021-10-23 markdown view was the active view each time I initiated the alt+drag action.
2021-10-24.07-31-08.mp4

Feature request: Include new line when dropping block

Thanks for developing this. I've been switching back and forth between Obsidian and LogSeq simply because LogSeq makes it easier to drag things around. Hopefully this will allow me to stick with Obsidian once and for all.

Could I ask for a minor improvement though ? I often want to use this to easily drag a line from one section to another e.g. a bullet under one heading into the middle of a list under another heading. When I drop however, the dragged line is added to the start of the drop target without a newline so the dragged item and the drop target are now a single line. I would much prefer it to include the newline so that the two remain separate.

Thanks again.

Handle disappears after interaction in preview mode

I have tested in both edit and preview mode, and they both works in creating the block ID and paste the reference at the destination. But the handle does not always appear in preview mode.

The way to reproduce it:

  1. in edit mode, make sure the handle is visible by hovering over it.
  2. switch to preview mode. The handle should still be visible if you hover over.
  3. alt+drag in preview mode. After that if you hover over at the same spot, the handle will now be gone.
  4. switch to edit mode again. Here comes the tricky part: if you just switch back to preview mode immediately without doing anything else, the handle will not re-appear; the only way to bring it back, is to hover over near the handle location in edit mode. Once it appears in edit mode, it will also appear in preview mode.

It's almost like that you have to "activate" the handle in edit mode first, then it will show in preview. But once you alt+drag in preview mode, it will be gone and you have to "reactivate" it in edit mode.

Edit mode doesn't have this problem. The handle will always be visible whenever you hover over it.

Issues with dragging empty lines

I have a set of lines like so:

This is text block 1


This is text block 2

This is text block 3
This is text block 4

I realise that I have two blank lines between block 1 and block 2 and none between block 3 and block 4 so I drag the second blank line from between 1 and 2 and and drop it between 3 and 4 and the result is the following where line 2 and the blank line below it appear to have disappeared:

This is text block 1


This is text block 3
This is text block 4

the icon for drag and drop doesn't show anymore

the plugin was working for me before, i have not messing with setting and here it looks like the plugin is not active so i wonder is it just me or the plugin is no longer function on obsidian 0.13.14?

request view update after drop to excalidraw view

Because you only add the block reference to the source line once the drop event is confirmed, the block reference does not resolve to the source text correctly in excalidraw.

Demo

2021-09-11.10-45-56.mp4

Note that I have Excalidraw switched to preview mode.
image

  • The first drop is displayed as a block reference because at the time of drop, the source reference does not exist and Excalidraw is unable to parse it to resolve the block contents.
  • The second drop is displayed correctly as the source text because by that time the block reference exists.
  • By switching back to raw mode and to preview mode again, the first reference is also resolved correctly.

Suggested solution

Note that you will need Excalidraw 1.3.6 (not yet released - but should be by the time you look at this) to accept text drops.

I think the following lines should resolve this issue if you add them here.

mdEditor2.replaceRange(stringToReplace, { line: startLine, ch: 0 }, { line: endLine, ch: endOfLine })

} else {
    mdEditor.replaceSelection(selectedText);
    //@ts-ignore
    if (thisApp.workspace.activeLeaf.view.getViewType() === "excalidraw") {
         //@ts-ignore
         thisApp.workspace.activeLeaf.view.plugin.triggerEmbedUpdates();
    }
}

Copy and link feature request

I think adding an option so that when someone drags and drop a selection it copies the selection and the link to the block it is selected from in a format like this:

  • [[link]]
    Tab- {selected highlight}

And Thanks for this lifesaver plugin. It was so needing this and was waiting for someone making it. I was so happy when I found out about your plugin

BUG? Cannot undo move

(Windows) After carrying out the drag block operation, using CTRL-Z will highlight the new block, then anther CTRL-Z will delete the new block. But the next CTRL-Z does not replace the block back in its original page.

This is thus a one-way, non-reversible operation.

Can this be fixed, or is there another way to reverse the operation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.