Clipboard copy-paste in JavaScript doesn't work in Edge browser? - javascript

I am aware of the fact that Clipboard API is currently not supported by edge browser. I am using document.execCommand() to do copy & paste. The copy functionality works fine. But the paste doesn't work. I am using a custom context menu to achieve copy and paste. Previouly I made use of Clipboard API for the functions, it was working flawlessly until Edge came up. I heard Clipboard API will be added in next Edge release. I even checked Zero clipboard from GitHub. But didn't get an appropriate way to implement "Paste" functionality. I just want to know is there any alternate way to achieve the same or by using ZeroClipboard.

Related

iOS copy code in clipboard not working on safari and iphone

Last couple of hours, i was trying to implement clipboard copy on iOS using different ways but no luck nothing is working on cross platform. I have tried different method using
zeorclipboard
clipboard and
jsfiddle
As the snap showing a code and a button below that, this is a webpage on safari browser on IPHONE and i just want to copy that code into clipboard when i press the copy code button and use that code on my APP page for verification but it is not working as i desired. With the fiddle code, when i click the button it focus on the code text-box but not select or copy that.
N.B: it is working on Firefox and chrome browser but i need it on iPhone safari browser except using flash. please help me out, i am badly need it

Why can't we right-click paste into TinyMCE with paste plugin in Firefox?

It seems to be impossible to copy text and then paste it into a TinyMCE editor using right-click paste with Firefox if you have the "paste" plugin. Why is this?
I'm using:
Firefox 33.1.1 (although users have complained of the issue with FF 29)
TinyMCE 4.1.1 with the "paste" plugin
I can right-click paste into these without error:
an element with the contenteditable="true" attribute (same method as TinyMCE), tested on http://html5demos.com/contenteditable
a normal textarea
TinyMCE 4.1.1 without the "paste" plugin
Users have discussed on the TinyMCE forum as far back as 2007, and mention an alert that says "Copy/Cut/Paste is not available in Mozilla and Firefox" which I do not receive with FF 33. No one mentions why this problem occurs, and the TinyMCE admins claim "this is not a bug". I'm interested in knowing what change was made to either Firefox or TinyMCE that causes this, and why (security?).
This question -- tinymce mouse paste not working -- has an answer of how to fix the issue: remove the "contextarea" plugin or any plugin that is based on it. But I'm interesting in knowing why it happens in the first place.
A co-worker got me on the right track and I found these two links:
https://developer.mozilla.org/en-US/Firefox/Releases/29/Site_Compatibility#Security
The removal of allowclipboard policy support broke the copy/paste buttons on some rich text editors like CKEditor. The standard Clipboard API's click-to-copy support will be implemented in the near future. The general keyboard shortcuts, Ctrl+C and Ctrl+V, should always work.
http://kb.mozillazine.org/Granting_JavaScript_access_to_the_clipboard
By default, JavaScript is not allowed to read or set your clipboard data for security and privacy reasons. This is because websites scripts can erase and replace what you currently have in your clipboard (data loss issue) and they can read whatever you have in your clipboard (security and privacy issue); as such, you should grant access with caution.
Maybe someone with TinyMCE expertise can provide more information on how it accesses the clipboard.
Good follow-up questions might be: Why don't the other browsers do this? Why is ctrl+v safer?

Maintain undo functionality with createRange()

I'm working on a Markdown text editor using a contenteditable and Rangy to easily add links and images. The problem is that rangy.createRange();, an important function in the Rangy library, cancels the ability to undo an action (text added in the contenteditable in my case).
I have browsed the Web to find a solution and I have found UndoManager, but I cannot find information about how to use it and if it has been added in Chrome (I'm working on a Chrome Packaged App so I don't care if Safari does not support it).
If somebody knows something about this piece of HTML5 it would be amazing.
Thanks in advance.
According to this link , none of the current browsers support the UndoManager spec. You can test that in your browser by trying to access document.undoManager which undefined in Chrome

Copy javascript made images to clipboard

Is there today with HTML5 a way to copy to clipboard, without browser plugins (and so without Flash nor java) nor short-term hacks, an image built in a canvas ?
The copy to clipboard would be initiated by javascript but having user confirmation or a dialog isn't a problem.
Solutions which don't work in Windows and Linux, or which don't work at least in Chrome and Firefox are without interest to me.
Ideally I would prefer a solution that doesn't impose to display the image (which is built in memory with document.createElement('canvas')) but that's not an absolute requirement.
As far as I'm aware, the Clipboard API is the only specification in this area. I've never used it and don't know how widely it's supported, but I suspect not widely. According to this quick and dirty test, the current versions of Chrome and Firefox fire the copy event. I believe the user has to initiate the copy (e.g., you say "press Ctrl+C to copy").
IE makes window.clipboardData available, but as far as I know you're limited to text and URLs.
So sadly, I think this is one of those answers that's basically: No, not yet.

Button to paste from clipboard for all browsers

Is it possible create a button that can be used to paste some clipboard text into a textbox using javascript?
In my project I'm using ZeroClipboard to copy any text that I want, but now I need to paste that information using a single button in other page without any copy page connection.
At the internet I found ways to do that, but it just works on IE and I need a cross browser solution (minimun IE, chrome and FF).
Can anyone help me?
Other info:
I'm using asp.net mvc 3
For security reasons, Javascript don't have access to clipboard.
ZeroClipboard uses Flash in order to copy the text to clipboard BUT for security reasons too, Flash can only write to clipboard, not read.
The only way to do it is using a Java applet.
Here is article/Tutorial explaining how to do it : http://www.dynamic-tools.net/toolbox/copyToClipboard/
But the best pratice is to have a textarea with the data to copy already selected. Because some browser will not let you change the value of the clipboard data.

Categories