谷歌选取器无法在边栏加载项中工作



我正在从加载项边栏使用Google Picker。我几乎使用了picker教程中提供的所有代码,效果非常好。

但是,当"选取器"模式对话框显示时,它仅限于"附加侧栏"的尺寸。使其无法使用。我希望它仅限于Google文档窗口的大小(我的侧边栏附在该窗口上)。这是主要代码:

function createPicker(token) { 
    if (pickerApiLoaded && token) {
      var picker = new google.picker.PickerBuilder()
          // Instruct Picker to display only spreadsheets in Drive. For other
          // views, see https://developers.google.com/picker/docs/#otherviews
          .addView(google.picker.ViewId.SPREADSHEETS)
          // Hide the navigation panel so that Picker fills more of the dialog.
          .enableFeature(google.picker.Feature.NAV_HIDDEN)
          // Hide the title bar since an Apps Script dialog already has a title.
          .hideTitleBar()
          .setOAuthToken(token)
          .setDeveloperKey(DEVELOPER_KEY)
          .setCallback(pickerCallback)
          // Instruct Picker to fill the dialog, minus 2 pixels for the border.
          .setSize(DIALOG_DIMENSIONS.width - 2,
              DIALOG_DIMENSIONS.height - 2)
           .build();
      //picker.setOrigin(window.location.protocol + '//' + window.location.host);     

      picker.setVisible(true);
    } else {
      showError('Unable to load the file picker.');
    }
  }

我在想下面的setOrgin()可能会有所帮助。但它实际上阻止了拾取器的工作。

setOrigin(window.location.protocol + '//' + window.location.host)  

您需要将原点设置为docs.google.com.

            .setOrigin('https://docs.google.com')

最新更新