检查光标是否在ckeditor对话框中的表格内?

时间:2014-04-15 11:33:03

标签: javascript jquery ckeditor wysiwyg

我正在使用ckeditor,我添加了1个对话框,在按钮单击时我想检查光标是否在ckeditor对话框中的表格内?

这是对话框代码,点击按钮我需要检查上述条件

 CKEDITOR.dialog.add( 'NDFSRSDialog', function( editor ) {

    return {
        title: 'Formula Editor',

        contents: [
            {
                id: 'tab-basic',
                label: 'Basic condition',
                elements: [
                    {
                        type: 'text',
                        id: 'NDFSRS',
                        label: 'FIELD',
                        validate: CKEDITOR.dialog.validate.notEmpty( " field cannot be empty" )
                    },
                    {
                        type: 'button',
                        id: 'title',
                        label: 'CONDITION',
                        validate: CKEDITOR.dialog.validate.notEmpty( " field cannot be empty" ),
                        onclick : function(  )
                                {
                                    alert(0);
                                }
                    }
                ]
            }
        ],
        onOk: function() {
            var dialog = this;


            dialog.getElement('tab-basic', 'NDFSRS' ).hide();

        }
    };
});

2 个答案:

答案 0 :(得分:1)

喜欢这个吗?

if($("#ckeditor").is(":focus")){
  //do stuff here
}

答案 1 :(得分:0)

$( '#save' ).on( 'click', function () {
      var editor = CKEDITOR.instances.ficeditor,
  sel = editor.getSelection(),tbchk;
  tbchk = sel.getStartElement();
  while(tbchk!=null){
   if(tbchk!=null && tbchk.getName()=="table"){
    console.log("inside table");
   }
   tbchk=tbchk.getParent();
  }
    });