是否可以在Google文档的Google Apps脚本中添加“复制到剪贴板”功能?

时间:2019-02-23 18:32:53

标签: google-apps-script copy clipboard

我有一个google doc,其中有以下脚本:

    var this_document = DocumentApp.openById('')
function onOpen() {
  var ui = DocumentApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('SCRIPT')
      .addItem('Copy (En)', 'copy_in_english')
      .addSeparator()
      .addItem('Copy (Fr)', 'copy_in_french')
      .addSeparator()
      .addItem('Copy (Sp)', 'copy_in_spanish')
      .addSeparator()
      .addToUi();
}
function copy_in_english(){
  var cursor = this_document.getCursor()
}
function copy_in_french(){
}
function copy_in_spanish(){
}

我将从功能copy_in_english开始,我想在按下“复制(En)”菜单项时执行该功能。从cursor的当前位置开始,我要将其下面的所有文本复制到剪贴板。我在JavaScript中看到了document.execCommand(copy)函数,该函数可以做到这一点,但在这里似乎不起作用。我还能做些什么吗?

0 个答案:

没有答案