ajaxorg / ace

Ace (Ajax.org Cloud9 Editor)
https://ace.c9.io
Other
26.73k stars 5.28k forks source link

copy-paste not working in firefox #2794

Open a-x- opened 8 years ago

a-x- commented 8 years ago

hi,

are know about this problem?

nightwing commented 8 years ago

Hi. We didn't know about this problem. Are you talking about copy-paste with keyboard shortcuts or context menu? Did you test this on ace.c9.io or some other site? Which OS did you use?

a-x- commented 8 years ago

os x maverix firefox 42

for example, ace on github

and hotkeys and context menu

on screenshot marked text, which will be paste

2015-12-10 10-07-42 screenshot

lennartcl commented 8 years ago

I tried this on OSX with version 40.0 and 43.0b9. Copy-paste with keyboard and the context menu both appear to work. The only thing I notice that is slightly off is the "Search Google for " menu item also shown in your screenshot. Other than that if you can't copy-paste that might be caused by a plugin. Could you try again in safe mode? (https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode)

a-x- commented 8 years ago

i tried now. with same result...

nightwing commented 8 years ago

Do you have a script or a program installed which enhances system clipboard? (e.g adds clipboard history)

a-x- commented 8 years ago

nope

my apps:

brew cask list
adium           evernote        jing            qlstephen       spectacle       webpquicklook
alfred          firefox         ngrok           quicklook-csv       sublime-text3       webstorm
asepsis         gimp            opera           quicklook-json      suspicious-package  xmind
betterzipql     google-chrome       pomotodo        screenhero      todoist (!)     xquartz
brain-workshop      google-chrome-canary    qlcolorcode     sketch          transmission        yandex
caffeine        iterm2          qlmarkdown      skype           vienna          yandex-beta
chromium        iterm2-beta     qlprettypatch       slack           vlc
ghost commented 8 years ago

tl;dr: Workaround for me(linux+firefox 44.0): dom.event.clipboardevents.enabled must be true in Firefox (which is the default)

Hi. I'm experiencing a similar situation: copy/paste not working in linux with firefox and here's a superficial explanation on why and the workaround: https://github.com/rust-lang/rust-playpen/issues/69#issuecomment-155036257

I'm currently trying to figure out a way to have dom.event.clipboardevents.enabled set to the non-default value of false in Firefox and still have the copy/pasting work fine (copy/pasting works in every other website thus far, except on play.rust-lang.org and https://rustbyexample.com/hello.html which both seem to be using ACE - as far as I could tell(I don't know javascript/html tho, so I might be wrong))

Any hints on how to fix this are more than welcome. Thank you in advance!

ghost commented 8 years ago

I get the exact same on-right-click 'Search Google for' when dom.event.clipboardevents.enabled is false (EDIT: correction, whether it's false or true it has the same effect) EDIT2: related issue: https://github.com/ajaxorg/ace/issues/2740

pic with false

EDIT: ok I have the search engine name renamed to 'Google2' but you get the point :)

nightwing commented 8 years ago

Unfortunately ace can not work without clipboard events, it needs copy event to update the hidden textarea. It is also possible to update value of textarea when selecting text, but that way editor becomes slow when large text is selected.

ghost commented 8 years ago

That is understandable of course. Is there some way that I can enable the update value of textarea when selecting text for myself ? Or can you tell me where to look in the ACE code if I wanted to do this? I would really like to have copy/paste work when clipboard events are disabled.

tl;dr from below: Is it possible to modify ACE to never use a hidden text area and instead just use the visible text area for copy/pasting?

If I understand you correctly, there's a hidden plaintext area which ACE maps its colorful multiline editor that is visible to when onCopy is triggered(I don't know javascript, so I'm just guessing here) and from that hidden text area the plain text is being fed to firefox/clipboard. Does that mean that whatever I've selected from the colorful multiline editor that is visible cannot be used as text/plaintext to be fed to the clipboard? Or if it can, something else is preventing this from working properly (such as, the fact that copying still pulls text from the hidden text area which has nothing selected due to onCopy never being triggered, while clipboard events are disabled) In other words, is the selected text from the visible text area not copy-able? in principle. Or, it is, but other ACE events are preventing it from working(even when clipboard events are disabled) because of the way it's implemented trying to update and use the hidden text area for copying? Maybe then I could disable those events, and thus allow firefox to can copy the visible text by itself?

