【问题标题】:Removing a fMath image properties dialog in ckeditor在 ckeditor 中删除 fMath 图像属性对话框
【发布时间】:2013-11-19 19:16:21
【问题描述】:

我对此有点坚持,如果你能提供帮助,那就太好了。

我正在使用 Drupal 7 和 Ckeditor 4.3。我正在开发一个集成了 fmath 方程编辑器的网站。

我已禁用图片按钮,因为我不希望最终用户能够上传自己的图片。另一方面,用户可以使用 fMath 插入方程。 fMath 处理方程插入的方式是插入一个 img 标签。

当用户双击此图像或右键单击图像时,他们会访问图像属性对话框,在那里他们可以更改图像的源 URL 和其他一些东西。在 url 输入文本上,他们可以更改图像的来源,以便他们可以在页面上插入自己的图像,这是我不想要的。

到目前为止,他们一直在使用两种不同的不成功方法来解决这个问题:

  1. 从对话框中删除元素,作为对话框上的 URL 输入文本(以及替代文本)。
  2. 试图禁用对话框本身。

我想使用自定义插件来完成所需的行为,因为我在 Drupal 中有不同的 CKeditor 配置文件。

我没有成功。你知道我该如何处理这种不良行为吗?

【问题讨论】:

    标签: drupal-7 ckeditor


    【解决方案1】:

    好的,我最终在 plugin.js 文件中得到了类似的内容:

    CKEDITOR.plugins.add( 'custom_doubleclick',
    {
    init: function( editor )
    {
    
      //  First part, dialogDefinition allow us to remove the
      // "Link" and "Advanced" tabs on the dialog  
      CKEDITOR.on( 'dialogDefinition', function( ev ) {
    
        var dialogName = ev.data.name;
        var dialogDefinition = ev.data.definition;
        if ( dialogName == 'image' ) {
    
          dialogDefinition.removeContents( 'Link' );
          dialogDefinition.removeContents( 'advanced' );
    
        }
      });
    
          // Second part, it disables the textUrl and txtAlt input text boxes
    
      editor.on( 'dialogShow', function( ev ) {
    
        var dialog = ev.data;
        var dialogName = dialog.getName();
    
        if ( dialogName == 'image' ) {
          //var dialog = CKEDITOR.dialog.getCurrent();
          // Get a reference to the Link Info tab.
          console.log(dialog)
          dialog.getContentElement( 'info','txtUrl' ).disable();
          dialog.getContentElement( 'info','txtAlt' ).disable();
    
        }
      });
    }
    });
    

    如您所见,我并没有禁用对话框本身,而是禁用了无用的元素。我希望这可以对其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多