Score:0

alter image style attribute

cn flag

i am trying to develop a CKEDITOR plugin to add padding/margin to images,

after looking in the documentations i have written this code :

const style = new CKEDITOR.style( { element: 'img', attributes: { 'style': 'margin:100px' } } );
editor.applyStyle(style);

but it didn't work so i tryied :

const style = new CKEDITOR.style( { element: 'image', attributes: { 'style': 'margin:100px' } } );
editor.applyStyle(style);

and still did not work, i read that on drupal 9 the image is a widget and not an element so i tryied:

const style = new CKEDITOR.style( { type:'widget', widget: 'image' , attributes: { 'style': 'margin:100px' } } );
editor.applyStyle(style);

and still did not work, so i tryied :

const style = new CKEDITOR.style( { element: 'p', attributes: { 'style': 'margin:100px' } } );
editor.applyStyle(style);

and it did work but it was added to the 'p' wraping the img so i know that the code is currect but i can't seem to add it to the img...

Score:1
cn flag

Trying to create a CKEditor plugin is not as easy as it might look. I'd suggest to check the amazing module CKEditor Templates (in a nutshell, you will need to extend the CKEditorPluginBase class).

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.