nightwing commented 8 years ago

Ace uses non eidtable nodes to render text. Dom nodes are created only for the visible part of the text, and selection is a div behind the text. This allows Ace to be fast, but browser selection doesn't work so we have to use copy event to fix that. https://github.com/ajaxorg/ace/blob/master/lib/ace/keyboard/textinput.js

Is there some way that I can enable the update value of textarea when selecting text for myself

this is possible to do, but you'll have to open browser console and run something like ace.setOption(...) to enable it, is that an acceptable solution?

ghost commented 8 years ago

this is possible to do, but you'll have to open browser console and run something like ace.setOption(...) to enable it, is that an acceptable solution?

That sounds acceptable. Eager to try it. Thanks in advance!

EDIT: I just did a test editor.setOption("maxLines", 10); on this webpage and it worked instantly! EDIT2: also did editor.setOption("showInvisibles", true); and I love it already xD EDIT3: this is also working editor.getCopyText();

ghost commented 8 years ago

Do you think it might be a good idea to, if ACE can detect that clipboard events are disabled(or for some reason not working), then automatically fallback to as you said It is also possible to update value of textarea when selecting text, but that way editor becomes slow when large text is selected.

nightwing commented 8 years ago

It is a good idea, but AFAIK there is no way to detect that.

ghost commented 8 years ago

Or here's a random idea, if it's possible for ACE to detect when the right click mouse button is pressed (or when that menu appears) , then execute editor.getCopyText(); and have ACE copy that into clipboard?(or maybe in order for ACE to modify clipboard, it does still need dom.event.clipboardevents.enabled to be true?) Or maybe a new menu item can be added ? Ok, I don't know :)

EDIT: Can ACE trigger a clipboard event? For example if it tries to put something into the clipboard(eg. do a copy into clipboard, programatically) then, if that triggers a clipboard event just like when the user does it, then ACE could use that to detect if clipboard events are enabled/working.

ghost commented 8 years ago

this is possible to do, but you'll have to open browser console and run something like ace.setOption(...) to enable it, is that an acceptable solution?

Can you please tell me which setOption to use there? I'm assuming it's already implemented, otherwise, you don't have to implement a new one just for this, obviously.

Otherwise, I could just use editor.getCopyText(); for now, it's still better than nothing :D (since I do want to keep clipboard events off for to avoid the case when websites can capture my copy/pasting of the password from the password manager to some website's password text area)

nightwing commented 8 years ago

I meant we can implement that, but it won't be convenient to use, because we do not have a way to detect missing support for clipboard events.

Webpages can't modify or read clipboard outside of clipboard events.

