2012-12-23 10 views
5

Blueimp FileUpload(https://github.com/blueimp/jQuery-File-Upload) をエディタCkEditor(http://ckeditor.com/)と統合することはできますか?ckeditorでの統合ブルーインプファイルアップロード

ヒント

ありがとうございました!で

<td> 
     <div class="btn scegli" id="chooseThis" > 
      <span class="url" style="display: none">"{%=file.url%}"</span> 
      <span>Choose</span> 
     </div> 
    </td> 

:私は最初</tr>コマンドを次の行を追加し、テーブルを編集した

blueimpファイルアップロードのファイルのindex.phpで:終わり

+0

あなたは試してみました何これまでのところ?現在のコードを表示したり、他の人がコードを書くことを期待していますか? – AlfonsoML

答えて

8

は、私が自分で解決策を見つけましたjqueryのインクルージョン後にこのファイルの最後に、私はCKEditorバージョンで使用する単純なプラグインを開発しました

<script type="text/javascript"> 

    $(".chooseThis").live("click", function (e) { 
    parent.triggerUploadImages($(this).children('.url').html()); 
    }); 

</script> 

CKEDITOR.plugins.add('fileUpload', 
{ 
    init: function (editor) { 
     editor.addCommand('OpenDialog',new CKEDITOR.dialogCommand('OpenDialog')); 
     editor.ui.addButton('FileUpload', 
      { 
       label: 'Upload images', 
       command: 'OpenDialog', 
       icon: CKEDITOR.plugins.getPath('fileUpload') + 'icon.gif' 
      }); 
     editor.contextMenu.addListener(function(element){ 
      return { 'My Dialog' : CKEDITOR.TRISTATE_OFF }; 
     }); 
     CKEDITOR.dialog.add('OpenDialog', function(api){ 
      var dialogDefinition = 
      { 
       title : 'Gestisci immagini', 
       minWidth : 700, 
       minHeight : 500, 
       contents : [ 
         { 
          expand : true, 
          padding : 0, 
          elements : 
          [ 
           { 

            type : 'html', 
            html : ' <iframe src="../../includes/fileUpload/index.php" style="width:100%;height:490px" />' 
           } 
          ] 
         } 
       ], 
       buttons : [] 
      }; 
      return dialogDefinition; 
     }); 

    } 
}); 

ボタンをツールバーに追加するには、config.jsも変更する必要があります。ボタンの名前は:「するFileUpload」

は、その後、私はCKEditorバージョンを作成する機能があります。

var editor, html = ''; 
    function createEditor() { 

       if (editor) return; 

       var config = {}; 
       editor = CKEDITOR.replace("editor", 
        { 
         extraPlugins : 'fileUpload', 
        }); 
    } 

をし、これが引き金を管理する機能である:

  function triggerUploadImages(url){ 
       if(editor){ 
        CKEDITOR.dialog.getCurrent().hide(); 
        editor.insertHtml('<img src='+url+' />'); 
       } 
      } 
+2

あなたのソリューションを投稿してくれてありがとう!これは私が開発しようとしているプラ​​グインで私を助けるかもしれない – Lorof

+1

あなたは大歓迎です! ;) – Danilo