euangoddard/clipboard2markdown

Doesn't work on Firefox 88 (Ubuntu 20.04 and Windows 10)

lamyergeier opened this issue · 24 comments

Hi! It doesn't work on the latest Firefox 82. When we paste into the website, the website becomes blank. Although it works fine on the latest Chrome.

Could you please have a look?

Hi, I've just updated my Firefox to 82 and it seems to work fine for me. I am on MacOS Catalina so I'm not sure if that makes any difference. Are there any errors in the console after pasting?

As can be seen the website becomes blank and only the watermark is visible in the background after pasting in firefox. Following are the errors:

Screenshot from 2020-11-13 10-52-05

This page uses the non standard property “zoom”. Consider using calc() in the relevant property values, or using “transform” along with “transform-origin: 0 0”. clipboard2markdown

Source map error: Error: request failed with status 404
Resource URL: http://euangoddard.github.io/clipboard2markdown/bootstrap.css
Source Map URL: bootstrap.css.map

Source map error: Error: NetworkError when attempting to fetch resource.
Resource URL: moz-extension://7ef6c60f-9c93-4a52-8b4d-ac762a508fc7/shared/browser-polyfill.js
Source Map URL: browser-polyfill.js.map

I don't think any of those messages are critical to the functionality. Can you try with different clipboard content- maybe something really simple. If that is still not working then it's nothing to do with the value you're pasting

@euangoddard I pasted very simple: euangoddard / clipboard2markdown

Pasted this from the top of this page!


Note: This also happens in the private browser, where all extensions and addons are disabled!
I am using Ubuntu 20.04.1

It's tricky for me to help much here as I don't have access to an Ubuntu machine. If I had to guess it's something to do with how the clipboard works differently on the different OSs. The generation is a bit of a hack as it hijacks the native paste into a hidden text area and uses the value of that textarea to process into markdown so it could be some subtle timing issue

But on the same machine it works fine on Google Chrome.

Who knows how browser maintainers implement the clipboard interface 😄 . The problem is that unless there is an error I can investigate or I have access to an Ubuntu machine with Firefox 82 on I'm not really what what I can do. Very open to suggestions

I also have this problem since a long time.

With Firefox 88 on a Ubuntu 20.04 computer, it doesn't work.

On another Windows computer :

  • it works with Firefox stable
  • it doesn't work with Firefox nightly

How can I help you ?

same issue with 88 stable on Windows

I've just re-checked on my Mac and this works fine so it looks like it must be to do with how windows deals with the clipboard. Not having a windows machine makes it hard for me to test this. It could be a permissions issue in Firefox for Windows or it could be to do with key-bindings on the event. If anyone can show me an error I can investigate it.

Is it possible for you to add in the JavaScript console some logs with different numbers to debug and see where in the code exactly the JavaScript stops working and maybe point to a function that fails ? Because for now, I can't see any error in the console. I am available to help !

The only output is on load of the page

Screenshot

I suspect it's not something that would error, but rather one of the expected events (e.g. the paste one) won't get triggered due to some security context that is only present on certain OS

I have investigated.

In my Firefox for Ubuntu (88.0.1), this "paste" event is never called :

pastebin.addEventListener('paste', function () {

But this function is correctly called :

document.addEventListener('keydown', function (event) {
if (event.ctrlKey || event.metaKey) {
if (String.fromCharCode(event.which).toLowerCase() === 'v') {
pastebin.innerHTML = '';
pastebin.focus();
info.classList.add('hidden');
wrapper.classList.add('hidden');
}
}
});

I can get the code to works correctly (obviously only with the CTRL + V keyboard event) by updating the previous function with the content of the first one :

document.addEventListener('keydown', function (event) {
  if (event.ctrlKey || event.metaKey) {
	if (String.fromCharCode(event.which).toLowerCase() === 'v') {
		
	  pastebin.innerHTML = '';
	  pastebin.focus();
	  info.classList.add('hidden');
	  wrapper.classList.add('hidden');
	  
	  // EDIT
	  setTimeout(function () {
	      var html = pastebin.innerHTML;
	      var markdown = convert(html);
	      output.value = markdown;
	      wrapper.classList.remove('hidden');
	      output.focus();
	      output.select();
	  }, 200);
	  // END EDIT
	  
	}
  }
});

I hope it helps !

disabling the privacy measure in firefox about:config -- dom.event.clipboardevents.enabled = false, fixes this, but its not something that can/should be a requirement .

(when its false, pasting functions still work fine, except on only some sites)

Disabling the privacy measure in firefox about:config -- dom.event.clipboardevents.enabled = false, fixes this

Thanks !

For me :

  • dom.event.clipboardevents.enabled = true : clipboard2markdown works (it solves the problem)
  • dom.event.clipboardevents.enabled = false : clipboard2markdown does not works

And it explains why the addEventListener('paste', function () is not called.

So what do people think the resolution should be here? The paste specific behaviour seems to be Firefox-related and clearly asking people to change their settings doesn't make sense, but it does seem that it can also be solved by @irvnriir's code change? If the code-change will fix this for everyone then I guess a PR with this change in would be good

code change ? dom.event.clipboardevents.enabled is a user setting . i guess you meant @ Massedil 's one .?

Ah apologies it was @Massedil who suggested the code change

@euangoddard @Massedil Could you please update so that it works in Firefox?

@anishmittal2020 feel free to drop a PR in that fixes this and I'll take a look

jnm commented

http://euangoddard.github.io/clipboard2markdown/ works fine for me with Firefox 101.0.1 on Ubuntu 20.04. Can this issue be closed?

Sounds good to me