2017-08-01 68 views
1

我试图添加证明插件,以便能够对齐文本的右,左或中心。但在按照文档(http://apostrophecms.org/docs/tutorials/howtos/ckeditor.html)中的说明操作后,我不知道该插件是否应该位于特定文件夹中(我的位置是public/modules /撇号/ areas/js/ckeditorPlugins/justify /),因为它在站点中消失被加载,但如果我将其包含在其他文件夹(如public/plugins/justify)中仍然不起作用。Ckeditor插件配置不工作

这是我的代码,以防万一:(位于lib/modules目录/撇号区/公/ JS/user.js的)

apos.define('apostrophe-areas', { 
    construct: function(self, options) { 
    // Use the super pattern - don't forget to call the original method 
    var superEnableCkeditor = self.enableCkeditor; 
    self.enableCkeditor = function() { 
     superEnableCkeditor(); 
     // Now do as we please 
     CKEDITOR.plugins.addExternal('justify', '/modules/apostrophe-areas/js/ckeditorPlugins/justify/', 'plugin.js'); 
    }; 
    } 
}); 

而且,这将是很好知道插件如何应在可编辑小部件的工具栏设置中调用。 谢谢!

回答

1

事实证明,仅仅拨打apostophe-areas内的CKEDITOR.plugins.addExternal是不够的。您还需要覆盖apostrophe-rich-text-widgets-editor模块的self.beforeCkeditorInline,并明确地调用self.config.extraPlugins = 'your_plugin_name';

这里是我结束了:

lib/modules/apostrophe-areas/public/js/user.js

apos.define('apostrophe-areas', { 
    construct: function(self, options) { 
    // Use the super pattern - don't forget to call the original method 
    var superEnableCkeditor = self.enableCkeditor; 
    self.enableCkeditor = function() { 
     superEnableCkeditor(); 
     // Now do as we please 
     CKEDITOR.plugins.addExternal('justify', '/modules/my-apostrophe-areas/js/ckeditorPlugins/justify/', 'plugin.js'); 
    }; 
    } 
}); 

然后在in lib/modules/apostrophe-rich-text-widgets/public/js/editor.js

apos.define('apostrophe-rich-text-widgets-editor', { 
    construct: function(self, options) { 
    self.beforeCkeditorInline = function() { 
     self.config.extraPlugins = 'justify'; 
    }; 
    } 
}); 

出于某种原因做CKEDITOR.config.extraPlugins = 'justify'apostrophe-areas不起作用,可能是由于CKEDITOR初始化的方式;

还有一件事:这个特殊的插件(证明,这是)似乎并不遵循按钮定义逻辑。它将按钮图标定义为图像,而在撇号CMS 2.3中使用的CKEditor 4.6使用font-awesome来显示图标。这意味着与justify模块一起提供的图标将不会显示,您将不得不为每个按钮分别编写自己的CSS。

还有另一个问题,你可能会遇到当你最终启用justify按钮。内置的html消毒工具将剥离样式证明添加到对齐内容的样式。

撇号CMS似乎在使用sanitize-html来消毒输入,所以更改CKEditor设置不会产生任何影响。要解决此问题,请将以下内容添加到您的app.js中:

'apostrophe-rich-text-widgets': { 
    // The standard list copied from the module, plus sup and sub 
    sanitizeHtml: { 
    allowedAttributes: { 
     a: ['href', 'name', 'target'], 
     img: ['src'], 
     '*': ['style'] //this will make sure the style attribute is not stripped off 
    } 
    } 
} 
2

您需要的网址是:

/modules/my-apostrophe-areas/js/ckeditorPlugins/justify/

my-前缀自动预先考虑,这样无论是原apostrophe-areas模块和它的项目级扩展的public文件夹可以有不同的URL。否则,例如,将无法访问他们的user.js

我会将这个注释添加到问题的HOWTO中,该问题目前通过在构成的URL中存根来交叉处理问题。

至于应该如何调用插件,请使用该插件导出的工具栏控件名称 - 该部分是ckeditor问题,而不是真正的撇号问题。但看看该插件的源代码,他们可能是JustifyLeft,JustifyCenter,JustifyRightJustifyBlock

0

谢谢你们的帮助。在遵循以下两种方法之后:找到my-apostrophe-areas文件夹中的插件以及在apostrophe-rich-text小部件上编辑editor.jssanitize.html文件已经使用该配置)后,我使插件工作。但是,我仍然遇到与图标有关的问题。

我固定,添加对应于align-justify, align-right, align-leftalign-centerpublic/modules/apostrophe-areas/js/vendor/ckeditor/skins/apostrophe/editor.less

末端的字体真棒图标