Jump to content
Guy Incognito

Strange CKeditor Problem

Recommended Posts

Hi all,

Having a strange problem with my CKeditor custom styles.

Trying to add standard bootstrap classes to the image alignment options. But for some reason if I add multiple classes to the centred image option it disappears from the editor drop down. But with only one class it works.

So this works:

 { name: 'Left Aligned Photo', element: 'img', attributes: { 'class': 'float-md-left img-fluid' } },
 { name: 'Right Aligned Photo', element: 'img', attributes: { 'class': 'float-md-right img-fluid' } },
 { name: 'Centered Photo', element: 'img', attributes: { 'class': 'img-fluid' } },

But this doesn't:

 { name: 'Left Aligned Photo', element: 'img', attributes: { 'class': 'float-md-left img-fluid' } },
 { name: 'Right Aligned Photo', element: 'img', attributes: { 'class': 'float-md-right img-fluid' } },
 { name: 'Centered Photo', element: 'img', attributes: { 'class': 'w-100 img-fluid' } }, 

Note the slight difference to the last line.

I've tried escaping the hyphens in case it was that but doesn't help.

Any ideas.... #puzzled!

Share this post


Link to post
Share on other sites
{ name: 'Left Aligned Photo', element: 'img', attributes: { 'class': 'float-md-left img-fluid' } },
 { name: 'Right Aligned Photo', element: 'img', attributes: { 'class': 'float-md-right img-fluid' } },
 { name: 'Centered Photo', element: 'img', attributes: { 'class': 'd-block img-fluid' } }, 

This alternative set of Bootstrap classes works fine - can't figure out what the common denominator is of the ones that don't work. It also doesn't seem to like more than 2 classes, not sure if there's a limit to the length of the attribute strings?

Share this post


Link to post
Share on other sites

Try adding the classes in alphabetical order.

{ name: 'Left Aligned Photo', element: 'img', attributes: { 'class': 'float-md-left img-fluid' } },
{ name: 'Right Aligned Photo', element: 'img', attributes: { 'class': 'float-md-right img-fluid' } },
{ name: 'Centered Photo', element: 'img', attributes: { 'class': 'img-fluid w-100' } }, 

 

  • Thanks 1

Share this post


Link to post
Share on other sites
50 minutes ago, wbmnfktr said:

Try adding the classes in alphabetical order.


{ name: 'Left Aligned Photo', element: 'img', attributes: { 'class': 'float-md-left img-fluid' } },
{ name: 'Right Aligned Photo', element: 'img', attributes: { 'class': 'float-md-right img-fluid' } },
{ name: 'Centered Photo', element: 'img', attributes: { 'class': 'img-fluid w-100' } }, 

 

I will do - is this a known issue then?

Share this post


Link to post
Share on other sites

I stumbled across this solution a few times. There is/was a bug in CKeditor which affected those multiple class setups.

  • Like 2

Share this post


Link to post
Share on other sites
On 9/20/2019 at 7:18 PM, wbmnfktr said:

Try adding the classes in alphabetical order.


{ name: 'Left Aligned Photo', element: 'img', attributes: { 'class': 'float-md-left img-fluid' } },
{ name: 'Right Aligned Photo', element: 'img', attributes: { 'class': 'float-md-right img-fluid' } },
{ name: 'Centered Photo', element: 'img', attributes: { 'class': 'img-fluid w-100' } }, 

 

Sorry for keeping you in suspense... but crazily I can confirm this works! Thanks for your help 😄

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Roberts R
      Hello.
      I never though about it before but when I insert image into CKeditor field I don't get ALT tag filled from image that has it. Do I have to do it manualy for inserted image or Im doing something wrong?
       
    • By Robin S
      If you've ever needed to insert links to a large number of files within CKEditor you may have found that the standard PW link modal is a somewhat slow way to do it.
      This module provides a quicker way to insert links to files on the page being edited. You can insert a link to an individual file, or insert an unordered list of links to all files on the page with a single click.
      CKEditor Link Files
      Adds a menu to CKEditor to allow the quick insertion of links to files on the page being edited.

      Features
      Hover a menu item to see the "Description" of the corresponding file (if present). Click a menu item to insert a link to the corresponding file at the current cursor position. The filename is used as the link text. If you Alt-click a menu item the file description is used as the link text (with fallback to filename if no description entered). If text is currently selected in the editor then the selected text is used as the link text. Click "* Insert links to all files *" to insert an unordered list of links to all files on the page. Also works with the Alt-click option. Menu is built via AJAX so newly uploaded files are included in the menu without the page needing to be saved. However, descriptions are not available for newly uploaded files until the page is saved. There is an option in the module config to include files from Repeater fields in the edited page. Nested Repeater fields (files inside a Repeater inside another Repeater) are not supported. Installation
      Install the CKEditor Link Files module.
      For any CKEditor field where you want the "Insert link to file" dropdown menu to appear in the CKEditor toolbar, visit the field settings and add "LinkFilesMenu" to the "CKEditor Toolbar" settings field.
       
      http://modules.processwire.com/modules/cke-link-files/
      https://github.com/Toutouwai/CkeLinkFiles
    • By iipa
      I have a CKEditor Textarea in a page template. Some users like to add text in them by pasting from Word document. This leads to internal server error when saving page. When using paste without formatting (cmd + shift + V), page is saved normally, so I assume error has something to do with Word's hidden characters that cause issues in many other programs as well. (I don't have Word myself, so I debugged this with video chat with user. I forgot to ask to check code view, so I'm not sure if they are visible there.)
      Is there a way in ProcessWire/PHP to sanitize Textarea input from these hidden characters, or can I prevent this by changing editor settings (listed below, if it helps)? I don't like leaving error handling rely to user action - somebody always forgets to do things specific way and it weakens user experience.
      Textarea formatting: none (htmlspecialchars off) field type: CKEditor content type: markup/html experimental markup/html settings: all on acf: on html purifier: on additional purify settings: all on extra allowed content: none add-ons: pwimage, pwlink, sourcedialog sourcedialog settings: none disabled add-ons: image, magicline  
    • By Gadgetto
      Hello,
      is it possible to configure CKEditor to have syntax highlighting enabled in Source and/or Sourcedialog? Coming from MODX i had this feature enabled and now I'm trying to find a solution for PW too.
      I'd like to have both the WysiWyg Editor and the Source editor with syntax highlighting enabled in on field.
      Andy plugins to achieve this?
      Greetings,
      Martin
    • By Smirftsch
      I've got some odd problem adding additional styles to mystyles.js. After reading some and following the article here: https://github.com/ryancramerdesign/ProcessWire/blob/dev/wire/modules/Inputfield/InputfieldCKEditor/README.md#custom-editor-js-styles-set
      I was able to add a custom style. So far so good 😉
      It is displayed in the Styles menu and can be selected there. Now the odd thing starts, if I add a custom style like this:
       
      ... { name: 'Box Top', element: 'span',attributes: { 'class': 'box_top' } }, { name: 'Box Bottom', element: 'span', attributes: { 'class': 'box_bottom' } }  
      it works and can be selected just fine.
      However, if I add this:
      { name: 'Box Top', element: 'div',attributes: { 'class': 'box_top' } }, { name: 'Box Bottom', element: 'div', attributes: { 'class': 'box_bottom' } } It is also displayed, can be selected - BUT - once the edit is saved, it is gone, won't be displayed in the page and won't be shown anymore in the editor as selected style, it goes back to "normal".
       
      Can anyone give me a hint what I missed?
×
×
  • Create New...