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

Conflict with Pure Paste #429

Closed
magic-lantern opened this issue Jul 12, 2022 · 18 comments
Closed

Conflict with Pure Paste #429

magic-lantern opened this issue Jul 12, 2022 · 18 comments

Comments

@magic-lantern
Copy link

I love Maccy and its many features such as the ability to keep a large clipboard history. However, I also like to automatically remove all formatting from my clipboard. I recently installed both Maccy and Pure Paste, and it seems that they conflict with each other: when Pure Paste is running, Maccy never shows new items added to my clipboard history.

Is it possible to run both Pure Paste and Maccy at the same time? If so, how?

Alternatively, is there a way for Maccy to automatically remove all formatting from my clipboard similar to Pure Paste? WIth Pure Paste, I don't need to use any special keyboard shortcuts to paste without formatting just copy and paste as normal. Pure Paste even works with MS Office products (found that "Paste Plain Text" app from FIPLAB doesn't work with MS Office).

@p0deje
Copy link
Owner

p0deje commented Jul 12, 2022

Have you tried enabling "Paste without formatting" in Maccy preferences?

@p0deje
Copy link
Owner

p0deje commented Jul 12, 2022

Ah, I see you want to use Cmd+V to remove formatting. There is currently no way to do that in Maccy - you'd have to first open Maccy and then select item to paste.

@p0deje
Copy link
Owner

p0deje commented Jul 12, 2022

I've found the following on https://sindresorhus.com/pure-paste:

Pure Paste conflicts with my clipboard manager

This is a known issue. It’s really just a flaw in how the clipboard works. If your clipboard managers reads the clipboard first, it will get it. If Pure Paste then reads the clipboard, it will do its thing, but also tell clipboard managers not to fetch the new contents as otherwise they might end up with duplicates. This is required as otherwise certain features like “fast-append” don’t work in Alfred and other clipboard managers. I’m working on a way all apps can collaborate, but it will take some time.

For now, I suggest setting a keyboard shortcut for “Clear formatting and paste” and then turn off “Automatically clear formatting”.

I suggest reaching out to Pure Paste author using https://sindresorhus.com/feedback/?product=Pure%20Paste&referrer=Website-FAQ and link this issue. I'd be glad to make Maccy work nice with Pure Paste, just not sure how to do that and PurePaste code is closed-source.

@magic-lantern
Copy link
Author

The way Pure Paste works is to intercept the regular clipboard so that copy (Command-C) followed by normal paste (Command-V) removes formatting.

The macOS built in paste and match style (Command + Option + Shift + V) doesn't work for many apps, so there isn't a reliable native option available.

I do have the option "Paste without formatting" already selected in Maccy but that seems to do nothing or I'm not understanding how it works. It is true I can open Maccy, select an item with special hotkeys pressed while selected, then paste the item to remove formatting.

I have reached out to Pure Paste with this issue.

@sindresorhus
Copy link

I'm already working with the Raycast team to resolve this.

I have a draft proposal Maccy may want to implement. I'm happy to answer any questions or discuss better solutions.

@sindresorhus
Copy link

Clipboard Modifiers Interoperability

This is a early draft proposal for improving compatibility between apps that modify the clipboard contents (like Pure Paste) and clipboard managers that save the clipboard contents.

Be aware that this proposal may change in the future.

I intend to submit an official proposal to nspasteboard.org at some point.

Problem

Apps that modify the clipboard can conflict with clipboard managers. If your clipboard manager reads the clipboard first, it will get it. If Pure Paste then reads the clipboard, it will do its thing, but also tell clipboard managers not to fetch the new contents (by setting the org.nspasteboard.AutoGeneratedType pasteboard identifier) as otherwise they might end up with duplicates. This is required as otherwise certain features like “fast-append” don’t work in Alfred and other clipboard managers. If Pure Paste reads the contents first, clipboard managers will not get it at all.

Solution

