Consider adding a way to link to a file from the link inserter so someone can upload a PDF file and link it to text
My apologies for the question, but I am posting here because I believe it is a UX issue with Gutenberg that could be improved.
In the classic WordPress editor, the "Add Media" button allowed you to easily upload files to the media library without leaving the page. This allowed for easy uploading of something like a PDF file, which you could then attach to some text like Click here to download this PDF.
I know there are separate/dedicated blocks for this type of thing, but what if I'd prefer to have the text inside a paragraph block type?
I see 2 possibly ways currently, neither of which are very user friendly or obvious:
-
I can leave the page entirely, navigate to the "Media Library" page, upload the image, copy the URL, navigate back to the Gutenberg editor, select the text in my paragraph block, click the chain icon, and then paste the URL.
-
I can add a "File" block, upload the PDF, copy the URL, remove the file block, select the text in my paragraph block, click the chain icon, and paste the URL.
Proposal: Add the "Add Media" button as an option to the paragraph block's controls:

Agreed that this is currently something of a sub-optimal experience as it currently stands. I noticed this whilst working on #8295 but I suspect that this sort of thing may be better resolved by inline/nested blocks, once that becomes more of A Thing.
Another possible solution might be to allow searching media, such as PDFs, as an option in the floating link toolbar. For reference, here is a screenshot showing how search results currently look in that toolbar:
Seen at http://alittletestblog.com/wp-admin/post.php?post=14091&action=edit using Firefox 61.0.1 on macOS 10.13.6.
I think that'd probably be a better solution (than an inline file block, which may not accomplish the same thing), but it'd require some adjustments to the UI to account for it. You'd probably also want to allow for uploads directly, rather than having to switch to the media library to upload the file, then switch back to Gutenberg. (And for parity with the classic editor!)
While a great idea to allow searching of media, it introduces a new UI for browsing media, which duplicates functionality that already exists with the media uploader/browser. It also wouldnt allow you to upload without leaving the gutenberg editor, correct?
@designsimply That doesn't resolve the issue of not being able to upload a file. Having the Add Media button on the existing TinyMCE toolbar is considerably more flexible. It's much easier (and more intuitive) adding inline images, than being forced to insert an Inline Image Block. It also allows you to easily upload and link to files such as PDF's or DOCX files, without having to disrupt your editing experience by exiting the editor, going to the media library, uploading the file, and then finally going back into the editor again.
Just noting there was some extra discussion on #10280.
I think this could also be an interesting use case for the richtext formatting API so it's handled in a similar way to inline images.
So the way to do this now is to use the file block, or just drag and drop the PDF to upload it. This results in the following:

You can then click the "copy URL" button, and paste the resulting link over text:

This is how it's done today.
But I agree this flow is not ideal, and can be optimized. So labelling it as such.
Going to close this since there is a block for Files and you can grab the URL from it. In the future, it'd be nice to expand the "Link" tool to also search for files, media, etc, to link directly.
@mtias I'm a little bit confused. What does closing this issue mean to you? Does it mean that it's being punted to a future release? Or is the intention that it become lost to the archives of closed issues and forgotten, or that hopefully someone brings it up again in the future? I'm just wondering what the intention of closing this issue is, since you yourself agree that it is a valid issue.
Please note that I spoke about the file block when I opened this issue. The purpose of this issue was to outline usability issues with the current file upload flow, and that the File Block is not sufficient for a user-friendly experience.
I agree that closing this issue seems premature. Nothing has been fixed, and the issue still exists.
@mtias can you please reopen this issue? Everyone acknowledges this is a hacky workaround, and you say it would be nice to have a legit fix in the future. This seems like the best place to track this issue for that future since it's well documented here and won't require duplicating efforts to document it again.
I've got to agree, this needs a better solution. I actually had to find this thread before I knew how to upload a PDF and link to it.
I'm going to reopen this and milestone it for 5.1.
Requiring the creation of a temporary block just to copy a file url and paste onto a link is a pretty poor step back from the old editor for what is a very common use case—simply linking to a document inline.
I think if we have enhancements that we know we'd like to address in the future, but just don't know when, then we should keep them open and possibly assign some indeterminate future milestone. This is how we’d handle them on Trac, so I think we should continue that here. Closing issues makes them very difficult to find and surface later.
@mintplugins sorry I missed your ping here before. It sounds good to me to keep this open and assign to a future milestone. If there are other ideas on how to handle this, please share.
A textual search like for pages and post would help, but would maybe not sufficient, because filenames (without preview in the mediathek) are not always really clear AND a future solution should have the same power as the classic one and allow text-linking of ALL filteypes in the mediathek (with preview for selection). So we need a button solution which leads to the mediathek.
I see 2 options: a) Toolbar button (like suggested by mintplugins at the beginning) b) additional button only in the link-enterform (where it belongs)
This is the first issue I've had raised with me by someone using Gutenberg and it took me to find this post to know how you are currently meant to do it, which is an extremely sub-optimal solution.
I think that both suggestions are required. You need to be able to search for an existing media item from the "link" option as well as having the option to upload a new link.
Also, it would be nice to be able to select some text and then drag and drop a file onto the page and it automatically upload that file to the media library and link the selected text, instead of it inserting the file block.
Would it be possible to have a Media Library button within the new Link dialog, whereby if you select a media item rather than embedding it it adds a link to the file, or a link to the attachment page?
How about simply expending the link options panel to include options to upload new media or link to existing media? The Upload button could also accept drops.

Starting from @EricDu solution, this could be another (and more compact) possible solution. The upload button is missing but the UI is more clean and simple. Anyway, users could always upload files while in media modal.

where
icon button will open the media modal popup.
@virgo79, you'd still need the "..." icon to trigger the drop-down (which currently only shows the "Open in New Tab" option but, if open to plugins, could have additional options such as class, id, etc.
I'm not sure how many layers of modals users are willing to accept. And the method should be as similar as possible as other instances where you're adding media.
My preference would be to keep the default view as minimal as possible (paste or type, apply icon, more icon) and put the more rarely used options (target, media, class, id, etc.) in the drop-down.