notable / notable

The Markdown-based note-taking app that doesn't suck.
https://notable.app
22.55k stars 1.15k forks source link

Treat linked attachments as actual attachments #318

Open RomanKornev opened 5 years ago

RomanKornev commented 5 years ago

Current behavior

Expected behavior

Add attachments: [icon.png] to note metadata on save.

fabiospampinato commented 5 years ago

🤔 This is sort of intended actually, that note has no attachments, it's just linking to one, which may or may not even exist.

But I guess what's the difference between explicitly adding a file as an attachment and linking to one? Currently when we delete a note we also delete the attachments if no other notes have them as attachments, but I guess we should also not delete the attachments if another note is linking to them.

This is quite tricky though because:

I'm keeping this open as it's an area where we should improve, but fixing the reported use case can be challenging.

RomanKornev commented 5 years ago

we should also not delete the attachments if another note is linking to them

Outlined in #280

what's the difference between explicitly adding a file as an attachment and linking to one

Is there a difference? I guess right now we can't have a link to the note as an attachment? It just copy-pastes the note in the attachments folder. I think linked images and files should always be in the attachments list. Then unlinking them can also remove them from the note plaintext as well. Maybe even automatically add [](@attachment/file.txt) to the end of the note when clicking Add Attachments.

But then we need to preserve path in attachment metadata #320

You may link to an attachment via an external editor while Notable is closed, should we parse all notes at startup and check for this?

It might be slow. Right now the metadata updates when editing a note so we can update the attachments there.

You may link to an attachment, then remove the link, but now should we remove that file from the attachments metadata?

Right now it just sits there even if it's deleted. Pasting multiple links and then removing them will lead to a lot of orphans that have to be manually deleted. So I think mirroring the note contents might be better. No link to attachment in text -> attachment symbol is not shown.

file is actually an attachment or just a link to one

Not sure about this one. I personally don't use plain attachments without a specific link to them in text.

What if you link to a file that doesn't exist? What if later that file is added manually to the data directory?

It's already working as intended, isn't it?

fabiospampinato commented 5 years ago

Is there a difference?

If you're just linking to an attachment it doesn't show up in the attachments popover.

Then unlinking them can also remove them from the note plaintext as well.

What if then manually re-add that attachment to the data directory? This is quite tricky, I'm not sure manipulating the content of the note in this scenario is wise.

Maybe even automatically add to the end of the note when clicking Add Attachments.

I don't know it doesn't sound like something everyone needs, I would rather make it much easier to link to attachments via some kind of autocomplete #20

It's already working as intended, isn't it?

Now yes, but if we were to manipulate the metadata or note content also when linking to an attachment and when an attachment is removed then we would have to better deal with this situation.

RomanKornev commented 5 years ago

Is there a difference? If you're just linking to an attachment it doesn't show up in the attachments popover.

I was thinking more of as a rhetorical question.

Consider 4 cases:

  1. Link to a picture is added in plaintext -> Add this attachment to metadata
  2. Attachment is added using the button -> Same as now
  3. Attachment is removed using the button -> Same as now, but provide an option to NOT delete the file on disk
  4. Link to a picture is removed from plaintext -> Tricky. If we keep reference in metadata, it might become polluted. If we remove - that might not be what the user intended.

Solution:

Do we really need this duality though?

fabiospampinato commented 5 years ago

Do we really need this duality though?

I don't know, I'll have to think more about this.

rathboma commented 5 years ago

One thing that would simplify things -- do a lot of folks care about the little paperclip icon in the note list view?

If not you could remove that and not worry about 'attachments' for individual notes, but manage the files on a global level.

The attachments abstraction is a little weird for images especially (should an embedded image really show up as an 'attachment' in the index view?)

You could even have a Files section in the sidebar and allow users to drag-drop files into a markdown document to add a link or image tag (depending on file type).

If you did the same thing with notes (drag a note to the markdown file to add a link) you'd also remove the need for in-line autocomplete

fabiospampinato commented 5 years ago

do a lot of folks care about the little paperclip icon in the note list view?

Not sure, we could make a poll on the subreddit or something, but I doubt a significant portion of the userbase will partecipate 🤔

The attachments abstraction is a little weird for images especially (should an embedded image really show up as an 'attachment' in the index view?)

I'm not sure what you mean, what's the "index view"? You mean an embedded image shouldn't be displayed in the list of attachments?

You could even have a Files section in the sidebar and allow users to drag-drop files into a markdown document to add a link or image tag (depending on file type).

If you did the same thing with notes (drag a note to the markdown file to add a link) you'd also remove the need for in-line autocomplete

Drag & drop is tracked here: #15. The "Files" section is interesting, I've actually thought about this, but I can't quite imagine it implemented in a way that'd be very useful. Today you can browse a list of attachments via the quick open already (maybe I could add an "Open Attachment..." action that shows only attachments 🤔 )

rathboma commented 5 years ago

By 'index view' - I mean the list of notes in a particular tag (with the search box at the top). There's a little paperclip icon if a note has an attachment.

If all one uses attachments for is to embed an image -- that seems like a weird abstraction (Vs something like a PDF that really feels like an attachment). Maybe attachments should just get auto-listed at the top of the file when you're viewing it or something.

Using email as an example -- you can embed an image and that is NOT an email attachment, but you can also attach a file, that file doesn't get included in the body of the email, but rather listed at the bottom of the email.

For files -- if you had an All Files section in the sidebar, you could click it and view all the files in the same way you view all notes (a list with a search box at the top)

fabiospampinato commented 5 years ago

Maybe attachments should just get auto-listed at the top

That's related to #105. IMHO having attachments and tags hidden inside a popover isn't great, I've been thinking about how to improve the situation for a while but I haven't found a solution I really like yet.

Using email as an example -- you can embed an image and that is NOT an email attachment, but you can also attach a file, that file doesn't get included in the body of the email, but rather listed at the bottom of the email.

I see what you mean now.

I agree that it can get weird in some situations, for instance you could add an image as an attachment and then link to it via ![](@attachment/Foo.png), but you could also manually move Foo.png into the attachments directory and link to it the same way, in the latter scenario that image won't show up as an attachment.

I'm not sure though if we want to align more with emails under this scenario. Also listing those embedded images as attachments is a way for the app to easily keep track of which files are used in which notes, if we don't have that we would have to parse notes' contents, which we may have to do anyway though considering the scenario I described earlier 🤔

For files -- if you had an All Files section in the sidebar, you could click it and view all the files in the same way you view all notes (a list with a search box at the top)

You can get a searchable list of attachments (and notes, for now) via File -> Open....

Maybe such section could be added if we implement some kind of preview feature that works across a reasonable number of file formats 🤔 It might be also useful to have a place where to show more infos about attachments and some ways to sort them (by creation date, modification date, file size, file type etc.) Feel free to open a separate issue about that so that we can better keep track of this.