Introducing a new meta identifier x.nspasteboard.ModifiedType (using x instead of org for now as it's not officially proposed yet) which would contain the NSPasteboard#changeCount of the original item that was modified. Pure Paste would set this meta identifier instead. That way, clipboard managers could remove the duplicate* if they already recorded the original item or use the new item if they didn't have a chance to record the original item.

So the flow would be:

A:

  • A user copies some rich text.
  • Pure Paste reads the clipboard first, strips formatting, and writes back the modified pasteboard items. It also sets x.nspasteboard.ModifiedType with the original changeCount.
  • The clipboard manager app reads the clipboard, sees that it has x.nspasteboard.ModifiedType, checks the provided changeCount and sees that it does not have a record of the original, so the clipboard manager app just accepts the current modified item.

B:

  • A user copies some rich text.
  • The clipboard manager app reads the clipboard first. It does not encounter any meta tags, so it just saves the pasteboard item.
  • Pure Paste then reads the clipboard, strips formatting, and writes back the modified pasteboard items. It also sets x.nspasteboard.ModifiedType with the original changeCount.
  • The clipboard manager app reads the clipboard again. This time it encounters x.nspasteboard.ModifiedType. It checks for the changeCount and sees that it previously recorded the original item. The clipboard manager app then replaces the original with the modified one.

Pure Paste sets x.nspasteboard.ModifiedType, so you can use it for testing.

* The changeCount is only unique for the current login session, so you should ensure you only check the pasteboard items in the last 5 seconds when checking for existing items.

Important

Note that Pure Paste still includes org.nspasteboard.AutoGeneratedType for compatibility with other clipboard managers like Alfred. x.nspasteboard.ModifiedType should take precedence for now. Eventually, Pure Paste will remove org.nspasteboard.AutoGeneratedType.

@p0deje
Copy link
Owner

p0deje commented Jul 13, 2022

@sindresorhus Thank you for sharing the proposal, is this available in any Pure Paste version so I could test it out?

@sindresorhus
Copy link

Yes, the latest version of Pure Paste includes it.

You can use https://github.com/sindresorhus/Pasteboard-Viewer for debugging.

@turbanisch
Copy link

I was wondering whether Maccy could eliminate the need for another program like Pure Paste by adding a separate shortcut for the action "paste the most recent item without formatting"? Then the user could replace the native Cmd + V with this action and trigger the Maccy popup only when needed, with another shortcut.

@magic-lantern
Copy link
Author

@turbanisch - That would work for my usecase!

@sindresorhus
Copy link

The latest version of Pure Paste is now compatible with clipboard managers by default. I would still recommend implementing what's proposed in this issue though, as there's still a chance to get duplicates (rich text + plain text) in your clipboard history.

@sindresorhus
Copy link

Note that Pure Paste is not simply just removing formatting. It's smart about it and has workarounds for a lot of apps. For example, if you naively remove formatting from stuff in Excel, cut and paste stops working. It also handles Figma and many other apps. In addition, it has removal of tracking parameters from URLs.

I do agree it makes sense to have a "paste the most recent item without formatting" thing in Maccy though.

@turbanisch
Copy link

Thanks for the clarification! And no offense, I did not mean to suggest that Pure Paste is redundant at all, I was just thinking that adding a shortcut that does not trigger the whole clipboard list to Maccy might work as a short-term solution for many people in most cases. Of course the solution proposed in #96 would be even better, I guess.

@p0deje
Copy link
Owner

p0deje commented Sep 30, 2022

It's already possible to paste without formatting by using a shortcut like https://www.icloud.com/shortcuts/de3500c2ef0543c8a05cce913f8d1723 (given you have "Paste automatically" and "Paste without formatting" enabled in Maccy preferences). You can bind the shortcut to any global keybinding you want.

@turbanisch
Copy link

Thanks! Apparently it is not possible to overwrite the ⌘V shortcut though because it triggers the (native) paste operation. Even pasting "⌘V" does not do the trick. When I bind it to some other shortcut, the Quick Action runs fine but with a very noticeable lag.

@p0deje
Copy link
Owner

p0deje commented Sep 30, 2022

Yeah, the lag is probably coming from the shortcut initialization and I don't think there is anything I can do about it.

@p0deje p0deje closed this as completed in e96eb3d Jan 20, 2023
@p0deje
Copy link
Owner

p0deje commented Jan 20, 2023

The new version should work with Pure Paste correctly. It would detect if Pure Paste clears formatting and replace the original item with the new one in Maccy history. Please make sure that you have "Improve compatibility with apps appending to the clipboard" disabled.

@sindresorhus
Copy link

@p0deje Nice work 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants