我正在尝试开发一个CKEDITOR插件来添加填充/边距到图像,
在查看文档后,我编写了以下代码:
const style = new CKEDITOR.style( { element: 'img', attributes: { 'style': 'margin:100px' } } );
editor.applyStyle(style);但它不起作用,所以我试着:
const style = new CKEDITOR.style( { element: 'image', attributes: { 'style': 'margin:100px' } } );
editor.applyStyle(style);仍然不起作用,我在Drupal9上读到图像是一个小部件,而不是一个元素,所以我尝试了:
const style = new CKEDITOR.style( { type:'widget', widget: 'image' , attributes: { 'style': 'margin:100px' } } );
editor.applyStyle(style);还是不起作用,所以我试了试:
const style = new CKEDITOR.style( { element: 'p', attributes: { 'style': 'margin:100px' } } );
editor.applyStyle(style);它确实起作用了,但它被添加到了包装img的'p‘中,所以我知道代码是正确的,但我似乎不能将它添加到img中。
发布于 2021-11-09 08:13:20
如果你想要一个固定的填充/边距,定制的ckeditor样式配置可能是你的解决方案。https://www.axelerant.com/blog/drupal-8-custom-styles-in-ckeditor
https://stackoverflow.com/questions/69797131
复制相似问题