farling42 / obsidian-import-json

Plug-in for Obsidian.md which will create Notes from JSON files
MIT License
91 stars 5 forks source link

Textarea to paste JSON from clipboard #3

Closed agnoldo closed 2 years ago

agnoldo commented 2 years ago

Thanks for the good work!

What about a command to import from clipboard? Or a dialog with a text area to paste JSON (instead of choosing the JSON file)? This would simplify some two-step "export-import" workflows to bring data from other tools (like MS Outlook) to Obsidian...

farling42 commented 2 years ago

Implemented in 0.6.0.

Perhaps not the nicest UI, but at least it is functional. :-)

agnoldo commented 2 years ago

Thank you very much, @farling42 !

agnoldo commented 2 years ago

Dear @farling42 , good morning! I tried the new implementation but couldn't make it work. I tried to paste the JSON data into the textbox of the Open File dialog but only the first line was pasted and so the JSON data was invalid. What am I doing wrong?

In addition, what do you think about allowing folder names inside the filename field? So we could paste JSON with a tree structure. I tried to edit main.ts by hand here in Obsidian (I changed validFileName function) but it didn't work, so I guess it's not so simple. I'd like to help on it but my works's PC doesn't allow installing a dev environment (I'm using Obsidian as a portable app!!!).

farling42 commented 2 years ago

I just tried copying 28,000 bytes of JSON data into the text box of the "Choose JSON File" section and it imported correctly.

I also put "bob\rewards" into the "Set Folder" box, and it created a "bob" folder inside which was a "rewards" folder, inside of which was all the entries in the JSON table that I pasted into the text box.

farling42 commented 2 years ago

The JSON text should be pasted in the box to the right of the main dialog in the top section labelled "Choose JSON File". Don't press the "Choose file" button.

agnoldo commented 2 years ago

Dear @farling42 , thank you very much for your attention! I'll try to follow your instructions here.

My idea about using folder names inside filename field was to create different folders for each note being pasted. Suppose (my case) you want to export messages from Outlook folders (your Inbox and its subfolders) and create the same structure in Obsidian. If your (already amazing) plugin is able to recreate the folders, we can use it to import messages keeping the same tree structure. Another use I have here is to create notes for each binary file (PDF and MS Office, mainly) in a shared folder, copying (again) the same tree structure.

Thanks for the support and for the great work!

agnoldo commented 2 years ago

Dear @farling42 , I just found the text area! I use Harmonic theme and the text area was almost invisible :-)

Thanks!

P.S.: importing from JSON worked perfectly, thanks!

farling42 commented 2 years ago

Dear @farling42 , I just found the text area! I use Harmonic theme and the text area was almost invisible :-)

Thanks!

P.S.: importing from JSON worked perfectly, thanks!

Great to hear it!

I will update the UI to make that box more visible in a future release.