(since I do want to keep clipboard events off for to avoid the case when websites can capture my copy/pasting of the password from the password manager to some website's password text area)

I don't understand. Only the website in which you paste can capture contents of your clipboard. But when you paste into password text area, you already give that password to the website, and website can detect changes to textarea using input event too.

ghost commented 8 years ago

Only the website in which you paste can capture contents of your clipboard. But when you paste into password text area, you already give that password to the website, and website can detect changes to textarea using input event too.

My bad! I misunderstood how clipboard events work - I thought that whenever I do a Copy (outside of firefox even), then all websites that have event listeners for onCopy would get notified and could capture the contents of the (system)clipboard. Furthermore I thought websites could also read the clipboard by just having timers and repeatedly checking for clipboard contents.

Webpages can't modify or read clipboard outside of clipboard events.

Got it! (I'm assuming clipboard events are local to each webpage, so a Copy from another webpage won't trigger onCopy in a different webpage and thus also a Copy in another program(outside of firefox) won't trigger any onCopy events in any firefox webpages)

Thank you for this!

ghost commented 8 years ago

I want to add a correction to this comment I made: Even with dom.event.clipboardevents.enabled true the Search Google for is still the same. (even if the clipboard copy/pasting now works). It seems to me that the value for Search Google for is taken from the selection (selected text).

ghost commented 8 years ago

I would like to add that in about:config the key clipboard.autocopy is set to true by default but firefox won't fire a copy event for when it does copy data into the second(?) clipboard(which happens when user is done selecting the text - this, outside of ACE) from which I can only paste via middle click mouse button (in Linux). (EDIT: paste event does fire tho)

I tested this by using https://github.com/ajaxorg/ace/blob/55313882c9e6f686489f5e1c1acf67fd3dfb7c7f/experiments/cut_copy.html and adding an e param + a call to log(e) in the fillSelection function

Meanwhile I'm trying to figure out how to make ACE keep some kind of (hidden text area) text selection(even when clipboard events are enabled! instead of just that one char marker) so that maybe firefox can pick that up and use that (selected)text for when displaying the Search Google for menu item. I'm thinking that maybe if I can do that, then I can get Firefox to have that text autocopied via the clipboard.autocopy;true (when clipboard events are disabled) and thus I can just middle click(to paste) after selecting that text in ACE editor. Wouldn't that be great! :D EDIT: this won't work because apparently there's no event triggering when firefox does that copy to second clipboard(used Firebug to watch all events) and text.select() will not make firefox do the copy. The only thing that does make ff do so is selecting normal text, not text within ACE editor though.

un1versal commented 8 years ago

I have this issue (for over a year now) and have reported it to GitHub (recently) who as usual dont have any issues whatsoever and everything works for them normally. :-1:

it was Rachel one of their support personnel which indicated this ticket maybe related but they strongly suggest that thiss is a local issue, despite default installs of OS's and Browsers and settings being untouched.

Both Windows and Linux are affected and so are other Browsers,

I have asked GitHub what technologies they use for this purpose and they said ACE Editor, but alas Im none the wiser, I was wondering what technologies ACE uses to facilitate this but from experience its probably not a good idea to ask such questions.

So bug exists and it goes unfixed and live goes on.

nightwing commented 8 years ago

@un1versal this bug is not about different browsers with settings being untouched, this is about Firefox with dom.event.clipboardevents.enabled turned off. Could you please tell on which browsers do you see this issue, and what is the value of dom.event.clipboardevents.enabled on firefox?

un1versal commented 8 years ago

Well like I said I was pointed to this report by GitHub personnel who insist this is a local issue.

The issue I face is also not just about the search for (something) being mangled, it about not being able to copy and paste anything via browser which I reported to GitHub and who pointed me here perhaps as a mean to investigate locally.. (though I also suffer from this issue)

My Firefox (46.x) is set per default which by definition is settings being untouched.

capture

Internet explorer and Chrome across Linux/Windows all present similar results.

nightwing commented 8 years ago
un1versal commented 8 years ago

I can copy and paste say any raw text from GitHub or from any website or anywhere else from source to any destination without any issues.

Ill blame java for now here, I have set the highest security (if there is such a thing with java) in Java control panel > security tab,

Its interesting in https://ace.c9.io/#nav=about you select a word inside the editor and right click and this issue reported here is present, but select a word above on the website and its no longer mangled.

Example on left 1) select a word; ACE in this example 2) Right click (See search with result is mangled) 3) Results cannot be pasted anywhere.

Example on right 1) Select a word; Ace in this example 2) Right click (See search with result is not mangled) 3) Results can be pasted anywhere inside editors or in any text editors in local machine

capture

Even more interesting at https://ace.c9.io/build/kitchen-sink.html

Example on left 1) move cursor over a word Tab in this example (do not select word) 2) Right click (See search with result is not mangled)

Example on right 1) select a word Tab in this example 2) Right click (See search with result is mangled) 3) Results cannot be pasted anywhere.

capture

so something extra funky is going on with Ace...

Edit Perhaps the developers of Ace can fix this, GitHub's support personnel message is clear, they still cant duplicate any of these issues not in house or via Users they asked to test, I find this hard to believe, but I also have provided enough evidence and test cases you can easily investigate and are fairly clear there's an issue with Ace.

