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

doc: add a spec for the change to formatted copying #5212

Merged
merged 14 commits into from
Apr 9, 2020

Conversation

cinnamon-msft
Copy link
Contributor

Summary of the Pull Request

This is the spec that goes into what we do with HTML copy once we set the default copy behavior to plain text.

References

#4191

PR Checklist

  • Closes #xxx
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

doc/specs/#4191 - Formatted Copy/spec.md Outdated Show resolved Hide resolved
doc/specs/#4191 - Formatted Copy/spec.md Outdated Show resolved Hide resolved
@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 1, 2020
carlos-zamora
carlos-zamora previously approved these changes Apr 1, 2020

One possible issue is that discovering how to copy the formatting might be difficult to find. We could mitigate this by adding it into the settings.json file and commenting it out.

## Future considerations
Copy link
Member

Choose a reason for hiding this comment

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

#1553 - We should just treat Alt like we do with Shift in VTMM. It's a non-rebindable keybinding until then.

doc/specs/#4191 - Formatted Copy/spec.md Outdated Show resolved Hide resolved
Comment on lines 46 to 48
a. Just like the the `trimWhitespace` argument you can add to the `copy` key binding, we could add one for text formatting.

`{"command": {"action": "copy", "keepFormatting": true}, "keys": "ctrl+a"}`
Copy link
Member

Choose a reason for hiding this comment

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

Personally, like this idea the best. It's simple and straightforward. At some point, after deciding which route to go with, we should decide what the default keybinding will be, if any.

@DHowett-MSFT
Copy link
Contributor

I have a strong distaste for changing our default because of a handful of applications that lack "paste plain text" as an option. It's not a hill I'm willing to die on, but look:

  • people say they want plain text, they can have it (via a couple steps)
  • pasting into a terminal already strips HTML/RTF
  • pasting into a rich document preserves rich formatting
  • pasting into a spreadsheet auto-strips html/rtf
  • pasting into a preformatted code block or code editor auto-strips html/rtf
  • people are going to be stuck in the mid 1900s forever, and we just look like we simply don't support html copy (because nobody's going to read our json file, let's be honest)

@carlos-zamora
Copy link
Member

I have a strong distaste for changing our default because of a handful of applications that lack "paste plain text" as an option. It's not a hill I'm willing to die on, but look:

  • people say they want plain text, they can have it (via a couple steps)
  • pasting into a terminal already strips HTML/RTF
  • pasting into a rich document preserves rich formatting
  • pasting into a spreadsheet auto-strips html/rtf
  • pasting into a preformatted code block or code editor auto-strips html/rtf
  • people are going to be stuck in the mid 1900s forever, and we just look like we simply don't support html copy (because nobody's going to read our json file, let's be honest)

That seems fair. So then the keybinding arg would default to "true" or "rtf, html, plain"? (this should be in the spec)

@carlos-zamora
Copy link
Member

(also maybe worth adding to the spec)
I was wondering "what if somebody wants to just copy a specific aspect of the formatting like the font size/family?". I feel that the main annoyance with html copy is the following scenario:

  • I'll have a dark background color but acrylic tuned to make it legible
  • I then copy it to MSFT Word
  • since acrylic can't be copied over (and that's just impossible to do) it may no longer be legible
    But if that's the case, and all I really wanted was the font family, then that should be something we allow as a part of FR: Customizable HTML/formated copy #2131 later. For now, the user would just have to paste with the current formatting, then tweak to make it look better, which I feel is fair.

@carlos-zamora carlos-zamora dismissed their stale review April 1, 2020 21:12

My bad. I didn't realize I approved this spec until just now.

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 1, 2020
@cinnamon-msft
Copy link
Contributor Author

I am strongly of the opinion that our default should be plain text copy. The votes were overwhelming towards plain text and other terminal emulators behave in this way (including conhost). We cannot guarantee that the receiving application will give you the ability to format your pasted text (Microsoft Teams for example).

To address your concern about discoverability, if it's a global setting, it would be easy to find in a settings UI. We could also ship either the key binding or the global setting inside settings.json.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Okay so I've got some thoughts off the cuff:

  • I think I prefer option 2, the keybinding arg one. That way users could specify different bindings for different formats.
    • maybe if we had a global setting, then that would apply to all copy actions, unless they set format manually. So you could use ["html", "rtf", "plain"] globally for all copy actions, but then a particular keybinding only has ["plain"]. This is more of a 1&2 combo solution.
  • I don't love the magic alt logic on right-click. Especially if we go with the global setting route. This would make more sense once we had mouse bindings, but I'm not so sure about it nowadays.
  • We could always support true == ["html", "rtf", "plain"], so the user could specify both? though the naming might be confusing then
  • I'd really love if we could have the "default" in userDefaults.json (the one that's created for new settings files) that includes all of ["html", "rtf", "plain"] by default, with a note that the user can remove whatever formats they want. That way, it's immensly more discoverable that those are options, and that they're trivial to opt out of.
    • The whole "copy as formatted text" thing was something that I wouldn't have thought I wanted until I had it and now I love it. If it's not immediately obvious as an option, I wouldn't have even looked for it.
  • This sure sounds like a lot of work, more than a bugfix. Are we planning on getting this in on this side of 1.0?

