添加图像的自定义插件后无法插入img标记 [英] Can't insert img tag after adding custom plugin for image

查看:127
本文介绍了添加图像的自定义插件后无法插入img标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了自己的自定义插件,用于在CKEDITOR中插入图片。我禁用工具栏中的图像按钮。我使用editor.insertHtml()函数从我的自定义插件插入图像。当我从工具集中删除标准图像按钮时,它禁止在CKEDITOR框中插入图像标记。所有其他html标记都被接受,但是< img /> 标记。



这是我的配置(在config.toolbar中没有'Image'):

 code> CKEDITOR.editorConfig = function(config)
{
CKEDITOR.plugins.addExternal('insert_blank','http:// localhost:3000 / assets / ckeditor / plugins / insert_blank /' ,'plugin.js');
CKEDITOR.plugins.addExternal('qimage','http:// localhost:3000 / assets / ckeditor / plugins / qimage /','plugin.js');
config.extraPlugins ='insert_blank,qimage';

config.toolbar =
[

{name:'basicstyles',items:['Bold',' - ','Italic']},

{name:'insert',items:['insert_blank.btn',' - ','qimage.btn'
]},

$ b b

];
config.keystrokes = [

[CKEDITOR.CTRL + 75,'InsertBlank'],
[CKEDITOR.CTRL + 85,'qimage'],
] ;

config.height = 300;
config.width = 350;
config.removePlugins ='elementpath,resize';

};

是否有启用图像标记插入的方法?



UPDATE :将以下命令添加到配置文件中:

  config.allowedContent ='bi img [!src,alt,width,height]'; 


解决方案

您阅读了如何集成插件与允许的过滤器内容?您需要定义您的插件添加按钮/命令,允许 img 标记及其属性。你还可以定义哪些标签及其属性是肯定需要启用此按钮/命令,当有人将设置 config.allowedContent 时,将激活/停用它。 p>

I have written my own custom plugin for inserting images in CKEDITOR. I disable the image button in toolbar . I use the editor.insertHtml() function to insert the image from my custom plugin . When I remove the standard image button from the toolset it disables insertion of image tag in the CKEDITOR box . All other html tags are accepted but for the <img/> tag .

This is my config(without the 'Image' in config.toolbar) :

CKEDITOR.editorConfig = function( config )
{
CKEDITOR.plugins.addExternal('insert_blank','http://localhost:3000/assets/ckeditor/plugins/insert_blank/', 'plugin.js');
CKEDITOR.plugins.addExternal('qimage','http://localhost:3000/assets/ckeditor/plugins/qimage/', 'plugin.js');
 config.extraPlugins = 'insert_blank,qimage' ; 

  config.toolbar =
    [

        { name: 'basicstyles', items : [ 'Bold','-','Italic' ] },

        { name: 'insert', items : [ 'insert_blank.btn','-','qimage.btn'
                 ] },




    ];
   config.keystrokes = [

    [ CKEDITOR.CTRL + 75, 'InsertBlank' ],    
    [ CKEDITOR.CTRL + 85, 'qimage' ], 
];  

        config.height = 300 ; 
                config.width = 350 ; 
                config.removePlugins =  'elementspath,resize' ;

};

Is there a way to enable image tag insert ?

UPDATE : Worked by adding the following command to the config file :

config.allowedContent = 'b i img[!src,alt,width,height]' ; 

解决方案

Have you read how to integrate plugin with Allowed Filter Content? You need to define that your plugin adds button/command which allow img tag and its attributes. You can also define which tag and its attributes are definitely required for this button/command to be enabled, what will activate/deactivate it when someone will set config.allowedContent.

这篇关于添加图像的自定义插件后无法插入img标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