For now my workaround is simple, for content in an editor I want to copy is to view raw contents in browser and copy that and paste that anywhere I like, its an extra step but it works always and flawlessly.

javascript should die in a fire

nightwing commented 8 years ago

@un1versal I couldn't reproduce this issue either, despite of spending long time on it.

You are saying that in the first group of screenshots copying worked in the Example on left, but didn't work in Example on right

Example on left shows text being copied from Ace, and Example on right shows text being copied from outside of Ace. Code from Ace can not affect text outside of editable area, so there must be some other issue here.

for content in an editor I want to copy is to view raw contents in browser and copy that and paste that anywhere I like

when copying doesn't work on github do you see this: image or this: image ?

un1versal commented 8 years ago

You are saying that in the first group of screenshots copying worked in the Example on left, but didn't work in Example on right

its explained in no uncertain details, if you didnt understand my explanation with pics idk how else to say it

when copying doesn't work on github do you see this:

I see this: definitely

this

the other works fully well.

nightwing commented 8 years ago

And about the first question, is there a typo or did copying not work for text outside of editor?

un1versal commented 8 years ago

it works fine outside the editor

yes there was a typo the result 3) was inverted I corrected it now (and confirmed by retest)... sorry.

h8nor commented 7 years ago

FF50 [cfg], FF51. Do not works the Paste-hotkey combination. Next...

clipboardevents.enabled After changing the setting does not work Shift+Insert only on GitHub to change the text or create a new file independently. In comments to issues and https://ace.c9.io/ works.

h8nor commented 7 years ago

The issue can be closed. The problem is no actual.

IceSentry commented 7 years ago

This problem is very much still "actual". I can reproduce every scenario that un1versal showed in his comment. I can't copy anything from anything that uses the ace editor but everything else is fine.

Silex commented 7 years ago

Same problem here, cannot copy text using the browser's right click menu. It's pretty annoying to be forced to use CTRL-C or CTRL-V

IceSentry commented 7 years ago

Did you mean CTRL-X CTRL-V to copy, or do you actually prefer to right click to copy? For me the right click and CTRL-C doesn't work

Silex commented 7 years ago

I mean that CTRL-C/CTRL-X/CTRL-V works. The right click menu does not permit any of "Copy", "Cut" or "Paste", as if nothing was selected.

We are using http://codiad.com (which uses ACE) to teach students learning IT, and right click makes it simpler to explain than remembering the CTRL shortcuts. A toolbar with copy/cut/paste buttons would work too.

IceSentry commented 7 years ago

You might want to open a new issue because this is not the same thing. This is about copy paste not working at all. For right click menu or shortcuts, this might be caused by the same thing, but consider yourself lucky that you can at least use the ctrl shortcuts.

Also, I know this is not the place to argue about that, but who is learning IT in 2017 and doesn't know what ctrl-c/ctrl-v does. It's probably the most well known shortcut that is used pretty much everywhere. I'm not here to judge, but I find it hard to believe that anyone struggle with the concept of using that shortcut.

dhardy commented 6 years ago

Yeah, is this about copy/paste not working at all, needing "clipboard events" enabled or the context menu not working? Maybe it would be worth opening a new issue.

For me paste works fine (from another source) but copy doesn't work at all (context or ctrl+C), and "clipboard events" are enabled.

nightwing commented 6 years ago

Could you try going to https://rawgit.com/nightwing/ace/t1/experiments/cut_copy.html and trying to follow instruction on that page.

I am suspecting either interference from browser extension, or from secondary clipboard, but it may be something entirely different, and the log output of that page should help us to figure what is going on.

dhardy commented 6 years ago
7:paste t3 get:=copied=5
6:...defaultPrevented
5:copy t2 set:
4:copy t2 get:
3:paste t3 get:=copied=1
2:...defaultPrevented
1:copy t1 set:
0:copy t1 get:
nightwing commented 6 years ago

@dhardy thanks! this is very helpful, could you please try going to https://rawgit.com/nightwing/ace/t2/experiments/cut_copy.html and copy text from the ace editor instance into the textarea 3 .

