无法执行命令window.document.execCommand("paste"),放在方括号中 [英] not able to execute command window.document.execCommand("paste") in brackets
问题描述
我在方括号中编写了一个插件,我想在其中从文本框中复制文本并粘贴到当前打开的文档中.
I wrote a plugin in brackets in which I want to copy text from the text box and paste in the current opened document .
window.document.execCommand("copy");
如果我使用键盘命令+ v可以正常工作,则可以粘贴由上述dom命令复制的文本.
if I use keyboard command+v its working, I am able to paste the text which is copied by the above dom command.
但是即使我也尝试过CommandManager.execute(Commands.EDIT_PASTE)
,我也无法通过window.document.execCommand("paste")
获得相同的结果.
But the same result I'm not able to get by window.document.execCommand("paste")
, even though I tried this CommandManager.execute(Commands.EDIT_PASTE)
too.
你能帮我吗?
问候 灰烬.
推荐答案
这些命令将不起作用,因为括号在Chromium Web视图中运行,并且Chromium不允许正常内容以编程方式访问剪贴板(作为安全措施).在Brackets中,安全性的原理并不是真正相关的,但是有人需要修补方括号-shell以禁用该限制,并且该工作尚未发生.
Those commands won't work because Brackets runs in a Chromium webview, and Chromium doesn't permit normal content to access the clipboard programmatically - as a security measure. In Brackets the security rationale isn't really relevant, but someone would need to patch brackets-shell to disable the restriction, and that work hasn't happened yet.
但是有一种解决方法:括号扩展有访问NodeJS ,因此您可以使用复制粘贴之类的Node包.访问剪贴板.查看扩展源右键单击扩展或
But there's a workaround: Brackets extensions have access to NodeJS, so you can use a Node package like copy-paste to access the clipboard. Check out the source of the extensions Right Click Extended or File Info to Clipboard for examples.
这篇关于无法执行命令window.document.execCommand("paste"),放在方括号中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!