@carlos-zamora
Copy link
Member

  • We could always support true == ["html", "rtf", "plain"], so the user could specify both? though the naming might be confusing then

I really like this. So then the following two keybindings would be deserialized to be the same thing:

{"command": {"action": "copy", "formats": ["html","rtf","plain"]}, "keys": "ctrl+a"}

and

{"command": {"action": "copy", "formats": true}, "keys": "ctrl+a"}
  • I'd really love if we could have the "default" in userDefaults.json (the one that's created for new settings files) that includes all of ["html", "rtf", "plain"] by default, with a note that the user can remove whatever formats they want. That way, it's immensly more discoverable that those are options, and that they're trivial to opt out of.

Also agree (this should go in the spec)

doc/specs/#4191 - Formatted Copy/spec.md Outdated Show resolved Hide resolved
doc/specs/#4191 - Formatted Copy/spec.md Outdated Show resolved Hide resolved
doc/specs/#4191 - Formatted Copy/spec.md Outdated Show resolved Hide resolved
doc/specs/#4191 - Formatted Copy/spec.md Outdated Show resolved Hide resolved
doc/specs/#4191 - Formatted Copy/spec.md Outdated Show resolved Hide resolved

`"copyFormats": ["html","rtf","plain"]`

b. We could also just combine html and rtf into a single boolean. Users would either get plain text only (`false`) or all formatting (`true`) onto their clipboard. If this is set to `true`, the default right click behavior is reversed: right clicking copies the formatting and holding `alt` copies only the plain text.
Copy link
Contributor

Choose a reason for hiding this comment

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

like other specs before it, make sure to call out the option we finally decided upon and move all unchosen options into an investigation notes section.

Copy link
Contributor

Choose a reason for hiding this comment

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

A spec isn't useful if it just says "we could do a, b, c" without it coming to its own consensus.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed the same formatting as the default profile settings spec and added a conclusions section at the bottom.

Copy link
Member

Choose a reason for hiding this comment

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

I think it might be clearer to make sure to mention "here are some proposals, with conclusions at the bottom" then, because I too got confused

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 7, 2020
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 7, 2020
@DHowett-MSFT DHowett-MSFT added the Needs-Second It's a PR that needs another sign-off label Apr 7, 2020
@ghost ghost requested review from miniksa and leonMSFT April 7, 2020 21:38
Copy link
Contributor

@leonMSFT leonMSFT left a comment

Choose a reason for hiding this comment

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

Just a couple of clarifications!

doc/specs/#4191 - Formatted Copy/spec.md Outdated Show resolved Hide resolved

`"copyFormats": ["html","rtf","plain"]`

b. We could also just combine html and rtf into a single boolean. Users would either get plain text only (`false`) or all formatting (`true`) onto their clipboard. If this is set to `true`, the default right click behavior is reversed: right clicking copies the formatting and holding `alt` copies only the plain text.
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but if option b is the one we're going for, we're not having the Alt-RightClick to copy plaintext/formatting right? Right click should just copy formatting if the setting is true, and plain text if false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah nice catch. I just removed references to alt right click functionality. 👍

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 9, 2020
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 9, 2020
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Yea these are kind of nits, so I'm not gonna block


`"copyFormats": ["html","rtf","plain"]`

b. We could also just combine html and rtf into a single boolean. Users would either get plain text only (`false`) or all formatting (`true`) onto their clipboard. If this is set to `true`, the default right click behavior is reversed: right clicking copies the formatting and holding `alt` copies only the plain text.
Copy link
Member

Choose a reason for hiding this comment

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

I think it might be clearer to make sure to mention "here are some proposals, with conclusions at the bottom" then, because I too got confused

doc/specs/#4191 - Formatted Copy/spec.md Outdated Show resolved Hide resolved
doc/specs/#4191 - Formatted Copy/spec.md Outdated Show resolved Hide resolved

## Conclusions

The team has decided to have plain text as the default copy behavior and to enable formatted copying with a global setting that accepts a boolean value (settings option 1 - global setting, option b). In the future, we can modify this setting to also accept an array, so the user can specify which formats they would like to copy. Additionally, a key binding can be added to allow for greater flexibility.
Copy link
Member

Choose a reason for hiding this comment

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

Wait didn't we decide on a combo of both 2 & 3?

We do the global setting now, as a boolean, because that's easy. (This is 2a)