Also in https://github.com/integer32llc/rust-playground/issues/227, you say my clipboard is filled with �. Is it always filled with � after selecting text in ace, or only after trying to copy?

dhardy commented 6 years ago

Result of copying from play.rust-lang.org:

0:input "3\u0001"

The clipboard is set when copying (ctrl+C or context menu). Curiously the mouse buffer is not affected by selecting text in the ACE editor (it still contains content from the previous selection).

Note: my other computer with similar OS & browser can copy text from the ACE editor correctly. If you like I can try narrowing down the differences.

nightwing commented 6 years ago

Could you please try to copy from the ace instance on the https://rawgit.com/nightwing/ace/t2/experiments/cut_copy.html page.

image

In the version of ace on that page, I have added logging and made a change that possibly can fix the clipboard issue.

If you like I can try narrowing down the differences.

That would help very helpful, but may be hard to do.

dhardy commented 6 years ago

Ok (there's an extra paste then ctrl+z, which are the last two lines). The editor always sets 'x' in the clipboard?

13:input "312x"
12:input "312xx"
11:input "312x"
10:input "312"
9:input "31"
nightwing commented 6 years ago

That is rather weird, the clipboard events fire for the first textarea, but do not fire for the textarea inside ace. Do you have any browser extensions installed?

In https://rawgit.com/nightwing/ace/t3/experiments/cut_copy.html i have tried to eliminate all the styling differences between textarea, could you try copy pasting with keyboard from ace and from the first textarea on that page, maybe this time it will work.

dhardy commented 6 years ago
2:input "312x"
1:input "312"
0:input "31"

Contrary to what I said earlier, I see that dom.event.clipboardevents.enabled was disabled. With that enabled, copy+paste works and I get:

24:input "3=copied=1=copied=7=copied=20"
23:setDataError NoModificationAllowedError: Modifications are not allowed for this document
22:paste t3 get:=copied=20
21:...defaultPrevented
20:copy set:ace1
19:copy get:ace1
18:took clipboard path
17:returning true
16:ace1
15:mime is text/plain
14:handleClipboardData: ace1 `ie`
13:data ace1
12:doCopy
11:input "3=copied=1=copied=7"
10:setDataError NoModificationAllowedError: Modifications are not allowed for this document
9:paste t3 get:=copied=7
8:...defaultPrevented
7:copy t2 set:
6:copy t2 get:
5:input "3=copied=1"
4:setDataError NoModificationAllowedError: Modifications are not allowed for this document
3:paste t3 get:=copied=1
2:...defaultPrevented
1:copy t1 set:
0:copy t1 get:
nightwing commented 6 years ago

Did you disable intentionally or was it enabled by some extension? Also do you want to you want to keep them disabled, or are you happy with the solution?

Asking because we may be able to add some warning/fallback for this case, but would like to know how useful that is going to be.

dhardy commented 6 years ago

Oh; I don't remember. It's possible I did it myself but can't remember why I would have. I'm happy enough now thanks.

As you can see from this issue there are a few people who've hit this (+5 on this comment), but not very many, so you'll have to decide that.

HenriVSL commented 6 years ago

This issue is now present on Chrome on OS X. Should I open a new issue or just add to this thread?

nightwing commented 6 years ago

@hene193 a new issue would be better.

EnricoScantamburlo commented 3 years ago

Hello, my company application will embed the ace-editor. I was asked to solve this and I tried to debug the problem. I cannot copy in Firefox, the problem is reproducible here https://ace.c9.io/build/kitchen-sink.html and if you enable the Text Input Debugger you will see that only a part of the text gets copied. The results of my debugging was that the listeners of the textarea ( the doCopy() method) are never called. The Firefox does not stop if I put a breakpoint on the onCopy event. It does not work even if add a listeners of mine or add the onClick attribute.

I think it is the same problem as https://github.com/ajaxorg/ace/issues/3976 no events are fired It could be because the element if not attached to the DOM? https://stackoverflow.com/questions/18303695/dynamically-created-ahref-click-event-not-working-in-firefox-or-safari

Any suggestions?