I am building a desktop application with electron. As a part of its functionality I want to get text that is currently selected, when a particular event fires. This text can be any where - webpage, pdf, sublime etc.
我正在用电子构建桌面应用程序。作为其功能的一部分,我希望在特定事件触发时获取当前选定的文本。这个文本可以是任何地方 - 网页,pdf,崇高等。
Is there any way I can do this?
有什么方法可以做到这一点吗?
1 个解决方案
#1
-2
For text in the DOM, you can use:
对于DOM中的文本,您可以使用:
selectedText = window.getSelection().toString()
selectedText = window.getSelection()。toString()
#1
-2
For text in the DOM, you can use:
对于DOM中的文本,您可以使用:
selectedText = window.getSelection().toString()
selectedText = window.getSelection()。toString()