We can then update that to additionally accept an array in the future, where true == [html, rtf, plain] and false==[plain] (This is 2b)

Then, we could further add an optional parameter to the copy ShortcutAction. If it's set, we'll copy with the provided formatting. Otherwise, we'll use the value of the global setting? (This is 3)

Copy link
Member

Choose a reason for hiding this comment

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

Okay I guess this is kinda what it does say, I just didn't immediately parse that this was a phased implementation plan

doc/specs/#4191 - Formatted Copy/spec.md Outdated Show resolved Hide resolved
Copy link
Contributor

@leonMSFT leonMSFT left a comment

Choose a reason for hiding this comment

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

lookin gud

ghost pushed a commit that referenced this pull request Apr 9, 2020
## Summary of the Pull Request
Implements `copyFormatting` as a global setting. When enabled, formatting such as font and foreground/background colors are copied to the clipboard on _all_ copy operations.

Also updates the schema and docs.

## References
#5212 - Spec for Formatted Copying
#4191 - Setting to enable/disable formatted copy

This feature will also have an impact on these yet-to-be-implemented features:
- #5262 - copyFormatting Keybinding Arg for Copy
- #1553 - Pointer Bindings


## PR Checklist
* [X] Closes #4191

## Detailed Description of the Pull Request / Additional comments
We already check if the hstring passed into the clipboard is empty before setting it. So the majority of the changes are actually just adding the global setting in.

## Validation Steps Performed
| `copyFormatting` | Mouse Copy | Keyboard Copy |
|--|--|--|
| not set (`false`) | ✔ | ✔ |
| `true` | ✔ | ✔ |
| `false` | ✔ | ✔ |
@cinnamon-msft
Copy link
Contributor Author

I addressed @zadjii-msft's nits as well as added @carlos-zamora's comment to the Future Considerations section. :)

@carlos-zamora
Copy link
Member

I addressed @zadjii-msft's nits as well as added @carlos-zamora's comment to the Future Considerations section. :)

The main thing holding me back is still that the GitHub issues aren't linked. That makes things like this easier to track.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Thanks

@DHowett-MSFT DHowett-MSFT changed the title Spec for Formatted Copying doc: add a spec for the change to formatted copying Apr 9, 2020
@DHowett-MSFT DHowett-MSFT merged commit 08df4fc into master Apr 9, 2020
@DHowett-MSFT DHowett-MSFT deleted the cinnamon/html-copy-spec branch April 9, 2020 23:30
ghost pushed a commit that referenced this pull request Apr 9, 2020
## Summary of the Pull Request
Implements `copyFormatting` as a global setting. When enabled, formatting such as font and foreground/background colors are copied to the clipboard on _all_ copy operations.

Also updates the schema and docs.

## References
#5212 - Spec for Formatted Copying
#4191 - Setting to enable/disable formatted copy

#5263 - PR prematurely merged without approval of #5212 

This feature will also have an impact on these yet-to-be-implemented features:
- #5262 - copyFormatting Keybinding Arg for Copy
- #1553 - Pointer Bindings
- #4191 - add array support for `copyFormatting`


## Detailed Description of the Pull Request
We already check if the hstring passed into the clipboard is empty before setting it. So the majority of the changes are actually just adding the global setting in.

## Validation Steps Performed
| `copyFormatting` | Mouse Copy | Keyboard Copy |
|--|--|--|
| not set (`false`) | ✔ | ✔ |
| `true` | ✔ | ✔ |
| `false` | ✔ | ✔ |
DHowett pushed a commit that referenced this pull request Aug 15, 2020
Adds array support for the existing `copyFormatting` global setting.
This allows users to define which formats they would specifically like
to be copied.

A boolean value is still accepted and is translated to the following:
- `false` --> `"none"` or `[]`
- `true` --> `"all"` or `["html", "rtf"]`

This also adds `copyFormatting` as a keybinding arg for `copy`. As with
the global setting, a boolean value and array value is accepted.

CopyFormat is a WinRT enum where each accepted format is a flag.
Currently accepted formats include `html`, and `rtf`. A boolean value is
accepted and converted. `true` is a conjunction of all the formats.
`false` only includes plain text.

For the global setting, `null` is not accepted. We already have a
default value from before so no worries there.

For the keybinding arg, `null` (the default value) means that we just do
what the global arg says to do. Overall, the `copyFormatting` keybinding
arg is an override of the global setting **when using that keybinding**.

References #5212 - Spec for formatted copying
References #2690 - disable html copy

Validated behavior with every combination of values below:
- `copyFormatting` global: { `true`, `false`, `[]`, `["html"]` }
- `copyFormatting` copy arg:
  { `null`, `true`, `false`, `[]`, `[, "html"]`}

Closes #4191
Closes #5262
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Second It's a PR that needs another sign-off
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants