1

TinyMCE の最新バージョンを使用しており、ユーザーが [画像の挿入] をクリックするたびに Google ドライブ ピッカーを統合したいと考えています。

TinyMCE のドキュメントから、file_browser_callbackパラメーターを使用する必要があることがわかりましたが、いくつかの問題に悩まされています。まず、Google Picker をアタッチすることはできましたが、Insert Image ポップアップが一番上に表示されたままになり、ファイルを選択する方法がありません。この問題を解決したとしても、Google ピッカーのコールバック関数からテキスト ボックスの値を設定するにはどうすればよいですか? 以下に私のコードを示します。Google ピッカーのコードは非常に標準的なので、貼り付けません。

var picker;

tinymce.init({
    //other init parameters...
    file_browser_callback: function(field_name, url, type, win) {
        picker.setVisible(true);
        win.document.getElementById(field_name).value = 'my browser value';
    }
});

function createPicker() {
    // Here I build the Picker...
    // var picker = ...
}

function pickerCallback(data) {
    //TODO: Find a way to set textbox value with the URL of the Image selected from Drive
}

ここに画像の説明を入力

4

1 に答える 1

1

呼び出すときにモーダルを非表示にできると思いますcreatePicker()

function createPicker() {
  document.getElementById('modal_id').style.display = 'none';
  // your picker code here!
}

コールバックを取得したら、それを表示します。つまりpickerCallback(data)

function pickerCallback(data) {
  document.getElementById('modal_id').style.display = 'block';
  var url = 'nothing';
  if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED) {
    var doc = data[google.picker.Response.DOCUMENTS][0];
    url = doc[google.picker.Document.URL];
  }
  // set the input text value with the URL:
  document.getElementById('source_input_id').value = url;
}

modal_idモーダルの div id とsource_input_idソース入力フィールドの idに変更します。

于 2014-10-09T19:29:01.783 に答える