Skip to content

Copy, Cut, Paste, Duplicate blocks#2378

Merged
geriux merged 6 commits intodevelopfrom
feature/copy-paste-blocks
Jun 30, 2020
Merged

Copy, Cut, Paste, Duplicate blocks#2378
geriux merged 6 commits intodevelopfrom
feature/copy-paste-blocks

Conversation

@geriux
Copy link
Copy Markdown
Contributor

@geriux geriux commented Jun 12, 2020

Fixes #2326

Gutenberg PR -> WordPress/gutenberg#23110
WordPress iOS PR-> wordpress-mobile/WordPress-iOS#14392
WordPress Android PR-> wordpress-mobile/WordPress-Android#12187

This PR adds the functionality to copy, cut, paste, and duplicate blocks. This would be very useful to be able to move blocks from inner blocks or to group blocks like Group or Columns.

To test check Gutenberg PR description.

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@geriux geriux added the [Type] Enhancement Improves a current area of the editor label Jun 12, 2020
@geriux geriux added this to the 1.31 milestone Jun 12, 2020
@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Jun 12, 2020

Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job!

@geriux geriux marked this pull request as ready for review June 12, 2020 16:09
@geriux geriux requested a review from pinarol June 12, 2020 16:09
Copy link
Copy Markdown
Contributor

@pinarol pinarol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, see for test effort: WordPress/gutenberg#23110 (comment)

@pinarol
Copy link
Copy Markdown
Contributor

pinarol commented Jun 12, 2020

Let's not forget to add release notes, though.

@geriux
Copy link
Copy Markdown
Contributor Author

geriux commented Jun 12, 2020

Hey there 👋 @iamthomasbishop !

Whenever you have a chance, could you please test this feature and give us your feedback?

Here you'll find the builds:

WordPress iOS PR-> wordpress-mobile/WordPress-iOS#14309
WordPress Android PR-> wordpress-mobile/WordPress-Android#12187

More info and screenshots here.

Thank you so much!

@geriux geriux force-pushed the feature/copy-paste-blocks branch from 3a46079 to 9563614 Compare June 15, 2020 12:51
@pinarol pinarol mentioned this pull request Jun 16, 2020
2 tasks
@iamthomasbishop
Copy link
Copy Markdown
Contributor

@geriux This is looking pretty solid already — nice work! After testing out pretty extensively, I've got a bunch of feedback which I'll try to keep succinct 🙂 I'm sure we'll need another round of review, but this should cover the big picture things.

Overfow menu

  • Can we hide the paste action when there isn't anything in the clipboard to paste? (rather than just disabling it)
  • On iOS, do we have access to the native Context Menu component? That might help to condense the menu a bit and also if we can get the menu to appear from near the ••• menu, we can have some proximity benefits. If we used that on iOS, perhaps it would be trying the Menu component on Android for consistency. (Examples of how this might work)
  • I'm not sold on the "Cut" option, and because web also doesn't have it, I vote we remove it to conserve space as we add more items.
  • I think we might want the labels on the sheet slightly more descriptive — "Copy block" and "Duplicate block", "Paste block", so it doesn't conflict/confuse with the native side (eg. while copying one part of a broader text string, "copy" means copy only that text, whereas in this context "copy" means the whole block).

Native select/copy/paste

  • Are we able to connect with the native paste function so users can use the native edit/selection menu components to paste? For example, if I’ve copied a block from the overflow menu, tap on a rich text input to see the edit menu, then tap paste, the block I’ve copied is pasted. (example on iOS)

Notice component

  • Can we also show notices when blocks are duplicated, pasted, or removed?
  • Instead of stacking multiple notices when there are multiple at a given moment, can we substitute them? For example, if I perform an action that triggers a notice and then another action that triggers a second, they currently stack on top of each other. I think it might feel smoother if the second one simply replaces the first one (in the same Y-position, via a cross-fade or instantly)
  • I've dropped updated styling for the component in the design docs here. The key thing you'll see is that I'm attempting to replicate the iOS-system materials on iOS, which produces a background blur and translucency. I talked to @wppinar today about potentially using a third party library called Blur if we're unable to access the system materials directly. Android uses solid colors, which we can fine-tune to use available colors if necessary.

Unrelated

  • For the overflow menu in general, I wonder if long-pressing on an un-selected block (or the surrounding UI on a selected block aka inline toolbar) should show the overflow/menu sheet with all of the options? Here is an example flow

@pinarol
Copy link
Copy Markdown
Contributor

pinarol commented Jun 18, 2020

I'm not sold on the "Cut" option, and because web also doesn't have it, I vote we remove it to conserve space as we add more items.

Actually "Cut block" is implemented behind the scenes on web, but it is connected with Cmd+X. It is just not in the menu but the functionality is there. You can see this small notice on web when you do cmd+x:

Screen Shot 2020-06-18 at 10 52 51

And as you know you can drag&drop blocks inside/outside a nested block by pressing down the up/down buttons on web.

