0

我在括号中写了一个插件,我想从文本框中复制文本并粘贴到当前打开的文档中。

window.document.execCommand("copy");

如果我使用键盘命令 + v 它的工作,我可以粘贴由上述 dom 命令复制的文本。

window.document.execCommand("paste")但是即使我也尝试过,我也无法获得相同的结果CommandManager.execute(Commands.EDIT_PASTE)

请问你能帮帮我吗。

问候阿什。

4

1 回答 1

0

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.

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.

于 2014-05-28T15:11:47.543 回答