簡體   English   中英

如何為CKEditor插件添加自定義功能?

[英]How do I add custom functionality to my CKEditor plugin?

我創建了CKEditor插件,其中包含一些標簽,並且每個標簽上都有一個不同的iframe。 在這些iframe中,表中包含網站上某些內容的標題。 我希望能夠單擊表格行,並使其插入被單擊項的標題。

問題是我不知道如何將這種自定義javascript添加到插件中。 我有plugin.js,它添加​​了用於添加按鈕的init函數,該函數在單擊時執行命令以添加對話框窗口。 然后在myDialog.js中,我將對話框窗口定義為:

CKEDITOR.dialog.add( 'addLinkDialog', function( editor ) {
  return {
    title: 'Links',
    minWidth: 800,
    minHeight: 600,
    contents: [
      {
        id : 'articlesTab',
        label : Drupal.t('Articles'),
        title : Drupal.t('Articles'),
        elements : [
      /* {
            id : 'articlenid',
            type : 'text',
            label : Drupal.t('Article Node ID')
          }, */
          {
            type : 'html',
            html : '<iframe src="/links/articles?link=1" style="width:900px; height:600px;"></iframe>',
          }
        ]
      },
      {
        id : 'menuTab',
        label : Drupal.t('Menu Items'),
        title : Drupal.t('Menu Items'),
        elements : [
          {
            type : 'html',
            html : '<div>MENU TEST</div>',
          }
        ]
      },
      {
        id : 'videosTab',
        label : Drupal.t('Videos'),
        title : Drupal.t('Videos'),
        elements : [
          {
            type : 'html',
            html : '<div>VIDEOS TEST</div>',
          }
        ]
      }
    ],
    onOk: function() {
      var editor = this.getParentEditor();
      // var content = this.getValueOf( 'articlesTab', 'articlenid' );
      // alert(content);
    }
  };
});

我知道當我單擊對話框窗口上的按鈕時,我的onOk可以工作,但是我不確定如何從iframe中獲取信息,以及類似的功能應該放在哪里(在我的plugin.js或myDialog.js中? )。

我最終不得不制作另一個js文件,並將其包含在iframe頁面上,然后在jquery中將parent.document選擇器與.find結合使用,以操縱iframe之外的dom元素。

$(".videoUrlInput", parent.document).find('input.cke_dialog_ui_input_text').val(assetUrl);

暫無
暫無

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

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