But we don't have a way to move a block inside/outside a nested block. In this sense Cut functionality is quite useful imo, and it is a quick win for us since we are already implementing Copy/Paste/Duplicate, wdyt?

@mchowning
Copy link
Copy Markdown
Contributor

mchowning commented Jun 18, 2020

👋 @geriux ! We're close to merging the monorepo changes 🎉 , and we will be cutting the release branches as soon as the monorepo changes are merged to gutenberg-mobile. As a result, we may be cutting the 1.31 release branches earlier than normal.

Because every merge further delays the monorepo work (ends up requiring conflicts to be fixed and other work due to the monorepo feature branch and the squash policy in gutenberg), we want to cut the release branch with no further changes. For that reason, I'll bump this milestone to 1.32. Of course, if this has to make the 1.31 release, go ahead and move it back to the 1.31 milestone, and let me know. 🙇

@mchowning mchowning modified the milestones: 1.31, 1.32 Jun 18, 2020
@geriux
Copy link
Copy Markdown
Contributor Author

geriux commented Jun 19, 2020

👋 @geriux ! We're close to merging the monorepo changes 🎉 , and we will be cutting the release branches as soon as the monorepo changes are merged to gutenberg-mobile. As a result, we may be cutting the 1.31 release branches earlier than normal.

Because every merge further delays the monorepo work (ends up requiring conflicts to be fixed and other work due to the monorepo feature branch and the squash policy in gutenberg), we want to cut the release branch with no further changes. For that reason, I'll bump this milestone to 1.32. Of course, if this has to make the 1.31 release, go ahead and move it back to the 1.31 milestone, and let me know. 🙇

Sounds good! Thanks for letting me know Matt 🙌

@geriux
Copy link
Copy Markdown
Contributor Author

geriux commented Jun 19, 2020

  • I've dropped updated styling for the component in the design docs here. The key thing you'll see is that I'm attempting to replicate the iOS-system materials on iOS, which produces a background blur and translucency. I talked to @wppinar today about potentially using a third party library called Blur if we're unable to access the system materials directly. Android uses solid colors, which we can fine-tune to use available colors if necessary.

Hey, @iamthomasbishop 👋 I've added the library to test how it'd work, here's a light mode example and a dark mode one.

Is that what you had in mind? If it is I can prepare a build for you to test. Also, to double check, this is only for iOS right?

Thanks!

@iamthomasbishop
Copy link
Copy Markdown
Contributor

@geriux That looks great, glad to see you were easily able to implement it! I'm not sure what values you're using, but it feels a little thin esp on light mode. I'm looking over the library readme and it looks like we have access to various blurType properties — can you tell me which one you're using in the examples above?

@iamthomasbishop
Copy link
Copy Markdown
Contributor

In this sense Cut functionality is quite useful imo, and it is a quick win for us since we are already implementing Copy/Paste/Duplicate, wdyt?

@pinarol Fair points you made above, let's keep cut for now.

@geriux
Copy link
Copy Markdown
Contributor Author

geriux commented Jun 23, 2020

@geriux That looks great, glad to see you were easily able to implement it! I'm not sure what values you're using, but it feels a little thin esp on light mode. I'm looking over the library readme and it looks like we have access to various blurType properties — can you tell me which one you're using in the examples above?

I was using light and dark, here are other examples:

light (before) regular (after)
dark (before) prominent (after)

What do you think of those? If you want other examples let me know =)

Thanks!

@iamthomasbishop
Copy link
Copy Markdown
Contributor

@geriux I pulled these screenshots into Figma to compare against the system material equivalents I have.

  • Dark mode: "Prominent" (RN) looks roughly equivalent to "Regular" (System), which is what I was going for 👍
  • Light mode: "Regular" (RN) looks roughly equivalent to "Ultralight" (System), which is a bit thin 👎
    Can we try "Prominent" in light mode as well and see if that aligns w/ the "Regular" system material in the same way?

Another thing I think I'd like to do is to remove the border-bottom from both iOS and Android — I thought it might be necessary for separation, but it doesn't quite look right esp on iOS. I'll update the component on the Figma + design docs side.

@geriux
Copy link
Copy Markdown
Contributor Author

geriux commented Jun 25, 2020

Can we try "Prominent" in light mode as well and see if that aligns w/ the "Regular" system material in the same way?

Prominent (light mode) Prominent (dark mode)

I think this one does look like your example, what do you think? I also removed the border bottom.

Let me know, thanks!

@geriux geriux force-pushed the feature/copy-paste-blocks branch from 9563614 to e43ccf8 Compare June 25, 2020 14:46
@iamthomasbishop
Copy link
Copy Markdown
Contributor

That looks great, let's roll with it. Nice work @geriux !

Side note: I think this will only look better when the Navigation Bars on the apps are all (eventually) changed to use the translucent materials. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Enhancement Improves a current area of the editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Copy/Cut/Paste blocks

4 participants