Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy and Export a Post #4284

Closed
mtias opened this issue Jan 4, 2018 · 9 comments
Closed

Copy and Export a Post #4284

mtias opened this issue Jan 4, 2018 · 9 comments
Labels
[Feature] Paste Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Enhancement A suggestion for improvement.

Comments

@mtias
Copy link
Member

mtias commented Jan 4, 2018

One drawback of composing all content via blocks is that the ability of copying and moving a full post can become a bit harder. We support Cmd+A and Cmd+C if you are not focused on a block. I think we can, in addition, offer some clear tools for this in the ellipsis menu while at the same time exposing keyboard shortcuts for quick copy-all.

image

Furthermore, we could consider having a "Export as..." menu there for quickly generating a plain text file, or an HTML doc for the post, etc.

@mtias mtias added [Feature] Paste Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Enhancement A suggestion for improvement. Design labels Jan 4, 2018
@karmatosed
Copy link
Member

I like this as an idea. I can imagine this could be good for things like sharing blocks too.

@ellatrix
Copy link
Member

ellatrix commented Jan 4, 2018

@jasmussen and I also discussed making cmd+a work to select all content. If a block is selected without any input fields, it would select all content as it does now. If the focus is inside an input field, it would first select all content in that field, and a second time would select all blocks.

@ellatrix
Copy link
Member

ellatrix commented Jan 4, 2018

This is still a good shortcut in addition of course.

@mcsf
Copy link
Contributor

mcsf commented Jan 4, 2018

Technically, how would the copying itself happen? Per the latest Clipboard API and events W3C draft, a pure Web-events-based operation isn't expected in the future:

Note: Synthetic clipboard events will not actually modify the clipboard or the document. In other words, while the script above will fire a paste event, the data will not be pasted into the document.

Out in the wild, buttons that need to be clicked in order to copy data (e.g. copying a repository's URL from its GitHub page) are a common sight. Historically, these would require hacks, one way or another: a common solution was to use Flash. 🙈

Enter document.execCommand and its copy command. This seems to be the de facto standard invocation to write to the clipboard. Its notable characteristic is that it doesn't accept arbitrary data (à la clipboardData.setData) and instead relies on document selection. Uses on the Web include the practice of creating a textarea on the fly, injecting text into it, selecting the element, triggering the copy command, then destroying the element. This is a possibility, along with simply relying on Gutenberg's own block selection abilities. For its simplicity, I explored the latter in branch update/copy-from-ellipsis; it works in Firefox and Chrome, but not in Safari.

Are there other methods we should be thinking of for this?

@mtias
Copy link
Member Author

mtias commented Jan 5, 2018

Uses on the Web include the practice of creating a textarea on the fly, injecting text into it, selecting the element, triggering the copy command, then destroying the element.

The textarea is already at hand for the "text" mode of the editor. (See also https://github.com/WordPress/gutenberg/tree/master/components/clipboard-button )

@mcsf
Copy link
Contributor

mcsf commented Jan 5, 2018

(See also https://github.com/WordPress/gutenberg/tree/master/components/clipboard-button )

TIL. I’m constantly surprised by this codebase.

@jasmussen
Copy link
Contributor

@iseulde

@jasmussen and I also discussed making cmd+a work to select all content. If a block is selected without any input fields, it would select all content as it does now. If the focus is inside an input field, it would first select all content in that field, and a second time would select all blocks.

YES! I was thinking about this, and was sure we'd discussed this. But I can't find a ticket.

I've also been thinking that it might be cool to have different behavior for multiple consecutive ⌘A's. Like ⌘A inside a paragraph selects all text in that paragraph, ⌘A again selects this paragraph at the block level, ⌘A again selects all blocks.

@mcsf
Copy link
Contributor

mcsf commented Jan 5, 2018

→ Copying aspect implemented in #4323

@mtias
Copy link
Member Author

mtias commented Jan 26, 2018

Closing as done. I'll open one for "Export...".

@mtias mtias closed this as completed Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Paste Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

5 participants