用CKEDITOR 做自助上傳的解決方案2

來源:互聯網
上載者:User

標籤:

1,在plugins下建立檔案夾 multiimg

2,建立檔案plugin.js

(function() {    CKEDITOR.plugins.add("multiimg", {        requires: ["dialog"],        init: function(a) {            a.addCommand("multiimg", new CKEDITOR.dialogCommand("multiimg"));            a.ui.addButton("multiimg", {                label: "批量上傳圖片",//調用dialog時顯示的名稱                command: "multiimg",                icon: this.path + "g.ico"//在toolbar中的表徵圖            });            CKEDITOR.dialog.add("multiimg", this.path + "dialogs/multiimg.js")        }    })})();

  3,建立一個g.ico  放在multiimg目錄下

4,建立dialogs檔案夾,建立檔案multiimg

(function() {    CKEDITOR.dialog.add("multiimg",        function(a) {            return {                title: "批量上傳圖片",                minWidth: "660px",                minHeight:"400px",                contents: [{                    id: "tab1",                    label: "",                    title: "",                    expand: true,                    width: "420px",                    height: "300px",                    padding: 0,                    elements: [{                        type: "html",                        style: "width:660px;height:400px",                        html: ‘<iframe id="uploadFrame" src="/image/image.html?v=‘ +new Date().getSeconds() + ‘" frameborder="0"></iframe>‘                    }]                }],                onOk: function() {                    // 拿到對象,這個在iframe裡定義                    var num = window.fff;                    //點擊確定按鈕後的操作                    a.insertHtml("編輯器追加內容"+num);                },                onShow: function () {                    document.getElementById("uploadFrame").setAttribute("src","/image/image.html?v=‘ +new Date().getSeconds() + ‘");                }            }        })})();

  

5,做那個上傳頁面,

 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 2         "http://www.w3.org/TR/html4/loose.dtd"> 3 <html> 4 <head> 5     <title></title> 6  7     <script type="text/javascript" src="/res/js/jquery-1.12.1.js"></script> 8  9 10 </head>11 <body>12 13 <img id="imgs">fuck</img>14 15 16 <script type="text/javascript">17     parent.fff =("fsdafsdafsdafsda");
    //關鍵,可以在...被調用
18 19 var a =$(window.parent.document).find("#title").val("================");20 21 </script>22 </body>23 24 </html>

 config.extraPlugins += ‘multiimg‘;

 

自訂按鈕

config.toolbar = [
[‘Source‘, ‘Cut‘, ‘Copy‘, ‘Paste‘, ‘PasteText‘, ‘PasteFromWord‘, ‘-‘, ‘Undo‘, ‘Redo‘, ‘Bold‘, ‘Italic‘,
"Format","FontSize","TextColor" ,"Link" ,"Unlink","CodeSnippet"]
]

 

用CKEDITOR 做自助上傳的解決方案2

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.