簡體   English   中英

CKEditor-自定義圖像瀏覽器

[英]CKEditor - Custom image browser

我目前正在使用PHP和jQuery開發圖像瀏覽器。 我設法創建了一個自定義按鈕插件,可以在新窗口(而不是對話框)中打開圖像瀏覽器:

CKEDITOR.plugins.add('imgbrowser',
{
    init: function(editor)
    {
        var pluginName = 'imgbrowser';
        editor.ui.addButton('Imgbrowser',
            {
                label: 'Image browser',
                command: pluginName,
                click: function (editor) { window.open('/publish/browser/index.php','Image Browser','width=900,height=600'); }
            });
    }
});

這里有人知道如何啟用回調功能以及如何使用回調功能,以便可以將所選圖片添加到編輯器中嗎?

好。 答案是:

在父窗口中,我具有以下功能:

function InsertHTML(file_path)
        {
            // Get the editor instance that we want to interact with.
            var oEditor = CKEDITOR.instances.page_content;
            var value = file_path;

            // Check the active editing mode.
            if ( oEditor.mode == 'wysiwyg' )
            {
                // Insert the desired HTML.
                oEditor.insertHtml( '<img src="' + value + '" />' );
            }
            else
                alert( 'You must be on WYSIWYG mode!' );
        }

page_content是我的文本區域的ID。

在彈出窗口中,我具有以下功能:

function sendToParent(file_path) {
    window.opener.InsertHTML(file_path);
}


echo "<input type='button' value='Insert image' onclick='sendToParent(\"".$img_element."\")' />"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM