0

外部ポップアップ ウィンドウを呼び出すプラグインを作成しました。

exec : function( editor )
{
    window.open('index.php?mod=xxxx','Name popup','width=900,height=600');
}

その部分はうまく機能します。データを CKeditor に送り返すには? jqueryを使用してCKeditorのオープナーインスタンスの現在の位置にHTMLを追加したいと思います。

私はこれを試しましたが、うまくいきません:

$('a#clickMe').click(function()
{ 
     window.opener.CKeditor.insertHtml('Bla bla bla');
});
4

3 に答える 3

2

それを行う方法を見つけました:

exec : function( editor )
{
    window.open('index.php?mod=xxxx&CKEditor='+CKEDITOR.currentInstance.name,'Name popup','width=900,height=600');
}

次に、渡された $_GET['CKEditor'] を要素の 'rel' 属性に挿入します。

HTML:

<a id="clickMe" rel="<?=$_GET['CKEditor']?>">click me</a>

jQuery:

 $('a#clickMe').click(function(){
        var editor = $(this).attr("rel");
        window.opener.CKEDITOR.instances[editor].insertHtml('bla bla');
 });
于 2012-06-27T08:06:11.250 に答える
0

試す:

window.opener.CKEDITOR.instances.nameOfYourInstance.insertHtml( 'bla bla' );

ただし、最初にエディターに焦点を合わせなくても、常に機能するかどうかはわかりません。むしろCKEditorのダイアログAPIを使用する必要があります。

于 2012-06-26T18:27:19.870 に答える
0

GET 変数なしでそれを行う方法 - グローバル変数を JavaScript に追加します (例: config.js ファイル内)。

var myEditorInstance;

次に、プラグインで

exec : function( editor )
{
    myEditorInstance=editor;
    window.open('index.php?mod=xxxx','Name popup','width=900,height=600');
}

次に、ポップアップウィンドウからこれにアクセスできます

window.opener.myEditorInstance.insertHtml('Bla bla bla');

また、ページに複数のエディターがある場合、ポップアップはウィンドウを開いたインスタンスに関連することも意味します。

于 2013-09-05T16:10:03.120 に答える